LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/dlg - gluectrl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 59 3.4 %
Date: 2013-07-09 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 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             : 
      58             : 
      59          11 : SFX_IMPL_TOOLBOX_CONTROL( SdTbxCtlGlueEscDir, SfxUInt16Item )
      60             : 
      61             : /**
      62             :  * Constructor for glue point escape direction Listbox
      63             :  */
      64           0 : GlueEscDirLB::GlueEscDirLB( Window* pParent, const Reference< XFrame >& rFrame ) :
      65             :         ListBox( pParent, WinBits( WB_BORDER | WB_DROPDOWN ) ),
      66           0 :         m_xFrame( rFrame )
      67             : {
      68           0 :     String aStr; aStr += sal_Unicode('X');
      69           0 :     Size aXSize( GetTextWidth( aStr ), GetTextHeight() );
      70           0 :     SetSizePixel( Size( aXSize.Width() * 12, aXSize.Height() * 10 ) );
      71           0 :     Fill();
      72           0 :     Show();
      73           0 : }
      74             : 
      75           0 : GlueEscDirLB::~GlueEscDirLB()
      76             : {
      77           0 : }
      78             : 
      79             : /**
      80             :  * Determines the escape direction and sends the corresponding slot
      81             :  */
      82           0 : void GlueEscDirLB::Select()
      83             : {
      84           0 :     sal_uInt16 nPos = GetSelectEntryPos();
      85           0 :     SfxUInt16Item aItem( SID_GLUE_ESCDIR, aEscDirArray[ nPos ] );
      86             : 
      87           0 :     if ( m_xFrame.is() )
      88             :     {
      89           0 :         Any a;
      90           0 :         Sequence< PropertyValue > aArgs( 1 );
      91           0 :         aArgs[0].Name   = "GlueEscapeDirection";
      92           0 :         aItem.QueryValue( a );
      93           0 :         aArgs[0].Value  = a;
      94           0 :         SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ),
      95             :                                     ".uno:GlueEscapeDirection",
      96           0 :                                     aArgs );
      97           0 :     }
      98           0 : }
      99             : 
     100             : /**
     101             :  * Fills the Listbox with strings
     102             :  */
     103           0 : void GlueEscDirLB::Fill()
     104             : {
     105           0 :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_SMART ) ) );
     106           0 :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LEFT ) ) );
     107           0 :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RIGHT ) ) );
     108           0 :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_TOP ) ) );
     109           0 :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_BOTTOM ) ) );
     110             :     /*
     111             :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LO ) ) );
     112             :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LU ) ) );
     113             :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RO ) ) );
     114             :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RU ) ) );
     115             :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_HORZ ) ) );
     116             :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_VERT ) ) );
     117             :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_ALL ) ) );
     118             :     */
     119           0 : }
     120             : 
     121             : /**
     122             :  * Constructor for glue point escape direction toolbox control
     123             :  */
     124           0 : SdTbxCtlGlueEscDir::SdTbxCtlGlueEscDir(
     125             :     sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
     126           0 :         SfxToolBoxControl( nSlotId, nId, rTbx )
     127             : {
     128           0 : }
     129             : 
     130             : /**
     131             :  * Represents state in the listbox of the controller
     132             :  */
     133           0 : void SdTbxCtlGlueEscDir::StateChanged( sal_uInt16 nSId,
     134             :                         SfxItemState eState, const SfxPoolItem* pState )
     135             : {
     136           0 :     if( eState == SFX_ITEM_AVAILABLE )
     137             :     {
     138           0 :         GlueEscDirLB* pGlueEscDirLB = (GlueEscDirLB*) ( GetToolBox().
     139           0 :                                             GetItemWindow( GetId() ) );
     140           0 :         if( pGlueEscDirLB )
     141             :         {
     142           0 :             if( pState )
     143             :             {
     144           0 :                 pGlueEscDirLB->Enable();
     145           0 :                 if ( IsInvalidItem( pState ) )
     146             :                 {
     147           0 :                     pGlueEscDirLB->SetNoSelection();
     148             :                 }
     149             :                 else
     150             :                 {
     151           0 :                     sal_uInt16 nEscDir = ( (const SfxUInt16Item*) pState )->GetValue();
     152           0 :                     pGlueEscDirLB->SelectEntryPos( GetEscDirPos( nEscDir ) );
     153             :                 }
     154             :             }
     155             :             else
     156             :             {
     157           0 :                 pGlueEscDirLB->Disable();
     158           0 :                 pGlueEscDirLB->SetNoSelection();
     159             :             }
     160             :         }
     161             :     }
     162             : 
     163           0 :     SfxToolBoxControl::StateChanged( nSId, eState, pState );
     164           0 : }
     165             : 
     166           0 : Window* SdTbxCtlGlueEscDir::CreateItemWindow( Window *pParent )
     167             : {
     168           0 :     if( GetSlotId() == SID_GLUE_ESCDIR )
     169             :     {
     170           0 :         return( new GlueEscDirLB( pParent, m_xFrame ) );
     171             :     }
     172             : 
     173           0 :     return( NULL );
     174             : }
     175             : 
     176             : 
     177             : /**
     178             :  * Returns position in the array for EscDir (Mapping for Listbox)
     179             :  */
     180           0 : sal_uInt16 SdTbxCtlGlueEscDir::GetEscDirPos( sal_uInt16 nEscDir )
     181             : {
     182           0 :     for( sal_uInt16 i = 0; i < ESCDIR_COUNT; i++ )
     183             :     {
     184           0 :         if( aEscDirArray[ i ] == nEscDir )
     185           0 :             return( i );
     186             :     }
     187           0 :     return( 99 );
     188          33 : }
     189             : 
     190             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10