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

Generated by: LCOV version 1.11