LCOV - code coverage report
Current view: top level - sd/source/ui/table - TableDesignPane.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 273 412 66.3 %
Date: 2012-08-25 Functions: 21 33 63.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 314 935 33.6 %

           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                 :            : 
      30                 :            : #include "sddll.hxx"
      31                 :            : 
      32                 :            : #include <com/sun/star/beans/XMultiPropertyStates.hpp>
      33                 :            : #include <com/sun/star/frame/XController.hpp>
      34                 :            : #include <com/sun/star/view/XSelectionSupplier.hpp>
      35                 :            : #include <com/sun/star/style/XStyle.hpp>
      36                 :            : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
      37                 :            : 
      38                 :            : #include <comphelper/processfactory.hxx>
      39                 :            : #include <sfx2/viewfrm.hxx>
      40                 :            : #include <vcl/bmpacc.hxx>
      41                 :            : #include <svl/style.hxx>
      42                 :            : #include <sfx2/bindings.hxx>
      43                 :            : #include <sfx2/app.hxx>
      44                 :            : #include <sfx2/request.hxx>
      45                 :            : #include <sfx2/dispatch.hxx>
      46                 :            : #include <svx/svxids.hrc>
      47                 :            : #include <svx/svdetc.hxx>
      48                 :            : #include <editeng/boxitem.hxx>
      49                 :            : #include <editeng/borderline.hxx>
      50                 :            : #include <editeng/colritem.hxx>
      51                 :            : #include <editeng/eeitem.hxx>
      52                 :            : #include <svx/sdr/table/tabledesign.hxx>
      53                 :            : 
      54                 :            : #include "TableDesignPane.hxx"
      55                 :            : #include <svtools/valueset.hxx>
      56                 :            : 
      57                 :            : #include "DrawDocShell.hxx"
      58                 :            : #include "ViewShellBase.hxx"
      59                 :            : #include "DrawViewShell.hxx"
      60                 :            : #include "DrawController.hxx"
      61                 :            : #include "glob.hrc"
      62                 :            : #include "sdresid.hxx"
      63                 :            : #include "EventMultiplexer.hxx"
      64                 :            : 
      65                 :            : using ::rtl::OUString;
      66                 :            : using namespace ::com::sun::star;
      67                 :            : using namespace ::com::sun::star::uno;
      68                 :            : using namespace ::com::sun::star::drawing;
      69                 :            : using namespace ::com::sun::star::container;
      70                 :            : using namespace ::com::sun::star::beans;
      71                 :            : using namespace ::com::sun::star::view;
      72                 :            : using namespace ::com::sun::star::style;
      73                 :            : using namespace ::com::sun::star::frame;
      74                 :            : using namespace ::com::sun::star::lang;
      75                 :            : using namespace ::com::sun::star::ui;
      76                 :            : 
      77                 :            : namespace sd {
      78                 :            : 
      79                 :            : static const sal_Int32 nPreviewColumns = 5;
      80                 :            : static const sal_Int32 nPreviewRows = 5;
      81                 :            : 
      82                 :            : // --------------------------------------------------------------------
      83                 :            : 
      84                 :         17 : static const OUString* getPropertyNames()
      85                 :            : {
      86                 :            :     static const OUString gPropNames[ CB_BANDED_COLUMNS-CB_HEADER_ROW+1 ] =
      87                 :            :     {
      88                 :            :         OUString("UseFirstRowStyle") ,
      89                 :            :         OUString("UseLastRowStyle") ,
      90                 :            :         OUString("UseBandingRowStyle") ,
      91                 :            :         OUString("UseFirstColumnStyle") ,
      92                 :            :         OUString("UseLastColumnStyle") ,
      93                 :            :         OUString("UseBandingColumnStyle")
      94 [ +  + ][ +  - ]:         73 :     };
                 [ +  + ]
      95                 :         17 :     return &gPropNames[0];
      96                 :            : }
      97                 :            : // --------------------------------------------------------------------
      98                 :            : 
      99                 :         17 : TableDesignPane::TableDesignPane( ::Window* pParent, ViewShellBase& rBase, bool bModal )
     100                 :            : : Control( pParent, SdResId(DLG_TABLEDESIGNPANE) )
     101                 :            : , mrBase( rBase )
     102                 :            : , msTableTemplate( "TableTemplate" )
     103                 :            : , mbModal( bModal )
     104                 :            : , mbStyleSelected( false )
     105 [ +  - ][ +  + ]:        170 : , mbOptionsChanged( false )
     106                 :            : {
     107         [ -  + ]:         17 :     Window* pControlParent = mbModal ? pParent : this;
     108                 :            : 
     109 [ +  - ][ +  - ]:         17 :     mxControls[FL_TABLE_STYLES].reset( new FixedLine( pControlParent, SdResId( FL_TABLE_STYLES + 1 ) ) );
         [ +  - ][ +  - ]
     110                 :            : 
     111 [ +  - ][ +  - ]:         17 :     ValueSet* pValueSet = new ValueSet( pControlParent, SdResId( CT_TABLE_STYLES+1 ) );
                 [ +  - ]
     112         [ +  - ]:         17 :     mxControls[CT_TABLE_STYLES].reset( pValueSet );
     113         [ +  - ]:         17 :     if( !mbModal )
     114                 :            :     {
     115 [ +  - ][ +  - ]:         17 :         pValueSet->SetStyle( (pValueSet->GetStyle() & ~(WB_ITEMBORDER|WB_BORDER)) | WB_NO_DIRECTSELECT | WB_FLATVALUESET | WB_NOBORDER );
     116         [ +  - ]:         17 :         pValueSet->SetColor();
     117         [ +  - ]:         17 :         pValueSet->SetExtraSpacing(8);
     118                 :            :     }
     119                 :            :     else
     120                 :            :     {
     121         [ #  # ]:          0 :         pValueSet->SetColor( Color( COL_WHITE ) );
     122 [ #  # ][ #  # ]:          0 :         pValueSet->SetBackground( Color( COL_WHITE ) );
                 [ #  # ]
     123                 :            :     }
     124         [ +  - ]:         17 :     pValueSet->SetSelectHdl (LINK(this, TableDesignPane, implValueSetHdl));
     125                 :            : 
     126 [ +  - ][ +  - ]:         17 :     mxControls[FL_STYLE_OPTIONS].reset( new FixedLine( pControlParent, SdResId( FL_STYLE_OPTIONS + 1 ) ) );
         [ +  - ][ +  - ]
     127                 :            :     sal_uInt16 i;
     128         [ +  + ]:        119 :     for( i = CB_HEADER_ROW; i <= CB_BANDED_COLUMNS; ++i )
     129                 :            :     {
     130 [ +  - ][ +  - ]:        102 :         CheckBox *pCheckBox = new CheckBox( pControlParent, SdResId( i+1 ) );
                 [ +  - ]
     131         [ +  - ]:        102 :         mxControls[i].reset( pCheckBox );
     132         [ +  - ]:        102 :         pCheckBox->SetClickHdl( LINK( this, TableDesignPane, implCheckBoxHdl ) );
     133                 :            :     }
     134                 :            : 
     135         [ +  + ]:        170 :     for( i = 0; i < DESIGNPANE_CONTROL_COUNT; i++ )
     136         [ +  - ]:        153 :         mnOrgOffsetY[i] = mxControls[i]->GetPosPixel().Y();
     137                 :            : 
     138                 :            :     // get current controller and initialize listeners
     139                 :            :     try
     140                 :            :     {
     141 [ +  - ][ +  - ]:         17 :         mxView = Reference< XDrawView >::query(mrBase.GetController());
                 [ +  - ]
     142         [ +  - ]:         17 :         addListener();
     143                 :            : 
     144 [ +  - ][ +  - ]:         17 :         Reference< XController > xController( mrBase.GetController(), UNO_QUERY_THROW );
     145 [ +  - ][ +  - ]:         17 :         Reference< XStyleFamiliesSupplier > xFamiliesSupp( xController->getModel(), UNO_QUERY_THROW );
                 [ +  - ]
     146 [ +  - ][ +  - ]:         17 :         Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() );
     147                 :         17 :         const OUString sFamilyName( "table" );
     148 [ +  - ][ +  - ]:         17 :         mxTableFamily = Reference< XIndexAccess >( xFamilies->getByName( sFamilyName ), UNO_QUERY_THROW );
         [ +  - ][ #  # ]
                 [ +  - ]
     149                 :            : 
     150                 :            :     }
     151         [ #  # ]:          0 :     catch( Exception& )
     152                 :            :     {
     153                 :            :         OSL_FAIL( "sd::CustomAnimationPane::CustomAnimationPane(), Exception caught!" );
     154                 :            :     }
     155                 :            : 
     156         [ +  - ]:         17 :     onSelectionChanged();
     157         [ +  - ]:         17 :     updateControls();
     158                 :            : 
     159         [ +  - ]:         17 :     FreeResource();
     160   [ #  #  #  # ]:         17 : }
     161                 :            : 
     162                 :            : // --------------------------------------------------------------------
     163                 :            : 
     164         [ +  - ]:        187 : TableDesignPane::~TableDesignPane()
     165                 :            : {
     166         [ +  - ]:         17 :     removeListener();
     167 [ +  - ][ +  + ]:        204 : }
                 [ -  + ]
           [ #  #  #  # ]
     168                 :            : 
     169                 :            : // --------------------------------------------------------------------
     170                 :            : 
     171                 :          0 : void TableDesignPane::DataChanged( const DataChangedEvent& /*rDCEvt*/ )
     172                 :            : {
     173                 :          0 :     updateLayout();
     174                 :          0 : }
     175                 :            : 
     176                 :            : // --------------------------------------------------------------------
     177                 :            : 
     178                 :         22 : void TableDesignPane::Resize()
     179                 :            : {
     180                 :         22 :     updateLayout();
     181                 :         22 : }
     182                 :            : 
     183                 :            : // --------------------------------------------------------------------
     184                 :            : 
     185                 :          0 : static SfxBindings* getBindings( ViewShellBase& rBase )
     186                 :            : {
     187 [ #  # ][ #  # ]:          0 :     if( rBase.GetMainViewShell().get() && rBase.GetMainViewShell()->GetViewFrame() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
                   #  # ]
     188         [ #  # ]:          0 :         return &rBase.GetMainViewShell()->GetViewFrame()->GetBindings();
     189                 :            :     else
     190                 :          0 :         return 0;
     191                 :            : }
     192                 :            : 
     193                 :            : // --------------------------------------------------------------------
     194                 :            : 
     195                 :          0 : static SfxDispatcher* getDispatcher( ViewShellBase& rBase )
     196                 :            : {
     197 [ #  # ][ #  # ]:          0 :     if( rBase.GetMainViewShell().get() && rBase.GetMainViewShell()->GetViewFrame() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
                   #  # ]
     198         [ #  # ]:          0 :         return rBase.GetMainViewShell()->GetViewFrame()->GetDispatcher();
     199                 :            :     else
     200                 :          0 :         return 0;
     201                 :            : }
     202                 :            : 
     203                 :            : // --------------------------------------------------------------------
     204                 :            : 
     205                 :          0 : IMPL_LINK_NOARG(TableDesignPane, implValueSetHdl)
     206                 :            : {
     207                 :          0 :     mbStyleSelected = true;
     208         [ #  # ]:          0 :     if( !mbModal )
     209                 :          0 :         ApplyStyle();
     210                 :          0 :     return 0;
     211                 :            : }
     212                 :            : 
     213                 :            : // --------------------------------------------------------------------
     214                 :            : 
     215                 :          0 : void TableDesignPane::ApplyStyle()
     216                 :            : {
     217                 :            :     try
     218                 :            :     {
     219                 :          0 :         OUString sStyleName;
     220                 :          0 :         ValueSet* pValueSet = static_cast< ValueSet* >( mxControls[CT_TABLE_STYLES].get() );
     221                 :          0 :         sal_Int32 nIndex = static_cast< sal_Int32 >( pValueSet->GetSelectItemId() ) - 1;
     222                 :            : 
     223 [ #  # ][ #  # ]:          0 :         if( (nIndex >= 0) && (nIndex < mxTableFamily->getCount()) )
         [ #  # ][ #  # ]
                 [ #  # ]
     224                 :            :         {
     225         [ #  # ]:          0 :             Reference< XNameAccess > xNames( mxTableFamily, UNO_QUERY_THROW );
     226 [ #  # ][ #  # ]:          0 :             sStyleName = xNames->getElementNames()[nIndex];
         [ #  # ][ #  # ]
     227                 :            :         }
     228                 :            : 
     229         [ #  # ]:          0 :         if( sStyleName.isEmpty() )
     230                 :          0 :             return;
     231                 :            : 
     232         [ #  # ]:          0 :         SdrView* pView = mrBase.GetDrawView();
     233         [ #  # ]:          0 :         if( mxSelectedTable.is() )
     234                 :            :         {
     235         [ #  # ]:          0 :             if( pView )
     236                 :            :             {
     237 [ #  # ][ #  # ]:          0 :                 SfxRequest aReq( SID_TABLE_STYLE, SFX_CALLMODE_SYNCHRON, SFX_APP()->GetPool() );
     238 [ #  # ][ #  # ]:          0 :                 aReq.AppendItem( SfxStringItem( SID_TABLE_STYLE, sStyleName ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     239                 :            : 
     240         [ #  # ]:          0 :                 rtl::Reference< sdr::SelectionController > xController( pView->getSelectionController() );
     241         [ #  # ]:          0 :                 if( xController.is() )
     242         [ #  # ]:          0 :                     xController->Execute( aReq );
     243                 :            : 
     244         [ #  # ]:          0 :                 SfxBindings* pBindings = getBindings( mrBase );
     245         [ #  # ]:          0 :                 if( pBindings )
     246                 :            :                 {
     247         [ #  # ]:          0 :                     pBindings->Invalidate( SID_UNDO );
     248         [ #  # ]:          0 :                     pBindings->Invalidate( SID_REDO );
     249         [ #  # ]:          0 :                 }
     250                 :            :             }
     251                 :            :         }
     252                 :            :         else
     253                 :            :         {
     254         [ #  # ]:          0 :             SfxDispatcher* pDispatcher = getDispatcher( mrBase );
     255 [ #  # ][ #  # ]:          0 :             SfxStringItem aArg( SID_TABLE_STYLE, sStyleName );
                 [ #  # ]
     256 [ #  # ][ #  # ]:          0 :             pDispatcher->Execute(SID_INSERT_TABLE, SFX_CALLMODE_ASYNCHRON, &aArg, 0 );
     257 [ #  # ][ #  # ]:          0 :         }
     258                 :            :     }
     259                 :          0 :     catch( Exception& )
     260                 :            :     {
     261                 :            :         OSL_FAIL("TableDesignPane::implValueSetHdl(), exception caught!");
     262                 :            :     }
     263                 :            : }
     264                 :            : 
     265                 :            : // --------------------------------------------------------------------
     266                 :            : 
     267                 :          0 : IMPL_LINK_NOARG(TableDesignPane, implCheckBoxHdl)
     268                 :            : {
     269                 :          0 :     mbOptionsChanged = true;
     270                 :            : 
     271         [ #  # ]:          0 :     if( !mbModal )
     272                 :          0 :         ApplyOptions();
     273                 :            : 
     274                 :          0 :     FillDesignPreviewControl();
     275                 :          0 :     return 0;
     276                 :            : }
     277                 :            : 
     278                 :            : // --------------------------------------------------------------------
     279                 :            : 
     280                 :          0 : void TableDesignPane::ApplyOptions()
     281                 :            : {
     282                 :            :     static sal_uInt16 gParamIds[CB_BANDED_COLUMNS-CB_HEADER_ROW+1] =
     283                 :            :     {
     284                 :            :         ID_VAL_USEFIRSTROWSTYLE, ID_VAL_USELASTROWSTYLE, ID_VAL_USEBANDINGROWSTYLE,
     285                 :            :         ID_VAL_USEFIRSTCOLUMNSTYLE, ID_VAL_USELASTCOLUMNSTYLE, ID_VAL_USEBANDINGCOLUMNSTYLE
     286                 :            :     };
     287                 :            : 
     288         [ #  # ]:          0 :     if( mxSelectedTable.is() )
     289                 :            :     {
     290 [ #  # ][ #  # ]:          0 :         SfxRequest aReq( SID_TABLE_STYLE_SETTINGS, SFX_CALLMODE_SYNCHRON, SFX_APP()->GetPool() );
     291                 :            : 
     292         [ #  # ]:          0 :         for( sal_uInt16 i = 0; i < (CB_BANDED_COLUMNS-CB_HEADER_ROW+1); ++i )
     293                 :            :         {
     294 [ #  # ][ #  # ]:          0 :             aReq.AppendItem( SfxBoolItem( gParamIds[i], static_cast< CheckBox* >( mxControls[CB_HEADER_ROW+i].get() )->IsChecked() ) );
         [ #  # ][ #  # ]
     295                 :            :         }
     296                 :            : 
     297         [ #  # ]:          0 :         SdrView* pView = mrBase.GetDrawView();
     298         [ #  # ]:          0 :         if( pView )
     299                 :            :         {
     300         [ #  # ]:          0 :             rtl::Reference< sdr::SelectionController > xController( pView->getSelectionController() );
     301         [ #  # ]:          0 :             if( xController.is() )
     302                 :            :             {
     303         [ #  # ]:          0 :                 xController->Execute( aReq );
     304                 :            : 
     305         [ #  # ]:          0 :                 SfxBindings* pBindings = getBindings( mrBase );
     306         [ #  # ]:          0 :                 if( pBindings )
     307                 :            :                 {
     308         [ #  # ]:          0 :                     pBindings->Invalidate( SID_UNDO );
     309         [ #  # ]:          0 :                     pBindings->Invalidate( SID_REDO );
     310                 :            :                 }
     311                 :          0 :             }
     312         [ #  # ]:          0 :         }
     313                 :            :     }
     314                 :          0 : }
     315                 :            : 
     316                 :            : // --------------------------------------------------------------------
     317                 :            : 
     318                 :         34 : void TableDesignPane::onSelectionChanged()
     319                 :            : {
     320                 :         34 :     Reference< XPropertySet > xNewSelection;
     321                 :            : 
     322         [ +  + ]:         34 :     if( mxView.is() ) try
     323                 :            :     {
     324         [ +  - ]:         17 :         Reference< XSelectionSupplier >  xSel( mxView, UNO_QUERY_THROW );
     325         [ +  - ]:         17 :         if (xSel.is())
     326                 :            :         {
     327 [ +  - ][ +  - ]:         17 :             Any aSel( xSel->getSelection() );
     328         [ +  - ]:         17 :             Sequence< XShape > xShapeSeq;
     329 [ +  - ][ -  + ]:         17 :             if( aSel >>= xShapeSeq )
     330                 :            :             {
     331         [ #  # ]:          0 :                 if( xShapeSeq.getLength() == 1 )
     332 [ #  # ][ #  # ]:          0 :                     aSel <<= xShapeSeq[0];
     333                 :            :             }
     334                 :            :             else
     335                 :            :             {
     336         [ +  - ]:         17 :                 Reference< XShapes > xShapes( aSel, UNO_QUERY );
     337 [ -  + ][ #  # ]:         17 :                 if( xShapes.is() && (xShapes->getCount() == 1) )
         [ #  # ][ #  # ]
                 [ -  + ]
     338 [ #  # ][ #  # ]:         17 :                     aSel <<= xShapes->getByIndex(0);
                 [ #  # ]
     339                 :            :             }
     340                 :            : 
     341         [ +  - ]:         17 :             Reference< XShapeDescriptor > xDesc( aSel, UNO_QUERY );
     342 [ -  + ][ #  # ]:         17 :             if( xDesc.is() && ( xDesc->getShapeType() == "com.sun.star.drawing.TableShape" || xDesc->getShapeType() == "com.sun.star.presentation.TableShape" ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ -  + ]
         [ -  + ][ -  +  
             #  #  #  # ]
     343                 :            :             {
     344 [ #  # ][ #  # ]:          0 :                 xNewSelection = Reference< XPropertySet >::query( xDesc );
     345         [ +  - ]:         17 :             }
     346         [ #  # ]:         17 :         }
     347                 :            :     }
     348         [ #  # ]:          0 :     catch( Exception& )
     349                 :            :     {
     350                 :            :         OSL_FAIL( "sd::TableDesignPane::onSelectionChanged(), Exception caught!" );
     351                 :            :     }
     352                 :            : 
     353 [ +  - ][ -  + ]:         34 :     if( mxSelectedTable != xNewSelection )
     354                 :            :     {
     355         [ #  # ]:          0 :         mxSelectedTable = xNewSelection;
     356         [ #  # ]:          0 :         updateControls();
     357                 :         34 :     }
     358                 :         34 : }
     359                 :            : 
     360                 :            : // --------------------------------------------------------------------
     361                 :            : 
     362                 :         39 : void TableDesignPane::updateLayout()
     363                 :            : {
     364         [ +  - ]:         39 :     ::Size aPaneSize( GetSizePixel() );
     365 [ +  - ][ +  - ]:         39 :     if(IsVisible() && aPaneSize.Width() > 0)
         [ +  + ][ +  + ]
     366                 :            :     {
     367 [ +  - ][ +  - ]:         34 :         Point aOffset( LogicToPixel( Point(3,3), MAP_APPFONT ) );
                 [ +  - ]
     368                 :            : 
     369                 :         34 :         ValueSet* pValueSet = static_cast< ValueSet* >( mxControls[CT_TABLE_STYLES].get() );
     370                 :            : 
     371                 :         34 :         Size aValueSetSize;
     372                 :            : 
     373         [ +  - ]:         34 :         if( !mbModal )
     374                 :            :         {
     375         [ +  - ]:         34 :             const long nOptionsHeight = mnOrgOffsetY[CB_BANDED_COLUMNS] + mxControls[CB_BANDED_COLUMNS]->GetSizePixel().Height() + aOffset.Y();
     376                 :            : 
     377                 :         34 :             const long nStylesHeight = aPaneSize.Height() - nOptionsHeight;
     378                 :            : 
     379                 :            :             // set with of controls to size of pane
     380         [ +  + ]:        340 :             for( sal_Int32 nId = 0; nId < DESIGNPANE_CONTROL_COUNT; ++nId )
     381                 :            :             {
     382         [ +  - ]:        306 :                 Size aSize( mxControls[nId]->GetSizePixel() );
     383         [ +  - ]:        306 :                 aSize.Width() = aPaneSize.Width() - aOffset.X() - mxControls[nId]->GetPosPixel().X();
     384         [ +  - ]:        306 :                 mxControls[nId]->SetSizePixel( aSize );
     385         [ +  - ]:        306 :                 mxControls[nId]->SetPaintTransparent(sal_True);
     386         [ +  - ]:        306 :                 mxControls[nId]->SetBackground();
     387                 :            :             }
     388 [ +  - ][ +  - ]:         34 :             aValueSetSize = Size( pValueSet->GetSizePixel().Width(), nStylesHeight - mxControls[FL_TABLE_STYLES]->GetSizePixel().Height() - mnOrgOffsetY[FL_TABLE_STYLES]  );
     389                 :            :         }
     390                 :            :         else
     391                 :            :         {
     392         [ #  # ]:          0 :             aValueSetSize = pValueSet->GetSizePixel();
     393                 :            :         }
     394                 :            : 
     395                 :            : 
     396                 :            :         // Calculate the number of rows and columns.
     397 [ +  - ][ +  - ]:         34 :         if( pValueSet->GetItemCount() > 0 )
     398                 :            :         {
     399 [ +  - ][ +  - ]:         34 :             Image aImage = pValueSet->GetItemImage(pValueSet->GetItemId(0));
     400 [ +  - ][ +  - ]:         34 :             Size aItemSize = pValueSet->CalcItemSizePixel(aImage.GetSizePixel());
     401         [ +  - ]:         34 :             pValueSet->SetItemWidth( aItemSize.Width() );
     402         [ +  - ]:         34 :             pValueSet->SetItemHeight( aItemSize.Height() );
     403                 :            : 
     404                 :         34 :             aItemSize.Width() += 10;
     405                 :         34 :             aItemSize.Height() += 10;
     406         [ +  - ]:         34 :             int nColumnCount = (aValueSetSize.Width() - pValueSet->GetScrollWidth()) / aItemSize.Width();
     407         [ -  + ]:         34 :             if (nColumnCount < 1)
     408                 :          0 :                 nColumnCount = 1;
     409                 :            : 
     410         [ +  - ]:         34 :             int nRowCount = (pValueSet->GetItemCount() + nColumnCount - 1) / nColumnCount;
     411         [ -  + ]:         34 :             if (nRowCount < 1)
     412                 :          0 :                 nRowCount = 1;
     413                 :            : 
     414                 :         34 :             int nVisibleRowCount = (aValueSetSize.Height()+2) / aItemSize.Height();
     415                 :            : 
     416 [ +  - ][ -  + ]:         34 :             pValueSet->SetLineCount ( (nRowCount < nVisibleRowCount) ? (sal_uInt16)nRowCount : 0 );
     417                 :            : 
     418         [ +  - ]:         34 :             pValueSet->SetColCount ((sal_uInt16)nColumnCount);
     419         [ +  - ]:         34 :             pValueSet->SetLineCount ((sal_uInt16)nRowCount);
     420                 :            : 
     421         [ +  - ]:         34 :             if( !mbModal )
     422                 :            :             {
     423         [ +  - ]:         34 :                 WinBits nStyle = pValueSet->GetStyle() & ~(WB_VSCROLL);
     424         [ -  + ]:         34 :                 if( nRowCount < nVisibleRowCount )
     425                 :            :                 {
     426                 :          0 :                     aValueSetSize.Height() = nRowCount * aItemSize.Height();
     427                 :            :                 }
     428         [ +  + ]:         34 :                 else if( nRowCount > nVisibleRowCount )
     429                 :            :                 {
     430                 :          9 :                     nStyle |= WB_VSCROLL;
     431                 :            :                 }
     432         [ +  - ]:         34 :                 pValueSet->SetStyle( nStyle );
     433         [ +  - ]:         34 :             }
     434                 :            :        }
     435                 :            : 
     436         [ +  - ]:         34 :         if( !mbModal )
     437                 :            :         {
     438         [ +  - ]:         34 :             pValueSet->SetSizePixel( aValueSetSize );
     439 [ +  - ][ +  - ]:         34 :             pValueSet->SetBackground( GetSettings().GetStyleSettings().GetWindowColor() );
                 [ +  - ]
     440         [ +  - ]:         34 :             pValueSet->SetColor( GetSettings().GetStyleSettings().GetWindowColor() );
     441                 :            : 
     442         [ +  - ]:         34 :             Point aPos( pValueSet->GetPosPixel() );
     443                 :            : 
     444                 :            :             // The following line may look like a no-op but without it the
     445                 :            :             // control is placed off-screen when RTL is active.
     446 [ +  - ][ +  - ]:         34 :             pValueSet->SetPosPixel(pValueSet->GetPosPixel());
     447                 :            : 
     448                 :            :             // shift show options section down
     449                 :         34 :             const long nOptionsPos = aPos.Y() + aValueSetSize.Height();
     450         [ +  + ]:        272 :             for( sal_Int32 nId = FL_STYLE_OPTIONS; nId <= CB_BANDED_COLUMNS; ++nId )
     451                 :            :             {
     452         [ +  - ]:        238 :                 Point aCPos( mxControls[nId]->GetPosPixel() );
     453         [ +  + ]:        238 :                 aCPos.X() = ( nId == FL_STYLE_OPTIONS ?  1 : 2 ) * aOffset.X();
     454                 :        238 :                 aCPos.Y() = mnOrgOffsetY[nId] + nOptionsPos;
     455         [ +  - ]:        238 :                 mxControls[nId]->SetPosPixel( aCPos );
     456                 :            :             }
     457                 :            :         }
     458                 :            :     }
     459                 :            : 
     460         [ +  - ]:         39 :     if( !mbModal )
     461 [ +  - ][ +  - ]:         39 :         SetBackground( GetSettings().GetStyleSettings().GetWindowColor() );
                 [ +  - ]
     462                 :         39 : }
     463                 :            : 
     464                 :            : // --------------------------------------------------------------------
     465                 :            : 
     466                 :         17 : void TableDesignPane::updateControls()
     467                 :            : {
     468                 :            :     static sal_Bool gDefaults[CB_BANDED_COLUMNS-CB_HEADER_ROW+1] = { sal_True, sal_False, sal_True, sal_False, sal_False, sal_False };
     469                 :            : 
     470                 :         17 :     const bool bHasTable = mxSelectedTable.is();
     471                 :         17 :     const OUString* pPropNames = getPropertyNames();
     472                 :            : 
     473         [ +  + ]:        119 :     for( sal_uInt16 i = CB_HEADER_ROW; i <= CB_BANDED_COLUMNS; ++i )
     474                 :            :     {
     475                 :        102 :         sal_Bool bUse = gDefaults[i-CB_HEADER_ROW];
     476         [ -  + ]:        102 :         if( bHasTable ) try
     477                 :            :         {
     478 [ #  # ][ #  # ]:          0 :             mxSelectedTable->getPropertyValue( *pPropNames++ ) >>= bUse;
     479                 :            :         }
     480         [ #  # ]:          0 :         catch( Exception& )
     481                 :            :         {
     482                 :            :             OSL_FAIL("sd::TableDesignPane::updateControls(), exception caught!");
     483                 :            :         }
     484 [ +  + ][ +  - ]:        102 :         static_cast< CheckBox* >( mxControls[i].get() )->Check( bUse ? sal_True : sal_False );
     485 [ -  + ][ +  - ]:        102 :         mxControls[i]->Enable(bHasTable ? sal_True : sal_False );
     486                 :            :     }
     487                 :            : 
     488                 :         17 :     FillDesignPreviewControl();
     489                 :         17 :     updateLayout();
     490                 :            : 
     491                 :            : 
     492                 :         17 :     sal_uInt16 nSelection = 0;
     493         [ -  + ]:         17 :     if( mxSelectedTable.is() )
     494                 :            :     {
     495 [ #  # ][ #  # ]:          0 :         Reference< XNamed > xNamed( mxSelectedTable->getPropertyValue( "TableTemplate" ), UNO_QUERY );
                 [ #  # ]
     496         [ #  # ]:          0 :         if( xNamed.is() )
     497                 :            :         {
     498 [ #  # ][ #  # ]:          0 :             const OUString sStyleName( xNamed->getName() );
     499                 :            : 
     500         [ #  # ]:          0 :             Reference< XNameAccess > xNames( mxTableFamily, UNO_QUERY );
     501         [ #  # ]:          0 :             if( xNames.is() )
     502                 :            :             {
     503 [ #  # ][ #  # ]:          0 :                 Sequence< OUString > aNames( xNames->getElementNames() );
     504         [ #  # ]:          0 :                 for( sal_Int32 nIndex = 0; nIndex < aNames.getLength(); nIndex++ )
     505                 :            :                 {
     506 [ #  # ][ #  # ]:          0 :                     if( aNames[nIndex] == sStyleName )
     507                 :            :                     {
     508                 :          0 :                         nSelection = (sal_uInt16)nIndex+1;
     509                 :          0 :                         break;
     510                 :            :                     }
     511         [ #  # ]:          0 :                 }
     512                 :          0 :             }
     513                 :          0 :         }
     514                 :            :     }
     515                 :         17 :     ValueSet* pValueSet = static_cast< ValueSet* >( mxControls[CT_TABLE_STYLES].get() );
     516                 :         17 :     pValueSet->SelectItem( nSelection );
     517         [ #  # ]:         17 : }
     518                 :            : 
     519                 :            : // --------------------------------------------------------------------
     520                 :            : 
     521                 :         17 : void TableDesignPane::addListener()
     522                 :            : {
     523         [ +  - ]:         17 :     Link aLink( LINK(this,TableDesignPane,EventMultiplexerListener) );
     524                 :            :     mrBase.GetEventMultiplexer()->AddEventListener (
     525                 :            :         aLink,
     526                 :            :         tools::EventMultiplexerEvent::EID_EDIT_VIEW_SELECTION
     527                 :            :         | tools::EventMultiplexerEvent::EID_CURRENT_PAGE
     528                 :            :         | tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED
     529                 :            :         | tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED
     530 [ +  - ][ +  - ]:         17 :         | tools::EventMultiplexerEvent::EID_DISPOSING);
                 [ +  - ]
     531                 :         17 : }
     532                 :            : 
     533                 :            : // --------------------------------------------------------------------
     534                 :            : 
     535                 :         17 : void TableDesignPane::removeListener()
     536                 :            : {
     537         [ +  - ]:         17 :     Link aLink( LINK(this,TableDesignPane,EventMultiplexerListener) );
     538 [ +  - ][ +  - ]:         17 :     mrBase.GetEventMultiplexer()->RemoveEventListener( aLink );
                 [ +  - ]
     539                 :         17 : }
     540                 :            : 
     541                 :            : // --------------------------------------------------------------------
     542                 :            : 
     543                 :        230 : IMPL_LINK(TableDesignPane,EventMultiplexerListener,
     544                 :            :     tools::EventMultiplexerEvent*,pEvent)
     545                 :            : {
     546   [ -  +  -  + ]:        230 :     switch (pEvent->meEventId)
     547                 :            :     {
     548                 :            :         case tools::EventMultiplexerEvent::EID_CURRENT_PAGE:
     549                 :            :         case tools::EventMultiplexerEvent::EID_EDIT_VIEW_SELECTION:
     550                 :          0 :             onSelectionChanged();
     551                 :          0 :             break;
     552                 :            : 
     553                 :            :         case tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED:
     554         [ +  - ]:         17 :             mxView = Reference<XDrawView>();
     555                 :         17 :             onSelectionChanged();
     556                 :         17 :             break;
     557                 :            : 
     558                 :            :         case tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED:
     559 [ #  # ][ #  # ]:          0 :             mxView = Reference<XDrawView>::query( mrBase.GetController() );
     560                 :          0 :             onSelectionChanged();
     561                 :          0 :             break;
     562                 :            :     }
     563                 :        230 :     return 0;
     564                 :            : }
     565                 :            : 
     566                 :            : // --------------------------------------------------------------------
     567                 :            : 
     568                 :       1309 : struct CellInfo
     569                 :            : {
     570                 :            :     Color maCellColor;
     571                 :            :     Color maTextColor;
     572                 :            :     SvxBoxItem maBorder;
     573                 :            : 
     574                 :            :     explicit CellInfo( const Reference< XStyle >& xStyle );
     575                 :            : };
     576                 :            : 
     577                 :       1309 : CellInfo::CellInfo( const Reference< XStyle >& xStyle )
     578                 :       1309 : : maBorder(SDRATTR_TABLE_BORDER)
     579                 :            : {
     580         [ +  - ]:       1309 :     SfxStyleSheet* pStyleSheet = SfxUnoStyleSheet::getUnoStyleSheet( xStyle );
     581         [ +  - ]:       1309 :     if( pStyleSheet )
     582                 :            :     {
     583         [ +  - ]:       1309 :         SfxItemSet& rSet = pStyleSheet->GetItemSet();
     584                 :            : 
     585                 :            :         // get style fill color
     586 [ +  - ][ -  + ]:       1309 :         if( !GetDraftFillColor(rSet, maCellColor) )
     587                 :          0 :             maCellColor.SetColor( COL_TRANSPARENT );
     588                 :            : 
     589                 :            :         // get style text color
     590 [ +  - ][ -  + ]:       1309 :         const SvxColorItem* pTextColor = dynamic_cast<const SvxColorItem*>( rSet.GetItem(EE_CHAR_COLOR) );
     591         [ +  - ]:       1309 :         if( pTextColor )
     592                 :       1309 :             maTextColor = pTextColor->GetValue();
     593                 :            :         else
     594                 :          0 :             maTextColor.SetColor( COL_TRANSPARENT );
     595                 :            : 
     596                 :            :         // get border
     597 [ +  - ][ -  + ]:       1309 :         const SvxBoxItem* pBoxItem = dynamic_cast<const SvxBoxItem*>(rSet.GetItem( SDRATTR_TABLE_BORDER ) );
     598         [ +  - ]:       1309 :         if( pBoxItem )
     599         [ +  - ]:       1309 :             maBorder = *pBoxItem;
     600                 :            :     }
     601                 :       1309 : }
     602                 :            : 
     603                 :            : // --------------------------------------------------------------------
     604                 :            : 
     605                 :            : typedef std::vector< boost::shared_ptr< CellInfo > > CellInfoVector;
     606                 :            : typedef boost::shared_ptr< CellInfo > CellInfoMatrix[nPreviewColumns][nPreviewRows];
     607                 :            : 
     608                 :            : struct TableStyleSettings
     609                 :            : {
     610                 :            :     bool mbUseFirstRow;
     611                 :            :     bool mbUseLastRow;
     612                 :            :     bool mbUseFirstColumn;
     613                 :            :     bool mbUseLastColumn;
     614                 :            :     bool mbUseRowBanding;
     615                 :            :     bool mbUseColumnBanding;
     616                 :            : 
     617                 :         17 :     TableStyleSettings()
     618                 :            :         : mbUseFirstRow(true)
     619                 :            :         , mbUseLastRow(false)
     620                 :            :         , mbUseFirstColumn(false)
     621                 :            :         , mbUseLastColumn(false)
     622                 :            :         , mbUseRowBanding(true)
     623                 :         17 :         , mbUseColumnBanding(false) {}
     624                 :            : };
     625                 :            : 
     626                 :            : // --------------------------------------------------------------------
     627                 :            : 
     628                 :        187 : static void FillCellInfoVector( const Reference< XIndexAccess >& xTableStyle, CellInfoVector& rVector )
     629                 :            : {
     630                 :            :     DBG_ASSERT( xTableStyle.is() && (xTableStyle->getCount() == sdr::table::style_count ), "sd::FillCellInfoVector(), inavlid table style!" );
     631         [ +  - ]:        187 :     if( xTableStyle.is() ) try
     632                 :            :     {
     633         [ +  - ]:        187 :         rVector.resize( sdr::table::style_count );
     634                 :            : 
     635         [ +  + ]:       2057 :         for( sal_Int32 nStyle = 0; nStyle < sdr::table::style_count; ++nStyle )
     636                 :            :         {
     637 [ +  - ][ +  - ]:       1870 :             Reference< XStyle > xStyle( xTableStyle->getByIndex( nStyle ), UNO_QUERY );
                 [ +  - ]
     638         [ +  + ]:       1870 :             if( xStyle.is() )
     639 [ +  - ][ +  - ]:       1309 :                 rVector[nStyle].reset( new CellInfo( xStyle ) );
                 [ +  - ]
     640         [ #  # ]:       1870 :         }
     641                 :            :     }
     642                 :          0 :     catch(Exception&)
     643                 :            :     {
     644                 :            :         OSL_FAIL("sd::FillCellInfoVector(), exception caught!");
     645                 :            :     }
     646                 :        187 : }
     647                 :            : 
     648                 :        187 : static void FillCellInfoMatrix( const CellInfoVector& rStyle, const TableStyleSettings& rSettings, CellInfoMatrix& rMatrix )
     649                 :            : {
     650         [ +  + ]:       1122 :     for( sal_Int32 nRow = 0; nRow < nPreviewColumns; ++nRow )
     651                 :            :     {
     652 [ +  - ][ +  + ]:        935 :         const bool bFirstRow = rSettings.mbUseFirstRow && (nRow == 0);
     653 [ -  + ][ #  # ]:        935 :         const bool bLastRow = rSettings.mbUseLastRow && (nRow == nPreviewColumns - 1);
     654                 :            : 
     655         [ +  + ]:       5610 :         for( sal_Int32 nCol = 0; nCol < nPreviewColumns; ++nCol )
     656                 :            :         {
     657         [ +  - ]:       4675 :             boost::shared_ptr< CellInfo > xCellInfo;
     658                 :            : 
     659                 :            :             // first and last row win first, if used and available
     660         [ +  + ]:       4675 :             if( bFirstRow )
     661                 :            :             {
     662         [ +  - ]:        935 :                 xCellInfo = rStyle[sdr::table::first_row_style];
     663                 :            :             }
     664         [ -  + ]:       3740 :             else if( bLastRow )
     665                 :            :             {
     666         [ #  # ]:          0 :                 xCellInfo = rStyle[sdr::table::last_row_style];
     667                 :            :             }
     668                 :            : 
     669         [ +  + ]:       4675 :             if( !xCellInfo.get() )
     670                 :            :             {
     671                 :            :                 // next come first and last column, if used and available
     672 [ -  + ][ #  # ]:       3740 :                 if( rSettings.mbUseFirstColumn && (nCol == 0)  )
     673                 :            :                 {
     674         [ #  # ]:          0 :                     xCellInfo = rStyle[sdr::table::first_column_style];
     675                 :            :                 }
     676 [ -  + ][ #  # ]:       3740 :                 else if( rSettings.mbUseLastColumn && (nCol == nPreviewColumns-1) )
     677                 :            :                 {
     678         [ #  # ]:       3740 :                     xCellInfo = rStyle[sdr::table::last_column_style];
     679                 :            :                 }
     680                 :            :             }
     681                 :            : 
     682         [ +  + ]:       4675 :             if( !xCellInfo.get() )
     683                 :            :             {
     684         [ +  - ]:       3740 :                 if( rSettings.mbUseRowBanding )
     685                 :            :                 {
     686         [ +  + ]:       3740 :                     if( (nRow & 1) == 0 )
     687                 :            :                     {
     688         [ +  - ]:       1870 :                         xCellInfo = rStyle[sdr::table::even_rows_style];
     689                 :            :                     }
     690                 :            :                     else
     691                 :            :                     {
     692         [ +  - ]:       1870 :                         xCellInfo = rStyle[sdr::table::odd_rows_style];
     693                 :            :                     }
     694                 :            :                 }
     695                 :            :             }
     696                 :            : 
     697         [ +  + ]:       4675 :             if( !xCellInfo.get() )
     698                 :            :             {
     699         [ -  + ]:       1870 :                 if( rSettings.mbUseColumnBanding )
     700                 :            :                 {
     701         [ #  # ]:          0 :                     if( (nCol & 1) == 0 )
     702                 :            :                     {
     703         [ #  # ]:          0 :                         xCellInfo = rStyle[sdr::table::even_columns_style];
     704                 :            :                     }
     705                 :            :                     else
     706                 :            :                     {
     707         [ #  # ]:          0 :                         xCellInfo = rStyle[sdr::table::odd_columns_style];
     708                 :            :                     }
     709                 :            :                 }
     710                 :            :             }
     711                 :            : 
     712         [ +  + ]:       4675 :             if( !xCellInfo.get() )
     713                 :            :             {
     714                 :            :                 // use default cell style if non found yet
     715         [ +  - ]:       1870 :                 xCellInfo = rStyle[sdr::table::body_style];
     716                 :            :             }
     717                 :            : 
     718         [ +  - ]:       4675 :             rMatrix[nCol][nRow] = xCellInfo;
     719         [ +  - ]:       4675 :         }
     720                 :            :     }
     721                 :        187 : }
     722                 :            : 
     723                 :            : // --------------------------------------------------------------------
     724                 :            : 
     725                 :        187 : const Bitmap CreateDesignPreview( const Reference< XIndexAccess >& xTableStyle, const TableStyleSettings& rSettings, bool bIsPageDark )
     726                 :            : {
     727         [ +  - ]:        187 :     CellInfoVector aCellInfoVector(sdr::table::style_count);
     728         [ +  - ]:        187 :     FillCellInfoVector( xTableStyle, aCellInfoVector );
     729                 :            : 
     730 [ +  - ][ +  + ]:      10472 :     CellInfoMatrix aMatrix;
         [ +  + ][ +  -  
          #  #  #  #  #  
                #  #  # ]
     731         [ +  - ]:        187 :     FillCellInfoMatrix( aCellInfoVector, rSettings, aMatrix );
     732                 :            : 
     733                 :            : // bbbbbbbbbbbb w = 12 pixel
     734                 :            : // bccccccccccb h = 7 pixel
     735                 :            : // bccccccccccb b = border color
     736                 :            : // bcttttttttcb c = cell color
     737                 :            : // bccccccccccb t = text color
     738                 :            : // bccccccccccb
     739                 :            : // bbbbbbbbbbbb
     740                 :            : 
     741                 :            : 
     742                 :        187 :     const sal_Int32 nCellWidth = 12; // one pixel is shared with the next cell!
     743                 :        187 :     const sal_Int32 nCellHeight = 7; // one pixel is shared with the next cell!
     744                 :            : 
     745         [ +  - ]:        187 :     Bitmap aPreviewBmp( Size( (nCellWidth * nPreviewColumns) - (nPreviewColumns - 1), (nCellHeight * nPreviewRows) - (nPreviewRows - 1)), 24, NULL );
     746         [ +  - ]:        187 :     BitmapWriteAccess* pAccess = aPreviewBmp.AcquireWriteAccess();
     747         [ +  - ]:        187 :     if( pAccess )
     748                 :            :     {
     749 [ -  + ][ +  - ]:        187 :         pAccess->Erase( Color( bIsPageDark ? COL_BLACK : COL_WHITE ) );
     750                 :            : 
     751                 :            :         // first draw cell background and text line previews
     752                 :        187 :         sal_Int32 nY = 0;
     753                 :            :         sal_Int32 nRow;
     754         [ +  + ]:       1122 :         for( nRow = 0; nRow < nPreviewRows; ++nRow, nY += nCellHeight-1 )
     755                 :            :         {
     756                 :        935 :             sal_Int32 nX = 0;
     757         [ +  + ]:       5610 :             for( sal_Int32 nCol = 0; nCol < nPreviewColumns; ++nCol, nX += nCellWidth-1 )
     758                 :            :             {
     759         [ +  - ]:       4675 :                 boost::shared_ptr< CellInfo > xCellInfo( aMatrix[nCol][nRow] );
     760                 :            : 
     761                 :       4675 :                 Color aTextColor( COL_AUTO );
     762         [ +  - ]:       4675 :                 if( xCellInfo.get() )
     763                 :            :                 {
     764                 :            :                     // fill cell background
     765         [ +  - ]:       4675 :                     const Rectangle aRect( nX, nY, nX + nCellWidth - 1, nY + nCellHeight - 1 );
     766                 :            : 
     767         [ +  - ]:       4675 :                     if( xCellInfo->maCellColor.GetColor() != COL_TRANSPARENT )
     768                 :            :                     {
     769         [ +  - ]:       4675 :                         pAccess->SetFillColor( xCellInfo->maCellColor );
     770         [ +  - ]:       4675 :                         pAccess->FillRect( aRect );
     771                 :            :                     }
     772                 :            : 
     773                 :       4675 :                     aTextColor = xCellInfo->maTextColor;
     774                 :            :                 }
     775                 :            : 
     776                 :            :                 // draw text preview line
     777         [ +  - ]:       4675 :                 if( aTextColor.GetColor() == COL_AUTO )
     778         [ -  + ]:       4675 :                     aTextColor.SetColor( bIsPageDark ? COL_WHITE : COL_BLACK );
     779         [ +  - ]:       4675 :                 pAccess->SetLineColor( aTextColor );
     780                 :       4675 :                 const Point aPnt1( nX + 2, nY + ((nCellHeight - 1 ) >> 1) );
     781                 :       4675 :                 const Point aPnt2( nX + nCellWidth - 3, aPnt1.Y() );
     782         [ +  - ]:       4675 :                 pAccess->DrawLine( aPnt1, aPnt2 );
     783         [ +  - ]:       4675 :             }
     784                 :            :         }
     785                 :            : 
     786                 :            :         // second draw border lines
     787                 :        187 :         nY = 0;
     788         [ +  + ]:       1122 :         for( nRow = 0; nRow < nPreviewRows; ++nRow, nY += nCellHeight-1 )
     789                 :            :         {
     790                 :        935 :             sal_Int32 nX = 0;
     791         [ +  + ]:       5610 :             for( sal_Int32 nCol = 0; nCol < nPreviewColumns; ++nCol, nX += nCellWidth-1 )
     792                 :            :             {
     793         [ +  - ]:       4675 :                 boost::shared_ptr< CellInfo > xCellInfo( aMatrix[nCol][nRow] );
     794                 :            : 
     795         [ +  - ]:       4675 :                 if( xCellInfo.get() )
     796                 :            :                 {
     797                 :       4675 :                     const Point aPntTL( nX, nY );
     798                 :       4675 :                     const Point aPntTR( nX + nCellWidth - 1, nY );
     799                 :       4675 :                     const Point aPntBL( nX, nY + nCellHeight - 1 );
     800                 :       4675 :                     const Point aPntBR( nX + nCellWidth - 1, nY + nCellHeight - 1 );
     801                 :            : 
     802                 :       4675 :                     sal_Int32 border_diffs[8] = { 0,-1, 0,1, -1,0, 1,0 };
     803                 :       4675 :                     sal_Int32* pDiff = &border_diffs[0];
     804                 :            : 
     805                 :            :                     // draw top border
     806         [ +  + ]:      23375 :                     for( sal_uInt16 nLine = 0; nLine < 4; ++nLine )
     807                 :            :                     {
     808         [ +  - ]:      18700 :                         const ::editeng::SvxBorderLine* pBorderLine = xCellInfo->maBorder.GetLine(nLine);
     809 [ +  - ][ +  - ]:      18700 :                         if( !pBorderLine || ((pBorderLine->GetOutWidth() == 0) && (pBorderLine->GetInWidth()==0)) )
         [ -  + ][ #  # ]
         [ #  # ][ -  + ]
     810                 :          0 :                             continue;
     811                 :            : 
     812                 :      18700 :                         sal_Int32 nBorderCol = nCol + *pDiff++;
     813                 :      18700 :                         sal_Int32 nBorderRow = nRow + *pDiff++;
     814 [ +  + ][ +  + ]:      18700 :                         if( (nBorderCol >= 0) && (nBorderCol < nPreviewColumns) && (nBorderRow >= 0) && (nBorderRow < nPreviewRows) )
         [ +  + ][ +  + ]
     815                 :            :                         {
     816                 :            :                             // check border
     817         [ +  - ]:      14960 :                             boost::shared_ptr< CellInfo > xBorderInfo( aMatrix[nBorderCol][nBorderRow] );
     818         [ +  - ]:      14960 :                             if( xBorderInfo.get() )
     819                 :            :                             {
     820                 :      14960 :                                 const sal_uInt16 nOtherLine = nLine ^ 1;
     821         [ +  - ]:      14960 :                                 const ::editeng::SvxBorderLine* pBorderLine2 = xBorderInfo->maBorder.GetLine(nOtherLine^1);
     822 [ +  - ][ +  - ]:      14960 :                                 if( pBorderLine2 && pBorderLine2->HasPriority(*pBorderLine) )
         [ -  + ][ -  + ]
     823                 :      14960 :                                     continue; // other border line wins
     824 [ +  - ][ +  - ]:      14960 :                             }
     825                 :            :                         }
     826                 :            : 
     827         [ +  - ]:      18700 :                         pAccess->SetLineColor( pBorderLine->GetColor() );
     828   [ +  +  +  +  :      18700 :                         switch( nLine )
                      - ]
     829                 :            :                         {
     830         [ +  - ]:       4675 :                         case 0: pAccess->DrawLine( aPntTL, aPntTR ); break;
     831         [ +  - ]:       4675 :                         case 1: pAccess->DrawLine( aPntBL, aPntBR ); break;
     832         [ +  - ]:       4675 :                         case 2: pAccess->DrawLine( aPntTL, aPntBL ); break;
     833         [ +  - ]:       4675 :                         case 3: pAccess->DrawLine( aPntTR, aPntBR ); break;
     834                 :            :                         }
     835                 :            :                     }
     836                 :            :                 }
     837         [ +  - ]:       4675 :             }
     838                 :            :         }
     839                 :            : 
     840         [ +  - ]:        187 :         aPreviewBmp.ReleaseAccess( pAccess );
     841                 :            :     }
     842                 :            : 
     843 [ +  + ][ #  # ]:       4862 :     return aPreviewBmp;
     844                 :            : }
     845                 :            : 
     846                 :         17 : void TableDesignPane::FillDesignPreviewControl()
     847                 :            : {
     848                 :         17 :     ValueSet* pValueSet = static_cast< ValueSet* >( mxControls[CT_TABLE_STYLES].get() );
     849                 :            : 
     850                 :         17 :     sal_uInt16 nSelectedItem = pValueSet->GetSelectItemId();
     851                 :         17 :     pValueSet->Clear();
     852                 :            :     try
     853                 :            :     {
     854                 :         17 :         TableStyleSettings aSettings;
     855         [ -  + ]:         17 :         if( mxSelectedTable.is() )
     856                 :            :         {
     857         [ #  # ]:          0 :             aSettings.mbUseFirstRow = static_cast< CheckBox* >(mxControls[CB_HEADER_ROW].get())->IsChecked();
     858         [ #  # ]:          0 :             aSettings.mbUseLastRow = static_cast< CheckBox* >(mxControls[CB_TOTAL_ROW].get())->IsChecked();
     859         [ #  # ]:          0 :             aSettings.mbUseRowBanding = static_cast< CheckBox* >(mxControls[CB_BANDED_ROWS].get())->IsChecked();
     860         [ #  # ]:          0 :             aSettings.mbUseFirstColumn = static_cast< CheckBox* >(mxControls[CB_FIRST_COLUMN].get())->IsChecked();
     861         [ #  # ]:          0 :             aSettings.mbUseLastColumn = static_cast< CheckBox* >(mxControls[CB_LAST_COLUMN].get())->IsChecked();
     862         [ #  # ]:          0 :             aSettings.mbUseColumnBanding = static_cast< CheckBox* >(mxControls[CB_BANDED_COLUMNS].get())->IsChecked();
     863                 :            :         }
     864                 :            : 
     865                 :         17 :         sal_Bool bIsPageDark = sal_False;
     866         [ +  - ]:         17 :         if( mxView.is() )
     867                 :            :         {
     868 [ +  - ][ +  - ]:         17 :             Reference< XPropertySet > xPageSet( mxView->getCurrentPage(), UNO_QUERY );
                 [ +  - ]
     869         [ +  - ]:         17 :             if( xPageSet.is() )
     870                 :            :             {
     871                 :         17 :                 const OUString sIsBackgroundDark( "IsBackgroundDark" );
     872 [ +  - ][ +  - ]:         17 :                 xPageSet->getPropertyValue(sIsBackgroundDark) >>= bIsPageDark;
     873                 :         17 :             }
     874                 :            :         }
     875                 :            : 
     876 [ +  - ][ +  - ]:        204 :         for( sal_Int32 nIndex = 0; nIndex < mxTableFamily->getCount(); nIndex++ ) try
                 [ +  + ]
     877                 :            :         {
     878 [ +  - ][ +  - ]:        187 :             Reference< XIndexAccess > xTableStyle( mxTableFamily->getByIndex( nIndex ), UNO_QUERY );
                 [ +  - ]
     879         [ +  - ]:        187 :             if( xTableStyle.is() )
     880 [ +  - ][ +  - ]:        187 :                 pValueSet->InsertItem( sal::static_int_cast<sal_uInt16>( nIndex + 1 ), Image( CreateDesignPreview( xTableStyle, aSettings, bIsPageDark ) ) );
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
     881                 :            :         }
     882   [ #  #  #  # ]:          0 :         catch( Exception& )
     883                 :            :         {
     884                 :            :             OSL_FAIL("sd::TableDesignPane::FillDesignPreviewControl(), exception caught!");
     885                 :            :         }
     886                 :            :     }
     887                 :          0 :     catch( Exception& )
     888                 :            :     {
     889                 :            :         OSL_FAIL("sd::TableDesignPane::FillDesignPreviewControl(), exception caught!");
     890                 :            :     }
     891                 :         17 :     pValueSet->SelectItem(nSelectedItem);
     892                 :         17 : }
     893                 :            : 
     894                 :            : // ====================================================================
     895                 :            : 
     896                 :          0 : TableDesignDialog::TableDesignDialog(::Window* pParent, ViewShellBase& rBase )
     897                 :            : : ModalDialog( pParent, SdResId( DLG_TABLEDESIGNPANE ))
     898         [ #  # ]:          0 : , mrBase( rBase )
     899                 :            : {
     900 [ #  # ][ #  # ]:          0 :     mxFlSep1.reset( new FixedLine( this, SdResId( FL_SEP1 ) ) );
         [ #  # ][ #  # ]
     901 [ #  # ][ #  # ]:          0 :     mxFlSep2.reset( new FixedLine( this, SdResId( FL_SEP2 ) ) );
         [ #  # ][ #  # ]
     902 [ #  # ][ #  # ]:          0 :     mxHelpButton.reset( new HelpButton( this, SdResId( BTN_HELP ) ) );
         [ #  # ][ #  # ]
     903 [ #  # ][ #  # ]:          0 :     mxOkButton.reset( new OKButton( this, SdResId( BTN_OK ) ) );
         [ #  # ][ #  # ]
     904 [ #  # ][ #  # ]:          0 :     mxCancelButton.reset( new CancelButton( this, SdResId( BTN_CANCEL ) ) );
         [ #  # ][ #  # ]
     905         [ #  # ]:          0 :     FreeResource();
     906                 :            : 
     907 [ #  # ][ #  # ]:          0 :     mpDesignPane.reset( new TableDesignPane( this, rBase, true ) );
                 [ #  # ]
     908         [ #  # ]:          0 :     mpDesignPane->Hide();
     909                 :          0 : }
     910                 :            : 
     911                 :            : // --------------------------------------------------------------------
     912                 :            : 
     913                 :          0 : short TableDesignDialog::Execute()
     914                 :            : {
     915         [ #  # ]:          0 :     if( ModalDialog::Execute() )
     916                 :            :     {
     917         [ #  # ]:          0 :         if( mpDesignPane->isStyleChanged() )
     918                 :          0 :             mpDesignPane->ApplyStyle();
     919                 :            : 
     920         [ #  # ]:          0 :         if( mpDesignPane->isOptionsChanged() )
     921                 :          0 :             mpDesignPane->ApplyOptions();
     922                 :          0 :         return sal_True;
     923                 :            :     }
     924                 :          0 :     return sal_False;
     925                 :            : }
     926                 :            : 
     927                 :            : // ====================================================================
     928                 :            : 
     929                 :         17 : ::Window * createTableDesignPanel( ::Window* pParent, ViewShellBase& rBase )
     930                 :            : {
     931         [ +  - ]:         17 :     return new TableDesignPane( pParent, rBase, false );
     932                 :            : }
     933                 :            : 
     934                 :            : // ====================================================================
     935                 :            : 
     936                 :          0 : void showTableDesignDialog( ::Window* pParent, ViewShellBase& rBase )
     937                 :            : {
     938 [ #  # ][ #  # ]:          0 :     boost::scoped_ptr< TableDesignDialog > xDialog( new TableDesignDialog( pParent, rBase ) );
     939 [ #  # ][ #  # ]:          0 :     xDialog->Execute();
     940                 :          0 : }
     941                 :            : 
     942                 :            : 
     943                 :            : }
     944                 :            : 
     945                 :            : 
     946                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10