LCOV - code coverage report
Current view: top level - cui/source/tabpages - borderconn.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 82 0.0 %
Date: 2012-08-25 Functions: 0 31 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 122 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 "borderconn.hxx"
      30                 :            : #include <svx/frmsel.hxx>
      31                 :            : #include "editeng/bolnitem.hxx"
      32                 :            : #include <editeng/boxitem.hxx>
      33                 :            : #include <svx/algitem.hxx>
      34                 :            : #include <editeng/shaditem.hxx>
      35                 :            : 
      36                 :            : namespace svx {
      37                 :            : 
      38                 :            : /* ============================================================================
      39                 :            : SvxLineItem connection
      40                 :            : ----------------------
      41                 :            : Connects an SvxLineItem (that contains the style of one line of a cell border)
      42                 :            : with one frame border from a svx::FrameSelector control. If this connection is
      43                 :            : used, no additional code is needed in the Reset() and FillItemSet() functions
      44                 :            : of the tab page.
      45                 :            : ============================================================================ */
      46                 :            : 
      47                 :            : // 1st: item wrappers ---------------------------------------------------------
      48                 :            : 
      49                 :            : class LineItemWrapper : public sfx::SingleItemWrapper< SvxLineItem, const editeng::SvxBorderLine* >
      50                 :            : {
      51                 :            : public:
      52                 :          0 :     inline explicit     LineItemWrapper( sal_uInt16 nSlot ) : SingleItemWrapperType( nSlot ) {}
      53                 :            : 
      54         [ #  # ]:          0 :     virtual ~LineItemWrapper() {}
      55                 :            : 
      56                 :          0 :     virtual const editeng::SvxBorderLine* GetItemValue( const SvxLineItem& rItem ) const
      57                 :          0 :                             { return rItem.GetLine(); }
      58                 :          0 :     virtual void        SetItemValue( SvxLineItem& rItem, const editeng::SvxBorderLine* pLine ) const
      59                 :          0 :                             { rItem.SetLine( pLine ); }
      60                 :            : };
      61                 :            : 
      62                 :            : // 2nd: control wrappers ------------------------------------------------------
      63                 :            : 
      64         [ #  # ]:          0 : class FrameSelectorWrapper : public sfx::SingleControlWrapper< FrameSelector, const editeng::SvxBorderLine* >
      65                 :            : {
      66                 :            : public:
      67                 :          0 :     inline explicit     FrameSelectorWrapper( FrameSelector& rFrameSel, FrameBorderType eBorder ) :
      68                 :          0 :                             SingleControlWrapperType( rFrameSel ), meBorder( eBorder ) {}
      69                 :            : 
      70                 :            :     virtual bool        IsControlDontKnow() const;
      71                 :            :     virtual void        SetControlDontKnow( bool bSet );
      72                 :            : 
      73                 :            :     virtual const editeng::SvxBorderLine* GetControlValue() const;
      74                 :            :     virtual void        SetControlValue( const editeng::SvxBorderLine* pLine );
      75                 :            : 
      76                 :            : private:
      77                 :            :     FrameBorderType       meBorder;         /// The line this wrapper works with.
      78                 :            : };
      79                 :            : 
      80                 :          0 : bool FrameSelectorWrapper::IsControlDontKnow() const
      81                 :            : {
      82                 :          0 :     return GetControl().GetFrameBorderState( meBorder ) == FRAMESTATE_DONTCARE;
      83                 :            : }
      84                 :            : 
      85                 :          0 : void FrameSelectorWrapper::SetControlDontKnow( bool bSet )
      86                 :            : {
      87         [ #  # ]:          0 :     if( bSet )
      88                 :          0 :         GetControl().SetBorderDontCare( meBorder );
      89                 :          0 : }
      90                 :            : 
      91                 :          0 : const editeng::SvxBorderLine* FrameSelectorWrapper::GetControlValue() const
      92                 :            : {
      93                 :          0 :     return GetControl().GetFrameBorderStyle( meBorder );
      94                 :            : }
      95                 :            : 
      96                 :          0 : void FrameSelectorWrapper::SetControlValue( const editeng::SvxBorderLine* pLine )
      97                 :            : {
      98                 :          0 :     GetControl().ShowBorder( meBorder, pLine );
      99                 :          0 : }
     100                 :            : 
     101                 :            : // 3rd: connection ------------------------------------------------------------
     102                 :            : 
     103                 :            : typedef sfx::ItemControlConnection< LineItemWrapper, FrameSelectorWrapper > FrameLineConnection;
     104                 :            : 
     105                 :            : /* ============================================================================
     106                 :            : SvxMarginItem connection
     107                 :            : ------------------------
     108                 :            : Connects an SvxMarginItem (that contains the inner margin of all cell borders)
     109                 :            : with the numerical edit controls of the SvxBorderTabPage. If this connection is
     110                 :            : used, no additional code is needed in the Reset() and FillItemSet() functions
     111                 :            : of the tab page.
     112                 :            : ============================================================================ */
     113                 :            : 
     114                 :            : // 1st: item wrappers ---------------------------------------------------------
     115                 :            : 
     116                 :            : typedef sfx::IdentItemWrapper< SvxMarginItem > MarginItemWrapper;
     117                 :            : 
     118                 :            : // 2nd: control wrappers ------------------------------------------------------
     119                 :            : 
     120 [ #  # ][ #  # ]:          0 : class MarginControlsWrapper : public sfx::MultiControlWrapper< SvxMarginItem >
         [ #  # ][ #  # ]
                 [ #  # ]
     121                 :            : {
     122                 :            : public:
     123                 :            :     explicit            MarginControlsWrapper(
     124                 :            :                             MetricField& rMfLeft, MetricField& rMfRight,
     125                 :            :                             MetricField& rMfTop, MetricField& rMfBottom );
     126                 :            : 
     127                 :            :     virtual SvxMarginItem GetControlValue() const;
     128                 :            :     virtual void        SetControlValue( SvxMarginItem aItem );
     129                 :            : 
     130                 :            : private:
     131                 :            :     sfx::Int16MetricFieldWrapper maLeftWrp;
     132                 :            :     sfx::Int16MetricFieldWrapper maRightWrp;
     133                 :            :     sfx::Int16MetricFieldWrapper maTopWrp;
     134                 :            :     sfx::Int16MetricFieldWrapper maBottomWrp;
     135                 :            : };
     136                 :            : 
     137                 :          0 : MarginControlsWrapper::MarginControlsWrapper(
     138                 :            :         MetricField& rMfLeft, MetricField& rMfRight, MetricField& rMfTop, MetricField& rMfBottom ) :
     139                 :            :     maLeftWrp( rMfLeft, FUNIT_TWIP ),
     140                 :            :     maRightWrp( rMfRight, FUNIT_TWIP ),
     141                 :            :     maTopWrp( rMfTop, FUNIT_TWIP ),
     142 [ #  # ][ #  # ]:          0 :     maBottomWrp( rMfBottom, FUNIT_TWIP )
         [ #  # ][ #  # ]
     143                 :            : {
     144         [ #  # ]:          0 :     RegisterControlWrapper( maLeftWrp );
     145         [ #  # ]:          0 :     RegisterControlWrapper( maRightWrp );
     146         [ #  # ]:          0 :     RegisterControlWrapper( maTopWrp );
     147         [ #  # ]:          0 :     RegisterControlWrapper( maBottomWrp );
     148                 :          0 : }
     149                 :            : 
     150                 :          0 : SvxMarginItem MarginControlsWrapper::GetControlValue() const
     151                 :            : {
     152                 :          0 :     SvxMarginItem aItem( GetDefaultValue() );
     153 [ #  # ][ #  # ]:          0 :     if( !maLeftWrp.IsControlDontKnow() )
     154 [ #  # ][ #  # ]:          0 :         aItem.SetLeftMargin( maLeftWrp.GetControlValue() );
     155 [ #  # ][ #  # ]:          0 :     if( !maRightWrp.IsControlDontKnow() )
     156 [ #  # ][ #  # ]:          0 :         aItem.SetRightMargin( maRightWrp.GetControlValue() );
     157 [ #  # ][ #  # ]:          0 :     if( !maTopWrp.IsControlDontKnow() )
     158 [ #  # ][ #  # ]:          0 :         aItem.SetTopMargin( maTopWrp.GetControlValue() );
     159 [ #  # ][ #  # ]:          0 :     if( !maBottomWrp.IsControlDontKnow() )
     160 [ #  # ][ #  # ]:          0 :         aItem.SetBottomMargin( maBottomWrp.GetControlValue() );
     161                 :          0 :     return aItem;
     162                 :            : }
     163                 :            : 
     164                 :          0 : void MarginControlsWrapper::SetControlValue( SvxMarginItem aItem )
     165                 :            : {
     166                 :          0 :     maLeftWrp.SetControlValue( aItem.GetLeftMargin() );
     167                 :          0 :     maRightWrp.SetControlValue( aItem.GetRightMargin() );
     168                 :          0 :     maTopWrp.SetControlValue( aItem.GetTopMargin() );
     169                 :          0 :     maBottomWrp.SetControlValue( aItem.GetBottomMargin() );
     170                 :          0 : }
     171                 :            : 
     172                 :            : // 3rd: connection ------------------------------------------------------------
     173                 :            : 
     174         [ #  # ]:          0 : class MarginConnection : public sfx::ItemControlConnection< MarginItemWrapper, MarginControlsWrapper >
     175                 :            : {
     176                 :            : public:
     177                 :            :     explicit            MarginConnection( const SfxItemSet& rItemSet,
     178                 :            :                             MetricField& rMfLeft, MetricField& rMfRight,
     179                 :            :                             MetricField& rMfTop, MetricField& rMfBottom,
     180                 :            :                             sfx::ItemConnFlags nFlags = sfx::ITEMCONN_DEFAULT );
     181                 :            : };
     182                 :            : 
     183                 :          0 : MarginConnection::MarginConnection( const SfxItemSet& rItemSet,
     184                 :            :         MetricField& rMfLeft, MetricField& rMfRight, MetricField& rMfTop, MetricField& rMfBottom,
     185                 :            :         sfx::ItemConnFlags nFlags ) :
     186         [ #  # ]:          0 :     ItemControlConnectionType( SID_ATTR_ALIGN_MARGIN, new MarginControlsWrapper( rMfLeft, rMfRight, rMfTop, rMfBottom ), nFlags )
     187                 :            : {
     188         [ #  # ]:          0 :     mxCtrlWrp->SetDefaultValue( maItemWrp.GetDefaultItem( rItemSet ) );
     189                 :          0 : }
     190                 :            : 
     191                 :            : /* ============================================================================
     192                 :            : SvxShadowItem connection
     193                 :            : ------------------------
     194                 :            : Connects an SvxShadowItem (that contains shadow position, size, and color) with
     195                 :            : the controls of the SvxBorderTabPage. If this connection is used, no additional
     196                 :            : code is needed in the Reset() and FillItemSet() functions of the tab page.
     197                 :            : ============================================================================ */
     198                 :            : 
     199                 :            : // 1st: item wrappers ---------------------------------------------------------
     200                 :            : 
     201                 :            : typedef sfx::IdentItemWrapper< SvxShadowItem > ShadowItemWrapper;
     202                 :            : 
     203                 :            : // 2nd: control wrappers ------------------------------------------------------
     204                 :            : 
     205                 :            : typedef sfx::ValueSetWrapper< SvxShadowLocation > ShadowPosWrapper;
     206                 :            : static const ShadowPosWrapper::MapEntryType s_pShadowPosMap[] =
     207                 :            : {
     208                 :            :     { 1,                        SVX_SHADOW_NONE         },
     209                 :            :     { 2,                        SVX_SHADOW_BOTTOMRIGHT  },
     210                 :            :     { 3,                        SVX_SHADOW_TOPRIGHT     },
     211                 :            :     { 4,                        SVX_SHADOW_BOTTOMLEFT   },
     212                 :            :     { 5,                        SVX_SHADOW_TOPLEFT      },
     213                 :            :     { VALUESET_ITEM_NOTFOUND,   SVX_SHADOW_NONE         }
     214                 :            : };
     215                 :            : 
     216 [ #  # ][ #  # ]:          0 : class ShadowControlsWrapper : public sfx::MultiControlWrapper< SvxShadowItem >
         [ #  # ][ #  # ]
     217                 :            : {
     218                 :            : public:
     219                 :            :     explicit            ShadowControlsWrapper( ValueSet& rVsPos, MetricField& rMfSize, ColorListBox& rLbColor );
     220                 :            : 
     221                 :            :     virtual SvxShadowItem GetControlValue() const;
     222                 :            :     virtual void        SetControlValue( SvxShadowItem aItem );
     223                 :            : 
     224                 :            : private:
     225                 :            :     ShadowPosWrapper                maPosWrp;
     226                 :            :     sfx::UShortMetricFieldWrapper   maSizeWrp;
     227                 :            :     sfx::ColorListBoxWrapper        maColorWrp;
     228                 :            : };
     229                 :            : 
     230                 :          0 : ShadowControlsWrapper::ShadowControlsWrapper(
     231                 :            :         ValueSet& rVsPos, MetricField& rMfSize, ColorListBox& rLbColor ) :
     232                 :            :     maPosWrp( rVsPos, s_pShadowPosMap ),
     233                 :            :     maSizeWrp( rMfSize, FUNIT_TWIP ),
     234 [ #  # ][ #  # ]:          0 :     maColorWrp( rLbColor )
                 [ #  # ]
     235                 :            : {
     236         [ #  # ]:          0 :     RegisterControlWrapper( maPosWrp );
     237         [ #  # ]:          0 :     RegisterControlWrapper( maSizeWrp );
     238         [ #  # ]:          0 :     RegisterControlWrapper( maColorWrp );
     239                 :          0 : }
     240                 :            : 
     241                 :          0 : SvxShadowItem ShadowControlsWrapper::GetControlValue() const
     242                 :            : {
     243                 :          0 :     SvxShadowItem aItem( GetDefaultValue() );
     244 [ #  # ][ #  # ]:          0 :     if( !maPosWrp.IsControlDontKnow() )
     245         [ #  # ]:          0 :         aItem.SetLocation( maPosWrp.GetControlValue() );
     246 [ #  # ][ #  # ]:          0 :     if( !maSizeWrp.IsControlDontKnow() )
     247         [ #  # ]:          0 :         aItem.SetWidth( maSizeWrp.GetControlValue() );
     248 [ #  # ][ #  # ]:          0 :     if( !maColorWrp.IsControlDontKnow() )
     249         [ #  # ]:          0 :         aItem.SetColor( maColorWrp.GetControlValue() );
     250                 :          0 :     return aItem;
     251                 :            : }
     252                 :            : 
     253                 :          0 : void ShadowControlsWrapper::SetControlValue( SvxShadowItem aItem )
     254                 :            : {
     255                 :          0 :     maPosWrp.SetControlValue( aItem.GetLocation() );
     256                 :          0 :     maSizeWrp.SetControlValue( aItem.GetWidth() );
     257                 :          0 :     maColorWrp.SetControlValue( aItem.GetColor() );
     258                 :          0 : }
     259                 :            : 
     260                 :            : // 3rd: connection ------------------------------------------------------------
     261                 :            : 
     262         [ #  # ]:          0 : class ShadowConnection : public sfx::ItemControlConnection< ShadowItemWrapper, ShadowControlsWrapper >
     263                 :            : {
     264                 :            : public:
     265                 :            :     explicit            ShadowConnection( const SfxItemSet& rItemSet,
     266                 :            :                                 ValueSet& rVsPos, MetricField& rMfSize, ColorListBox& rLbColor,
     267                 :            :                                 sfx::ItemConnFlags nFlags = sfx::ITEMCONN_DEFAULT );
     268                 :            : };
     269                 :            : 
     270                 :          0 : ShadowConnection::ShadowConnection( const SfxItemSet& rItemSet,
     271                 :            :         ValueSet& rVsPos, MetricField& rMfSize, ColorListBox& rLbColor, sfx::ItemConnFlags nFlags ) :
     272         [ #  # ]:          0 :     ItemControlConnectionType( SID_ATTR_BORDER_SHADOW, new ShadowControlsWrapper( rVsPos, rMfSize, rLbColor ), nFlags )
     273                 :            : {
     274         [ #  # ]:          0 :     mxCtrlWrp->SetDefaultValue( maItemWrp.GetDefaultItem( rItemSet ) );
     275                 :          0 : }
     276                 :            : 
     277                 :            : // ============================================================================
     278                 :            : // ============================================================================
     279                 :            : 
     280                 :          0 : sfx::ItemConnectionBase* CreateFrameLineConnection( sal_uInt16 nSlot,
     281                 :            :         FrameSelector& rFrameSel, FrameBorderType eBorder, sfx::ItemConnFlags nFlags )
     282                 :            : {
     283 [ #  # ][ #  # ]:          0 :     return new FrameLineConnection( nSlot, new FrameSelectorWrapper( rFrameSel, eBorder ), nFlags );
     284                 :            : }
     285                 :            : 
     286                 :          0 : sfx::ItemConnectionBase* CreateMarginConnection( const SfxItemSet& rItemSet,
     287                 :            :         MetricField& rMfLeft, MetricField& rMfRight,
     288                 :            :         MetricField& rMfTop, MetricField& rMfBottom,
     289                 :            :         sfx::ItemConnFlags nFlags )
     290                 :            : {
     291         [ #  # ]:          0 :     return new MarginConnection( rItemSet, rMfLeft, rMfRight, rMfTop, rMfBottom, nFlags );
     292                 :            : }
     293                 :            : 
     294                 :          0 : sfx::ItemConnectionBase* CreateShadowConnection( const SfxItemSet& rItemSet,
     295                 :            :         ValueSet& rVsPos, MetricField& rMfSize, ColorListBox& rLbColor,
     296                 :            :         sfx::ItemConnFlags nFlags )
     297                 :            : {
     298         [ #  # ]:          0 :     return new ShadowConnection( rItemSet, rVsPos, rMfSize, rLbColor, nFlags );
     299                 :            : }
     300                 :            : 
     301                 :            : // ============================================================================
     302                 :            : 
     303                 :            : } // namespace svx
     304                 :            : 
     305                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10