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

Generated by: LCOV version 1.11