LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - gluectrl.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 2 58 3.4 %
Date: 2014-11-03 Functions: 3 13 23.1 %
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 <string>
      21             : 
      22             : #include <svx/dialogs.hrc>
      23             : #include <svx/svdglue.hxx>
      24             : #include <svl/intitem.hxx>
      25             : #include <sfx2/app.hxx>
      26             : #include <sfx2/dispatch.hxx>
      27             : #include <vcl/toolbox.hxx>
      28             : #include <sfx2/viewfrm.hxx>
      29             : 
      30             : #include "strings.hrc"
      31             : #include "gluectrl.hxx"
      32             : #include "sdresid.hxx"
      33             : #include "app.hrc"
      34             : 
      35             : using namespace ::com::sun::star::uno;
      36             : using namespace ::com::sun::star::beans;
      37             : using namespace ::com::sun::star::frame;
      38             : 
      39             : // at the moment, Joe only supports the methods specified below
      40             : #define ESCDIR_COUNT 5
      41             : static const sal_uInt16 aEscDirArray[] =
      42             : {
      43             :     SDRESC_SMART,
      44             :     SDRESC_LEFT,
      45             :     SDRESC_RIGHT,
      46             :     SDRESC_TOP,
      47             :     SDRESC_BOTTOM,
      48             : //  SDRESC_LO,
      49             : //  SDRESC_LU,
      50             : //  SDRESC_RO,
      51             : //  SDRESC_RU,
      52             : //  SDRESC_HORZ,
      53             : //  SDRESC_VERT,
      54             : //  SDRESC_ALL
      55             : };
      56             : 
      57          36 : SFX_IMPL_TOOLBOX_CONTROL( SdTbxCtlGlueEscDir, SfxUInt16Item )
      58             : 
      59             : /**
      60             :  * Constructor for glue point escape direction Listbox
      61             :  */
      62           0 : GlueEscDirLB::GlueEscDirLB( vcl::Window* pParent, const Reference< XFrame >& rFrame ) :
      63             :         ListBox( pParent, WinBits( WB_BORDER | WB_DROPDOWN ) ),
      64           0 :         m_xFrame( rFrame )
      65             : {
      66           0 :     Size aXSize( GetTextWidth( "X" ), GetTextHeight() );
      67           0 :     SetSizePixel( Size( aXSize.Width() * 12, aXSize.Height() * 10 ) );
      68           0 :     Fill();
      69           0 :     Show();
      70           0 : }
      71             : 
      72           0 : GlueEscDirLB::~GlueEscDirLB()
      73             : {
      74           0 : }
      75             : 
      76             : /**
      77             :  * Determines the escape direction and sends the corresponding slot
      78             :  */
      79           0 : void GlueEscDirLB::Select()
      80             : {
      81           0 :     sal_Int32 nPos = GetSelectEntryPos();
      82           0 :     SfxUInt16Item aItem( SID_GLUE_ESCDIR, aEscDirArray[ nPos ] );
      83             : 
      84           0 :     if ( m_xFrame.is() )
      85             :     {
      86           0 :         Any a;
      87           0 :         Sequence< PropertyValue > aArgs( 1 );
      88           0 :         aArgs[0].Name   = "GlueEscapeDirection";
      89           0 :         aItem.QueryValue( a );
      90           0 :         aArgs[0].Value  = a;
      91           0 :         SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ),
      92             :                                     ".uno:GlueEscapeDirection",
      93           0 :                                     aArgs );
      94           0 :     }
      95           0 : }
      96             : 
      97             : /**
      98             :  * Fills the Listbox with strings
      99             :  */
     100           0 : void GlueEscDirLB::Fill()
     101             : {
     102           0 :     InsertEntry( SD_RESSTR( STR_GLUE_ESCDIR_SMART ) );
     103           0 :     InsertEntry( SD_RESSTR( STR_GLUE_ESCDIR_LEFT ) );
     104           0 :     InsertEntry( SD_RESSTR( STR_GLUE_ESCDIR_RIGHT ) );
     105           0 :     InsertEntry( SD_RESSTR( STR_GLUE_ESCDIR_TOP ) );
     106           0 :     InsertEntry( SD_RESSTR( STR_GLUE_ESCDIR_BOTTOM ) );
     107             :     /*
     108             :     InsertEntry( SD_RESSTR( STR_GLUE_ESCDIR_LO ) );
     109             :     InsertEntry( SD_RESSTR( STR_GLUE_ESCDIR_LU ) );
     110             :     InsertEntry( SD_RESSTR( STR_GLUE_ESCDIR_RO ) );
     111             :     InsertEntry( SD_RESSTR( STR_GLUE_ESCDIR_RU ) );
     112             :     InsertEntry( SD_RESSTR( STR_GLUE_ESCDIR_HORZ ) );
     113             :     InsertEntry( SD_RESSTR( STR_GLUE_ESCDIR_VERT ) );
     114             :     InsertEntry( SD_RESSTR( STR_GLUE_ESCDIR_ALL ) );
     115             :     */
     116           0 : }
     117             : 
     118             : /**
     119             :  * Constructor for glue point escape direction toolbox control
     120             :  */
     121           0 : SdTbxCtlGlueEscDir::SdTbxCtlGlueEscDir(
     122             :     sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
     123           0 :         SfxToolBoxControl( nSlotId, nId, rTbx )
     124             : {
     125           0 : }
     126             : 
     127             : /**
     128             :  * Represents state in the listbox of the controller
     129             :  */
     130           0 : void SdTbxCtlGlueEscDir::StateChanged( sal_uInt16 nSId,
     131             :                         SfxItemState eState, const SfxPoolItem* pState )
     132             : {
     133           0 :     if( eState == SfxItemState::DEFAULT )
     134             :     {
     135           0 :         GlueEscDirLB* pGlueEscDirLB = (GlueEscDirLB*) ( GetToolBox().
     136           0 :                                             GetItemWindow( GetId() ) );
     137           0 :         if( pGlueEscDirLB )
     138             :         {
     139           0 :             if( pState )
     140             :             {
     141           0 :                 pGlueEscDirLB->Enable();
     142           0 :                 if ( IsInvalidItem( pState ) )
     143             :                 {
     144           0 :                     pGlueEscDirLB->SetNoSelection();
     145             :                 }
     146             :                 else
     147             :                 {
     148           0 :                     sal_uInt16 nEscDir = ( (const SfxUInt16Item*) pState )->GetValue();
     149           0 :                     pGlueEscDirLB->SelectEntryPos( GetEscDirPos( nEscDir ) );
     150             :                 }
     151             :             }
     152             :             else
     153             :             {
     154           0 :                 pGlueEscDirLB->Disable();
     155           0 :                 pGlueEscDirLB->SetNoSelection();
     156             :             }
     157             :         }
     158             :     }
     159             : 
     160           0 :     SfxToolBoxControl::StateChanged( nSId, eState, pState );
     161           0 : }
     162             : 
     163           0 : vcl::Window* SdTbxCtlGlueEscDir::CreateItemWindow( vcl::Window *pParent )
     164             : {
     165           0 :     if( GetSlotId() == SID_GLUE_ESCDIR )
     166             :     {
     167           0 :         return( new GlueEscDirLB( pParent, m_xFrame ) );
     168             :     }
     169             : 
     170           0 :     return( NULL );
     171             : }
     172             : 
     173             : /**
     174             :  * Returns position in the array for EscDir (Mapping for Listbox)
     175             :  */
     176           0 : sal_uInt16 SdTbxCtlGlueEscDir::GetEscDirPos( sal_uInt16 nEscDir )
     177             : {
     178           0 :     for( sal_uInt16 i = 0; i < ESCDIR_COUNT; i++ )
     179             :     {
     180           0 :         if( aEscDirArray[ i ] == nEscDir )
     181           0 :             return( i );
     182             :     }
     183           0 :     return( 99 );
     184         114 : }
     185             : 
     186             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10