LCOV - code coverage report
Current view: top level - sd/source/ui/app - tbxww.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 31 103 30.1 %
Date: 2014-11-03 Functions: 7 9 77.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <sfx2/bindings.hxx>
      21             : #include <svx/svxids.hrc>
      22             : #include <svx/grafctrl.hxx>
      23             : #include <svl/cjkoptions.hxx>
      24             : #include <sfx2/viewsh.hxx>
      25             : #include <sfx2/imagemgr.hxx>
      26             : #include <rtl/ustring.hxx>
      27             : #include <rtl/ustrbuf.hxx>
      28             : 
      29             : #include "sddll.hxx"
      30             : #include "GraphicDocShell.hxx"
      31             : 
      32             : #include <vcl/toolbox.hxx>
      33             : 
      34             : #include "sdmod.hxx"
      35             : #include "app.hrc"
      36             : #include "res_bmp.hrc"
      37             : #include "sdresid.hxx"
      38             : #include "tbx_ww.hxx"
      39             : 
      40        1612 : SFX_IMPL_TOOLBOX_CONTROL( SdTbxControl, TbxImageItem )
      41             : 
      42             : /**
      43             :  * Class for toolbox
      44             :  */
      45        1180 : SdTbxControl::SdTbxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
      46        1180 :         SfxToolBoxControl( nSlotId, nId, rTbx )
      47             : {
      48        1180 :     rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWN | rTbx.GetItemBits( nId ) );
      49        1180 :     rTbx.Invalidate();
      50        1180 : }
      51             : 
      52             : /*-------------------------------------------------------------------------*/
      53             : 
      54           0 : SfxPopupWindowType SdTbxControl::GetPopupWindowType() const
      55             : {
      56           0 :     return( SFX_POPUPWINDOW_ONTIMEOUT );
      57             : }
      58             : 
      59             : /**
      60             :  * We create the window here
      61             :  * You can get the position of the toolbox with GetToolBox()
      62             :  * rItemRect are screen coordinates
      63             :  */
      64             : 
      65           0 : SfxPopupWindow* SdTbxControl::CreatePopupWindow()
      66             : {
      67           0 :     SfxPopupWindow *pWin = NULL;
      68           0 :     OUString aToolBarResStr;
      69           0 :     OUStringBuffer aTbxResName( "private:resource/toolbar/" );
      70           0 :     switch( GetSlotId() )
      71             :     {
      72             :         case SID_OBJECT_ALIGN:
      73           0 :             aTbxResName.appendAscii( "alignmentbar" );
      74           0 :             aToolBarResStr = aTbxResName.makeStringAndClear();
      75           0 :         break;
      76             :         case SID_ZOOM_TOOLBOX:
      77           0 :             aTbxResName.appendAscii( "zoombar" );
      78           0 :             aToolBarResStr = aTbxResName.makeStringAndClear();
      79           0 :         break;
      80             :         case SID_OBJECT_CHOOSE_MODE:
      81           0 :             aTbxResName.appendAscii( "choosemodebar" );
      82           0 :             aToolBarResStr = aTbxResName.makeStringAndClear();
      83           0 :         break;
      84             :         case SID_POSITION:
      85           0 :             aTbxResName.appendAscii( "positionbar" );
      86           0 :             aToolBarResStr = aTbxResName.makeStringAndClear();
      87           0 :         break;
      88             :         case SID_DRAWTBX_TEXT:
      89           0 :             aTbxResName.appendAscii( "textbar" );
      90           0 :             aToolBarResStr = aTbxResName.makeStringAndClear();
      91           0 :         break;
      92             :         case SID_DRAWTBX_RECTANGLES:
      93           0 :             aTbxResName.appendAscii( "rectanglesbar" );
      94           0 :             aToolBarResStr = aTbxResName.makeStringAndClear();
      95           0 :         break;
      96             :         case SID_DRAWTBX_ELLIPSES:
      97           0 :             aTbxResName.appendAscii( "ellipsesbar" );
      98           0 :             aToolBarResStr = aTbxResName.makeStringAndClear();
      99           0 :         break;
     100             :         case SID_DRAWTBX_LINES:
     101           0 :             aTbxResName.appendAscii( "linesbar" );
     102           0 :             aToolBarResStr = aTbxResName.makeStringAndClear();
     103           0 :         break;
     104             :         case SID_DRAWTBX_ARROWS:
     105           0 :             aTbxResName.appendAscii( "arrowsbar" );
     106           0 :             aToolBarResStr = aTbxResName.makeStringAndClear();
     107           0 :         break;
     108             :         case SID_DRAWTBX_3D_OBJECTS:
     109           0 :             aTbxResName.appendAscii( "3dobjectsbar" );
     110           0 :             aToolBarResStr = aTbxResName.makeStringAndClear();
     111           0 :         break;
     112             :         case SID_DRAWTBX_CONNECTORS:
     113           0 :             aTbxResName.appendAscii( "connectorsbar" );
     114           0 :             aToolBarResStr = aTbxResName.makeStringAndClear();
     115           0 :         break;
     116             :         case SID_DRAWTBX_INSERT:
     117           0 :             aTbxResName.appendAscii( "insertbar" );
     118           0 :             aToolBarResStr = aTbxResName.makeStringAndClear();
     119           0 :         break;
     120             :     }
     121             : 
     122           0 :     if ( !aToolBarResStr.isEmpty() )
     123           0 :         createAndPositionSubToolBar( aToolBarResStr );
     124             : 
     125           0 :     return( pWin );
     126             : }
     127             : 
     128             : /*-------------------------------------------------------------------------*/
     129             : 
     130         635 : void SdTbxControl::StateChanged( sal_uInt16 nSId,
     131             :                         SfxItemState eState, const SfxPoolItem* pState )
     132             : {
     133         635 :     SfxToolBoxControl::StateChanged( nSId, eState, pState );
     134             : 
     135         635 :     if( eState == SfxItemState::DEFAULT )
     136             :     {
     137         635 :         const TbxImageItem* pItem = PTR_CAST( TbxImageItem, pState );
     138             :         // StarDesktop can also receive another item,
     139             :         // but it is not allowed to evaluate it
     140         635 :         if( pItem )
     141             :         {
     142         635 :             ToolBox& rTbx = GetToolBox();
     143         635 :             sal_uInt16 nImage = pItem->GetValue();
     144         635 :             if( nImage == 0 )
     145             :             {
     146         317 :                 if( rTbx.IsItemChecked( nSId ) )
     147           0 :                     rTbx.CheckItem( nSId, false );
     148             :             }
     149             :             else
     150             :             {
     151         318 :                 OUString aSlotURL( "slot:" );
     152         318 :                 aSlotURL += OUString::number( nImage);
     153             :                 Image aImage = GetImage( m_xFrame,
     154             :                                          aSlotURL,
     155         318 :                                          hasBigImages()
     156         636 :                                        );
     157             : 
     158             :                 // !-operator checks if image is not present
     159         318 :                 if( !!aImage )
     160             :                 {
     161         318 :                     rTbx.SetItemImage( GetId(), aImage );
     162         318 :                     rTbx.CheckItem( GetId(), IsCheckable( nImage ) );
     163             : 
     164         318 :                     if( nSId != SID_ZOOM_TOOLBOX &&
     165         132 :                         nSId != SID_DRAWTBX_INSERT &&
     166          66 :                         nSId != SID_POSITION &&
     167             :                         nSId != SID_OBJECT_ALIGN )
     168             :                     {
     169           0 :                         if( nSId != SID_OBJECT_CHOOSE_MODE &&
     170           0 :                             rTbx.IsItemChecked( SID_OBJECT_CHOOSE_MODE ) )
     171           0 :                             rTbx.CheckItem( SID_OBJECT_CHOOSE_MODE, false );
     172           0 :                         if( nSId != SID_DRAWTBX_TEXT &&
     173           0 :                             rTbx.IsItemChecked( SID_DRAWTBX_TEXT ) )
     174           0 :                              rTbx.CheckItem( SID_DRAWTBX_TEXT, false );
     175           0 :                         if( nSId != SID_DRAWTBX_RECTANGLES &&
     176           0 :                             rTbx.IsItemChecked( SID_DRAWTBX_RECTANGLES ) )
     177           0 :                                rTbx.CheckItem( SID_DRAWTBX_RECTANGLES, false );
     178           0 :                         if( nSId != SID_DRAWTBX_ELLIPSES &&
     179           0 :                             rTbx.IsItemChecked( SID_DRAWTBX_ELLIPSES ) )
     180           0 :                                rTbx.CheckItem( SID_DRAWTBX_ELLIPSES, false );
     181           0 :                         if( nSId != SID_DRAWTBX_LINES &&
     182           0 :                             rTbx.IsItemChecked( SID_DRAWTBX_LINES ) )
     183           0 :                             rTbx.CheckItem( SID_DRAWTBX_LINES, false );
     184           0 :                         if( nSId != SID_DRAWTBX_ARROWS &&
     185           0 :                             rTbx.IsItemChecked( SID_DRAWTBX_ARROWS ) )
     186           0 :                             rTbx.CheckItem( SID_DRAWTBX_ARROWS, false );
     187           0 :                         if( nSId != SID_DRAWTBX_3D_OBJECTS &&
     188           0 :                             rTbx.IsItemChecked( SID_DRAWTBX_3D_OBJECTS ) )
     189           0 :                             rTbx.CheckItem( SID_DRAWTBX_3D_OBJECTS, false );
     190           0 :                         if( nSId != SID_DRAWTBX_CONNECTORS &&
     191           0 :                             rTbx.IsItemChecked( SID_DRAWTBX_CONNECTORS ) )
     192           0 :                             rTbx.CheckItem( SID_DRAWTBX_CONNECTORS, false );
     193             :                     }
     194         318 :                 }
     195             :             }
     196             :         }
     197             :     }
     198         635 : }
     199             : 
     200             : /*-------------------------------------------------------------------------*/
     201             : 
     202         318 : bool SdTbxControl::IsCheckable( sal_uInt16 nSId )
     203             : {
     204         318 :     switch( nSId )
     205             :     {
     206             :         case SID_OBJECT_ROTATE:
     207             :         case SID_OBJECT_MIRROR:
     208             :         case SID_OBJECT_CROP:
     209             :         case SID_OBJECT_TRANSPARENCE:
     210             :         case SID_OBJECT_GRADIENT:
     211             :         case SID_OBJECT_SHEAR:
     212             :         case SID_OBJECT_CROOK_ROTATE:
     213             :         case SID_OBJECT_CROOK_SLANT:
     214             :         case SID_OBJECT_CROOK_STRETCH:
     215             :         case SID_CONVERT_TO_3D_LATHE:
     216             : 
     217             :         case SID_ATTR_CHAR:
     218             :         case SID_ATTR_CHAR_VERTICAL:
     219             :         case SID_TEXT_FITTOSIZE:
     220             :         case SID_TEXT_FITTOSIZE_VERTICAL:
     221             :         case SID_DRAW_CAPTION:
     222             :         case SID_DRAW_CAPTION_VERTICAL:
     223             :         case SID_DRAW_FONTWORK:
     224             :         case SID_DRAW_FONTWORK_VERTICAL:
     225             : 
     226             :         case SID_DRAW_RECT:
     227             :         case SID_DRAW_SQUARE:
     228             :         case SID_DRAW_RECT_ROUND:
     229             :         case SID_DRAW_SQUARE_ROUND:
     230             :         case SID_DRAW_RECT_NOFILL:
     231             :         case SID_DRAW_SQUARE_NOFILL:
     232             :         case SID_DRAW_RECT_ROUND_NOFILL:
     233             :         case SID_DRAW_SQUARE_ROUND_NOFILL:
     234             : 
     235             :         case SID_DRAW_ELLIPSE:
     236             :         case SID_DRAW_CIRCLE:
     237             :         case SID_DRAW_PIE:
     238             :         case SID_DRAW_CIRCLEPIE:
     239             :         case SID_DRAW_ELLIPSECUT:
     240             :         case SID_DRAW_CIRCLECUT:
     241             :         case SID_DRAW_ARC:
     242             :         case SID_DRAW_CIRCLEARC:
     243             :         case SID_DRAW_ELLIPSE_NOFILL:
     244             :         case SID_DRAW_CIRCLE_NOFILL:
     245             :         case SID_DRAW_PIE_NOFILL:
     246             :         case SID_DRAW_CIRCLEPIE_NOFILL:
     247             :         case SID_DRAW_ELLIPSECUT_NOFILL:
     248             :         case SID_DRAW_CIRCLECUT_NOFILL:
     249             : 
     250             :         case SID_DRAW_BEZIER_NOFILL:
     251             :         case SID_DRAW_POLYGON_NOFILL:
     252             :         case SID_DRAW_XPOLYGON_NOFILL:
     253             :         case SID_DRAW_BEZIER_FILL:
     254             :         case SID_DRAW_POLYGON:
     255             :         case SID_DRAW_XPOLYGON:
     256             :         case SID_DRAW_FREELINE:
     257             :         case SID_DRAW_FREELINE_NOFILL:
     258             : 
     259             :         case SID_DRAW_LINE:
     260             :         case SID_DRAW_XLINE:
     261             :         case SID_DRAW_MEASURELINE:
     262             :         case SID_LINE_ARROW_START:
     263             :         case SID_LINE_ARROW_END:
     264             :         case SID_LINE_ARROWS:
     265             :         case SID_LINE_ARROW_CIRCLE:
     266             :         case SID_LINE_CIRCLE_ARROW:
     267             :         case SID_LINE_ARROW_SQUARE:
     268             :         case SID_LINE_SQUARE_ARROW:
     269             : 
     270             :         case SID_3D_CUBE:
     271             :         case SID_3D_SPHERE:
     272             :         case SID_3D_CYLINDER:
     273             :         case SID_3D_CONE:
     274             :         case SID_3D_PYRAMID:
     275             :         case SID_3D_TORUS:
     276             :         case SID_3D_SHELL:
     277             :         case SID_3D_HALF_SPHERE:
     278             : 
     279             :         case SID_TOOL_CONNECTOR:
     280             :         case SID_CONNECTOR_ARROW_START:
     281             :         case SID_CONNECTOR_ARROW_END:
     282             :         case SID_CONNECTOR_ARROWS:
     283             :         case SID_CONNECTOR_CIRCLE_START:
     284             :         case SID_CONNECTOR_CIRCLE_END:
     285             :         case SID_CONNECTOR_CIRCLES:
     286             :         case SID_CONNECTOR_LINE:
     287             :         case SID_CONNECTOR_LINE_ARROW_START:
     288             :         case SID_CONNECTOR_LINE_ARROW_END:
     289             :         case SID_CONNECTOR_LINE_ARROWS:
     290             :         case SID_CONNECTOR_LINE_CIRCLE_START:
     291             :         case SID_CONNECTOR_LINE_CIRCLE_END:
     292             :         case SID_CONNECTOR_LINE_CIRCLES:
     293             :         case SID_CONNECTOR_CURVE:
     294             :         case SID_CONNECTOR_CURVE_ARROW_START:
     295             :         case SID_CONNECTOR_CURVE_ARROW_END:
     296             :         case SID_CONNECTOR_CURVE_ARROWS:
     297             :         case SID_CONNECTOR_CURVE_CIRCLE_START:
     298             :         case SID_CONNECTOR_CURVE_CIRCLE_END:
     299             :         case SID_CONNECTOR_CURVE_CIRCLES:
     300             :         case SID_CONNECTOR_LINES:
     301             :         case SID_CONNECTOR_LINES_ARROW_START:
     302             :         case SID_CONNECTOR_LINES_ARROW_END:
     303             :         case SID_CONNECTOR_LINES_ARROWS:
     304             :         case SID_CONNECTOR_LINES_CIRCLE_START:
     305             :         case SID_CONNECTOR_LINES_CIRCLE_END:
     306             :         case SID_CONNECTOR_LINES_CIRCLES:
     307             : 
     308           0 :             return true;
     309             :     }
     310         318 :     return false;
     311         114 : }
     312             : 
     313             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10