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