xref: /AOO41X/main/sw/source/ui/dialog/uiregionsw.cxx (revision efeef26f81c84063fb0a91bde3856d4a51172d90)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION
27cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <hintids.hxx>
31cdf0e10cSrcweir #include <regionsw.hxx>
32cdf0e10cSrcweir #include <svl/urihelper.hxx>
33cdf0e10cSrcweir #include <svl/PasswordHelper.hxx>
34cdf0e10cSrcweir #include <vcl/svapp.hxx>
35cdf0e10cSrcweir #include <vcl/msgbox.hxx>
36cdf0e10cSrcweir #include <svl/stritem.hxx>
37cdf0e10cSrcweir #include <svl/eitem.hxx>
38cdf0e10cSrcweir #include <sfx2/passwd.hxx>
39cdf0e10cSrcweir #include <sfx2/docfilt.hxx>
40cdf0e10cSrcweir #include <sfx2/request.hxx>
41cdf0e10cSrcweir #include <sfx2/docfile.hxx>
42cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
43cdf0e10cSrcweir #include <sfx2/docinsert.hxx>
44cdf0e10cSrcweir #include <sfx2/filedlghelper.hxx>
45cdf0e10cSrcweir #include <editeng/sizeitem.hxx>
46cdf0e10cSrcweir #include <svtools/htmlcfg.hxx>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #include <comphelper/storagehelper.hxx>
49cdf0e10cSrcweir #include <uitool.hxx>
50cdf0e10cSrcweir #include <IMark.hxx>
51cdf0e10cSrcweir #include <section.hxx>
52cdf0e10cSrcweir #include <docary.hxx>
53cdf0e10cSrcweir #include <doc.hxx>						// fuers SwSectionFmt-Array
54cdf0e10cSrcweir #include <basesh.hxx>
55cdf0e10cSrcweir #include <wdocsh.hxx>
56cdf0e10cSrcweir #include <view.hxx>
57cdf0e10cSrcweir #include <swmodule.hxx>
58cdf0e10cSrcweir #include <wrtsh.hxx>
59cdf0e10cSrcweir #include <swundo.hxx>               	// fuer Undo-Ids
60cdf0e10cSrcweir #include <column.hxx>
61cdf0e10cSrcweir #include <fmtfsize.hxx>
62cdf0e10cSrcweir #include <swunodef.hxx>
63cdf0e10cSrcweir #include <shellio.hxx>
64cdf0e10cSrcweir 
65cdf0e10cSrcweir #include <helpid.h>
66cdf0e10cSrcweir #include <cmdid.h>
67cdf0e10cSrcweir #include <regionsw.hrc>
68cdf0e10cSrcweir #include <comcore.hrc>
69cdf0e10cSrcweir #include <globals.hrc>
70cdf0e10cSrcweir #include <sfx2/bindings.hxx>
71cdf0e10cSrcweir #include <svx/htmlmode.hxx>
72cdf0e10cSrcweir #include <svx/dlgutil.hxx>
73cdf0e10cSrcweir #include <svx/dialogs.hrc>
74cdf0e10cSrcweir #include <svx/svxdlg.hxx>
75cdf0e10cSrcweir #include <svx/flagsdef.hxx>
76cdf0e10cSrcweir 
77cdf0e10cSrcweir using namespace ::com::sun::star;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 
80cdf0e10cSrcweir // sw/inc/docary.hxx
81cdf0e10cSrcweir SV_IMPL_PTRARR( SwSectionFmts, SwSectionFmtPtr )
82cdf0e10cSrcweir 
83cdf0e10cSrcweir #define FILE_NAME_LENGTH 17
84cdf0e10cSrcweir 
85cdf0e10cSrcweir static void   lcl_ReadSections( SfxMedium& rMedium, ComboBox& rBox );
86cdf0e10cSrcweir 
87cdf0e10cSrcweir void lcl_FillList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAvailNames, const SwSectionFmt* pNewFmt )
88cdf0e10cSrcweir {
89cdf0e10cSrcweir     const SwSectionFmt* pFmt;
90cdf0e10cSrcweir     if( !pNewFmt )
91cdf0e10cSrcweir     {
92cdf0e10cSrcweir         sal_uInt16 nCount = rSh.GetSectionFmtCount();
93cdf0e10cSrcweir         for(sal_uInt16 i=0;i<nCount;i++)
94cdf0e10cSrcweir         {
95cdf0e10cSrcweir             SectionType eTmpType;
96cdf0e10cSrcweir             if( !(pFmt = &rSh.GetSectionFmt(i))->GetParent() &&
97cdf0e10cSrcweir                     pFmt->IsInNodesArr() &&
98cdf0e10cSrcweir                     (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
99cdf0e10cSrcweir                     && TOX_HEADER_SECTION != eTmpType )
100cdf0e10cSrcweir             {
101cdf0e10cSrcweir                     String* pString =
102cdf0e10cSrcweir                         new String(pFmt->GetSection()->GetSectionName());
103cdf0e10cSrcweir                     if(pAvailNames)
104cdf0e10cSrcweir                         pAvailNames->InsertEntry(*pString);
105cdf0e10cSrcweir                     rSubRegions.InsertEntry(*pString);
106cdf0e10cSrcweir                     lcl_FillList( rSh, rSubRegions, pAvailNames, pFmt );
107cdf0e10cSrcweir             }
108cdf0e10cSrcweir         }
109cdf0e10cSrcweir     }
110cdf0e10cSrcweir     else
111cdf0e10cSrcweir     {
112cdf0e10cSrcweir         SwSections aTmpArr;
113cdf0e10cSrcweir         sal_uInt16 nCnt = pNewFmt->GetChildSections(aTmpArr,SORTSECT_POS);
114cdf0e10cSrcweir         if( nCnt )
115cdf0e10cSrcweir         {
116cdf0e10cSrcweir             SectionType eTmpType;
117cdf0e10cSrcweir             for( sal_uInt16 n = 0; n < nCnt; ++n )
118cdf0e10cSrcweir                 if( (pFmt = aTmpArr[n]->GetFmt())->IsInNodesArr()&&
119cdf0e10cSrcweir                     (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
120cdf0e10cSrcweir                     && TOX_HEADER_SECTION != eTmpType )
121cdf0e10cSrcweir                 {
122cdf0e10cSrcweir                     String* pString =
123cdf0e10cSrcweir                         new String(pFmt->GetSection()->GetSectionName());
124cdf0e10cSrcweir                     if(pAvailNames)
125cdf0e10cSrcweir                         pAvailNames->InsertEntry(*pString);
126cdf0e10cSrcweir                     rSubRegions.InsertEntry(*pString);
127cdf0e10cSrcweir                     lcl_FillList( rSh, rSubRegions, pAvailNames, pFmt );
128cdf0e10cSrcweir                 }
129cdf0e10cSrcweir         }
130cdf0e10cSrcweir     }
131cdf0e10cSrcweir }
132cdf0e10cSrcweir 
133cdf0e10cSrcweir void lcl_FillSubRegionList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAvailNames )
134cdf0e10cSrcweir {
135cdf0e10cSrcweir     lcl_FillList( rSh, rSubRegions, pAvailNames, 0 );
136cdf0e10cSrcweir     IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
137cdf0e10cSrcweir     for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin();
138cdf0e10cSrcweir         ppMark != pMarkAccess->getMarksEnd();
139cdf0e10cSrcweir         ppMark++)
140cdf0e10cSrcweir     {
141cdf0e10cSrcweir         const ::sw::mark::IMark* pBkmk = ppMark->get();
142cdf0e10cSrcweir         if( pBkmk->IsExpanded() )
143cdf0e10cSrcweir             rSubRegions.InsertEntry( pBkmk->GetName() );
144cdf0e10cSrcweir     }
145cdf0e10cSrcweir }
146cdf0e10cSrcweir 
147cdf0e10cSrcweir /* -----------------25.06.99 15:38-------------------
148cdf0e10cSrcweir 
149cdf0e10cSrcweir  --------------------------------------------------*/
150cdf0e10cSrcweir class SwTestPasswdDlg : public SfxPasswordDialog
151cdf0e10cSrcweir {
152cdf0e10cSrcweir public:
153cdf0e10cSrcweir 		SwTestPasswdDlg(Window* pParent) :
154cdf0e10cSrcweir 		SfxPasswordDialog(pParent)
155cdf0e10cSrcweir 		{
156cdf0e10cSrcweir 			SetHelpId(HID_DLG_PASSWD_SECTION);
157cdf0e10cSrcweir 		}
158cdf0e10cSrcweir };
159cdf0e10cSrcweir 
160cdf0e10cSrcweir /*----------------------------------------------------------------------------
161cdf0e10cSrcweir  Beschreibung: User Data Klasse fuer Bereichsinformationen
162cdf0e10cSrcweir ----------------------------------------------------------------------------*/
163cdf0e10cSrcweir 
164cdf0e10cSrcweir class SectRepr
165cdf0e10cSrcweir {
166cdf0e10cSrcweir private:
167cdf0e10cSrcweir     SwSectionData           m_SectionData;
168cdf0e10cSrcweir     SwFmtCol                m_Col;
169cdf0e10cSrcweir     SvxBrushItem            m_Brush;
170cdf0e10cSrcweir     SwFmtFtnAtTxtEnd        m_FtnNtAtEnd;
171cdf0e10cSrcweir     SwFmtEndAtTxtEnd        m_EndNtAtEnd;
172cdf0e10cSrcweir     SwFmtNoBalancedColumns  m_Balance;
173cdf0e10cSrcweir     SvxFrameDirectionItem   m_FrmDirItem;
174cdf0e10cSrcweir     SvxLRSpaceItem          m_LRSpaceItem;
175cdf0e10cSrcweir     sal_uInt16                  m_nArrPos;
176cdf0e10cSrcweir     // zeigt an, ob evtl. Textinhalt im Bereich ist
177cdf0e10cSrcweir     bool                    m_bContent  : 1;
178cdf0e10cSrcweir     // fuer Multiselektion erst markieren, dann mit der TreeListBox arbeiten!
179cdf0e10cSrcweir     bool                    m_bSelected : 1;
180cdf0e10cSrcweir     uno::Sequence<sal_Int8> m_TempPasswd;
181cdf0e10cSrcweir 
182cdf0e10cSrcweir public:
183cdf0e10cSrcweir     SectRepr(sal_uInt16 nPos, SwSection& rSect);
184cdf0e10cSrcweir     bool    operator==(SectRepr& rSectRef) const
185cdf0e10cSrcweir             { return m_nArrPos == rSectRef.GetArrPos(); }
186cdf0e10cSrcweir 
187cdf0e10cSrcweir     bool    operator< (SectRepr& rSectRef) const
188cdf0e10cSrcweir             { return m_nArrPos <  rSectRef.GetArrPos(); }
189cdf0e10cSrcweir 
190cdf0e10cSrcweir     SwSectionData &     GetSectionData()        { return m_SectionData; }
191cdf0e10cSrcweir     SwSectionData const&GetSectionData() const  { return m_SectionData; }
192cdf0e10cSrcweir     SwFmtCol&               GetCol()            { return m_Col; }
193cdf0e10cSrcweir     SvxBrushItem&           GetBackground()     { return m_Brush; }
194cdf0e10cSrcweir     SwFmtFtnAtTxtEnd&       GetFtnNtAtEnd()     { return m_FtnNtAtEnd; }
195cdf0e10cSrcweir     SwFmtEndAtTxtEnd&       GetEndNtAtEnd()     { return m_EndNtAtEnd; }
196cdf0e10cSrcweir     SwFmtNoBalancedColumns& GetBalance()        { return m_Balance; }
197cdf0e10cSrcweir     SvxFrameDirectionItem&  GetFrmDir()         { return m_FrmDirItem; }
198cdf0e10cSrcweir     SvxLRSpaceItem&         GetLRSpace()        { return m_LRSpaceItem; }
199cdf0e10cSrcweir 
200cdf0e10cSrcweir     sal_uInt16              GetArrPos() const { return m_nArrPos; }
201cdf0e10cSrcweir     String              GetFile() const;
202cdf0e10cSrcweir     String              GetSubRegion() const;
203cdf0e10cSrcweir     void                SetFile(String const& rFile);
204cdf0e10cSrcweir     void                SetFilter(String const& rFilter);
205cdf0e10cSrcweir     void                SetSubRegion(String const& rSubRegion);
206cdf0e10cSrcweir 
207cdf0e10cSrcweir     bool                IsContent() { return m_bContent; }
208cdf0e10cSrcweir     void                SetContent(bool const bValue) { m_bContent = bValue; }
209cdf0e10cSrcweir 
210cdf0e10cSrcweir     void                SetSelected() { m_bSelected = true; }
211cdf0e10cSrcweir     bool                IsSelected() const { return m_bSelected; }
212cdf0e10cSrcweir 
213cdf0e10cSrcweir     uno::Sequence<sal_Int8> & GetTempPasswd() { return m_TempPasswd; }
214cdf0e10cSrcweir     void SetTempPasswd(const uno::Sequence<sal_Int8> & rPasswd)
215cdf0e10cSrcweir         { m_TempPasswd = rPasswd; }
216cdf0e10cSrcweir };
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 
219cdf0e10cSrcweir SV_IMPL_OP_PTRARR_SORT( SectReprArr, SectReprPtr )
220cdf0e10cSrcweir 
221cdf0e10cSrcweir SectRepr::SectRepr( sal_uInt16 nPos, SwSection& rSect )
222cdf0e10cSrcweir     : m_SectionData( rSect )
223cdf0e10cSrcweir     , m_Brush( RES_BACKGROUND )
224cdf0e10cSrcweir     , m_FrmDirItem( FRMDIR_ENVIRONMENT, RES_FRAMEDIR )
225cdf0e10cSrcweir     , m_LRSpaceItem( RES_LR_SPACE )
226cdf0e10cSrcweir     , m_nArrPos(nPos)
227cdf0e10cSrcweir     , m_bContent(m_SectionData.GetLinkFileName().Len() == 0)
228cdf0e10cSrcweir     , m_bSelected(false)
229cdf0e10cSrcweir {
230cdf0e10cSrcweir 	SwSectionFmt *pFmt = rSect.GetFmt();
231cdf0e10cSrcweir 	if( pFmt )
232cdf0e10cSrcweir 	{
233cdf0e10cSrcweir         m_Col = pFmt->GetCol();
234cdf0e10cSrcweir         m_Brush = pFmt->GetBackground();
235cdf0e10cSrcweir         m_FtnNtAtEnd = pFmt->GetFtnAtTxtEnd();
236cdf0e10cSrcweir         m_EndNtAtEnd = pFmt->GetEndAtTxtEnd();
237cdf0e10cSrcweir         m_Balance.SetValue(pFmt->GetBalancedColumns().GetValue());
238cdf0e10cSrcweir         m_FrmDirItem = pFmt->GetFrmDir();
239cdf0e10cSrcweir         m_LRSpaceItem = pFmt->GetLRSpace();
240cdf0e10cSrcweir 	}
241cdf0e10cSrcweir }
242cdf0e10cSrcweir 
243cdf0e10cSrcweir void SectRepr::SetFile( const String& rFile )
244cdf0e10cSrcweir {
245cdf0e10cSrcweir 	String sNewFile( INetURLObject::decode( rFile, INET_HEX_ESCAPE,
246cdf0e10cSrcweir 						   				INetURLObject::DECODE_UNAMBIGUOUS,
247cdf0e10cSrcweir 										RTL_TEXTENCODING_UTF8 ));
248cdf0e10cSrcweir     String sOldFileName( m_SectionData.GetLinkFileName() );
249cdf0e10cSrcweir     String sSub( sOldFileName.GetToken( 2, sfx2::cTokenSeperator ) );
250cdf0e10cSrcweir 
251cdf0e10cSrcweir 	if( rFile.Len() || sSub.Len() )
252cdf0e10cSrcweir 	{
253cdf0e10cSrcweir         sNewFile += sfx2::cTokenSeperator;
254cdf0e10cSrcweir 		if( rFile.Len() ) // Filter nur mit FileName
255cdf0e10cSrcweir             sNewFile += sOldFileName.GetToken( 1, sfx2::cTokenSeperator );
256cdf0e10cSrcweir 
257cdf0e10cSrcweir         sNewFile += sfx2::cTokenSeperator;
258cdf0e10cSrcweir 		sNewFile +=	sSub;
259cdf0e10cSrcweir 	}
260cdf0e10cSrcweir 
261cdf0e10cSrcweir     m_SectionData.SetLinkFileName( sNewFile );
262cdf0e10cSrcweir 
263cdf0e10cSrcweir 	if( rFile.Len() || sSub.Len() )
264cdf0e10cSrcweir     {
265cdf0e10cSrcweir         m_SectionData.SetType( FILE_LINK_SECTION );
266cdf0e10cSrcweir     }
267cdf0e10cSrcweir     else
268cdf0e10cSrcweir     {
269cdf0e10cSrcweir         m_SectionData.SetType( CONTENT_SECTION );
270cdf0e10cSrcweir     }
271cdf0e10cSrcweir }
272cdf0e10cSrcweir 
273cdf0e10cSrcweir 
274cdf0e10cSrcweir void SectRepr::SetFilter( const String& rFilter )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir 	String sNewFile;
277cdf0e10cSrcweir     String sOldFileName( m_SectionData.GetLinkFileName() );
278cdf0e10cSrcweir     String sFile( sOldFileName.GetToken( 0, sfx2::cTokenSeperator ) );
279cdf0e10cSrcweir     String sSub( sOldFileName.GetToken( 2, sfx2::cTokenSeperator ) );
280cdf0e10cSrcweir 
281cdf0e10cSrcweir 	if( sFile.Len() )
282cdf0e10cSrcweir         (((( sNewFile = sFile ) += sfx2::cTokenSeperator ) += rFilter )
283cdf0e10cSrcweir                                 += sfx2::cTokenSeperator ) += sSub;
284cdf0e10cSrcweir 	else if( sSub.Len() )
285cdf0e10cSrcweir         (( sNewFile = sfx2::cTokenSeperator ) += sfx2::cTokenSeperator ) += sSub;
286cdf0e10cSrcweir 
287cdf0e10cSrcweir     m_SectionData.SetLinkFileName( sNewFile );
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 	if( sNewFile.Len() )
290cdf0e10cSrcweir     {
291cdf0e10cSrcweir         m_SectionData.SetType( FILE_LINK_SECTION );
292cdf0e10cSrcweir     }
293cdf0e10cSrcweir }
294cdf0e10cSrcweir 
295cdf0e10cSrcweir void SectRepr::SetSubRegion(const String& rSubRegion)
296cdf0e10cSrcweir {
297cdf0e10cSrcweir 	String sNewFile;
298cdf0e10cSrcweir     String sOldFileName( m_SectionData.GetLinkFileName() );
299cdf0e10cSrcweir     String sFilter( sOldFileName.GetToken( 1, sfx2::cTokenSeperator ) );
300cdf0e10cSrcweir     sOldFileName = sOldFileName.GetToken( 0, sfx2::cTokenSeperator );
301cdf0e10cSrcweir 
302cdf0e10cSrcweir 	if( rSubRegion.Len() || sOldFileName.Len() )
303cdf0e10cSrcweir         (((( sNewFile = sOldFileName ) += sfx2::cTokenSeperator ) += sFilter )
304cdf0e10cSrcweir                                        += sfx2::cTokenSeperator ) += rSubRegion;
305cdf0e10cSrcweir 
306cdf0e10cSrcweir     m_SectionData.SetLinkFileName( sNewFile );
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 	if( rSubRegion.Len() || sOldFileName.Len() )
309cdf0e10cSrcweir     {
310cdf0e10cSrcweir         m_SectionData.SetType( FILE_LINK_SECTION );
311cdf0e10cSrcweir     }
312cdf0e10cSrcweir     else
313cdf0e10cSrcweir     {
314cdf0e10cSrcweir         m_SectionData.SetType( CONTENT_SECTION );
315cdf0e10cSrcweir     }
316cdf0e10cSrcweir }
317cdf0e10cSrcweir 
318cdf0e10cSrcweir 
319cdf0e10cSrcweir String SectRepr::GetFile() const
320cdf0e10cSrcweir {
321cdf0e10cSrcweir     String sLinkFile( m_SectionData.GetLinkFileName() );
322cdf0e10cSrcweir 	if( sLinkFile.Len() )
323cdf0e10cSrcweir 	{
324cdf0e10cSrcweir         if (DDE_LINK_SECTION == m_SectionData.GetType())
325cdf0e10cSrcweir         {
326cdf0e10cSrcweir             sal_uInt16 n = sLinkFile.SearchAndReplace( sfx2::cTokenSeperator, ' ' );
327cdf0e10cSrcweir             sLinkFile.SearchAndReplace( sfx2::cTokenSeperator, ' ',  n );
328cdf0e10cSrcweir 		}
329cdf0e10cSrcweir 		else
330cdf0e10cSrcweir             sLinkFile = INetURLObject::decode( sLinkFile.GetToken( 0,
331cdf0e10cSrcweir                                                sfx2::cTokenSeperator ),
332cdf0e10cSrcweir 										INET_HEX_ESCAPE,
333cdf0e10cSrcweir 						   				INetURLObject::DECODE_UNAMBIGUOUS,
334cdf0e10cSrcweir 										RTL_TEXTENCODING_UTF8 );
335cdf0e10cSrcweir 	}
336cdf0e10cSrcweir 	return sLinkFile;
337cdf0e10cSrcweir }
338cdf0e10cSrcweir 
339cdf0e10cSrcweir 
340cdf0e10cSrcweir String SectRepr::GetSubRegion() const
341cdf0e10cSrcweir {
342cdf0e10cSrcweir     String sLinkFile( m_SectionData.GetLinkFileName() );
343cdf0e10cSrcweir 	if( sLinkFile.Len() )
344cdf0e10cSrcweir         sLinkFile = sLinkFile.GetToken( 2, sfx2::cTokenSeperator );
345cdf0e10cSrcweir 	return sLinkFile;
346cdf0e10cSrcweir }
347cdf0e10cSrcweir 
348cdf0e10cSrcweir 
349cdf0e10cSrcweir 
350cdf0e10cSrcweir /*----------------------------------------------------------------------------
351cdf0e10cSrcweir  Beschreibung: Dialog Bearbeiten Bereiche
352cdf0e10cSrcweir ----------------------------------------------------------------------------*/
353cdf0e10cSrcweir 
354cdf0e10cSrcweir //---------------------------------------------------------------------
355cdf0e10cSrcweir 
356cdf0e10cSrcweir SwEditRegionDlg::SwEditRegionDlg( Window* pParent, SwWrtShell& rWrtSh )
357cdf0e10cSrcweir 	: SfxModalDialog( pParent, SW_RES(MD_EDIT_REGION) ),
358cdf0e10cSrcweir     aNameFL             ( this, SW_RES( FL_NAME ) ),
359cdf0e10cSrcweir     aCurName            ( this, SW_RES( ED_RANAME ) ),
360cdf0e10cSrcweir     aTree               ( this, SW_RES( TLB_SECTION )),
361cdf0e10cSrcweir     aLinkFL             ( this, SW_RES( FL_LINK ) ),
362cdf0e10cSrcweir     aFileCB             ( this, SW_RES( CB_FILE ) ),
363cdf0e10cSrcweir 	aDDECB              ( this, SW_RES( CB_DDE ) ) ,
364cdf0e10cSrcweir     aFileNameFT         ( this, SW_RES( FT_FILE ) ) ,
365cdf0e10cSrcweir 	aDDECommandFT       ( this, SW_RES( FT_DDE ) ) ,
366cdf0e10cSrcweir 	aFileNameED         ( this, SW_RES( ED_FILE ) ),
367cdf0e10cSrcweir     aFilePB             ( this, SW_RES( PB_FILE ) ),
368cdf0e10cSrcweir     aSubRegionFT        ( this, SW_RES( FT_SUBREG ) ) ,
369cdf0e10cSrcweir 	aSubRegionED        ( this, SW_RES( LB_SUBREG ) ) ,
370cdf0e10cSrcweir     bSubRegionsFilled( false ),
371cdf0e10cSrcweir 
372cdf0e10cSrcweir     aProtectFL          ( this, SW_RES( FL_PROTECT ) ),
373cdf0e10cSrcweir     aProtectCB          ( this, SW_RES( CB_PROTECT ) ),
374cdf0e10cSrcweir 	aPasswdCB			( this, SW_RES( CB_PASSWD ) ),
375cdf0e10cSrcweir     aPasswdPB           ( this, SW_RES( PB_PASSWD ) ),
376cdf0e10cSrcweir 
377cdf0e10cSrcweir     aHideFL             ( this, SW_RES( FL_HIDE ) ),
378cdf0e10cSrcweir     aHideCB             ( this, SW_RES( CB_HIDE ) ),
379cdf0e10cSrcweir     aConditionFT        ( this, SW_RES( FT_CONDITION ) ),
380cdf0e10cSrcweir     aConditionED        ( this, SW_RES( ED_CONDITION ) ),
381cdf0e10cSrcweir 
382cdf0e10cSrcweir     // --> FME 2004-06-22 #114856# edit in readonly sections
383cdf0e10cSrcweir     aPropertiesFL       ( this, SW_RES( FL_PROPERTIES ) ),
384cdf0e10cSrcweir     aEditInReadonlyCB   ( this, SW_RES( CB_EDIT_IN_READONLY ) ),
385cdf0e10cSrcweir     // <--
386cdf0e10cSrcweir 
387cdf0e10cSrcweir     aOK                 ( this, SW_RES( PB_OK ) ),
388cdf0e10cSrcweir     aCancel             ( this, SW_RES( PB_CANCEL ) ),
389cdf0e10cSrcweir 	aOptionsPB  		( this, SW_RES( PB_OPTIONS ) ),
390cdf0e10cSrcweir 	aDismiss			( this, SW_RES( CB_DISMISS ) ),
391cdf0e10cSrcweir 	aHelp               ( this, SW_RES( PB_HELP ) ),
392cdf0e10cSrcweir 
393cdf0e10cSrcweir     aImageIL            (       SW_RES(IL_BITMAPS)),
394cdf0e10cSrcweir     aImageILH           (       SW_RES(ILH_BITMAPS)),
395cdf0e10cSrcweir 
396cdf0e10cSrcweir     rSh( rWrtSh ),
397cdf0e10cSrcweir     pAktEntry( 0 ),
398cdf0e10cSrcweir     m_pDocInserter        ( NULL ),
399cdf0e10cSrcweir     m_pOldDefDlgParent    ( NULL ),
400cdf0e10cSrcweir     bDontCheckPasswd    ( sal_True)
401cdf0e10cSrcweir {
402cdf0e10cSrcweir 	FreeResource();
403cdf0e10cSrcweir 
404cdf0e10cSrcweir     bWeb = 0 != PTR_CAST( SwWebDocShell, rSh.GetView().GetDocShell() );
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 	aTree.SetSelectHdl		( LINK( this, SwEditRegionDlg, GetFirstEntryHdl));
407cdf0e10cSrcweir 	aTree.SetDeselectHdl	( LINK( this, SwEditRegionDlg, DeselectHdl));
408cdf0e10cSrcweir 	aCurName.SetModifyHdl	( LINK( this, SwEditRegionDlg, NameEditHdl));
409cdf0e10cSrcweir 	aConditionED.SetModifyHdl( LINK( this, SwEditRegionDlg, ConditionEditHdl));
410cdf0e10cSrcweir 	aOK.SetClickHdl			( LINK( this, SwEditRegionDlg, OkHdl));
411cdf0e10cSrcweir 	aPasswdCB.SetClickHdl	( LINK( this, SwEditRegionDlg, ChangePasswdHdl));
412cdf0e10cSrcweir     aPasswdPB.SetClickHdl   ( LINK( this, SwEditRegionDlg, ChangePasswdHdl));
413cdf0e10cSrcweir 	aHideCB.SetClickHdl		( LINK( this, SwEditRegionDlg, ChangeHideHdl));
414cdf0e10cSrcweir     // --> FME 2004-06-22 #114856# edit in readonly sections
415cdf0e10cSrcweir     aEditInReadonlyCB.SetClickHdl ( LINK( this, SwEditRegionDlg, ChangeEditInReadonlyHdl));
416cdf0e10cSrcweir     // <--
417cdf0e10cSrcweir 
418cdf0e10cSrcweir     aOptionsPB.Show();
419cdf0e10cSrcweir 	aOptionsPB.SetClickHdl	( LINK( this, SwEditRegionDlg, OptionsHdl));
420cdf0e10cSrcweir 	aProtectCB.SetClickHdl	( LINK( this, SwEditRegionDlg, ChangeProtectHdl));
421cdf0e10cSrcweir 	aDismiss.SetClickHdl	( LINK( this, SwEditRegionDlg, ChangeDismissHdl));
422cdf0e10cSrcweir 	aFileCB.SetClickHdl     ( LINK( this, SwEditRegionDlg, UseFileHdl ));
423cdf0e10cSrcweir 	aFilePB.SetClickHdl     ( LINK( this, SwEditRegionDlg, FileSearchHdl ));
424cdf0e10cSrcweir 	aFileNameED.SetModifyHdl( LINK( this, SwEditRegionDlg, FileNameHdl ));
425cdf0e10cSrcweir 	aSubRegionED.SetModifyHdl( LINK( this, SwEditRegionDlg, FileNameHdl ));
426cdf0e10cSrcweir     aSubRegionED.AddEventListener( LINK( this, SwEditRegionDlg, SubRegionEventHdl ));
427cdf0e10cSrcweir     aSubRegionED.EnableAutocomplete( sal_True, sal_True );
428cdf0e10cSrcweir 
429cdf0e10cSrcweir 	aTree.SetHelpId(HID_REGION_TREE);
430cdf0e10cSrcweir 	aTree.SetSelectionMode( MULTIPLE_SELECTION );
431cdf0e10cSrcweir 	aTree.SetStyle(aTree.GetStyle()|WB_HASBUTTONSATROOT|WB_CLIPCHILDREN|WB_HSCROLL);
432cdf0e10cSrcweir 	aTree.SetSpaceBetweenEntries(0);
433cdf0e10cSrcweir 
434cdf0e10cSrcweir 	if(bWeb)
435cdf0e10cSrcweir 	{
436cdf0e10cSrcweir         aConditionFT         .Hide();
437cdf0e10cSrcweir         aConditionED    .Hide();
438cdf0e10cSrcweir 		aPasswdCB		.Hide();
439cdf0e10cSrcweir 		aHideCB			.Hide();
440cdf0e10cSrcweir 
441cdf0e10cSrcweir 		aDDECB              .Hide();
442cdf0e10cSrcweir 		aDDECommandFT       .Hide();
443cdf0e10cSrcweir 	}
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 	aDDECB.SetClickHdl		( LINK( this, SwEditRegionDlg, DDEHdl ));
446cdf0e10cSrcweir 
447cdf0e10cSrcweir     //Ermitteln der vorhandenen Bereiche
448cdf0e10cSrcweir 	pCurrSect = rSh.GetCurrSection();
449cdf0e10cSrcweir 	RecurseList( 0, 0 );
450cdf0e10cSrcweir 	//falls der Cursor nicht in einem Bereich steht,
451cdf0e10cSrcweir 	//wird immer der erste selektiert
452cdf0e10cSrcweir 	if( !aTree.FirstSelected() && aTree.First() )
453cdf0e10cSrcweir 		aTree.Select( aTree.First() );
454cdf0e10cSrcweir 	aTree.Show();
455cdf0e10cSrcweir     bDontCheckPasswd = sal_False;
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 	aPasswdPB.SetAccessibleRelationMemberOf(&aProtectFL);
458cdf0e10cSrcweir 	aPasswdPB.SetAccessibleRelationLabeledBy(&aPasswdCB);
459cdf0e10cSrcweir     aSubRegionED.SetAccessibleName(aSubRegionFT.GetText());
460cdf0e10cSrcweir }
461cdf0e10cSrcweir /* -----------------------------26.04.01 14:56--------------------------------
462cdf0e10cSrcweir 
463cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
464cdf0e10cSrcweir sal_Bool SwEditRegionDlg::CheckPasswd(CheckBox* pBox)
465cdf0e10cSrcweir {
466cdf0e10cSrcweir     if(bDontCheckPasswd)
467cdf0e10cSrcweir         return sal_True;
468cdf0e10cSrcweir     sal_Bool bRet = sal_True;
469cdf0e10cSrcweir     SvLBoxEntry* pEntry = aTree.FirstSelected();
470cdf0e10cSrcweir     while( pEntry )
471cdf0e10cSrcweir 	{
472cdf0e10cSrcweir 		SectReprPtr pRepr = (SectReprPtr)pEntry->GetUserData();
473cdf0e10cSrcweir         if (!pRepr->GetTempPasswd().getLength()
474cdf0e10cSrcweir             && pRepr->GetSectionData().GetPassword().getLength())
475cdf0e10cSrcweir         {
476cdf0e10cSrcweir             SwTestPasswdDlg aPasswdDlg(this);
477cdf0e10cSrcweir             bRet = sal_False;
478cdf0e10cSrcweir             if (aPasswdDlg.Execute())
479cdf0e10cSrcweir             {
480cdf0e10cSrcweir                 String sNewPasswd( aPasswdDlg.GetPassword() );
481cdf0e10cSrcweir                 UNO_NMSPC::Sequence <sal_Int8 > aNewPasswd;
482cdf0e10cSrcweir                 SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
483cdf0e10cSrcweir                 if (SvPasswordHelper::CompareHashPassword(
484cdf0e10cSrcweir                         pRepr->GetSectionData().GetPassword(), sNewPasswd))
485cdf0e10cSrcweir                 {
486cdf0e10cSrcweir                     pRepr->SetTempPasswd(aNewPasswd);
487cdf0e10cSrcweir                     bRet = sal_True;
488cdf0e10cSrcweir                 }
489cdf0e10cSrcweir                 else
490cdf0e10cSrcweir                 {
491cdf0e10cSrcweir                     InfoBox(this, SW_RES(REG_WRONG_PASSWORD)).Execute();
492cdf0e10cSrcweir                 }
493cdf0e10cSrcweir             }
494cdf0e10cSrcweir         }
495cdf0e10cSrcweir         pEntry = aTree.NextSelected(pEntry);
496cdf0e10cSrcweir     }
497cdf0e10cSrcweir     if(!bRet && pBox)
498cdf0e10cSrcweir     {
499cdf0e10cSrcweir         //reset old button state
500cdf0e10cSrcweir         if(pBox->IsTriStateEnabled())
501cdf0e10cSrcweir             pBox->SetState(pBox->IsChecked() ? STATE_NOCHECK : STATE_DONTKNOW);
502cdf0e10cSrcweir         else
503cdf0e10cSrcweir             pBox->Check(!pBox->IsChecked());
504cdf0e10cSrcweir     }
505cdf0e10cSrcweir 
506cdf0e10cSrcweir     return bRet;
507cdf0e10cSrcweir }
508cdf0e10cSrcweir /*---------------------------------------------------------------------
509cdf0e10cSrcweir 	Beschreibung: Durchsuchen nach Child-Sections, rekursiv
510cdf0e10cSrcweir ---------------------------------------------------------------------*/
511cdf0e10cSrcweir 
512cdf0e10cSrcweir void SwEditRegionDlg::RecurseList( const SwSectionFmt* pFmt, SvLBoxEntry* pEntry )
513cdf0e10cSrcweir {
514cdf0e10cSrcweir     SwSection* pSect = 0;
515cdf0e10cSrcweir 	SvLBoxEntry* pSelEntry = 0;
516cdf0e10cSrcweir 
517cdf0e10cSrcweir 	if (!pFmt)
518cdf0e10cSrcweir 	{
519cdf0e10cSrcweir 		sal_uInt16 nCount=rSh.GetSectionFmtCount();
520cdf0e10cSrcweir 		for ( sal_uInt16 n=0; n < nCount; n++ )
521cdf0e10cSrcweir 		{
522cdf0e10cSrcweir 			SectionType eTmpType;
523cdf0e10cSrcweir 			if( !( pFmt = &rSh.GetSectionFmt(n))->GetParent() &&
524cdf0e10cSrcweir 				pFmt->IsInNodesArr() &&
525cdf0e10cSrcweir 				(eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
526cdf0e10cSrcweir 				&& TOX_HEADER_SECTION != eTmpType )
527cdf0e10cSrcweir 			{
528cdf0e10cSrcweir 				SectRepr* pSectRepr = new SectRepr( n,
529cdf0e10cSrcweir 											*(pSect=pFmt->GetSection()) );
530cdf0e10cSrcweir                 Image aImg = BuildBitmap( pSect->IsProtect(),pSect->IsHidden(), sal_False);
531cdf0e10cSrcweir                 pEntry = aTree.InsertEntry(pSect->GetSectionName(), aImg, aImg);
532cdf0e10cSrcweir                 Image aHCImg = BuildBitmap( pSect->IsProtect(),pSect->IsHidden(), sal_True);
533cdf0e10cSrcweir                 aTree.SetExpandedEntryBmp(pEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
534cdf0e10cSrcweir                 aTree.SetCollapsedEntryBmp(pEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
535cdf0e10cSrcweir                 pEntry->SetUserData(pSectRepr);
536cdf0e10cSrcweir 				RecurseList( pFmt, pEntry );
537cdf0e10cSrcweir 				if (pEntry->HasChilds())
538cdf0e10cSrcweir 					aTree.Expand(pEntry);
539cdf0e10cSrcweir 				if (pCurrSect==pSect)
540cdf0e10cSrcweir 					aTree.Select(pEntry);
541cdf0e10cSrcweir 			}
542cdf0e10cSrcweir 		}
543cdf0e10cSrcweir 	}
544cdf0e10cSrcweir 	else
545cdf0e10cSrcweir 	{
546cdf0e10cSrcweir 		SwSections aTmpArr;
547cdf0e10cSrcweir 		SvLBoxEntry* pNEntry;
548cdf0e10cSrcweir 		sal_uInt16 nCnt = pFmt->GetChildSections(aTmpArr,SORTSECT_POS);
549cdf0e10cSrcweir 		if( nCnt )
550cdf0e10cSrcweir 		{
551cdf0e10cSrcweir 			for( sal_uInt16 n = 0; n < nCnt; ++n )
552cdf0e10cSrcweir 			{
553cdf0e10cSrcweir 				SectionType eTmpType;
554cdf0e10cSrcweir                 pFmt = aTmpArr[n]->GetFmt();
555cdf0e10cSrcweir 				if( pFmt->IsInNodesArr() &&
556cdf0e10cSrcweir 					(eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
557cdf0e10cSrcweir 					&& TOX_HEADER_SECTION != eTmpType )
558cdf0e10cSrcweir 				{
559cdf0e10cSrcweir 					pSect=aTmpArr[n];
560cdf0e10cSrcweir 					SectRepr* pSectRepr=new SectRepr(
561cdf0e10cSrcweir 									FindArrPos( pSect->GetFmt() ), *pSect );
562cdf0e10cSrcweir                     Image aImage = BuildBitmap( pSect->IsProtect(),
563cdf0e10cSrcweir                                             pSect->IsHidden(), sal_False);
564cdf0e10cSrcweir                     pNEntry = aTree.InsertEntry(
565cdf0e10cSrcweir                         pSect->GetSectionName(), aImage, aImage, pEntry);
566cdf0e10cSrcweir                     Image aHCImg = BuildBitmap( pSect->IsProtect(),pSect->IsHidden(), sal_True);
567cdf0e10cSrcweir                     aTree.SetExpandedEntryBmp(pEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
568cdf0e10cSrcweir                     aTree.SetCollapsedEntryBmp(pEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
569cdf0e10cSrcweir                     pNEntry->SetUserData(pSectRepr);
570cdf0e10cSrcweir 					RecurseList( aTmpArr[n]->GetFmt(), pNEntry );
571cdf0e10cSrcweir 					if( pNEntry->HasChilds())
572cdf0e10cSrcweir 						aTree.Expand(pNEntry);
573cdf0e10cSrcweir 					if (pCurrSect==pSect)
574cdf0e10cSrcweir 						pSelEntry = pNEntry;
575cdf0e10cSrcweir 				}
576cdf0e10cSrcweir 			}
577cdf0e10cSrcweir 		}
578cdf0e10cSrcweir 	}
579cdf0e10cSrcweir 	if(0 != pSelEntry)
580cdf0e10cSrcweir 	{
581cdf0e10cSrcweir 		aTree.MakeVisible(pSelEntry);
582cdf0e10cSrcweir 		aTree.Select(pSelEntry);
583cdf0e10cSrcweir 	}
584cdf0e10cSrcweir }
585cdf0e10cSrcweir /*---------------------------------------------------------------------
586cdf0e10cSrcweir 
587cdf0e10cSrcweir ---------------------------------------------------------------------*/
588cdf0e10cSrcweir 
589cdf0e10cSrcweir sal_uInt16 SwEditRegionDlg::FindArrPos(const SwSectionFmt* pFmt )
590cdf0e10cSrcweir {
591cdf0e10cSrcweir 	sal_uInt16 nCount=rSh.GetSectionFmtCount();
592cdf0e10cSrcweir 	for (sal_uInt16 i=0;i<nCount;i++)
593cdf0e10cSrcweir 		if (pFmt==&rSh.GetSectionFmt(i))
594cdf0e10cSrcweir 			return i;
595cdf0e10cSrcweir 
596cdf0e10cSrcweir 	DBG_ERROR(  "SectionFormat nicht in der Liste" );
597cdf0e10cSrcweir 	return USHRT_MAX;
598cdf0e10cSrcweir }
599cdf0e10cSrcweir /*---------------------------------------------------------------------
600cdf0e10cSrcweir  Beschreibung:
601cdf0e10cSrcweir ---------------------------------------------------------------------*/
602cdf0e10cSrcweir 
603cdf0e10cSrcweir SwEditRegionDlg::~SwEditRegionDlg( )
604cdf0e10cSrcweir {
605cdf0e10cSrcweir 	SvLBoxEntry* pEntry = aTree.First();
606cdf0e10cSrcweir 	while( pEntry )
607cdf0e10cSrcweir 	{
608cdf0e10cSrcweir 		delete (SectRepr*)pEntry->GetUserData();
609cdf0e10cSrcweir 		pEntry = aTree.Next( pEntry );
610cdf0e10cSrcweir 	}
611cdf0e10cSrcweir 
612cdf0e10cSrcweir 	aSectReprArr.DeleteAndDestroy( 0, aSectReprArr.Count() );
613cdf0e10cSrcweir     delete m_pDocInserter;
614cdf0e10cSrcweir }
615cdf0e10cSrcweir /* -----------------------------09.10.2001 15:41------------------------------
616cdf0e10cSrcweir 
617cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
618cdf0e10cSrcweir void    SwEditRegionDlg::SelectSection(const String& rSectionName)
619cdf0e10cSrcweir {
620cdf0e10cSrcweir     SvLBoxEntry* pEntry = aTree.First();
621cdf0e10cSrcweir     while(pEntry)
622cdf0e10cSrcweir     {
623cdf0e10cSrcweir         SectReprPtr pRepr = (SectReprPtr)pEntry->GetUserData();
624cdf0e10cSrcweir         if (pRepr->GetSectionData().GetSectionName() == rSectionName)
625cdf0e10cSrcweir             break;
626cdf0e10cSrcweir         pEntry = aTree.Next(pEntry);
627cdf0e10cSrcweir     }
628cdf0e10cSrcweir     if(pEntry)
629cdf0e10cSrcweir     {
630cdf0e10cSrcweir         aTree.SelectAll( sal_False);
631cdf0e10cSrcweir         aTree.Select(pEntry);
632cdf0e10cSrcweir         aTree.MakeVisible(pEntry);
633cdf0e10cSrcweir     }
634cdf0e10cSrcweir }
635cdf0e10cSrcweir /*---------------------------------------------------------------------
636cdf0e10cSrcweir 	Beschreibung: 	Selektierte Eintrag in der TreeListBox wird im
637cdf0e10cSrcweir 					Edit-Fenster angezeigt
638cdf0e10cSrcweir 					Bei Multiselektion werden einige Controls disabled
639cdf0e10cSrcweir ---------------------------------------------------------------------*/
640cdf0e10cSrcweir 
641cdf0e10cSrcweir IMPL_LINK( SwEditRegionDlg, GetFirstEntryHdl, SvTreeListBox *, pBox )
642cdf0e10cSrcweir {
643cdf0e10cSrcweir     bDontCheckPasswd = sal_True;
644cdf0e10cSrcweir     SvLBoxEntry* pEntry=pBox->FirstSelected();
645cdf0e10cSrcweir 	aHideCB		.Enable(sal_True);
646cdf0e10cSrcweir     // --> FME 2004-06-22 #114856# edit in readonly sections
647cdf0e10cSrcweir     aEditInReadonlyCB.Enable(sal_True);
648cdf0e10cSrcweir     // <--
649cdf0e10cSrcweir     aProtectCB  .Enable(sal_True);
650cdf0e10cSrcweir 	aFileCB		.Enable(sal_True);
651cdf0e10cSrcweir     UNO_NMSPC::Sequence <sal_Int8> aCurPasswd;
652cdf0e10cSrcweir 	if( 1 < pBox->GetSelectionCount() )
653cdf0e10cSrcweir 	{
654cdf0e10cSrcweir 		aHideCB.EnableTriState( sal_True );
655cdf0e10cSrcweir 		aProtectCB.EnableTriState( sal_True );
656cdf0e10cSrcweir         // --> FME 2004-06-22 #114856# edit in readonly sections
657cdf0e10cSrcweir         aEditInReadonlyCB.EnableTriState ( sal_True );
658cdf0e10cSrcweir         // <--
659cdf0e10cSrcweir         aFileCB.EnableTriState( sal_True );
660cdf0e10cSrcweir 
661cdf0e10cSrcweir         bool bHiddenValid       = true;
662cdf0e10cSrcweir         bool bProtectValid      = true;
663cdf0e10cSrcweir         bool bConditionValid    = true;
664cdf0e10cSrcweir         // --> FME 2004-06-22 #114856# edit in readonly sections
665cdf0e10cSrcweir         bool bEditInReadonlyValid = true;
666cdf0e10cSrcweir         bool bEditInReadonly    = true;
667cdf0e10cSrcweir         // <--
668cdf0e10cSrcweir         bool bHidden            = true;
669cdf0e10cSrcweir         bool bProtect           = true;
670cdf0e10cSrcweir 		String sCondition;
671cdf0e10cSrcweir 		sal_Bool bFirst 			= sal_True;
672cdf0e10cSrcweir 		sal_Bool bFileValid 		= sal_True;
673cdf0e10cSrcweir 		sal_Bool bFile 				= sal_True;
674cdf0e10cSrcweir         sal_Bool bPasswdValid       = sal_True;
675cdf0e10cSrcweir 
676cdf0e10cSrcweir 		while( pEntry )
677cdf0e10cSrcweir 		{
678cdf0e10cSrcweir 			SectRepr* pRepr=(SectRepr*) pEntry->GetUserData();
679cdf0e10cSrcweir             SwSectionData const& rData( pRepr->GetSectionData() );
680cdf0e10cSrcweir 			if(bFirst)
681cdf0e10cSrcweir 			{
682cdf0e10cSrcweir                 sCondition      = rData.GetCondition();
683cdf0e10cSrcweir                 bHidden         = rData.IsHidden();
684cdf0e10cSrcweir                 bProtect        = rData.IsProtectFlag();
685cdf0e10cSrcweir                 // --> FME 2004-06-22 #114856# edit in readonly sections
686cdf0e10cSrcweir                 bEditInReadonly = rData.IsEditInReadonlyFlag();
687cdf0e10cSrcweir                 // <--
688cdf0e10cSrcweir                 bFile           = (rData.GetType() != CONTENT_SECTION);
689cdf0e10cSrcweir                 aCurPasswd      = rData.GetPassword();
690cdf0e10cSrcweir 			}
691cdf0e10cSrcweir 			else
692cdf0e10cSrcweir 			{
693cdf0e10cSrcweir                 String sTemp(rData.GetCondition());
694cdf0e10cSrcweir 				if(sCondition != sTemp)
695cdf0e10cSrcweir 					bConditionValid = sal_False;
696cdf0e10cSrcweir                 bHiddenValid      = (bHidden == rData.IsHidden());
697cdf0e10cSrcweir                 bProtectValid     = (bProtect == rData.IsProtectFlag());
698cdf0e10cSrcweir                 // --> FME 2004-06-22 #114856# edit in readonly sections
699cdf0e10cSrcweir                 bEditInReadonlyValid =
700cdf0e10cSrcweir                     (bEditInReadonly == rData.IsEditInReadonlyFlag());
701cdf0e10cSrcweir                 // <--
702cdf0e10cSrcweir                 bFileValid        = (bFile ==
703cdf0e10cSrcweir                     (rData.GetType() != CONTENT_SECTION));
704cdf0e10cSrcweir                 bPasswdValid      = (aCurPasswd == rData.GetPassword());
705cdf0e10cSrcweir 			}
706cdf0e10cSrcweir 			pEntry = pBox->NextSelected(pEntry);
707cdf0e10cSrcweir 			bFirst = sal_False;
708cdf0e10cSrcweir 		}
709cdf0e10cSrcweir 
710cdf0e10cSrcweir 		aHideCB.SetState( !bHiddenValid ? STATE_DONTKNOW :
711cdf0e10cSrcweir 					bHidden ? STATE_CHECK : STATE_NOCHECK);
712cdf0e10cSrcweir 		aProtectCB.SetState( !bProtectValid ? STATE_DONTKNOW :
713cdf0e10cSrcweir 					bProtect ? STATE_CHECK : STATE_NOCHECK);
714cdf0e10cSrcweir         // --> FME 2004-06-22 #114856# edit in readonly sections
715cdf0e10cSrcweir         aEditInReadonlyCB.SetState( !bEditInReadonlyValid ? STATE_DONTKNOW :
716cdf0e10cSrcweir                     bEditInReadonly ? STATE_CHECK : STATE_NOCHECK);
717cdf0e10cSrcweir         // <--
718cdf0e10cSrcweir         aFileCB.SetState(!bFileValid ? STATE_DONTKNOW :
719cdf0e10cSrcweir 					bFile ? STATE_CHECK : STATE_NOCHECK);
720cdf0e10cSrcweir 
721cdf0e10cSrcweir 		if(bConditionValid)
722cdf0e10cSrcweir 			aConditionED.SetText(sCondition);
723cdf0e10cSrcweir 		else
724cdf0e10cSrcweir 		{
725cdf0e10cSrcweir //			aConditionED.SetText(aEmptyStr);
726cdf0e10cSrcweir             aConditionFT.Enable(sal_False);
727cdf0e10cSrcweir             aConditionED.Enable(sal_False);
728cdf0e10cSrcweir 		}
729cdf0e10cSrcweir 
730cdf0e10cSrcweir 		aFilePB.Enable(sal_False);
731cdf0e10cSrcweir 		aFileNameFT	.Enable(sal_False);
732cdf0e10cSrcweir 		aFileNameED	.Enable(sal_False);
733cdf0e10cSrcweir 		aSubRegionFT.Enable(sal_False);
734cdf0e10cSrcweir 		aSubRegionED.Enable(sal_False);
735cdf0e10cSrcweir //        aNameFT     .Enable(sal_False);
736cdf0e10cSrcweir 		aCurName	.Enable(sal_False);
737cdf0e10cSrcweir 		aOptionsPB	.Enable(sal_False);
738cdf0e10cSrcweir 		aDDECB   			.Enable(sal_False);
739cdf0e10cSrcweir 		aDDECommandFT       .Enable(sal_False);
740cdf0e10cSrcweir         sal_Bool bPasswdEnabled = aProtectCB.GetState() == STATE_CHECK;
741cdf0e10cSrcweir         aPasswdCB.Enable(bPasswdEnabled);
742cdf0e10cSrcweir         aPasswdPB.Enable(bPasswdEnabled);
743cdf0e10cSrcweir         if(!bPasswdValid)
744cdf0e10cSrcweir         {
745cdf0e10cSrcweir             pEntry = pBox->FirstSelected();
746cdf0e10cSrcweir             pBox->SelectAll( sal_False );
747cdf0e10cSrcweir             pBox->Select( pEntry );
748cdf0e10cSrcweir             GetFirstEntryHdl(pBox);
749cdf0e10cSrcweir             return 0;
750cdf0e10cSrcweir         }
751cdf0e10cSrcweir         else
752cdf0e10cSrcweir             aPasswdCB.Check(aCurPasswd.getLength() > 0);
753cdf0e10cSrcweir 	}
754cdf0e10cSrcweir 	else if (pEntry )
755cdf0e10cSrcweir 	{
756cdf0e10cSrcweir //        aNameFT     .Enable(sal_True);
757cdf0e10cSrcweir 		aCurName	.Enable(sal_True);
758cdf0e10cSrcweir 		aOptionsPB	.Enable(sal_True);
759cdf0e10cSrcweir 		SectRepr* pRepr=(SectRepr*) pEntry->GetUserData();
760cdf0e10cSrcweir         SwSectionData const& rData( pRepr->GetSectionData() );
761cdf0e10cSrcweir         aConditionED.SetText(rData.GetCondition());
762cdf0e10cSrcweir 		aHideCB.Enable();
763cdf0e10cSrcweir         aHideCB.SetState((rData.IsHidden()) ? STATE_CHECK : STATE_NOCHECK);
764cdf0e10cSrcweir 		sal_Bool bHide = STATE_CHECK == aHideCB.GetState();
765cdf0e10cSrcweir         aConditionED.Enable(bHide);
766cdf0e10cSrcweir         aConditionFT.Enable(bHide);
767cdf0e10cSrcweir         aPasswdCB.Check(rData.GetPassword().getLength() > 0);
768cdf0e10cSrcweir 
769cdf0e10cSrcweir 		aOK.Enable();
770cdf0e10cSrcweir 		aPasswdCB.Enable();
771cdf0e10cSrcweir 		aCurName.SetText(pBox->GetEntryText(pEntry));
772cdf0e10cSrcweir 		aCurName.Enable();
773cdf0e10cSrcweir 		aDismiss.Enable();
774cdf0e10cSrcweir 		String aFile = pRepr->GetFile();
775cdf0e10cSrcweir 		String sSub = pRepr->GetSubRegion();
776cdf0e10cSrcweir         bSubRegionsFilled = false;
777cdf0e10cSrcweir         aSubRegionED.Clear();
778cdf0e10cSrcweir 		if(aFile.Len()||sSub.Len())
779cdf0e10cSrcweir 		{
780cdf0e10cSrcweir 			aFileCB.Check(sal_True);
781cdf0e10cSrcweir 			aFileNameED.SetText(aFile);
782cdf0e10cSrcweir 			aSubRegionED.SetText(sSub);
783cdf0e10cSrcweir             aDDECB.Check(rData.GetType() == DDE_LINK_SECTION);
784cdf0e10cSrcweir 		}
785cdf0e10cSrcweir 		else
786cdf0e10cSrcweir 		{
787cdf0e10cSrcweir 			aFileCB.Check(sal_False);
788cdf0e10cSrcweir 			aFileNameED.SetText(aFile);
789cdf0e10cSrcweir 			aDDECB.Enable(sal_False);
790cdf0e10cSrcweir 			aDDECB.Check(sal_False);
791cdf0e10cSrcweir 		}
792cdf0e10cSrcweir 		UseFileHdl(&aFileCB);
793cdf0e10cSrcweir 		DDEHdl( &aDDECB );
794cdf0e10cSrcweir         aProtectCB.SetState((rData.IsProtectFlag())
795cdf0e10cSrcweir                 ? STATE_CHECK : STATE_NOCHECK);
796cdf0e10cSrcweir 		aProtectCB.Enable();
797cdf0e10cSrcweir 
798cdf0e10cSrcweir         // --> FME 2004-06-22 #114856# edit in readonly sections
799cdf0e10cSrcweir         aEditInReadonlyCB.SetState((rData.IsEditInReadonlyFlag())
800cdf0e10cSrcweir                 ? STATE_CHECK : STATE_NOCHECK);
801cdf0e10cSrcweir         aEditInReadonlyCB.Enable();
802cdf0e10cSrcweir         // <--
803cdf0e10cSrcweir 
804cdf0e10cSrcweir         sal_Bool bPasswdEnabled = aProtectCB.IsChecked();
805cdf0e10cSrcweir         aPasswdCB.Enable(bPasswdEnabled);
806cdf0e10cSrcweir         aPasswdPB.Enable(bPasswdEnabled);
807cdf0e10cSrcweir 	}
808cdf0e10cSrcweir     bDontCheckPasswd = sal_False;
809cdf0e10cSrcweir 	return 0;
810cdf0e10cSrcweir }
811cdf0e10cSrcweir /*-----------------28.06.97 09:19-------------------
812cdf0e10cSrcweir 
813cdf0e10cSrcweir --------------------------------------------------*/
814cdf0e10cSrcweir IMPL_LINK( SwEditRegionDlg, DeselectHdl, SvTreeListBox *, pBox )
815cdf0e10cSrcweir {
816cdf0e10cSrcweir 	if( !pBox->GetSelectionCount() )
817cdf0e10cSrcweir 	{
818cdf0e10cSrcweir 		aHideCB		.Enable(sal_False);
819cdf0e10cSrcweir 		aProtectCB	.Enable(sal_False);
820cdf0e10cSrcweir         // --> FME 2004-06-22 #114856# edit in readonly sections
821cdf0e10cSrcweir         aEditInReadonlyCB.Enable(sal_False);
822cdf0e10cSrcweir         // <--
823cdf0e10cSrcweir         aPasswdCB   .Enable(sal_False);
824cdf0e10cSrcweir         aPasswdCB   .Enable(sal_False);
825cdf0e10cSrcweir         aConditionFT     .Enable(sal_False);
826cdf0e10cSrcweir         aConditionED.Enable(sal_False);
827cdf0e10cSrcweir 		aFileCB		.Enable(sal_False);
828cdf0e10cSrcweir 		aFilePB		.Enable(sal_False);
829cdf0e10cSrcweir 		aFileNameFT  .Enable(sal_False);
830cdf0e10cSrcweir 		aFileNameED  .Enable(sal_False);
831cdf0e10cSrcweir 		aSubRegionFT .Enable(sal_False);
832cdf0e10cSrcweir 		aSubRegionED .Enable(sal_False);
833cdf0e10cSrcweir //        aNameFT      .Enable(sal_False);
834cdf0e10cSrcweir 		aCurName	 .Enable(sal_False);
835cdf0e10cSrcweir 		aDDECB   			.Enable(sal_False);
836cdf0e10cSrcweir 		aDDECommandFT       .Enable(sal_False);
837cdf0e10cSrcweir 
838cdf0e10cSrcweir 		UseFileHdl(&aFileCB);
839cdf0e10cSrcweir 		DDEHdl( &aDDECB );
840cdf0e10cSrcweir 	}
841cdf0e10cSrcweir 	return 0;
842cdf0e10cSrcweir }
843cdf0e10cSrcweir 
844cdf0e10cSrcweir /*---------------------------------------------------------------------
845cdf0e10cSrcweir 	Beschreibung:	Im OkHdl werden die veraenderten Einstellungen
846cdf0e10cSrcweir 					uebernommen und aufgehobene Bereiche geloescht
847cdf0e10cSrcweir ---------------------------------------------------------------------*/
848cdf0e10cSrcweir 
849cdf0e10cSrcweir IMPL_LINK( SwEditRegionDlg, OkHdl, CheckBox *, EMPTYARG )
850cdf0e10cSrcweir {
851cdf0e10cSrcweir 	// JP 13.03.96:
852cdf0e10cSrcweir 	// temp. Array weil sich waehrend des aendern eines Bereiches die
853cdf0e10cSrcweir 	// Position innerhalb des "Core-Arrays" verschieben kann:
854cdf0e10cSrcweir 	//	- bei gelinkten Bereichen, wenn sie weitere SubBereiche haben oder
855cdf0e10cSrcweir 	//	  neu erhalten.
856cdf0e10cSrcweir 	// JP 30.05.97: StartUndo darf natuerlich auch erst nach dem Kopieren
857cdf0e10cSrcweir 	//				der Formate erfolgen (ClearRedo!)
858cdf0e10cSrcweir 
859cdf0e10cSrcweir 	const SwSectionFmts& rDocFmts = rSh.GetDoc()->GetSections();
860cdf0e10cSrcweir 	SwSectionFmts aOrigArray( 0, 5 );
861cdf0e10cSrcweir 	aOrigArray.Insert( &rDocFmts, 0 );
862cdf0e10cSrcweir 
863cdf0e10cSrcweir 	rSh.StartAllAction();
864cdf0e10cSrcweir 	rSh.StartUndo();
865cdf0e10cSrcweir 	rSh.ResetSelect( 0,sal_False );
866cdf0e10cSrcweir 	SvLBoxEntry* pEntry = aTree.First();
867cdf0e10cSrcweir 
868cdf0e10cSrcweir 	while( pEntry )
869cdf0e10cSrcweir 	{
870cdf0e10cSrcweir 		SectReprPtr pRepr = (SectReprPtr) pEntry->GetUserData();
871cdf0e10cSrcweir 		SwSectionFmt* pFmt = aOrigArray[ pRepr->GetArrPos() ];
872cdf0e10cSrcweir         if (!pRepr->GetSectionData().IsProtectFlag())
873cdf0e10cSrcweir         {
874cdf0e10cSrcweir             pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >());
875cdf0e10cSrcweir         }
876cdf0e10cSrcweir         sal_uInt16 nNewPos = rDocFmts.GetPos( pFmt );
877cdf0e10cSrcweir 		if( USHRT_MAX != nNewPos )
878cdf0e10cSrcweir 		{
879cdf0e10cSrcweir 			SfxItemSet* pSet = pFmt->GetAttrSet().Clone( sal_False );
880cdf0e10cSrcweir 			if( pFmt->GetCol() != pRepr->GetCol() )
881cdf0e10cSrcweir 				pSet->Put( pRepr->GetCol() );
882cdf0e10cSrcweir 
883cdf0e10cSrcweir 			if( pFmt->GetBackground(sal_False) != pRepr->GetBackground() )
884cdf0e10cSrcweir 				pSet->Put( pRepr->GetBackground() );
885cdf0e10cSrcweir 
886cdf0e10cSrcweir 			if( pFmt->GetFtnAtTxtEnd(sal_False) != pRepr->GetFtnNtAtEnd() )
887cdf0e10cSrcweir 				pSet->Put( pRepr->GetFtnNtAtEnd() );
888cdf0e10cSrcweir 
889cdf0e10cSrcweir 			if( pFmt->GetEndAtTxtEnd(sal_False) != pRepr->GetEndNtAtEnd() )
890cdf0e10cSrcweir 				pSet->Put( pRepr->GetEndNtAtEnd() );
891cdf0e10cSrcweir 
892cdf0e10cSrcweir 			if( pFmt->GetBalancedColumns() != pRepr->GetBalance() )
893cdf0e10cSrcweir 				pSet->Put( pRepr->GetBalance() );
894cdf0e10cSrcweir 
895cdf0e10cSrcweir             if( pFmt->GetFrmDir() != pRepr->GetFrmDir() )
896cdf0e10cSrcweir                 pSet->Put( pRepr->GetFrmDir() );
897cdf0e10cSrcweir 
898cdf0e10cSrcweir             if( pFmt->GetLRSpace() != pRepr->GetLRSpace())
899cdf0e10cSrcweir                 pSet->Put( pRepr->GetLRSpace());
900cdf0e10cSrcweir 
901cdf0e10cSrcweir             rSh.UpdateSection( nNewPos, pRepr->GetSectionData(),
902cdf0e10cSrcweir 							pSet->Count() ? pSet : 0 );
903cdf0e10cSrcweir 			delete pSet;
904cdf0e10cSrcweir 		}
905cdf0e10cSrcweir 		pEntry = aTree.Next( pEntry );
906cdf0e10cSrcweir 	}
907cdf0e10cSrcweir 
908cdf0e10cSrcweir 	for(sal_uInt16 i = aSectReprArr.Count(); i; )
909cdf0e10cSrcweir 	{
910cdf0e10cSrcweir 		SwSectionFmt* pFmt = aOrigArray[ aSectReprArr[ --i ]->GetArrPos() ];
911cdf0e10cSrcweir 		sal_uInt16 nNewPos = rDocFmts.GetPos( pFmt );
912cdf0e10cSrcweir 		if( USHRT_MAX != nNewPos )
913cdf0e10cSrcweir 			rSh.DelSectionFmt( nNewPos );
914cdf0e10cSrcweir 	}
915cdf0e10cSrcweir //    rSh.ChgSectionPasswd(aNewPasswd);
916cdf0e10cSrcweir 
917cdf0e10cSrcweir 	aOrigArray.Remove( 0, aOrigArray.Count() );
918cdf0e10cSrcweir 
919cdf0e10cSrcweir 	//JP 21.05.97: EndDialog muss vor Ende der EndAction gerufen werden,
920cdf0e10cSrcweir 	//				sonst kann es ScrollFehler geben.
921cdf0e10cSrcweir 	EndDialog(RET_OK);
922cdf0e10cSrcweir 
923cdf0e10cSrcweir 	rSh.EndUndo();
924cdf0e10cSrcweir 	rSh.EndAllAction();
925cdf0e10cSrcweir 
926cdf0e10cSrcweir 	return 0;
927cdf0e10cSrcweir }
928cdf0e10cSrcweir /*---------------------------------------------------------------------
929cdf0e10cSrcweir  Beschreibung: Toggle protect
930cdf0e10cSrcweir ---------------------------------------------------------------------*/
931cdf0e10cSrcweir 
932cdf0e10cSrcweir IMPL_LINK( SwEditRegionDlg, ChangeProtectHdl, TriStateBox *, pBox )
933cdf0e10cSrcweir {
934cdf0e10cSrcweir     if(!CheckPasswd(pBox))
935cdf0e10cSrcweir         return 0;
936cdf0e10cSrcweir     pBox->EnableTriState( sal_False );
937cdf0e10cSrcweir 	SvLBoxEntry* pEntry=aTree.FirstSelected();
938cdf0e10cSrcweir 	DBG_ASSERT(pEntry,"kein Entry gefunden");
939cdf0e10cSrcweir     sal_Bool bCheck = STATE_CHECK == pBox->GetState();
940cdf0e10cSrcweir     while( pEntry )
941cdf0e10cSrcweir 	{
942cdf0e10cSrcweir 		SectReprPtr pRepr = (SectReprPtr) pEntry->GetUserData();
943cdf0e10cSrcweir         pRepr->GetSectionData().SetProtectFlag(bCheck);
944cdf0e10cSrcweir         Image aImage = BuildBitmap( bCheck,
945cdf0e10cSrcweir                                     STATE_CHECK == aHideCB.GetState(), sal_False);
946cdf0e10cSrcweir         aTree.SetExpandedEntryBmp(pEntry, aImage, BMP_COLOR_NORMAL);
947cdf0e10cSrcweir         aTree.SetCollapsedEntryBmp(pEntry, aImage, BMP_COLOR_NORMAL);
948cdf0e10cSrcweir         Image aHCImg = BuildBitmap( bCheck, STATE_CHECK == aHideCB.GetState(), sal_True);
949cdf0e10cSrcweir         aTree.SetExpandedEntryBmp(pEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
950cdf0e10cSrcweir         aTree.SetCollapsedEntryBmp(pEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
951cdf0e10cSrcweir         pEntry = aTree.NextSelected(pEntry);
952cdf0e10cSrcweir 	}
953cdf0e10cSrcweir     aPasswdCB.Enable(bCheck);
954cdf0e10cSrcweir     aPasswdPB.Enable(bCheck);
955cdf0e10cSrcweir     return 0;
956cdf0e10cSrcweir }
957cdf0e10cSrcweir /*---------------------------------------------------------------------
958cdf0e10cSrcweir  Beschreibung: Toggle hide
959cdf0e10cSrcweir ---------------------------------------------------------------------*/
960cdf0e10cSrcweir 
961cdf0e10cSrcweir IMPL_LINK( SwEditRegionDlg, ChangeHideHdl, TriStateBox *, pBox )
962cdf0e10cSrcweir {
963cdf0e10cSrcweir     if(!CheckPasswd(pBox))
964cdf0e10cSrcweir         return 0;
965cdf0e10cSrcweir     pBox->EnableTriState( sal_False );
966cdf0e10cSrcweir 	SvLBoxEntry* pEntry=aTree.FirstSelected();
967cdf0e10cSrcweir 	DBG_ASSERT(pEntry,"kein Entry gefunden");
968cdf0e10cSrcweir 	while( pEntry )
969cdf0e10cSrcweir 	{
970cdf0e10cSrcweir 		SectReprPtr pRepr = (SectReprPtr) pEntry->GetUserData();
971cdf0e10cSrcweir         pRepr->GetSectionData().SetHidden(STATE_CHECK == pBox->GetState());
972cdf0e10cSrcweir         Image aImage = BuildBitmap(STATE_CHECK == aProtectCB.GetState(),
973cdf0e10cSrcweir                                     STATE_CHECK == pBox->GetState(), sal_False);
974cdf0e10cSrcweir         aTree.SetExpandedEntryBmp(pEntry, aImage, BMP_COLOR_NORMAL);
975cdf0e10cSrcweir         aTree.SetCollapsedEntryBmp(pEntry, aImage, BMP_COLOR_NORMAL);
976cdf0e10cSrcweir         Image aHCImg = BuildBitmap( STATE_CHECK == aProtectCB.GetState(),
977cdf0e10cSrcweir                                     STATE_CHECK == pBox->GetState(), sal_True);
978cdf0e10cSrcweir         aTree.SetExpandedEntryBmp(pEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
979cdf0e10cSrcweir         aTree.SetCollapsedEntryBmp(pEntry, aHCImg, BMP_COLOR_HIGHCONTRAST);
980cdf0e10cSrcweir 
981cdf0e10cSrcweir 		pEntry = aTree.NextSelected(pEntry);
982cdf0e10cSrcweir 	}
983cdf0e10cSrcweir 
984cdf0e10cSrcweir 	sal_Bool bHide = STATE_CHECK == pBox->GetState();
985cdf0e10cSrcweir     aConditionED.Enable(bHide);
986cdf0e10cSrcweir     aConditionFT.Enable(bHide);
987cdf0e10cSrcweir     return 0;
988cdf0e10cSrcweir }
989cdf0e10cSrcweir 
990cdf0e10cSrcweir /*---------------------------------------------------------------------
991cdf0e10cSrcweir  Beschreibung: Toggle edit in readonly
992cdf0e10cSrcweir ---------------------------------------------------------------------*/
993cdf0e10cSrcweir 
994cdf0e10cSrcweir IMPL_LINK( SwEditRegionDlg, ChangeEditInReadonlyHdl, TriStateBox *, pBox )
995cdf0e10cSrcweir {
996cdf0e10cSrcweir     if(!CheckPasswd(pBox))
997cdf0e10cSrcweir         return 0;
998cdf0e10cSrcweir     pBox->EnableTriState( sal_False );
999cdf0e10cSrcweir     SvLBoxEntry* pEntry=aTree.FirstSelected();
1000cdf0e10cSrcweir     DBG_ASSERT(pEntry,"kein Entry gefunden");
1001cdf0e10cSrcweir     while( pEntry )
1002cdf0e10cSrcweir     {
1003cdf0e10cSrcweir         SectReprPtr pRepr = (SectReprPtr) pEntry->GetUserData();
1004cdf0e10cSrcweir         pRepr->GetSectionData().SetEditInReadonlyFlag(
1005cdf0e10cSrcweir                 STATE_CHECK == pBox->GetState());
1006cdf0e10cSrcweir         pEntry = aTree.NextSelected(pEntry);
1007cdf0e10cSrcweir     }
1008cdf0e10cSrcweir 
1009cdf0e10cSrcweir     return 0;
1010cdf0e10cSrcweir }
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir /*---------------------------------------------------------------------
1013cdf0e10cSrcweir  Beschreibung: selektierten Bereich aufheben
1014cdf0e10cSrcweir ---------------------------------------------------------------------*/
1015cdf0e10cSrcweir 
1016cdf0e10cSrcweir IMPL_LINK( SwEditRegionDlg, ChangeDismissHdl, CheckBox *, EMPTYARG )
1017cdf0e10cSrcweir {
1018cdf0e10cSrcweir     if(!CheckPasswd())
1019cdf0e10cSrcweir         return 0;
1020cdf0e10cSrcweir     SvLBoxEntry* pEntry = aTree.FirstSelected();
1021cdf0e10cSrcweir 	SvLBoxEntry* pChild;
1022cdf0e10cSrcweir 	SvLBoxEntry* pParent;
1023cdf0e10cSrcweir 	//zuerst alle selektierten markieren
1024cdf0e10cSrcweir 	while(pEntry)
1025cdf0e10cSrcweir 	{
1026cdf0e10cSrcweir 		const SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
1027cdf0e10cSrcweir 		pSectRepr->SetSelected();
1028cdf0e10cSrcweir 		pEntry = aTree.NextSelected(pEntry);
1029cdf0e10cSrcweir 	}
1030cdf0e10cSrcweir 	pEntry = aTree.FirstSelected();
1031cdf0e10cSrcweir 	// dann loeschen
1032cdf0e10cSrcweir 	while(pEntry)
1033cdf0e10cSrcweir 	{
1034cdf0e10cSrcweir 		const SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
1035cdf0e10cSrcweir 		SvLBoxEntry* pRemove = 0;
1036cdf0e10cSrcweir 		sal_Bool bRestart = sal_False;
1037cdf0e10cSrcweir 		if(pSectRepr->IsSelected())
1038cdf0e10cSrcweir 		{
1039cdf0e10cSrcweir 			aSectReprArr.Insert( pSectRepr );
1040cdf0e10cSrcweir 			while( (pChild = aTree.FirstChild(pEntry) )!= 0 )
1041cdf0e10cSrcweir 			{
1042cdf0e10cSrcweir 				//durch das Umhaengen muss wieder am Anfang aufgesetzt werden
1043cdf0e10cSrcweir 				bRestart = sal_True;
1044cdf0e10cSrcweir 				pParent=aTree.GetParent(pEntry);
1045cdf0e10cSrcweir 				aTree.GetModel()->Move(pChild, pParent, aTree.GetModel()->GetRelPos(pEntry));
1046cdf0e10cSrcweir 			}
1047cdf0e10cSrcweir 			pRemove = pEntry;
1048cdf0e10cSrcweir 		}
1049cdf0e10cSrcweir 		if(bRestart)
1050cdf0e10cSrcweir 			pEntry = aTree.First();
1051cdf0e10cSrcweir 		else
1052cdf0e10cSrcweir 			pEntry = aTree.Next(pEntry);
1053cdf0e10cSrcweir 		if(pRemove)
1054cdf0e10cSrcweir 			aTree.GetModel()->Remove( pRemove );
1055cdf0e10cSrcweir 	}
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir 	if ( (pEntry=aTree.FirstSelected()) == 0 )
1058cdf0e10cSrcweir 	{
1059cdf0e10cSrcweir         aConditionFT.        Enable(sal_False);
1060cdf0e10cSrcweir         aConditionED.   Enable(sal_False);
1061cdf0e10cSrcweir 		aDismiss.		Enable(sal_False);
1062cdf0e10cSrcweir 		aCurName.		Enable(sal_False);
1063cdf0e10cSrcweir 		aProtectCB.		Enable(sal_False);
1064cdf0e10cSrcweir 		aPasswdCB.		Enable(sal_False);
1065cdf0e10cSrcweir 		aHideCB.		Enable(sal_False);
1066cdf0e10cSrcweir         // --> FME 2004-06-22 #114856# edit in readonly sections
1067cdf0e10cSrcweir         aEditInReadonlyCB.Enable(sal_False);
1068cdf0e10cSrcweir         aEditInReadonlyCB.SetState(STATE_NOCHECK);
1069cdf0e10cSrcweir         // <--
1070cdf0e10cSrcweir         aProtectCB.     SetState(STATE_NOCHECK);
1071cdf0e10cSrcweir 		aPasswdCB.		Check(sal_False);
1072cdf0e10cSrcweir 		aHideCB.		SetState(STATE_NOCHECK);
1073cdf0e10cSrcweir 		aFileCB.		Check(sal_False);
1074cdf0e10cSrcweir 		//sonst liegt der Focus auf dem HelpButton
1075cdf0e10cSrcweir 		aOK.GrabFocus();
1076cdf0e10cSrcweir 		UseFileHdl(&aFileCB);
1077cdf0e10cSrcweir 	}
1078cdf0e10cSrcweir 	return 0;
1079cdf0e10cSrcweir }
1080cdf0e10cSrcweir /*---------------------------------------------------------------------
1081cdf0e10cSrcweir  Beschreibung: CheckBox mit Datei verknuepfen?
1082cdf0e10cSrcweir ---------------------------------------------------------------------*/
1083cdf0e10cSrcweir 
1084cdf0e10cSrcweir IMPL_LINK( SwEditRegionDlg, UseFileHdl, CheckBox *, pBox )
1085cdf0e10cSrcweir {
1086cdf0e10cSrcweir     if(!CheckPasswd(pBox))
1087cdf0e10cSrcweir         return 0;
1088cdf0e10cSrcweir     SvLBoxEntry* pEntry = aTree.FirstSelected();
1089cdf0e10cSrcweir 	pBox->EnableTriState(sal_False);
1090cdf0e10cSrcweir 	sal_Bool bMulti = 1 < aTree.GetSelectionCount();
1091cdf0e10cSrcweir 	sal_Bool bFile = pBox->IsChecked();
1092cdf0e10cSrcweir 	if(pEntry)
1093cdf0e10cSrcweir 	{
1094cdf0e10cSrcweir 		while(pEntry)
1095cdf0e10cSrcweir 		{
1096cdf0e10cSrcweir 			const SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
1097cdf0e10cSrcweir 			sal_Bool bContent = pSectRepr->IsContent();
1098cdf0e10cSrcweir 			if( pBox->IsChecked() && bContent && rSh.HasSelection() )
1099cdf0e10cSrcweir 			{
1100cdf0e10cSrcweir 				if( RET_NO == QueryBox( this, SW_RES(QB_CONNECT) ).Execute() )
1101cdf0e10cSrcweir 					pBox->Check( sal_False );
1102cdf0e10cSrcweir 			}
1103cdf0e10cSrcweir 			if( bFile )
1104cdf0e10cSrcweir 				pSectRepr->SetContent(sal_False);
1105cdf0e10cSrcweir 			else
1106cdf0e10cSrcweir 			{
1107cdf0e10cSrcweir 				pSectRepr->SetFile(aEmptyStr);
1108cdf0e10cSrcweir 				pSectRepr->SetSubRegion(aEmptyStr);
1109cdf0e10cSrcweir                 pSectRepr->GetSectionData().SetLinkFilePassword(aEmptyStr);
1110cdf0e10cSrcweir 			}
1111cdf0e10cSrcweir 
1112cdf0e10cSrcweir 			pEntry = aTree.NextSelected(pEntry);
1113cdf0e10cSrcweir 		}
1114cdf0e10cSrcweir 		aFileNameFT.Enable(bFile && ! bMulti);
1115cdf0e10cSrcweir 		aFileNameED.Enable(bFile && ! bMulti);
1116cdf0e10cSrcweir 		aFilePB.Enable(bFile && ! bMulti);
1117cdf0e10cSrcweir 		aSubRegionED.Enable(bFile && ! bMulti);
1118cdf0e10cSrcweir 		aSubRegionFT.Enable(bFile && ! bMulti);
1119cdf0e10cSrcweir 		aDDECommandFT.Enable(bFile && ! bMulti);
1120cdf0e10cSrcweir 		aDDECB.Enable(bFile && ! bMulti);
1121cdf0e10cSrcweir 		if( bFile )
1122cdf0e10cSrcweir 		{
1123cdf0e10cSrcweir 			aProtectCB.SetState(STATE_CHECK);
1124cdf0e10cSrcweir 			aFileNameED.GrabFocus();
1125cdf0e10cSrcweir 
1126cdf0e10cSrcweir 		}
1127cdf0e10cSrcweir 		else
1128cdf0e10cSrcweir 		{
1129cdf0e10cSrcweir 			aDDECB.Check(sal_False);
1130cdf0e10cSrcweir 			DDEHdl(&aDDECB);
1131cdf0e10cSrcweir //			aFileNameED.SetText(aEmptyStr);
1132cdf0e10cSrcweir 			aSubRegionED.SetText(aEmptyStr);
1133cdf0e10cSrcweir 		}
1134cdf0e10cSrcweir 	}
1135cdf0e10cSrcweir 	else
1136cdf0e10cSrcweir 	{
1137cdf0e10cSrcweir 		pBox->Check(sal_False);
1138cdf0e10cSrcweir 		pBox->Enable(sal_False);
1139cdf0e10cSrcweir 		aFilePB.Enable(sal_False);
1140cdf0e10cSrcweir 		aFileNameED.Enable(sal_False);
1141cdf0e10cSrcweir 		aFileNameFT.Enable(sal_False);
1142cdf0e10cSrcweir 		aSubRegionED.Enable(sal_False);
1143cdf0e10cSrcweir 		aSubRegionFT.Enable(sal_False);
1144cdf0e10cSrcweir 		aDDECB.Check(sal_False);
1145cdf0e10cSrcweir 		aDDECB.Enable(sal_False);
1146cdf0e10cSrcweir 		aDDECommandFT.Enable(sal_False);
1147cdf0e10cSrcweir 	}
1148cdf0e10cSrcweir 	return 0;
1149cdf0e10cSrcweir }
1150cdf0e10cSrcweir 
1151cdf0e10cSrcweir /*---------------------------------------------------------------------
1152cdf0e10cSrcweir 	Beschreibung: Dialog Datei einfuegen rufen
1153cdf0e10cSrcweir ---------------------------------------------------------------------*/
1154cdf0e10cSrcweir 
1155cdf0e10cSrcweir IMPL_LINK( SwEditRegionDlg, FileSearchHdl, PushButton *, EMPTYARG )
1156cdf0e10cSrcweir {
1157cdf0e10cSrcweir     if(!CheckPasswd(0))
1158cdf0e10cSrcweir         return 0;
1159cdf0e10cSrcweir 
1160cdf0e10cSrcweir     m_pOldDefDlgParent = Application::GetDefDialogParent();
1161cdf0e10cSrcweir     Application::SetDefDialogParent( this );
1162cdf0e10cSrcweir     if ( m_pDocInserter )
1163cdf0e10cSrcweir         delete m_pDocInserter;
1164cdf0e10cSrcweir     m_pDocInserter = new ::sfx2::DocumentInserter( 0, String::CreateFromAscii("swriter") );
1165cdf0e10cSrcweir     m_pDocInserter->StartExecuteModal( LINK( this, SwEditRegionDlg, DlgClosedHdl ) );
1166cdf0e10cSrcweir     return 0;
1167cdf0e10cSrcweir }
1168cdf0e10cSrcweir 
1169cdf0e10cSrcweir /*---------------------------------------------------------------------
1170cdf0e10cSrcweir 	Beschreibung:
1171cdf0e10cSrcweir ---------------------------------------------------------------------*/
1172cdf0e10cSrcweir 
1173cdf0e10cSrcweir IMPL_LINK( SwEditRegionDlg, OptionsHdl, PushButton *, EMPTYARG )
1174cdf0e10cSrcweir {
1175cdf0e10cSrcweir     if(!CheckPasswd())
1176cdf0e10cSrcweir         return 0;
1177cdf0e10cSrcweir     SvLBoxEntry* pEntry = aTree.FirstSelected();
1178cdf0e10cSrcweir 
1179cdf0e10cSrcweir 	if(pEntry)
1180cdf0e10cSrcweir 	{
1181cdf0e10cSrcweir 		SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
1182cdf0e10cSrcweir 		SfxItemSet aSet(rSh.GetView().GetPool(),
1183cdf0e10cSrcweir 							RES_COL, RES_COL,
1184cdf0e10cSrcweir                             RES_COLUMNBALANCE, RES_FRAMEDIR,
1185cdf0e10cSrcweir 							RES_BACKGROUND, RES_BACKGROUND,
1186cdf0e10cSrcweir 							RES_FRM_SIZE, RES_FRM_SIZE,
1187cdf0e10cSrcweir 							SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
1188cdf0e10cSrcweir 							RES_LR_SPACE, RES_LR_SPACE,
1189cdf0e10cSrcweir 							RES_FTN_AT_TXTEND, RES_END_AT_TXTEND,
1190cdf0e10cSrcweir                             0);
1191cdf0e10cSrcweir 
1192cdf0e10cSrcweir 		aSet.Put( pSectRepr->GetCol() );
1193cdf0e10cSrcweir 		aSet.Put( pSectRepr->GetBackground() );
1194cdf0e10cSrcweir 		aSet.Put( pSectRepr->GetFtnNtAtEnd() );
1195cdf0e10cSrcweir 		aSet.Put( pSectRepr->GetEndNtAtEnd() );
1196cdf0e10cSrcweir 		aSet.Put( pSectRepr->GetBalance() );
1197cdf0e10cSrcweir         aSet.Put( pSectRepr->GetFrmDir() );
1198cdf0e10cSrcweir         aSet.Put( pSectRepr->GetLRSpace() );
1199cdf0e10cSrcweir 
1200cdf0e10cSrcweir 		const SwSectionFmts& rDocFmts = rSh.GetDoc()->GetSections();
1201cdf0e10cSrcweir 		SwSectionFmts aOrigArray( 0, 5 );
1202cdf0e10cSrcweir 		aOrigArray.Insert( &rDocFmts, 0 );
1203cdf0e10cSrcweir 
1204cdf0e10cSrcweir 		SwSectionFmt* pFmt = aOrigArray[pSectRepr->GetArrPos()];
1205cdf0e10cSrcweir 		long nWidth = rSh.GetSectionWidth(*pFmt);
1206cdf0e10cSrcweir 		aOrigArray.Remove( 0, aOrigArray.Count() );
1207cdf0e10cSrcweir 		if (!nWidth)
1208cdf0e10cSrcweir 			nWidth = USHRT_MAX;
1209cdf0e10cSrcweir 
1210cdf0e10cSrcweir 		aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth));
1211cdf0e10cSrcweir 		aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth)));
1212cdf0e10cSrcweir 
1213cdf0e10cSrcweir 		SwSectionPropertyTabDialog aTabDlg(this, aSet, rSh);
1214cdf0e10cSrcweir 		if(RET_OK == aTabDlg.Execute())
1215cdf0e10cSrcweir 		{
1216cdf0e10cSrcweir 			const SfxItemSet* pOutSet = aTabDlg.GetOutputItemSet();
1217cdf0e10cSrcweir 			if( pOutSet && pOutSet->Count() )
1218cdf0e10cSrcweir 			{
1219cdf0e10cSrcweir 				const SfxPoolItem *pColItem, *pBrushItem,
1220cdf0e10cSrcweir                                   *pFtnItem, *pEndItem, *pBalanceItem,
1221cdf0e10cSrcweir                                   *pFrmDirItem, *pLRSpaceItem;
1222cdf0e10cSrcweir 				SfxItemState eColState = pOutSet->GetItemState(
1223cdf0e10cSrcweir 										RES_COL, sal_False, &pColItem );
1224cdf0e10cSrcweir 				SfxItemState eBrushState = pOutSet->GetItemState(
1225cdf0e10cSrcweir 										RES_BACKGROUND, sal_False, &pBrushItem );
1226cdf0e10cSrcweir 				SfxItemState eFtnState = pOutSet->GetItemState(
1227cdf0e10cSrcweir 										RES_FTN_AT_TXTEND, sal_False, &pFtnItem );
1228cdf0e10cSrcweir 				SfxItemState eEndState = pOutSet->GetItemState(
1229cdf0e10cSrcweir 										RES_END_AT_TXTEND, sal_False, &pEndItem );
1230cdf0e10cSrcweir 				SfxItemState eBalanceState = pOutSet->GetItemState(
1231cdf0e10cSrcweir 										RES_COLUMNBALANCE, sal_False, &pBalanceItem );
1232cdf0e10cSrcweir                 SfxItemState eFrmDirState = pOutSet->GetItemState(
1233cdf0e10cSrcweir                                         RES_FRAMEDIR, sal_False, &pFrmDirItem );
1234cdf0e10cSrcweir                 SfxItemState eLRState = pOutSet->GetItemState(
1235cdf0e10cSrcweir                                         RES_LR_SPACE, sal_False, &pLRSpaceItem);
1236cdf0e10cSrcweir 
1237cdf0e10cSrcweir 				if( SFX_ITEM_SET == eColState ||
1238cdf0e10cSrcweir 					SFX_ITEM_SET == eBrushState ||
1239cdf0e10cSrcweir 					SFX_ITEM_SET == eFtnState ||
1240cdf0e10cSrcweir 					SFX_ITEM_SET == eEndState ||
1241cdf0e10cSrcweir                     SFX_ITEM_SET == eBalanceState||
1242cdf0e10cSrcweir                     SFX_ITEM_SET == eFrmDirState||
1243cdf0e10cSrcweir                     SFX_ITEM_SET == eLRState)
1244cdf0e10cSrcweir 				{
1245cdf0e10cSrcweir                     SvLBoxEntry* pSelEntry = aTree.FirstSelected();
1246cdf0e10cSrcweir                     while( pSelEntry )
1247cdf0e10cSrcweir 					{
1248cdf0e10cSrcweir                         SectReprPtr pRepr = (SectReprPtr)pSelEntry->GetUserData();
1249cdf0e10cSrcweir 						if( SFX_ITEM_SET == eColState )
1250cdf0e10cSrcweir 							pRepr->GetCol() = *(SwFmtCol*)pColItem;
1251cdf0e10cSrcweir 						if( SFX_ITEM_SET == eBrushState )
1252cdf0e10cSrcweir 							pRepr->GetBackground() = *(SvxBrushItem*)pBrushItem;
1253cdf0e10cSrcweir 						if( SFX_ITEM_SET == eFtnState )
1254cdf0e10cSrcweir 							pRepr->GetFtnNtAtEnd() = *(SwFmtFtnAtTxtEnd*)pFtnItem;
1255cdf0e10cSrcweir 						if( SFX_ITEM_SET == eEndState )
1256cdf0e10cSrcweir 							pRepr->GetEndNtAtEnd() = *(SwFmtEndAtTxtEnd*)pEndItem;
1257cdf0e10cSrcweir 						if( SFX_ITEM_SET == eBalanceState )
1258cdf0e10cSrcweir 							pRepr->GetBalance().SetValue(((SwFmtNoBalancedColumns*)pBalanceItem)->GetValue());
1259cdf0e10cSrcweir                         if( SFX_ITEM_SET == eFrmDirState )
1260cdf0e10cSrcweir                             pRepr->GetFrmDir().SetValue(((SvxFrameDirectionItem*)pFrmDirItem)->GetValue());
1261cdf0e10cSrcweir                         if( SFX_ITEM_SET == eLRState )
1262cdf0e10cSrcweir                             pRepr->GetLRSpace() = *(SvxLRSpaceItem*)pLRSpaceItem;
1263cdf0e10cSrcweir 
1264cdf0e10cSrcweir                         pSelEntry = aTree.NextSelected(pSelEntry);
1265cdf0e10cSrcweir 					}
1266cdf0e10cSrcweir 				}
1267cdf0e10cSrcweir 			}
1268cdf0e10cSrcweir 		}
1269cdf0e10cSrcweir 	}
1270cdf0e10cSrcweir 
1271cdf0e10cSrcweir 	return 0;
1272cdf0e10cSrcweir }
1273cdf0e10cSrcweir 
1274cdf0e10cSrcweir /*---------------------------------------------------------------------
1275cdf0e10cSrcweir 	Beschreibung:  	Uebernahme des Dateinamen oder
1276cdf0e10cSrcweir 					des verknuepften Bereichs
1277cdf0e10cSrcweir ---------------------------------------------------------------------*/
1278cdf0e10cSrcweir 
1279cdf0e10cSrcweir IMPL_LINK( SwEditRegionDlg, FileNameHdl, Edit *, pEdit )
1280cdf0e10cSrcweir {
1281cdf0e10cSrcweir     Selection aSelect = pEdit->GetSelection();
1282cdf0e10cSrcweir     if(!CheckPasswd())
1283cdf0e10cSrcweir         return 0;
1284cdf0e10cSrcweir     pEdit->SetSelection(aSelect);
1285cdf0e10cSrcweir     SvLBoxEntry* pEntry=aTree.FirstSelected();
1286cdf0e10cSrcweir 	DBG_ASSERT(pEntry,"kein Entry gefunden");
1287cdf0e10cSrcweir 	SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
1288cdf0e10cSrcweir 	if(pEdit == &aFileNameED)
1289cdf0e10cSrcweir 	{
1290cdf0e10cSrcweir         bSubRegionsFilled = false;
1291cdf0e10cSrcweir         aSubRegionED.Clear();
1292cdf0e10cSrcweir 		if( aDDECB.IsChecked() )
1293cdf0e10cSrcweir 		{
1294cdf0e10cSrcweir 			String sLink( pEdit->GetText() );
1295cdf0e10cSrcweir 			sal_uInt16 nPos = 0;
1296cdf0e10cSrcweir 			while( STRING_NOTFOUND != (nPos = sLink.SearchAscii( "  ", nPos )) )
1297cdf0e10cSrcweir 				sLink.Erase( nPos--, 1 );
1298cdf0e10cSrcweir 
1299cdf0e10cSrcweir             nPos = sLink.SearchAndReplace( ' ', sfx2::cTokenSeperator );
1300cdf0e10cSrcweir             sLink.SearchAndReplace( ' ', sfx2::cTokenSeperator, nPos );
1301cdf0e10cSrcweir 
1302cdf0e10cSrcweir             pSectRepr->GetSectionData().SetLinkFileName( sLink );
1303cdf0e10cSrcweir             pSectRepr->GetSectionData().SetType( DDE_LINK_SECTION );
1304cdf0e10cSrcweir         }
1305cdf0e10cSrcweir 		else
1306cdf0e10cSrcweir 		{
1307cdf0e10cSrcweir 			String sTmp(pEdit->GetText());
1308cdf0e10cSrcweir 			if(sTmp.Len())
1309cdf0e10cSrcweir             {
1310cdf0e10cSrcweir                 SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
1311cdf0e10cSrcweir                 INetURLObject aAbs;
1312cdf0e10cSrcweir                 if( pMedium )
1313cdf0e10cSrcweir                     aAbs = pMedium->GetURLObject();
1314cdf0e10cSrcweir                 sTmp = URIHelper::SmartRel2Abs(
1315cdf0e10cSrcweir                     aAbs, sTmp, URIHelper::GetMaybeFileHdl() );
1316cdf0e10cSrcweir             }
1317cdf0e10cSrcweir 			pSectRepr->SetFile( sTmp );
1318cdf0e10cSrcweir             pSectRepr->GetSectionData().SetLinkFilePassword( aEmptyStr );
1319cdf0e10cSrcweir 		}
1320cdf0e10cSrcweir 	}
1321cdf0e10cSrcweir 	else
1322cdf0e10cSrcweir 	{
1323cdf0e10cSrcweir 		pSectRepr->SetSubRegion( pEdit->GetText() );
1324cdf0e10cSrcweir 	}
1325cdf0e10cSrcweir 	return 0;
1326cdf0e10cSrcweir }
1327cdf0e10cSrcweir /*---------------------------------------------------------------------
1328cdf0e10cSrcweir 	Beschreibung:
1329cdf0e10cSrcweir ---------------------------------------------------------------------*/
1330cdf0e10cSrcweir 
1331cdf0e10cSrcweir IMPL_LINK( SwEditRegionDlg, DDEHdl, CheckBox*, pBox )
1332cdf0e10cSrcweir {
1333cdf0e10cSrcweir     if(!CheckPasswd(pBox))
1334cdf0e10cSrcweir         return 0;
1335cdf0e10cSrcweir     SvLBoxEntry* pEntry=aTree.FirstSelected();
1336cdf0e10cSrcweir 	if(pEntry)
1337cdf0e10cSrcweir 	{
1338cdf0e10cSrcweir 		sal_Bool bFile = aFileCB.IsChecked();
1339cdf0e10cSrcweir 		SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
1340cdf0e10cSrcweir         SwSectionData & rData( pSectRepr->GetSectionData() );
1341cdf0e10cSrcweir 		sal_Bool bDDE = pBox->IsChecked();
1342cdf0e10cSrcweir 		if(bDDE)
1343cdf0e10cSrcweir 		{
1344cdf0e10cSrcweir 			aFileNameFT.Hide();
1345cdf0e10cSrcweir 			aDDECommandFT.Enable();
1346cdf0e10cSrcweir 			aDDECommandFT.Show();
1347cdf0e10cSrcweir 			aSubRegionFT.Hide();
1348cdf0e10cSrcweir 			aSubRegionED.Hide();
1349cdf0e10cSrcweir             if (FILE_LINK_SECTION == rData.GetType())
1350cdf0e10cSrcweir 			{
1351cdf0e10cSrcweir 				pSectRepr->SetFile(aEmptyStr);
1352cdf0e10cSrcweir 				aFileNameED.SetText(aEmptyStr);
1353cdf0e10cSrcweir                 rData.SetLinkFilePassword( aEmptyStr );
1354cdf0e10cSrcweir             }
1355cdf0e10cSrcweir             rData.SetType(DDE_LINK_SECTION);
1356cdf0e10cSrcweir 			aFileNameED.SetAccessibleName(aDDECommandFT.GetText());
1357cdf0e10cSrcweir 		}
1358cdf0e10cSrcweir 		else
1359cdf0e10cSrcweir 		{
1360cdf0e10cSrcweir 			aDDECommandFT.Hide();
1361cdf0e10cSrcweir 			aFileNameFT.Enable(bFile);
1362cdf0e10cSrcweir 			aFileNameFT.Show();
1363cdf0e10cSrcweir 			aSubRegionED.Show();
1364cdf0e10cSrcweir 			aSubRegionFT.Show();
1365cdf0e10cSrcweir 			aSubRegionED.Enable(bFile);
1366cdf0e10cSrcweir 			aSubRegionFT.Enable(bFile);
1367cdf0e10cSrcweir 			aSubRegionED.Enable(bFile);
1368cdf0e10cSrcweir             if (DDE_LINK_SECTION == rData.GetType())
1369cdf0e10cSrcweir 			{
1370cdf0e10cSrcweir                 rData.SetType(FILE_LINK_SECTION);
1371cdf0e10cSrcweir 				pSectRepr->SetFile(aEmptyStr);
1372cdf0e10cSrcweir                 rData.SetLinkFilePassword( aEmptyStr );
1373cdf0e10cSrcweir 				aFileNameED.SetText(aEmptyStr);
1374cdf0e10cSrcweir 			}
1375cdf0e10cSrcweir 			aFileNameED.SetAccessibleName(aFileNameFT.GetText());
1376cdf0e10cSrcweir 		}
1377cdf0e10cSrcweir 		aFilePB.Enable(bFile && !bDDE);
1378cdf0e10cSrcweir 	}
1379cdf0e10cSrcweir 	return 0;
1380cdf0e10cSrcweir }
1381cdf0e10cSrcweir /*---------------------------------------------------------------------
1382cdf0e10cSrcweir 
1383cdf0e10cSrcweir ---------------------------------------------------------------------*/
1384cdf0e10cSrcweir 
1385cdf0e10cSrcweir IMPL_LINK( SwEditRegionDlg, ChangePasswdHdl, Button *, pBox )
1386cdf0e10cSrcweir {
1387cdf0e10cSrcweir     sal_Bool bChange = pBox == &aPasswdPB;
1388cdf0e10cSrcweir     if(!CheckPasswd(0))
1389cdf0e10cSrcweir     {
1390cdf0e10cSrcweir         if(!bChange)
1391cdf0e10cSrcweir             aPasswdCB.Check(!aPasswdCB.IsChecked());
1392cdf0e10cSrcweir         return 0;
1393cdf0e10cSrcweir     }
1394cdf0e10cSrcweir     SvLBoxEntry* pEntry=aTree.FirstSelected();
1395cdf0e10cSrcweir     sal_Bool bSet = bChange ? bChange : aPasswdCB.IsChecked();
1396cdf0e10cSrcweir     DBG_ASSERT(pEntry,"kein Entry gefunden");
1397cdf0e10cSrcweir     while( pEntry )
1398cdf0e10cSrcweir 	{
1399cdf0e10cSrcweir 		SectReprPtr pRepr = (SectReprPtr)pEntry->GetUserData();
1400cdf0e10cSrcweir         if(bSet)
1401cdf0e10cSrcweir         {
1402cdf0e10cSrcweir             if(!pRepr->GetTempPasswd().getLength() || bChange)
1403cdf0e10cSrcweir             {
1404cdf0e10cSrcweir                 SwTestPasswdDlg aPasswdDlg(this);
1405cdf0e10cSrcweir                 aPasswdDlg.ShowExtras(SHOWEXTRAS_CONFIRM);
1406cdf0e10cSrcweir                 if(RET_OK == aPasswdDlg.Execute())
1407cdf0e10cSrcweir                 {
1408cdf0e10cSrcweir                     String sNewPasswd( aPasswdDlg.GetPassword() );
1409cdf0e10cSrcweir                     if( aPasswdDlg.GetConfirm() == sNewPasswd )
1410cdf0e10cSrcweir                     {
1411cdf0e10cSrcweir                         SvPasswordHelper::GetHashPassword( pRepr->GetTempPasswd(), sNewPasswd );
1412cdf0e10cSrcweir                     }
1413cdf0e10cSrcweir                     else
1414cdf0e10cSrcweir                     {
1415cdf0e10cSrcweir                         InfoBox(pBox, SW_RES(REG_WRONG_PASSWD_REPEAT)).Execute();
1416cdf0e10cSrcweir                         ChangePasswdHdl(pBox);
1417cdf0e10cSrcweir                         break;
1418cdf0e10cSrcweir                     }
1419cdf0e10cSrcweir                 }
1420cdf0e10cSrcweir                 else
1421cdf0e10cSrcweir                 {
1422cdf0e10cSrcweir                     if(!bChange)
1423cdf0e10cSrcweir                         aPasswdCB.Check(sal_False);
1424cdf0e10cSrcweir                     break;
1425cdf0e10cSrcweir                 }
1426cdf0e10cSrcweir             }
1427cdf0e10cSrcweir             pRepr->GetSectionData().SetPassword(pRepr->GetTempPasswd());
1428cdf0e10cSrcweir         }
1429cdf0e10cSrcweir         else
1430cdf0e10cSrcweir         {
1431cdf0e10cSrcweir             pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >());
1432cdf0e10cSrcweir         }
1433cdf0e10cSrcweir 		pEntry = aTree.NextSelected(pEntry);
1434cdf0e10cSrcweir 	}
1435cdf0e10cSrcweir     return 0;
1436cdf0e10cSrcweir }
1437cdf0e10cSrcweir /*---------------------------------------------------------------------
1438cdf0e10cSrcweir 	Beschreibung:	Aktueller Bereichsname wird sofort beim editieren
1439cdf0e10cSrcweir 					in die TreeListBox eingetragen, mit leerem String
1440cdf0e10cSrcweir 					kein Ok()
1441cdf0e10cSrcweir ---------------------------------------------------------------------*/
1442cdf0e10cSrcweir 
1443cdf0e10cSrcweir IMPL_LINK( SwEditRegionDlg, NameEditHdl, Edit *, EMPTYARG )
1444cdf0e10cSrcweir {
1445cdf0e10cSrcweir     if(!CheckPasswd(0))
1446cdf0e10cSrcweir         return 0;
1447cdf0e10cSrcweir     SvLBoxEntry* pEntry=aTree.FirstSelected();
1448cdf0e10cSrcweir 	DBG_ASSERT(pEntry,"kein Entry gefunden");
1449cdf0e10cSrcweir 	if (pEntry)
1450cdf0e10cSrcweir 	{
1451cdf0e10cSrcweir 		String	aName = aCurName.GetText();
1452cdf0e10cSrcweir 		aTree.SetEntryText(pEntry,aName);
1453cdf0e10cSrcweir         SectReprPtr pRepr = (SectReprPtr) pEntry->GetUserData();
1454cdf0e10cSrcweir         pRepr->GetSectionData().SetSectionName(aName);
1455cdf0e10cSrcweir 
1456cdf0e10cSrcweir 		aOK.Enable(aName.Len() != 0);
1457cdf0e10cSrcweir 	}
1458cdf0e10cSrcweir 	return 0;
1459cdf0e10cSrcweir }
1460cdf0e10cSrcweir /*---------------------------------------------------------------------
1461cdf0e10cSrcweir 
1462cdf0e10cSrcweir ---------------------------------------------------------------------*/
1463cdf0e10cSrcweir 
1464cdf0e10cSrcweir IMPL_LINK( SwEditRegionDlg, ConditionEditHdl, Edit *, pEdit )
1465cdf0e10cSrcweir {
1466cdf0e10cSrcweir     Selection aSelect = pEdit->GetSelection();
1467cdf0e10cSrcweir     if(!CheckPasswd(0))
1468cdf0e10cSrcweir         return 0;
1469cdf0e10cSrcweir     pEdit->SetSelection(aSelect);
1470cdf0e10cSrcweir     SvLBoxEntry* pEntry = aTree.FirstSelected();
1471cdf0e10cSrcweir 	DBG_ASSERT(pEntry,"kein Entry gefunden");
1472cdf0e10cSrcweir 	while( pEntry )
1473cdf0e10cSrcweir 	{
1474cdf0e10cSrcweir 		SectReprPtr pRepr = (SectReprPtr)pEntry->GetUserData();
1475cdf0e10cSrcweir         pRepr->GetSectionData().SetCondition(pEdit->GetText());
1476cdf0e10cSrcweir 		pEntry = aTree.NextSelected(pEntry);
1477cdf0e10cSrcweir 	}
1478cdf0e10cSrcweir 	return 0;
1479cdf0e10cSrcweir }
1480cdf0e10cSrcweir 
1481cdf0e10cSrcweir IMPL_LINK( SwEditRegionDlg, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg )
1482cdf0e10cSrcweir {
1483cdf0e10cSrcweir     String sFileName, sFilterName, sPassword;
1484cdf0e10cSrcweir     if ( _pFileDlg->GetError() == ERRCODE_NONE )
1485cdf0e10cSrcweir     {
1486cdf0e10cSrcweir         SfxMedium* pMedium = m_pDocInserter->CreateMedium();
1487cdf0e10cSrcweir         if ( pMedium )
1488cdf0e10cSrcweir         {
1489cdf0e10cSrcweir             sFileName = pMedium->GetURLObject().GetMainURL( INetURLObject::NO_DECODE );
1490cdf0e10cSrcweir             sFilterName = pMedium->GetFilter()->GetFilterName();
1491cdf0e10cSrcweir             const SfxPoolItem* pItem;
1492cdf0e10cSrcweir             if ( SFX_ITEM_SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, sal_False, &pItem ) )
1493cdf0e10cSrcweir                 sPassword = ( (SfxStringItem*)pItem )->GetValue();
1494cdf0e10cSrcweir             ::lcl_ReadSections( *pMedium, aSubRegionED );
1495cdf0e10cSrcweir             delete pMedium;
1496cdf0e10cSrcweir         }
1497cdf0e10cSrcweir     }
1498cdf0e10cSrcweir 
1499cdf0e10cSrcweir     SvLBoxEntry* pEntry = aTree.FirstSelected();
1500cdf0e10cSrcweir     DBG_ASSERT( pEntry, "no entry found" );
1501cdf0e10cSrcweir     if ( pEntry )
1502cdf0e10cSrcweir     {
1503cdf0e10cSrcweir         SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
1504cdf0e10cSrcweir         pSectRepr->SetFile( sFileName );
1505cdf0e10cSrcweir         pSectRepr->SetFilter( sFilterName );
1506cdf0e10cSrcweir         pSectRepr->GetSectionData().SetLinkFilePassword(sPassword);
1507cdf0e10cSrcweir         aFileNameED.SetText( pSectRepr->GetFile() );
1508cdf0e10cSrcweir     }
1509cdf0e10cSrcweir 
1510cdf0e10cSrcweir     Application::SetDefDialogParent( m_pOldDefDlgParent );
1511cdf0e10cSrcweir     return 0;
1512cdf0e10cSrcweir }
1513cdf0e10cSrcweir /*-- 03.09.2009 16:24:18---------------------------------------------------
1514cdf0e10cSrcweir 
1515cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1516cdf0e10cSrcweir IMPL_LINK( SwEditRegionDlg, SubRegionEventHdl, VclWindowEvent *, pEvent )
1517cdf0e10cSrcweir {
1518cdf0e10cSrcweir     if( !bSubRegionsFilled && pEvent && pEvent->GetId() == VCLEVENT_DROPDOWN_PRE_OPEN )
1519cdf0e10cSrcweir     {
1520cdf0e10cSrcweir         //if necessary fill the names bookmarks/sections/tables now
1521cdf0e10cSrcweir 
1522cdf0e10cSrcweir         rtl::OUString sFileName = aFileNameED.GetText();
1523cdf0e10cSrcweir         if(sFileName.getLength())
1524cdf0e10cSrcweir         {
1525cdf0e10cSrcweir             SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
1526cdf0e10cSrcweir             INetURLObject aAbs;
1527cdf0e10cSrcweir             if( pMedium )
1528cdf0e10cSrcweir                 aAbs = pMedium->GetURLObject();
1529cdf0e10cSrcweir             sFileName = URIHelper::SmartRel2Abs(
1530cdf0e10cSrcweir                     aAbs, sFileName, URIHelper::GetMaybeFileHdl() );
1531cdf0e10cSrcweir 
1532cdf0e10cSrcweir             //load file and set the shell
1533cdf0e10cSrcweir             SfxMedium aMedium( sFileName, STREAM_STD_READ );
1534cdf0e10cSrcweir             sFileName = aMedium.GetURLObject().GetMainURL( INetURLObject::NO_DECODE );
1535cdf0e10cSrcweir             ::lcl_ReadSections( aMedium, aSubRegionED );
1536cdf0e10cSrcweir         }
1537cdf0e10cSrcweir         else
1538cdf0e10cSrcweir             lcl_FillSubRegionList( rSh, aSubRegionED, 0 );
1539cdf0e10cSrcweir         bSubRegionsFilled = true;
1540cdf0e10cSrcweir     }
1541cdf0e10cSrcweir     return 0;
1542cdf0e10cSrcweir }
1543cdf0e10cSrcweir 
1544cdf0e10cSrcweir /* -----------------------------08.05.2002 15:00------------------------------
1545cdf0e10cSrcweir 
1546cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
1547cdf0e10cSrcweir Image SwEditRegionDlg::BuildBitmap(sal_Bool bProtect,sal_Bool bHidden, sal_Bool bHighContrast)
1548cdf0e10cSrcweir {
1549cdf0e10cSrcweir     ImageList& rImgLst = bHighContrast ? aImageILH : aImageIL;
1550cdf0e10cSrcweir     return rImgLst.GetImage((!bHidden+(bProtect<<1)) + 1);
1551cdf0e10cSrcweir }
1552cdf0e10cSrcweir 
1553cdf0e10cSrcweir /*--------------------------------------------------------------------
1554cdf0e10cSrcweir 	Beschreibung:	Hilfsfunktion - Bereichsnamen aus dem Medium lesen
1555cdf0e10cSrcweir  --------------------------------------------------------------------*/
1556cdf0e10cSrcweir 
1557cdf0e10cSrcweir static void lcl_ReadSections( SfxMedium& rMedium, ComboBox& rBox )
1558cdf0e10cSrcweir {
1559cdf0e10cSrcweir 	rBox.Clear();
1560cdf0e10cSrcweir     uno::Reference < embed::XStorage > xStg;
1561cdf0e10cSrcweir     if( rMedium.IsStorage() && (xStg = rMedium.GetStorage()).is() )
1562cdf0e10cSrcweir 	{
1563cdf0e10cSrcweir         SvStrings aArr( 10, 10 );
1564cdf0e10cSrcweir         sal_uInt32 nFormat = SotStorage::GetFormatID( xStg );
1565cdf0e10cSrcweir         if ( nFormat == SOT_FORMATSTR_ID_STARWRITER_60 || nFormat == SOT_FORMATSTR_ID_STARWRITERGLOB_60 ||
1566cdf0e10cSrcweir             nFormat == SOT_FORMATSTR_ID_STARWRITER_8 || nFormat == SOT_FORMATSTR_ID_STARWRITERGLOB_8)
1567cdf0e10cSrcweir             SwGetReaderXML()->GetSectionList( rMedium, aArr );
1568cdf0e10cSrcweir 
1569cdf0e10cSrcweir 		for( sal_uInt16 n = 0; n < aArr.Count(); ++n )
1570cdf0e10cSrcweir 			rBox.InsertEntry( *aArr[ n ] );
1571cdf0e10cSrcweir 
1572cdf0e10cSrcweir         aArr.DeleteAndDestroy(0, aArr.Count());
1573cdf0e10cSrcweir 	}
1574cdf0e10cSrcweir }
1575cdf0e10cSrcweir /* -----------------21.05.99 10:16-------------------
1576cdf0e10cSrcweir  *
1577cdf0e10cSrcweir  * --------------------------------------------------*/
1578cdf0e10cSrcweir SwInsertSectionTabDialog::SwInsertSectionTabDialog(
1579cdf0e10cSrcweir 			Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh) :
1580cdf0e10cSrcweir 	SfxTabDialog( pParent, SW_RES(DLG_INSERT_SECTION), &rSet ),
1581cdf0e10cSrcweir     rWrtSh(rSh)
1582cdf0e10cSrcweir     , m_pSectionData(0)
1583cdf0e10cSrcweir {
1584cdf0e10cSrcweir 	String sInsert(SW_RES(ST_INSERT));
1585cdf0e10cSrcweir 	GetOKButton().SetText(sInsert);
1586cdf0e10cSrcweir 	FreeResource();
1587cdf0e10cSrcweir     SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1588cdf0e10cSrcweir     DBG_ASSERT(pFact, "Dialogdiet fail!");
1589cdf0e10cSrcweir 	AddTabPage(TP_INSERT_SECTION, SwInsertSectionTabPage::Create, 0);
1590cdf0e10cSrcweir 	AddTabPage(TP_COLUMN,	SwColumnPage::Create,  	 0);
1591cdf0e10cSrcweir     AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), 0);
1592cdf0e10cSrcweir 	AddTabPage(TP_SECTION_FTNENDNOTES, SwSectionFtnEndTabPage::Create, 0);
1593cdf0e10cSrcweir     AddTabPage(TP_SECTION_INDENTS, SwSectionIndentTabPage::Create, 0);
1594cdf0e10cSrcweir 
1595cdf0e10cSrcweir 	SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get();
1596cdf0e10cSrcweir 	long nHtmlMode = pHtmlOpt->GetExportMode();
1597cdf0e10cSrcweir 
1598cdf0e10cSrcweir 	sal_Bool bWeb = 0 != PTR_CAST( SwWebDocShell, rSh.GetView().GetDocShell() );
1599cdf0e10cSrcweir 	if(bWeb)
1600cdf0e10cSrcweir 	{
1601cdf0e10cSrcweir 		RemoveTabPage(TP_SECTION_FTNENDNOTES);
1602cdf0e10cSrcweir         RemoveTabPage(TP_SECTION_INDENTS);
1603cdf0e10cSrcweir         if( HTML_CFG_NS40 != nHtmlMode && HTML_CFG_WRITER != nHtmlMode)
1604cdf0e10cSrcweir 			RemoveTabPage(TP_COLUMN);
1605cdf0e10cSrcweir 	}
1606cdf0e10cSrcweir 	SetCurPageId(TP_INSERT_SECTION);
1607cdf0e10cSrcweir }
1608cdf0e10cSrcweir /* -----------------21.05.99 10:17-------------------
1609cdf0e10cSrcweir  *
1610cdf0e10cSrcweir  * --------------------------------------------------*/
1611cdf0e10cSrcweir SwInsertSectionTabDialog::~SwInsertSectionTabDialog()
1612cdf0e10cSrcweir {
1613cdf0e10cSrcweir }
1614cdf0e10cSrcweir /* -----------------21.05.99 10:23-------------------
1615cdf0e10cSrcweir  *
1616cdf0e10cSrcweir  * --------------------------------------------------*/
1617cdf0e10cSrcweir void SwInsertSectionTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
1618cdf0e10cSrcweir {
1619cdf0e10cSrcweir 	if(TP_INSERT_SECTION == nId)
1620cdf0e10cSrcweir 		((SwInsertSectionTabPage&)rPage).SetWrtShell(rWrtSh);
1621cdf0e10cSrcweir 	else if( TP_BACKGROUND == nId  )
1622cdf0e10cSrcweir     {
1623cdf0e10cSrcweir 			SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
1624cdf0e10cSrcweir 			aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, SVX_SHOW_SELECTOR));
1625cdf0e10cSrcweir 			rPage.PageCreated(aSet);
1626cdf0e10cSrcweir 	}
1627cdf0e10cSrcweir 	else if( TP_COLUMN == nId )
1628cdf0e10cSrcweir 	{
1629cdf0e10cSrcweir 		const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)GetInputSetImpl()->Get(RES_FRM_SIZE);
1630cdf0e10cSrcweir 		((SwColumnPage&)rPage).SetPageWidth(rSize.GetWidth());
1631cdf0e10cSrcweir 		((SwColumnPage&)rPage).ShowBalance(sal_True);
1632cdf0e10cSrcweir         ((SwColumnPage&)rPage).SetInSection(sal_True);
1633cdf0e10cSrcweir 	}
1634cdf0e10cSrcweir     else if(TP_SECTION_INDENTS == nId)
1635cdf0e10cSrcweir         ((SwSectionIndentTabPage&)rPage).SetWrtShell(rWrtSh);
1636cdf0e10cSrcweir }
1637cdf0e10cSrcweir /* -----------------21.05.99 13:08-------------------
1638cdf0e10cSrcweir  *
1639cdf0e10cSrcweir  * --------------------------------------------------*/
1640cdf0e10cSrcweir 
1641cdf0e10cSrcweir void SwInsertSectionTabDialog::SetSectionData(SwSectionData const& rSect)
1642cdf0e10cSrcweir {
1643cdf0e10cSrcweir     m_pSectionData.reset( new SwSectionData(rSect) );
1644cdf0e10cSrcweir }
1645cdf0e10cSrcweir /* -----------------21.05.99 13:10-------------------
1646cdf0e10cSrcweir  *
1647cdf0e10cSrcweir  * --------------------------------------------------*/
1648cdf0e10cSrcweir short	SwInsertSectionTabDialog::Ok()
1649cdf0e10cSrcweir {
1650cdf0e10cSrcweir 	short nRet = SfxTabDialog::Ok();
1651cdf0e10cSrcweir     DBG_ASSERT(m_pSectionData.get(),
1652cdf0e10cSrcweir             "SwInsertSectionTabDialog: no SectionData?");
1653cdf0e10cSrcweir     const SfxItemSet* pOutputItemSet = GetOutputItemSet();
1654cdf0e10cSrcweir     rWrtSh.InsertSection(*m_pSectionData, pOutputItemSet);
1655cdf0e10cSrcweir     SfxViewFrame* pViewFrm = rWrtSh.GetView().GetViewFrame();
1656cdf0e10cSrcweir     uno::Reference< frame::XDispatchRecorder > xRecorder =
1657cdf0e10cSrcweir             pViewFrm->GetBindings().GetRecorder();
1658cdf0e10cSrcweir     if ( xRecorder.is() )
1659cdf0e10cSrcweir     {
1660cdf0e10cSrcweir         SfxRequest aRequest( pViewFrm, FN_INSERT_REGION);
1661cdf0e10cSrcweir         const SfxPoolItem* pCol;
1662cdf0e10cSrcweir         if(SFX_ITEM_SET == pOutputItemSet->GetItemState(RES_COL, sal_False, &pCol))
1663cdf0e10cSrcweir         {
1664cdf0e10cSrcweir             aRequest.AppendItem(SfxUInt16Item(SID_ATTR_COLUMNS,
1665cdf0e10cSrcweir                 ((const SwFmtCol*)pCol)->GetColumns().Count()));
1666cdf0e10cSrcweir         }
1667cdf0e10cSrcweir         aRequest.AppendItem(SfxStringItem( FN_PARAM_REGION_NAME,
1668cdf0e10cSrcweir                     m_pSectionData->GetSectionName()));
1669cdf0e10cSrcweir         aRequest.AppendItem(SfxStringItem( FN_PARAM_REGION_CONDITION,
1670cdf0e10cSrcweir                     m_pSectionData->GetCondition()));
1671cdf0e10cSrcweir         aRequest.AppendItem(SfxBoolItem( FN_PARAM_REGION_HIDDEN,
1672cdf0e10cSrcweir                     m_pSectionData->IsHidden()));
1673cdf0e10cSrcweir         aRequest.AppendItem(SfxBoolItem( FN_PARAM_REGION_PROTECT,
1674cdf0e10cSrcweir                     m_pSectionData->IsProtectFlag()));
1675cdf0e10cSrcweir         // --> FME 2004-06-22 #114856# edit in readonly sections
1676cdf0e10cSrcweir         aRequest.AppendItem(SfxBoolItem( FN_PARAM_REGION_EDIT_IN_READONLY,
1677cdf0e10cSrcweir                     m_pSectionData->IsEditInReadonlyFlag()));
1678cdf0e10cSrcweir         // <--
1679cdf0e10cSrcweir 
1680cdf0e10cSrcweir         String sLinkFileName( m_pSectionData->GetLinkFileName() );
1681cdf0e10cSrcweir         aRequest.AppendItem(SfxStringItem( FN_PARAM_1, sLinkFileName.GetToken( 0, sfx2::cTokenSeperator )));
1682cdf0e10cSrcweir         aRequest.AppendItem(SfxStringItem( FN_PARAM_2, sLinkFileName.GetToken( 1, sfx2::cTokenSeperator )));
1683cdf0e10cSrcweir         aRequest.AppendItem(SfxStringItem( FN_PARAM_3, sLinkFileName.GetToken( 2, sfx2::cTokenSeperator )));
1684cdf0e10cSrcweir         aRequest.Done();
1685cdf0e10cSrcweir     }
1686cdf0e10cSrcweir     return nRet;
1687cdf0e10cSrcweir }
1688cdf0e10cSrcweir 
1689cdf0e10cSrcweir /* -----------------21.05.99 10:31-------------------
1690cdf0e10cSrcweir  *
1691cdf0e10cSrcweir  * --------------------------------------------------*/
1692cdf0e10cSrcweir SwInsertSectionTabPage::SwInsertSectionTabPage(
1693cdf0e10cSrcweir 							Window *pParent, const SfxItemSet &rAttrSet) :
1694cdf0e10cSrcweir 	SfxTabPage( pParent, SW_RES(TP_INSERT_SECTION), rAttrSet ),
1695cdf0e10cSrcweir     aNameFL       ( this, SW_RES( FL_NAME ) ),
1696cdf0e10cSrcweir     aCurName            ( this, SW_RES( ED_RNAME ) ),
1697cdf0e10cSrcweir     aLinkFL             ( this, SW_RES( FL_LINK ) ),
1698cdf0e10cSrcweir     aFileCB             ( this, SW_RES( CB_FILE ) ),
1699cdf0e10cSrcweir 	aDDECB              ( this, SW_RES( CB_DDE ) ) ,
1700cdf0e10cSrcweir 	aDDECommandFT       ( this, SW_RES( FT_DDE ) ) ,
1701cdf0e10cSrcweir     aFileNameFT         ( this, SW_RES( FT_FILE ) ) ,
1702cdf0e10cSrcweir 	aFileNameED         ( this, SW_RES( ED_FILE ) ),
1703cdf0e10cSrcweir     aFilePB             ( this, SW_RES( PB_FILE ) ),
1704cdf0e10cSrcweir     aSubRegionFT        ( this, SW_RES( FT_SUBREG ) ) ,
1705cdf0e10cSrcweir 	aSubRegionED        ( this, SW_RES( LB_SUBREG ) ) ,
1706cdf0e10cSrcweir 
1707cdf0e10cSrcweir     aProtectFL          ( this, SW_RES( FL_PROTECT ) ),
1708cdf0e10cSrcweir     aProtectCB          ( this, SW_RES( CB_PROTECT ) ),
1709cdf0e10cSrcweir     aPasswdCB           ( this, SW_RES( CB_PASSWD ) ),
1710cdf0e10cSrcweir     aPasswdPB           ( this, SW_RES( PB_PASSWD ) ),
1711cdf0e10cSrcweir 
1712cdf0e10cSrcweir     aHideFL             ( this, SW_RES( FL_HIDE ) ),
1713cdf0e10cSrcweir     aHideCB             ( this, SW_RES( CB_HIDE ) ),
1714cdf0e10cSrcweir     aConditionFT             ( this, SW_RES( FT_CONDITION ) ),
1715cdf0e10cSrcweir     aConditionED        ( this, SW_RES( ED_CONDITION ) ),
1716cdf0e10cSrcweir     // --> FME 2004-06-22 #114856# edit in readonly sections
1717cdf0e10cSrcweir     aPropertiesFL       ( this, SW_RES( FL_PROPERTIES ) ),
1718cdf0e10cSrcweir     aEditInReadonlyCB   ( this, SW_RES( CB_EDIT_IN_READONLY ) ),
1719cdf0e10cSrcweir     // <--
1720cdf0e10cSrcweir 
1721cdf0e10cSrcweir     m_pWrtSh(0),
1722cdf0e10cSrcweir     m_pDocInserter(NULL),
1723cdf0e10cSrcweir     m_pOldDefDlgParent(NULL)
1724cdf0e10cSrcweir {
1725cdf0e10cSrcweir 	FreeResource();
1726cdf0e10cSrcweir 
1727cdf0e10cSrcweir 	aProtectCB.SetClickHdl	( LINK( this, SwInsertSectionTabPage, ChangeProtectHdl));
1728cdf0e10cSrcweir     aPasswdCB.SetClickHdl   ( LINK( this, SwInsertSectionTabPage, ChangePasswdHdl));
1729cdf0e10cSrcweir     aPasswdPB.SetClickHdl   ( LINK( this, SwInsertSectionTabPage, ChangePasswdHdl));
1730cdf0e10cSrcweir     aHideCB.SetClickHdl     ( LINK( this, SwInsertSectionTabPage, ChangeHideHdl));
1731cdf0e10cSrcweir     // --> FME 2004-06-22 #114856# edit in readonly sections
1732cdf0e10cSrcweir     aEditInReadonlyCB.SetClickHdl       ( LINK( this, SwInsertSectionTabPage, ChangeEditInReadonlyHdl));
1733cdf0e10cSrcweir     // <--
1734cdf0e10cSrcweir     aFileCB.SetClickHdl     ( LINK( this, SwInsertSectionTabPage, UseFileHdl ));
1735cdf0e10cSrcweir 	aFilePB.SetClickHdl     ( LINK( this, SwInsertSectionTabPage, FileSearchHdl ));
1736cdf0e10cSrcweir 	aCurName.SetModifyHdl	( LINK( this, SwInsertSectionTabPage, NameEditHdl));
1737cdf0e10cSrcweir 	aDDECB.SetClickHdl		( LINK( this, SwInsertSectionTabPage, DDEHdl ));
1738cdf0e10cSrcweir     ChangeProtectHdl(&aProtectCB);
1739cdf0e10cSrcweir 	aPasswdPB.SetAccessibleRelationMemberOf(&aProtectFL);
1740cdf0e10cSrcweir     aSubRegionED.EnableAutocomplete( sal_True, sal_True );
1741cdf0e10cSrcweir }
1742cdf0e10cSrcweir /* -----------------21.05.99 10:31-------------------
1743cdf0e10cSrcweir  *
1744cdf0e10cSrcweir  * --------------------------------------------------*/
1745cdf0e10cSrcweir SwInsertSectionTabPage::~SwInsertSectionTabPage()
1746cdf0e10cSrcweir {
1747cdf0e10cSrcweir     delete m_pDocInserter;
1748cdf0e10cSrcweir }
1749cdf0e10cSrcweir 
1750cdf0e10cSrcweir void	SwInsertSectionTabPage::SetWrtShell(SwWrtShell& rSh)
1751cdf0e10cSrcweir {
1752cdf0e10cSrcweir     m_pWrtSh = &rSh;
1753cdf0e10cSrcweir 
1754cdf0e10cSrcweir     sal_Bool bWeb = 0 != PTR_CAST(SwWebDocShell, m_pWrtSh->GetView().GetDocShell());
1755cdf0e10cSrcweir 	if(bWeb)
1756cdf0e10cSrcweir 	{
1757cdf0e10cSrcweir 		aHideCB    		.Hide();
1758cdf0e10cSrcweir 		aConditionED    .Hide();
1759cdf0e10cSrcweir         aConditionFT    .Hide();
1760cdf0e10cSrcweir 		aDDECB           .Hide();
1761cdf0e10cSrcweir 		aDDECommandFT    .Hide();
1762cdf0e10cSrcweir 	}
1763cdf0e10cSrcweir 
1764cdf0e10cSrcweir     lcl_FillSubRegionList( *m_pWrtSh, aSubRegionED, &aCurName );
1765cdf0e10cSrcweir 
1766cdf0e10cSrcweir     SwSectionData *const pSectionData =
1767cdf0e10cSrcweir         static_cast<SwInsertSectionTabDialog*>(GetTabDialog())
1768cdf0e10cSrcweir             ->GetSectionData();
1769cdf0e10cSrcweir     if (pSectionData) // something set?
1770cdf0e10cSrcweir     {
1771cdf0e10cSrcweir         aCurName.SetText(
1772cdf0e10cSrcweir             rSh.GetUniqueSectionName(& pSectionData->GetSectionName()));
1773cdf0e10cSrcweir         aProtectCB.Check( 0 != pSectionData->IsProtectFlag() );
1774cdf0e10cSrcweir         m_sFileName = pSectionData->GetLinkFileName();
1775cdf0e10cSrcweir         m_sFilePasswd = pSectionData->GetLinkFilePassword();
1776cdf0e10cSrcweir         aFileCB.Check( 0 != m_sFileName.Len() );
1777cdf0e10cSrcweir         aFileNameED.SetText( m_sFileName );
1778cdf0e10cSrcweir 		UseFileHdl( &aFileCB );
1779cdf0e10cSrcweir 	}
1780cdf0e10cSrcweir 	else
1781cdf0e10cSrcweir 	{
1782cdf0e10cSrcweir 		aCurName.SetText( rSh.GetUniqueSectionName() );
1783cdf0e10cSrcweir 	}
1784cdf0e10cSrcweir }
1785cdf0e10cSrcweir /* -----------------21.05.99 10:32-------------------
1786cdf0e10cSrcweir  *
1787cdf0e10cSrcweir  * --------------------------------------------------*/
1788cdf0e10cSrcweir sal_Bool SwInsertSectionTabPage::FillItemSet( SfxItemSet& )
1789cdf0e10cSrcweir {
1790cdf0e10cSrcweir     SwSectionData aSection(CONTENT_SECTION, aCurName.GetText());
1791cdf0e10cSrcweir     aSection.SetCondition(aConditionED.GetText());
1792cdf0e10cSrcweir     sal_Bool bProtected = aProtectCB.IsChecked();
1793cdf0e10cSrcweir     aSection.SetProtectFlag(bProtected);
1794cdf0e10cSrcweir 	aSection.SetHidden(aHideCB.IsChecked());
1795cdf0e10cSrcweir     // --> FME 2004-06-22 #114856# edit in readonly sections
1796cdf0e10cSrcweir     aSection.SetEditInReadonlyFlag(aEditInReadonlyCB.IsChecked());
1797cdf0e10cSrcweir     // <--
1798cdf0e10cSrcweir     if(bProtected)
1799cdf0e10cSrcweir     {
1800cdf0e10cSrcweir         aSection.SetPassword(m_aNewPasswd);
1801cdf0e10cSrcweir     }
1802cdf0e10cSrcweir 	String sFileName = aFileNameED.GetText();
1803cdf0e10cSrcweir 	String sSubRegion = aSubRegionED.GetText();
1804cdf0e10cSrcweir 	sal_Bool bDDe = aDDECB.IsChecked();
1805cdf0e10cSrcweir 	if(aFileCB.IsChecked() && (sFileName.Len() || sSubRegion.Len() || bDDe))
1806cdf0e10cSrcweir 	{
1807cdf0e10cSrcweir 		String aLinkFile;
1808cdf0e10cSrcweir 		if( bDDe )
1809cdf0e10cSrcweir 		{
1810cdf0e10cSrcweir 			aLinkFile = sFileName;
1811cdf0e10cSrcweir 
1812cdf0e10cSrcweir 			sal_uInt16 nPos = 0;
1813cdf0e10cSrcweir 			while( STRING_NOTFOUND != (nPos = aLinkFile.SearchAscii( "  ", nPos )) )
1814cdf0e10cSrcweir 				aLinkFile.Erase( nPos--, 1 );
1815cdf0e10cSrcweir 
1816cdf0e10cSrcweir             nPos = aLinkFile.SearchAndReplace( ' ', sfx2::cTokenSeperator );
1817cdf0e10cSrcweir             aLinkFile.SearchAndReplace( ' ', sfx2::cTokenSeperator, nPos );
1818cdf0e10cSrcweir 		}
1819cdf0e10cSrcweir 		else
1820cdf0e10cSrcweir 		{
1821cdf0e10cSrcweir 			if(sFileName.Len())
1822cdf0e10cSrcweir 			{
1823cdf0e10cSrcweir                 SfxMedium* pMedium = m_pWrtSh->GetView().GetDocShell()->GetMedium();
1824cdf0e10cSrcweir                 INetURLObject aAbs;
1825cdf0e10cSrcweir                 if( pMedium )
1826cdf0e10cSrcweir                     aAbs = pMedium->GetURLObject();
1827cdf0e10cSrcweir                 aLinkFile = URIHelper::SmartRel2Abs(
1828cdf0e10cSrcweir                     aAbs, sFileName, URIHelper::GetMaybeFileHdl() );
1829cdf0e10cSrcweir                 aSection.SetLinkFilePassword( m_sFilePasswd );
1830cdf0e10cSrcweir 			}
1831cdf0e10cSrcweir 
1832cdf0e10cSrcweir             aLinkFile += sfx2::cTokenSeperator;
1833cdf0e10cSrcweir             aLinkFile += m_sFilterName;
1834cdf0e10cSrcweir             aLinkFile += sfx2::cTokenSeperator;
1835cdf0e10cSrcweir 			aLinkFile += sSubRegion;
1836cdf0e10cSrcweir         }
1837cdf0e10cSrcweir 
1838cdf0e10cSrcweir 		aSection.SetLinkFileName(aLinkFile);
1839cdf0e10cSrcweir 		if(aLinkFile.Len())
1840cdf0e10cSrcweir 		{
1841cdf0e10cSrcweir 			aSection.SetType( aDDECB.IsChecked() ?
1842cdf0e10cSrcweir 									DDE_LINK_SECTION :
1843cdf0e10cSrcweir 										FILE_LINK_SECTION);
1844cdf0e10cSrcweir 		}
1845cdf0e10cSrcweir 	}
1846cdf0e10cSrcweir     ((SwInsertSectionTabDialog*)GetTabDialog())->SetSectionData(aSection);
1847cdf0e10cSrcweir 	return sal_True;
1848cdf0e10cSrcweir }
1849cdf0e10cSrcweir /* -----------------21.05.99 10:32-------------------
1850cdf0e10cSrcweir  *
1851cdf0e10cSrcweir  * --------------------------------------------------*/
1852cdf0e10cSrcweir void SwInsertSectionTabPage::Reset( const SfxItemSet& )
1853cdf0e10cSrcweir {
1854cdf0e10cSrcweir }
1855cdf0e10cSrcweir /* -----------------21.05.99 11:22-------------------
1856cdf0e10cSrcweir  *
1857cdf0e10cSrcweir  * --------------------------------------------------*/
1858cdf0e10cSrcweir SfxTabPage*	SwInsertSectionTabPage::Create( Window* pParent,
1859cdf0e10cSrcweir 								const SfxItemSet& rAttrSet)
1860cdf0e10cSrcweir {
1861cdf0e10cSrcweir 	return new SwInsertSectionTabPage(pParent, rAttrSet);
1862cdf0e10cSrcweir }
1863cdf0e10cSrcweir /*---------------------------------------------------------------------
1864cdf0e10cSrcweir 
1865cdf0e10cSrcweir ---------------------------------------------------------------------*/
1866cdf0e10cSrcweir 
1867cdf0e10cSrcweir IMPL_LINK( SwInsertSectionTabPage, ChangeHideHdl, CheckBox *, pBox )
1868cdf0e10cSrcweir {
1869cdf0e10cSrcweir 	sal_Bool bHide = pBox->IsChecked();
1870cdf0e10cSrcweir     aConditionED.Enable(bHide);
1871cdf0e10cSrcweir     aConditionFT.Enable(bHide);
1872cdf0e10cSrcweir 	return 0;
1873cdf0e10cSrcweir }
1874cdf0e10cSrcweir /*---------------------------------------------------------------------
1875cdf0e10cSrcweir 
1876cdf0e10cSrcweir ---------------------------------------------------------------------*/
1877cdf0e10cSrcweir 
1878cdf0e10cSrcweir IMPL_LINK( SwInsertSectionTabPage, ChangeEditInReadonlyHdl, CheckBox *, EMPTYARG )
1879cdf0e10cSrcweir {
1880cdf0e10cSrcweir     return 0;
1881cdf0e10cSrcweir }
1882cdf0e10cSrcweir /*---------------------------------------------------------------------
1883cdf0e10cSrcweir 
1884cdf0e10cSrcweir ---------------------------------------------------------------------*/
1885cdf0e10cSrcweir 
1886cdf0e10cSrcweir IMPL_LINK( SwInsertSectionTabPage, ChangeProtectHdl, CheckBox *, pBox )
1887cdf0e10cSrcweir {
1888cdf0e10cSrcweir     sal_Bool bCheck = pBox->IsChecked();
1889cdf0e10cSrcweir     aPasswdCB.Enable(bCheck);
1890cdf0e10cSrcweir     aPasswdPB.Enable(bCheck);
1891cdf0e10cSrcweir     return 0;
1892cdf0e10cSrcweir }
1893cdf0e10cSrcweir /* -----------------------------26.04.01 14:50--------------------------------
1894cdf0e10cSrcweir 
1895cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
1896cdf0e10cSrcweir IMPL_LINK( SwInsertSectionTabPage, ChangePasswdHdl, Button *, pButton )
1897cdf0e10cSrcweir {
1898cdf0e10cSrcweir     sal_Bool bChange = pButton == &aPasswdPB;
1899cdf0e10cSrcweir     sal_Bool bSet = bChange ? bChange : aPasswdCB.IsChecked();
1900cdf0e10cSrcweir     if(bSet)
1901cdf0e10cSrcweir     {
1902cdf0e10cSrcweir         if(!m_aNewPasswd.getLength() || bChange)
1903cdf0e10cSrcweir         {
1904cdf0e10cSrcweir             SwTestPasswdDlg aPasswdDlg(this);
1905cdf0e10cSrcweir             aPasswdDlg.ShowExtras(SHOWEXTRAS_CONFIRM);
1906cdf0e10cSrcweir             if(RET_OK == aPasswdDlg.Execute())
1907cdf0e10cSrcweir             {
1908cdf0e10cSrcweir                 String sNewPasswd( aPasswdDlg.GetPassword() );
1909cdf0e10cSrcweir                 if( aPasswdDlg.GetConfirm() == sNewPasswd )
1910cdf0e10cSrcweir                 {
1911cdf0e10cSrcweir                     SvPasswordHelper::GetHashPassword( m_aNewPasswd, sNewPasswd );
1912cdf0e10cSrcweir                 }
1913cdf0e10cSrcweir                 else
1914cdf0e10cSrcweir                 {
1915cdf0e10cSrcweir                     InfoBox(pButton, SW_RES(REG_WRONG_PASSWD_REPEAT)).Execute();
1916cdf0e10cSrcweir                 }
1917cdf0e10cSrcweir             }
1918cdf0e10cSrcweir             else if(!bChange)
1919cdf0e10cSrcweir                 aPasswdCB.Check(sal_False);
1920cdf0e10cSrcweir         }
1921cdf0e10cSrcweir     }
1922cdf0e10cSrcweir     else
1923cdf0e10cSrcweir         m_aNewPasswd.realloc(0);
1924cdf0e10cSrcweir     return 0;
1925cdf0e10cSrcweir }
1926cdf0e10cSrcweir /*---------------------------------------------------------------------
1927cdf0e10cSrcweir 
1928cdf0e10cSrcweir ---------------------------------------------------------------------*/
1929cdf0e10cSrcweir 
1930cdf0e10cSrcweir IMPL_LINK_INLINE_START( SwInsertSectionTabPage, NameEditHdl, Edit *, EMPTYARG )
1931cdf0e10cSrcweir {
1932cdf0e10cSrcweir 	String	aName=aCurName.GetText();
1933cdf0e10cSrcweir 	GetTabDialog()->GetOKButton().Enable(aName.Len() && aCurName.GetEntryPos( aName ) == USHRT_MAX);
1934cdf0e10cSrcweir 	return 0;
1935cdf0e10cSrcweir }
1936cdf0e10cSrcweir IMPL_LINK_INLINE_END( SwInsertSectionTabPage, NameEditHdl, Edit *, EMPTYARG )
1937cdf0e10cSrcweir 
1938cdf0e10cSrcweir /*---------------------------------------------------------------------
1939cdf0e10cSrcweir 
1940cdf0e10cSrcweir ---------------------------------------------------------------------*/
1941cdf0e10cSrcweir 
1942cdf0e10cSrcweir IMPL_LINK( SwInsertSectionTabPage, UseFileHdl, CheckBox *, pBox )
1943cdf0e10cSrcweir {
1944cdf0e10cSrcweir 	if( pBox->IsChecked() )
1945cdf0e10cSrcweir 	{
1946cdf0e10cSrcweir         if( m_pWrtSh->HasSelection() &&
1947cdf0e10cSrcweir 			RET_NO == QueryBox( this, SW_RES(QB_CONNECT) ).Execute() )
1948cdf0e10cSrcweir 			pBox->Check( sal_False );
1949cdf0e10cSrcweir 	}
1950cdf0e10cSrcweir 
1951cdf0e10cSrcweir 	sal_Bool bFile = pBox->IsChecked();
1952cdf0e10cSrcweir 	aFileNameFT.Enable(bFile);
1953cdf0e10cSrcweir 	aFileNameED.Enable(bFile);
1954cdf0e10cSrcweir 	aFilePB.Enable(bFile);
1955cdf0e10cSrcweir 	aSubRegionFT.Enable(bFile);
1956cdf0e10cSrcweir 	aSubRegionED.Enable(bFile);
1957cdf0e10cSrcweir 	aDDECommandFT.Enable(bFile);
1958cdf0e10cSrcweir 	aDDECB.Enable(bFile);
1959cdf0e10cSrcweir 	if( bFile )
1960cdf0e10cSrcweir 	{
1961cdf0e10cSrcweir //		aFileNameED.SetText( aFileName );
1962cdf0e10cSrcweir 		aFileNameED.GrabFocus();
1963cdf0e10cSrcweir 		aProtectCB.Check( sal_True );
1964cdf0e10cSrcweir 	}
1965cdf0e10cSrcweir 	else
1966cdf0e10cSrcweir 	{
1967cdf0e10cSrcweir 		aDDECB.Check(sal_False);
1968cdf0e10cSrcweir 		DDEHdl(&aDDECB);
1969cdf0e10cSrcweir //		aFileNameED.SetText(aEmptyStr);
1970cdf0e10cSrcweir 	}
1971cdf0e10cSrcweir 	return 0;
1972cdf0e10cSrcweir }
1973cdf0e10cSrcweir 
1974cdf0e10cSrcweir /*---------------------------------------------------------------------
1975cdf0e10cSrcweir 
1976cdf0e10cSrcweir ---------------------------------------------------------------------*/
1977cdf0e10cSrcweir 
1978cdf0e10cSrcweir IMPL_LINK( SwInsertSectionTabPage, FileSearchHdl, PushButton *, EMPTYARG )
1979cdf0e10cSrcweir {
1980cdf0e10cSrcweir     m_pOldDefDlgParent = Application::GetDefDialogParent();
1981cdf0e10cSrcweir     Application::SetDefDialogParent( this );
1982cdf0e10cSrcweir     if ( m_pDocInserter )
1983cdf0e10cSrcweir         delete m_pDocInserter;
1984cdf0e10cSrcweir     m_pDocInserter = new ::sfx2::DocumentInserter( 0, String::CreateFromAscii("swriter") );
1985cdf0e10cSrcweir     m_pDocInserter->StartExecuteModal( LINK( this, SwInsertSectionTabPage, DlgClosedHdl ) );
1986cdf0e10cSrcweir     return 0;
1987cdf0e10cSrcweir }
1988cdf0e10cSrcweir 
1989cdf0e10cSrcweir /*---------------------------------------------------------------------
1990cdf0e10cSrcweir 
1991cdf0e10cSrcweir ---------------------------------------------------------------------*/
1992cdf0e10cSrcweir 
1993cdf0e10cSrcweir IMPL_LINK( SwInsertSectionTabPage, DDEHdl, CheckBox*, pBox )
1994cdf0e10cSrcweir {
1995cdf0e10cSrcweir 	sal_Bool bDDE = pBox->IsChecked();
1996cdf0e10cSrcweir 	sal_Bool bFile = aFileCB.IsChecked();
1997cdf0e10cSrcweir 	aFilePB.Enable(!bDDE && bFile);
1998cdf0e10cSrcweir 	if(bDDE)
1999cdf0e10cSrcweir 	{
2000cdf0e10cSrcweir 		aFileNameFT.Hide();
2001cdf0e10cSrcweir 		aDDECommandFT.Enable(bDDE);
2002cdf0e10cSrcweir 		aDDECommandFT.Show();
2003cdf0e10cSrcweir 		aSubRegionFT.Hide();
2004cdf0e10cSrcweir 		aSubRegionED.Hide();
2005cdf0e10cSrcweir 		aFileNameED.SetAccessibleName(aDDECommandFT.GetText());
2006cdf0e10cSrcweir 	}
2007cdf0e10cSrcweir 	else
2008cdf0e10cSrcweir 	{
2009cdf0e10cSrcweir 		aDDECommandFT.Hide();
2010cdf0e10cSrcweir 		aFileNameFT.Enable(bFile);
2011cdf0e10cSrcweir 		aFileNameFT.Show();
2012cdf0e10cSrcweir 		aSubRegionFT.Show();
2013cdf0e10cSrcweir 		aSubRegionED.Show();
2014cdf0e10cSrcweir 		aSubRegionED.Enable(bFile);
2015cdf0e10cSrcweir 		aFileNameED.SetAccessibleName(aFileNameFT.GetText());
2016cdf0e10cSrcweir 	}
2017cdf0e10cSrcweir 	return 0;
2018cdf0e10cSrcweir }
2019cdf0e10cSrcweir 
2020cdf0e10cSrcweir IMPL_LINK( SwInsertSectionTabPage, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg )
2021cdf0e10cSrcweir {
2022cdf0e10cSrcweir     if ( _pFileDlg->GetError() == ERRCODE_NONE )
2023cdf0e10cSrcweir     {
2024cdf0e10cSrcweir         SfxMedium* pMedium = m_pDocInserter->CreateMedium();
2025cdf0e10cSrcweir         if ( pMedium )
2026cdf0e10cSrcweir         {
2027cdf0e10cSrcweir             m_sFileName = pMedium->GetURLObject().GetMainURL( INetURLObject::NO_DECODE );
2028cdf0e10cSrcweir             m_sFilterName = pMedium->GetFilter()->GetFilterName();
2029cdf0e10cSrcweir             const SfxPoolItem* pItem;
2030cdf0e10cSrcweir             if ( SFX_ITEM_SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, sal_False, &pItem ) )
2031cdf0e10cSrcweir                 m_sFilePasswd = ( (SfxStringItem*)pItem )->GetValue();
2032cdf0e10cSrcweir             aFileNameED.SetText( INetURLObject::decode(
2033cdf0e10cSrcweir                 m_sFileName, INET_HEX_ESCAPE, INetURLObject::DECODE_UNAMBIGUOUS, RTL_TEXTENCODING_UTF8 ) );
2034cdf0e10cSrcweir             ::lcl_ReadSections( *pMedium, aSubRegionED );
2035cdf0e10cSrcweir             delete pMedium;
2036cdf0e10cSrcweir         }
2037cdf0e10cSrcweir     }
2038cdf0e10cSrcweir     else
2039cdf0e10cSrcweir         m_sFilterName = m_sFilePasswd = aEmptyStr;
2040cdf0e10cSrcweir 
2041cdf0e10cSrcweir     Application::SetDefDialogParent( m_pOldDefDlgParent );
2042cdf0e10cSrcweir     return 0;
2043cdf0e10cSrcweir }
2044cdf0e10cSrcweir 
2045cdf0e10cSrcweir // --------------------------------------------------------------
2046cdf0e10cSrcweir 
2047cdf0e10cSrcweir // Numerierungsformat Umsetzung:
2048cdf0e10cSrcweir // ListBox	- Format			- Enum-Wert
2049cdf0e10cSrcweir // 0 		- A, B, C, ...		- 0
2050cdf0e10cSrcweir // 1		- a, b, c, ...		- 1
2051cdf0e10cSrcweir // 2		- I, II, III, ... 	- 2
2052cdf0e10cSrcweir // 3        - i, ii, iii, ...	- 3
2053cdf0e10cSrcweir // 4        - 1, 2, 3, ...		- 4
2054cdf0e10cSrcweir // 5        - A, .., AA, .., 	- 9
2055cdf0e10cSrcweir // 6        - a, .., aa, .., 	- 10
2056cdf0e10cSrcweir 
2057cdf0e10cSrcweir inline sal_uInt16 GetNumPos( sal_uInt16 n )
2058cdf0e10cSrcweir {
2059cdf0e10cSrcweir 	return SVX_NUM_ARABIC < n ? n - 4 : n;
2060cdf0e10cSrcweir }
2061cdf0e10cSrcweir 
2062cdf0e10cSrcweir inline SvxExtNumType GetNumType( sal_uInt16 n )
2063cdf0e10cSrcweir {
2064cdf0e10cSrcweir 	return (SvxExtNumType)(4 < n ? n + 4 : n );
2065cdf0e10cSrcweir }
2066cdf0e10cSrcweir 
2067cdf0e10cSrcweir SwSectionFtnEndTabPage::SwSectionFtnEndTabPage( Window *pParent,
2068cdf0e10cSrcweir 												const SfxItemSet &rAttrSet)
2069cdf0e10cSrcweir 	: SfxTabPage( pParent, SW_RES( TP_SECTION_FTNENDNOTES ), rAttrSet ),
2070cdf0e10cSrcweir     aFtnFL              ( this, SW_RES( FL_FTN ) ),
2071cdf0e10cSrcweir 	aFtnNtAtTextEndCB   ( this, SW_RES( CB_FTN_AT_TXTEND ) ),
2072cdf0e10cSrcweir 
2073cdf0e10cSrcweir     aFtnNtNumCB         ( this, SW_RES( CB_FTN_NUM ) ),
2074cdf0e10cSrcweir     aFtnOffsetLbl       ( this, SW_RES( FT_FTN_OFFSET   )),
2075cdf0e10cSrcweir     aFtnOffsetFld       ( this, SW_RES( FLD_FTN_OFFSET   )),
2076cdf0e10cSrcweir 
2077cdf0e10cSrcweir     aFtnNtNumFmtCB      ( this, SW_RES( CB_FTN_NUM_FMT ) ),
2078cdf0e10cSrcweir     aFtnPrefixFT        ( this, SW_RES( FT_FTN_PREFIX   )),
2079cdf0e10cSrcweir     aFtnPrefixED        ( this, SW_RES( ED_FTN_PREFIX    )),
2080cdf0e10cSrcweir     aFtnNumViewBox      ( this, SW_RES( LB_FTN_NUMVIEW  ), INSERT_NUM_EXTENDED_TYPES),
2081cdf0e10cSrcweir 	aFtnSuffixFT		( this, SW_RES( FT_FTN_SUFFIX    )),
2082cdf0e10cSrcweir 	aFtnSuffixED		( this, SW_RES( ED_FTN_SUFFIX    )),
2083cdf0e10cSrcweir 
2084cdf0e10cSrcweir     aEndFL              ( this, SW_RES( FL_END ) ),
2085cdf0e10cSrcweir 	aEndNtAtTextEndCB   ( this, SW_RES( CB_END_AT_TXTEND )),
2086cdf0e10cSrcweir 
2087cdf0e10cSrcweir     aEndNtNumCB         ( this, SW_RES( CB_END_NUM )),
2088cdf0e10cSrcweir     aEndOffsetLbl       ( this, SW_RES( FT_END_OFFSET   )),
2089cdf0e10cSrcweir     aEndOffsetFld       ( this, SW_RES( FLD_END_OFFSET   )),
2090cdf0e10cSrcweir 
2091cdf0e10cSrcweir     aEndNtNumFmtCB      ( this, SW_RES( CB_END_NUM_FMT ) ),
2092cdf0e10cSrcweir     aEndPrefixFT        ( this, SW_RES( FT_END_PREFIX   )),
2093cdf0e10cSrcweir     aEndPrefixED        ( this, SW_RES( ED_END_PREFIX    )),
2094cdf0e10cSrcweir     aEndNumViewBox      ( this, SW_RES( LB_END_NUMVIEW  ), INSERT_NUM_EXTENDED_TYPES),
2095cdf0e10cSrcweir 	aEndSuffixFT		( this, SW_RES( FT_END_SUFFIX    )),
2096cdf0e10cSrcweir 	aEndSuffixED		( this, SW_RES( ED_END_SUFFIX    ))
2097cdf0e10cSrcweir {
2098cdf0e10cSrcweir 	FreeResource();
2099cdf0e10cSrcweir 
2100cdf0e10cSrcweir 	Link aLk( LINK( this, SwSectionFtnEndTabPage, FootEndHdl));
2101cdf0e10cSrcweir 	aFtnNtAtTextEndCB.SetClickHdl( aLk );
2102cdf0e10cSrcweir 	aFtnNtNumCB.SetClickHdl( aLk );
2103cdf0e10cSrcweir 	aEndNtAtTextEndCB.SetClickHdl( aLk );
2104cdf0e10cSrcweir 	aEndNtNumCB.SetClickHdl( aLk );
2105cdf0e10cSrcweir 	aFtnNtNumFmtCB.SetClickHdl( aLk );
2106cdf0e10cSrcweir 	aEndNtNumFmtCB.SetClickHdl( aLk );
2107cdf0e10cSrcweir }
2108cdf0e10cSrcweir 
2109cdf0e10cSrcweir SwSectionFtnEndTabPage::~SwSectionFtnEndTabPage()
2110cdf0e10cSrcweir {
2111cdf0e10cSrcweir }
2112cdf0e10cSrcweir 
2113cdf0e10cSrcweir sal_Bool SwSectionFtnEndTabPage::FillItemSet( SfxItemSet& rSet )
2114cdf0e10cSrcweir {
2115cdf0e10cSrcweir 	SwFmtFtnAtTxtEnd aFtn( aFtnNtAtTextEndCB.IsChecked()
2116cdf0e10cSrcweir 							? ( aFtnNtNumCB.IsChecked()
2117cdf0e10cSrcweir 								? ( aFtnNtNumFmtCB.IsChecked()
2118cdf0e10cSrcweir 									? FTNEND_ATTXTEND_OWNNUMANDFMT
2119cdf0e10cSrcweir 									: FTNEND_ATTXTEND_OWNNUMSEQ )
2120cdf0e10cSrcweir 								: FTNEND_ATTXTEND )
2121cdf0e10cSrcweir 							: FTNEND_ATPGORDOCEND );
2122cdf0e10cSrcweir 
2123cdf0e10cSrcweir 	switch( aFtn.GetValue() )
2124cdf0e10cSrcweir 	{
2125cdf0e10cSrcweir 	case FTNEND_ATTXTEND_OWNNUMANDFMT:
2126cdf0e10cSrcweir 		aFtn.SetNumType( aFtnNumViewBox.GetSelectedNumberingType() );
2127cdf0e10cSrcweir 		aFtn.SetPrefix( aFtnPrefixED.GetText() );
2128cdf0e10cSrcweir 		aFtn.SetSuffix( aFtnSuffixED.GetText() );
2129cdf0e10cSrcweir 		// no break;
2130cdf0e10cSrcweir 
2131cdf0e10cSrcweir 	case FTNEND_ATTXTEND_OWNNUMSEQ:
2132cdf0e10cSrcweir         aFtn.SetOffset( static_cast< sal_uInt16 >( aFtnOffsetFld.GetValue()-1 ) );
2133cdf0e10cSrcweir 		// no break;
2134cdf0e10cSrcweir 	}
2135cdf0e10cSrcweir 
2136cdf0e10cSrcweir 	SwFmtEndAtTxtEnd aEnd( aEndNtAtTextEndCB.IsChecked()
2137cdf0e10cSrcweir 							? ( aEndNtNumCB.IsChecked()
2138cdf0e10cSrcweir 								? ( aEndNtNumFmtCB.IsChecked()
2139cdf0e10cSrcweir 									? FTNEND_ATTXTEND_OWNNUMANDFMT
2140cdf0e10cSrcweir 									: FTNEND_ATTXTEND_OWNNUMSEQ )
2141cdf0e10cSrcweir 								: FTNEND_ATTXTEND )
2142cdf0e10cSrcweir 							: FTNEND_ATPGORDOCEND );
2143cdf0e10cSrcweir 
2144cdf0e10cSrcweir 	switch( aEnd.GetValue() )
2145cdf0e10cSrcweir 	{
2146cdf0e10cSrcweir 	case FTNEND_ATTXTEND_OWNNUMANDFMT:
2147cdf0e10cSrcweir         aEnd.SetNumType( aEndNumViewBox.GetSelectedNumberingType() );
2148cdf0e10cSrcweir 		aEnd.SetPrefix( aEndPrefixED.GetText() );
2149cdf0e10cSrcweir 		aEnd.SetSuffix( aEndSuffixED.GetText() );
2150cdf0e10cSrcweir 		// no break;
2151cdf0e10cSrcweir 
2152cdf0e10cSrcweir 	case FTNEND_ATTXTEND_OWNNUMSEQ:
2153cdf0e10cSrcweir         aEnd.SetOffset( static_cast< sal_uInt16 >( aEndOffsetFld.GetValue()-1 ) );
2154cdf0e10cSrcweir 		// no break;
2155cdf0e10cSrcweir 	}
2156cdf0e10cSrcweir 
2157cdf0e10cSrcweir 	rSet.Put( aFtn );
2158cdf0e10cSrcweir 	rSet.Put( aEnd );
2159cdf0e10cSrcweir 
2160cdf0e10cSrcweir 	return sal_True;
2161cdf0e10cSrcweir }
2162cdf0e10cSrcweir 
2163cdf0e10cSrcweir void SwSectionFtnEndTabPage::ResetState( sal_Bool bFtn,
2164cdf0e10cSrcweir 									const SwFmtFtnEndAtTxtEnd& rAttr )
2165cdf0e10cSrcweir {
2166cdf0e10cSrcweir 	CheckBox *pNtAtTextEndCB, *pNtNumCB, *pNtNumFmtCB;
2167cdf0e10cSrcweir 	FixedText*pPrefixFT, *pSuffixFT;
2168cdf0e10cSrcweir 	Edit *pPrefixED, *pSuffixED;
2169cdf0e10cSrcweir 	SwNumberingTypeListBox *pNumViewBox;
2170cdf0e10cSrcweir 	FixedText* pOffsetTxt;
2171cdf0e10cSrcweir 	NumericField *pOffsetFld;
2172cdf0e10cSrcweir 
2173cdf0e10cSrcweir 	if( bFtn )
2174cdf0e10cSrcweir 	{
2175cdf0e10cSrcweir 		pNtAtTextEndCB = &aFtnNtAtTextEndCB;
2176cdf0e10cSrcweir 		pNtNumCB = &aFtnNtNumCB;
2177cdf0e10cSrcweir 		pNtNumFmtCB = &aFtnNtNumFmtCB;
2178cdf0e10cSrcweir 		pPrefixFT = &aFtnPrefixFT;
2179cdf0e10cSrcweir 		pPrefixED = &aFtnPrefixED;
2180cdf0e10cSrcweir 		pSuffixFT = &aFtnSuffixFT;
2181cdf0e10cSrcweir 		pSuffixED = &aFtnSuffixED;
2182cdf0e10cSrcweir 		pNumViewBox = &aFtnNumViewBox;
2183cdf0e10cSrcweir 		pOffsetTxt = &aFtnOffsetLbl;
2184cdf0e10cSrcweir 		pOffsetFld = &aFtnOffsetFld;
2185cdf0e10cSrcweir 	}
2186cdf0e10cSrcweir 	else
2187cdf0e10cSrcweir 	{
2188cdf0e10cSrcweir 		pNtAtTextEndCB = &aEndNtAtTextEndCB;
2189cdf0e10cSrcweir 		pNtNumCB = &aEndNtNumCB;
2190cdf0e10cSrcweir 		pNtNumFmtCB = &aEndNtNumFmtCB;
2191cdf0e10cSrcweir 		pPrefixFT = &aEndPrefixFT;
2192cdf0e10cSrcweir 		pPrefixED = &aEndPrefixED;
2193cdf0e10cSrcweir 		pSuffixFT = &aEndSuffixFT;
2194cdf0e10cSrcweir 		pSuffixED = &aEndSuffixED;
2195cdf0e10cSrcweir 		pNumViewBox = &aEndNumViewBox;
2196cdf0e10cSrcweir 		pOffsetTxt = &aEndOffsetLbl;
2197cdf0e10cSrcweir 		pOffsetFld = &aEndOffsetFld;
2198cdf0e10cSrcweir 	}
2199cdf0e10cSrcweir 
2200cdf0e10cSrcweir 	sal_uInt16 eState = rAttr.GetValue();
2201cdf0e10cSrcweir 	switch( eState )
2202cdf0e10cSrcweir 	{
2203cdf0e10cSrcweir 	// case FTNEND_ATPGORDOCEND:
2204cdf0e10cSrcweir 	case FTNEND_ATTXTEND_OWNNUMANDFMT:
2205cdf0e10cSrcweir 		pNtNumFmtCB->SetState( STATE_CHECK );
2206cdf0e10cSrcweir 		// no break;
2207cdf0e10cSrcweir 
2208cdf0e10cSrcweir 	case FTNEND_ATTXTEND_OWNNUMSEQ:
2209cdf0e10cSrcweir 		pNtNumCB->SetState( STATE_CHECK );
2210cdf0e10cSrcweir 		// no break;
2211cdf0e10cSrcweir 
2212cdf0e10cSrcweir 	case FTNEND_ATTXTEND:
2213cdf0e10cSrcweir 		pNtAtTextEndCB->SetState( STATE_CHECK );
2214cdf0e10cSrcweir 		// no break;
2215cdf0e10cSrcweir 	}
2216cdf0e10cSrcweir 
2217cdf0e10cSrcweir 	pNumViewBox->SelectNumberingType( rAttr.GetNumType() );
2218cdf0e10cSrcweir 	pOffsetFld->SetValue( rAttr.GetOffset() + 1 );
2219cdf0e10cSrcweir 	pPrefixED->SetText( rAttr.GetPrefix() );
2220cdf0e10cSrcweir 	pSuffixED->SetText( rAttr.GetSuffix() );
2221cdf0e10cSrcweir 
2222cdf0e10cSrcweir 	switch( eState )
2223cdf0e10cSrcweir 	{
2224cdf0e10cSrcweir 	case FTNEND_ATPGORDOCEND:
2225cdf0e10cSrcweir 		pNtNumCB->Enable( sal_False );
2226cdf0e10cSrcweir 		// no break;
2227cdf0e10cSrcweir 
2228cdf0e10cSrcweir 	case FTNEND_ATTXTEND:
2229cdf0e10cSrcweir 		pNtNumFmtCB->Enable( sal_False );
2230cdf0e10cSrcweir 		pOffsetFld->Enable( sal_False );
2231cdf0e10cSrcweir 		pOffsetTxt->Enable( sal_False );
2232cdf0e10cSrcweir 		// no break;
2233cdf0e10cSrcweir 
2234cdf0e10cSrcweir 	case FTNEND_ATTXTEND_OWNNUMSEQ:
2235cdf0e10cSrcweir 		pNumViewBox->Enable( sal_False );
2236cdf0e10cSrcweir 		pPrefixFT->Enable( sal_False );
2237cdf0e10cSrcweir 		pPrefixED->Enable( sal_False );
2238cdf0e10cSrcweir 		pSuffixFT->Enable( sal_False );
2239cdf0e10cSrcweir 		pSuffixED->Enable( sal_False );
2240cdf0e10cSrcweir 		// no break;
2241cdf0e10cSrcweir 	}
2242cdf0e10cSrcweir }
2243cdf0e10cSrcweir 
2244cdf0e10cSrcweir void SwSectionFtnEndTabPage::Reset( const SfxItemSet& rSet )
2245cdf0e10cSrcweir {
2246cdf0e10cSrcweir 	ResetState( sal_True, (const SwFmtFtnAtTxtEnd&)rSet.Get(
2247cdf0e10cSrcweir 									RES_FTN_AT_TXTEND, sal_False ));
2248cdf0e10cSrcweir 	ResetState( sal_False, (const SwFmtEndAtTxtEnd&)rSet.Get(
2249cdf0e10cSrcweir 									RES_END_AT_TXTEND, sal_False ));
2250cdf0e10cSrcweir }
2251cdf0e10cSrcweir 
2252cdf0e10cSrcweir SfxTabPage*	SwSectionFtnEndTabPage::Create( Window* pParent,
2253cdf0e10cSrcweir 								const SfxItemSet& rAttrSet)
2254cdf0e10cSrcweir {
2255cdf0e10cSrcweir 	return new SwSectionFtnEndTabPage(pParent, rAttrSet);
2256cdf0e10cSrcweir }
2257cdf0e10cSrcweir 
2258cdf0e10cSrcweir IMPL_LINK( SwSectionFtnEndTabPage, FootEndHdl, CheckBox *, pBox )
2259cdf0e10cSrcweir {
2260cdf0e10cSrcweir //	pBox->EnableTriState( sal_False );
2261cdf0e10cSrcweir 	sal_Bool bFoot = &aFtnNtAtTextEndCB == pBox || &aFtnNtNumCB == pBox ||
2262cdf0e10cSrcweir 					&aFtnNtNumFmtCB == pBox ;
2263cdf0e10cSrcweir 
2264cdf0e10cSrcweir 	CheckBox *pNumBox, *pNumFmtBox, *pEndBox;
2265cdf0e10cSrcweir 	SwNumberingTypeListBox* pNumViewBox;
2266cdf0e10cSrcweir 	FixedText* pOffsetTxt;
2267cdf0e10cSrcweir 	NumericField *pOffsetFld;
2268cdf0e10cSrcweir 	FixedText*pPrefixFT, *pSuffixFT;
2269cdf0e10cSrcweir 	Edit *pPrefixED, *pSuffixED;
2270cdf0e10cSrcweir 
2271cdf0e10cSrcweir 	if( bFoot )
2272cdf0e10cSrcweir 	{
2273cdf0e10cSrcweir 		pEndBox = &aFtnNtAtTextEndCB;
2274cdf0e10cSrcweir 		pNumBox = &aFtnNtNumCB;
2275cdf0e10cSrcweir 		pNumFmtBox = &aFtnNtNumFmtCB;
2276cdf0e10cSrcweir 		pNumViewBox = &aFtnNumViewBox;
2277cdf0e10cSrcweir 		pOffsetTxt = &aFtnOffsetLbl;
2278cdf0e10cSrcweir 		pOffsetFld = &aFtnOffsetFld;
2279cdf0e10cSrcweir 		pPrefixFT = &aFtnPrefixFT;
2280cdf0e10cSrcweir 		pSuffixFT = &aFtnSuffixFT;
2281cdf0e10cSrcweir 		pPrefixED = &aFtnPrefixED;
2282cdf0e10cSrcweir 		pSuffixED = &aFtnSuffixED;
2283cdf0e10cSrcweir 	}
2284cdf0e10cSrcweir 	else
2285cdf0e10cSrcweir 	{
2286cdf0e10cSrcweir 		pEndBox = &aEndNtAtTextEndCB;
2287cdf0e10cSrcweir 		pNumBox = &aEndNtNumCB;
2288cdf0e10cSrcweir 		pNumFmtBox = &aEndNtNumFmtCB;
2289cdf0e10cSrcweir 		pNumViewBox = &aEndNumViewBox;
2290cdf0e10cSrcweir 		pOffsetTxt = &aEndOffsetLbl;
2291cdf0e10cSrcweir 		pOffsetFld = &aEndOffsetFld;
2292cdf0e10cSrcweir 		pPrefixFT = &aEndPrefixFT;
2293cdf0e10cSrcweir 		pSuffixFT = &aEndSuffixFT;
2294cdf0e10cSrcweir 		pPrefixED = &aEndPrefixED;
2295cdf0e10cSrcweir 		pSuffixED = &aEndSuffixED;
2296cdf0e10cSrcweir 	}
2297cdf0e10cSrcweir 
2298cdf0e10cSrcweir 	sal_Bool bEnableAtEnd = STATE_CHECK == pEndBox->GetState();
2299cdf0e10cSrcweir 	sal_Bool bEnableNum = bEnableAtEnd && STATE_CHECK == pNumBox->GetState();
2300cdf0e10cSrcweir 	sal_Bool bEnableNumFmt = bEnableNum && STATE_CHECK == pNumFmtBox->GetState();
2301cdf0e10cSrcweir 
2302cdf0e10cSrcweir 	pNumBox->Enable( bEnableAtEnd );
2303cdf0e10cSrcweir 	pOffsetTxt->Enable( bEnableNum );
2304cdf0e10cSrcweir 	pOffsetFld->Enable( bEnableNum );
2305cdf0e10cSrcweir 	pNumFmtBox->Enable( bEnableNum );
2306cdf0e10cSrcweir 	pNumViewBox->Enable( bEnableNumFmt );
2307cdf0e10cSrcweir 	pPrefixED->Enable( bEnableNumFmt );
2308cdf0e10cSrcweir 	pSuffixED->Enable( bEnableNumFmt );
2309cdf0e10cSrcweir 	pPrefixFT->Enable( bEnableNumFmt );
2310cdf0e10cSrcweir 	pSuffixFT->Enable( bEnableNumFmt );
2311cdf0e10cSrcweir 
2312cdf0e10cSrcweir 	return 0;
2313cdf0e10cSrcweir }
2314cdf0e10cSrcweir 
2315cdf0e10cSrcweir /* -----------------21.05.99 13:59-------------------
2316cdf0e10cSrcweir  *
2317cdf0e10cSrcweir  * --------------------------------------------------*/
2318cdf0e10cSrcweir SwSectionPropertyTabDialog::SwSectionPropertyTabDialog(
2319cdf0e10cSrcweir 	Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh) :
2320cdf0e10cSrcweir     SfxTabDialog(pParent, SW_RES(DLG_SECTION_PROPERTIES), &rSet),
2321cdf0e10cSrcweir     rWrtSh(rSh)
2322cdf0e10cSrcweir {
2323cdf0e10cSrcweir 	FreeResource();
2324cdf0e10cSrcweir     SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
2325cdf0e10cSrcweir     DBG_ASSERT(pFact, "Dialogdiet fail!");
2326cdf0e10cSrcweir 	AddTabPage(TP_COLUMN,	SwColumnPage::Create,  	 0);
2327cdf0e10cSrcweir     AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), 0 );
2328cdf0e10cSrcweir 	AddTabPage(TP_SECTION_FTNENDNOTES, SwSectionFtnEndTabPage::Create, 0);
2329cdf0e10cSrcweir     AddTabPage(TP_SECTION_INDENTS, SwSectionIndentTabPage::Create, 0);
2330cdf0e10cSrcweir 
2331cdf0e10cSrcweir 	SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get();
2332cdf0e10cSrcweir 	long nHtmlMode = pHtmlOpt->GetExportMode();
2333cdf0e10cSrcweir 	sal_Bool bWeb = 0 != PTR_CAST( SwWebDocShell, rSh.GetView().GetDocShell() );
2334cdf0e10cSrcweir 	if(bWeb)
2335cdf0e10cSrcweir 	{
2336cdf0e10cSrcweir 		RemoveTabPage(TP_SECTION_FTNENDNOTES);
2337cdf0e10cSrcweir         RemoveTabPage(TP_SECTION_INDENTS);
2338cdf0e10cSrcweir         if( HTML_CFG_NS40 != nHtmlMode && HTML_CFG_WRITER != nHtmlMode)
2339cdf0e10cSrcweir 			RemoveTabPage(TP_COLUMN);
2340cdf0e10cSrcweir 	}
2341cdf0e10cSrcweir }
2342cdf0e10cSrcweir /* -----------------21.05.99 13:59-------------------
2343cdf0e10cSrcweir  *
2344cdf0e10cSrcweir  * --------------------------------------------------*/
2345cdf0e10cSrcweir SwSectionPropertyTabDialog::~SwSectionPropertyTabDialog()
2346cdf0e10cSrcweir {
2347cdf0e10cSrcweir }
2348cdf0e10cSrcweir /* -----------------21.05.99 13:59-------------------
2349cdf0e10cSrcweir  *
2350cdf0e10cSrcweir  * --------------------------------------------------*/
2351cdf0e10cSrcweir void SwSectionPropertyTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
2352cdf0e10cSrcweir {
2353cdf0e10cSrcweir 	if( TP_BACKGROUND == nId  )
2354cdf0e10cSrcweir     {
2355cdf0e10cSrcweir 			SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
2356cdf0e10cSrcweir 			aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, SVX_SHOW_SELECTOR));
2357cdf0e10cSrcweir 			rPage.PageCreated(aSet);
2358cdf0e10cSrcweir 	}
2359cdf0e10cSrcweir 	else if( TP_COLUMN == nId )
2360cdf0e10cSrcweir     {
2361cdf0e10cSrcweir 		((SwColumnPage&)rPage).ShowBalance(sal_True);
2362cdf0e10cSrcweir         ((SwColumnPage&)rPage).SetInSection(sal_True);
2363cdf0e10cSrcweir     }
2364cdf0e10cSrcweir     else if(TP_SECTION_INDENTS == nId)
2365cdf0e10cSrcweir         ((SwSectionIndentTabPage&)rPage).SetWrtShell(rWrtSh);
2366cdf0e10cSrcweir }
2367cdf0e10cSrcweir /*-- 13.06.2003 09:59:08---------------------------------------------------
2368cdf0e10cSrcweir 
2369cdf0e10cSrcweir   -----------------------------------------------------------------------*/
2370cdf0e10cSrcweir SwSectionIndentTabPage::SwSectionIndentTabPage( Window *pParent, const SfxItemSet &rAttrSet ) :
2371cdf0e10cSrcweir     SfxTabPage(pParent, SW_RES(TP_SECTION_INDENTS), rAttrSet),
2372cdf0e10cSrcweir     aIndentFL(this,     SW_RES(FL_INDENT     )),
2373cdf0e10cSrcweir     aBeforeFT(this,     SW_RES(FT_BEFORE     )),
2374cdf0e10cSrcweir     aBeforeMF(this,     SW_RES(MF_BEFORE     )),
2375cdf0e10cSrcweir     aAfterFT(this,      SW_RES(FT_AFTER      )),
2376cdf0e10cSrcweir     aAfterMF(this,      SW_RES(MF_AFTER      )),
2377cdf0e10cSrcweir     aPreviewWin(this,   SW_RES(WIN_PREVIEW   ))
2378cdf0e10cSrcweir {
2379cdf0e10cSrcweir     FreeResource();
2380cdf0e10cSrcweir     Link aLk = LINK(this, SwSectionIndentTabPage, IndentModifyHdl);
2381cdf0e10cSrcweir     aBeforeMF.SetModifyHdl(aLk);
2382cdf0e10cSrcweir     aAfterMF.SetModifyHdl(aLk);
2383cdf0e10cSrcweir     aPreviewWin.SetAccessibleName(aIndentFL.GetText());
2384cdf0e10cSrcweir }
2385cdf0e10cSrcweir /*-- 13.06.2003 09:59:23---------------------------------------------------
2386cdf0e10cSrcweir 
2387cdf0e10cSrcweir   -----------------------------------------------------------------------*/
2388cdf0e10cSrcweir SwSectionIndentTabPage::~SwSectionIndentTabPage()
2389cdf0e10cSrcweir {
2390cdf0e10cSrcweir }
2391cdf0e10cSrcweir /*-- 13.06.2003 09:59:23---------------------------------------------------
2392cdf0e10cSrcweir 
2393cdf0e10cSrcweir   -----------------------------------------------------------------------*/
2394cdf0e10cSrcweir sal_Bool SwSectionIndentTabPage::FillItemSet( SfxItemSet& rSet)
2395cdf0e10cSrcweir {
2396cdf0e10cSrcweir     if(aBeforeMF.IsValueModified() ||
2397cdf0e10cSrcweir             aAfterMF.IsValueModified())
2398cdf0e10cSrcweir     {
2399cdf0e10cSrcweir         SvxLRSpaceItem aLRSpace(
2400cdf0e10cSrcweir                 static_cast< long >(aBeforeMF.Denormalize(aBeforeMF.GetValue(FUNIT_TWIP))) ,
2401cdf0e10cSrcweir                 static_cast< long >(aAfterMF.Denormalize(aAfterMF.GetValue(FUNIT_TWIP))), 0, 0, RES_LR_SPACE);
2402cdf0e10cSrcweir         rSet.Put(aLRSpace);
2403cdf0e10cSrcweir     }
2404cdf0e10cSrcweir     return sal_True;
2405cdf0e10cSrcweir }
2406cdf0e10cSrcweir /*-- 13.06.2003 09:59:24---------------------------------------------------
2407cdf0e10cSrcweir 
2408cdf0e10cSrcweir   -----------------------------------------------------------------------*/
2409cdf0e10cSrcweir void SwSectionIndentTabPage::Reset( const SfxItemSet& rSet)
2410cdf0e10cSrcweir {
2411cdf0e10cSrcweir     //this page doesn't show up in HTML mode
2412cdf0e10cSrcweir     FieldUnit aMetric = ::GetDfltMetric(sal_False);
2413cdf0e10cSrcweir     SetMetric(aBeforeMF, aMetric);
2414cdf0e10cSrcweir     SetMetric(aAfterMF , aMetric);
2415cdf0e10cSrcweir 
2416cdf0e10cSrcweir     SfxItemState eItemState = rSet.GetItemState( RES_LR_SPACE );
2417cdf0e10cSrcweir     if ( eItemState >= SFX_ITEM_AVAILABLE )
2418cdf0e10cSrcweir     {
2419cdf0e10cSrcweir         const SvxLRSpaceItem& rSpace =
2420cdf0e10cSrcweir             (const SvxLRSpaceItem&)rSet.Get( RES_LR_SPACE );
2421cdf0e10cSrcweir 
2422cdf0e10cSrcweir         aBeforeMF.SetValue( aBeforeMF.Normalize(rSpace.GetLeft()), FUNIT_TWIP );
2423cdf0e10cSrcweir         aAfterMF.SetValue( aAfterMF.Normalize(rSpace.GetRight()), FUNIT_TWIP );
2424cdf0e10cSrcweir     }
2425cdf0e10cSrcweir     else
2426cdf0e10cSrcweir     {
2427cdf0e10cSrcweir         aBeforeMF.SetEmptyFieldValue();
2428cdf0e10cSrcweir         aAfterMF.SetEmptyFieldValue();
2429cdf0e10cSrcweir     }
2430cdf0e10cSrcweir     aBeforeMF.SaveValue();
2431cdf0e10cSrcweir     aAfterMF.SaveValue();
2432cdf0e10cSrcweir     IndentModifyHdl(0);
2433cdf0e10cSrcweir }
2434cdf0e10cSrcweir /*-- 13.06.2003 09:59:24---------------------------------------------------
2435cdf0e10cSrcweir 
2436cdf0e10cSrcweir   -----------------------------------------------------------------------*/
2437cdf0e10cSrcweir SfxTabPage*  SwSectionIndentTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet)
2438cdf0e10cSrcweir {
2439cdf0e10cSrcweir     return new SwSectionIndentTabPage(pParent, rAttrSet);
2440cdf0e10cSrcweir }
2441cdf0e10cSrcweir /* -----------------13.06.2003 13:57-----------------
2442cdf0e10cSrcweir 
2443cdf0e10cSrcweir  --------------------------------------------------*/
2444cdf0e10cSrcweir void SwSectionIndentTabPage::SetWrtShell(SwWrtShell& rSh)
2445cdf0e10cSrcweir {
2446cdf0e10cSrcweir     //set sensible values at the preview
2447cdf0e10cSrcweir     aPreviewWin.SetAdjust(SVX_ADJUST_BLOCK);
2448cdf0e10cSrcweir     aPreviewWin.SetLastLine(SVX_ADJUST_BLOCK);
2449cdf0e10cSrcweir     const SwRect& rPageRect = rSh.GetAnyCurRect( RECT_PAGE, 0 );
2450cdf0e10cSrcweir     Size aPageSize(rPageRect.Width(), rPageRect.Height());
2451cdf0e10cSrcweir     aPreviewWin.SetSize(aPageSize);
2452cdf0e10cSrcweir }
2453cdf0e10cSrcweir /* -----------------13.06.2003 14:02-----------------
2454cdf0e10cSrcweir 
2455cdf0e10cSrcweir  --------------------------------------------------*/
2456cdf0e10cSrcweir IMPL_LINK(SwSectionIndentTabPage, IndentModifyHdl, MetricField*, EMPTYARG)
2457cdf0e10cSrcweir {
2458cdf0e10cSrcweir     aPreviewWin.SetLeftMargin( static_cast< long >(aBeforeMF.Denormalize(aBeforeMF.GetValue(FUNIT_TWIP))) );
2459cdf0e10cSrcweir     aPreviewWin.SetRightMargin( static_cast< long >(aAfterMF.Denormalize(aAfterMF.GetValue(FUNIT_TWIP))) );
2460cdf0e10cSrcweir     aPreviewWin.Draw(sal_True);
2461cdf0e10cSrcweir     return 0;
2462cdf0e10cSrcweir }
2463cdf0e10cSrcweir 
2464