Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : #/*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <string>
30 : :
31 : : #include <svx/dialogs.hrc>
32 : : #include <svx/svdglue.hxx>
33 : : #include <svl/intitem.hxx>
34 : : #include <sfx2/app.hxx>
35 : : #include <sfx2/dispatch.hxx>
36 : : #include <vcl/toolbox.hxx>
37 : : #include <sfx2/viewfrm.hxx>
38 : :
39 : : #include "strings.hrc"
40 : : #include "gluectrl.hxx"
41 : : #include "sdresid.hxx"
42 : : #include "app.hrc"
43 : :
44 : : using namespace ::com::sun::star::uno;
45 : : using namespace ::com::sun::star::beans;
46 : : using namespace ::com::sun::star::frame;
47 : :
48 : : // z.Z. werden von Joe nur die u.a. Moeglichkeiten unterstuetzt
49 : : #define ESCDIR_COUNT 5
50 : : static sal_uInt16 aEscDirArray[] =
51 : : {
52 : : SDRESC_SMART,
53 : : SDRESC_LEFT,
54 : : SDRESC_RIGHT,
55 : : SDRESC_TOP,
56 : : SDRESC_BOTTOM,
57 : : // SDRESC_LO,
58 : : // SDRESC_LU,
59 : : // SDRESC_RO,
60 : : // SDRESC_RU,
61 : : // SDRESC_HORZ,
62 : : // SDRESC_VERT,
63 : : // SDRESC_ALL
64 : : };
65 : :
66 : :
67 : :
68 [ # # ]: 25 : SFX_IMPL_TOOLBOX_CONTROL( SdTbxCtlGlueEscDir, SfxUInt16Item )
69 : :
70 : : /*************************************************************************
71 : : |*
72 : : |* Konstruktor fuer Klebepunkt-Autrittsrichtungs-Listbox
73 : : |*
74 : : \************************************************************************/
75 : :
76 : 0 : GlueEscDirLB::GlueEscDirLB( Window* pParent, const Reference< XFrame >& rFrame ) :
77 : : ListBox( pParent, WinBits( WB_BORDER | WB_DROPDOWN ) ),
78 : 0 : m_xFrame( rFrame )
79 : : {
80 [ # # ][ # # ]: 0 : String aStr; aStr += sal_Unicode('X');
81 [ # # ][ # # ]: 0 : Size aXSize( GetTextWidth( aStr ), GetTextHeight() );
82 [ # # ]: 0 : SetSizePixel( Size( aXSize.Width() * 12, aXSize.Height() * 10 ) );
83 [ # # ]: 0 : Fill();
84 [ # # ][ # # ]: 0 : Show();
85 : 0 : }
86 : :
87 : : /*************************************************************************
88 : : |*
89 : : |* Dtor
90 : : |*
91 : : \************************************************************************/
92 : :
93 : 0 : GlueEscDirLB::~GlueEscDirLB()
94 : : {
95 [ # # ]: 0 : }
96 : :
97 : : /*************************************************************************
98 : : |*
99 : : |* Ermittelt die Austrittsrichtung und verschickt den entspr. Slot
100 : : |*
101 : : \************************************************************************/
102 : :
103 : 0 : void GlueEscDirLB::Select()
104 : : {
105 [ # # ]: 0 : sal_uInt16 nPos = GetSelectEntryPos();
106 [ # # ]: 0 : SfxUInt16Item aItem( SID_GLUE_ESCDIR, aEscDirArray[ nPos ] );
107 : :
108 [ # # ]: 0 : if ( m_xFrame.is() )
109 : : {
110 : 0 : Any a;
111 [ # # ]: 0 : Sequence< PropertyValue > aArgs( 1 );
112 [ # # ]: 0 : aArgs[0].Name = "GlueEscapeDirection";
113 [ # # ]: 0 : aItem.QueryValue( a );
114 [ # # ]: 0 : aArgs[0].Value = a;
115 [ # # ]: 0 : SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ),
116 : : ".uno:GlueEscapeDirection",
117 [ # # ][ # # ]: 0 : aArgs );
[ # # ][ # # ]
118 [ # # ]: 0 : }
119 : 0 : }
120 : :
121 : : /*************************************************************************
122 : : |*
123 : : |* Fuellen der Listbox mit Strings
124 : : |*
125 : : \************************************************************************/
126 : :
127 : 0 : void GlueEscDirLB::Fill()
128 : : {
129 [ # # ][ # # ]: 0 : InsertEntry( String( SdResId( STR_GLUE_ESCDIR_SMART ) ) );
[ # # ]
130 [ # # ][ # # ]: 0 : InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LEFT ) ) );
[ # # ]
131 [ # # ][ # # ]: 0 : InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RIGHT ) ) );
[ # # ]
132 [ # # ][ # # ]: 0 : InsertEntry( String( SdResId( STR_GLUE_ESCDIR_TOP ) ) );
[ # # ]
133 [ # # ][ # # ]: 0 : InsertEntry( String( SdResId( STR_GLUE_ESCDIR_BOTTOM ) ) );
[ # # ]
134 : : /*
135 : : InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LO ) ) );
136 : : InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LU ) ) );
137 : : InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RO ) ) );
138 : : InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RU ) ) );
139 : : InsertEntry( String( SdResId( STR_GLUE_ESCDIR_HORZ ) ) );
140 : : InsertEntry( String( SdResId( STR_GLUE_ESCDIR_VERT ) ) );
141 : : InsertEntry( String( SdResId( STR_GLUE_ESCDIR_ALL ) ) );
142 : : */
143 : 0 : }
144 : :
145 : : /*************************************************************************
146 : : |*
147 : : |* Konstruktor fuer Klebepunkt-Autrittsrichtungs-Toolbox-Control
148 : : |*
149 : : \************************************************************************/
150 : :
151 : 0 : SdTbxCtlGlueEscDir::SdTbxCtlGlueEscDir(
152 : : sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
153 : 0 : SfxToolBoxControl( nSlotId, nId, rTbx )
154 : : {
155 : 0 : }
156 : :
157 : : /*************************************************************************
158 : : |*
159 : : |* Stellt Status in der Listbox des Controllers dar
160 : : |*
161 : : \************************************************************************/
162 : :
163 : 0 : void SdTbxCtlGlueEscDir::StateChanged( sal_uInt16 nSId,
164 : : SfxItemState eState, const SfxPoolItem* pState )
165 : : {
166 [ # # ]: 0 : if( eState == SFX_ITEM_AVAILABLE )
167 : : {
168 : 0 : GlueEscDirLB* pGlueEscDirLB = (GlueEscDirLB*) ( GetToolBox().
169 : 0 : GetItemWindow( GetId() ) );
170 [ # # ]: 0 : if( pGlueEscDirLB )
171 : : {
172 [ # # ]: 0 : if( pState )
173 : : {
174 : 0 : pGlueEscDirLB->Enable();
175 [ # # ]: 0 : if ( IsInvalidItem( pState ) )
176 : : {
177 : 0 : pGlueEscDirLB->SetNoSelection();
178 : : }
179 : : else
180 : : {
181 : 0 : sal_uInt16 nEscDir = ( (const SfxUInt16Item*) pState )->GetValue();
182 : 0 : pGlueEscDirLB->SelectEntryPos( GetEscDirPos( nEscDir ) );
183 : : }
184 : : }
185 : : else
186 : : {
187 : 0 : pGlueEscDirLB->Disable();
188 : 0 : pGlueEscDirLB->SetNoSelection();
189 : : }
190 : : }
191 : : }
192 : :
193 : 0 : SfxToolBoxControl::StateChanged( nSId, eState, pState );
194 : 0 : }
195 : :
196 : 0 : Window* SdTbxCtlGlueEscDir::CreateItemWindow( Window *pParent )
197 : : {
198 [ # # ]: 0 : if( GetSlotId() == SID_GLUE_ESCDIR )
199 : : {
200 [ # # ]: 0 : return( new GlueEscDirLB( pParent, m_xFrame ) );
201 : : }
202 : :
203 : 0 : return( NULL );
204 : : }
205 : :
206 : :
207 : : /*************************************************************************
208 : : |*
209 : : |* Liefert Position im Array fuer EscDir zurueck (Mapping fuer Listbox)
210 : : |*
211 : : \************************************************************************/
212 : :
213 : 0 : sal_uInt16 SdTbxCtlGlueEscDir::GetEscDirPos( sal_uInt16 nEscDir )
214 : : {
215 [ # # ]: 0 : for( sal_uInt16 i = 0; i < ESCDIR_COUNT; i++ )
216 : : {
217 [ # # ]: 0 : if( aEscDirArray[ i ] == nEscDir )
218 : 0 : return( i );
219 : : }
220 : 0 : return( 99 );
221 : : }
222 : :
223 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|