LCOV - code coverage report
Current view: top level - sw/source/ui/dialog - uiregionsw.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 1247 0.0 %
Date: 2012-08-25 Functions: 0 124 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10