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