LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/table - tableobjectbar.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 6 78 7.7 %
Date: 2012-12-27 Functions: 6 19 31.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <sfx2/msg.hxx>
      22             : #include <sfx2/app.hxx>
      23             : #include <sfx2/sfxsids.hrc>
      24             : #include <sfx2/request.hxx>
      25             : #include <sfx2/objface.hxx>
      26             : #include <sfx2/viewfrm.hxx>
      27             : #include <sfx2/dispatch.hxx>
      28             : #include <sfx2/msgpool.hxx>
      29             : #include <svl/whiter.hxx>
      30             : #include <svl/itempool.hxx>
      31             : #include <svx/svdomedia.hxx>
      32             : #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
      33             : #include <svx/svxdlg.hxx>
      34             : #include <svx/dialogs.hrc>
      35             : #include <svx/svxids.hrc>
      36             : 
      37             : #include "app.hrc"
      38             : #include "res_bmp.hrc"
      39             : #include "glob.hrc"
      40             : #include "strings.hrc"
      41             : #include "DrawDocShell.hxx"
      42             : #include "ViewShell.hxx"
      43             : #include "Window.hxx"
      44             : #include "drawview.hxx"
      45             : #include "sdresid.hxx"
      46             : #include "drawdoc.hxx"
      47             : #include "DrawViewShell.hxx"
      48             : 
      49             : #include "tableobjectbar.hxx"
      50             : 
      51             : using namespace sd;
      52             : using namespace sd::ui::table;
      53             : 
      54             : #define TableObjectBar
      55             : #include "sdslots.hxx"
      56             : 
      57             : 
      58             : namespace sd { namespace ui { namespace table {
      59             : 
      60             : /** creates a table object bar for the given ViewShell */
      61           0 : SfxShell* CreateTableObjectBar( ViewShell& rShell, ::sd::View* pView )
      62             : {
      63           0 :     return new TableObjectBar( &rShell, pView );
      64             : }
      65             : 
      66             : 
      67             : /** registers the interfaces from the table ui */
      68           3 : void RegisterInterfaces(SfxModule* pMod)
      69             : {
      70           3 :     TableObjectBar::RegisterInterface(pMod);
      71           3 : }
      72             : 
      73             : // ------------------
      74             : // - TableObjectBar -
      75             : // ------------------
      76             : 
      77           0 : TYPEINIT1( TableObjectBar, SfxShell );
      78             : 
      79             : // -----------------------------------------------------------------------------
      80             : 
      81           9 : SFX_IMPL_INTERFACE( TableObjectBar, SfxShell, SdResId( STR_TABLEOBJECTBARSHELL ) )
      82             : {
      83           3 : }
      84             : 
      85             : // -----------------------------------------------------------------------------
      86             : 
      87           0 : TableObjectBar::TableObjectBar( ViewShell* pSdViewShell, ::sd::View* pSdView )
      88             : :   SfxShell( pSdViewShell->GetViewShell() )
      89             : ,   mpView( pSdView )
      90           0 : ,   mpViewSh( pSdViewShell )
      91             : {
      92           0 :     DrawDocShell* pDocShell = mpViewSh->GetDocSh();
      93           0 :     if( pDocShell )
      94             :     {
      95           0 :         SetPool( &pDocShell->GetPool() );
      96           0 :         SetUndoManager( pDocShell->GetUndoManager() );
      97             :     }
      98           0 :     SetRepeatTarget( mpView );
      99           0 :     SetHelpId( SD_IF_SDDRAWTABLEOBJECTBAR );
     100           0 :     SetName( String( SdResId( RID_DRAW_TABLE_TOOLBOX ) ) );
     101           0 : }
     102             : 
     103             : // -----------------------------------------------------------------------------
     104             : 
     105           0 : TableObjectBar::~TableObjectBar()
     106             : {
     107           0 :     SetRepeatTarget( NULL );
     108           0 : }
     109             : 
     110             : // -----------------------------------------------------------------------------
     111             : 
     112           0 : void TableObjectBar::GetState( SfxItemSet& rSet )
     113             : {
     114           0 :     bool bReadOnly = false;
     115             : 
     116           0 :     if( bReadOnly )
     117             :     {
     118           0 :         rSet.DisableItem (SID_INSERT_TABLE );
     119             :     }
     120             : 
     121           0 :     if( mpView )
     122             :     {
     123           0 :         rtl::Reference< sdr::SelectionController > xController( mpView->getSelectionController() );
     124           0 :         if( xController.is() )
     125             :         {
     126           0 :             xController->GetState( rSet );
     127           0 :         }
     128             :     }
     129           0 : }
     130             : 
     131             : // -----------------------------------------------------------------------------
     132             : 
     133           0 : void TableObjectBar::GetAttrState( SfxItemSet& rSet )
     134             : {
     135           0 :     DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >( mpViewSh );
     136           0 :     if( pDrawViewShell )
     137           0 :         pDrawViewShell->GetAttrState( rSet );
     138           0 : }
     139             : 
     140             : // -----------------------------------------------------------------------------
     141             : 
     142           0 : void TableObjectBar::Execute( SfxRequest& rReq )
     143             : {
     144           0 :     if( mpView )
     145             :     {
     146           0 :         SdrView* pView = mpView;
     147           0 :         SfxBindings* pBindings = &mpViewSh->GetViewFrame()->GetBindings();
     148             : 
     149           0 :         rtl::Reference< sdr::SelectionController > xController( mpView->getSelectionController() );
     150           0 :         sal_uLong nSlotId = rReq.GetSlot();
     151           0 :         if( xController.is() )
     152             :         {
     153           0 :             switch( nSlotId )
     154             :             {
     155             :             case SID_TABLE_INSERT_ROW_DLG:
     156             :             case SID_TABLE_INSERT_COL_DLG:
     157             :             {
     158           0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     159           0 :                 ::std::auto_ptr<SvxAbstractInsRowColDlg> pDlg( pFact ? pFact->CreateSvxInsRowColDlg( mpView->GetViewShell()->GetParentWindow(), nSlotId == SID_TABLE_INSERT_COL_DLG, SD_MOD()->GetSlotPool()->GetSlot(nSlotId)->GetCommand()) : 0);
     160             : 
     161           0 :                 if( pDlg.get() && (pDlg->Execute() == 1) )
     162             :                 {
     163           0 :                     if( nSlotId == SID_TABLE_INSERT_ROW_DLG )
     164           0 :                         nSlotId = SID_TABLE_INSERT_ROW;
     165             :                     else
     166           0 :                         nSlotId = SID_TABLE_INSERT_COL;
     167             : 
     168           0 :                     rReq.AppendItem( SfxInt16Item( (sal_uInt16)nSlotId, (sal_uInt16)pDlg->getInsertCount() ) );
     169           0 :                     rReq.AppendItem( SfxBoolItem( SID_TABLE_PARAM_INSERT_AFTER, !pDlg->isInsertBefore() ) );
     170             : 
     171           0 :                      rReq.SetSlot( (sal_uInt16)nSlotId );
     172           0 :                 }
     173             :             }
     174             :             }
     175             : 
     176           0 :             xController->Execute( rReq );
     177             :         }
     178             : 
     179             :         // note: we may be deleted at this point, no more member access possible
     180             : 
     181           0 :         switch( rReq.GetSlot() )
     182             :         {
     183             :         case SID_ATTR_BORDER:
     184             :         case SID_TABLE_MERGE_CELLS:
     185             :         case SID_TABLE_SPLIT_CELLS:
     186             :         case SID_OPTIMIZE_TABLE:
     187             :         case SID_TABLE_DELETE_ROW:
     188             :         case SID_TABLE_DELETE_COL:
     189             :         case SID_FORMAT_TABLE_DLG:
     190             :         case SID_TABLE_INSERT_ROW:
     191             :         case SID_TABLE_INSERT_COL:
     192             :         {
     193           0 :             pView->AdjustMarkHdl();
     194           0 :             pBindings->Invalidate( SID_TABLE_DELETE_ROW );
     195           0 :             pBindings->Invalidate( SID_TABLE_DELETE_COL );
     196           0 :             pBindings->Invalidate( SID_FRAME_LINESTYLE );
     197           0 :             pBindings->Invalidate( SID_FRAME_LINECOLOR );
     198           0 :             pBindings->Invalidate( SID_ATTR_BORDER );
     199           0 :             pBindings->Invalidate( SID_ATTR_FILL_STYLE );
     200           0 :             pBindings->Invalidate( SID_TABLE_MERGE_CELLS );
     201           0 :             pBindings->Invalidate( SID_TABLE_SPLIT_CELLS );
     202           0 :             pBindings->Invalidate( SID_OPTIMIZE_TABLE );
     203           0 :             pBindings->Invalidate( SID_TABLE_VERT_BOTTOM );
     204           0 :             pBindings->Invalidate( SID_TABLE_VERT_CENTER );
     205           0 :             pBindings->Invalidate( SID_TABLE_VERT_NONE );
     206           0 :             break;
     207             :         }
     208             :         case SID_TABLE_VERT_BOTTOM:
     209             :         case SID_TABLE_VERT_CENTER:
     210             :         case SID_TABLE_VERT_NONE:
     211             :         {
     212           0 :             pBindings->Invalidate( SID_TABLE_VERT_BOTTOM );
     213           0 :             pBindings->Invalidate( SID_TABLE_VERT_CENTER );
     214           0 :             pBindings->Invalidate( SID_TABLE_VERT_NONE );
     215           0 :             break;
     216             :         }
     217             :         }
     218             : 
     219           0 :         pBindings->Invalidate( SID_UNDO );
     220           0 :         pBindings->Invalidate( SID_REDO );
     221             :     }
     222           0 : }
     223             : 
     224           9 : } } }
     225             : 
     226             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10