LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/cui/source/tabpages - border.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 529 0.0 %
Date: 2013-07-09 Functions: 0 38 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <sfx2/app.hxx>
      21             : #include <sfx2/objsh.hxx>
      22             : #include <sfx2/module.hxx>
      23             : #include <svx/dialogs.hrc>
      24             : #include <svx/dialmgr.hxx>
      25             : 
      26             : #include <cuires.hrc>
      27             : #include "border.hrc"
      28             : #include "helpid.hrc"
      29             : 
      30             : #include <svx/xtable.hxx>               // XColorList
      31             : #include <svx/drawitem.hxx>
      32             : #include <editeng/boxitem.hxx>
      33             : #include <editeng/shaditem.hxx>
      34             : #include "border.hxx"
      35             : #include <svx/dlgutil.hxx>
      36             : #include <dialmgr.hxx>
      37             : #include <sfx2/htmlmode.hxx>
      38             : #include <vcl/msgbox.hxx>
      39             : #include "svx/flagsdef.hxx"
      40             : #include <sfx2/request.hxx>
      41             : #include <svl/intitem.hxx>
      42             : #include <sfx2/itemconnect.hxx>
      43             : #include <sal/macros.h>
      44             : #include "borderconn.hxx"
      45             : 
      46             : using namespace ::editeng;
      47             : 
      48             : // -----------------------------------------------------------------------
      49             : 
      50             : /*
      51             :  * [Description:]
      52             :  * TabPage for setting the border attributes.
      53             :  * Needs
      54             :  *      a SvxShadowItem: shadow
      55             :  *      a SvxBoxItem:    lines left, right, top, bottom,
      56             :  *      a SvxBoxInfo:    lines vertical, horizontal, distance, flags
      57             :  *
      58             :  * Lines can have three conditions:
      59             :  *      1. Show     ( -> valid values )
      60             :  *      2. Hide     ( -> NULL-Pointer )
      61             :  *      3. DontCare ( -> special Valid-Flags in the InfoItem )
      62             :  */
      63             : 
      64             : // static ----------------------------------------------------------------
      65             : 
      66             : static sal_uInt16 pRanges[] =
      67             : {
      68             :     SID_ATTR_BORDER_INNER,      SID_ATTR_BORDER_SHADOW,
      69             :     SID_ATTR_ALIGN_MARGIN,      SID_ATTR_ALIGN_MARGIN,
      70             :     SID_ATTR_BORDER_CONNECT,    SID_ATTR_BORDER_CONNECT,
      71             :     SID_SW_COLLAPSING_BORDERS,  SID_SW_COLLAPSING_BORDERS,
      72             :     SID_ATTR_BORDER_DIAG_TLBR,  SID_ATTR_BORDER_DIAG_BLTR,
      73             :     0
      74             : };
      75             : 
      76             : // -----------------------------------------------------------------------
      77           0 : static void lcl_SetDecimalDigitsTo1(MetricField& rField)
      78             : {
      79           0 :     sal_Int64 nMin = rField.Denormalize( rField.GetMin( FUNIT_TWIP ) );
      80           0 :     rField.SetDecimalDigits(1);
      81           0 :     rField.SetMin( rField.Normalize( nMin ), FUNIT_TWIP );
      82           0 : }
      83             : // -----------------------------------------------------------------------
      84             : 
      85           0 : SvxBorderTabPage::SvxBorderTabPage(Window* pParent, const SfxItemSet& rCoreAttrs)
      86             :     : SfxTabPage(pParent, "BorderPage", "cui/ui/borderpage.ui", rCoreAttrs)
      87             : 
      88             : ,
      89             : 
      90             : 
      91             : 
      92             : 
      93           0 :         aShadowImgLst( CUI_RES(IL_SDW_BITMAPS)),
      94           0 :         aBorderImgLst( CUI_RES(IL_PRE_BITMAPS)),
      95             :         nMinValue(0),
      96             :         nSWMode(0),
      97             :         mbHorEnabled( false ),
      98             :         mbVerEnabled( false ),
      99             :         mbTLBREnabled( false ),
     100             :         mbBLTREnabled( false ),
     101             :         mbUseMarginItem( false ),
     102           0 :         mbSync(true)
     103             : 
     104             : {
     105           0 :     get(m_pWndPresets, "presets");
     106           0 :     get(m_pUserDefFT, "userdefft");
     107           0 :     get(m_pFrameSel, "framesel");
     108           0 :     get(m_pLbLineStyle, "linestylelb");
     109           0 :     get(m_pLbLineColor, "linecolorlb");
     110           0 :     get(m_pLineWidthMF, "linewidthmf");
     111             : 
     112           0 :     get(m_pSpacingFrame, "spacing");
     113           0 :     get(m_pLeftFT, "leftft");
     114           0 :     get(m_pLeftMF, "leftmf");
     115           0 :     get(m_pRightFT, "rightft");
     116           0 :     get(m_pRightMF, "rightmf");
     117           0 :     get(m_pTopFT, "topft");
     118           0 :     get(m_pTopMF, "topmf");
     119           0 :     get(m_pBottomFT, "bottomft");
     120           0 :     get(m_pBottomMF, "bottommf");
     121           0 :     get(m_pSynchronizeCB, "sync");
     122             : 
     123           0 :     get(m_pShadowFrame, "shadow");
     124           0 :     get(m_pWndShadows, "shadows");
     125           0 :     get(m_pFtShadowSize, "distanceft");
     126           0 :     get(m_pEdShadowSize, "distancemf");
     127           0 :     get(m_pFtShadowColor, "shadowcolorft");
     128           0 :     get(m_pLbShadowColor, "shadowcolorlb");
     129             : 
     130           0 :     get(m_pPropertiesFrame, "properties");
     131           0 :     get(m_pMergeWithNextCB, "mergewithnext");
     132           0 :     get(m_pMergeAdjacentBordersCB, "mergeadjacent");
     133             : 
     134             :     // this page needs ExchangeSupport
     135           0 :     SetExchangeSupport();
     136             : 
     137             :     /*  Use SvxMarginItem instead of margins from SvxBoxItem, if present.
     138             :         ->  Remember this state in mbUseMarginItem, because other special handling
     139             :             is needed across various functions... */
     140           0 :     mbUseMarginItem = rCoreAttrs.GetItemState(GetWhich(SID_ATTR_ALIGN_MARGIN),sal_True) != SFX_ITEM_UNKNOWN;
     141             : 
     142             :     // set metric
     143           0 :     FieldUnit eFUnit = GetModuleFieldUnit( rCoreAttrs );
     144             : 
     145           0 :     if( mbUseMarginItem )
     146             :     {
     147             :         // copied from SvxAlignmentTabPage
     148           0 :         switch ( eFUnit )
     149             :         {
     150             :             //  #103396# the default value (1pt) can't be accurately represented in
     151             :             //  inches or pica with two decimals, so point is used instead.
     152             :             case FUNIT_PICA:
     153             :             case FUNIT_INCH:
     154             :             case FUNIT_FOOT:
     155             :             case FUNIT_MILE:
     156           0 :                 eFUnit = FUNIT_POINT;
     157           0 :                 break;
     158             : 
     159             :             case FUNIT_CM:
     160             :             case FUNIT_M:
     161             :             case FUNIT_KM:
     162           0 :                 eFUnit = FUNIT_MM;
     163           0 :                 break;
     164             :             default: ;//prevent warning
     165             :         }
     166             :     }
     167             :     else
     168             :     {
     169           0 :         switch ( eFUnit )
     170             :         {
     171             :             case FUNIT_M:
     172             :             case FUNIT_KM:
     173           0 :                 eFUnit = FUNIT_MM;
     174           0 :                 break;
     175             :             default: ; //prevent warning
     176             :         }
     177             :     }
     178             : 
     179           0 :     SetFieldUnit(*m_pEdShadowSize, eFUnit);
     180             : 
     181           0 :     sal_uInt16 nWhich = GetWhich( SID_ATTR_BORDER_INNER, sal_False );
     182           0 :     sal_Bool bIsDontCare = sal_True;
     183             : 
     184           0 :     if ( rCoreAttrs.GetItemState( nWhich, sal_True ) >= SFX_ITEM_AVAILABLE )
     185             :     {
     186             :         // paragraph or table
     187             :         const SvxBoxInfoItem* pBoxInfo =
     188           0 :             (const SvxBoxInfoItem*)&( rCoreAttrs.Get( nWhich ) );
     189             : 
     190           0 :         mbHorEnabled = pBoxInfo->IsHorEnabled();
     191           0 :         mbVerEnabled = pBoxInfo->IsVerEnabled();
     192           0 :         mbTLBREnabled = sfx::ItemWrapperHelper::IsKnownItem( rCoreAttrs, SID_ATTR_BORDER_DIAG_TLBR );
     193           0 :         mbBLTREnabled = sfx::ItemWrapperHelper::IsKnownItem( rCoreAttrs, SID_ATTR_BORDER_DIAG_BLTR );
     194             : 
     195           0 :         if(pBoxInfo->IsDist())
     196             :         {
     197           0 :             SetFieldUnit(*m_pLeftMF, eFUnit);
     198           0 :             SetFieldUnit(*m_pRightMF, eFUnit);
     199           0 :             SetFieldUnit(*m_pTopMF, eFUnit);
     200           0 :             SetFieldUnit(*m_pBottomMF, eFUnit);
     201           0 :             m_pSynchronizeCB->SetClickHdl(LINK(this, SvxBorderTabPage, SyncHdl_Impl));
     202           0 :             m_pLeftMF->SetModifyHdl(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
     203           0 :             m_pRightMF->SetModifyHdl(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
     204           0 :             m_pTopMF->SetModifyHdl(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
     205           0 :             m_pBottomMF->SetModifyHdl(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
     206             :         }
     207             :         else
     208             :         {
     209           0 :             m_pSpacingFrame->Hide();
     210             :         }
     211           0 :         bIsDontCare = !pBoxInfo->IsValid( VALID_DISABLE );
     212             :     }
     213           0 :     if(!mbUseMarginItem && eFUnit == FUNIT_MM && SFX_MAPUNIT_TWIP == rCoreAttrs.GetPool()->GetMetric( GetWhich( SID_ATTR_BORDER_INNER ) ))
     214             :     {
     215             :         //#i91548# changing the number of decimal digits changes the minimum values, too
     216           0 :         lcl_SetDecimalDigitsTo1(*m_pLeftMF);
     217           0 :         lcl_SetDecimalDigitsTo1(*m_pRightMF);
     218           0 :         lcl_SetDecimalDigitsTo1(*m_pTopMF);
     219           0 :         lcl_SetDecimalDigitsTo1(*m_pBottomMF);
     220           0 :         lcl_SetDecimalDigitsTo1(*m_pEdShadowSize);
     221             :     }
     222             : 
     223           0 :     svx::FrameSelFlags nFlags = svx::FRAMESEL_OUTER;
     224           0 :     if( mbHorEnabled )
     225           0 :         nFlags |= svx::FRAMESEL_INNER_HOR;
     226           0 :     if( mbVerEnabled )
     227           0 :         nFlags |= svx::FRAMESEL_INNER_VER;
     228           0 :     if( mbTLBREnabled )
     229           0 :         nFlags |= svx::FRAMESEL_DIAG_TLBR;
     230           0 :     if( mbBLTREnabled )
     231           0 :         nFlags |= svx::FRAMESEL_DIAG_BLTR;
     232           0 :     if( bIsDontCare )
     233           0 :         nFlags |= svx::FRAMESEL_DONTCARE;
     234           0 :     m_pFrameSel->Initialize( nFlags );
     235             : 
     236           0 :     m_pFrameSel->SetSelectHdl(LINK(this, SvxBorderTabPage, LinesChanged_Impl));
     237           0 :     m_pLbLineStyle->SetSelectHdl( LINK( this, SvxBorderTabPage, SelStyleHdl_Impl ) );
     238           0 :     m_pLbLineColor->SetSelectHdl( LINK( this, SvxBorderTabPage, SelColHdl_Impl ) );
     239           0 :     m_pLineWidthMF->SetModifyHdl( LINK( this, SvxBorderTabPage, ModifyWidthHdl_Impl ) );
     240           0 :     m_pLbShadowColor->SetSelectHdl( LINK( this, SvxBorderTabPage, SelColHdl_Impl ) );
     241           0 :     m_pWndPresets->SetSelectHdl( LINK( this, SvxBorderTabPage, SelPreHdl_Impl ) );
     242           0 :     m_pWndShadows->SetSelectHdl( LINK( this, SvxBorderTabPage, SelSdwHdl_Impl ) );
     243             : 
     244           0 :     FillValueSets();
     245           0 :     FillLineListBox_Impl();
     246             : 
     247             :     // fill ColorBox out of the XColorList
     248           0 :     SfxObjectShell*     pDocSh      = SfxObjectShell::Current();
     249           0 :     XColorListRef       pColorTable;
     250             : 
     251             :     DBG_ASSERT( pDocSh, "DocShell not found!" );
     252             : 
     253           0 :     if ( pDocSh )
     254             :     {
     255           0 :         const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE );
     256           0 :         if ( pItem != NULL )
     257           0 :             pColorTable = ( (SvxColorListItem*)pItem )->GetColorList();
     258             :     }
     259             : 
     260             :     DBG_ASSERT( pColorTable.is(), "ColorTable not found!" );
     261             : 
     262           0 :     if ( pColorTable.is() )
     263             :     {
     264             :         // filling the line color box
     265           0 :         m_pLbLineColor->SetUpdateMode( sal_False );
     266             : 
     267           0 :         for ( long i = 0; i < pColorTable->Count(); ++i )
     268             :         {
     269           0 :             XColorEntry* pEntry = pColorTable->GetColor(i);
     270           0 :             m_pLbLineColor->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
     271             :         }
     272           0 :         m_pLbLineColor->SetUpdateMode( sal_True );
     273             : 
     274           0 :         m_pLbShadowColor->CopyEntries(*m_pLbLineColor);
     275             :     }
     276             : 
     277             :     // connections
     278             : 
     279           0 :     bool bSupportsShadow = !SfxItemPool::IsSlot( GetWhich( SID_ATTR_BORDER_SHADOW ) );
     280           0 :     if( bSupportsShadow )
     281           0 :         AddItemConnection( svx::CreateShadowConnection( rCoreAttrs, *m_pWndShadows, *m_pEdShadowSize, *m_pLbShadowColor ) );
     282             :     else
     283           0 :         HideShadowControls();
     284             : 
     285           0 :     if( mbUseMarginItem )
     286           0 :         AddItemConnection( svx::CreateMarginConnection( rCoreAttrs, *m_pLeftMF, *m_pRightMF, *m_pTopMF, *m_pBottomMF ) );
     287           0 :     if( m_pFrameSel->IsBorderEnabled( svx::FRAMEBORDER_TLBR ) )
     288           0 :         AddItemConnection( svx::CreateFrameLineConnection( SID_ATTR_BORDER_DIAG_TLBR, *m_pFrameSel, svx::FRAMEBORDER_TLBR ) );
     289           0 :     if( m_pFrameSel->IsBorderEnabled( svx::FRAMEBORDER_BLTR ) )
     290           0 :         AddItemConnection( svx::CreateFrameLineConnection( SID_ATTR_BORDER_DIAG_BLTR, *m_pFrameSel, svx::FRAMEBORDER_BLTR ) );
     291             :     // #i43593# - item connection doesn't work for Writer,
     292             :     // because the Writer item sets contain these items
     293             :     // checkbox "Merge with next paragraph" only visible for Writer dialog format.paragraph
     294           0 :     AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_BORDER_CONNECT, *m_pMergeWithNextCB, sfx::ITEMCONN_DEFAULT ) );
     295           0 :     m_pMergeWithNextCB->Hide();
     296             :     // checkbox "Merge adjacent line styles" only visible for Writer dialog format.table
     297           0 :     AddItemConnection( new sfx::CheckBoxConnection( SID_SW_COLLAPSING_BORDERS, *m_pMergeAdjacentBordersCB, sfx::ITEMCONN_DEFAULT ) );
     298           0 :     m_pMergeAdjacentBordersCB->Hide();
     299           0 : }
     300             : 
     301             : // -----------------------------------------------------------------------
     302             : 
     303           0 : SvxBorderTabPage::~SvxBorderTabPage()
     304             : {
     305           0 : }
     306             : 
     307             : // -----------------------------------------------------------------------
     308             : 
     309           0 : sal_uInt16* SvxBorderTabPage::GetRanges()
     310             : {
     311           0 :     return pRanges;
     312             : }
     313             : 
     314             : // -----------------------------------------------------------------------
     315             : 
     316           0 : SfxTabPage* SvxBorderTabPage::Create( Window* pParent,
     317             :                                       const SfxItemSet& rAttrSet )
     318             : {
     319           0 :     return ( new SvxBorderTabPage( pParent, rAttrSet ) );
     320             : }
     321             : 
     322             : // -----------------------------------------------------------------------
     323             : 
     324           0 : void SvxBorderTabPage::ResetFrameLine_Impl( svx::FrameBorderType eBorder, const SvxBorderLine* pCoreLine, bool bValid )
     325             : {
     326           0 :     if( m_pFrameSel->IsBorderEnabled( eBorder ) )
     327             :     {
     328           0 :         if( bValid )
     329           0 :             m_pFrameSel->ShowBorder( eBorder, pCoreLine );
     330             :         else
     331           0 :             m_pFrameSel->SetBorderDontCare( eBorder );
     332             :     }
     333           0 : }
     334             : 
     335             : // -----------------------------------------------------------------------
     336             : 
     337           0 : void SvxBorderTabPage::Reset( const SfxItemSet& rSet )
     338             : {
     339           0 :     SfxTabPage::Reset( rSet );
     340             : 
     341             :     const SvxBoxItem*       pBoxItem;
     342             :     const SvxBoxInfoItem*   pBoxInfoItem;
     343           0 :     sal_uInt16                  nWhichBox       = GetWhich(SID_ATTR_BORDER_OUTER);
     344             :     SfxMapUnit              eCoreUnit;
     345             : 
     346           0 :     pBoxItem  = (const SvxBoxItem*)GetItem( rSet, SID_ATTR_BORDER_OUTER );
     347             : 
     348           0 :     pBoxInfoItem = (const SvxBoxInfoItem*)GetItem( rSet, SID_ATTR_BORDER_INNER, sal_False );
     349             : 
     350           0 :     eCoreUnit = rSet.GetPool()->GetMetric( nWhichBox );
     351             : 
     352           0 :     if ( pBoxItem && pBoxInfoItem ) // -> Don't Care
     353             :     {
     354           0 :         ResetFrameLine_Impl( svx::FRAMEBORDER_LEFT,   pBoxItem->GetLeft(),     pBoxInfoItem->IsValid( VALID_LEFT ) );
     355           0 :         ResetFrameLine_Impl( svx::FRAMEBORDER_RIGHT,  pBoxItem->GetRight(),    pBoxInfoItem->IsValid( VALID_RIGHT ) );
     356           0 :         ResetFrameLine_Impl( svx::FRAMEBORDER_TOP,    pBoxItem->GetTop(),      pBoxInfoItem->IsValid( VALID_TOP ) );
     357           0 :         ResetFrameLine_Impl( svx::FRAMEBORDER_BOTTOM, pBoxItem->GetBottom(),   pBoxInfoItem->IsValid( VALID_BOTTOM ) );
     358           0 :         ResetFrameLine_Impl( svx::FRAMEBORDER_VER,    pBoxInfoItem->GetVert(), pBoxInfoItem->IsValid( VALID_VERT ) );
     359           0 :         ResetFrameLine_Impl( svx::FRAMEBORDER_HOR,    pBoxInfoItem->GetHori(), pBoxInfoItem->IsValid( VALID_HORI ) );
     360             : 
     361             :         //-------------------
     362             :         // distance inside
     363             :         //-------------------
     364           0 :         if( !mbUseMarginItem )
     365             :         {
     366           0 :             if ( m_pLeftMF->IsVisible() )
     367             :             {
     368           0 :                 SetMetricValue(*m_pLeftMF,    pBoxInfoItem->GetDefDist(), eCoreUnit);
     369           0 :                 SetMetricValue(*m_pRightMF,   pBoxInfoItem->GetDefDist(), eCoreUnit);
     370           0 :                 SetMetricValue(*m_pTopMF,     pBoxInfoItem->GetDefDist(), eCoreUnit);
     371           0 :                 SetMetricValue(*m_pBottomMF,  pBoxInfoItem->GetDefDist(), eCoreUnit);
     372             : 
     373           0 :                 nMinValue = static_cast<long>(m_pLeftMF->GetValue());
     374             : 
     375           0 :                 if ( pBoxInfoItem->IsMinDist() )
     376             :                 {
     377           0 :                     m_pLeftMF->SetFirst( nMinValue );
     378           0 :                     m_pRightMF->SetFirst( nMinValue );
     379           0 :                     m_pTopMF->SetFirst( nMinValue );
     380           0 :                     m_pBottomMF->SetFirst( nMinValue );
     381             :                 }
     382             : 
     383           0 :                 if ( pBoxInfoItem->IsDist() )
     384             :                 {
     385           0 :                     if( rSet.GetItemState( nWhichBox, sal_True ) >= SFX_ITEM_DEFAULT )
     386             :                     {
     387           0 :                         sal_Bool bIsAnyBorderVisible = m_pFrameSel->IsAnyBorderVisible();
     388           0 :                         if( !bIsAnyBorderVisible || !pBoxInfoItem->IsMinDist() )
     389             :                         {
     390           0 :                             m_pLeftMF->SetMin( 0 );
     391           0 :                             m_pLeftMF->SetFirst( 0 );
     392           0 :                             m_pRightMF->SetMin( 0 );
     393           0 :                             m_pRightMF->SetFirst( 0 );
     394           0 :                             m_pTopMF->SetMin( 0 );
     395           0 :                             m_pTopMF->SetFirst( 0 );
     396           0 :                             m_pBottomMF->SetMin( 0 );
     397           0 :                             m_pBottomMF->SetFirst( 0 );
     398             :                         }
     399           0 :                         long nLeftDist = pBoxItem->GetDistance( BOX_LINE_LEFT);
     400           0 :                         SetMetricValue(*m_pLeftMF, nLeftDist, eCoreUnit);
     401           0 :                         long nRightDist = pBoxItem->GetDistance( BOX_LINE_RIGHT);
     402           0 :                         SetMetricValue(*m_pRightMF, nRightDist, eCoreUnit);
     403           0 :                         long nTopDist = pBoxItem->GetDistance( BOX_LINE_TOP);
     404           0 :                         SetMetricValue( *m_pTopMF, nTopDist, eCoreUnit );
     405           0 :                         long nBottomDist = pBoxItem->GetDistance( BOX_LINE_BOTTOM);
     406           0 :                         SetMetricValue( *m_pBottomMF, nBottomDist, eCoreUnit );
     407             : 
     408             :                         // if the distance is set with no active border line
     409             :                         // or it is null with an active border line
     410             :                         // no automatic changes should be made
     411           0 :                         const long nDefDist = bIsAnyBorderVisible ? pBoxInfoItem->GetDefDist() : 0;
     412           0 :                         sal_Bool bDiffDist = (nDefDist != nLeftDist ||
     413           0 :                                     nDefDist != nRightDist ||
     414           0 :                                     nDefDist != nTopDist   ||
     415           0 :                                     nDefDist != nBottomDist);
     416           0 :                         if((pBoxItem->GetDistance() ||
     417           0 :                                 bIsAnyBorderVisible) && bDiffDist )
     418             :                         {
     419           0 :                             m_pLeftMF->SetModifyFlag();
     420           0 :                             m_pRightMF->SetModifyFlag();
     421           0 :                             m_pTopMF->SetModifyFlag();
     422           0 :                             m_pBottomMF->SetModifyFlag();
     423             :                         }
     424             :                     }
     425             :                     else
     426             :                     {
     427             :                         // #106224# different margins -> do not fill the edits
     428           0 :                         m_pLeftMF->SetText( String() );
     429           0 :                         m_pRightMF->SetText( String() );
     430           0 :                         m_pTopMF->SetText( String() );
     431           0 :                         m_pBottomMF->SetText( String() );
     432             :                     }
     433             :                 }
     434           0 :                 m_pLeftMF->SaveValue();
     435           0 :                 m_pRightMF->SaveValue();
     436           0 :                 m_pTopMF->SaveValue();
     437           0 :                 m_pBottomMF->SaveValue();
     438             :             }
     439           0 :         }
     440             :     }
     441             :     else
     442             :     {
     443             :         // avoid ResetFrameLine-calls:
     444           0 :         m_pFrameSel->HideAllBorders();
     445             :     }
     446             : 
     447             :     //-------------------------------------------------------------
     448             :     // depict line (color) in controllers if unambiguous:
     449             :     //-------------------------------------------------------------
     450             :     {
     451             :         // Do all visible lines show the same line widths?
     452             :         long nWidth;
     453             :         SvxBorderStyle nStyle;
     454           0 :         bool bWidthEq = m_pFrameSel->GetVisibleWidth( nWidth, nStyle );
     455           0 :         if( bWidthEq )
     456             :         {
     457             :             // Determine the width first as some styles can be missing depending on it
     458             :             sal_Int64 nWidthPt =  static_cast<sal_Int64>(MetricField::ConvertDoubleValue(
     459           0 :                         sal_Int64( nWidth ), m_pLineWidthMF->GetDecimalDigits( ),
     460           0 :                         MAP_TWIP,m_pLineWidthMF->GetUnit() ));
     461           0 :             m_pLineWidthMF->SetValue( nWidthPt );
     462           0 :             m_pLbLineStyle->SetWidth( nWidth );
     463             : 
     464             :             // then set the style
     465           0 :             m_pLbLineStyle->SelectEntry( nStyle );
     466             :         }
     467             :         else
     468           0 :             m_pLbLineStyle->SelectEntryPos( 1 );
     469             : 
     470             :         // Do all visible lines show the same line color?
     471           0 :         Color aColor;
     472           0 :         bool bColorEq = m_pFrameSel->GetVisibleColor( aColor );
     473           0 :         if( !bColorEq )
     474           0 :             aColor.SetColor( COL_BLACK );
     475             : 
     476           0 :         sal_uInt16 nSelPos = m_pLbLineColor->GetEntryPos( aColor );
     477           0 :         if( nSelPos == LISTBOX_ENTRY_NOTFOUND )
     478           0 :             nSelPos = m_pLbLineColor->InsertEntry( aColor, SVX_RESSTR( RID_SVXSTR_COLOR_USER ) );
     479             : 
     480           0 :         m_pLbLineColor->SelectEntryPos( nSelPos );
     481           0 :         m_pLbLineStyle->SetColor( aColor );
     482             : 
     483             :         // Select all visible lines, if they are all equal.
     484           0 :         if( bWidthEq && bColorEq )
     485           0 :             m_pFrameSel->SelectAllVisibleBorders();
     486             : 
     487             :         // set the current style and color (caches style in control even if nothing is selected)
     488           0 :         SelStyleHdl_Impl(m_pLbLineStyle);
     489           0 :         SelColHdl_Impl(m_pLbLineColor);
     490             :     }
     491             : 
     492           0 :     sal_Bool bEnable = m_pWndShadows->GetSelectItemId() > 1 ;
     493           0 :     m_pFtShadowSize->Enable(bEnable);
     494           0 :     m_pEdShadowSize->Enable(bEnable);
     495           0 :     m_pFtShadowColor->Enable(bEnable);
     496           0 :     m_pLbShadowColor->Enable(bEnable);
     497             : 
     498           0 :     m_pWndPresets->SetNoSelection();
     499             : 
     500             :     // - no line - should not be selected
     501             : 
     502           0 :     if ( m_pLbLineStyle->GetSelectEntryPos() == 0 )
     503             :     {
     504           0 :         m_pLbLineStyle->SelectEntryPos( 1 );
     505           0 :         SelStyleHdl_Impl(m_pLbLineStyle);
     506             :     }
     507             : 
     508             :     const SfxPoolItem* pItem;
     509             :     SfxObjectShell* pShell;
     510           0 :     if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, sal_False, &pItem) ||
     511           0 :         ( 0 != (pShell = SfxObjectShell::Current()) &&
     512           0 :                     0 != (pItem = pShell->GetItem(SID_HTML_MODE))))
     513             :     {
     514           0 :         sal_uInt16 nHtmlMode = ((SfxUInt16Item*)pItem)->GetValue();
     515           0 :         if(nHtmlMode & HTMLMODE_ON)
     516             :         {
     517             :             // there are no shadows in Html-mode and only complete borders
     518           0 :             m_pShadowFrame->Disable();
     519             : 
     520           0 :             if( !(nSWMode & SW_BORDER_MODE_TABLE) )
     521             :             {
     522           0 :                 m_pUserDefFT->Disable();
     523           0 :                 m_pFrameSel->Disable();
     524           0 :                 m_pWndPresets->RemoveItem(3);
     525           0 :                 m_pWndPresets->RemoveItem(4);
     526           0 :                 m_pWndPresets->RemoveItem(5);
     527             :             }
     528             :         }
     529             :     }
     530             : 
     531           0 :     LinesChanged_Impl( 0 );
     532           0 :     if(m_pLeftMF->GetValue() == m_pRightMF->GetValue() && m_pTopMF->GetValue() == m_pBottomMF->GetValue() && m_pTopMF->GetValue() == m_pLeftMF->GetValue())
     533           0 :         mbSync = true;
     534             :     else
     535           0 :         mbSync = false;
     536           0 :     m_pSynchronizeCB->Check(mbSync);
     537           0 : }
     538             : 
     539             : // -----------------------------------------------------------------------
     540             : 
     541           0 : int SvxBorderTabPage::DeactivatePage( SfxItemSet* _pSet )
     542             : {
     543           0 :     if ( _pSet )
     544           0 :         FillItemSet( *_pSet );
     545             : 
     546           0 :     return LEAVE_PAGE;
     547             : }
     548             : 
     549             : // -----------------------------------------------------------------------
     550             : 
     551           0 : sal_Bool SvxBorderTabPage::FillItemSet( SfxItemSet& rCoreAttrs )
     552             : {
     553           0 :     bool bAttrsChanged = SfxTabPage::FillItemSet( rCoreAttrs );
     554             : 
     555           0 :     sal_Bool                  bPut          = sal_True;
     556           0 :     sal_uInt16                nBoxWhich     = GetWhich( SID_ATTR_BORDER_OUTER );
     557           0 :     sal_uInt16                nBoxInfoWhich = rCoreAttrs.GetPool()->GetWhich( SID_ATTR_BORDER_INNER, sal_False );
     558           0 :     const SfxItemSet&     rOldSet       = GetItemSet();
     559           0 :     SvxBoxItem            aBoxItem      ( nBoxWhich );
     560           0 :     SvxBoxInfoItem        aBoxInfoItem  ( nBoxInfoWhich );
     561           0 :     SvxBoxItem* pOldBoxItem = (SvxBoxItem*)GetOldItem( rCoreAttrs, SID_ATTR_BORDER_OUTER );
     562             : 
     563           0 :     SfxMapUnit eCoreUnit = rOldSet.GetPool()->GetMetric( nBoxWhich );
     564             : 
     565             :     //------------------
     566             :     // outer border:
     567             :     //------------------
     568             :     typedef ::std::pair<svx::FrameBorderType,sal_uInt16> TBorderPair;
     569             :     TBorderPair eTypes1[] = {
     570             :                                 TBorderPair(svx::FRAMEBORDER_TOP,BOX_LINE_TOP),
     571             :                                 TBorderPair(svx::FRAMEBORDER_BOTTOM,BOX_LINE_BOTTOM),
     572             :                                 TBorderPair(svx::FRAMEBORDER_LEFT,BOX_LINE_LEFT),
     573             :                                 TBorderPair(svx::FRAMEBORDER_RIGHT,BOX_LINE_RIGHT),
     574           0 :                             };
     575             : 
     576           0 :     for (sal_uInt32 i=0; i < SAL_N_ELEMENTS(eTypes1); ++i)
     577           0 :         aBoxItem.SetLine( m_pFrameSel->GetFrameBorderStyle( eTypes1[i].first ), eTypes1[i].second );
     578             : 
     579             :     //--------------------------------
     580             :     // border hor/ver and TableFlag
     581             :     //--------------------------------
     582             :     TBorderPair eTypes2[] = {
     583             :                                 TBorderPair(svx::FRAMEBORDER_HOR,BOXINFO_LINE_HORI),
     584             :                                 TBorderPair(svx::FRAMEBORDER_VER,BOXINFO_LINE_VERT)
     585           0 :                             };
     586           0 :     for (sal_uInt32 j=0; j < SAL_N_ELEMENTS(eTypes2); ++j)
     587           0 :         aBoxInfoItem.SetLine( m_pFrameSel->GetFrameBorderStyle( eTypes2[j].first ), eTypes2[j].second );
     588             : 
     589           0 :     aBoxInfoItem.EnableHor( mbHorEnabled );
     590           0 :     aBoxInfoItem.EnableVer( mbVerEnabled );
     591             : 
     592             :     //-------------------
     593             :     // inner distance
     594             :     //-------------------
     595           0 :     if( m_pLeftMF->IsVisible() )
     596             :     {
     597             :         // #i40405# enable distance controls for next dialog call
     598           0 :         aBoxInfoItem.SetDist( sal_True );
     599             : 
     600           0 :         if( !mbUseMarginItem )
     601             :         {
     602             :             // #106224# all edits empty: do nothing
     603           0 :             if( !m_pLeftMF->GetText().isEmpty() || !m_pRightMF->GetText().isEmpty() ||
     604           0 :                 !m_pTopMF->GetText().isEmpty() || !m_pBottomMF->GetText().isEmpty() )
     605             :             {
     606           0 :                 if ( ((mbHorEnabled || mbVerEnabled || (nSWMode & SW_BORDER_MODE_TABLE)) &&
     607           0 :                         (m_pLeftMF->IsModified()||m_pRightMF->IsModified()||
     608           0 :                             m_pTopMF->IsModified()||m_pBottomMF->IsModified()) )||
     609           0 :                      m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_TOP ) != svx::FRAMESTATE_HIDE
     610           0 :                      || m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_BOTTOM ) != svx::FRAMESTATE_HIDE
     611           0 :                      || m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_LEFT ) != svx::FRAMESTATE_HIDE
     612           0 :                      || m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_RIGHT ) != svx::FRAMESTATE_HIDE )
     613             :                 {
     614             :                     SvxBoxInfoItem* pOldBoxInfoItem = (SvxBoxInfoItem*)GetOldItem(
     615           0 :                                                         rCoreAttrs, SID_ATTR_BORDER_INNER );
     616           0 :                     if (
     617           0 :                         !pOldBoxItem ||
     618           0 :                         m_pLeftMF->GetText() != m_pLeftMF->GetSavedValue() ||
     619           0 :                         m_pRightMF->GetText() != m_pRightMF->GetSavedValue() ||
     620           0 :                         m_pTopMF->GetText() != m_pTopMF->GetSavedValue() ||
     621           0 :                         m_pBottomMF->GetText() != m_pBottomMF->GetSavedValue() ||
     622           0 :                         nMinValue == m_pLeftMF->GetValue() ||
     623           0 :                         nMinValue == m_pRightMF->GetValue() ||
     624           0 :                         nMinValue == m_pTopMF->GetValue() ||
     625           0 :                         nMinValue == m_pBottomMF->GetValue() ||
     626           0 :                         (pOldBoxInfoItem && !pOldBoxInfoItem->IsValid(VALID_DISTANCE))
     627             :                        )
     628             :                     {
     629           0 :                         aBoxItem.SetDistance( (sal_uInt16)GetCoreValue(*m_pLeftMF, eCoreUnit ), BOX_LINE_LEFT  );
     630           0 :                         aBoxItem.SetDistance( (sal_uInt16)GetCoreValue(*m_pRightMF, eCoreUnit ), BOX_LINE_RIGHT );
     631           0 :                         aBoxItem.SetDistance( (sal_uInt16)GetCoreValue(*m_pTopMF, eCoreUnit ), BOX_LINE_TOP   );
     632           0 :                         aBoxItem.SetDistance( (sal_uInt16)GetCoreValue(*m_pBottomMF, eCoreUnit ), BOX_LINE_BOTTOM);
     633             :                     }
     634             :                     else
     635             :                     {
     636           0 :                         aBoxItem.SetDistance(pOldBoxItem->GetDistance(BOX_LINE_LEFT ), BOX_LINE_LEFT);
     637           0 :                         aBoxItem.SetDistance(pOldBoxItem->GetDistance(BOX_LINE_RIGHT),  BOX_LINE_RIGHT);
     638           0 :                         aBoxItem.SetDistance(pOldBoxItem->GetDistance(BOX_LINE_TOP  ), BOX_LINE_TOP);
     639           0 :                         aBoxItem.SetDistance(pOldBoxItem->GetDistance(BOX_LINE_BOTTOM), BOX_LINE_BOTTOM);
     640             :                     }
     641           0 :                     aBoxInfoItem.SetValid( VALID_DISTANCE, sal_True );
     642             :                 }
     643             :                 else
     644           0 :                     aBoxInfoItem.SetValid( VALID_DISTANCE, sal_False );
     645             :             }
     646             :         }
     647             :     }
     648             : 
     649             :     //------------------------------------------
     650             :     // note Don't Care Status in the Info-Item:
     651             :     //------------------------------------------
     652           0 :     aBoxInfoItem.SetValid( VALID_TOP,    m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_TOP )    != svx::FRAMESTATE_DONTCARE );
     653           0 :     aBoxInfoItem.SetValid( VALID_BOTTOM, m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_BOTTOM ) != svx::FRAMESTATE_DONTCARE );
     654           0 :     aBoxInfoItem.SetValid( VALID_LEFT,   m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_LEFT )   != svx::FRAMESTATE_DONTCARE );
     655           0 :     aBoxInfoItem.SetValid( VALID_RIGHT,  m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_RIGHT )  != svx::FRAMESTATE_DONTCARE );
     656           0 :     aBoxInfoItem.SetValid( VALID_HORI,   m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_HOR )    != svx::FRAMESTATE_DONTCARE );
     657           0 :     aBoxInfoItem.SetValid( VALID_VERT,   m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_VER )    != svx::FRAMESTATE_DONTCARE );
     658             : 
     659             :     //
     660             :     // Put or Clear of the border?
     661             :     //
     662           0 :     bPut = sal_True;
     663             : 
     664           0 :     if (   SFX_ITEM_DEFAULT == rOldSet.GetItemState( nBoxWhich,     sal_False ))
     665             :     {
     666           0 :         bPut = aBoxItem != (const SvxBoxItem&)(rOldSet.Get(nBoxWhich)) ? sal_True : sal_False;
     667             :     }
     668           0 :     if(  SFX_ITEM_DEFAULT == rOldSet.GetItemState( nBoxInfoWhich, sal_False ) )
     669             :     {
     670             :         const SvxBoxInfoItem& rOldBoxInfo = (const SvxBoxInfoItem&)
     671           0 :                                 rOldSet.Get(nBoxInfoWhich);
     672             : 
     673           0 :         aBoxInfoItem.SetMinDist( rOldBoxInfo.IsMinDist() );
     674           0 :         aBoxInfoItem.SetDefDist( rOldBoxInfo.GetDefDist() );
     675           0 :         bPut |= (aBoxInfoItem != rOldBoxInfo );
     676             :     }
     677             : 
     678           0 :     if ( bPut )
     679             :     {
     680           0 :         if ( !pOldBoxItem || !( *pOldBoxItem == aBoxItem ) )
     681             :         {
     682           0 :             rCoreAttrs.Put( aBoxItem );
     683           0 :             bAttrsChanged |= sal_True;
     684             :         }
     685           0 :         const SfxPoolItem* pOld = GetOldItem( rCoreAttrs, SID_ATTR_BORDER_INNER, sal_False );
     686             : 
     687           0 :         if ( !pOld || !( *(const SvxBoxInfoItem*)pOld == aBoxInfoItem ) )
     688             :         {
     689           0 :             rCoreAttrs.Put( aBoxInfoItem );
     690           0 :             bAttrsChanged |= sal_True;
     691             :         }
     692             :     }
     693             :     else
     694             :     {
     695           0 :         rCoreAttrs.ClearItem( nBoxWhich );
     696           0 :         rCoreAttrs.ClearItem( nBoxInfoWhich );
     697             :     }
     698             : 
     699           0 :     return bAttrsChanged;
     700             : }
     701             : 
     702             : // -----------------------------------------------------------------------
     703             : 
     704           0 : void SvxBorderTabPage::HideShadowControls()
     705             : {
     706           0 :     m_pShadowFrame->Hide();
     707           0 : }
     708             : 
     709             : // -----------------------------------------------------------------------
     710             : 
     711           0 : IMPL_LINK_NOARG(SvxBorderTabPage, SelPreHdl_Impl)
     712             : {
     713           0 :     const svx::FrameBorderState SHOW = svx::FRAMESTATE_SHOW;
     714           0 :     const svx::FrameBorderState HIDE = svx::FRAMESTATE_HIDE;
     715           0 :     const svx::FrameBorderState DONT = svx::FRAMESTATE_DONTCARE;
     716             : 
     717             :     static const svx::FrameBorderState ppeStates[][ svx::FRAMEBORDERTYPE_COUNT ] =
     718             :     {                   /*    Left  Right Top   Bot   Hor   Ver   TLBR  BLTR */
     719             : /* ---------------------+--------------------------------------------------- */
     720             : /* IID_PRE_CELL_NONE    */  { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
     721             : /* IID_PRE_CELL_ALL     */  { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
     722             : /* IID_PRE_CELL_LR      */  { SHOW, SHOW, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
     723             : /* IID_PRE_CELL_TB      */  { HIDE, HIDE, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
     724             : /* IID_PRE_CELL_L       */  { SHOW, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
     725             : /* IID_PRE_CELL_DIAG    */  { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, SHOW, SHOW },
     726             : /* IID_PRE_HOR_NONE     */  { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
     727             : /* IID_PRE_HOR_OUTER    */  { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
     728             : /* IID_PRE_HOR_HOR      */  { HIDE, HIDE, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE },
     729             : /* IID_PRE_HOR_ALL      */  { SHOW, SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE },
     730             : /* IID_PRE_HOR_OUTER2   */  { SHOW, SHOW, SHOW, SHOW, DONT, HIDE, HIDE, HIDE },
     731             : /* IID_PRE_VER_NONE     */  { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
     732             : /* IID_PRE_VER_OUTER    */  { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
     733             : /* IID_PRE_VER_VER      */  { SHOW, SHOW, HIDE, HIDE, HIDE, SHOW, HIDE, HIDE },
     734             : /* IID_PRE_VER_ALL      */  { SHOW, SHOW, SHOW, SHOW, HIDE, SHOW, HIDE, HIDE },
     735             : /* IID_PRE_VER_OUTER2   */  { SHOW, SHOW, SHOW, SHOW, HIDE, DONT, HIDE, HIDE },
     736             : /* IID_PRE_TABLE_NONE   */  { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
     737             : /* IID_PRE_TABLE_OUTER  */  { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
     738             : /* IID_PRE_TABLE_OUTERH */  { SHOW, SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE },
     739             : /* IID_PRE_TABLE_ALL    */  { SHOW, SHOW, SHOW, SHOW, SHOW, SHOW, HIDE, HIDE },
     740             : /* IID_PRE_TABLE_OUTER2 */  { SHOW, SHOW, SHOW, SHOW, DONT, DONT, HIDE, HIDE }
     741             :     };
     742             : 
     743             :     // first hide and deselect all frame borders
     744           0 :     m_pFrameSel->HideAllBorders();
     745           0 :     m_pFrameSel->DeselectAllBorders();
     746             : 
     747             :     // Using image ID to find correct line in table above.
     748           0 :     sal_uInt16 nLine = GetPresetImageId( m_pWndPresets->GetSelectItemId() ) - 1;
     749             : 
     750             :     // Apply all styles from the table
     751           0 :     for( int nBorder = 0; nBorder < svx::FRAMEBORDERTYPE_COUNT; ++nBorder )
     752             :     {
     753           0 :         svx::FrameBorderType eBorder = svx::GetFrameBorderTypeFromIndex( nBorder );
     754           0 :         switch( ppeStates[ nLine ][ nBorder ] )
     755             :         {
     756           0 :             case SHOW:  m_pFrameSel->SelectBorder( eBorder );      break;
     757           0 :             case HIDE:  /* nothing to do */                     break;
     758           0 :             case DONT:  m_pFrameSel->SetBorderDontCare( eBorder ); break;
     759             :         }
     760             :     }
     761             : 
     762             :     // Show all lines that have been selected above
     763           0 :     if( m_pFrameSel->IsAnyBorderSelected() )
     764             :     {
     765             :         // any visible style, but "no-line" in line list box? -> use hair-line
     766           0 :         if( (m_pLbLineStyle->GetSelectEntryPos() == 0) || (m_pLbLineStyle->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND) )
     767           0 :             m_pLbLineStyle->SelectEntryPos( 1 );
     768             : 
     769             :         // set current style to all previously selected lines
     770           0 :         SelStyleHdl_Impl(m_pLbLineStyle);
     771           0 :         SelColHdl_Impl(m_pLbLineColor);
     772             :     }
     773             : 
     774             :     // Presets ValueSet does not show a selection (used as push buttons).
     775           0 :     m_pWndPresets->SetNoSelection();
     776             : 
     777           0 :     LinesChanged_Impl( 0 );
     778           0 :     return 0;
     779             : }
     780             : 
     781             : // -----------------------------------------------------------------------
     782             : 
     783           0 : IMPL_LINK_NOARG(SvxBorderTabPage, SelSdwHdl_Impl)
     784             : {
     785           0 :     sal_Bool bEnable = m_pWndShadows->GetSelectItemId() > 1;
     786           0 :     m_pFtShadowSize->Enable(bEnable);
     787           0 :     m_pEdShadowSize->Enable(bEnable);
     788           0 :     m_pFtShadowColor->Enable(bEnable);
     789           0 :     m_pLbShadowColor->Enable(bEnable);
     790           0 :     return 0;
     791             : }
     792             : 
     793             : // -----------------------------------------------------------------------
     794             : 
     795           0 : IMPL_LINK( SvxBorderTabPage, SelColHdl_Impl, ListBox *, pLb )
     796             : {
     797           0 :     ColorListBox* pColLb = (ColorListBox*)(pLb);
     798             : 
     799           0 :     if (pLb == m_pLbLineColor)
     800             :     {
     801           0 :         m_pFrameSel->SetColorToSelection( pColLb->GetSelectEntryColor() );
     802           0 :         m_pLbLineStyle->SetColor( pColLb->GetSelectEntryColor() );
     803             :     }
     804             : 
     805           0 :     return 0;
     806             : }
     807             : 
     808           0 : IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthHdl_Impl)
     809             : {
     810             :     sal_Int64 nVal = static_cast<sal_Int64>(MetricField::ConvertDoubleValue(
     811           0 :                 m_pLineWidthMF->GetValue( ),
     812           0 :                 m_pLineWidthMF->GetDecimalDigits( ),
     813           0 :                 m_pLineWidthMF->GetUnit(), MAP_TWIP ));
     814           0 :     m_pLbLineStyle->SetWidth( nVal );
     815             : 
     816             :     m_pFrameSel->SetStyleToSelection( nVal,
     817           0 :         SvxBorderStyle( m_pLbLineStyle->GetSelectEntryStyle() ) );
     818             : 
     819           0 :     return 0;
     820             : }
     821             : 
     822             : // -----------------------------------------------------------------------
     823             : 
     824           0 : IMPL_LINK( SvxBorderTabPage, SelStyleHdl_Impl, ListBox *, pLb )
     825             : {
     826           0 :     if (pLb == m_pLbLineStyle)
     827             :     {
     828             :         sal_Int64 nVal = static_cast<sal_Int64>(MetricField::ConvertDoubleValue(
     829           0 :                     m_pLineWidthMF->GetValue( ),
     830           0 :                     m_pLineWidthMF->GetDecimalDigits( ),
     831           0 :                     m_pLineWidthMF->GetUnit(), MAP_TWIP ));
     832             :         m_pFrameSel->SetStyleToSelection ( nVal,
     833           0 :             SvxBorderStyle( m_pLbLineStyle->GetSelectEntryStyle() ) );
     834             :     }
     835             : 
     836           0 :     return 0;
     837             : }
     838             : 
     839             : // ============================================================================
     840             : // ValueSet handling
     841             : // ============================================================================
     842             : 
     843             : // number of preset images to show
     844             : const sal_uInt16 SVX_BORDER_PRESET_COUNT = 5;
     845             : 
     846             : // number of shadow images to show
     847             : const sal_uInt16 SVX_BORDER_SHADOW_COUNT = 5;
     848             : 
     849             : // ----------------------------------------------------------------------------
     850             : 
     851           0 : sal_uInt16 SvxBorderTabPage::GetPresetImageId( sal_uInt16 nValueSetIdx ) const
     852             : {
     853             :     // table with all sets of predefined border styles
     854             :     static const sal_uInt16 ppnImgIds[][ SVX_BORDER_PRESET_COUNT ] =
     855             :     {
     856             :         // simple cell without diagonal frame borders
     857             :         {   IID_PRE_CELL_NONE,  IID_PRE_CELL_ALL,       IID_PRE_CELL_LR,        IID_PRE_CELL_TB,    IID_PRE_CELL_L          },
     858             :         // simple cell with diagonal frame borders
     859             :         {   IID_PRE_CELL_NONE,  IID_PRE_CELL_ALL,       IID_PRE_CELL_LR,        IID_PRE_CELL_TB,    IID_PRE_CELL_DIAG       },
     860             :         // with horizontal inner frame border
     861             :         {   IID_PRE_HOR_NONE,   IID_PRE_HOR_OUTER,      IID_PRE_HOR_HOR,        IID_PRE_HOR_ALL,    IID_PRE_HOR_OUTER2      },
     862             :         // with vertical inner frame border
     863             :         {   IID_PRE_VER_NONE,   IID_PRE_VER_OUTER,      IID_PRE_VER_VER,        IID_PRE_VER_ALL,    IID_PRE_VER_OUTER2      },
     864             :         // with horizontal and vertical inner frame borders
     865             :         {   IID_PRE_TABLE_NONE, IID_PRE_TABLE_OUTER,    IID_PRE_TABLE_OUTERH,   IID_PRE_TABLE_ALL,  IID_PRE_TABLE_OUTER2    }
     866             :     };
     867             : 
     868             :     // find correct set of presets
     869           0 :     int nLine = 0;
     870           0 :     if( !mbHorEnabled && !mbVerEnabled )
     871           0 :         nLine = (mbTLBREnabled || mbBLTREnabled) ? 1 : 0;
     872           0 :     else if( mbHorEnabled && !mbVerEnabled )
     873           0 :         nLine = 2;
     874           0 :     else if( !mbHorEnabled && mbVerEnabled )
     875           0 :         nLine = 3;
     876             :     else
     877           0 :         nLine = 4;
     878             : 
     879             :     DBG_ASSERT( (1 <= nValueSetIdx) && (nValueSetIdx <= SVX_BORDER_PRESET_COUNT),
     880             :         "SvxBorderTabPage::GetPresetImageId - wrong index" );
     881           0 :     return ppnImgIds[ nLine ][ nValueSetIdx - 1 ];
     882             : }
     883             : 
     884           0 : sal_uInt16 SvxBorderTabPage::GetPresetStringId( sal_uInt16 nValueSetIdx ) const
     885             : {
     886             :     // string resource IDs for each image (in order of the IID_PRE_* image IDs)
     887             :     static const sal_uInt16 pnStrIds[] =
     888             :     {
     889             :         RID_SVXSTR_TABLE_PRESET_NONE,
     890             :         RID_SVXSTR_PARA_PRESET_ALL,
     891             :         RID_SVXSTR_PARA_PRESET_LEFTRIGHT,
     892             :         RID_SVXSTR_PARA_PRESET_TOPBOTTOM,
     893             :         RID_SVXSTR_PARA_PRESET_ONLYLEFT,
     894             :         RID_SVXSTR_PARA_PRESET_DIAGONAL,
     895             : 
     896             :         RID_SVXSTR_TABLE_PRESET_NONE,
     897             :         RID_SVXSTR_TABLE_PRESET_ONLYOUTER,
     898             :         RID_SVXSTR_HOR_PRESET_ONLYHOR,
     899             :         RID_SVXSTR_TABLE_PRESET_OUTERALL,
     900             :         RID_SVXSTR_TABLE_PRESET_OUTERINNER,
     901             : 
     902             :         RID_SVXSTR_TABLE_PRESET_NONE,
     903             :         RID_SVXSTR_TABLE_PRESET_ONLYOUTER,
     904             :         RID_SVXSTR_VER_PRESET_ONLYVER,
     905             :         RID_SVXSTR_TABLE_PRESET_OUTERALL,
     906             :         RID_SVXSTR_TABLE_PRESET_OUTERINNER,
     907             : 
     908             :         RID_SVXSTR_TABLE_PRESET_NONE,
     909             :         RID_SVXSTR_TABLE_PRESET_ONLYOUTER,
     910             :         RID_SVXSTR_TABLE_PRESET_OUTERHORI,
     911             :         RID_SVXSTR_TABLE_PRESET_OUTERALL,
     912             :         RID_SVXSTR_TABLE_PRESET_OUTERINNER
     913             :     };
     914           0 :     return pnStrIds[ GetPresetImageId( nValueSetIdx ) - 1 ];
     915             : }
     916             : 
     917             : // ----------------------------------------------------------------------------
     918             : 
     919           0 : void SvxBorderTabPage::FillPresetVS()
     920             : {
     921           0 :     ImageList& rImgList = aBorderImgLst;
     922             : 
     923             :     // basic initialization of the ValueSet
     924           0 :     m_pWndPresets->SetStyle( m_pWndPresets->GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER );
     925           0 :     m_pWndPresets->SetColCount( SVX_BORDER_PRESET_COUNT );
     926             : 
     927             :     // insert images and help texts
     928           0 :     for( sal_uInt16 nVSIdx = 1; nVSIdx <= SVX_BORDER_PRESET_COUNT; ++nVSIdx )
     929             :     {
     930           0 :         m_pWndPresets->InsertItem( nVSIdx );
     931           0 :         m_pWndPresets->SetItemImage( nVSIdx, rImgList.GetImage( GetPresetImageId( nVSIdx ) ) );
     932           0 :         m_pWndPresets->SetItemText( nVSIdx, CUI_RESSTR( GetPresetStringId( nVSIdx ) ) );
     933             :     }
     934             : 
     935             :     // show the control
     936           0 :     m_pWndPresets->SetNoSelection();
     937           0 :     m_pWndPresets->Show();
     938           0 : }
     939             : 
     940             : // ----------------------------------------------------------------------------
     941             : 
     942           0 : void SvxBorderTabPage::FillShadowVS()
     943             : {
     944           0 :     ImageList& rImgList = aShadowImgLst;
     945             : 
     946             :     // basic initialization of the ValueSet
     947           0 :     m_pWndShadows->SetStyle( m_pWndShadows->GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER );
     948           0 :     m_pWndShadows->SetColCount( SVX_BORDER_SHADOW_COUNT );
     949             : 
     950             :     // image resource IDs
     951             :     static const sal_uInt16 pnImgIds[ SVX_BORDER_SHADOW_COUNT ] =
     952             :         { IID_SHADOWNONE, IID_SHADOW_BOT_RIGHT, IID_SHADOW_TOP_RIGHT, IID_SHADOW_BOT_LEFT, IID_SHADOW_TOP_LEFT };
     953             :     // string resource IDs for each image
     954             :     static const sal_uInt16 pnStrIds[ SVX_BORDER_SHADOW_COUNT ] =
     955             :         { RID_SVXSTR_SHADOW_STYLE_NONE, RID_SVXSTR_SHADOW_STYLE_BOTTOMRIGHT, RID_SVXSTR_SHADOW_STYLE_TOPRIGHT, RID_SVXSTR_SHADOW_STYLE_BOTTOMLEFT, RID_SVXSTR_SHADOW_STYLE_TOPLEFT };
     956             : 
     957             :     // insert images and help texts
     958           0 :     for( sal_uInt16 nVSIdx = 1; nVSIdx <= SVX_BORDER_SHADOW_COUNT; ++nVSIdx )
     959             :     {
     960           0 :         m_pWndShadows->InsertItem( nVSIdx );
     961           0 :         m_pWndShadows->SetItemImage( nVSIdx, rImgList.GetImage( pnImgIds[ nVSIdx - 1 ] ) );
     962           0 :         m_pWndShadows->SetItemText( nVSIdx, CUI_RESSTR( pnStrIds[ nVSIdx - 1 ] ) );
     963             :     }
     964             : 
     965             :     // show the control
     966           0 :     m_pWndShadows->SelectItem( 1 );
     967           0 :     m_pWndShadows->Show();
     968           0 : }
     969             : 
     970             : // ----------------------------------------------------------------------------
     971             : 
     972           0 : void SvxBorderTabPage::FillValueSets()
     973             : {
     974           0 :     FillPresetVS();
     975           0 :     FillShadowVS();
     976           0 : }
     977             : 
     978             : // ============================================================================
     979           0 : static Color lcl_mediumColor( Color aMain, Color /*aDefault*/ )
     980             : {
     981           0 :     return SvxBorderLine::threeDMediumColor( aMain );
     982             : }
     983             : 
     984           0 : void SvxBorderTabPage::FillLineListBox_Impl()
     985             : {
     986             :     using namespace ::com::sun::star::table::BorderLineStyle;
     987             : 
     988           0 :     m_pLbLineStyle->SetSourceUnit( FUNIT_TWIP );
     989             : 
     990           0 :     m_pLbLineStyle->SetNone( SVX_RESSTR( RID_SVXSTR_NONE ) );
     991             : 
     992             :     // Simple lines
     993           0 :     m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( SOLID ), SOLID );
     994           0 :     m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( DOTTED ), DOTTED );
     995           0 :     m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( DASHED ), DASHED );
     996           0 :     m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( FINE_DASHED ), FINE_DASHED );
     997             : 
     998             :     // Double lines
     999           0 :     m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( DOUBLE ), DOUBLE );
    1000           0 :     m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_SMALLGAP ), THINTHICK_SMALLGAP, 20 );
    1001           0 :     m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_MEDIUMGAP ), THINTHICK_MEDIUMGAP );
    1002           0 :     m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_LARGEGAP ), THINTHICK_LARGEGAP );
    1003           0 :     m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_SMALLGAP ), THICKTHIN_SMALLGAP, 20 );
    1004           0 :     m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_MEDIUMGAP ), THICKTHIN_MEDIUMGAP );
    1005           0 :     m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_LARGEGAP ), THICKTHIN_LARGEGAP );
    1006             : 
    1007             :     // Engraved / Embossed
    1008             :     m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( EMBOSSED ), EMBOSSED, 15,
    1009             :             &SvxBorderLine::threeDLightColor, &SvxBorderLine::threeDDarkColor,
    1010           0 :             &lcl_mediumColor );
    1011             :     m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( ENGRAVED ), ENGRAVED, 15,
    1012             :             &SvxBorderLine::threeDDarkColor, &SvxBorderLine::threeDLightColor,
    1013           0 :             &lcl_mediumColor );
    1014             : 
    1015             :     // Inset / Outset
    1016             :     m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( OUTSET ), OUTSET, 10,
    1017           0 :            &SvxBorderLine::lightColor, &SvxBorderLine::darkColor );
    1018             :     m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( INSET ), INSET, 10,
    1019           0 :            &SvxBorderLine::darkColor, &SvxBorderLine::lightColor );
    1020             : 
    1021             :     sal_Int64 nVal = static_cast<sal_Int64>(MetricField::ConvertDoubleValue(
    1022           0 :                 m_pLineWidthMF->GetValue( ),
    1023           0 :                 m_pLineWidthMF->GetDecimalDigits( ),
    1024           0 :                 m_pLineWidthMF->GetUnit(), MAP_TWIP ));
    1025           0 :     m_pLbLineStyle->SetWidth( nVal );
    1026           0 : }
    1027             : 
    1028             : // -----------------------------------------------------------------------
    1029           0 : IMPL_LINK_NOARG(SvxBorderTabPage, LinesChanged_Impl)
    1030             : {
    1031           0 :     if(!mbUseMarginItem && m_pLeftMF->IsVisible())
    1032             :     {
    1033           0 :         sal_Bool bLineSet = m_pFrameSel->IsAnyBorderVisible();
    1034           0 :         sal_Bool bMinAllowed = 0 != (nSWMode & (SW_BORDER_MODE_FRAME|SW_BORDER_MODE_TABLE));
    1035           0 :         sal_Bool bSpaceModified =   m_pLeftMF->IsModified()||
    1036           0 :                                 m_pRightMF->IsModified()||
    1037           0 :                                 m_pTopMF->IsModified()||
    1038           0 :                                 m_pBottomMF->IsModified();
    1039             : 
    1040           0 :         if(bLineSet)
    1041             :         {
    1042           0 :             if(!bMinAllowed)
    1043             :             {
    1044           0 :                 m_pLeftMF->SetFirst(nMinValue);
    1045           0 :                 m_pRightMF->SetFirst(nMinValue);
    1046           0 :                 m_pTopMF->SetFirst(nMinValue);
    1047           0 :                 m_pBottomMF->SetFirst(nMinValue);
    1048             :             }
    1049           0 :             if(!bSpaceModified)
    1050             :             {
    1051           0 :                 m_pLeftMF->SetValue(nMinValue);
    1052           0 :                 m_pRightMF->SetValue(nMinValue);
    1053           0 :                 m_pTopMF->SetValue(nMinValue);
    1054           0 :                 m_pBottomMF->SetValue(nMinValue);
    1055             :             }
    1056             :         }
    1057             :         else
    1058             :         {
    1059           0 :             m_pLeftMF->SetMin(0);
    1060           0 :             m_pRightMF->SetMin(0);
    1061           0 :             m_pTopMF->SetMin(0);
    1062           0 :             m_pBottomMF->SetMin(0);
    1063           0 :             m_pLeftMF->SetFirst(0);
    1064           0 :             m_pRightMF->SetFirst(0);
    1065           0 :             m_pTopMF->SetFirst(0);
    1066           0 :             m_pBottomMF->SetFirst(0);
    1067           0 :             if(!bSpaceModified)
    1068             :             {
    1069           0 :                 m_pLeftMF->SetValue(0);
    1070           0 :                 m_pRightMF->SetValue(0);
    1071           0 :                 m_pTopMF->SetValue(0);
    1072           0 :                 m_pBottomMF->SetValue(0);
    1073             :             }
    1074             :         }
    1075             :         // for tables everything is allowed
    1076           0 :         sal_uInt16 nValid = VALID_TOP|VALID_BOTTOM|VALID_LEFT|VALID_RIGHT;
    1077             : 
    1078             :         // for border and paragraph the edit is disabled, if there's no border set
    1079           0 :         if(nSWMode & (SW_BORDER_MODE_FRAME|SW_BORDER_MODE_PARA))
    1080             :         {
    1081           0 :             if(bLineSet)
    1082             :             {
    1083           0 :                 nValid  = (m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_TOP)    == svx::FRAMESTATE_SHOW) ? VALID_TOP : 0;
    1084           0 :                 nValid |= (m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_BOTTOM) == svx::FRAMESTATE_SHOW) ? VALID_BOTTOM : 0;
    1085           0 :                 nValid |= (m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_LEFT)   == svx::FRAMESTATE_SHOW) ? VALID_LEFT : 0;
    1086           0 :                 nValid |= (m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_RIGHT ) == svx::FRAMESTATE_SHOW) ? VALID_RIGHT : 0;
    1087             :             }
    1088             :             else
    1089           0 :                 nValid = 0;
    1090             :         }
    1091           0 :         m_pLeftFT->Enable(0 != (nValid&VALID_LEFT));
    1092           0 :         m_pRightFT->Enable(0 != (nValid&VALID_RIGHT));
    1093           0 :         m_pTopFT->Enable(0 != (nValid&VALID_TOP));
    1094           0 :         m_pBottomFT->Enable(0 != (nValid&VALID_BOTTOM));
    1095           0 :         m_pLeftMF->Enable(0 != (nValid&VALID_LEFT));
    1096           0 :         m_pRightMF->Enable(0 != (nValid&VALID_RIGHT));
    1097           0 :         m_pTopMF->Enable(0 != (nValid&VALID_TOP));
    1098           0 :         m_pBottomMF->Enable(0 != (nValid&VALID_BOTTOM));
    1099           0 :         m_pSynchronizeCB->Enable( m_pRightMF->IsEnabled() || m_pTopMF->IsEnabled() ||
    1100           0 :                                m_pBottomMF->IsEnabled() || m_pLeftMF->IsEnabled() );
    1101             :     }
    1102           0 :     return 0;
    1103             : }
    1104             : 
    1105             : // -----------------------------------------------------------------------
    1106             : 
    1107           0 : IMPL_LINK( SvxBorderTabPage, ModifyDistanceHdl_Impl, MetricField*, pField)
    1108             : {
    1109           0 :     if ( mbSync )
    1110             :     {
    1111           0 :         sal_Int64 nVal = pField->GetValue();
    1112           0 :         if(pField != m_pLeftMF)
    1113           0 :             m_pLeftMF->SetValue(nVal);
    1114           0 :         if(pField != m_pRightMF)
    1115           0 :             m_pRightMF->SetValue(nVal);
    1116           0 :         if(pField != m_pTopMF)
    1117           0 :             m_pTopMF->SetValue(nVal);
    1118           0 :         if(pField != m_pBottomMF)
    1119           0 :             m_pBottomMF->SetValue(nVal);
    1120             :     }
    1121           0 :     return 0;
    1122             : }
    1123             : 
    1124           0 : IMPL_LINK( SvxBorderTabPage, SyncHdl_Impl, CheckBox*, pBox)
    1125             : {
    1126           0 :     mbSync = pBox->IsChecked();
    1127           0 :     return 0;
    1128             : }
    1129             : 
    1130           0 : void SvxBorderTabPage::DataChanged( const DataChangedEvent& rDCEvt )
    1131             : {
    1132           0 :     if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
    1133           0 :         FillValueSets();
    1134             : 
    1135           0 :     SfxTabPage::DataChanged( rDCEvt );
    1136           0 : }
    1137             : 
    1138           0 : void SvxBorderTabPage::PageCreated (SfxAllItemSet aSet)
    1139             : {
    1140           0 :     SFX_ITEMSET_ARG (&aSet,pSWModeItem,SfxUInt16Item,SID_SWMODE_TYPE,sal_False);
    1141           0 :     SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,sal_False);
    1142           0 :     if (pSWModeItem)
    1143             :     {
    1144           0 :         nSWMode = pSWModeItem->GetValue();
    1145             :         // #i43593#
    1146             :         // show checkbox <m_pMergeWithNextCB> for format.paragraph
    1147           0 :         if ( nSWMode == SW_BORDER_MODE_PARA )
    1148             :         {
    1149           0 :             m_pMergeWithNextCB->Show();
    1150           0 :             m_pPropertiesFrame->Show();
    1151             :         }
    1152             :         // show checkbox <m_pMergeAdjacentBordersCB> for format.paragraph
    1153           0 :         else if ( nSWMode == SW_BORDER_MODE_TABLE )
    1154             :         {
    1155           0 :             m_pMergeAdjacentBordersCB->Show();
    1156           0 :             m_pPropertiesFrame->Show();
    1157             :         }
    1158             :     }
    1159           0 :     if (pFlagItem)
    1160           0 :         if ( ( pFlagItem->GetValue() & SVX_HIDESHADOWCTL ) == SVX_HIDESHADOWCTL )
    1161           0 :             HideShadowControls();
    1162           0 : }
    1163             : 
    1164             : // ============================================================================
    1165             : 
    1166             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10