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