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