fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / dlg / gluectrl.cxx
blobb1f760eee7cc52a20a2628bc747d18b8a5f60212
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <string>
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>
30 #include "strings.hrc"
31 #include "gluectrl.hxx"
32 #include "sdresid.hxx"
33 #include "app.hrc"
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::beans;
37 using namespace ::com::sun::star::frame;
39 // at the moment, Joe only supports the methods specified below
40 #define ESCDIR_COUNT 5
41 static sal_uInt16 aEscDirArray[] =
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
59 SFX_IMPL_TOOLBOX_CONTROL( SdTbxCtlGlueEscDir, SfxUInt16Item )
61 /**
62 * Constructor for glue point escape direction Listbox
64 GlueEscDirLB::GlueEscDirLB( Window* pParent, const Reference< XFrame >& rFrame ) :
65 ListBox( pParent, WinBits( WB_BORDER | WB_DROPDOWN ) ),
66 m_xFrame( rFrame )
68 String aStr; aStr += sal_Unicode('X');
69 Size aXSize( GetTextWidth( aStr ), GetTextHeight() );
70 SetSizePixel( Size( aXSize.Width() * 12, aXSize.Height() * 10 ) );
71 Fill();
72 Show();
75 GlueEscDirLB::~GlueEscDirLB()
79 /**
80 * Determines the escape direction and sends the corresponding slot
82 void GlueEscDirLB::Select()
84 sal_uInt16 nPos = GetSelectEntryPos();
85 SfxUInt16Item aItem( SID_GLUE_ESCDIR, aEscDirArray[ nPos ] );
87 if ( m_xFrame.is() )
89 Any a;
90 Sequence< PropertyValue > aArgs( 1 );
91 aArgs[0].Name = "GlueEscapeDirection";
92 aItem.QueryValue( a );
93 aArgs[0].Value = a;
94 SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ),
95 ".uno:GlueEscapeDirection",
96 aArgs );
101 * Fills the Listbox with strings
103 void GlueEscDirLB::Fill()
105 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_SMART ) ) );
106 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LEFT ) ) );
107 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RIGHT ) ) );
108 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_TOP ) ) );
109 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_BOTTOM ) ) );
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 ) ) );
122 * Constructor for glue point escape direction toolbox control
124 SdTbxCtlGlueEscDir::SdTbxCtlGlueEscDir(
125 sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
126 SfxToolBoxControl( nSlotId, nId, rTbx )
131 * Represents state in the listbox of the controller
133 void SdTbxCtlGlueEscDir::StateChanged( sal_uInt16 nSId,
134 SfxItemState eState, const SfxPoolItem* pState )
136 if( eState == SFX_ITEM_AVAILABLE )
138 GlueEscDirLB* pGlueEscDirLB = (GlueEscDirLB*) ( GetToolBox().
139 GetItemWindow( GetId() ) );
140 if( pGlueEscDirLB )
142 if( pState )
144 pGlueEscDirLB->Enable();
145 if ( IsInvalidItem( pState ) )
147 pGlueEscDirLB->SetNoSelection();
149 else
151 sal_uInt16 nEscDir = ( (const SfxUInt16Item*) pState )->GetValue();
152 pGlueEscDirLB->SelectEntryPos( GetEscDirPos( nEscDir ) );
155 else
157 pGlueEscDirLB->Disable();
158 pGlueEscDirLB->SetNoSelection();
163 SfxToolBoxControl::StateChanged( nSId, eState, pState );
166 Window* SdTbxCtlGlueEscDir::CreateItemWindow( Window *pParent )
168 if( GetSlotId() == SID_GLUE_ESCDIR )
170 return( new GlueEscDirLB( pParent, m_xFrame ) );
173 return( NULL );
178 * Returns position in the array for EscDir (Mapping for Listbox)
180 sal_uInt16 SdTbxCtlGlueEscDir::GetEscDirPos( sal_uInt16 nEscDir )
182 for( sal_uInt16 i = 0; i < ESCDIR_COUNT; i++ )
184 if( aEscDirArray[ i ] == nEscDir )
185 return( i );
187 return( 99 );
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */