LCOV - code coverage report
Current view: top level - sw/source/ui/frmdlg - column.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 734 0.0 %
Date: 2012-08-25 Functions: 0 47 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 "column.hxx"
      30                 :            : 
      31                 :            : #include "hintids.hxx"
      32                 :            : #include <svx/dialogs.hrc>
      33                 :            : #include <svx/dialmgr.hxx>
      34                 :            : #include <svx/htmlmode.hxx>
      35                 :            : #include <svx/xtable.hxx>
      36                 :            : #include <svx/drawitem.hxx>
      37                 :            : #include <editeng/borderline.hxx>
      38                 :            : #include <editeng/boxitem.hxx>
      39                 :            : #include <editeng/lrspitem.hxx>
      40                 :            : #include <editeng/sizeitem.hxx>
      41                 :            : #include "editeng/frmdiritem.hxx"
      42                 :            : #include <svl/ctloptions.hxx>
      43                 :            : #include <sfx2/dispatch.hxx>
      44                 :            : #include <vcl/msgbox.hxx>
      45                 :            : #include <swmodule.hxx>
      46                 :            : #include <sal/macros.h>
      47                 :            : 
      48                 :            : #include <helpid.h>
      49                 :            : #include "globals.hrc"
      50                 :            : #include "swtypes.hxx"
      51                 :            : #include "wrtsh.hxx"
      52                 :            : #include "view.hxx"
      53                 :            : #include "docsh.hxx"
      54                 :            : #include "uitool.hxx"
      55                 :            : #include "cmdid.h"
      56                 :            : #include "viewopt.hxx"
      57                 :            : #include "format.hxx"
      58                 :            : #include "frmmgr.hxx"
      59                 :            : #include "frmdlg.hxx"
      60                 :            : #include "colmgr.hxx"
      61                 :            : #include "prcntfld.hxx"
      62                 :            : #include "paratr.hxx"
      63                 :            : #include "frmui.hrc"
      64                 :            : #include "poolfmt.hrc"
      65                 :            : #include "column.hrc"
      66                 :            : #include <section.hxx>
      67                 :            : #include <docary.hxx>
      68                 :            : #include <pagedesc.hxx>
      69                 :            : 
      70                 :            : #include "access.hrc"
      71                 :            : 
      72                 :            : 
      73                 :            : using namespace ::com::sun::star;
      74                 :            : 
      75                 :            : #define FRAME_FORMAT_WIDTH 1000
      76                 :            : 
      77                 :            : /*--------------------------------------------------------------------
      78                 :            :     Description:  static data
      79                 :            :  --------------------------------------------------------------------*/
      80                 :            : 
      81                 :            : static const sal_uInt16 nVisCols = 3;
      82                 :            : 
      83                 :          0 : inline sal_Bool IsMarkInSameSection( SwWrtShell& rWrtSh, const SwSection* pSect )
      84                 :            : {
      85                 :          0 :     rWrtSh.SwapPam();
      86                 :          0 :     sal_Bool bRet = pSect == rWrtSh.GetCurrSection();
      87                 :          0 :     rWrtSh.SwapPam();
      88                 :          0 :     return bRet;
      89                 :            : }
      90                 :            : 
      91                 :          0 : SwColumnDlg::SwColumnDlg(Window* pParent, SwWrtShell& rSh) :
      92                 :            :     SfxModalDialog(pParent, SW_RES(DLG_COLUMN)),
      93                 :            :     aOK(this,       SW_RES(PB_OK)),
      94                 :            :     aCancel(this,   SW_RES(PB_CANCEL)),
      95                 :            :     aHelp(this,     SW_RES(PB_HELP)),
      96                 :            :     aApplyToFT(this, SW_RES(FT_APPLY_TO)),
      97                 :            :     aApplyToLB(this, SW_RES(LB_APPLY_TO)),
      98                 :            :     rWrtShell(rSh),
      99                 :            :     pPageSet(0),
     100                 :            :     pSectionSet(0),
     101                 :            :     pSelectionSet(0),
     102                 :            :     pFrameSet(0),
     103                 :            :     nOldSelection(0),
     104                 :            :     nSelectionWidth(0),
     105                 :            :     bPageChanged(sal_False),
     106                 :            :     bSectionChanged(sal_False),
     107                 :            :     bSelSectionChanged(sal_False),
     108                 :          0 :     bFrameChanged(sal_False)
     109                 :            : {
     110                 :          0 :     FreeResource();
     111                 :            : 
     112                 :          0 :     SwRect aRect;
     113                 :          0 :     rWrtShell.CalcBoundRect(aRect, FLY_AS_CHAR);
     114                 :            : 
     115                 :          0 :     nSelectionWidth = aRect.Width();
     116                 :            : 
     117                 :          0 :     SfxItemSet* pColPgSet = 0;
     118                 :            :     static sal_uInt16 const aSectIds[] = { RES_COL, RES_COL,
     119                 :            :                                                 RES_FRM_SIZE, RES_FRM_SIZE,
     120                 :            :                                                 RES_COLUMNBALANCE, RES_FRAMEDIR,
     121                 :            :                                                 0 };
     122                 :            : 
     123                 :          0 :     const SwSection* pCurrSection = rWrtShell.GetCurrSection();
     124                 :          0 :     sal_uInt16 nFullSectCnt = rWrtShell.GetFullSelectedSectionCount();
     125                 :          0 :     if( pCurrSection && ( !rWrtShell.HasSelection() || 0 != nFullSectCnt ))
     126                 :            :     {
     127                 :          0 :         nSelectionWidth = rSh.GetSectionWidth(*pCurrSection->GetFmt());
     128                 :          0 :         if ( !nSelectionWidth )
     129                 :          0 :             nSelectionWidth = USHRT_MAX;
     130                 :          0 :         pSectionSet = new SfxItemSet( rWrtShell.GetAttrPool(), aSectIds );
     131                 :          0 :         pSectionSet->Put( pCurrSection->GetFmt()->GetAttrSet() );
     132                 :          0 :         pColPgSet = pSectionSet;
     133                 :            :         aApplyToLB.RemoveEntry( aApplyToLB.GetEntryPos(
     134                 :            :                                         (void*)(sal_IntPtr)( 1 >= nFullSectCnt
     135                 :            :                                                     ? LISTBOX_SECTIONS
     136                 :          0 :                                                     : LISTBOX_SECTION )));
     137                 :            :     }
     138                 :            :     else
     139                 :            :     {
     140                 :          0 :         aApplyToLB.RemoveEntry(aApplyToLB.GetEntryPos( (void*)(sal_IntPtr)LISTBOX_SECTION ));
     141                 :          0 :         aApplyToLB.RemoveEntry(aApplyToLB.GetEntryPos( (void*)(sal_IntPtr)LISTBOX_SECTIONS ));
     142                 :            :     }
     143                 :            : 
     144                 :          0 :     if( rWrtShell.HasSelection() && rWrtShell.IsInsRegionAvailable() &&
     145                 :            :         ( !pCurrSection || ( 1 != nFullSectCnt &&
     146                 :          0 :             IsMarkInSameSection( rWrtShell, pCurrSection ) )))
     147                 :            :     {
     148                 :          0 :         pSelectionSet = new SfxItemSet( rWrtShell.GetAttrPool(), aSectIds );
     149                 :          0 :         pColPgSet = pSelectionSet;
     150                 :            :     }
     151                 :            :     else
     152                 :          0 :         aApplyToLB.RemoveEntry(aApplyToLB.GetEntryPos( (void*)(sal_IntPtr)LISTBOX_SELECTION ));
     153                 :            : 
     154                 :          0 :     if( rWrtShell.GetFlyFrmFmt() )
     155                 :            :     {
     156                 :          0 :         const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt() ;
     157                 :          0 :         pFrameSet = new SfxItemSet(rWrtShell.GetAttrPool(), aSectIds );
     158                 :          0 :         pFrameSet->Put(pFmt->GetFrmSize());
     159                 :          0 :         pFrameSet->Put(pFmt->GetCol());
     160                 :          0 :         pColPgSet = pFrameSet;
     161                 :            :     }
     162                 :            :     else
     163                 :          0 :         aApplyToLB.RemoveEntry(aApplyToLB.GetEntryPos( (void*) LISTBOX_FRAME ));
     164                 :            : 
     165                 :            : 
     166                 :          0 :     sal_uInt16 nPagePos = aApplyToLB.GetEntryPos( (void*) LISTBOX_PAGE );
     167                 :          0 :     const SwPageDesc* pPageDesc = rWrtShell.GetSelectedPageDescs();
     168                 :          0 :     if( pPageDesc )
     169                 :            :     {
     170                 :          0 :         pPageSet = new SfxItemSet( rWrtShell.GetAttrPool(),
     171                 :            :                                     RES_COL, RES_COL,
     172                 :            :                                     RES_FRM_SIZE, RES_FRM_SIZE,
     173                 :            :                                     RES_LR_SPACE, RES_LR_SPACE,
     174                 :          0 :                                     0 );
     175                 :            : 
     176                 :          0 :         String sPageStr = aApplyToLB.GetEntry(nPagePos);
     177                 :          0 :         aApplyToLB.RemoveEntry( nPagePos );
     178                 :          0 :         sPageStr += pPageDesc->GetName();
     179                 :          0 :         aApplyToLB.InsertEntry( sPageStr, nPagePos );
     180                 :          0 :         aApplyToLB.SetEntryData( nPagePos, (void*) LISTBOX_PAGE);
     181                 :            : 
     182                 :          0 :         const SwFrmFmt &rFmt = pPageDesc->GetMaster();
     183                 :          0 :         nPageWidth = rFmt.GetFrmSize().GetSize().Width();
     184                 :            : 
     185                 :          0 :         const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)rFmt.GetLRSpace();
     186                 :          0 :         const SvxBoxItem& rBox = (const SvxBoxItem&) rFmt.GetBox();
     187                 :          0 :         nPageWidth -= rLRSpace.GetLeft() + rLRSpace.GetRight() + rBox.GetDistance();
     188                 :            : 
     189                 :          0 :         pPageSet->Put(rFmt.GetCol());
     190                 :          0 :         pPageSet->Put(rFmt.GetLRSpace());
     191                 :          0 :         pColPgSet = pPageSet;
     192                 :            :     }
     193                 :            :     else
     194                 :          0 :         aApplyToLB.RemoveEntry( nPagePos );
     195                 :            : 
     196                 :            :     OSL_ENSURE( pColPgSet, "" );
     197                 :            :     // create TabPage
     198                 :            :     SwColumnPage* pPage = (SwColumnPage*) SwColumnPage::Create( this,
     199                 :          0 :                                                                 *pColPgSet );
     200                 :          0 :     pTabPage = pPage;
     201                 :            : 
     202                 :            :     // adjust size
     203                 :          0 :     Size aPageSize(pTabPage->GetSizePixel());
     204                 :          0 :     Size aDlgSize(GetOutputSizePixel());
     205                 :          0 :     aDlgSize.Height() = aPageSize.Height();
     206                 :          0 :     SetOutputSizePixel(aDlgSize);
     207                 :          0 :     pTabPage->Show();
     208                 :            : 
     209                 :          0 :     aApplyToLB.SelectEntryPos(0);
     210                 :          0 :     ObjectHdl(0);
     211                 :            : 
     212                 :          0 :     aApplyToLB.SetSelectHdl(LINK(this, SwColumnDlg, ObjectHdl));
     213                 :          0 :     aOK.SetClickHdl(LINK(this, SwColumnDlg, OkHdl));
     214                 :            :     //#i80458# if no columns can be set then disable OK
     215                 :          0 :     if( !aApplyToLB.GetEntryCount() )
     216                 :          0 :         aOK.Enable( sal_False );
     217                 :            :     //#i97810# set focus to the TabPage
     218                 :          0 :     pTabPage->ActivateColumnControl();
     219                 :          0 : }
     220                 :            : 
     221                 :          0 : SwColumnDlg::~SwColumnDlg()
     222                 :            : {
     223                 :          0 :     delete pTabPage;
     224                 :          0 :     delete pPageSet;
     225                 :          0 :     delete pSectionSet;
     226                 :          0 :     delete pSelectionSet;
     227                 :          0 : }
     228                 :            : 
     229                 :          0 : IMPL_LINK(SwColumnDlg, ObjectHdl, ListBox*, pBox)
     230                 :            : {
     231                 :          0 :     SfxItemSet* pSet = 0;
     232                 :          0 :     switch(nOldSelection)
     233                 :            :     {
     234                 :            :         case LISTBOX_SELECTION  :
     235                 :          0 :             pSet = pSelectionSet;
     236                 :          0 :         break;
     237                 :            :         case LISTBOX_SECTION    :
     238                 :          0 :             pSet = pSectionSet;
     239                 :          0 :             bSectionChanged = sal_True;
     240                 :          0 :         break;
     241                 :            :         case LISTBOX_SECTIONS   :
     242                 :          0 :             pSet = pSectionSet;
     243                 :          0 :             bSelSectionChanged = sal_True;
     244                 :          0 :         break;
     245                 :            :         case LISTBOX_PAGE       :
     246                 :          0 :             pSet = pPageSet;
     247                 :          0 :             bPageChanged = sal_True;
     248                 :          0 :         break;
     249                 :            :         case LISTBOX_FRAME:
     250                 :          0 :             pSet = pFrameSet;
     251                 :          0 :             bFrameChanged = sal_True;
     252                 :          0 :         break;
     253                 :            :     }
     254                 :          0 :     if(pBox)
     255                 :            :     {
     256                 :          0 :         pTabPage->FillItemSet(*pSet);
     257                 :            :     }
     258                 :          0 :     nOldSelection = (long)aApplyToLB.GetEntryData(aApplyToLB.GetSelectEntryPos());
     259                 :          0 :     long nWidth = nSelectionWidth;
     260                 :          0 :     switch(nOldSelection)
     261                 :            :     {
     262                 :            :         case LISTBOX_SELECTION  :
     263                 :          0 :             pSet = pSelectionSet;
     264                 :          0 :             if( pSelectionSet )
     265                 :          0 :                 pSet->Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth, nWidth));
     266                 :          0 :         break;
     267                 :            :         case LISTBOX_SECTION    :
     268                 :            :         case LISTBOX_SECTIONS   :
     269                 :          0 :             pSet = pSectionSet;
     270                 :          0 :             pSet->Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth, nWidth));
     271                 :          0 :         break;
     272                 :            :         case LISTBOX_PAGE       :
     273                 :          0 :             nWidth = nPageWidth;
     274                 :          0 :             pSet = pPageSet;
     275                 :          0 :             pSet->Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth, nWidth));
     276                 :          0 :         break;
     277                 :            :         case LISTBOX_FRAME:
     278                 :          0 :             pSet = pFrameSet;
     279                 :          0 :         break;
     280                 :            :     }
     281                 :            : 
     282                 :          0 :     sal_Bool bIsSection = pSet == pSectionSet || pSet == pSelectionSet;
     283                 :          0 :     pTabPage->ShowBalance(bIsSection);
     284                 :          0 :     pTabPage->SetInSection(bIsSection);
     285                 :          0 :     pTabPage->SetFrmMode(sal_True);
     286                 :          0 :     pTabPage->SetPageWidth(nWidth);
     287                 :          0 :     if( pSet )
     288                 :          0 :         pTabPage->Reset(*pSet);
     289                 :          0 :     return 0;
     290                 :            : }
     291                 :            : 
     292                 :          0 : IMPL_LINK_NOARG(SwColumnDlg, OkHdl)
     293                 :            : {
     294                 :            :     // evaluate current selection
     295                 :          0 :     SfxItemSet* pSet = 0;
     296                 :          0 :     switch(nOldSelection)
     297                 :            :     {
     298                 :            :         case LISTBOX_SELECTION  :
     299                 :          0 :             pSet = pSelectionSet;
     300                 :          0 :         break;
     301                 :            :         case LISTBOX_SECTION    :
     302                 :          0 :             pSet = pSectionSet;
     303                 :          0 :             bSectionChanged = sal_True;
     304                 :          0 :         break;
     305                 :            :         case LISTBOX_SECTIONS   :
     306                 :          0 :             pSet = pSectionSet;
     307                 :          0 :             bSelSectionChanged = sal_True;
     308                 :          0 :         break;
     309                 :            :         case LISTBOX_PAGE       :
     310                 :          0 :             pSet = pPageSet;
     311                 :          0 :             bPageChanged = sal_True;
     312                 :          0 :         break;
     313                 :            :         case LISTBOX_FRAME:
     314                 :          0 :             pSet = pFrameSet;
     315                 :          0 :             bFrameChanged = sal_True;
     316                 :          0 :         break;
     317                 :            :     }
     318                 :          0 :     pTabPage->FillItemSet(*pSet);
     319                 :            : 
     320                 :          0 :     if(pSelectionSet && SFX_ITEM_SET == pSelectionSet->GetItemState(RES_COL))
     321                 :            :     {
     322                 :            :         //insert region with columns
     323                 :          0 :         const SwFmtCol& rColItem = (const SwFmtCol&)pSelectionSet->Get(RES_COL);
     324                 :            :         //only if there actually are columns!
     325                 :          0 :         if(rColItem.GetNumCols() > 1)
     326                 :          0 :             rWrtShell.GetView().GetViewFrame()->GetDispatcher()->Execute(
     327                 :          0 :                 FN_INSERT_REGION, SFX_CALLMODE_ASYNCHRON, *pSelectionSet );
     328                 :            :     }
     329                 :            : 
     330                 :          0 :     if(pSectionSet && pSectionSet->Count() && bSectionChanged )
     331                 :            :     {
     332                 :          0 :         const SwSection* pCurrSection = rWrtShell.GetCurrSection();
     333                 :          0 :         const SwSectionFmt* pFmt = pCurrSection->GetFmt();
     334                 :          0 :         sal_uInt16 nNewPos = rWrtShell.GetSectionFmtPos( *pFmt );
     335                 :          0 :         SwSectionData aData(*pCurrSection);
     336                 :          0 :         rWrtShell.UpdateSection( nNewPos, aData, pSectionSet );
     337                 :            :     }
     338                 :            : 
     339                 :          0 :     if(pSectionSet && pSectionSet->Count() && bSelSectionChanged )
     340                 :            :     {
     341                 :          0 :         rWrtShell.SetSectionAttr( *pSectionSet );
     342                 :            :     }
     343                 :            : 
     344                 :          0 :     if(pPageSet && SFX_ITEM_SET == pPageSet->GetItemState(RES_COL) && bPageChanged)
     345                 :            :     {
     346                 :            :         // deterine current PageDescriptor and fill the Set with it
     347                 :          0 :         const sal_uInt16 nCurIdx = rWrtShell.GetCurPageDesc();
     348                 :          0 :         SwPageDesc aPageDesc(rWrtShell.GetPageDesc(nCurIdx));
     349                 :          0 :         SwFrmFmt &rFmt = aPageDesc.GetMaster();
     350                 :          0 :         rFmt.SetFmtAttr(pPageSet->Get(RES_COL));
     351                 :          0 :         rWrtShell.ChgPageDesc(nCurIdx, aPageDesc);
     352                 :            :     }
     353                 :          0 :     if(pFrameSet && SFX_ITEM_SET == pFrameSet->GetItemState(RES_COL) && bFrameChanged)
     354                 :            :     {
     355                 :          0 :         SfxItemSet aTmp(*pFrameSet->GetPool(), RES_COL, RES_COL);
     356                 :          0 :         aTmp.Put(*pFrameSet);
     357                 :          0 :         rWrtShell.StartAction();
     358                 :          0 :         rWrtShell.Push();
     359                 :          0 :         rWrtShell.SetFlyFrmAttr( aTmp );
     360                 :            :         // undo the frame selction again
     361                 :          0 :         if(rWrtShell.IsFrmSelected())
     362                 :            :         {
     363                 :          0 :             rWrtShell.UnSelectFrm();
     364                 :          0 :             rWrtShell.LeaveSelFrmMode();
     365                 :            :         }
     366                 :          0 :         rWrtShell.Pop();
     367                 :          0 :         rWrtShell.EndAction();
     368                 :            :     }
     369                 :          0 :     EndDialog(RET_OK);
     370                 :          0 :     return 0;
     371                 :            : }
     372                 :            : 
     373                 :            : #if OSL_DEBUG_LEVEL < 2
     374                 :            : inline
     375                 :            : #endif
     376                 :          0 : sal_uInt16 GetMaxWidth( SwColMgr* pColMgr, sal_uInt16 nCols )
     377                 :            : {
     378                 :          0 :     sal_uInt16 nMax = pColMgr->GetActualSize();
     379                 :          0 :     if( --nCols )
     380                 :          0 :         nMax -= pColMgr->GetGutterWidth() * nCols;
     381                 :          0 :     return nMax;
     382                 :            : }
     383                 :            : 
     384                 :            : static sal_uInt16 aPageRg[] = {
     385                 :            :     RES_COL, RES_COL,
     386                 :            :     0
     387                 :            : };
     388                 :            : 
     389                 :            : DBG_NAME(columnhdl)
     390                 :            : 
     391                 :          0 : void SwColumnPage::ResetColWidth()
     392                 :            : {
     393                 :          0 :     if( nCols )
     394                 :            :     {
     395                 :          0 :         sal_uInt16 nWidth = GetMaxWidth( pColMgr, nCols );
     396                 :          0 :         nWidth = nWidth / nCols;
     397                 :            : 
     398                 :          0 :         for(sal_uInt16 i = 0; i < nCols; ++i)
     399                 :          0 :             nColWidth[i] = (long) nWidth;
     400                 :            :     }
     401                 :            : 
     402                 :          0 : }
     403                 :            : 
     404                 :            : /*--------------------------------------------------------------------
     405                 :            :     Description:    Now as TabPage
     406                 :            :  --------------------------------------------------------------------*/
     407                 :          0 : SwColumnPage::SwColumnPage(Window *pParent, const SfxItemSet &rSet)
     408                 :            : 
     409                 :            :     : SfxTabPage(pParent, SW_RES(TP_COLUMN), rSet),
     410                 :            : 
     411                 :            :     aFLGroup(this,          SW_RES(FL_COLUMNS )),
     412                 :            :     aClNrLbl(this,          SW_RES(FT_NUMBER  )),
     413                 :            :     aCLNrEdt(this,          SW_RES(ED_NUMBER  )),
     414                 :            :     aDefaultVS(this,        SW_RES(VS_DEFAULTS)),
     415                 :            :     aBalanceColsCB(this,    SW_RES(CB_BALANCECOLS)),
     416                 :            : 
     417                 :            :     aFLLayout(this,         SW_RES(FL_LAYOUT)),
     418                 :            :     aBtnUp(this,            SW_RES(BTN_DOWN)),
     419                 :            :     aColumnFT(this,         SW_RES(FT_COLUMN)),
     420                 :            :     aWidthFT(this,          SW_RES(FT_WIDTH)),
     421                 :            :     aDistFT(this,           SW_RES(FT_DIST)),
     422                 :            :     aLbl1(this,             SW_RES(FT_1)),
     423                 :            :     aEd1(this,              SW_RES(ED_1)),
     424                 :            :     aDistEd1(this,          SW_RES(ED_DIST1)),
     425                 :            :     aLbl2(this,             SW_RES(FT_2)),
     426                 :            :     aEd2(this,              SW_RES(ED_2)),
     427                 :            :     aDistEd2(this,          SW_RES(ED_DIST2)),
     428                 :            :     aLbl3(this,             SW_RES(FT_3)),
     429                 :            :     aEd3(this,              SW_RES(ED_3)),
     430                 :            :     aBtnDown(this,          SW_RES(BTN_UP)),
     431                 :            :     aAutoWidthBox(this,     SW_RES(CB_AUTO_WIDTH)),
     432                 :            : 
     433                 :            :     aFLLineType(this,       SW_RES(FL_LINETYPE)),
     434                 :            :     aLineTypeLbl(this,      SW_RES(FT_STYLE)),
     435                 :            :     aLineTypeDLB(this,      SW_RES(LB_STYLE)),
     436                 :            :     aLineWidthLbl(this,     SW_RES(FT_LINEWIDTH)),
     437                 :            :     aLineWidthEdit(this,    SW_RES(ED_LINEWIDTH)),
     438                 :            :     aLineColorLbl(this,     SW_RES(FT_COLOR)),
     439                 :            :     aLineColorDLB(this,     SW_RES(LB_COLOR)),
     440                 :            :     aLineHeightLbl(this,    SW_RES(FT_HEIGHT)),
     441                 :            :     aLineHeightEdit(this,   SW_RES(ED_HEIGHT)),
     442                 :            :     aLinePosLbl(this,       SW_RES(FT_POSITION)),
     443                 :            :     aLinePosDLB(this,       SW_RES(LB_POSITION)),
     444                 :            : 
     445                 :            :     aTextDirectionFT( this,  SW_RES( FT_TEXTDIRECTION )),
     446                 :            :     aTextDirectionLB( this,  SW_RES( LB_TEXTDIRECTION )),
     447                 :            : 
     448                 :            :     aPgeExampleWN(this,     SW_RES(WN_BSP)),
     449                 :            :     aFrmExampleWN(this,     SW_RES(WN_BSP)),
     450                 :            : 
     451                 :            :     pColMgr(0),
     452                 :            : 
     453                 :            :     nFirstVis(0),
     454                 :            :     nMinWidth(MINLAY),
     455                 :            :     pModifiedField(0),
     456                 :            :     bFormat(sal_False),
     457                 :            :     bFrm(sal_False),
     458                 :            :     bHtmlMode(sal_False),
     459                 :          0 :     bLockUpdate(sal_False)
     460                 :            : {
     461                 :            :     long i;
     462                 :            : 
     463                 :          0 :     FreeResource();
     464                 :          0 :     SetExchangeSupport();
     465                 :            : 
     466                 :          0 :     aBtnDown.SetAccessibleRelationMemberOf(&aFLLayout);
     467                 :          0 :     aEd1.SetAccessibleRelationLabeledBy(&aWidthFT);
     468                 :          0 :     aEd2.SetAccessibleRelationLabeledBy(&aWidthFT);
     469                 :          0 :     aEd3.SetAccessibleRelationLabeledBy(&aWidthFT);
     470                 :          0 :     aDistEd1.SetAccessibleRelationLabeledBy(&aDistFT);
     471                 :          0 :     aDistEd2.SetAccessibleRelationLabeledBy(&aDistFT);
     472                 :          0 :     aBtnUp.SetAccessibleRelationLabeledBy(&aColumnFT);
     473                 :          0 :     aBtnDown.SetAccessibleRelationLabeledBy(&aColumnFT);
     474                 :            : 
     475                 :          0 :     aDefaultVS.SetHelpId(HID_COLUMN_VALUESET);
     476                 :          0 :     aDefaultVS.SetColCount( 5 );
     477                 :          0 :     aDefaultVS.SetStyle(  aDefaultVS.GetStyle()
     478                 :            :                             | WB_ITEMBORDER
     479                 :          0 :                             | WB_DOUBLEBORDER );
     480                 :            : 
     481                 :          0 :     for( i = 0; i < 5; i++)
     482                 :          0 :         aDefaultVS.InsertItem( i + 1, i );
     483                 :            : 
     484                 :          0 :     aDefaultVS.SetSelectHdl(LINK(this, SwColumnPage, SetDefaultsHdl));
     485                 :            : 
     486                 :            :     // announce Controls for additional region at the MoreButton
     487                 :          0 :     Link aCLNrLk = LINK(this, SwColumnPage, ColModify);
     488                 :          0 :     aCLNrEdt.SetLoseFocusHdl(aCLNrLk);
     489                 :          0 :     aCLNrEdt.SetUpHdl(aCLNrLk);
     490                 :          0 :     aCLNrEdt.SetDownHdl(aCLNrLk);
     491                 :          0 :     Link aLk = LINK(this, SwColumnPage, GapModify);
     492                 :          0 :     aDistEd1.SetUpHdl(aLk);
     493                 :          0 :     aDistEd1.SetDownHdl(aLk);
     494                 :          0 :     aDistEd1.SetLoseFocusHdl(aLk);
     495                 :          0 :     aDistEd2.SetUpHdl(aLk);
     496                 :          0 :     aDistEd2.SetDownHdl(aLk);
     497                 :          0 :     aDistEd2.SetLoseFocusHdl(aLk);
     498                 :            : 
     499                 :          0 :     aLk = LINK(this, SwColumnPage, EdModify);
     500                 :            : 
     501                 :          0 :     aEd1.SetUpHdl(aLk);
     502                 :          0 :     aEd1.SetDownHdl(aLk);
     503                 :          0 :     aEd1.SetLoseFocusHdl(aLk);
     504                 :            : 
     505                 :          0 :     aEd2.SetUpHdl(aLk);
     506                 :          0 :     aEd2.SetDownHdl(aLk);
     507                 :          0 :     aEd2.SetLoseFocusHdl(aLk);
     508                 :            : 
     509                 :          0 :     aEd3.SetUpHdl(aLk);
     510                 :          0 :     aEd3.SetDownHdl(aLk);
     511                 :          0 :     aEd3.SetLoseFocusHdl(aLk);
     512                 :            : 
     513                 :          0 :     aBtnUp.SetClickHdl(LINK(this, SwColumnPage, Up));
     514                 :          0 :     aBtnDown.SetClickHdl(LINK(this, SwColumnPage, Down));
     515                 :          0 :     aAutoWidthBox.SetClickHdl(LINK(this, SwColumnPage, AutoWidthHdl));
     516                 :            : 
     517                 :          0 :     aLk = LINK( this, SwColumnPage, UpdateColMgr );
     518                 :          0 :     aLineTypeDLB.SetSelectHdl( aLk );
     519                 :          0 :     aLineWidthEdit.SetModifyHdl( aLk );
     520                 :          0 :     aLineColorDLB.SetSelectHdl( aLk );
     521                 :          0 :     aLineHeightEdit.SetModifyHdl( aLk );
     522                 :          0 :     aLinePosDLB.SetSelectHdl( aLk );
     523                 :            : 
     524                 :            :     // Separator line
     525                 :          0 :     aLineTypeDLB.SetUnit( FUNIT_POINT );
     526                 :          0 :     aLineTypeDLB.SetSourceUnit( FUNIT_TWIP );
     527                 :            : 
     528                 :            :     // Fill the line styles listbox
     529                 :          0 :     aLineTypeDLB.SetNone( SVX_RESSTR( RID_SVXSTR_NONE ) );
     530                 :            :     aLineTypeDLB.InsertEntry(
     531                 :            :         ::editeng::SvxBorderLine::getWidthImpl(table::BorderLineStyle::SOLID),
     532                 :          0 :         table::BorderLineStyle::SOLID );
     533                 :            :     aLineTypeDLB.InsertEntry(
     534                 :            :         ::editeng::SvxBorderLine::getWidthImpl(table::BorderLineStyle::DOTTED),
     535                 :          0 :         table::BorderLineStyle::DOTTED );
     536                 :            :     aLineTypeDLB.InsertEntry(
     537                 :            :         ::editeng::SvxBorderLine::getWidthImpl(table::BorderLineStyle::DASHED),
     538                 :          0 :         table::BorderLineStyle::DASHED );
     539                 :            : 
     540                 :            :     long nLineWidth = static_cast<long>(MetricField::ConvertDoubleValue(
     541                 :            :             aLineWidthEdit.GetValue( ),
     542                 :          0 :             aLineWidthEdit.GetDecimalDigits( ),
     543                 :          0 :             aLineWidthEdit.GetUnit(), MAP_TWIP ));
     544                 :          0 :     aLineTypeDLB.SetWidth( nLineWidth );
     545                 :            : 
     546                 :            :     // Fill the color listbox
     547                 :          0 :     SfxObjectShell* pDocSh = SfxObjectShell::Current();
     548                 :          0 :     const SfxPoolItem*  pItem       = NULL;
     549                 :          0 :     XColorListRef pColorList;
     550                 :          0 :     if ( pDocSh )
     551                 :            :     {
     552                 :          0 :         pItem = pDocSh->GetItem( SID_COLOR_TABLE );
     553                 :          0 :         if ( pItem != NULL )
     554                 :          0 :             pColorList = ( (SvxColorListItem*)pItem )->GetColorList();
     555                 :            :     }
     556                 :            : 
     557                 :          0 :     if ( pColorList.is() )
     558                 :            :     {
     559                 :          0 :         aLineColorDLB.SetUpdateMode( sal_False );
     560                 :            : 
     561                 :          0 :         for ( i = 0; i < pColorList->Count(); ++i )
     562                 :            :         {
     563                 :          0 :             XColorEntry* pEntry = pColorList->GetColor(i);
     564                 :          0 :             aLineColorDLB.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
     565                 :            :         }
     566                 :          0 :         aLineColorDLB.SetUpdateMode( sal_True );
     567                 :            :     }
     568                 :          0 :     aLineColorDLB.SelectEntryPos( 0 );
     569                 :          0 : }
     570                 :            : 
     571                 :          0 : SwColumnPage::~SwColumnPage()
     572                 :            : {
     573                 :          0 :     delete pColMgr;
     574                 :          0 : }
     575                 :            : 
     576                 :          0 : void SwColumnPage::SetPageWidth(long nPageWidth)
     577                 :            : {
     578                 :          0 :     long nNewMaxWidth = static_cast< long >(aEd1.NormalizePercent(nPageWidth));
     579                 :            : 
     580                 :          0 :     aDistEd1.SetMax(nNewMaxWidth, FUNIT_TWIP);
     581                 :          0 :     aDistEd2.SetMax(nNewMaxWidth, FUNIT_TWIP);
     582                 :          0 :     aEd1.SetMax(nNewMaxWidth, FUNIT_TWIP);
     583                 :          0 :     aEd2.SetMax(nNewMaxWidth, FUNIT_TWIP);
     584                 :          0 :     aEd3.SetMax(nNewMaxWidth, FUNIT_TWIP);
     585                 :          0 : }
     586                 :            : 
     587                 :          0 : void SwColumnPage::Reset(const SfxItemSet &rSet)
     588                 :            : {
     589                 :          0 :     sal_uInt16 nHtmlMode = ::GetHtmlMode((const SwDocShell*)SfxObjectShell::Current());
     590                 :          0 :     if(nHtmlMode & HTMLMODE_ON)
     591                 :            :     {
     592                 :          0 :         bHtmlMode = sal_True;
     593                 :          0 :         aAutoWidthBox.Enable(sal_False);
     594                 :            :     }
     595                 :          0 :     FieldUnit aMetric = ::GetDfltMetric(bHtmlMode);
     596                 :          0 :     SetMetric(aEd1, aMetric);
     597                 :          0 :     SetMetric(aEd2, aMetric);
     598                 :          0 :     SetMetric(aEd3, aMetric);
     599                 :          0 :     SetMetric(aDistEd1, aMetric);
     600                 :          0 :     SetMetric(aDistEd2, aMetric);
     601                 :            : 
     602                 :          0 :     delete pColMgr;
     603                 :          0 :     pColMgr = new SwColMgr(rSet);
     604                 :          0 :     nCols   = pColMgr->GetCount() ;
     605                 :          0 :     aCLNrEdt.SetMax(Max((sal_uInt16)aCLNrEdt.GetMax(), (sal_uInt16)nCols));
     606                 :          0 :     aCLNrEdt.SetLast(Max(nCols,(sal_uInt16)aCLNrEdt.GetMax()));
     607                 :            : 
     608                 :          0 :     if(bFrm)
     609                 :            :     {
     610                 :          0 :         if(bFormat)                     // there is no size here
     611                 :          0 :             pColMgr->SetActualWidth(FRAME_FORMAT_WIDTH);
     612                 :            :         else
     613                 :            :         {
     614                 :          0 :             const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)rSet.Get(RES_FRM_SIZE);
     615                 :          0 :             const SvxBoxItem& rBox = (const SvxBoxItem&) rSet.Get(RES_BOX);
     616                 :          0 :             pColMgr->SetActualWidth((sal_uInt16)rSize.GetSize().Width() - rBox.GetDistance());
     617                 :            :         }
     618                 :            :     }
     619                 :          0 :     if(aBalanceColsCB.IsVisible())
     620                 :            :     {
     621                 :            :         const SfxPoolItem* pItem;
     622                 :          0 :         if( SFX_ITEM_SET == rSet.GetItemState( RES_COLUMNBALANCE, sal_False, &pItem ))
     623                 :          0 :             aBalanceColsCB.Check(!((const SwFmtNoBalancedColumns*)pItem)->GetValue());
     624                 :            :         else
     625                 :          0 :             aBalanceColsCB.Check( sal_True );
     626                 :            :     }
     627                 :            : 
     628                 :            :     //text direction
     629                 :          0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( RES_FRAMEDIR ) )
     630                 :            :     {
     631                 :          0 :         const SvxFrameDirectionItem& rItem = (const SvxFrameDirectionItem&)rSet.Get(RES_FRAMEDIR);
     632                 :          0 :         sal_uIntPtr nVal  = rItem.GetValue();
     633                 :          0 :         sal_uInt16 nPos = aTextDirectionLB.GetEntryPos( (void*) nVal );
     634                 :          0 :         aTextDirectionLB.SelectEntryPos( nPos );
     635                 :          0 :         aTextDirectionLB.SaveValue();
     636                 :            :     }
     637                 :            : 
     638                 :          0 :     Init();
     639                 :          0 :     ActivatePage( rSet );
     640                 :          0 : }
     641                 :            : 
     642                 :            : /*--------------------------------------------------------------------
     643                 :            :     Description:    create TabPage
     644                 :            :  --------------------------------------------------------------------*/
     645                 :          0 : SfxTabPage* SwColumnPage::Create(Window *pParent, const SfxItemSet &rSet)
     646                 :            : {
     647                 :          0 :     return new SwColumnPage(pParent, rSet);
     648                 :            : }
     649                 :            : 
     650                 :            : /*--------------------------------------------------------------------
     651                 :            :     Description:    stuff attributes into the Set when OK
     652                 :            :  --------------------------------------------------------------------*/
     653                 :          0 : sal_Bool SwColumnPage::FillItemSet(SfxItemSet &rSet)
     654                 :            : {
     655                 :          0 :     if(aCLNrEdt.HasChildPathFocus())
     656                 :          0 :         aCLNrEdt.GetDownHdl().Call(&aCLNrEdt);
     657                 :            :     // set in ItemSet setzen
     658                 :            :     // the current settings are already present
     659                 :            :     //
     660                 :            :     const SfxPoolItem* pOldItem;
     661                 :          0 :     const SwFmtCol& rCol = pColMgr->GetColumns();
     662                 :          0 :     if(0 == (pOldItem = GetOldItem( rSet, RES_COL )) ||
     663                 :          0 :                 rCol != *pOldItem )
     664                 :          0 :         rSet.Put(rCol);
     665                 :            : 
     666                 :          0 :     if(aBalanceColsCB.IsVisible() )
     667                 :            :     {
     668                 :          0 :         rSet.Put(SwFmtNoBalancedColumns(!aBalanceColsCB.IsChecked() ));
     669                 :            :     }
     670                 :            :     sal_uInt16 nPos;
     671                 :          0 :     if( aTextDirectionLB.IsVisible() &&
     672                 :          0 :         ( nPos = aTextDirectionLB.GetSelectEntryPos() ) !=
     673                 :          0 :                                             aTextDirectionLB.GetSavedValue() )
     674                 :            :     {
     675                 :          0 :         sal_uInt32 nDirection = (sal_uInt32)(sal_IntPtr)aTextDirectionLB.GetEntryData( nPos );
     676                 :          0 :         rSet.Put( SvxFrameDirectionItem( (SvxFrameDirection)nDirection, RES_FRAMEDIR));
     677                 :            :     }
     678                 :          0 :     return sal_True;
     679                 :            : }
     680                 :            : 
     681                 :            : /*--------------------------------------------------------------------
     682                 :            :     Description:    update ColumnManager
     683                 :            :  --------------------------------------------------------------------*/
     684                 :          0 : IMPL_LINK( SwColumnPage, UpdateColMgr, void *, /*pField*/ )
     685                 :            : {
     686                 :          0 :     long nGutterWidth = pColMgr->GetGutterWidth();
     687                 :          0 :     if(nCols > 1)
     688                 :            :     {
     689                 :            :             // Determine whether the most narrow column is too narrow
     690                 :            :             // for the adjusted column gap
     691                 :          0 :         long nMin = nColWidth[0];
     692                 :            :         sal_uInt16 i;
     693                 :            : 
     694                 :          0 :         for( i = 1; i < nCols; ++i)
     695                 :          0 :             nMin = Min(nMin, nColWidth[i]);
     696                 :            : 
     697                 :          0 :         sal_Bool bAutoWidth = aAutoWidthBox.IsChecked();
     698                 :          0 :         if(!bAutoWidth)
     699                 :            :         {
     700                 :          0 :             pColMgr->SetAutoWidth(sal_False);
     701                 :            :                 // when the user didn't allocate the whole width,
     702                 :            :                 // add the missing amount to the last column.
     703                 :          0 :             long nSum = 0;
     704                 :          0 :             for(i = 0; i < nCols; ++i)
     705                 :          0 :                 nSum += nColWidth[i];
     706                 :          0 :             nGutterWidth = 0;
     707                 :          0 :             for(i = 0; i < nCols - 1; ++i)
     708                 :          0 :                 nGutterWidth += nColDist[i];
     709                 :          0 :             nSum += nGutterWidth;
     710                 :            : 
     711                 :          0 :             long nMaxW = pColMgr->GetActualSize();
     712                 :            : 
     713                 :          0 :             if( nSum < nMaxW  )
     714                 :          0 :                 nColWidth[nCols - 1] += nMaxW - nSum;
     715                 :            : 
     716                 :          0 :             pColMgr->SetColWidth( 0, static_cast< sal_uInt16 >(nColWidth[0] + (sal_uInt16)nColDist[0]/2) );
     717                 :          0 :             for( i = 1; i < nCols-1; ++i )
     718                 :            :             {
     719                 :          0 :                 long nActDist = (nColDist[i] + nColDist[i - 1]) / 2;
     720                 :          0 :                 pColMgr->SetColWidth( i, (sal_uInt16)nColWidth[i] + (sal_uInt16)nActDist );
     721                 :            :             }
     722                 :          0 :             pColMgr->SetColWidth( nCols-1, static_cast< sal_uInt16 >(nColWidth[nCols-1] + nColDist[nCols -2]/2) );
     723                 :            : 
     724                 :            :         }
     725                 :            : 
     726                 :            :             // nothing is turned off
     727                 :          0 :         const sal_uInt16 nPos = aLineTypeDLB.GetSelectEntryPos();
     728                 :          0 :         sal_Bool bEnable = 0 != nPos;
     729                 :          0 :         aLineHeightEdit.Enable( bEnable );
     730                 :          0 :         aLineHeightLbl.Enable( bEnable );
     731                 :            :         long nLineWidth = static_cast<long>(MetricField::ConvertDoubleValue(
     732                 :            :                 aLineWidthEdit.GetValue( ),
     733                 :          0 :                 aLineWidthEdit.GetDecimalDigits( ),
     734                 :          0 :                 aLineWidthEdit.GetUnit(), MAP_TWIP ));
     735                 :          0 :         if( !bEnable )
     736                 :          0 :             pColMgr->SetNoLine();
     737                 :          0 :         else if( LISTBOX_ENTRY_NOTFOUND != nPos )
     738                 :            :         {
     739                 :            :             pColMgr->SetLineWidthAndColor(
     740                 :          0 :                     ::editeng::SvxBorderStyle( aLineTypeDLB.GetSelectEntryStyle( ) ),
     741                 :            :                     nLineWidth,
     742                 :          0 :                     aLineColorDLB.GetSelectEntryColor() );
     743                 :            :             pColMgr->SetAdjust( SwColLineAdj(
     744                 :          0 :                                     aLinePosDLB.GetSelectEntryPos() + 1) );
     745                 :          0 :             pColMgr->SetLineHeightPercent((short)aLineHeightEdit.GetValue());
     746                 :          0 :             bEnable = pColMgr->GetLineHeightPercent() != 100;
     747                 :            :         }
     748                 :          0 :         aLinePosLbl.Enable( bEnable );
     749                 :          0 :         aLinePosDLB.Enable( bEnable );
     750                 :            : 
     751                 :          0 :         aLineTypeDLB.SetWidth( nLineWidth );
     752                 :          0 :         aLineTypeDLB.SetColor( aLineColorDLB.GetSelectEntryColor( ) );
     753                 :            :     }
     754                 :            :     else
     755                 :            :     {
     756                 :          0 :         pColMgr->NoCols();
     757                 :          0 :         nCols = 0;
     758                 :            :     }
     759                 :            : 
     760                 :            :     //set maximum values
     761                 :            :     aCLNrEdt.SetMax(Max(1L,
     762                 :          0 :         Min(long(nMaxCols), long( pColMgr->GetActualSize() / (nGutterWidth + MINLAY)) )));
     763                 :          0 :     aCLNrEdt.SetLast(aCLNrEdt.GetMax());
     764                 :          0 :     aCLNrEdt.Reformat();
     765                 :            : 
     766                 :            :     //prompt example window
     767                 :          0 :     if(!bLockUpdate)
     768                 :            :     {
     769                 :          0 :         if(bFrm)
     770                 :            :         {
     771                 :          0 :             aFrmExampleWN.SetColumns( pColMgr->GetColumns() );
     772                 :          0 :             aFrmExampleWN.Invalidate();
     773                 :            :         }
     774                 :            :         else
     775                 :          0 :             aPgeExampleWN.Invalidate();
     776                 :            :     }
     777                 :            : 
     778                 :          0 :     return 0;
     779                 :            : }
     780                 :            : 
     781                 :            : /*------------------------------------------------------------------------
     782                 :            :  Description:   Initialisation
     783                 :            : ------------------------------------------------------------------------*/
     784                 :          0 : void SwColumnPage::Init()
     785                 :            : {
     786                 :          0 :     aCLNrEdt.SetValue(nCols);
     787                 :            : 
     788                 :          0 :     sal_Bool bAutoWidth = pColMgr->IsAutoWidth() || bHtmlMode;
     789                 :          0 :     aAutoWidthBox.Check( bAutoWidth );
     790                 :            : 
     791                 :          0 :     sal_Int32 nColumnWidthSum = 0;
     792                 :            :     // set the widths
     793                 :            :     sal_uInt16 i;
     794                 :          0 :     for(i = 0; i < nCols; ++i)
     795                 :            :     {
     796                 :          0 :         nColWidth[i] = pColMgr->GetColWidth(i);
     797                 :          0 :         nColumnWidthSum += nColWidth[i];
     798                 :          0 :         if(i < nCols - 1)
     799                 :          0 :             nColDist[i] = pColMgr->GetGutterWidth(i);
     800                 :            :     }
     801                 :            : 
     802                 :          0 :     if( 1 < nCols )
     803                 :            :     {
     804                 :            :         // #97495# make sure that the automatic column widht's are always equal
     805                 :          0 :         if(bAutoWidth)
     806                 :            :         {
     807                 :          0 :             nColumnWidthSum /= nCols;
     808                 :          0 :             for(i = 0; i < nCols; ++i)
     809                 :          0 :                 nColWidth[i] = nColumnWidthSum;
     810                 :            :         }
     811                 :          0 :         SwColLineAdj eAdj = pColMgr->GetAdjust();
     812                 :          0 :         if( COLADJ_NONE == eAdj )       // the dialog doesn't know a NONE!
     813                 :            :         {
     814                 :          0 :             eAdj = COLADJ_TOP;
     815                 :            :             //without Adjust no line type
     816                 :          0 :             aLineTypeDLB.SelectEntryPos( 0 );
     817                 :          0 :             aLineHeightEdit.SetValue( 100 );
     818                 :            :         }
     819                 :            :         else
     820                 :            :         {
     821                 :            :             // Need to multiply by 100 because of the 2 decimals
     822                 :          0 :             aLineWidthEdit.SetValue( pColMgr->GetLineWidth() * 100, FUNIT_TWIP );
     823                 :          0 :             aLineColorDLB.SelectEntry( pColMgr->GetLineColor() );
     824                 :          0 :             aLineTypeDLB.SelectEntry( pColMgr->GetLineStyle() );
     825                 :          0 :             aLineTypeDLB.SetWidth( pColMgr->GetLineWidth( ) );
     826                 :          0 :             aLineHeightEdit.SetValue( pColMgr->GetLineHeightPercent() );
     827                 :            : 
     828                 :            :         }
     829                 :          0 :         aLinePosDLB.SelectEntryPos( static_cast< sal_uInt16 >(eAdj - 1) );
     830                 :            :     }
     831                 :            :     else
     832                 :            :     {
     833                 :          0 :         aLinePosDLB.SelectEntryPos( 0 );
     834                 :          0 :         aLineTypeDLB.SelectEntryPos( 0 );
     835                 :          0 :         aLineHeightEdit.SetValue( 100 );
     836                 :            :     }
     837                 :            : 
     838                 :          0 :     UpdateCols();
     839                 :          0 :     Update();
     840                 :            : 
     841                 :            :         // set maximum number of columns
     842                 :            :         // values below 1 are not allowed
     843                 :            :     aCLNrEdt.SetMax(Max(1L,
     844                 :          0 :         Min(long(nMaxCols), long( pColMgr->GetActualSize() / nMinWidth) )));
     845                 :          0 : }
     846                 :            : 
     847                 :            : /*------------------------------------------------------------------------
     848                 :            :  Description:   The number of columns has changed -- here the controls for
     849                 :            :                 editing of the columns are en- or disabled according to the
     850                 :            :                 column number.
     851                 :            :                 In case there are more than nVisCols (=3) all Edit are being
     852                 :            :                 enabled and the buttons for scrolling too.
     853                 :            :                 Otherwise Edits are being enabled according to the column
     854                 :            :                 numbers; one column can not be edited.
     855                 :            : ------------------------------------------------------------------------*/
     856                 :          0 : void SwColumnPage::UpdateCols()
     857                 :            : {
     858                 :          0 :     sal_Bool bEnableBtns= sal_False;
     859                 :          0 :     sal_Bool bEnable12  = sal_False;
     860                 :          0 :     sal_Bool bEnable3   = sal_False;
     861                 :          0 :     const sal_Bool bEdit = !aAutoWidthBox.IsChecked();
     862                 :          0 :     if ( nCols > nVisCols )
     863                 :            :     {
     864                 :          0 :         bEnableBtns = sal_True && !bHtmlMode;
     865                 :          0 :         bEnable12 = bEnable3 = bEdit;
     866                 :            :     }
     867                 :          0 :     else if( bEdit )
     868                 :            :     {
     869                 :            :         // here are purposely hardly any breaks
     870                 :          0 :         switch(nCols)
     871                 :            :         {
     872                 :          0 :             case 3: bEnable3 = sal_True;
     873                 :          0 :             case 2: bEnable12= sal_True; break;
     874                 :            :             default: /* do nothing */;
     875                 :            :         }
     876                 :            :     }
     877                 :          0 :     aEd1.Enable( bEnable12 );
     878                 :          0 :     aDistEd1.Enable(nCols > 1);
     879                 :          0 :     aEd2.Enable( bEnable12 );
     880                 :          0 :     aDistEd2.Enable(bEnable3);
     881                 :          0 :     aEd3.Enable( bEnable3  );
     882                 :          0 :     aLbl1.Enable(bEnable12 );
     883                 :          0 :     aLbl2.Enable(bEnable12 );
     884                 :          0 :     aLbl3.Enable(bEnable3  );
     885                 :          0 :     aBtnUp.Enable( bEnableBtns );
     886                 :          0 :     aBtnDown.Enable( bEnableBtns );
     887                 :            : 
     888                 :          0 :     const sal_Bool bEnable = nCols > 1;
     889                 :          0 :     if( !bEnable )
     890                 :            :     {
     891                 :          0 :         aLinePosDLB.Enable( sal_False );
     892                 :          0 :         aLinePosLbl.Enable( sal_False );
     893                 :            :     }
     894                 :          0 :     aLineHeightEdit.Enable( bEnable );
     895                 :          0 :     aLineHeightLbl.Enable( bEnable );
     896                 :          0 :     aLineTypeDLB.Enable( bEnable );
     897                 :          0 :     aLineTypeLbl.Enable( bEnable );
     898                 :          0 :     aLineWidthLbl.Enable( bEnable );
     899                 :          0 :     aLineWidthEdit.Enable( bEnable );
     900                 :          0 :     aLineColorDLB.Enable( bEnable );
     901                 :          0 :     aLineColorLbl.Enable( bEnable );
     902                 :          0 :     aAutoWidthBox.Enable( bEnable && !bHtmlMode );
     903                 :          0 : }
     904                 :            : 
     905                 :          0 : void SwColumnPage::SetLabels( sal_uInt16 nVis )
     906                 :            : {
     907                 :          0 :     rtl::OUString sLbl( '~' );
     908                 :            : 
     909                 :          0 :     String sLbl2( String::CreateFromInt32( nVis + 1 ));
     910                 :          0 :     String tmp1(sLbl2);
     911                 :          0 :     sLbl2.Insert(sLbl, sLbl2.Len() - 1);
     912                 :          0 :     aLbl1.SetText(sLbl2);
     913                 :            : 
     914                 :          0 :     sLbl2 = String::CreateFromInt32( nVis + 2 );
     915                 :          0 :     String tmp2(sLbl2);
     916                 :          0 :     sLbl2.Insert(sLbl, sLbl2.Len() - 1);
     917                 :          0 :     aLbl2.SetText(sLbl2);
     918                 :            : 
     919                 :          0 :     sLbl2 = String::CreateFromInt32( nVis + 3 );
     920                 :          0 :     String tmp3(sLbl2);
     921                 :          0 :     sLbl2.Insert(sLbl, sLbl2.Len() - 1);
     922                 :          0 :     aLbl3.SetText(sLbl2);
     923                 :          0 :     String sColumnWidth = SW_RESSTR( STR_ACCESS_COLUMN_WIDTH ) ;
     924                 :          0 :     sColumnWidth.SearchAndReplaceAscii("%1", tmp1);
     925                 :          0 :     aEd1.SetAccessibleName(sColumnWidth);
     926                 :            : 
     927                 :          0 :     sColumnWidth = SW_RESSTR( STR_ACCESS_COLUMN_WIDTH ) ;
     928                 :          0 :     sColumnWidth.SearchAndReplaceAscii("%1", tmp2);
     929                 :          0 :     aEd2.SetAccessibleName(sColumnWidth);
     930                 :            : 
     931                 :          0 :     sColumnWidth = SW_RESSTR( STR_ACCESS_COLUMN_WIDTH ) ;
     932                 :          0 :     sColumnWidth.SearchAndReplaceAscii("%1", tmp3);
     933                 :          0 :     aEd3.SetAccessibleName(sColumnWidth);
     934                 :            : 
     935                 :          0 :     String sDist = SW_RESSTR( STR_ACCESS_PAGESETUP_SPACING ) ;
     936                 :          0 :     String sDist1 = sDist;
     937                 :          0 :     sDist1.SearchAndReplaceAscii("%1", tmp1);
     938                 :          0 :     sDist1.SearchAndReplaceAscii("%2", tmp2);
     939                 :          0 :     aDistEd1.SetAccessibleName(sDist1);
     940                 :            : 
     941                 :          0 :     String sDist2 = sDist;
     942                 :          0 :     sDist2.SearchAndReplaceAscii("%1", tmp2);
     943                 :          0 :     sDist2.SearchAndReplaceAscii("%2", tmp3);
     944                 :          0 :     aDistEd2.SetAccessibleName(sDist2);
     945                 :          0 : }
     946                 :            : 
     947                 :            : /*------------------------------------------------------------------------
     948                 :            :  Description:   Handler that is called at alteration of the column number.
     949                 :            :                 An alteration of the column number overwrites potential
     950                 :            :                 user's width settings; all columns are equally wide.
     951                 :            : ------------------------------------------------------------------------*/
     952                 :          0 : IMPL_LINK( SwColumnPage, ColModify, NumericField *, pNF )
     953                 :            : {
     954                 :          0 :     nCols = (sal_uInt16)aCLNrEdt.GetValue();
     955                 :            :     //#107890# the handler is also called from LoseFocus()
     956                 :            :     //then no change has been made and thus no action should be taken
     957                 :            :     // #i17816# changing the displayed types within the ValueSet
     958                 :            :     //from two columns to two columns with different settings doesn't invalidate the
     959                 :            :     // example windows in ::ColModify()
     960                 :          0 :     if(!pNF ||(pColMgr->GetCount() != nCols))
     961                 :            :     {
     962                 :          0 :         if(pNF)
     963                 :          0 :             aDefaultVS.SetNoSelection();
     964                 :          0 :         long nDist = static_cast< long >(aDistEd1.DenormalizePercent(aDistEd1.GetValue(FUNIT_TWIP)));
     965                 :          0 :         pColMgr->SetCount(nCols, (sal_uInt16)nDist);
     966                 :          0 :         for(sal_uInt16 i = 0; i < nCols; i++)
     967                 :          0 :             nColDist[i] = nDist;
     968                 :          0 :         nFirstVis = 0;
     969                 :          0 :         SetLabels( nFirstVis );
     970                 :          0 :         UpdateCols();
     971                 :          0 :         ResetColWidth();
     972                 :          0 :         Update();
     973                 :            :     }
     974                 :            : 
     975                 :          0 :     return 0;
     976                 :            : }
     977                 :            : 
     978                 :            : /*------------------------------------------------------------------------
     979                 :            :  Description:   Modify handler for an alteration of the column width or
     980                 :            :                 the column gap.
     981                 :            :                 These changes take effect time-displaced. With an
     982                 :            :                 alteration of the column width the automatic calculation
     983                 :            :                 of the column width is overruled; only an alteration
     984                 :            :                 of the column number leads back to that default.
     985                 :            : ------------------------------------------------------------------------*/
     986                 :          0 : IMPL_LINK( SwColumnPage, GapModify, PercentField *, pFld )
     987                 :            : {
     988                 :          0 :     long nActValue = static_cast< long >(pFld->DenormalizePercent(pFld->GetValue(FUNIT_TWIP)));
     989                 :          0 :     if(nCols < 2)
     990                 :          0 :         return 0;
     991                 :          0 :     if(aAutoWidthBox.IsChecked())
     992                 :            :     {
     993                 :          0 :         sal_uInt16 nMaxGap = pColMgr->GetActualSize() - nCols * MINLAY;
     994                 :            :         OSL_ENSURE(nCols, "Abstand kann nicht ohne Spalten eingestellt werden");
     995                 :          0 :         nMaxGap /= nCols - 1;
     996                 :          0 :         if(nActValue > nMaxGap)
     997                 :            :         {
     998                 :          0 :             nActValue = nMaxGap;
     999                 :          0 :             aDistEd1.SetPrcntValue(aDistEd1.NormalizePercent(nMaxGap), FUNIT_TWIP);
    1000                 :            :         }
    1001                 :          0 :         pColMgr->SetGutterWidth((sal_uInt16)nActValue);
    1002                 :          0 :         for(sal_uInt16 i = 0; i < nCols; i++)
    1003                 :          0 :             nColDist[i] = nActValue;
    1004                 :            : 
    1005                 :          0 :         ResetColWidth();
    1006                 :          0 :         UpdateCols();
    1007                 :            :     }
    1008                 :            :     else
    1009                 :            : 
    1010                 :            :     {
    1011                 :          0 :         sal_uInt16 nOffset = 0;
    1012                 :          0 :         if(pFld == &aDistEd2)
    1013                 :            :         {
    1014                 :          0 :             nOffset = 1;
    1015                 :            :         }
    1016                 :          0 :         long nDiff = nActValue - nColDist[nFirstVis + nOffset];
    1017                 :          0 :         if(nDiff)
    1018                 :            :         {
    1019                 :          0 :             long nLeft = nColWidth[nFirstVis + nOffset];
    1020                 :          0 :             long nRight = nColWidth[nFirstVis + nOffset + 1];
    1021                 :          0 :             if(nLeft + nRight + 2 * MINLAY < nDiff)
    1022                 :          0 :                 nDiff = nLeft + nRight - 2 * MINLAY;
    1023                 :          0 :             if(nDiff < nRight - MINLAY)
    1024                 :            :             {
    1025                 :          0 :                 nRight -= nDiff;
    1026                 :            :             }
    1027                 :            :             else
    1028                 :            :             {
    1029                 :          0 :                 long nTemp = nDiff - nRight + MINLAY;
    1030                 :          0 :                 nRight = MINLAY;
    1031                 :          0 :                 if(nLeft > nTemp - MINLAY)
    1032                 :            :                 {
    1033                 :          0 :                     nLeft -= nTemp;
    1034                 :          0 :                     nTemp = 0;
    1035                 :            :                 }
    1036                 :            :                 else
    1037                 :            :                 {
    1038                 :          0 :                     nTemp -= nLeft + MINLAY;
    1039                 :          0 :                     nLeft = MINLAY;
    1040                 :            :                 }
    1041                 :          0 :                 nDiff = nTemp;
    1042                 :            :             }
    1043                 :          0 :             nColWidth[nFirstVis + nOffset] = nLeft;
    1044                 :          0 :             nColWidth[nFirstVis + nOffset + 1] = nRight;
    1045                 :          0 :             nColDist[nFirstVis + nOffset] += nDiff;
    1046                 :            : 
    1047                 :          0 :             pColMgr->SetColWidth( nFirstVis + nOffset, sal_uInt16(nLeft) );
    1048                 :          0 :             pColMgr->SetColWidth( nFirstVis + nOffset + 1, sal_uInt16(nRight) );
    1049                 :          0 :             pColMgr->SetGutterWidth( sal_uInt16(nColDist[nFirstVis + nOffset]), nFirstVis + nOffset );
    1050                 :            :         }
    1051                 :            : 
    1052                 :            :     }
    1053                 :          0 :     Update();
    1054                 :          0 :     return 0;
    1055                 :            : }
    1056                 :            : 
    1057                 :          0 : IMPL_LINK( SwColumnPage, EdModify, PercentField *, pField )
    1058                 :            : {
    1059                 :          0 :     pModifiedField = pField;
    1060                 :          0 :     Timeout();
    1061                 :          0 :     return 0;
    1062                 :            : }
    1063                 :            : 
    1064                 :            : /*------------------------------------------------------------------------
    1065                 :            :  Description:   Handler behind the Checkbox for automatic width.
    1066                 :            :                 When the box is checked no expicit values for the column
    1067                 :            :                 width can be entered.
    1068                 :            : ------------------------------------------------------------------------*/
    1069                 :          0 : IMPL_LINK( SwColumnPage, AutoWidthHdl, CheckBox *, pBox )
    1070                 :            : {
    1071                 :          0 :     long nDist = static_cast< long >(aDistEd1.DenormalizePercent(aDistEd1.GetValue(FUNIT_TWIP)));
    1072                 :          0 :     pColMgr->SetCount(nCols, (sal_uInt16)nDist);
    1073                 :          0 :     for(sal_uInt16 i = 0; i < nCols; i++)
    1074                 :          0 :         nColDist[i] = nDist;
    1075                 :          0 :     if(pBox->IsChecked())
    1076                 :            :     {
    1077                 :          0 :         pColMgr->SetGutterWidth(sal_uInt16(nDist));
    1078                 :          0 :         ResetColWidth();
    1079                 :            :     }
    1080                 :          0 :     pColMgr->SetAutoWidth(pBox->IsChecked(), sal_uInt16(nDist));
    1081                 :          0 :     UpdateCols();
    1082                 :          0 :     Update();
    1083                 :          0 :     return 0;
    1084                 :            : }
    1085                 :            : 
    1086                 :            : /*------------------------------------------------------------------------
    1087                 :            :  Description:   scroll up the contents of the edits
    1088                 :            : ------------------------------------------------------------------------*/
    1089                 :          0 : IMPL_LINK_NOARG(SwColumnPage, Up)
    1090                 :            : {
    1091                 :          0 :     if( nFirstVis )
    1092                 :            :     {
    1093                 :          0 :         --nFirstVis;
    1094                 :          0 :         SetLabels( nFirstVis );
    1095                 :          0 :         Update();
    1096                 :            :     }
    1097                 :          0 :     return 0;
    1098                 :            : }
    1099                 :            : 
    1100                 :            : /*------------------------------------------------------------------------
    1101                 :            :  Description:   scroll down the contents of the edits.
    1102                 :            : ------------------------------------------------------------------------*/
    1103                 :          0 : IMPL_LINK_NOARG(SwColumnPage, Down)
    1104                 :            : {
    1105                 :          0 :     if( nFirstVis + nVisCols < nCols )
    1106                 :            :     {
    1107                 :          0 :         ++nFirstVis;
    1108                 :          0 :         SetLabels( nFirstVis );
    1109                 :          0 :         Update();
    1110                 :            :     }
    1111                 :          0 :     return 0;
    1112                 :            : }
    1113                 :            : 
    1114                 :            : /*------------------------------------------------------------------------
    1115                 :            :  Description:   relict from ancient times - now directly without time
    1116                 :            :                 handler; triggered by an alteration of the column width
    1117                 :            :                 or the column gap.
    1118                 :            : ------------------------------------------------------------------------*/
    1119                 :          0 : void SwColumnPage::Timeout()
    1120                 :            : {
    1121                 :            :     DBG_PROFSTART(columnhdl) ;
    1122                 :          0 :     if(pModifiedField)
    1123                 :            :     {
    1124                 :            :             // find the changed column
    1125                 :          0 :         sal_uInt16 nChanged = nFirstVis;
    1126                 :          0 :         if(pModifiedField == &aEd2)
    1127                 :          0 :             ++nChanged;
    1128                 :          0 :         else if(pModifiedField == &aEd3)
    1129                 :          0 :             nChanged += 2;
    1130                 :            : 
    1131                 :            :         long nNewWidth = (sal_uInt16)
    1132                 :          0 :             pModifiedField->DenormalizePercent(pModifiedField->GetValue(FUNIT_TWIP));
    1133                 :          0 :         long nDiff = nNewWidth - nColWidth[nChanged];
    1134                 :            : 
    1135                 :            :         // when it's the last column
    1136                 :          0 :         if(nChanged == nCols - 1)
    1137                 :            :         {
    1138                 :          0 :             nColWidth[0] -= nDiff;
    1139                 :          0 :             if(nColWidth[0] < (long)nMinWidth)
    1140                 :            :             {
    1141                 :          0 :                 nNewWidth -= nMinWidth - nColWidth[0];
    1142                 :          0 :                 nColWidth[0] = nMinWidth;
    1143                 :            :             }
    1144                 :            : 
    1145                 :            :         }
    1146                 :          0 :         else if(nDiff)
    1147                 :            :         {
    1148                 :          0 :             nColWidth[nChanged + 1] -= nDiff;
    1149                 :          0 :             if(nColWidth[nChanged + 1] < (long) nMinWidth)
    1150                 :            :             {
    1151                 :          0 :                 nNewWidth -= nMinWidth - nColWidth[nChanged + 1];
    1152                 :          0 :                 nColWidth[nChanged + 1] = nMinWidth;
    1153                 :            :             }
    1154                 :            :         }
    1155                 :          0 :         nColWidth[nChanged] = nNewWidth;
    1156                 :          0 :         pModifiedField = 0;
    1157                 :            :     }
    1158                 :          0 :     Update();
    1159                 :            :     DBG_PROFSTOP(columnhdl) ;
    1160                 :          0 : }
    1161                 :            : 
    1162                 :            : /*------------------------------------------------------------------------
    1163                 :            :  Description:   Update the view
    1164                 :            : ------------------------------------------------------------------------*/
    1165                 :          0 : void SwColumnPage::Update()
    1166                 :            : {
    1167                 :          0 :     aBalanceColsCB.Enable(nCols > 1);
    1168                 :          0 :     if(nCols >= 2)
    1169                 :            :     {
    1170                 :          0 :         aEd1.SetPrcntValue(aEd1.NormalizePercent(nColWidth[nFirstVis]), FUNIT_TWIP);
    1171                 :          0 :         aDistEd1.SetPrcntValue(aDistEd1.NormalizePercent(nColDist[nFirstVis]), FUNIT_TWIP);
    1172                 :          0 :         aEd2.SetPrcntValue(aEd2.NormalizePercent(nColWidth[nFirstVis + 1]), FUNIT_TWIP);
    1173                 :          0 :         if(nCols >= 3)
    1174                 :            :         {
    1175                 :          0 :             aDistEd2.SetPrcntValue(aDistEd2.NormalizePercent(nColDist[nFirstVis + 1]), FUNIT_TWIP);
    1176                 :          0 :             aEd3.SetPrcntValue(aEd3.NormalizePercent(nColWidth[nFirstVis + 2]), FUNIT_TWIP);
    1177                 :            :         }
    1178                 :            :         else
    1179                 :            :         {
    1180                 :          0 :             aEd3.SetText(aEmptyStr);
    1181                 :          0 :             aDistEd2.SetText(aEmptyStr);
    1182                 :            :         }
    1183                 :            :     }
    1184                 :            :     else
    1185                 :            :     {
    1186                 :          0 :         aEd1.SetText(aEmptyStr);
    1187                 :          0 :         aEd2.SetText(aEmptyStr);
    1188                 :          0 :         aEd3.SetText(aEmptyStr);
    1189                 :          0 :         aDistEd1.SetText(aEmptyStr);
    1190                 :          0 :         aDistEd2.SetText(aEmptyStr);
    1191                 :            :     }
    1192                 :          0 :     UpdateColMgr(0);
    1193                 :          0 : }
    1194                 :            : 
    1195                 :            : /*--------------------------------------------------------------------
    1196                 :            :     Description:    Update Bsp
    1197                 :            :  --------------------------------------------------------------------*/
    1198                 :          0 : void SwColumnPage::ActivatePage(const SfxItemSet& rSet)
    1199                 :            : {
    1200                 :          0 :     if(!bFrm)
    1201                 :            :     {
    1202                 :          0 :         if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_SIZE ))
    1203                 :            :         {
    1204                 :            :             const SvxSizeItem& rSize = (const SvxSizeItem&)rSet.Get(
    1205                 :          0 :                                                 SID_ATTR_PAGE_SIZE);
    1206                 :            :             const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)rSet.Get(
    1207                 :          0 :                                                                 RES_LR_SPACE );
    1208                 :          0 :             const SvxBoxItem& rBox = (const SvxBoxItem&) rSet.Get(RES_BOX);
    1209                 :          0 :             sal_uInt16 nActWidth = static_cast< sal_uInt16 >(rSize.GetSize().Width()
    1210                 :          0 :                             - rLRSpace.GetLeft() - rLRSpace.GetRight() - rBox.GetDistance());
    1211                 :            : 
    1212                 :          0 :             if( pColMgr->GetActualSize() != nActWidth)
    1213                 :            :             {
    1214                 :          0 :                 pColMgr->SetActualWidth(nActWidth);
    1215                 :          0 :                 ColModify( 0 );
    1216                 :          0 :                 UpdateColMgr( 0 );
    1217                 :            :             }
    1218                 :            :         }
    1219                 :          0 :         aFrmExampleWN.Hide();
    1220                 :          0 :         aPgeExampleWN.UpdateExample( rSet, pColMgr );
    1221                 :          0 :         aPgeExampleWN.Show();
    1222                 :            : 
    1223                 :            :     }
    1224                 :            :     else
    1225                 :            :     {
    1226                 :          0 :         aPgeExampleWN.Hide();
    1227                 :          0 :         aFrmExampleWN.Show();
    1228                 :            : 
    1229                 :            :         // Size
    1230                 :          0 :         const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)rSet.Get(RES_FRM_SIZE);
    1231                 :          0 :         const SvxBoxItem& rBox = (const SvxBoxItem&) rSet.Get(RES_BOX);
    1232                 :            : 
    1233                 :          0 :         long nDistance = rBox.GetDistance();
    1234                 :          0 :         const sal_uInt16 nTotalWish = bFormat ? FRAME_FORMAT_WIDTH : sal_uInt16(rSize.GetWidth() - 2 * nDistance);
    1235                 :            : 
    1236                 :            :         // set maximum values of column width
    1237                 :          0 :         SetPageWidth(nTotalWish);
    1238                 :            : 
    1239                 :          0 :         if(pColMgr->GetActualSize() != nTotalWish)
    1240                 :            :         {
    1241                 :          0 :             pColMgr->SetActualWidth(nTotalWish);
    1242                 :          0 :             Init();
    1243                 :            :         }
    1244                 :            :         sal_Bool bPercent;
    1245                 :            :         // only relative data in frame format
    1246                 :          0 :         if ( bFormat || (rSize.GetWidthPercent() && rSize.GetWidthPercent() != 0xff) )
    1247                 :            :         {
    1248                 :            :             // set value for 100%
    1249                 :          0 :             aEd1.SetRefValue(nTotalWish);
    1250                 :          0 :             aEd2.SetRefValue(nTotalWish);
    1251                 :          0 :             aEd3.SetRefValue(nTotalWish);
    1252                 :          0 :             aDistEd1.SetRefValue(nTotalWish);
    1253                 :          0 :             aDistEd2.SetRefValue(nTotalWish);
    1254                 :            : 
    1255                 :            :             // switch to %-view
    1256                 :          0 :             bPercent = sal_True;
    1257                 :            :         }
    1258                 :            :         else
    1259                 :          0 :             bPercent = sal_False;
    1260                 :            : 
    1261                 :          0 :         aEd1.ShowPercent(bPercent);
    1262                 :          0 :         aEd2.ShowPercent(bPercent);
    1263                 :          0 :         aEd3.ShowPercent(bPercent);
    1264                 :          0 :         aDistEd1.ShowPercent(bPercent);
    1265                 :          0 :         aDistEd2.ShowPercent(bPercent);
    1266                 :          0 :         aDistEd1.MetricField::SetMin(0);
    1267                 :          0 :         aDistEd2.MetricField::SetMin(0);
    1268                 :            :     }
    1269                 :          0 :     Update();
    1270                 :          0 : }
    1271                 :            : 
    1272                 :          0 : int SwColumnPage::DeactivatePage(SfxItemSet *_pSet)
    1273                 :            : {
    1274                 :          0 :     if(_pSet)
    1275                 :          0 :         FillItemSet(*_pSet);
    1276                 :            : 
    1277                 :          0 :     return sal_True;
    1278                 :            : }
    1279                 :            : 
    1280                 :          0 : sal_uInt16* SwColumnPage::GetRanges()
    1281                 :            : {
    1282                 :          0 :     return aPageRg;
    1283                 :            : }
    1284                 :            : 
    1285                 :          0 : IMPL_LINK( SwColumnPage, SetDefaultsHdl, ValueSet *, pVS )
    1286                 :            : {
    1287                 :          0 :     sal_uInt16 nItem = pVS->GetSelectItemId();
    1288                 :          0 :     if( nItem < 4 )
    1289                 :            :     {
    1290                 :          0 :         aCLNrEdt.SetValue( nItem );
    1291                 :          0 :         aAutoWidthBox.Check();
    1292                 :          0 :         aDistEd1.SetPrcntValue(0);
    1293                 :          0 :         ColModify(0);
    1294                 :            :     }
    1295                 :            :     else
    1296                 :            :     {
    1297                 :          0 :         bLockUpdate = sal_True;
    1298                 :          0 :         aCLNrEdt.SetValue( 2 );
    1299                 :          0 :         aAutoWidthBox.Check(sal_False);
    1300                 :          0 :         aDistEd1.SetPrcntValue(0);
    1301                 :          0 :         ColModify(0);
    1302                 :            :         // now set the width ratio to 2 : 1 or 1 : 2 respectively
    1303                 :          0 :         sal_uInt16 nSmall = pColMgr->GetActualSize()  / 3;
    1304                 :          0 :         if(nItem == 4)
    1305                 :            :         {
    1306                 :          0 :             aEd2.SetPrcntValue(aEd2.NormalizePercent(long(nSmall)), FUNIT_TWIP);
    1307                 :          0 :             pModifiedField = &aEd2;
    1308                 :            :         }
    1309                 :            :         else
    1310                 :            :         {
    1311                 :          0 :             aEd1.SetPrcntValue(aEd1.NormalizePercent(long(nSmall)), FUNIT_TWIP);
    1312                 :          0 :             pModifiedField = &aEd1;
    1313                 :            :         }
    1314                 :          0 :         bLockUpdate = sal_False;
    1315                 :          0 :         Timeout();
    1316                 :            : 
    1317                 :            :     }
    1318                 :          0 :     return 0;
    1319                 :            : }
    1320                 :            : 
    1321                 :          0 : void SwColumnPage::SetFrmMode(sal_Bool bMod)
    1322                 :            : {
    1323                 :          0 :     bFrm = bMod;
    1324                 :          0 : }
    1325                 :            : 
    1326                 :          0 : void SwColumnPage::SetInSection(sal_Bool bSet)
    1327                 :            : {
    1328                 :          0 :     if(!SW_MOD()->GetCTLOptions().IsCTLFontEnabled())
    1329                 :          0 :         return;
    1330                 :            : 
    1331                 :          0 :     aTextDirectionFT.Show(bSet);
    1332                 :          0 :     aTextDirectionLB.Show(bSet);
    1333                 :            : }
    1334                 :            : 
    1335                 :          0 : void ColumnValueSet::UserDraw( const UserDrawEvent& rUDEvt )
    1336                 :            : {
    1337                 :          0 :     OutputDevice*  pDev = rUDEvt.GetDevice();
    1338                 :          0 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
    1339                 :            : 
    1340                 :          0 :     Rectangle aRect = rUDEvt.GetRect();
    1341                 :          0 :     sal_uInt16  nItemId = rUDEvt.GetItemId();
    1342                 :          0 :     long nRectWidth = aRect.GetWidth();
    1343                 :          0 :     long nRectHeight = aRect.GetHeight();
    1344                 :            : 
    1345                 :          0 :     Point aBLPos = aRect.TopLeft();
    1346                 :          0 :     Color aFillColor(pDev->GetFillColor());
    1347                 :          0 :     Color aLineColor(pDev->GetLineColor());
    1348                 :          0 :     pDev->SetFillColor(rStyleSettings.GetFieldColor());
    1349                 :          0 :     pDev->SetLineColor(SwViewOption::GetFontColor());
    1350                 :            : 
    1351                 :          0 :     long nStep = Abs(Abs(nRectHeight * 95 /100) / 11);
    1352                 :          0 :     long nTop = (nRectHeight - 11 * nStep ) / 2;
    1353                 :          0 :     sal_uInt16 nCols = 0;
    1354                 :            :     long nStarts[3];
    1355                 :            :     long nEnds[3];
    1356                 :          0 :     nStarts[0] = nRectWidth * 10 / 100;
    1357                 :          0 :     switch( nItemId )
    1358                 :            :     {
    1359                 :            :         case 1:
    1360                 :          0 :             nEnds[0] = nRectWidth * 9 / 10;
    1361                 :          0 :             nCols = 1;
    1362                 :          0 :         break;
    1363                 :          0 :         case 2: nCols = 2;
    1364                 :          0 :             nEnds[0] = nRectWidth * 45 / 100;
    1365                 :          0 :             nStarts[1] = nEnds[0] + nStep;
    1366                 :          0 :             nEnds[1] = nRectWidth * 9 / 10;
    1367                 :          0 :         break;
    1368                 :          0 :         case 3: nCols = 3;
    1369                 :          0 :             nEnds[0]    = nRectWidth * 30 / 100;
    1370                 :          0 :             nStarts[1]  = nEnds[0] + nStep;
    1371                 :          0 :             nEnds[1]    = nRectWidth * 63 / 100;
    1372                 :          0 :             nStarts[2]  = nEnds[1] + nStep;
    1373                 :          0 :             nEnds[2]    = nRectWidth * 9 / 10;
    1374                 :          0 :         break;
    1375                 :          0 :         case 4: nCols = 2;
    1376                 :          0 :             nEnds[0] = nRectWidth * 63 / 100;
    1377                 :          0 :             nStarts[1] = nEnds[0] + nStep;
    1378                 :          0 :             nEnds[1] = nRectWidth * 9 / 10;
    1379                 :          0 :         break;
    1380                 :          0 :         case 5: nCols = 2;
    1381                 :          0 :             nEnds[0] = nRectWidth * 30 / 100;
    1382                 :          0 :             nStarts[1] = nEnds[0] + nStep;
    1383                 :          0 :             nEnds[1] = nRectWidth * 9 / 10;
    1384                 :          0 :         break;
    1385                 :            :     }
    1386                 :          0 :     for(sal_uInt16 j = 0; j < nCols; j++ )
    1387                 :            :     {
    1388                 :          0 :         Point aStart(aBLPos.X() + nStarts[j], 0);
    1389                 :          0 :         Point aEnd(aBLPos.X() + nEnds[j], 0);
    1390                 :          0 :         for( sal_uInt16 i = 0; i < 12; i ++)
    1391                 :            :         {
    1392                 :          0 :             aStart.Y() = aEnd.Y() = aBLPos.Y() + nTop + i * nStep;
    1393                 :          0 :             pDev->DrawLine(aStart, aEnd);
    1394                 :            :         }
    1395                 :            :     }
    1396                 :          0 :     pDev->SetFillColor(aFillColor);
    1397                 :          0 :     pDev->SetLineColor(aLineColor);
    1398                 :          0 : }
    1399                 :            : 
    1400                 :          0 : ColumnValueSet::~ColumnValueSet()
    1401                 :            : {
    1402                 :          0 : }
    1403                 :            : 
    1404                 :          0 : void ColumnValueSet::DataChanged( const DataChangedEvent& rDCEvt )
    1405                 :            : {
    1406                 :          0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
    1407                 :          0 :          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
    1408                 :            :     {
    1409                 :          0 :         Format();
    1410                 :            :     }
    1411                 :          0 :     ValueSet::DataChanged( rDCEvt );
    1412                 :          0 : }
    1413                 :            : 
    1414                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10