1 #/*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: gluectrl.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
35 #include <string> // HACK: prevent conflict between STLPORT and Workshop headers
37 #include <svx/dialogs.hrc>
38 #include <svx/svdglue.hxx>
39 #include <svtools/intitem.hxx>
40 #include <sfx2/app.hxx>
41 #include <sfx2/dispatch.hxx>
42 #include <vcl/toolbox.hxx>
43 #include <sfx2/viewfrm.hxx>
45 #include "strings.hrc"
46 #include "gluectrl.hxx"
47 #include "sdresid.hxx"
50 using namespace ::com::sun::star::uno
;
51 using namespace ::com::sun::star::beans
;
52 using namespace ::com::sun::star::frame
;
54 // z.Z. werden von Joe nur die u.a. Moeglichkeiten unterstuetzt
55 #define ESCDIR_COUNT 5
56 static UINT16 aEscDirArray
[] =
74 SFX_IMPL_TOOLBOX_CONTROL( SdTbxCtlGlueEscDir
, SfxUInt16Item
)
76 /*************************************************************************
78 |* Konstruktor fuer Klebepunkt-Autrittsrichtungs-Listbox
80 \************************************************************************/
82 GlueEscDirLB::GlueEscDirLB( Window
* pParent
, const Reference
< XFrame
>& rFrame
) :
83 ListBox( pParent
, WinBits( WB_BORDER
| WB_DROPDOWN
) ),
86 String aStr
; aStr
+= sal_Unicode('X');
87 Size
aXSize( GetTextWidth( aStr
), GetTextHeight() );
88 //SetPosPixel( Point( aSize.Width(), 0 ) );
89 SetSizePixel( Size( aXSize
.Width() * 12, aXSize
.Height() * 10 ) );
91 //SelectEntryPos( 0 );
95 /*************************************************************************
99 \************************************************************************/
101 GlueEscDirLB::~GlueEscDirLB()
105 /*************************************************************************
107 |* Ermittelt die Austrittsrichtung und verschickt den entspr. Slot
109 \************************************************************************/
111 void GlueEscDirLB::Select()
113 UINT16 nPos
= GetSelectEntryPos();
114 SfxUInt16Item
aItem( SID_GLUE_ESCDIR
, aEscDirArray
[ nPos
] );
119 Sequence
< PropertyValue
> aArgs( 1 );
120 aArgs
[0].Name
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GlueEscapeDirection" ));
121 aItem
.QueryValue( a
);
123 SfxToolBoxControl::Dispatch( Reference
< XDispatchProvider
>( m_xFrame
->getController(), UNO_QUERY
),
124 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GlueEscapeDirection" )),
128 SfxViewFrame::Current()->GetDispatcher()->Execute( SID_GLUE_ESCDIR, SFX_CALLMODE_ASYNCHRON |
129 SFX_CALLMODE_RECORD, &aItem, (void*) NULL, 0L );
133 /*************************************************************************
135 |* Fuellen der Listbox mit Strings
137 \************************************************************************/
139 void GlueEscDirLB::Fill()
141 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_SMART
) ) );
142 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LEFT
) ) );
143 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RIGHT
) ) );
144 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_TOP
) ) );
145 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_BOTTOM
) ) );
147 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LO ) ) );
148 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LU ) ) );
149 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RO ) ) );
150 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RU ) ) );
151 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_HORZ ) ) );
152 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_VERT ) ) );
153 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_ALL ) ) );
157 /*************************************************************************
159 |* Konstruktor fuer Klebepunkt-Autrittsrichtungs-Toolbox-Control
161 \************************************************************************/
163 SdTbxCtlGlueEscDir::SdTbxCtlGlueEscDir(
164 USHORT nSlotId
, USHORT nId
, ToolBox
& rTbx
) :
165 SfxToolBoxControl( nSlotId
, nId
, rTbx
)
169 /*************************************************************************
171 |* Stellt Status in der Listbox des Controllers dar
173 \************************************************************************/
175 void SdTbxCtlGlueEscDir::StateChanged( USHORT nSId
,
176 SfxItemState eState
, const SfxPoolItem
* pState
)
178 if( eState
== SFX_ITEM_AVAILABLE
)
180 GlueEscDirLB
* pGlueEscDirLB
= (GlueEscDirLB
*) ( GetToolBox().
181 GetItemWindow( GetId() ) );
186 pGlueEscDirLB
->Enable();
187 if ( IsInvalidItem( pState
) )
189 pGlueEscDirLB
->SetNoSelection();
193 UINT16 nEscDir
= ( (const SfxUInt16Item
*) pState
)->GetValue();
194 pGlueEscDirLB
->SelectEntryPos( GetEscDirPos( nEscDir
) );
199 pGlueEscDirLB
->Disable();
200 pGlueEscDirLB
->SetNoSelection();
205 SfxToolBoxControl::StateChanged( nSId
, eState
, pState
);
208 /*************************************************************************
212 \************************************************************************/
214 Window
* SdTbxCtlGlueEscDir::CreateItemWindow( Window
*pParent
)
216 if( GetSlotId() == SID_GLUE_ESCDIR
)
218 return( new GlueEscDirLB( pParent
, m_xFrame
) );
225 /*************************************************************************
227 |* Liefert Position im Array fuer EscDir zurueck (Mapping fuer Listbox)
229 \************************************************************************/
231 UINT16
SdTbxCtlGlueEscDir::GetEscDirPos( UINT16 nEscDir
)
233 for( UINT16 i
= 0; i
< ESCDIR_COUNT
; i
++ )
235 if( aEscDirArray
[ i
] == nEscDir
)