LCOV - code coverage report
Current view: top level - sw/source/ui/dialog - uiregionsw.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 1286 0.0 %
Date: 2014-04-11 Functions: 0 123 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <hintids.hxx>
      21             : #include <regionsw.hxx>
      22             : #include <svl/urihelper.hxx>
      23             : #include <svl/PasswordHelper.hxx>
      24             : #include <vcl/svapp.hxx>
      25             : #include <vcl/msgbox.hxx>
      26             : #include <svl/stritem.hxx>
      27             : #include <svl/eitem.hxx>
      28             : #include <sfx2/passwd.hxx>
      29             : #include <sfx2/docfilt.hxx>
      30             : #include <sfx2/request.hxx>
      31             : #include <sfx2/docfile.hxx>
      32             : #include <sfx2/linkmgr.hxx>
      33             : #include <sfx2/docinsert.hxx>
      34             : #include <sfx2/filedlghelper.hxx>
      35             : #include <editeng/sizeitem.hxx>
      36             : #include <svtools/htmlcfg.hxx>
      37             : #include "svtools/treelistentry.hxx"
      38             : 
      39             : #include <comphelper/storagehelper.hxx>
      40             : #include <uitool.hxx>
      41             : #include <IMark.hxx>
      42             : #include <section.hxx>
      43             : #include <docary.hxx>
      44             : #include <doc.hxx>
      45             : #include <basesh.hxx>
      46             : #include <wdocsh.hxx>
      47             : #include <view.hxx>
      48             : #include <swmodule.hxx>
      49             : #include <wrtsh.hxx>
      50             : #include <swundo.hxx>
      51             : #include <column.hxx>
      52             : #include <fmtfsize.hxx>
      53             : #include <shellio.hxx>
      54             : 
      55             : #include <helpid.h>
      56             : #include <cmdid.h>
      57             : #include <../../core/uibase/dialog/regionsw.hrc>
      58             : #include <comcore.hrc>
      59             : #include <globals.hrc>
      60             : #include <sfx2/bindings.hxx>
      61             : #include <sfx2/htmlmode.hxx>
      62             : #include <svx/dlgutil.hxx>
      63             : #include <svx/dialogs.hrc>
      64             : #include <svx/svxdlg.hxx>
      65             : #include <svx/flagsdef.hxx>
      66             : 
      67             : using namespace ::com::sun::star;
      68             : 
      69             : static void   lcl_ReadSections( SfxMedium& rMedium, ComboBox& rBox );
      70             : 
      71           0 : static void lcl_FillList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAvailNames, const SwSectionFmt* pNewFmt )
      72             : {
      73             :     const SwSectionFmt* pFmt;
      74           0 :     if( !pNewFmt )
      75             :     {
      76           0 :         const sal_uInt16 nCount = rSh.GetSectionFmtCount();
      77           0 :         for(sal_uInt16 i=0;i<nCount;i++)
      78             :         {
      79             :             SectionType eTmpType;
      80           0 :             if( !(pFmt = &rSh.GetSectionFmt(i))->GetParent() &&
      81           0 :                     pFmt->IsInNodesArr() &&
      82           0 :                     (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
      83           0 :                     && TOX_HEADER_SECTION != eTmpType )
      84             :             {
      85           0 :                     const OUString sString(pFmt->GetSection()->GetSectionName());
      86           0 :                     if(pAvailNames)
      87           0 :                         pAvailNames->InsertEntry(sString);
      88           0 :                     rSubRegions.InsertEntry(sString);
      89           0 :                     lcl_FillList( rSh, rSubRegions, pAvailNames, pFmt );
      90             :             }
      91             :         }
      92             :     }
      93             :     else
      94             :     {
      95           0 :         SwSections aTmpArr;
      96           0 :         const sal_uInt16 nCnt = pNewFmt->GetChildSections(aTmpArr,SORTSECT_POS);
      97           0 :         if( nCnt )
      98             :         {
      99             :             SectionType eTmpType;
     100           0 :             for( sal_uInt16 n = 0; n < nCnt; ++n )
     101           0 :                 if( (pFmt = aTmpArr[n]->GetFmt())->IsInNodesArr()&&
     102           0 :                     (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
     103           0 :                     && TOX_HEADER_SECTION != eTmpType )
     104             :                 {
     105           0 :                     const OUString sString(pFmt->GetSection()->GetSectionName());
     106           0 :                     if(pAvailNames)
     107           0 :                         pAvailNames->InsertEntry(sString);
     108           0 :                     rSubRegions.InsertEntry(sString);
     109           0 :                     lcl_FillList( rSh, rSubRegions, pAvailNames, pFmt );
     110             :                 }
     111           0 :         }
     112             :     }
     113           0 : }
     114             : 
     115           0 : static void lcl_FillSubRegionList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAvailNames )
     116             : {
     117           0 :     lcl_FillList( rSh, rSubRegions, pAvailNames, 0 );
     118           0 :     IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
     119           0 :     for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getBookmarksBegin();
     120           0 :         ppMark != pMarkAccess->getBookmarksBegin();
     121             :         ++ppMark)
     122             :     {
     123           0 :         const ::sw::mark::IMark* pBkmk = ppMark->get();
     124           0 :         if( pBkmk->IsExpanded() )
     125           0 :             rSubRegions.InsertEntry( pBkmk->GetName() );
     126             :     }
     127           0 : }
     128             : 
     129             : /*----------------------------------------------------------------------------
     130             :  Description: user data class for region information
     131             : ----------------------------------------------------------------------------*/
     132             : 
     133           0 : class SectRepr
     134             : {
     135             : private:
     136             :     SwSectionData           m_SectionData;
     137             :     SwFmtCol                m_Col;
     138             :     SvxBrushItem            m_Brush;
     139             :     SwFmtFtnAtTxtEnd        m_FtnNtAtEnd;
     140             :     SwFmtEndAtTxtEnd        m_EndNtAtEnd;
     141             :     SwFmtNoBalancedColumns  m_Balance;
     142             :     SvxFrameDirectionItem   m_FrmDirItem;
     143             :     SvxLRSpaceItem          m_LRSpaceItem;
     144             :     sal_uInt16                  m_nArrPos;
     145             :     // shows, if maybe textcontent is in the region
     146             :     bool                    m_bContent  : 1;
     147             :     // for multiselection, mark at first, then work with TreeListBox!
     148             :     bool                    m_bSelected : 1;
     149             :     uno::Sequence<sal_Int8> m_TempPasswd;
     150             : 
     151             : public:
     152             :     SectRepr(sal_uInt16 nPos, SwSection& rSect);
     153             :     bool    operator==(const SectRepr& rSectRef) const
     154             :             { return m_nArrPos == rSectRef.GetArrPos(); }
     155             : 
     156           0 :     bool    operator< (const SectRepr& rSectRef) const
     157           0 :             { return m_nArrPos <  rSectRef.GetArrPos(); }
     158             : 
     159           0 :     SwSectionData &     GetSectionData()        { return m_SectionData; }
     160             :     SwSectionData const&GetSectionData() const  { return m_SectionData; }
     161           0 :     SwFmtCol&               GetCol()            { return m_Col; }
     162           0 :     SvxBrushItem&           GetBackground()     { return m_Brush; }
     163           0 :     SwFmtFtnAtTxtEnd&       GetFtnNtAtEnd()     { return m_FtnNtAtEnd; }
     164           0 :     SwFmtEndAtTxtEnd&       GetEndNtAtEnd()     { return m_EndNtAtEnd; }
     165           0 :     SwFmtNoBalancedColumns& GetBalance()        { return m_Balance; }
     166           0 :     SvxFrameDirectionItem&  GetFrmDir()         { return m_FrmDirItem; }
     167           0 :     SvxLRSpaceItem&         GetLRSpace()        { return m_LRSpaceItem; }
     168             : 
     169           0 :     sal_uInt16              GetArrPos() const { return m_nArrPos; }
     170             :     OUString            GetFile() const;
     171             :     OUString            GetSubRegion() const;
     172             :     void                SetFile(OUString const& rFile);
     173             :     void                SetFilter(OUString const& rFilter);
     174             :     void                SetSubRegion(OUString const& rSubRegion);
     175             : 
     176           0 :     bool                IsContent() { return m_bContent; }
     177           0 :     void                SetContent(bool const bValue) { m_bContent = bValue; }
     178             : 
     179           0 :     void                SetSelected() { m_bSelected = true; }
     180           0 :     bool                IsSelected() const { return m_bSelected; }
     181             : 
     182           0 :     uno::Sequence<sal_Int8> & GetTempPasswd() { return m_TempPasswd; }
     183           0 :     void SetTempPasswd(const uno::Sequence<sal_Int8> & rPasswd)
     184           0 :         { m_TempPasswd = rPasswd; }
     185             : };
     186             : 
     187           0 : SectRepr::SectRepr( sal_uInt16 nPos, SwSection& rSect )
     188             :     : m_SectionData( rSect )
     189             :     , m_Brush( RES_BACKGROUND )
     190             :     , m_FrmDirItem( FRMDIR_ENVIRONMENT, RES_FRAMEDIR )
     191             :     , m_LRSpaceItem( RES_LR_SPACE )
     192             :     , m_nArrPos(nPos)
     193           0 :     , m_bContent(m_SectionData.GetLinkFileName().isEmpty())
     194           0 :     , m_bSelected(false)
     195             : {
     196           0 :     SwSectionFmt *pFmt = rSect.GetFmt();
     197           0 :     if( pFmt )
     198             :     {
     199           0 :         m_Col = pFmt->GetCol();
     200           0 :         m_Brush = pFmt->GetBackground();
     201           0 :         m_FtnNtAtEnd = pFmt->GetFtnAtTxtEnd();
     202           0 :         m_EndNtAtEnd = pFmt->GetEndAtTxtEnd();
     203           0 :         m_Balance.SetValue(pFmt->GetBalancedColumns().GetValue());
     204           0 :         m_FrmDirItem = pFmt->GetFrmDir();
     205           0 :         m_LRSpaceItem = pFmt->GetLRSpace();
     206             :     }
     207           0 : }
     208             : 
     209           0 : void SectRepr::SetFile( const OUString& rFile )
     210             : {
     211             :     OUString sNewFile( INetURLObject::decode( rFile, '%',
     212             :                                            INetURLObject::DECODE_UNAMBIGUOUS,
     213           0 :                                         RTL_TEXTENCODING_UTF8 ));
     214           0 :     const OUString sOldFileName( m_SectionData.GetLinkFileName() );
     215           0 :     const OUString sSub( sOldFileName.getToken( 2, sfx2::cTokenSeparator ) );
     216             : 
     217           0 :     if( !rFile.isEmpty() || !sSub.isEmpty() )
     218             :     {
     219           0 :         sNewFile += OUString(sfx2::cTokenSeparator);
     220           0 :         if( !rFile.isEmpty() ) // Filter only with FileName
     221           0 :             sNewFile += sOldFileName.getToken( 1, sfx2::cTokenSeparator );
     222             : 
     223           0 :         sNewFile += OUString(sfx2::cTokenSeparator) + sSub;
     224             :     }
     225             : 
     226           0 :     m_SectionData.SetLinkFileName( sNewFile );
     227             : 
     228           0 :     if( !rFile.isEmpty() || !sSub.isEmpty() )
     229             :     {
     230           0 :         m_SectionData.SetType( FILE_LINK_SECTION );
     231             :     }
     232             :     else
     233             :     {
     234           0 :         m_SectionData.SetType( CONTENT_SECTION );
     235           0 :     }
     236           0 : }
     237             : 
     238           0 : void SectRepr::SetFilter( const OUString& rFilter )
     239             : {
     240           0 :     OUString sNewFile;
     241           0 :     const OUString sOldFileName( m_SectionData.GetLinkFileName() );
     242           0 :     const OUString sFile( sOldFileName.getToken( 0, sfx2::cTokenSeparator ) );
     243           0 :     const OUString sSub( sOldFileName.getToken( 2, sfx2::cTokenSeparator ) );
     244             : 
     245           0 :     if( !sFile.isEmpty() )
     246           0 :         sNewFile = sFile + OUString(sfx2::cTokenSeparator) +
     247           0 :                    rFilter + OUString(sfx2::cTokenSeparator) + sSub;
     248           0 :     else if( !sSub.isEmpty() )
     249           0 :         sNewFile = OUString(sfx2::cTokenSeparator) + OUString(sfx2::cTokenSeparator) + sSub;
     250             : 
     251           0 :     m_SectionData.SetLinkFileName( sNewFile );
     252             : 
     253           0 :     if( !sNewFile.isEmpty() )
     254             :     {
     255           0 :         m_SectionData.SetType( FILE_LINK_SECTION );
     256           0 :     }
     257           0 : }
     258             : 
     259           0 : void SectRepr::SetSubRegion(const OUString& rSubRegion)
     260             : {
     261           0 :     OUString sNewFile;
     262           0 :     sal_Int32 n(0);
     263           0 :     const OUString sLinkFileName(m_SectionData.GetLinkFileName());
     264           0 :     const OUString sOldFileName( sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n ) );
     265           0 :     const OUString sFilter( sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n ) );
     266             : 
     267           0 :     if( !rSubRegion.isEmpty() || !sOldFileName.isEmpty() )
     268           0 :         sNewFile = sOldFileName + OUString(sfx2::cTokenSeparator) +
     269           0 :                    sFilter + OUString(sfx2::cTokenSeparator) + rSubRegion;
     270             : 
     271           0 :     m_SectionData.SetLinkFileName( sNewFile );
     272             : 
     273           0 :     if( !rSubRegion.isEmpty() || !sOldFileName.isEmpty() )
     274             :     {
     275           0 :         m_SectionData.SetType( FILE_LINK_SECTION );
     276             :     }
     277             :     else
     278             :     {
     279           0 :         m_SectionData.SetType( CONTENT_SECTION );
     280           0 :     }
     281           0 : }
     282             : 
     283           0 : OUString SectRepr::GetFile() const
     284             : {
     285           0 :     const OUString sLinkFile( m_SectionData.GetLinkFileName() );
     286             : 
     287           0 :     if( sLinkFile.isEmpty() )
     288             :     {
     289           0 :         return sLinkFile;
     290             :     }
     291           0 :     if (DDE_LINK_SECTION == m_SectionData.GetType())
     292             :     {
     293           0 :         sal_Int32 n = 0;
     294             :         return sLinkFile.replaceFirst( OUString(sfx2::cTokenSeparator), " ", &n )
     295           0 :                         .replaceFirst( OUString(sfx2::cTokenSeparator), " ", &n );
     296             :     }
     297             :     return INetURLObject::decode( sLinkFile.getToken( 0, sfx2::cTokenSeparator ),
     298             :                                   '%',
     299             :                                   INetURLObject::DECODE_UNAMBIGUOUS,
     300           0 :                                   RTL_TEXTENCODING_UTF8 );
     301             : }
     302             : 
     303           0 : OUString SectRepr::GetSubRegion() const
     304             : {
     305           0 :     const OUString sLinkFile( m_SectionData.GetLinkFileName() );
     306           0 :     if( !sLinkFile.isEmpty() )
     307           0 :         return sLinkFile.getToken( 2, sfx2::cTokenSeparator );
     308           0 :     return sLinkFile;
     309             : }
     310             : 
     311             : /*----------------------------------------------------------------------------
     312             :  Description: dialog edit regions
     313             : ----------------------------------------------------------------------------*/
     314           0 : SwEditRegionDlg::SwEditRegionDlg( Window* pParent, SwWrtShell& rWrtSh )
     315             :     : SfxModalDialog(pParent, "EditSectionDialog",
     316             :         "modules/swriter/ui/editsectiondialog.ui")
     317             :     , m_bSubRegionsFilled(false)
     318             :     , aImageIL(SW_RES(IL_SECTION_BITMAPS))
     319             :     , rSh(rWrtSh)
     320             :     , m_pDocInserter(NULL)
     321             :     , m_pOldDefDlgParent(NULL)
     322           0 :     , bDontCheckPasswd(true)
     323             : {
     324           0 :     get(m_pCurName, "curname");
     325           0 :     get(m_pTree, "tree");
     326           0 :     m_pTree->set_height_request(m_pTree->GetTextHeight() * 16);
     327           0 :     get(m_pFileCB, "link");
     328           0 :     m_pFileCB->SetState(TRISTATE_FALSE);
     329           0 :     get(m_pDDECB, "dde");
     330           0 :     get(m_pDDEFrame, "ddedepend");
     331           0 :     get(m_pFileNameFT, "filenameft");
     332           0 :     get(m_pDDECommandFT, "ddeft");
     333           0 :     get(m_pFileNameED, "filename");
     334           0 :     get(m_pFilePB, "file");
     335           0 :     get(m_pSubRegionFT, "sectionft");
     336           0 :     get(m_pSubRegionED, "section");
     337           0 :     m_pSubRegionED->SetStyle(m_pSubRegionED->GetStyle() | WB_SORT);
     338           0 :     get(m_pProtectCB, "protect");
     339           0 :     m_pProtectCB->SetState(TRISTATE_FALSE);
     340           0 :     get(m_pPasswdCB, "withpassword");
     341           0 :     get(m_pPasswdPB, "password");
     342           0 :     get(m_pHideCB, "hide");
     343           0 :     m_pHideCB->SetState(TRISTATE_FALSE);
     344           0 :     get(m_pConditionFT, "conditionft");
     345           0 :     get(m_pConditionED, "condition");
     346             :     // edit in readonly sections
     347           0 :     get(m_pEditInReadonlyCB, "editinro");
     348           0 :     m_pEditInReadonlyCB->SetState(TRISTATE_FALSE);
     349           0 :     get(m_pOptionsPB, "options");
     350           0 :     get(m_pDismiss, "remove");
     351           0 :     get(m_pOK, "ok");
     352             : 
     353           0 :     bWeb = 0 != PTR_CAST( SwWebDocShell, rSh.GetView().GetDocShell() );
     354             : 
     355           0 :     m_pTree->SetSelectHdl(LINK(this, SwEditRegionDlg, GetFirstEntryHdl));
     356           0 :     m_pTree->SetDeselectHdl(LINK(this, SwEditRegionDlg, DeselectHdl));
     357           0 :     m_pCurName->SetModifyHdl(LINK(this, SwEditRegionDlg, NameEditHdl));
     358           0 :     m_pConditionED->SetModifyHdl( LINK( this, SwEditRegionDlg, ConditionEditHdl));
     359           0 :     m_pOK->SetClickHdl         ( LINK( this, SwEditRegionDlg, OkHdl));
     360           0 :     m_pPasswdCB->SetClickHdl(LINK(this, SwEditRegionDlg, ChangePasswdHdl));
     361           0 :     m_pPasswdPB->SetClickHdl(LINK(this, SwEditRegionDlg, ChangePasswdHdl));
     362           0 :     m_pHideCB->SetClickHdl(LINK(this, SwEditRegionDlg, ChangeHideHdl));
     363             :     // edit in readonly sections
     364           0 :     m_pEditInReadonlyCB->SetClickHdl(LINK(this, SwEditRegionDlg, ChangeEditInReadonlyHdl));
     365             : 
     366           0 :     m_pOptionsPB->SetClickHdl(LINK(this, SwEditRegionDlg, OptionsHdl));
     367           0 :     m_pProtectCB->SetClickHdl(LINK(this, SwEditRegionDlg, ChangeProtectHdl));
     368           0 :     m_pDismiss->SetClickHdl    ( LINK( this, SwEditRegionDlg, ChangeDismissHdl));
     369           0 :     m_pFileCB->SetClickHdl(LINK(this, SwEditRegionDlg, UseFileHdl));
     370           0 :     m_pFilePB->SetClickHdl(LINK(this, SwEditRegionDlg, FileSearchHdl));
     371           0 :     m_pFileNameED->SetModifyHdl(LINK(this, SwEditRegionDlg, FileNameHdl));
     372           0 :     m_pSubRegionED->SetModifyHdl(LINK(this, SwEditRegionDlg, FileNameHdl));
     373           0 :     m_pSubRegionED->AddEventListener(LINK(this, SwEditRegionDlg, SubRegionEventHdl));
     374           0 :     m_pSubRegionED->EnableAutocomplete(true, true);
     375             : 
     376           0 :     m_pTree->SetSelectionMode( MULTIPLE_SELECTION );
     377           0 :     m_pTree->SetStyle(m_pTree->GetStyle()|WB_HASBUTTONSATROOT|WB_CLIPCHILDREN|WB_HSCROLL);
     378           0 :     m_pTree->SetSpaceBetweenEntries(0);
     379           0 :     m_pTree->SetAllEntriesAccessibleRoleType(TREEBOX_ALLITEM_ACCROLE_TYPE_TREE);
     380             : 
     381           0 :     if(bWeb)
     382             :     {
     383           0 :         m_pDDECB->Hide();
     384           0 :         get<VclContainer>("hideframe")->Hide();
     385           0 :         m_pPasswdCB->Hide();
     386             :     }
     387             : 
     388           0 :     m_pDDECB->SetClickHdl(LINK(this, SwEditRegionDlg, DDEHdl));
     389             : 
     390           0 :     pCurrSect = rSh.GetCurrSection();
     391           0 :     RecurseList( 0, 0 );
     392             :     // if the cursor is not in a region
     393             :     // the first one will always be selected
     394           0 :     if( !m_pTree->FirstSelected() && m_pTree->First() )
     395           0 :         m_pTree->Select( m_pTree->First() );
     396           0 :     m_pTree->Show();
     397           0 :     bDontCheckPasswd = sal_False;
     398           0 : }
     399             : 
     400           0 : sal_Bool SwEditRegionDlg::CheckPasswd(CheckBox* pBox)
     401             : {
     402           0 :     if(bDontCheckPasswd)
     403           0 :         return sal_True;
     404           0 :     sal_Bool bRet = sal_True;
     405           0 :     SvTreeListEntry* pEntry = m_pTree->FirstSelected();
     406           0 :     while( pEntry )
     407             :     {
     408           0 :         SectReprPtr pRepr = (SectReprPtr)pEntry->GetUserData();
     409           0 :         if (!pRepr->GetTempPasswd().getLength()
     410           0 :             && pRepr->GetSectionData().GetPassword().getLength())
     411             :         {
     412           0 :             SfxPasswordDialog aPasswdDlg(this);
     413           0 :             bRet = sal_False;
     414           0 :             if (aPasswdDlg.Execute())
     415             :             {
     416           0 :                 const OUString sNewPasswd( aPasswdDlg.GetPassword() );
     417           0 :                 ::com::sun::star::uno::Sequence <sal_Int8 > aNewPasswd;
     418           0 :                 SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
     419           0 :                 if (SvPasswordHelper::CompareHashPassword(
     420           0 :                         pRepr->GetSectionData().GetPassword(), sNewPasswd))
     421             :                 {
     422           0 :                     pRepr->SetTempPasswd(aNewPasswd);
     423           0 :                     bRet = sal_True;
     424             :                 }
     425             :                 else
     426             :                 {
     427           0 :                     InfoBox(this, SW_RES(REG_WRONG_PASSWORD)).Execute();
     428           0 :                 }
     429           0 :             }
     430             :         }
     431           0 :         pEntry = m_pTree->NextSelected(pEntry);
     432             :     }
     433           0 :     if(!bRet && pBox)
     434             :     {
     435             :         //reset old button state
     436           0 :         if(pBox->IsTriStateEnabled())
     437           0 :             pBox->SetState(pBox->IsChecked() ? TRISTATE_FALSE : TRISTATE_INDET);
     438             :         else
     439           0 :             pBox->Check(!pBox->IsChecked());
     440             :     }
     441             : 
     442           0 :     return bRet;
     443             : }
     444             : 
     445             : /*---------------------------------------------------------------------
     446             :     Description: recursively look for child-sections
     447             : ---------------------------------------------------------------------*/
     448           0 : void SwEditRegionDlg::RecurseList( const SwSectionFmt* pFmt, SvTreeListEntry* pEntry )
     449             : {
     450           0 :     SwSection* pSect = 0;
     451           0 :     SvTreeListEntry* pSelEntry = 0;
     452             : 
     453           0 :     if (!pFmt)
     454             :     {
     455           0 :         const sal_uInt16 nCount=rSh.GetSectionFmtCount();
     456           0 :         for ( sal_uInt16 n=0; n < nCount; n++ )
     457             :         {
     458             :             SectionType eTmpType;
     459           0 :             if( !( pFmt = &rSh.GetSectionFmt(n))->GetParent() &&
     460           0 :                 pFmt->IsInNodesArr() &&
     461           0 :                 (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
     462           0 :                 && TOX_HEADER_SECTION != eTmpType )
     463             :             {
     464             :                 SectRepr* pSectRepr = new SectRepr( n,
     465           0 :                                             *(pSect=pFmt->GetSection()) );
     466           0 :                 Image aImg = BuildBitmap( pSect->IsProtect(),pSect->IsHidden());
     467           0 :                 pEntry = m_pTree->InsertEntry(pSect->GetSectionName(), aImg, aImg);
     468           0 :                 pEntry->SetUserData(pSectRepr);
     469           0 :                 RecurseList( pFmt, pEntry );
     470           0 :                 if (pEntry->HasChildren())
     471           0 :                     m_pTree->Expand(pEntry);
     472           0 :                 if (pCurrSect==pSect)
     473           0 :                     m_pTree->Select(pEntry);
     474             :             }
     475             :         }
     476             :     }
     477             :     else
     478             :     {
     479           0 :         SwSections aTmpArr;
     480             :         SvTreeListEntry* pNEntry;
     481           0 :         const sal_uInt16 nCnt = pFmt->GetChildSections(aTmpArr,SORTSECT_POS);
     482           0 :         if( nCnt )
     483             :         {
     484           0 :             for( sal_uInt16 n = 0; n < nCnt; ++n )
     485             :             {
     486             :                 SectionType eTmpType;
     487           0 :                 pFmt = aTmpArr[n]->GetFmt();
     488           0 :                 if( pFmt->IsInNodesArr() &&
     489           0 :                     (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
     490           0 :                     && TOX_HEADER_SECTION != eTmpType )
     491             :                 {
     492           0 :                     pSect=aTmpArr[n];
     493             :                     SectRepr* pSectRepr=new SectRepr(
     494           0 :                                     FindArrPos( pSect->GetFmt() ), *pSect );
     495           0 :                     Image aImage = BuildBitmap( pSect->IsProtect(),
     496           0 :                                             pSect->IsHidden());
     497             :                     pNEntry = m_pTree->InsertEntry(
     498           0 :                         pSect->GetSectionName(), aImage, aImage, pEntry);
     499           0 :                     pNEntry->SetUserData(pSectRepr);
     500           0 :                     RecurseList( aTmpArr[n]->GetFmt(), pNEntry );
     501           0 :                     if( pNEntry->HasChildren())
     502           0 :                         m_pTree->Expand(pNEntry);
     503           0 :                     if (pCurrSect==pSect)
     504           0 :                         pSelEntry = pNEntry;
     505             :                 }
     506             :             }
     507           0 :         }
     508             :     }
     509           0 :     if(0 != pSelEntry)
     510             :     {
     511           0 :         m_pTree->MakeVisible(pSelEntry);
     512           0 :         m_pTree->Select(pSelEntry);
     513             :     }
     514           0 : }
     515             : 
     516           0 : sal_uInt16 SwEditRegionDlg::FindArrPos(const SwSectionFmt* pFmt )
     517             : {
     518           0 :     const sal_uInt16 nCount=rSh.GetSectionFmtCount();
     519           0 :     for (sal_uInt16 i=0;i<nCount;i++)
     520           0 :         if (pFmt==&rSh.GetSectionFmt(i))
     521           0 :             return i;
     522             : 
     523             :     OSL_FAIL("SectionFormat not on the list" );
     524           0 :     return USHRT_MAX;
     525             : }
     526             : 
     527           0 : SwEditRegionDlg::~SwEditRegionDlg( )
     528             : {
     529           0 :     SvTreeListEntry* pEntry = m_pTree->First();
     530           0 :     while( pEntry )
     531             :     {
     532           0 :         delete (SectRepr*)pEntry->GetUserData();
     533           0 :         pEntry = m_pTree->Next( pEntry );
     534             :     }
     535             : 
     536           0 :     delete m_pDocInserter;
     537           0 : }
     538             : 
     539           0 : void    SwEditRegionDlg::SelectSection(const OUString& rSectionName)
     540             : {
     541           0 :     SvTreeListEntry* pEntry = m_pTree->First();
     542           0 :     while(pEntry)
     543             :     {
     544           0 :         SectReprPtr pRepr = (SectReprPtr)pEntry->GetUserData();
     545           0 :         if (pRepr->GetSectionData().GetSectionName() == rSectionName)
     546           0 :             break;
     547           0 :         pEntry = m_pTree->Next(pEntry);
     548             :     }
     549           0 :     if(pEntry)
     550             :     {
     551           0 :         m_pTree->SelectAll(false);
     552           0 :         m_pTree->Select(pEntry);
     553           0 :         m_pTree->MakeVisible(pEntry);
     554             :     }
     555           0 : }
     556             : 
     557             : /*---------------------------------------------------------------------
     558             :     Description:    selected entry in TreeListBox is showed in
     559             :                     Edit window
     560             :                     in case of multiselection some controls are disabled
     561             : ---------------------------------------------------------------------*/
     562           0 : IMPL_LINK( SwEditRegionDlg, GetFirstEntryHdl, SvTreeListBox *, pBox )
     563             : {
     564           0 :     bDontCheckPasswd = true;
     565           0 :     SvTreeListEntry* pEntry=pBox->FirstSelected();
     566           0 :     m_pHideCB->Enable(true);
     567             :     // edit in readonly sections
     568           0 :     m_pEditInReadonlyCB->Enable(true);
     569             : 
     570           0 :     m_pProtectCB->Enable(true);
     571           0 :     m_pFileCB->Enable(true);
     572           0 :     ::com::sun::star::uno::Sequence <sal_Int8> aCurPasswd;
     573           0 :     if( 1 < pBox->GetSelectionCount() )
     574             :     {
     575           0 :         m_pHideCB->EnableTriState(true);
     576           0 :         m_pProtectCB->EnableTriState(true);
     577             :         // edit in readonly sections
     578           0 :         m_pEditInReadonlyCB->EnableTriState(true);
     579             : 
     580           0 :         m_pFileCB->EnableTriState(true);
     581             : 
     582           0 :         bool bHiddenValid       = true;
     583           0 :         bool bProtectValid      = true;
     584           0 :         bool bConditionValid    = true;
     585             :         // edit in readonly sections
     586           0 :         bool bEditInReadonlyValid = true;
     587           0 :         bool bEditInReadonly    = true;
     588             : 
     589           0 :         bool bHidden            = true;
     590           0 :         bool bProtect           = true;
     591           0 :         OUString sCondition;
     592           0 :         bool bFirst             = true;
     593           0 :         bool bFileValid         = true;
     594           0 :         bool bFile              = true;
     595           0 :         bool bPasswdValid       = true;
     596             : 
     597           0 :         while( pEntry )
     598             :         {
     599           0 :             SectRepr* pRepr=(SectRepr*) pEntry->GetUserData();
     600           0 :             SwSectionData const& rData( pRepr->GetSectionData() );
     601           0 :             if(bFirst)
     602             :             {
     603           0 :                 sCondition      = rData.GetCondition();
     604           0 :                 bHidden         = rData.IsHidden();
     605           0 :                 bProtect        = rData.IsProtectFlag();
     606             :                 // edit in readonly sections
     607           0 :                 bEditInReadonly = rData.IsEditInReadonlyFlag();
     608             : 
     609           0 :                 bFile           = (rData.GetType() != CONTENT_SECTION);
     610           0 :                 aCurPasswd      = rData.GetPassword();
     611             :             }
     612             :             else
     613             :             {
     614           0 :                 if(sCondition != rData.GetCondition())
     615           0 :                     bConditionValid = false;
     616           0 :                 bHiddenValid      = (bHidden == rData.IsHidden());
     617           0 :                 bProtectValid     = (bProtect == rData.IsProtectFlag());
     618             :                 // edit in readonly sections
     619             :                 bEditInReadonlyValid =
     620           0 :                     (bEditInReadonly == rData.IsEditInReadonlyFlag());
     621             : 
     622           0 :                 bFileValid        = (bFile ==
     623           0 :                     (rData.GetType() != CONTENT_SECTION));
     624           0 :                 bPasswdValid      = (aCurPasswd == rData.GetPassword());
     625             :             }
     626           0 :             pEntry = pBox->NextSelected(pEntry);
     627           0 :             bFirst = false;
     628             :         }
     629             : 
     630             :         m_pHideCB->SetState(!bHiddenValid ? TRISTATE_INDET :
     631           0 :                     bHidden ? TRISTATE_TRUE : TRISTATE_FALSE);
     632             :         m_pProtectCB->SetState(!bProtectValid ? TRISTATE_INDET :
     633           0 :                     bProtect ? TRISTATE_TRUE : TRISTATE_FALSE);
     634             :         // edit in readonly sections
     635             :         m_pEditInReadonlyCB->SetState(!bEditInReadonlyValid ? TRISTATE_INDET :
     636           0 :                     bEditInReadonly ? TRISTATE_TRUE : TRISTATE_FALSE);
     637             : 
     638             :         m_pFileCB->SetState(!bFileValid ? TRISTATE_INDET :
     639           0 :                     bFile ? TRISTATE_TRUE : TRISTATE_FALSE);
     640             : 
     641           0 :         if (bConditionValid)
     642           0 :             m_pConditionED->SetText(sCondition);
     643             :         else
     644             :         {
     645           0 :             m_pConditionFT->Enable(false);
     646           0 :             m_pConditionED->Enable(false);
     647             :         }
     648             : 
     649           0 :         m_pCurName->Enable(false);
     650           0 :         m_pDDECB->Enable(false);
     651           0 :         m_pDDEFrame->Enable(false);
     652           0 :         m_pOptionsPB->Enable(false);
     653           0 :         bool bPasswdEnabled = m_pProtectCB->GetState() == TRISTATE_TRUE;
     654           0 :         m_pPasswdCB->Enable(bPasswdEnabled);
     655           0 :         m_pPasswdPB->Enable(bPasswdEnabled);
     656           0 :         if(!bPasswdValid)
     657             :         {
     658           0 :             pEntry = pBox->FirstSelected();
     659           0 :             pBox->SelectAll( false );
     660           0 :             pBox->Select( pEntry );
     661           0 :             GetFirstEntryHdl(pBox);
     662           0 :             return 0;
     663             :         }
     664             :         else
     665           0 :             m_pPasswdCB->Check(aCurPasswd.getLength() > 0);
     666             :     }
     667           0 :     else if (pEntry )
     668             :     {
     669           0 :         m_pCurName->Enable(true);
     670           0 :         m_pOptionsPB->Enable(true);
     671           0 :         SectRepr* pRepr=(SectRepr*) pEntry->GetUserData();
     672           0 :         SwSectionData const& rData( pRepr->GetSectionData() );
     673           0 :         m_pConditionED->SetText(rData.GetCondition());
     674           0 :         m_pHideCB->Enable();
     675           0 :         m_pHideCB->SetState((rData.IsHidden()) ? TRISTATE_TRUE : TRISTATE_FALSE);
     676           0 :         bool bHide = TRISTATE_TRUE == m_pHideCB->GetState();
     677           0 :         m_pConditionED->Enable(bHide);
     678           0 :         m_pConditionFT->Enable(bHide);
     679           0 :         m_pPasswdCB->Check(rData.GetPassword().getLength() > 0);
     680             : 
     681           0 :         m_pOK->Enable();
     682           0 :         m_pPasswdCB->Enable();
     683           0 :         m_pCurName->SetText(pBox->GetEntryText(pEntry));
     684           0 :         m_pCurName->Enable();
     685           0 :         m_pDismiss->Enable();
     686           0 :         const OUString aFile = pRepr->GetFile();
     687           0 :         const OUString sSub = pRepr->GetSubRegion();
     688           0 :         m_bSubRegionsFilled = false;
     689           0 :         m_pSubRegionED->Clear();
     690           0 :         if( !aFile.isEmpty() || !sSub.isEmpty() )
     691             :         {
     692           0 :             m_pFileCB->Check(true);
     693           0 :             m_pFileNameED->SetText(aFile);
     694           0 :             m_pSubRegionED->SetText(sSub);
     695           0 :             m_pDDECB->Check(rData.GetType() == DDE_LINK_SECTION);
     696             :         }
     697             :         else
     698             :         {
     699           0 :             m_pFileCB->Check(false);
     700           0 :             m_pFileNameED->SetText(aFile);
     701           0 :             m_pDDECB->Enable(false);
     702           0 :             m_pDDECB->Check(false);
     703             :         }
     704           0 :         UseFileHdl(m_pFileCB);
     705           0 :         DDEHdl(m_pDDECB);
     706           0 :         m_pProtectCB->SetState((rData.IsProtectFlag())
     707           0 :                 ? TRISTATE_TRUE : TRISTATE_FALSE);
     708           0 :         m_pProtectCB->Enable();
     709             : 
     710             :         // edit in readonly sections
     711           0 :         m_pEditInReadonlyCB->SetState((rData.IsEditInReadonlyFlag())
     712           0 :                 ? TRISTATE_TRUE : TRISTATE_FALSE);
     713           0 :         m_pEditInReadonlyCB->Enable();
     714             : 
     715           0 :         bool bPasswdEnabled = m_pProtectCB->IsChecked();
     716           0 :         m_pPasswdCB->Enable(bPasswdEnabled);
     717           0 :         m_pPasswdPB->Enable(bPasswdEnabled);
     718             :     }
     719           0 :     bDontCheckPasswd = sal_False;
     720           0 :     return 0;
     721             : }
     722             : 
     723           0 : IMPL_LINK( SwEditRegionDlg, DeselectHdl, SvTreeListBox *, pBox )
     724             : {
     725           0 :     if( !pBox->GetSelectionCount() )
     726             :     {
     727           0 :         m_pHideCB->Enable(false);
     728           0 :         m_pProtectCB->Enable(false);
     729             :         // edit in readonly sections
     730           0 :         m_pEditInReadonlyCB->Enable(false);
     731             : 
     732           0 :         m_pPasswdCB->Enable(false);
     733           0 :         m_pConditionFT->Enable(false);
     734           0 :         m_pConditionED->Enable(false);
     735           0 :         m_pFileCB->Enable(false);
     736           0 :         m_pDDEFrame->Enable(false);
     737           0 :         m_pDDECB->Enable(false);
     738           0 :         m_pCurName->Enable(false);
     739             : 
     740           0 :         UseFileHdl(m_pFileCB);
     741           0 :         DDEHdl(m_pDDECB);
     742             :     }
     743           0 :     return 0;
     744             : }
     745             : 
     746             : /*---------------------------------------------------------------------
     747             :     Description:    in OkHdl the modified settings are being applied
     748             :                     and reversed regions are deleted
     749             : ---------------------------------------------------------------------*/
     750           0 : IMPL_LINK_NOARG(SwEditRegionDlg, OkHdl)
     751             : {
     752             :     // temp. Array because during changing of a region the position
     753             :     // inside of the "Core-Arrays" can be shifted:
     754             :     //  - at linked regions, when they have more SubRegions or get
     755             :     //    new ones.
     756             :     // StartUndo must certainly also happen not before the formats
     757             :     // are copied (ClearRedo!)
     758             : 
     759           0 :     const SwSectionFmts& rDocFmts = rSh.GetDoc()->GetSections();
     760           0 :     SwSectionFmts aOrigArray(rDocFmts);
     761             : 
     762           0 :     rSh.StartAllAction();
     763           0 :     rSh.StartUndo();
     764           0 :     rSh.ResetSelect( 0,sal_False );
     765           0 :     SvTreeListEntry* pEntry = m_pTree->First();
     766             : 
     767           0 :     while( pEntry )
     768             :     {
     769           0 :         SectReprPtr pRepr = (SectReprPtr) pEntry->GetUserData();
     770           0 :         SwSectionFmt* pFmt = aOrigArray[ pRepr->GetArrPos() ];
     771           0 :         if (!pRepr->GetSectionData().IsProtectFlag())
     772             :         {
     773           0 :             pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >());
     774             :         }
     775           0 :         sal_uInt16 nNewPos = rDocFmts.GetPos( pFmt );
     776           0 :         if( USHRT_MAX != nNewPos )
     777             :         {
     778           0 :             SfxItemSet* pSet = pFmt->GetAttrSet().Clone( false );
     779           0 :             if( pFmt->GetCol() != pRepr->GetCol() )
     780           0 :                 pSet->Put( pRepr->GetCol() );
     781             : 
     782           0 :             if( pFmt->GetBackground(sal_False) != pRepr->GetBackground() )
     783           0 :                 pSet->Put( pRepr->GetBackground() );
     784             : 
     785           0 :             if( pFmt->GetFtnAtTxtEnd(sal_False) != pRepr->GetFtnNtAtEnd() )
     786           0 :                 pSet->Put( pRepr->GetFtnNtAtEnd() );
     787             : 
     788           0 :             if( pFmt->GetEndAtTxtEnd(sal_False) != pRepr->GetEndNtAtEnd() )
     789           0 :                 pSet->Put( pRepr->GetEndNtAtEnd() );
     790             : 
     791           0 :             if( pFmt->GetBalancedColumns() != pRepr->GetBalance() )
     792           0 :                 pSet->Put( pRepr->GetBalance() );
     793             : 
     794           0 :             if( pFmt->GetFrmDir() != pRepr->GetFrmDir() )
     795           0 :                 pSet->Put( pRepr->GetFrmDir() );
     796             : 
     797           0 :             if( pFmt->GetLRSpace() != pRepr->GetLRSpace())
     798           0 :                 pSet->Put( pRepr->GetLRSpace());
     799             : 
     800           0 :             rSh.UpdateSection( nNewPos, pRepr->GetSectionData(),
     801           0 :                             pSet->Count() ? pSet : 0 );
     802           0 :             delete pSet;
     803             :         }
     804           0 :         pEntry = m_pTree->Next( pEntry );
     805             :     }
     806             : 
     807           0 :     for (SectReprArr::reverse_iterator aI = aSectReprArr.rbegin(), aEnd = aSectReprArr.rend(); aI != aEnd; ++aI)
     808             :     {
     809           0 :         SwSectionFmt* pFmt = aOrigArray[ aI->GetArrPos() ];
     810           0 :         const sal_uInt16 nNewPos = rDocFmts.GetPos( pFmt );
     811           0 :         if( USHRT_MAX != nNewPos )
     812           0 :             rSh.DelSectionFmt( nNewPos );
     813             :     }
     814             : 
     815           0 :     aOrigArray.clear();
     816             : 
     817             :     // EndDialog must be called ahead of EndAction's end,
     818             :     // otherwise ScrollError can occur.
     819           0 :     EndDialog(RET_OK);
     820             : 
     821           0 :     rSh.EndUndo();
     822           0 :     rSh.EndAllAction();
     823             : 
     824           0 :     return 0;
     825             : }
     826             : 
     827             : /*---------------------------------------------------------------------
     828             :  Description: Toggle protect
     829             : ---------------------------------------------------------------------*/
     830           0 : IMPL_LINK( SwEditRegionDlg, ChangeProtectHdl, TriStateBox *, pBox )
     831             : {
     832           0 :     if(!CheckPasswd(pBox))
     833           0 :         return 0;
     834           0 :     pBox->EnableTriState(false);
     835           0 :     SvTreeListEntry* pEntry = m_pTree->FirstSelected();
     836             :     OSL_ENSURE(pEntry,"no entry found");
     837           0 :     sal_Bool bCheck = TRISTATE_TRUE == pBox->GetState();
     838           0 :     while( pEntry )
     839             :     {
     840           0 :         SectReprPtr pRepr = (SectReprPtr) pEntry->GetUserData();
     841           0 :         pRepr->GetSectionData().SetProtectFlag(bCheck);
     842             :         Image aImage = BuildBitmap(bCheck,
     843           0 :                                    TRISTATE_TRUE == m_pHideCB->GetState());
     844           0 :         m_pTree->SetExpandedEntryBmp(  pEntry, aImage );
     845           0 :         m_pTree->SetCollapsedEntryBmp( pEntry, aImage );
     846           0 :         pEntry = m_pTree->NextSelected(pEntry);
     847           0 :     }
     848           0 :     m_pPasswdCB->Enable(bCheck);
     849           0 :     m_pPasswdPB->Enable(bCheck);
     850           0 :     return 0;
     851             : }
     852             : 
     853             : /*---------------------------------------------------------------------
     854             :  Description: Toggle hide
     855             : ---------------------------------------------------------------------*/
     856           0 : IMPL_LINK( SwEditRegionDlg, ChangeHideHdl, TriStateBox *, pBox )
     857             : {
     858           0 :     if(!CheckPasswd(pBox))
     859           0 :         return 0;
     860           0 :     pBox->EnableTriState(false);
     861           0 :     SvTreeListEntry* pEntry = m_pTree->FirstSelected();
     862             :     OSL_ENSURE(pEntry,"no entry found");
     863           0 :     while( pEntry )
     864             :     {
     865           0 :         SectReprPtr pRepr = (SectReprPtr) pEntry->GetUserData();
     866           0 :         pRepr->GetSectionData().SetHidden(TRISTATE_TRUE == pBox->GetState());
     867             : 
     868           0 :         Image aImage = BuildBitmap(TRISTATE_TRUE == m_pProtectCB->GetState(),
     869           0 :                                     TRISTATE_TRUE == pBox->GetState());
     870           0 :         m_pTree->SetExpandedEntryBmp(  pEntry, aImage );
     871           0 :         m_pTree->SetCollapsedEntryBmp( pEntry, aImage );
     872             : 
     873           0 :         pEntry = m_pTree->NextSelected(pEntry);
     874           0 :     }
     875             : 
     876           0 :     bool bHide = TRISTATE_TRUE == pBox->GetState();
     877           0 :     m_pConditionED->Enable(bHide);
     878           0 :     m_pConditionFT->Enable(bHide);
     879           0 :     return 0;
     880             : }
     881             : 
     882             : /*---------------------------------------------------------------------
     883             :  Description: Toggle edit in readonly
     884             : ---------------------------------------------------------------------*/
     885           0 : IMPL_LINK( SwEditRegionDlg, ChangeEditInReadonlyHdl, TriStateBox *, pBox )
     886             : {
     887           0 :     if(!CheckPasswd(pBox))
     888           0 :         return 0;
     889           0 :     pBox->EnableTriState(false);
     890           0 :     SvTreeListEntry* pEntry = m_pTree->FirstSelected();
     891             :     OSL_ENSURE(pEntry,"no entry found");
     892           0 :     while( pEntry )
     893             :     {
     894           0 :         SectReprPtr pRepr = (SectReprPtr) pEntry->GetUserData();
     895           0 :         pRepr->GetSectionData().SetEditInReadonlyFlag(
     896           0 :                 TRISTATE_TRUE == pBox->GetState());
     897           0 :         pEntry = m_pTree->NextSelected(pEntry);
     898             :     }
     899             : 
     900           0 :     return 0;
     901             : }
     902             : 
     903             : /*---------------------------------------------------------------------
     904             :  Description: clear selected region
     905             : ---------------------------------------------------------------------*/
     906           0 : IMPL_LINK_NOARG(SwEditRegionDlg, ChangeDismissHdl)
     907             : {
     908           0 :     if(!CheckPasswd())
     909           0 :         return 0;
     910           0 :     SvTreeListEntry* pEntry = m_pTree->FirstSelected();
     911             :     SvTreeListEntry* pChild;
     912             :     SvTreeListEntry* pParent;
     913             :     // at first mark all selected
     914           0 :     while(pEntry)
     915             :     {
     916           0 :         const SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
     917           0 :         pSectRepr->SetSelected();
     918           0 :         pEntry = m_pTree->NextSelected(pEntry);
     919             :     }
     920           0 :     pEntry = m_pTree->FirstSelected();
     921             :     // then delete
     922           0 :     while(pEntry)
     923             :     {
     924           0 :         const SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
     925           0 :         SvTreeListEntry* pRemove = 0;
     926           0 :         bool bRestart = false;
     927           0 :         if(pSectRepr->IsSelected())
     928             :         {
     929           0 :             aSectReprArr.insert( pSectRepr );
     930           0 :             while( (pChild = m_pTree->FirstChild(pEntry) )!= 0 )
     931             :             {
     932             :                 // because of the repositioning we have to start at the beginning again
     933           0 :                 bRestart = true;
     934           0 :                 pParent = m_pTree->GetParent(pEntry);
     935           0 :                 m_pTree->GetModel()->Move(pChild, pParent, m_pTree->GetModel()->GetRelPos(pEntry));
     936             :             }
     937           0 :             pRemove = pEntry;
     938             :         }
     939           0 :         if(bRestart)
     940           0 :             pEntry = m_pTree->First();
     941             :         else
     942           0 :             pEntry = m_pTree->Next(pEntry);
     943           0 :         if(pRemove)
     944           0 :             m_pTree->GetModel()->Remove( pRemove );
     945             :     }
     946             : 
     947           0 :     if ( m_pTree->FirstSelected() == 0 )
     948             :     {
     949           0 :         m_pConditionFT->Enable(false);
     950           0 :         m_pConditionED->Enable(false);
     951           0 :         m_pDismiss->       Enable(false);
     952           0 :         m_pCurName->Enable(false);
     953           0 :         m_pProtectCB->Enable(false);
     954           0 :         m_pPasswdCB->Enable(false);
     955           0 :         m_pHideCB->Enable(false);
     956             :         // edit in readonly sections
     957           0 :         m_pEditInReadonlyCB->Enable(false);
     958           0 :         m_pEditInReadonlyCB->SetState(TRISTATE_FALSE);
     959           0 :         m_pProtectCB->SetState(TRISTATE_FALSE);
     960           0 :         m_pPasswdCB->Check(false);
     961           0 :         m_pHideCB->SetState(TRISTATE_FALSE);
     962           0 :         m_pFileCB->Check(false);
     963             :         // otherwise the focus would be on HelpButton
     964           0 :         m_pOK->GrabFocus();
     965           0 :         UseFileHdl(m_pFileCB);
     966             :     }
     967           0 :     return 0;
     968             : }
     969             : 
     970             : /*---------------------------------------------------------------------
     971             :  Description: link CheckBox to file?
     972             : ---------------------------------------------------------------------*/
     973           0 : IMPL_LINK( SwEditRegionDlg, UseFileHdl, CheckBox *, pBox )
     974             : {
     975           0 :     if(!CheckPasswd(pBox))
     976           0 :         return 0;
     977           0 :     SvTreeListEntry* pEntry = m_pTree->FirstSelected();
     978           0 :     pBox->EnableTriState(false);
     979           0 :     sal_Bool bMulti = 1 < m_pTree->GetSelectionCount();
     980           0 :     sal_Bool bFile = pBox->IsChecked();
     981           0 :     if(pEntry)
     982             :     {
     983           0 :         while(pEntry)
     984             :         {
     985           0 :             const SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
     986           0 :             sal_Bool bContent = pSectRepr->IsContent();
     987           0 :             if( pBox->IsChecked() && bContent && rSh.HasSelection() )
     988             :             {
     989           0 :                 if( RET_NO == QueryBox( this, SW_RES(QB_CONNECT) ).Execute() )
     990           0 :                     pBox->Check( false );
     991             :             }
     992           0 :             if( bFile )
     993           0 :                 pSectRepr->SetContent(false);
     994             :             else
     995             :             {
     996           0 :                 pSectRepr->SetFile(aEmptyOUStr);
     997           0 :                 pSectRepr->SetSubRegion(aEmptyOUStr);
     998           0 :                 pSectRepr->GetSectionData().SetLinkFilePassword(aEmptyOUStr);
     999             :             }
    1000             : 
    1001           0 :             pEntry = m_pTree->NextSelected(pEntry);
    1002             :         }
    1003           0 :         m_pDDECB->Enable(bFile && ! bMulti);
    1004           0 :         m_pDDEFrame->Enable(bFile && ! bMulti);
    1005           0 :         if( bFile )
    1006             :         {
    1007           0 :             m_pProtectCB->SetState(TRISTATE_TRUE);
    1008           0 :             m_pFileNameED->GrabFocus();
    1009             : 
    1010             :         }
    1011             :         else
    1012             :         {
    1013           0 :             m_pDDECB->Check(false);
    1014           0 :             DDEHdl(m_pDDECB);
    1015           0 :             m_pSubRegionED->SetText(OUString());
    1016             :         }
    1017             :     }
    1018             :     else
    1019             :     {
    1020           0 :         pBox->Check(false);
    1021           0 :         pBox->Enable(false);
    1022           0 :         m_pDDECB->Check(false);
    1023           0 :         m_pDDECB->Enable(false);
    1024           0 :         m_pDDEFrame->Enable(false);
    1025             :     }
    1026           0 :     return 0;
    1027             : }
    1028             : 
    1029             : /*---------------------------------------------------------------------
    1030             :     Description: call dialog paste file
    1031             : ---------------------------------------------------------------------*/
    1032           0 : IMPL_LINK_NOARG(SwEditRegionDlg, FileSearchHdl)
    1033             : {
    1034           0 :     if(!CheckPasswd(0))
    1035           0 :         return 0;
    1036             : 
    1037           0 :     m_pOldDefDlgParent = Application::GetDefDialogParent();
    1038           0 :     Application::SetDefDialogParent( this );
    1039           0 :     delete m_pDocInserter;
    1040             :     m_pDocInserter =
    1041           0 :         new ::sfx2::DocumentInserter( "swriter" );
    1042           0 :     m_pDocInserter->StartExecuteModal( LINK( this, SwEditRegionDlg, DlgClosedHdl ) );
    1043           0 :     return 0;
    1044             : }
    1045             : 
    1046           0 : IMPL_LINK_NOARG(SwEditRegionDlg, OptionsHdl)
    1047             : {
    1048           0 :     if(!CheckPasswd())
    1049           0 :         return 0;
    1050           0 :     SvTreeListEntry* pEntry = m_pTree->FirstSelected();
    1051             : 
    1052           0 :     if(pEntry)
    1053             :     {
    1054           0 :         SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
    1055           0 :         SfxItemSet aSet(rSh.GetView().GetPool(),
    1056             :                             RES_COL, RES_COL,
    1057             :                             RES_COLUMNBALANCE, RES_FRAMEDIR,
    1058             :                             RES_BACKGROUND, RES_BACKGROUND,
    1059             :                             RES_FRM_SIZE, RES_FRM_SIZE,
    1060             :                             SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
    1061             :                             RES_LR_SPACE, RES_LR_SPACE,
    1062             :                             RES_FTN_AT_TXTEND, RES_END_AT_TXTEND,
    1063           0 :                             0);
    1064             : 
    1065           0 :         aSet.Put( pSectRepr->GetCol() );
    1066           0 :         aSet.Put( pSectRepr->GetBackground() );
    1067           0 :         aSet.Put( pSectRepr->GetFtnNtAtEnd() );
    1068           0 :         aSet.Put( pSectRepr->GetEndNtAtEnd() );
    1069           0 :         aSet.Put( pSectRepr->GetBalance() );
    1070           0 :         aSet.Put( pSectRepr->GetFrmDir() );
    1071           0 :         aSet.Put( pSectRepr->GetLRSpace() );
    1072             : 
    1073           0 :         const SwSectionFmts& rDocFmts = rSh.GetDoc()->GetSections();
    1074           0 :         SwSectionFmts aOrigArray(rDocFmts);
    1075             : 
    1076           0 :         SwSectionFmt* pFmt = aOrigArray[pSectRepr->GetArrPos()];
    1077           0 :         long nWidth = rSh.GetSectionWidth(*pFmt);
    1078           0 :         aOrigArray.clear();
    1079           0 :         if (!nWidth)
    1080           0 :             nWidth = USHRT_MAX;
    1081             : 
    1082           0 :         aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth));
    1083           0 :         aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth)));
    1084             : 
    1085           0 :         SwSectionPropertyTabDialog aTabDlg(this, aSet, rSh);
    1086           0 :         if(RET_OK == aTabDlg.Execute())
    1087             :         {
    1088           0 :             const SfxItemSet* pOutSet = aTabDlg.GetOutputItemSet();
    1089           0 :             if( pOutSet && pOutSet->Count() )
    1090             :             {
    1091             :                 const SfxPoolItem *pColItem, *pBrushItem,
    1092             :                                   *pFtnItem, *pEndItem, *pBalanceItem,
    1093             :                                   *pFrmDirItem, *pLRSpaceItem;
    1094             :                 SfxItemState eColState = pOutSet->GetItemState(
    1095           0 :                                         RES_COL, false, &pColItem );
    1096             :                 SfxItemState eBrushState = pOutSet->GetItemState(
    1097           0 :                                         RES_BACKGROUND, false, &pBrushItem );
    1098             :                 SfxItemState eFtnState = pOutSet->GetItemState(
    1099           0 :                                         RES_FTN_AT_TXTEND, false, &pFtnItem );
    1100             :                 SfxItemState eEndState = pOutSet->GetItemState(
    1101           0 :                                         RES_END_AT_TXTEND, false, &pEndItem );
    1102             :                 SfxItemState eBalanceState = pOutSet->GetItemState(
    1103           0 :                                         RES_COLUMNBALANCE, false, &pBalanceItem );
    1104             :                 SfxItemState eFrmDirState = pOutSet->GetItemState(
    1105           0 :                                         RES_FRAMEDIR, false, &pFrmDirItem );
    1106             :                 SfxItemState eLRState = pOutSet->GetItemState(
    1107           0 :                                         RES_LR_SPACE, false, &pLRSpaceItem);
    1108             : 
    1109           0 :                 if( SFX_ITEM_SET == eColState ||
    1110           0 :                     SFX_ITEM_SET == eBrushState ||
    1111           0 :                     SFX_ITEM_SET == eFtnState ||
    1112           0 :                     SFX_ITEM_SET == eEndState ||
    1113           0 :                     SFX_ITEM_SET == eBalanceState||
    1114           0 :                     SFX_ITEM_SET == eFrmDirState||
    1115             :                     SFX_ITEM_SET == eLRState)
    1116             :                 {
    1117           0 :                     SvTreeListEntry* pSelEntry = m_pTree->FirstSelected();
    1118           0 :                     while( pSelEntry )
    1119             :                     {
    1120           0 :                         SectReprPtr pRepr = (SectReprPtr)pSelEntry->GetUserData();
    1121           0 :                         if( SFX_ITEM_SET == eColState )
    1122           0 :                             pRepr->GetCol() = *(SwFmtCol*)pColItem;
    1123           0 :                         if( SFX_ITEM_SET == eBrushState )
    1124           0 :                             pRepr->GetBackground() = *(SvxBrushItem*)pBrushItem;
    1125           0 :                         if( SFX_ITEM_SET == eFtnState )
    1126           0 :                             pRepr->GetFtnNtAtEnd() = *(SwFmtFtnAtTxtEnd*)pFtnItem;
    1127           0 :                         if( SFX_ITEM_SET == eEndState )
    1128           0 :                             pRepr->GetEndNtAtEnd() = *(SwFmtEndAtTxtEnd*)pEndItem;
    1129           0 :                         if( SFX_ITEM_SET == eBalanceState )
    1130           0 :                             pRepr->GetBalance().SetValue(((SwFmtNoBalancedColumns*)pBalanceItem)->GetValue());
    1131           0 :                         if( SFX_ITEM_SET == eFrmDirState )
    1132           0 :                             pRepr->GetFrmDir().SetValue(((SvxFrameDirectionItem*)pFrmDirItem)->GetValue());
    1133           0 :                         if( SFX_ITEM_SET == eLRState )
    1134           0 :                             pRepr->GetLRSpace() = *(SvxLRSpaceItem*)pLRSpaceItem;
    1135             : 
    1136           0 :                         pSelEntry = m_pTree->NextSelected(pSelEntry);
    1137             :                     }
    1138             :                 }
    1139             :             }
    1140           0 :         }
    1141             :     }
    1142             : 
    1143           0 :     return 0;
    1144             : }
    1145             : 
    1146             : /*---------------------------------------------------------------------
    1147             :     Description:    Applying of the filename or the
    1148             :                     linked region
    1149             : ---------------------------------------------------------------------*/
    1150           0 : IMPL_LINK( SwEditRegionDlg, FileNameHdl, Edit *, pEdit )
    1151             : {
    1152           0 :     Selection aSelect = pEdit->GetSelection();
    1153           0 :     if(!CheckPasswd())
    1154           0 :         return 0;
    1155           0 :     pEdit->SetSelection(aSelect);
    1156           0 :     SvTreeListEntry* pEntry = m_pTree->FirstSelected();
    1157             :     OSL_ENSURE(pEntry,"no entry found");
    1158           0 :     SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
    1159           0 :     if (pEdit == m_pFileNameED)
    1160             :     {
    1161           0 :         m_bSubRegionsFilled = false;
    1162           0 :         m_pSubRegionED->Clear();
    1163           0 :         if (m_pDDECB->IsChecked())
    1164             :         {
    1165           0 :             OUString sLink( SwSectionData::CollapseWhiteSpaces(pEdit->GetText()) );
    1166           0 :             sal_Int32 nPos = 0;
    1167           0 :             sLink = sLink.replaceFirst( " ", OUString(sfx2::cTokenSeparator), &nPos );
    1168           0 :             if (nPos>=0)
    1169             :             {
    1170           0 :                 sLink = sLink.replaceFirst( " ", OUString(sfx2::cTokenSeparator), &nPos );
    1171             :             }
    1172             : 
    1173           0 :             pSectRepr->GetSectionData().SetLinkFileName( sLink );
    1174           0 :             pSectRepr->GetSectionData().SetType( DDE_LINK_SECTION );
    1175             :         }
    1176             :         else
    1177             :         {
    1178           0 :             OUString sTmp(pEdit->GetText());
    1179           0 :             if(!sTmp.isEmpty())
    1180             :             {
    1181           0 :                 SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
    1182           0 :                 INetURLObject aAbs;
    1183           0 :                 if( pMedium )
    1184           0 :                     aAbs = pMedium->GetURLObject();
    1185           0 :                 sTmp = URIHelper::SmartRel2Abs(
    1186           0 :                     aAbs, sTmp, URIHelper::GetMaybeFileHdl() );
    1187             :             }
    1188           0 :             pSectRepr->SetFile( sTmp );
    1189           0 :             pSectRepr->GetSectionData().SetLinkFilePassword( aEmptyOUStr );
    1190             :         }
    1191             :     }
    1192             :     else
    1193             :     {
    1194           0 :         pSectRepr->SetSubRegion( pEdit->GetText() );
    1195             :     }
    1196           0 :     return 0;
    1197             : }
    1198             : 
    1199           0 : IMPL_LINK( SwEditRegionDlg, DDEHdl, CheckBox*, pBox )
    1200             : {
    1201           0 :     if(!CheckPasswd(pBox))
    1202           0 :         return 0;
    1203           0 :     SvTreeListEntry* pEntry = m_pTree->FirstSelected();
    1204           0 :     if(pEntry)
    1205             :     {
    1206           0 :         bool bFile = m_pFileCB->IsChecked();
    1207           0 :         SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
    1208           0 :         SwSectionData & rData( pSectRepr->GetSectionData() );
    1209           0 :         sal_Bool bDDE = pBox->IsChecked();
    1210           0 :         if(bDDE)
    1211             :         {
    1212           0 :             m_pFileNameFT->Hide();
    1213           0 :             m_pDDECommandFT->Enable();
    1214           0 :             m_pDDECommandFT->Show();
    1215           0 :             m_pSubRegionFT->Hide();
    1216           0 :             m_pSubRegionED->Hide();
    1217           0 :             if (FILE_LINK_SECTION == rData.GetType())
    1218             :             {
    1219           0 :                 pSectRepr->SetFile(OUString());
    1220           0 :                 m_pFileNameED->SetText(OUString());
    1221           0 :                 rData.SetLinkFilePassword(OUString());
    1222             :             }
    1223           0 :             rData.SetType(DDE_LINK_SECTION);
    1224             :         }
    1225             :         else
    1226             :         {
    1227           0 :             m_pDDECommandFT->Hide();
    1228           0 :             m_pFileNameFT->Enable(bFile);
    1229           0 :             m_pFileNameFT->Show();
    1230           0 :             m_pSubRegionED->Show();
    1231           0 :             m_pSubRegionFT->Show();
    1232           0 :             m_pSubRegionED->Enable(bFile);
    1233           0 :             m_pSubRegionFT->Enable(bFile);
    1234           0 :             m_pSubRegionED->Enable(bFile);
    1235           0 :             if (DDE_LINK_SECTION == rData.GetType())
    1236             :             {
    1237           0 :                 rData.SetType(FILE_LINK_SECTION);
    1238           0 :                 pSectRepr->SetFile(OUString());
    1239           0 :                 rData.SetLinkFilePassword(OUString());
    1240           0 :                 m_pFileNameED->SetText(OUString());
    1241             :             }
    1242             :         }
    1243           0 :         m_pFilePB->Enable(bFile && !bDDE);
    1244             :     }
    1245           0 :     return 0;
    1246             : }
    1247             : 
    1248           0 : IMPL_LINK( SwEditRegionDlg, ChangePasswdHdl, Button *, pBox )
    1249             : {
    1250           0 :     bool bChange = pBox == m_pPasswdPB;
    1251           0 :     if(!CheckPasswd(0))
    1252             :     {
    1253           0 :         if(!bChange)
    1254           0 :             m_pPasswdCB->Check(!m_pPasswdCB->IsChecked());
    1255           0 :         return 0;
    1256             :     }
    1257           0 :     SvTreeListEntry* pEntry = m_pTree->FirstSelected();
    1258           0 :     bool bSet = bChange ? bChange : m_pPasswdCB->IsChecked();
    1259             :     OSL_ENSURE(pEntry,"no entry found");
    1260           0 :     while( pEntry )
    1261             :     {
    1262           0 :         SectReprPtr pRepr = (SectReprPtr)pEntry->GetUserData();
    1263           0 :         if(bSet)
    1264             :         {
    1265           0 :             if(!pRepr->GetTempPasswd().getLength() || bChange)
    1266             :             {
    1267           0 :                 SfxPasswordDialog aPasswdDlg(this);
    1268           0 :                 aPasswdDlg.ShowExtras(SHOWEXTRAS_CONFIRM);
    1269           0 :                 if(RET_OK == aPasswdDlg.Execute())
    1270             :                 {
    1271           0 :                     const OUString sNewPasswd( aPasswdDlg.GetPassword() );
    1272           0 :                     if( aPasswdDlg.GetConfirm() == sNewPasswd )
    1273             :                     {
    1274           0 :                         SvPasswordHelper::GetHashPassword( pRepr->GetTempPasswd(), sNewPasswd );
    1275             :                     }
    1276             :                     else
    1277             :                     {
    1278           0 :                         InfoBox(pBox, SW_RES(REG_WRONG_PASSWD_REPEAT)).Execute();
    1279           0 :                         ChangePasswdHdl(pBox);
    1280           0 :                         break;
    1281           0 :                     }
    1282             :                 }
    1283             :                 else
    1284             :                 {
    1285           0 :                     if(!bChange)
    1286           0 :                         m_pPasswdCB->Check(false);
    1287           0 :                     break;
    1288           0 :                 }
    1289             :             }
    1290           0 :             pRepr->GetSectionData().SetPassword(pRepr->GetTempPasswd());
    1291             :         }
    1292             :         else
    1293             :         {
    1294           0 :             pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >());
    1295             :         }
    1296           0 :         pEntry = m_pTree->NextSelected(pEntry);
    1297             :     }
    1298           0 :     return 0;
    1299             : }
    1300             : 
    1301             : /*---------------------------------------------------------------------
    1302             :     Description:    the current region name is being added to the
    1303             :                     TreeListBox immediately during editing, with empty
    1304             :                     string no Ok()
    1305             : ---------------------------------------------------------------------*/
    1306           0 : IMPL_LINK_NOARG(SwEditRegionDlg, NameEditHdl)
    1307             : {
    1308           0 :     if(!CheckPasswd(0))
    1309           0 :         return 0;
    1310           0 :     SvTreeListEntry* pEntry = m_pTree->FirstSelected();
    1311             :     OSL_ENSURE(pEntry,"no entry found");
    1312           0 :     if (pEntry)
    1313             :     {
    1314           0 :         const OUString aName = m_pCurName->GetText();
    1315           0 :         m_pTree->SetEntryText(pEntry,aName);
    1316           0 :         SectReprPtr pRepr = (SectReprPtr) pEntry->GetUserData();
    1317           0 :         pRepr->GetSectionData().SetSectionName(aName);
    1318             : 
    1319           0 :         m_pOK->Enable(!aName.isEmpty());
    1320             :     }
    1321           0 :     return 0;
    1322             : }
    1323             : 
    1324           0 : IMPL_LINK( SwEditRegionDlg, ConditionEditHdl, Edit *, pEdit )
    1325             : {
    1326           0 :     Selection aSelect = pEdit->GetSelection();
    1327           0 :     if(!CheckPasswd(0))
    1328           0 :         return 0;
    1329           0 :     pEdit->SetSelection(aSelect);
    1330           0 :     SvTreeListEntry* pEntry = m_pTree->FirstSelected();
    1331             :     OSL_ENSURE(pEntry,"no entry found");
    1332           0 :     while( pEntry )
    1333             :     {
    1334           0 :         SectReprPtr pRepr = (SectReprPtr)pEntry->GetUserData();
    1335           0 :         pRepr->GetSectionData().SetCondition(pEdit->GetText());
    1336           0 :         pEntry = m_pTree->NextSelected(pEntry);
    1337             :     }
    1338           0 :     return 0;
    1339             : }
    1340             : 
    1341           0 : IMPL_LINK( SwEditRegionDlg, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg )
    1342             : {
    1343           0 :     OUString sFileName, sFilterName, sPassword;
    1344           0 :     if ( _pFileDlg->GetError() == ERRCODE_NONE )
    1345             :     {
    1346           0 :         SfxMedium* pMedium = m_pDocInserter->CreateMedium();
    1347           0 :         if ( pMedium )
    1348             :         {
    1349           0 :             sFileName = pMedium->GetURLObject().GetMainURL( INetURLObject::NO_DECODE );
    1350           0 :             sFilterName = pMedium->GetFilter()->GetFilterName();
    1351             :             const SfxPoolItem* pItem;
    1352           0 :             if ( SFX_ITEM_SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, false, &pItem ) )
    1353           0 :                 sPassword = ( (SfxStringItem*)pItem )->GetValue();
    1354           0 :             ::lcl_ReadSections(*pMedium, *m_pSubRegionED);
    1355           0 :             delete pMedium;
    1356             :         }
    1357             :     }
    1358             : 
    1359           0 :     SvTreeListEntry* pEntry = m_pTree->FirstSelected();
    1360             :     OSL_ENSURE( pEntry, "no entry found" );
    1361           0 :     if ( pEntry )
    1362             :     {
    1363           0 :         SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData();
    1364           0 :         pSectRepr->SetFile( sFileName );
    1365           0 :         pSectRepr->SetFilter( sFilterName );
    1366           0 :         pSectRepr->GetSectionData().SetLinkFilePassword(sPassword);
    1367           0 :         m_pFileNameED->SetText(pSectRepr->GetFile());
    1368             :     }
    1369             : 
    1370           0 :     Application::SetDefDialogParent( m_pOldDefDlgParent );
    1371           0 :     return 0;
    1372             : }
    1373             : 
    1374           0 : IMPL_LINK( SwEditRegionDlg, SubRegionEventHdl, VclWindowEvent *, pEvent )
    1375             : {
    1376           0 :     if( !m_bSubRegionsFilled && pEvent && pEvent->GetId() == VCLEVENT_DROPDOWN_PRE_OPEN )
    1377             :     {
    1378             :         //if necessary fill the names bookmarks/sections/tables now
    1379             : 
    1380           0 :         OUString sFileName = m_pFileNameED->GetText();
    1381           0 :         if(!sFileName.isEmpty())
    1382             :         {
    1383           0 :             SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
    1384           0 :             INetURLObject aAbs;
    1385           0 :             if( pMedium )
    1386           0 :                 aAbs = pMedium->GetURLObject();
    1387           0 :             sFileName = URIHelper::SmartRel2Abs(
    1388           0 :                     aAbs, sFileName, URIHelper::GetMaybeFileHdl() );
    1389             : 
    1390             :             //load file and set the shell
    1391           0 :             SfxMedium aMedium( sFileName, STREAM_STD_READ );
    1392           0 :             sFileName = aMedium.GetURLObject().GetMainURL( INetURLObject::NO_DECODE );
    1393           0 :             ::lcl_ReadSections(aMedium, *m_pSubRegionED);
    1394             :         }
    1395             :         else
    1396           0 :             lcl_FillSubRegionList(rSh, *m_pSubRegionED, 0);
    1397           0 :         m_bSubRegionsFilled = true;
    1398             :     }
    1399           0 :     return 0;
    1400             : }
    1401             : 
    1402           0 : Image SwEditRegionDlg::BuildBitmap( sal_Bool bProtect, sal_Bool bHidden )
    1403             : {
    1404           0 :     ImageList& rImgLst = aImageIL;
    1405           0 :     return rImgLst.GetImage((int(!bHidden)+(bProtect<<1)) + 1);
    1406             : }
    1407             : 
    1408             : /*--------------------------------------------------------------------
    1409             :     Description:    helper function - read region names from medium
    1410             :  --------------------------------------------------------------------*/
    1411           0 : static void lcl_ReadSections( SfxMedium& rMedium, ComboBox& rBox )
    1412             : {
    1413           0 :     rBox.Clear();
    1414           0 :     uno::Reference < embed::XStorage > xStg;
    1415           0 :     if( rMedium.IsStorage() && (xStg = rMedium.GetStorage()).is() )
    1416             :     {
    1417           0 :         std::vector<OUString*> aArr;
    1418           0 :         sal_uInt32 nFormat = SotStorage::GetFormatID( xStg );
    1419           0 :         if ( nFormat == SOT_FORMATSTR_ID_STARWRITER_60 || nFormat == SOT_FORMATSTR_ID_STARWRITERGLOB_60 ||
    1420           0 :             nFormat == SOT_FORMATSTR_ID_STARWRITER_8 || nFormat == SOT_FORMATSTR_ID_STARWRITERGLOB_8)
    1421           0 :             SwGetReaderXML()->GetSectionList( rMedium, aArr );
    1422             : 
    1423           0 :         for(std::vector<OUString*>::const_iterator it(aArr.begin()); it != aArr.end(); ++it) {
    1424           0 :             rBox.InsertEntry( **it );
    1425           0 :             delete *it;
    1426           0 :         }
    1427           0 :     }
    1428           0 : }
    1429             : 
    1430           0 : SwInsertSectionTabDialog::SwInsertSectionTabDialog(
    1431             :             Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh)
    1432             :     : SfxTabDialog(pParent, "InsertSectionDialog",
    1433             :         "modules/swriter/ui/insertsectiondialog.ui", &rSet)
    1434             :     , rWrtSh(rSh)
    1435           0 :     , m_pSectionData(0)
    1436             : {
    1437           0 :     SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
    1438             :     OSL_ENSURE(pFact, "Dialogdiet fail!");
    1439           0 :     m_nSectionPageId = AddTabPage("section", SwInsertSectionTabPage::Create, 0);
    1440           0 :     m_nColumnPageId = AddTabPage("columns",   SwColumnPage::Create,    0);
    1441           0 :     m_nBackPageId = AddTabPage("background", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), 0);
    1442           0 :     m_nNotePageId = AddTabPage("notes", SwSectionFtnEndTabPage::Create, 0);
    1443           0 :     m_nIndentPage = AddTabPage("indents", SwSectionIndentTabPage::Create, 0);
    1444             : 
    1445           0 :     SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
    1446           0 :     long nHtmlMode = rHtmlOpt.GetExportMode();
    1447             : 
    1448           0 :     bool bWeb = 0 != PTR_CAST( SwWebDocShell, rSh.GetView().GetDocShell() );
    1449           0 :     if(bWeb)
    1450             :     {
    1451           0 :         RemoveTabPage(m_nNotePageId);
    1452           0 :         RemoveTabPage(m_nIndentPage);
    1453           0 :         if( HTML_CFG_NS40 != nHtmlMode && HTML_CFG_WRITER != nHtmlMode)
    1454           0 :             RemoveTabPage(m_nColumnPageId);
    1455             :     }
    1456           0 :     SetCurPageId(m_nSectionPageId);
    1457           0 : }
    1458             : 
    1459           0 : SwInsertSectionTabDialog::~SwInsertSectionTabDialog()
    1460             : {
    1461           0 : }
    1462             : 
    1463           0 : void SwInsertSectionTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
    1464             : {
    1465           0 :     if (nId == m_nSectionPageId)
    1466           0 :         ((SwInsertSectionTabPage&)rPage).SetWrtShell(rWrtSh);
    1467           0 :     else if (nId == m_nBackPageId)
    1468             :     {
    1469           0 :             SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
    1470           0 :             aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, SVX_SHOW_SELECTOR));
    1471           0 :             rPage.PageCreated(aSet);
    1472             :     }
    1473           0 :     else if (nId == m_nColumnPageId)
    1474             :     {
    1475           0 :         const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)GetInputSetImpl()->Get(RES_FRM_SIZE);
    1476           0 :         ((SwColumnPage&)rPage).SetPageWidth(rSize.GetWidth());
    1477           0 :         ((SwColumnPage&)rPage).ShowBalance(sal_True);
    1478           0 :         ((SwColumnPage&)rPage).SetInSection(sal_True);
    1479             :     }
    1480           0 :     else if (nId == m_nIndentPage)
    1481           0 :         ((SwSectionIndentTabPage&)rPage).SetWrtShell(rWrtSh);
    1482           0 : }
    1483             : 
    1484           0 : void SwInsertSectionTabDialog::SetSectionData(SwSectionData const& rSect)
    1485             : {
    1486           0 :     m_pSectionData.reset( new SwSectionData(rSect) );
    1487           0 : }
    1488             : 
    1489           0 : short   SwInsertSectionTabDialog::Ok()
    1490             : {
    1491           0 :     short nRet = SfxTabDialog::Ok();
    1492             :     OSL_ENSURE(m_pSectionData.get(),
    1493             :             "SwInsertSectionTabDialog: no SectionData?");
    1494           0 :     const SfxItemSet* pOutputItemSet = GetOutputItemSet();
    1495           0 :     rWrtSh.InsertSection(*m_pSectionData, pOutputItemSet);
    1496           0 :     SfxViewFrame* pViewFrm = rWrtSh.GetView().GetViewFrame();
    1497             :     uno::Reference< frame::XDispatchRecorder > xRecorder =
    1498           0 :             pViewFrm->GetBindings().GetRecorder();
    1499           0 :     if ( xRecorder.is() )
    1500             :     {
    1501           0 :         SfxRequest aRequest( pViewFrm, FN_INSERT_REGION);
    1502             :         const SfxPoolItem* pCol;
    1503           0 :         if(SFX_ITEM_SET == pOutputItemSet->GetItemState(RES_COL, false, &pCol))
    1504             :         {
    1505             :             aRequest.AppendItem(SfxUInt16Item(SID_ATTR_COLUMNS,
    1506           0 :                 ((const SwFmtCol*)pCol)->GetColumns().size()));
    1507             :         }
    1508             :         aRequest.AppendItem(SfxStringItem( FN_PARAM_REGION_NAME,
    1509           0 :                     m_pSectionData->GetSectionName()));
    1510             :         aRequest.AppendItem(SfxStringItem( FN_PARAM_REGION_CONDITION,
    1511           0 :                     m_pSectionData->GetCondition()));
    1512             :         aRequest.AppendItem(SfxBoolItem( FN_PARAM_REGION_HIDDEN,
    1513           0 :                     m_pSectionData->IsHidden()));
    1514             :         aRequest.AppendItem(SfxBoolItem( FN_PARAM_REGION_PROTECT,
    1515           0 :                     m_pSectionData->IsProtectFlag()));
    1516             :         // edit in readonly sections
    1517             :         aRequest.AppendItem(SfxBoolItem( FN_PARAM_REGION_EDIT_IN_READONLY,
    1518           0 :                     m_pSectionData->IsEditInReadonlyFlag()));
    1519             : 
    1520           0 :         const OUString sLinkFileName( m_pSectionData->GetLinkFileName() );
    1521           0 :         sal_Int32 n = 0;
    1522           0 :         aRequest.AppendItem(SfxStringItem( FN_PARAM_1, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
    1523           0 :         aRequest.AppendItem(SfxStringItem( FN_PARAM_2, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
    1524           0 :         aRequest.AppendItem(SfxStringItem( FN_PARAM_3, sLinkFileName.getToken( 0, sfx2::cTokenSeparator, n )));
    1525           0 :         aRequest.Done();
    1526             :     }
    1527           0 :     return nRet;
    1528             : }
    1529             : 
    1530           0 : SwInsertSectionTabPage::SwInsertSectionTabPage(
    1531             :                             Window *pParent, const SfxItemSet &rAttrSet)
    1532             :     : SfxTabPage(pParent, "SectionPage",
    1533             :         "modules/swriter/ui/sectionpage.ui", rAttrSet)
    1534             :     , m_pWrtSh(0)
    1535             :     , m_pDocInserter(NULL)
    1536           0 :     , m_pOldDefDlgParent(NULL)
    1537             : {
    1538           0 :     get(m_pCurName, "sectionnames");
    1539           0 :     m_pCurName->SetStyle(m_pCurName->GetStyle() | WB_SORT);
    1540           0 :     m_pCurName->set_height_request(m_pCurName->GetTextHeight() * 12);
    1541           0 :     get(m_pFileCB, "link");
    1542           0 :     get(m_pDDECB, "dde");
    1543           0 :     get(m_pDDECommandFT, "ddelabel");
    1544           0 :     get(m_pFileNameFT, "filelabel");
    1545           0 :     get(m_pFileNameED, "filename");
    1546           0 :     get(m_pFilePB, "selectfile");
    1547           0 :     get(m_pSubRegionFT, "sectionlabel");
    1548           0 :     get(m_pSubRegionED, "sectionname");
    1549           0 :     m_pSubRegionED->SetStyle(m_pSubRegionED->GetStyle() | WB_SORT);
    1550           0 :     get(m_pProtectCB, "protect");
    1551           0 :     get(m_pPasswdCB, "withpassword");
    1552           0 :     get(m_pPasswdPB, "selectpassword");
    1553           0 :     get(m_pHideCB, "hide");
    1554           0 :     get(m_pConditionFT, "condlabel");
    1555           0 :     get(m_pConditionED, "withcond");
    1556             :     // edit in readonly sections
    1557           0 :     get(m_pEditInReadonlyCB, "editable");
    1558             : 
    1559           0 :     m_pProtectCB->SetClickHdl  ( LINK( this, SwInsertSectionTabPage, ChangeProtectHdl));
    1560           0 :     m_pPasswdCB->SetClickHdl   ( LINK( this, SwInsertSectionTabPage, ChangePasswdHdl));
    1561           0 :     m_pPasswdPB->SetClickHdl   ( LINK( this, SwInsertSectionTabPage, ChangePasswdHdl));
    1562           0 :     m_pHideCB->SetClickHdl     ( LINK( this, SwInsertSectionTabPage, ChangeHideHdl));
    1563             :     // edit in readonly sections
    1564           0 :     m_pEditInReadonlyCB->SetClickHdl       ( LINK( this, SwInsertSectionTabPage, ChangeEditInReadonlyHdl));
    1565           0 :     m_pFileCB->SetClickHdl     ( LINK( this, SwInsertSectionTabPage, UseFileHdl ));
    1566           0 :     m_pFilePB->SetClickHdl     ( LINK( this, SwInsertSectionTabPage, FileSearchHdl ));
    1567           0 :     m_pCurName->SetModifyHdl   ( LINK( this, SwInsertSectionTabPage, NameEditHdl));
    1568           0 :     m_pDDECB->SetClickHdl      ( LINK( this, SwInsertSectionTabPage, DDEHdl ));
    1569           0 :     ChangeProtectHdl(m_pProtectCB);
    1570           0 :     m_pSubRegionED->EnableAutocomplete( true, true );
    1571           0 : }
    1572             : 
    1573           0 : SwInsertSectionTabPage::~SwInsertSectionTabPage()
    1574             : {
    1575           0 :     delete m_pDocInserter;
    1576           0 : }
    1577             : 
    1578           0 : void    SwInsertSectionTabPage::SetWrtShell(SwWrtShell& rSh)
    1579             : {
    1580           0 :     m_pWrtSh = &rSh;
    1581             : 
    1582           0 :     bool bWeb = 0 != PTR_CAST(SwWebDocShell, m_pWrtSh->GetView().GetDocShell());
    1583           0 :     if(bWeb)
    1584             :     {
    1585           0 :         m_pHideCB->Hide();
    1586           0 :         m_pConditionED->Hide();
    1587           0 :         m_pConditionFT->Hide();
    1588           0 :         m_pDDECB->Hide();
    1589           0 :         m_pDDECommandFT->Hide();
    1590             :     }
    1591             : 
    1592           0 :     lcl_FillSubRegionList(*m_pWrtSh, *m_pSubRegionED, m_pCurName);
    1593             : 
    1594             :     SwSectionData *const pSectionData =
    1595           0 :         static_cast<SwInsertSectionTabDialog*>(GetTabDialog())
    1596           0 :             ->GetSectionData();
    1597           0 :     if (pSectionData) // something set?
    1598             :     {
    1599           0 :         const OUString sSectionName(pSectionData->GetSectionName());
    1600           0 :         m_pCurName->SetText(rSh.GetUniqueSectionName(&sSectionName));
    1601           0 :         m_pProtectCB->Check( pSectionData->IsProtectFlag() );
    1602           0 :         m_sFileName = pSectionData->GetLinkFileName();
    1603           0 :         m_sFilePasswd = pSectionData->GetLinkFilePassword();
    1604           0 :         m_pFileCB->Check( !m_sFileName.isEmpty() );
    1605           0 :         m_pFileNameED->SetText( m_sFileName );
    1606           0 :         UseFileHdl(m_pFileCB);
    1607             :     }
    1608             :     else
    1609             :     {
    1610           0 :         m_pCurName->SetText( rSh.GetUniqueSectionName() );
    1611             :     }
    1612           0 : }
    1613             : 
    1614           0 : bool SwInsertSectionTabPage::FillItemSet( SfxItemSet& )
    1615             : {
    1616           0 :     SwSectionData aSection(CONTENT_SECTION, m_pCurName->GetText());
    1617           0 :     aSection.SetCondition(m_pConditionED->GetText());
    1618           0 :     sal_Bool bProtected = m_pProtectCB->IsChecked();
    1619           0 :     aSection.SetProtectFlag(bProtected);
    1620           0 :     aSection.SetHidden(m_pHideCB->IsChecked());
    1621             :     // edit in readonly sections
    1622           0 :     aSection.SetEditInReadonlyFlag(m_pEditInReadonlyCB->IsChecked());
    1623             : 
    1624           0 :     if(bProtected)
    1625             :     {
    1626           0 :         aSection.SetPassword(m_aNewPasswd);
    1627             :     }
    1628           0 :     const OUString sFileName = m_pFileNameED->GetText();
    1629           0 :     const OUString sSubRegion = m_pSubRegionED->GetText();
    1630           0 :     sal_Bool bDDe = m_pDDECB->IsChecked();
    1631           0 :     if(m_pFileCB->IsChecked() && (!sFileName.isEmpty() || !sSubRegion.isEmpty() || bDDe))
    1632             :     {
    1633           0 :         OUString aLinkFile;
    1634           0 :         if( bDDe )
    1635             :         {
    1636           0 :             aLinkFile = SwSectionData::CollapseWhiteSpaces(sFileName);
    1637           0 :             sal_Int32 nPos = 0;
    1638           0 :             aLinkFile = aLinkFile.replaceFirst( " ", OUString(sfx2::cTokenSeparator), &nPos );
    1639           0 :             if (nPos>=0)
    1640             :             {
    1641           0 :                 aLinkFile = aLinkFile.replaceFirst( " ", OUString(sfx2::cTokenSeparator), &nPos );
    1642             :             }
    1643             :         }
    1644             :         else
    1645             :         {
    1646           0 :             if(!sFileName.isEmpty())
    1647             :             {
    1648           0 :                 SfxMedium* pMedium = m_pWrtSh->GetView().GetDocShell()->GetMedium();
    1649           0 :                 INetURLObject aAbs;
    1650           0 :                 if( pMedium )
    1651           0 :                     aAbs = pMedium->GetURLObject();
    1652           0 :                 aLinkFile = URIHelper::SmartRel2Abs(
    1653           0 :                     aAbs, sFileName, URIHelper::GetMaybeFileHdl() );
    1654           0 :                 aSection.SetLinkFilePassword( m_sFilePasswd );
    1655             :             }
    1656             : 
    1657           0 :             aLinkFile += OUString(sfx2::cTokenSeparator) + m_sFilterName
    1658           0 :                       +  OUString(sfx2::cTokenSeparator) + sSubRegion;
    1659             :         }
    1660             : 
    1661           0 :         aSection.SetLinkFileName(aLinkFile);
    1662           0 :         if (!aLinkFile.isEmpty())
    1663             :         {
    1664           0 :             aSection.SetType( m_pDDECB->IsChecked() ?
    1665             :                                     DDE_LINK_SECTION :
    1666           0 :                                         FILE_LINK_SECTION);
    1667           0 :         }
    1668             :     }
    1669           0 :     ((SwInsertSectionTabDialog*)GetTabDialog())->SetSectionData(aSection);
    1670           0 :     return true;
    1671             : }
    1672             : 
    1673           0 : void SwInsertSectionTabPage::Reset( const SfxItemSet& )
    1674             : {
    1675           0 : }
    1676             : 
    1677           0 : SfxTabPage* SwInsertSectionTabPage::Create( Window* pParent,
    1678             :                                 const SfxItemSet& rAttrSet)
    1679             : {
    1680           0 :     return new SwInsertSectionTabPage(pParent, rAttrSet);
    1681             : }
    1682             : 
    1683           0 : IMPL_LINK( SwInsertSectionTabPage, ChangeHideHdl, CheckBox *, pBox )
    1684             : {
    1685           0 :     sal_Bool bHide = pBox->IsChecked();
    1686           0 :     m_pConditionED->Enable(bHide);
    1687           0 :     m_pConditionFT->Enable(bHide);
    1688           0 :     return 0;
    1689             : }
    1690             : 
    1691           0 : IMPL_LINK_NOARG(SwInsertSectionTabPage, ChangeEditInReadonlyHdl)
    1692             : {
    1693           0 :     return 0;
    1694             : }
    1695             : 
    1696           0 : IMPL_LINK( SwInsertSectionTabPage, ChangeProtectHdl, CheckBox *, pBox )
    1697             : {
    1698           0 :     sal_Bool bCheck = pBox->IsChecked();
    1699           0 :     m_pPasswdCB->Enable(bCheck);
    1700           0 :     m_pPasswdPB->Enable(bCheck);
    1701           0 :     return 0;
    1702             : }
    1703             : 
    1704           0 : IMPL_LINK( SwInsertSectionTabPage, ChangePasswdHdl, Button *, pButton )
    1705             : {
    1706           0 :     sal_Bool bChange = pButton == m_pPasswdPB;
    1707           0 :     sal_Bool bSet = bChange ? bChange : m_pPasswdCB->IsChecked();
    1708           0 :     if(bSet)
    1709             :     {
    1710           0 :         if(!m_aNewPasswd.getLength() || bChange)
    1711             :         {
    1712           0 :             SfxPasswordDialog aPasswdDlg(this);
    1713           0 :             aPasswdDlg.ShowExtras(SHOWEXTRAS_CONFIRM);
    1714           0 :             if(RET_OK == aPasswdDlg.Execute())
    1715             :             {
    1716           0 :                 const OUString sNewPasswd( aPasswdDlg.GetPassword() );
    1717           0 :                 if( aPasswdDlg.GetConfirm() == sNewPasswd )
    1718             :                 {
    1719           0 :                     SvPasswordHelper::GetHashPassword( m_aNewPasswd, sNewPasswd );
    1720             :                 }
    1721             :                 else
    1722             :                 {
    1723           0 :                     InfoBox(pButton, SW_RES(REG_WRONG_PASSWD_REPEAT)).Execute();
    1724           0 :                 }
    1725             :             }
    1726           0 :             else if(!bChange)
    1727           0 :                 m_pPasswdCB->Check(false);
    1728             :         }
    1729             :     }
    1730             :     else
    1731           0 :         m_aNewPasswd.realloc(0);
    1732           0 :     return 0;
    1733             : }
    1734             : 
    1735           0 : IMPL_LINK_NOARG_INLINE_START(SwInsertSectionTabPage, NameEditHdl)
    1736             : {
    1737           0 :     const OUString aName = m_pCurName->GetText();
    1738           0 :     GetTabDialog()->GetOKButton().Enable(!aName.isEmpty() && m_pCurName->GetEntryPos( aName ) == USHRT_MAX);
    1739           0 :     return 0;
    1740             : }
    1741           0 : IMPL_LINK_NOARG_INLINE_END(SwInsertSectionTabPage, NameEditHdl)
    1742             : 
    1743           0 : IMPL_LINK( SwInsertSectionTabPage, UseFileHdl, CheckBox *, pBox )
    1744             : {
    1745           0 :     if( pBox->IsChecked() )
    1746             :     {
    1747           0 :         if( m_pWrtSh->HasSelection() &&
    1748           0 :             RET_NO == QueryBox( this, SW_RES(QB_CONNECT) ).Execute() )
    1749           0 :             pBox->Check( false );
    1750             :     }
    1751             : 
    1752           0 :     sal_Bool bFile = pBox->IsChecked();
    1753           0 :     m_pFileNameFT->Enable(bFile);
    1754           0 :     m_pFileNameED->Enable(bFile);
    1755           0 :     m_pFilePB->Enable(bFile);
    1756           0 :     m_pSubRegionFT->Enable(bFile);
    1757           0 :     m_pSubRegionED->Enable(bFile);
    1758           0 :     m_pDDECommandFT->Enable(bFile);
    1759           0 :     m_pDDECB->Enable(bFile);
    1760           0 :     if( bFile )
    1761             :     {
    1762           0 :         m_pFileNameED->GrabFocus();
    1763           0 :         m_pProtectCB->Check( true );
    1764             :     }
    1765             :     else
    1766             :     {
    1767           0 :         m_pDDECB->Check(false);
    1768           0 :         DDEHdl(m_pDDECB);
    1769             :     }
    1770           0 :     return 0;
    1771             : }
    1772             : 
    1773           0 : IMPL_LINK_NOARG(SwInsertSectionTabPage, FileSearchHdl)
    1774             : {
    1775           0 :     m_pOldDefDlgParent = Application::GetDefDialogParent();
    1776           0 :     Application::SetDefDialogParent( this );
    1777           0 :     delete m_pDocInserter;
    1778           0 :     m_pDocInserter = new ::sfx2::DocumentInserter( "swriter" );
    1779           0 :     m_pDocInserter->StartExecuteModal( LINK( this, SwInsertSectionTabPage, DlgClosedHdl ) );
    1780           0 :     return 0;
    1781             : }
    1782             : 
    1783           0 : IMPL_LINK( SwInsertSectionTabPage, DDEHdl, CheckBox*, pBox )
    1784             : {
    1785           0 :     sal_Bool bDDE = pBox->IsChecked();
    1786           0 :     sal_Bool bFile = m_pFileCB->IsChecked();
    1787           0 :     m_pFilePB->Enable(!bDDE && bFile);
    1788           0 :     if(bDDE)
    1789             :     {
    1790           0 :         m_pFileNameFT->Hide();
    1791           0 :         m_pDDECommandFT->Enable(bDDE);
    1792           0 :         m_pDDECommandFT->Show();
    1793           0 :         m_pSubRegionFT->Hide();
    1794           0 :         m_pSubRegionED->Hide();
    1795           0 :         m_pFileNameED->SetAccessibleName(m_pDDECommandFT->GetText());
    1796             :     }
    1797             :     else
    1798             :     {
    1799           0 :         m_pDDECommandFT->Hide();
    1800           0 :         m_pFileNameFT->Enable(bFile);
    1801           0 :         m_pFileNameFT->Show();
    1802           0 :         m_pSubRegionFT->Show();
    1803           0 :         m_pSubRegionED->Show();
    1804           0 :         m_pSubRegionED->Enable(bFile);
    1805           0 :         m_pFileNameED->SetAccessibleName(m_pFileNameFT->GetText());
    1806             :     }
    1807           0 :     return 0;
    1808             : }
    1809             : 
    1810           0 : IMPL_LINK( SwInsertSectionTabPage, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg )
    1811             : {
    1812           0 :     if ( _pFileDlg->GetError() == ERRCODE_NONE )
    1813             :     {
    1814           0 :         SfxMedium* pMedium = m_pDocInserter->CreateMedium();
    1815           0 :         if ( pMedium )
    1816             :         {
    1817           0 :             m_sFileName = pMedium->GetURLObject().GetMainURL( INetURLObject::NO_DECODE );
    1818           0 :             m_sFilterName = pMedium->GetFilter()->GetFilterName();
    1819             :             const SfxPoolItem* pItem;
    1820           0 :             if ( SFX_ITEM_SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, false, &pItem ) )
    1821           0 :                 m_sFilePasswd = ( (SfxStringItem*)pItem )->GetValue();
    1822             :             m_pFileNameED->SetText( INetURLObject::decode(
    1823           0 :                 m_sFileName, '%', INetURLObject::DECODE_UNAMBIGUOUS, RTL_TEXTENCODING_UTF8 ) );
    1824           0 :             ::lcl_ReadSections(*pMedium, *m_pSubRegionED);
    1825           0 :             delete pMedium;
    1826             :         }
    1827             :     }
    1828             :     else
    1829           0 :         m_sFilterName = m_sFilePasswd = aEmptyOUStr;
    1830             : 
    1831           0 :     Application::SetDefDialogParent( m_pOldDefDlgParent );
    1832           0 :     return 0;
    1833             : }
    1834             : 
    1835             : // numbering format conversion:
    1836             : // ListBox  - format            - enum-value
    1837             : // 0        - A, B, C, ...      - 0
    1838             : // 1        - a, b, c, ...      - 1
    1839             : // 2        - I, II, III, ...   - 2
    1840             : // 3        - i, ii, iii, ...   - 3
    1841             : // 4        - 1, 2, 3, ...      - 4
    1842             : // 5        - A, .., AA, ..,    - 9
    1843             : // 6        - a, .., aa, ..,    - 10
    1844             : 
    1845             : inline SvxExtNumType GetNumType( sal_uInt16 n )
    1846             : {
    1847             :     return (SvxExtNumType)(4 < n ? n + 4 : n );
    1848             : }
    1849             : 
    1850           0 : SwSectionFtnEndTabPage::SwSectionFtnEndTabPage( Window *pParent,
    1851             :                                                 const SfxItemSet &rAttrSet)
    1852           0 :     : SfxTabPage( pParent, "FootnotesEndnotesTabPage", "modules/swriter/ui/footnotesendnotestabpage.ui", rAttrSet )
    1853             : 
    1854             : {
    1855           0 :     get(pFtnNtAtTextEndCB,"ftnntattextend");
    1856             : 
    1857           0 :     get(pFtnNtNumCB,"ftnntnum");
    1858           0 :     get(pFtnOffsetLbl,"ftnoffset_label");
    1859           0 :     get(pFtnOffsetFld,"ftnoffset");
    1860             : 
    1861           0 :     get(pFtnNtNumFmtCB,"ftnntnumfmt");
    1862           0 :     get(pFtnPrefixFT,"ftnprefix_label");
    1863           0 :     get(pFtnPrefixED,"ftnprefix");
    1864           0 :     get(pFtnNumViewBox,"ftnnumviewbox");
    1865           0 :     get(pFtnSuffixFT,"ftnsuffix_label");
    1866           0 :     get(pFtnSuffixED,"ftnsuffix");
    1867             : 
    1868           0 :     get(pEndNtAtTextEndCB,"endntattextend");
    1869             : 
    1870           0 :     get(pEndNtNumCB,"endntnum");
    1871           0 :     get(pEndOffsetLbl,"endoffset_label");
    1872           0 :     get(pEndOffsetFld,"endoffset");
    1873             : 
    1874           0 :     get(pEndNtNumFmtCB,"endntnumfmt");
    1875           0 :     get(pEndPrefixFT,"endprefix_label");
    1876           0 :     get(pEndPrefixED,"endprefix");
    1877           0 :     get(pEndNumViewBox,"endnumviewbox");
    1878           0 :     get(pEndSuffixFT,"endsuffix_label");
    1879           0 :     get(pEndSuffixED,"endsuffix");
    1880             : 
    1881           0 :     Link aLk( LINK( this, SwSectionFtnEndTabPage, FootEndHdl));
    1882           0 :     pFtnNtAtTextEndCB->SetClickHdl( aLk );
    1883           0 :     pFtnNtNumCB->SetClickHdl( aLk );
    1884           0 :     pEndNtAtTextEndCB->SetClickHdl( aLk );
    1885           0 :     pEndNtNumCB->SetClickHdl( aLk );
    1886           0 :     pFtnNtNumFmtCB->SetClickHdl( aLk );
    1887           0 :     pEndNtNumFmtCB->SetClickHdl( aLk );
    1888           0 : }
    1889             : 
    1890           0 : SwSectionFtnEndTabPage::~SwSectionFtnEndTabPage()
    1891             : {
    1892           0 : }
    1893             : 
    1894           0 : bool SwSectionFtnEndTabPage::FillItemSet( SfxItemSet& rSet )
    1895             : {
    1896           0 :     SwFmtFtnAtTxtEnd aFtn( pFtnNtAtTextEndCB->IsChecked()
    1897           0 :                             ? ( pFtnNtNumCB->IsChecked()
    1898           0 :                                 ? ( pFtnNtNumFmtCB->IsChecked()
    1899             :                                     ? FTNEND_ATTXTEND_OWNNUMANDFMT
    1900             :                                     : FTNEND_ATTXTEND_OWNNUMSEQ )
    1901             :                                 : FTNEND_ATTXTEND )
    1902           0 :                             : FTNEND_ATPGORDOCEND );
    1903             : 
    1904           0 :     switch( aFtn.GetValue() )
    1905             :     {
    1906             :     case FTNEND_ATTXTEND_OWNNUMANDFMT:
    1907           0 :         aFtn.SetNumType( pFtnNumViewBox->GetSelectedNumberingType() );
    1908           0 :         aFtn.SetPrefix( pFtnPrefixED->GetText().replaceAll("\\t", "\t") ); // fdo#65666
    1909           0 :         aFtn.SetSuffix( pFtnSuffixED->GetText().replaceAll("\\t", "\t") );
    1910             :         // no break;
    1911             : 
    1912             :     case FTNEND_ATTXTEND_OWNNUMSEQ:
    1913           0 :         aFtn.SetOffset( static_cast< sal_uInt16 >( pFtnOffsetFld->GetValue()-1 ) );
    1914             :         // no break;
    1915             :     }
    1916             : 
    1917           0 :     SwFmtEndAtTxtEnd aEnd( pEndNtAtTextEndCB->IsChecked()
    1918           0 :                             ? ( pEndNtNumCB->IsChecked()
    1919           0 :                                 ? ( pEndNtNumFmtCB->IsChecked()
    1920             :                                     ? FTNEND_ATTXTEND_OWNNUMANDFMT
    1921             :                                     : FTNEND_ATTXTEND_OWNNUMSEQ )
    1922             :                                 : FTNEND_ATTXTEND )
    1923           0 :                             : FTNEND_ATPGORDOCEND );
    1924             : 
    1925           0 :     switch( aEnd.GetValue() )
    1926             :     {
    1927             :     case FTNEND_ATTXTEND_OWNNUMANDFMT:
    1928           0 :         aEnd.SetNumType( pEndNumViewBox->GetSelectedNumberingType() );
    1929           0 :         aEnd.SetPrefix( pEndPrefixED->GetText().replaceAll("\\t", "\t") );
    1930           0 :         aEnd.SetSuffix( pEndSuffixED->GetText().replaceAll("\\t", "\t") );
    1931             :         // no break;
    1932             : 
    1933             :     case FTNEND_ATTXTEND_OWNNUMSEQ:
    1934           0 :         aEnd.SetOffset( static_cast< sal_uInt16 >( pEndOffsetFld->GetValue()-1 ) );
    1935             :         // no break;
    1936             :     }
    1937             : 
    1938           0 :     rSet.Put( aFtn );
    1939           0 :     rSet.Put( aEnd );
    1940             : 
    1941           0 :     return true;
    1942             : }
    1943             : 
    1944           0 : void SwSectionFtnEndTabPage::ResetState( sal_Bool bFtn,
    1945             :                                     const SwFmtFtnEndAtTxtEnd& rAttr )
    1946             : {
    1947             :     CheckBox *pNtAtTextEndCB, *pNtNumCB, *pNtNumFmtCB;
    1948             :     FixedText*pPrefixFT, *pSuffixFT;
    1949             :     Edit *pPrefixED, *pSuffixED;
    1950             :     SwNumberingTypeListBox *pNumViewBox;
    1951             :     FixedText* pOffsetTxt;
    1952             :     NumericField *pOffsetFld;
    1953             : 
    1954           0 :     if( bFtn )
    1955             :     {
    1956           0 :         pNtAtTextEndCB = pFtnNtAtTextEndCB;
    1957           0 :         pNtNumCB = pFtnNtNumCB;
    1958           0 :         pNtNumFmtCB = pFtnNtNumFmtCB;
    1959           0 :         pPrefixFT = pFtnPrefixFT;
    1960           0 :         pPrefixED = pFtnPrefixED;
    1961           0 :         pSuffixFT = pFtnSuffixFT;
    1962           0 :         pSuffixED = pFtnSuffixED;
    1963           0 :         pNumViewBox = pFtnNumViewBox;
    1964           0 :         pOffsetTxt = pFtnOffsetLbl;
    1965           0 :         pOffsetFld = pFtnOffsetFld;
    1966             :     }
    1967             :     else
    1968             :     {
    1969           0 :         pNtAtTextEndCB = pEndNtAtTextEndCB;
    1970           0 :         pNtNumCB = pEndNtNumCB;
    1971           0 :         pNtNumFmtCB = pEndNtNumFmtCB;
    1972           0 :         pPrefixFT = pEndPrefixFT;
    1973           0 :         pPrefixED = pEndPrefixED;
    1974           0 :         pSuffixFT = pEndSuffixFT;
    1975           0 :         pSuffixED = pEndSuffixED;
    1976           0 :         pNumViewBox = pEndNumViewBox;
    1977           0 :         pOffsetTxt = pEndOffsetLbl;
    1978           0 :         pOffsetFld = pEndOffsetFld;
    1979             :     }
    1980             : 
    1981           0 :     const sal_uInt16 eState = rAttr.GetValue();
    1982           0 :     switch( eState )
    1983             :     {
    1984             :     case FTNEND_ATTXTEND_OWNNUMANDFMT:
    1985           0 :         pNtNumFmtCB->SetState( TRISTATE_TRUE );
    1986             :         // no break;
    1987             : 
    1988             :     case FTNEND_ATTXTEND_OWNNUMSEQ:
    1989           0 :         pNtNumCB->SetState( TRISTATE_TRUE );
    1990             :         // no break;
    1991             : 
    1992             :     case FTNEND_ATTXTEND:
    1993           0 :         pNtAtTextEndCB->SetState( TRISTATE_TRUE );
    1994             :         // no break;
    1995             :     }
    1996             : 
    1997           0 :     pNumViewBox->SelectNumberingType( rAttr.GetNumType() );
    1998           0 :     pOffsetFld->SetValue( rAttr.GetOffset() + 1 );
    1999           0 :     pPrefixED->SetText( rAttr.GetPrefix().replaceAll("\t", "\\t") );
    2000           0 :     pSuffixED->SetText( rAttr.GetSuffix().replaceAll("\t", "\\t") );
    2001             : 
    2002           0 :     switch( eState )
    2003             :     {
    2004             :     case FTNEND_ATPGORDOCEND:
    2005           0 :         pNtNumCB->Enable( false );
    2006             :         // no break;
    2007             : 
    2008             :     case FTNEND_ATTXTEND:
    2009           0 :         pNtNumFmtCB->Enable( false );
    2010           0 :         pOffsetFld->Enable( false );
    2011           0 :         pOffsetTxt->Enable( false );
    2012             :         // no break;
    2013             : 
    2014             :     case FTNEND_ATTXTEND_OWNNUMSEQ:
    2015           0 :         pNumViewBox->Enable( false );
    2016           0 :         pPrefixFT->Enable( false );
    2017           0 :         pPrefixED->Enable( false );
    2018           0 :         pSuffixFT->Enable( false );
    2019           0 :         pSuffixED->Enable( false );
    2020             :         // no break;
    2021             :     }
    2022           0 : }
    2023             : 
    2024           0 : void SwSectionFtnEndTabPage::Reset( const SfxItemSet& rSet )
    2025             : {
    2026             :     ResetState( sal_True, (const SwFmtFtnAtTxtEnd&)rSet.Get(
    2027           0 :                                     RES_FTN_AT_TXTEND, false ));
    2028             :     ResetState( sal_False, (const SwFmtEndAtTxtEnd&)rSet.Get(
    2029           0 :                                     RES_END_AT_TXTEND, false ));
    2030           0 : }
    2031             : 
    2032           0 : SfxTabPage* SwSectionFtnEndTabPage::Create( Window* pParent,
    2033             :                                 const SfxItemSet& rAttrSet)
    2034             : {
    2035           0 :     return new SwSectionFtnEndTabPage(pParent, rAttrSet);
    2036             : }
    2037             : 
    2038           0 : IMPL_LINK( SwSectionFtnEndTabPage, FootEndHdl, CheckBox *, pBox )
    2039             : {
    2040           0 :     sal_Bool bFoot = pFtnNtAtTextEndCB == pBox || pFtnNtNumCB == pBox ||
    2041           0 :                     pFtnNtNumFmtCB == pBox ;
    2042             : 
    2043             :     CheckBox *pNumBox, *pNumFmtBox, *pEndBox;
    2044             :     SwNumberingTypeListBox* pNumViewBox;
    2045             :     FixedText* pOffsetTxt;
    2046             :     NumericField *pOffsetFld;
    2047             :     FixedText*pPrefixFT, *pSuffixFT;
    2048             :     Edit *pPrefixED, *pSuffixED;
    2049             : 
    2050           0 :     if( bFoot )
    2051             :     {
    2052           0 :         pEndBox = pFtnNtAtTextEndCB;
    2053           0 :         pNumBox = pFtnNtNumCB;
    2054           0 :         pNumFmtBox = pFtnNtNumFmtCB;
    2055           0 :         pNumViewBox = pFtnNumViewBox;
    2056           0 :         pOffsetTxt = pFtnOffsetLbl;
    2057           0 :         pOffsetFld = pFtnOffsetFld;
    2058           0 :         pPrefixFT = pFtnPrefixFT;
    2059           0 :         pSuffixFT = pFtnSuffixFT;
    2060           0 :         pPrefixED = pFtnPrefixED;
    2061           0 :         pSuffixED = pFtnSuffixED;
    2062             :     }
    2063             :     else
    2064             :     {
    2065           0 :         pEndBox = pEndNtAtTextEndCB;
    2066           0 :         pNumBox = pEndNtNumCB;
    2067           0 :         pNumFmtBox = pEndNtNumFmtCB;
    2068           0 :         pNumViewBox = pEndNumViewBox;
    2069           0 :         pOffsetTxt = pEndOffsetLbl;
    2070           0 :         pOffsetFld = pEndOffsetFld;
    2071           0 :         pPrefixFT = pEndPrefixFT;
    2072           0 :         pSuffixFT = pEndSuffixFT;
    2073           0 :         pPrefixED = pEndPrefixED;
    2074           0 :         pSuffixED = pEndSuffixED;
    2075             :     }
    2076             : 
    2077           0 :     sal_Bool bEnableAtEnd = TRISTATE_TRUE == pEndBox->GetState();
    2078           0 :     sal_Bool bEnableNum = bEnableAtEnd && TRISTATE_TRUE == pNumBox->GetState();
    2079           0 :     sal_Bool bEnableNumFmt = bEnableNum && TRISTATE_TRUE == pNumFmtBox->GetState();
    2080             : 
    2081           0 :     pNumBox->Enable( bEnableAtEnd );
    2082           0 :     pOffsetTxt->Enable( bEnableNum );
    2083           0 :     pOffsetFld->Enable( bEnableNum );
    2084           0 :     pNumFmtBox->Enable( bEnableNum );
    2085           0 :     pNumViewBox->Enable( bEnableNumFmt );
    2086           0 :     pPrefixED->Enable( bEnableNumFmt );
    2087           0 :     pSuffixED->Enable( bEnableNumFmt );
    2088           0 :     pPrefixFT->Enable( bEnableNumFmt );
    2089           0 :     pSuffixFT->Enable( bEnableNumFmt );
    2090             : 
    2091           0 :     return 0;
    2092             : }
    2093             : 
    2094           0 : SwSectionPropertyTabDialog::SwSectionPropertyTabDialog(
    2095             :     Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh)
    2096             :     : SfxTabDialog(pParent, "FormatSectionDialog",
    2097             :         "modules/swriter/ui/formatsectiondialog.ui", &rSet)
    2098           0 :     , rWrtSh(rSh)
    2099             : {
    2100           0 :     SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
    2101             :     OSL_ENSURE(pFact, "Dialogdiet fail!");
    2102           0 :     m_nColumnPageId = AddTabPage("columns",   SwColumnPage::Create,    0);
    2103           0 :     m_nBackPageId = AddTabPage("background", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), 0 );
    2104           0 :     m_nNotePageId = AddTabPage("notes", SwSectionFtnEndTabPage::Create, 0);
    2105           0 :     m_nIndentPage = AddTabPage("indents", SwSectionIndentTabPage::Create, 0);
    2106             : 
    2107           0 :     SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
    2108           0 :     long nHtmlMode = rHtmlOpt.GetExportMode();
    2109           0 :     bool bWeb = 0 != PTR_CAST( SwWebDocShell, rSh.GetView().GetDocShell() );
    2110           0 :     if(bWeb)
    2111             :     {
    2112           0 :         RemoveTabPage(m_nNotePageId);
    2113           0 :         RemoveTabPage(m_nIndentPage);
    2114           0 :         if( HTML_CFG_NS40 != nHtmlMode && HTML_CFG_WRITER != nHtmlMode)
    2115           0 :             RemoveTabPage(m_nColumnPageId);
    2116             :     }
    2117           0 : }
    2118             : 
    2119           0 : SwSectionPropertyTabDialog::~SwSectionPropertyTabDialog()
    2120             : {
    2121           0 : }
    2122             : 
    2123           0 : void SwSectionPropertyTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
    2124             : {
    2125           0 :     if (nId == m_nBackPageId)
    2126             :     {
    2127           0 :             SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
    2128           0 :             aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, SVX_SHOW_SELECTOR));
    2129           0 :             rPage.PageCreated(aSet);
    2130             :     }
    2131           0 :     else if (nId == m_nColumnPageId)
    2132             :     {
    2133           0 :         ((SwColumnPage&)rPage).ShowBalance(sal_True);
    2134           0 :         ((SwColumnPage&)rPage).SetInSection(sal_True);
    2135             :     }
    2136           0 :     else if (nId == m_nIndentPage)
    2137           0 :         ((SwSectionIndentTabPage&)rPage).SetWrtShell(rWrtSh);
    2138           0 : }
    2139             : 
    2140           0 : SwSectionIndentTabPage::SwSectionIndentTabPage(Window *pParent, const SfxItemSet &rAttrSet)
    2141           0 :     : SfxTabPage(pParent, "IndentPage", "modules/swriter/ui/indentpage.ui", rAttrSet)
    2142             : {
    2143           0 :     get(m_pBeforeMF, "before");
    2144           0 :     get(m_pAfterMF, "after");
    2145           0 :     get(m_pPreviewWin, "preview");
    2146           0 :     Link aLk = LINK(this, SwSectionIndentTabPage, IndentModifyHdl);
    2147           0 :     m_pBeforeMF->SetModifyHdl(aLk);
    2148           0 :     m_pAfterMF->SetModifyHdl(aLk);
    2149           0 : }
    2150             : 
    2151           0 : SwSectionIndentTabPage::~SwSectionIndentTabPage()
    2152             : {
    2153           0 : }
    2154             : 
    2155           0 : bool SwSectionIndentTabPage::FillItemSet( SfxItemSet& rSet)
    2156             : {
    2157           0 :     if(m_pBeforeMF->IsValueModified() ||
    2158           0 :             m_pAfterMF->IsValueModified())
    2159             :     {
    2160             :         SvxLRSpaceItem aLRSpace(
    2161           0 :                 static_cast< long >(m_pBeforeMF->Denormalize(m_pBeforeMF->GetValue(FUNIT_TWIP))) ,
    2162           0 :                 static_cast< long >(m_pAfterMF->Denormalize(m_pAfterMF->GetValue(FUNIT_TWIP))), 0, 0, RES_LR_SPACE);
    2163           0 :         rSet.Put(aLRSpace);
    2164             :     }
    2165           0 :     return true;
    2166             : }
    2167             : 
    2168           0 : void SwSectionIndentTabPage::Reset( const SfxItemSet& rSet)
    2169             : {
    2170             :     //this page doesn't show up in HTML mode
    2171           0 :     FieldUnit aMetric = ::GetDfltMetric(sal_False);
    2172           0 :     SetMetric(*m_pBeforeMF, aMetric);
    2173           0 :     SetMetric(*m_pAfterMF , aMetric);
    2174             : 
    2175           0 :     SfxItemState eItemState = rSet.GetItemState( RES_LR_SPACE );
    2176           0 :     if ( eItemState >= SFX_ITEM_AVAILABLE )
    2177             :     {
    2178             :         const SvxLRSpaceItem& rSpace =
    2179           0 :             (const SvxLRSpaceItem&)rSet.Get( RES_LR_SPACE );
    2180             : 
    2181           0 :         m_pBeforeMF->SetValue( m_pBeforeMF->Normalize(rSpace.GetLeft()), FUNIT_TWIP );
    2182           0 :         m_pAfterMF->SetValue( m_pAfterMF->Normalize(rSpace.GetRight()), FUNIT_TWIP );
    2183             :     }
    2184             :     else
    2185             :     {
    2186           0 :         m_pBeforeMF->SetEmptyFieldValue();
    2187           0 :         m_pAfterMF->SetEmptyFieldValue();
    2188             :     }
    2189           0 :     m_pBeforeMF->SaveValue();
    2190           0 :     m_pAfterMF->SaveValue();
    2191           0 :     IndentModifyHdl(0);
    2192           0 : }
    2193             : 
    2194           0 : SfxTabPage*  SwSectionIndentTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet)
    2195             : {
    2196           0 :     return new SwSectionIndentTabPage(pParent, rAttrSet);
    2197             : }
    2198             : 
    2199           0 : void SwSectionIndentTabPage::SetWrtShell(SwWrtShell& rSh)
    2200             : {
    2201             :     //set sensible values at the preview
    2202           0 :     m_pPreviewWin->SetAdjust(SVX_ADJUST_BLOCK);
    2203           0 :     m_pPreviewWin->SetLastLine(SVX_ADJUST_BLOCK);
    2204           0 :     const SwRect& rPageRect = rSh.GetAnyCurRect( RECT_PAGE, 0 );
    2205           0 :     Size aPageSize(rPageRect.Width(), rPageRect.Height());
    2206           0 :     m_pPreviewWin->SetSize(aPageSize);
    2207           0 : }
    2208             : 
    2209           0 : IMPL_LINK_NOARG(SwSectionIndentTabPage, IndentModifyHdl)
    2210             : {
    2211           0 :     m_pPreviewWin->SetLeftMargin( static_cast< long >(m_pBeforeMF->Denormalize(m_pBeforeMF->GetValue(FUNIT_TWIP))) );
    2212           0 :     m_pPreviewWin->SetRightMargin( static_cast< long >(m_pAfterMF->Denormalize(m_pAfterMF->GetValue(FUNIT_TWIP))) );
    2213           0 :     m_pPreviewWin->Draw(true);
    2214           0 :     return 0;
    2215           0 : }
    2216             : 
    2217             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10