xref: /aoo41x/main/sd/source/ui/dlg/gluectrl.cxx (revision 79aad27f)
1*5b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*5b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*5b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*5b190011SAndrew Rist  * distributed with this work for additional information
6*5b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*5b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*5b190011SAndrew Rist  * "License"); you may not use this file except in compliance
9*5b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*5b190011SAndrew Rist  *
11*5b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*5b190011SAndrew Rist  *
13*5b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*5b190011SAndrew Rist  * software distributed under the License is distributed on an
15*5b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
17*5b190011SAndrew Rist  * specific language governing permissions and limitations
18*5b190011SAndrew Rist  * under the License.
19*5b190011SAndrew Rist  *
20*5b190011SAndrew Rist  *************************************************************/
21*5b190011SAndrew Rist 
22*5b190011SAndrew Rist #
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <string> // HACK: prevent conflict between STLPORT and Workshop headers
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <svx/dialogs.hrc>
31cdf0e10cSrcweir #include <svx/svdglue.hxx>
32cdf0e10cSrcweir #include <svl/intitem.hxx>
33cdf0e10cSrcweir #include <sfx2/app.hxx>
34cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
35cdf0e10cSrcweir #include <vcl/toolbox.hxx>
36cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #include "strings.hrc"
39cdf0e10cSrcweir #include "gluectrl.hxx"
40cdf0e10cSrcweir #include "sdresid.hxx"
41cdf0e10cSrcweir #include "app.hrc"
42cdf0e10cSrcweir 
43cdf0e10cSrcweir using namespace ::com::sun::star::uno;
44cdf0e10cSrcweir using namespace ::com::sun::star::beans;
45cdf0e10cSrcweir using namespace ::com::sun::star::frame;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir // z.Z. werden von Joe nur die u.a. Moeglichkeiten unterstuetzt
48cdf0e10cSrcweir #define ESCDIR_COUNT 5
49cdf0e10cSrcweir static sal_uInt16 aEscDirArray[] =
50cdf0e10cSrcweir {
51cdf0e10cSrcweir 	SDRESC_SMART,
52cdf0e10cSrcweir 	SDRESC_LEFT,
53cdf0e10cSrcweir 	SDRESC_RIGHT,
54cdf0e10cSrcweir 	SDRESC_TOP,
55cdf0e10cSrcweir 	SDRESC_BOTTOM,
56cdf0e10cSrcweir //	SDRESC_LO,
57cdf0e10cSrcweir //	SDRESC_LU,
58cdf0e10cSrcweir //	SDRESC_RO,
59cdf0e10cSrcweir //	SDRESC_RU,
60cdf0e10cSrcweir //	SDRESC_HORZ,
61cdf0e10cSrcweir //	SDRESC_VERT,
62cdf0e10cSrcweir //	SDRESC_ALL
63cdf0e10cSrcweir };
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 
SFX_IMPL_TOOLBOX_CONTROL(SdTbxCtlGlueEscDir,SfxUInt16Item)67cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL( SdTbxCtlGlueEscDir, SfxUInt16Item )
68cdf0e10cSrcweir 
69cdf0e10cSrcweir /*************************************************************************
70cdf0e10cSrcweir |*
71cdf0e10cSrcweir |* Konstruktor fuer Klebepunkt-Autrittsrichtungs-Listbox
72cdf0e10cSrcweir |*
73cdf0e10cSrcweir \************************************************************************/
74cdf0e10cSrcweir 
75cdf0e10cSrcweir GlueEscDirLB::GlueEscDirLB( Window* pParent, const Reference< XFrame >& rFrame ) :
76cdf0e10cSrcweir 		ListBox( pParent, WinBits( WB_BORDER | WB_DROPDOWN ) ),
77cdf0e10cSrcweir         m_xFrame( rFrame )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir 	String aStr; aStr += sal_Unicode('X');
80cdf0e10cSrcweir 	Size aXSize( GetTextWidth( aStr ), GetTextHeight() );
81cdf0e10cSrcweir 	//SetPosPixel( Point( aSize.Width(), 0 ) );
82cdf0e10cSrcweir 	SetSizePixel( Size( aXSize.Width() * 12, aXSize.Height() * 10 ) );
83cdf0e10cSrcweir 	Fill();
84cdf0e10cSrcweir 	//SelectEntryPos( 0 );
85cdf0e10cSrcweir 	Show();
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
88cdf0e10cSrcweir /*************************************************************************
89cdf0e10cSrcweir |*
90cdf0e10cSrcweir |*	Dtor
91cdf0e10cSrcweir |*
92cdf0e10cSrcweir \************************************************************************/
93cdf0e10cSrcweir 
~GlueEscDirLB()94cdf0e10cSrcweir GlueEscDirLB::~GlueEscDirLB()
95cdf0e10cSrcweir {
96cdf0e10cSrcweir }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir /*************************************************************************
99cdf0e10cSrcweir |*
100cdf0e10cSrcweir |* Ermittelt die Austrittsrichtung und verschickt den entspr. Slot
101cdf0e10cSrcweir |*
102cdf0e10cSrcweir \************************************************************************/
103cdf0e10cSrcweir 
Select()104cdf0e10cSrcweir void GlueEscDirLB::Select()
105cdf0e10cSrcweir {
106cdf0e10cSrcweir 	sal_uInt16 nPos = GetSelectEntryPos();
107cdf0e10cSrcweir 	SfxUInt16Item aItem( SID_GLUE_ESCDIR, aEscDirArray[ nPos ] );
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     if ( m_xFrame.is() )
110cdf0e10cSrcweir     {
111cdf0e10cSrcweir         Any a;
112cdf0e10cSrcweir         Sequence< PropertyValue > aArgs( 1 );
113cdf0e10cSrcweir         aArgs[0].Name   = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GlueEscapeDirection" ));
114cdf0e10cSrcweir         aItem.QueryValue( a );
115cdf0e10cSrcweir         aArgs[0].Value  = a;
116cdf0e10cSrcweir         SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ),
117cdf0e10cSrcweir                                     rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GlueEscapeDirection" )),
118cdf0e10cSrcweir                                     aArgs );
119cdf0e10cSrcweir     }
120cdf0e10cSrcweir /*
121cdf0e10cSrcweir 	SfxViewFrame::Current()->GetDispatcher()->Execute( SID_GLUE_ESCDIR, SFX_CALLMODE_ASYNCHRON |
122cdf0e10cSrcweir 													   SFX_CALLMODE_RECORD, &aItem, (void*) NULL, 0L );
123cdf0e10cSrcweir */
124cdf0e10cSrcweir }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir /*************************************************************************
127cdf0e10cSrcweir |*
128cdf0e10cSrcweir |* Fuellen der Listbox mit Strings
129cdf0e10cSrcweir |*
130cdf0e10cSrcweir \************************************************************************/
131cdf0e10cSrcweir 
Fill()132cdf0e10cSrcweir void GlueEscDirLB::Fill()
133cdf0e10cSrcweir {
134cdf0e10cSrcweir 	InsertEntry( String( SdResId( STR_GLUE_ESCDIR_SMART ) ) );
135cdf0e10cSrcweir 	InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LEFT ) ) );
136cdf0e10cSrcweir 	InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RIGHT ) ) );
137cdf0e10cSrcweir 	InsertEntry( String( SdResId( STR_GLUE_ESCDIR_TOP ) ) );
138cdf0e10cSrcweir 	InsertEntry( String( SdResId( STR_GLUE_ESCDIR_BOTTOM ) ) );
139cdf0e10cSrcweir 	/*
140cdf0e10cSrcweir 	InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LO ) ) );
141cdf0e10cSrcweir 	InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LU ) ) );
142cdf0e10cSrcweir 	InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RO ) ) );
143cdf0e10cSrcweir 	InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RU ) ) );
144cdf0e10cSrcweir 	InsertEntry( String( SdResId( STR_GLUE_ESCDIR_HORZ ) ) );
145cdf0e10cSrcweir 	InsertEntry( String( SdResId( STR_GLUE_ESCDIR_VERT ) ) );
146cdf0e10cSrcweir 	InsertEntry( String( SdResId( STR_GLUE_ESCDIR_ALL ) ) );
147cdf0e10cSrcweir 	*/
148cdf0e10cSrcweir }
149cdf0e10cSrcweir 
150cdf0e10cSrcweir /*************************************************************************
151cdf0e10cSrcweir |*
152cdf0e10cSrcweir |* Konstruktor fuer Klebepunkt-Autrittsrichtungs-Toolbox-Control
153cdf0e10cSrcweir |*
154cdf0e10cSrcweir \************************************************************************/
155cdf0e10cSrcweir 
SdTbxCtlGlueEscDir(sal_uInt16 nSlotId,sal_uInt16 nId,ToolBox & rTbx)156cdf0e10cSrcweir SdTbxCtlGlueEscDir::SdTbxCtlGlueEscDir(
157cdf0e10cSrcweir     sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
158cdf0e10cSrcweir 		SfxToolBoxControl( nSlotId, nId, rTbx )
159cdf0e10cSrcweir {
160cdf0e10cSrcweir }
161cdf0e10cSrcweir 
162cdf0e10cSrcweir /*************************************************************************
163cdf0e10cSrcweir |*
164cdf0e10cSrcweir |* Stellt Status in der Listbox des Controllers dar
165cdf0e10cSrcweir |*
166cdf0e10cSrcweir \************************************************************************/
167cdf0e10cSrcweir 
StateChanged(sal_uInt16 nSId,SfxItemState eState,const SfxPoolItem * pState)168cdf0e10cSrcweir void SdTbxCtlGlueEscDir::StateChanged( sal_uInt16 nSId,
169cdf0e10cSrcweir 						SfxItemState eState, const SfxPoolItem* pState )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir 	if( eState == SFX_ITEM_AVAILABLE )
172cdf0e10cSrcweir 	{
173cdf0e10cSrcweir 		GlueEscDirLB* pGlueEscDirLB = (GlueEscDirLB*) ( GetToolBox().
174cdf0e10cSrcweir 											GetItemWindow( GetId() ) );
175cdf0e10cSrcweir 		if( pGlueEscDirLB )
176cdf0e10cSrcweir 		{
177cdf0e10cSrcweir 			if( pState )
178cdf0e10cSrcweir 			{
179cdf0e10cSrcweir 				pGlueEscDirLB->Enable();
180cdf0e10cSrcweir 				if ( IsInvalidItem( pState ) )
181cdf0e10cSrcweir 				{
182cdf0e10cSrcweir 					pGlueEscDirLB->SetNoSelection();
183cdf0e10cSrcweir 				}
184cdf0e10cSrcweir 				else
185cdf0e10cSrcweir 				{
186cdf0e10cSrcweir 					sal_uInt16 nEscDir = ( (const SfxUInt16Item*) pState )->GetValue();
187cdf0e10cSrcweir 					pGlueEscDirLB->SelectEntryPos( GetEscDirPos( nEscDir ) );
188cdf0e10cSrcweir 				}
189cdf0e10cSrcweir 			}
190cdf0e10cSrcweir 			else
191cdf0e10cSrcweir 			{
192cdf0e10cSrcweir 				pGlueEscDirLB->Disable();
193cdf0e10cSrcweir 				pGlueEscDirLB->SetNoSelection();
194cdf0e10cSrcweir 			}
195cdf0e10cSrcweir 		}
196cdf0e10cSrcweir 	}
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 	SfxToolBoxControl::StateChanged( nSId, eState, pState );
199cdf0e10cSrcweir }
200cdf0e10cSrcweir 
201cdf0e10cSrcweir /*************************************************************************
202cdf0e10cSrcweir |*
203cdf0e10cSrcweir |* No Comment
204cdf0e10cSrcweir |*
205cdf0e10cSrcweir \************************************************************************/
206cdf0e10cSrcweir 
CreateItemWindow(Window * pParent)207cdf0e10cSrcweir Window* SdTbxCtlGlueEscDir::CreateItemWindow( Window *pParent )
208cdf0e10cSrcweir {
209cdf0e10cSrcweir 	if( GetSlotId() == SID_GLUE_ESCDIR )
210cdf0e10cSrcweir 	{
211cdf0e10cSrcweir 		return( new GlueEscDirLB( pParent, m_xFrame ) );
212cdf0e10cSrcweir 	}
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 	return( NULL );
215cdf0e10cSrcweir }
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 
218cdf0e10cSrcweir /*************************************************************************
219cdf0e10cSrcweir |*
220cdf0e10cSrcweir |* Liefert Position im Array fuer EscDir zurueck (Mapping fuer Listbox)
221cdf0e10cSrcweir |*
222cdf0e10cSrcweir \************************************************************************/
223cdf0e10cSrcweir 
GetEscDirPos(sal_uInt16 nEscDir)224cdf0e10cSrcweir sal_uInt16 SdTbxCtlGlueEscDir::GetEscDirPos( sal_uInt16 nEscDir )
225cdf0e10cSrcweir {
226cdf0e10cSrcweir 	for( sal_uInt16 i = 0; i < ESCDIR_COUNT; i++ )
227cdf0e10cSrcweir 	{
228cdf0e10cSrcweir 		if( aEscDirArray[ i ] == nEscDir )
229cdf0e10cSrcweir 			return( i );
230cdf0e10cSrcweir 	}
231cdf0e10cSrcweir 	return( 99 );
232cdf0e10cSrcweir }
233