LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/dlg - gluectrl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 58 1.7 %
Date: 2012-12-17 Functions: 1 11 9.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             : // z.Z. werden von Joe nur die u.a. Moeglichkeiten unterstuetzt
      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           6 : SFX_IMPL_TOOLBOX_CONTROL( SdTbxCtlGlueEscDir, SfxUInt16Item )
      60             : 
      61             : /*************************************************************************
      62             : |*
      63             : |* Konstruktor fuer Klebepunkt-Autrittsrichtungs-Listbox
      64             : |*
      65             : \************************************************************************/
      66             : 
      67           0 : GlueEscDirLB::GlueEscDirLB( Window* pParent, const Reference< XFrame >& rFrame ) :
      68             :         ListBox( pParent, WinBits( WB_BORDER | WB_DROPDOWN ) ),
      69           0 :         m_xFrame( rFrame )
      70             : {
      71           0 :     String aStr; aStr += sal_Unicode('X');
      72           0 :     Size aXSize( GetTextWidth( aStr ), GetTextHeight() );
      73           0 :     SetSizePixel( Size( aXSize.Width() * 12, aXSize.Height() * 10 ) );
      74           0 :     Fill();
      75           0 :     Show();
      76           0 : }
      77             : 
      78             : /*************************************************************************
      79             : |*
      80             : |*  Dtor
      81             : |*
      82             : \************************************************************************/
      83             : 
      84           0 : GlueEscDirLB::~GlueEscDirLB()
      85             : {
      86           0 : }
      87             : 
      88             : /*************************************************************************
      89             : |*
      90             : |* Ermittelt die Austrittsrichtung und verschickt den entspr. Slot
      91             : |*
      92             : \************************************************************************/
      93             : 
      94           0 : void GlueEscDirLB::Select()
      95             : {
      96           0 :     sal_uInt16 nPos = GetSelectEntryPos();
      97           0 :     SfxUInt16Item aItem( SID_GLUE_ESCDIR, aEscDirArray[ nPos ] );
      98             : 
      99           0 :     if ( m_xFrame.is() )
     100             :     {
     101           0 :         Any a;
     102           0 :         Sequence< PropertyValue > aArgs( 1 );
     103           0 :         aArgs[0].Name   = "GlueEscapeDirection";
     104           0 :         aItem.QueryValue( a );
     105           0 :         aArgs[0].Value  = a;
     106           0 :         SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ),
     107             :                                     ".uno:GlueEscapeDirection",
     108           0 :                                     aArgs );
     109           0 :     }
     110           0 : }
     111             : 
     112             : /*************************************************************************
     113             : |*
     114             : |* Fuellen der Listbox mit Strings
     115             : |*
     116             : \************************************************************************/
     117             : 
     118           0 : void GlueEscDirLB::Fill()
     119             : {
     120           0 :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_SMART ) ) );
     121           0 :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LEFT ) ) );
     122           0 :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RIGHT ) ) );
     123           0 :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_TOP ) ) );
     124           0 :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_BOTTOM ) ) );
     125             :     /*
     126             :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LO ) ) );
     127             :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LU ) ) );
     128             :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RO ) ) );
     129             :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RU ) ) );
     130             :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_HORZ ) ) );
     131             :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_VERT ) ) );
     132             :     InsertEntry( String( SdResId( STR_GLUE_ESCDIR_ALL ) ) );
     133             :     */
     134           0 : }
     135             : 
     136             : /*************************************************************************
     137             : |*
     138             : |* Konstruktor fuer Klebepunkt-Autrittsrichtungs-Toolbox-Control
     139             : |*
     140             : \************************************************************************/
     141             : 
     142           0 : SdTbxCtlGlueEscDir::SdTbxCtlGlueEscDir(
     143             :     sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
     144           0 :         SfxToolBoxControl( nSlotId, nId, rTbx )
     145             : {
     146           0 : }
     147             : 
     148             : /*************************************************************************
     149             : |*
     150             : |* Stellt Status in der Listbox des Controllers dar
     151             : |*
     152             : \************************************************************************/
     153             : 
     154           0 : void SdTbxCtlGlueEscDir::StateChanged( sal_uInt16 nSId,
     155             :                         SfxItemState eState, const SfxPoolItem* pState )
     156             : {
     157           0 :     if( eState == SFX_ITEM_AVAILABLE )
     158             :     {
     159           0 :         GlueEscDirLB* pGlueEscDirLB = (GlueEscDirLB*) ( GetToolBox().
     160           0 :                                             GetItemWindow( GetId() ) );
     161           0 :         if( pGlueEscDirLB )
     162             :         {
     163           0 :             if( pState )
     164             :             {
     165           0 :                 pGlueEscDirLB->Enable();
     166           0 :                 if ( IsInvalidItem( pState ) )
     167             :                 {
     168           0 :                     pGlueEscDirLB->SetNoSelection();
     169             :                 }
     170             :                 else
     171             :                 {
     172           0 :                     sal_uInt16 nEscDir = ( (const SfxUInt16Item*) pState )->GetValue();
     173           0 :                     pGlueEscDirLB->SelectEntryPos( GetEscDirPos( nEscDir ) );
     174             :                 }
     175             :             }
     176             :             else
     177             :             {
     178           0 :                 pGlueEscDirLB->Disable();
     179           0 :                 pGlueEscDirLB->SetNoSelection();
     180             :             }
     181             :         }
     182             :     }
     183             : 
     184           0 :     SfxToolBoxControl::StateChanged( nSId, eState, pState );
     185           0 : }
     186             : 
     187           0 : Window* SdTbxCtlGlueEscDir::CreateItemWindow( Window *pParent )
     188             : {
     189           0 :     if( GetSlotId() == SID_GLUE_ESCDIR )
     190             :     {
     191           0 :         return( new GlueEscDirLB( pParent, m_xFrame ) );
     192             :     }
     193             : 
     194           0 :     return( NULL );
     195             : }
     196             : 
     197             : 
     198             : /*************************************************************************
     199             : |*
     200             : |* Liefert Position im Array fuer EscDir zurueck (Mapping fuer Listbox)
     201             : |*
     202             : \************************************************************************/
     203             : 
     204           0 : sal_uInt16 SdTbxCtlGlueEscDir::GetEscDirPos( sal_uInt16 nEscDir )
     205             : {
     206           0 :     for( sal_uInt16 i = 0; i < ESCDIR_COUNT; i++ )
     207             :     {
     208           0 :         if( aEscDirArray[ i ] == nEscDir )
     209           0 :             return( i );
     210             :     }
     211           0 :     return( 99 );
     212             : }
     213             : 
     214             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10