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 : :
30 : : #include <com/sun/star/text/WritingMode.hpp>
31 : :
32 : : #include <vcl/toolbox.hxx>
33 : :
34 : : #include <svl/itempool.hxx>
35 : :
36 : : #include <svtools/toolbarmenu.hxx>
37 : : #include <svtools/popupwindowcontroller.hxx>
38 : : #include <svtools/popupmenucontrollerbase.hxx>
39 : :
40 : : #include <sfx2/app.hxx>
41 : : #include <sfx2/dispatch.hxx>
42 : :
43 : : #include <editeng/eeitem.hxx>
44 : : #include <editeng/frmdiritem.hxx>
45 : :
46 : : #include <svx/fmmodel.hxx>
47 : : #include <svx/svxids.hrc>
48 : : #include <svx/dialmgr.hxx>
49 : : #include <svx/dialogs.hrc>
50 : : #include <svx/svdpage.hxx>
51 : : #include <svx/svdobj.hxx>
52 : : #include <svx/svdview.hxx>
53 : : #include <svx/svdoutl.hxx>
54 : :
55 : : #include "svx/gallery.hxx"
56 : : #include <svx/dlgutil.hxx>
57 : :
58 : : #include <svx/fontworkgallery.hxx>
59 : : #include "fontworkgallery.hrc"
60 : :
61 : : #include <algorithm>
62 : :
63 : : #include "helpid.hrc"
64 : :
65 : : using ::rtl::OUString;
66 : : using ::svtools::ToolbarMenu;
67 : :
68 : : using namespace ::com::sun::star;
69 : : using namespace ::com::sun::star::uno;
70 : : using namespace ::com::sun::star::lang;
71 : : using namespace ::com::sun::star::beans;
72 : : using namespace ::com::sun::star::frame;
73 : :
74 : : namespace svx
75 : : {
76 : :
77 : : const int nColCount = 4;
78 : : const int nLineCount = 4;
79 : :
80 : : /*************************************************************************
81 : : |* Svx3DWin - FloatingWindow
82 : : \************************************************************************/
83 : 0 : FontWorkGalleryDialog::FontWorkGalleryDialog( SdrView* pSdrView, Window* pParent, sal_uInt16 /*nSID*/ ) :
84 : 0 : ModalDialog( pParent, SVX_RES( RID_SVX_MDLG_FONTWORK_GALLERY ) ),
85 [ # # ]: 0 : maFLFavorites ( this, SVX_RES( FL_FAVORITES ) ),
86 [ # # ]: 0 : maCtlFavorites ( this, SVX_RES( CTL_FAVORITES ) ),
87 [ # # ]: 0 : maOKButton ( this, SVX_RES( BTN_OK ) ),
88 [ # # ]: 0 : maCancelButton ( this, SVX_RES( BTN_CANCEL ) ),
89 [ # # ]: 0 : maHelpButton ( this, SVX_RES( BTN_HELP ) ),
90 : : mnThemeId ( 0xffff ),
91 : : mpSdrView ( pSdrView ),
92 : 0 : mpModel ( (FmFormModel*)pSdrView->GetModel() ),
93 [ # # ]: 0 : maStrClickToAddText ( SVX_RES( STR_CLICK_TO_ADD_TEXT ) ),
94 : : mppSdrObject ( NULL ),
95 [ # # ][ # # ]: 0 : mpDestModel ( NULL )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
96 : : {
97 [ # # ]: 0 : FreeResource();
98 : :
99 [ # # ]: 0 : maCtlFavorites.SetDoubleClickHdl( LINK( this, FontWorkGalleryDialog, DoubleClickFavoriteHdl ) );
100 [ # # ]: 0 : maOKButton.SetClickHdl( LINK( this, FontWorkGalleryDialog, ClickOKHdl ) );
101 : :
102 [ # # ]: 0 : maCtlFavorites.SetColCount( nColCount );
103 [ # # ]: 0 : maCtlFavorites.SetLineCount( nLineCount );
104 [ # # ]: 0 : maCtlFavorites.SetExtraSpacing( 3 );
105 : :
106 [ # # ]: 0 : initfavorites( GALLERY_THEME_FONTWORK, maFavoritesHorizontal );
107 [ # # ]: 0 : fillFavorites( GALLERY_THEME_FONTWORK, maFavoritesHorizontal );
108 : 0 : }
109 : :
110 [ # # ]: 0 : static void delete_bitmap( Bitmap* p ) { delete p; }
111 : :
112 : : // -----------------------------------------------------------------------
113 [ # # ][ # # ]: 0 : FontWorkGalleryDialog::~FontWorkGalleryDialog()
[ # # ][ # # ]
[ # # ][ # # ]
114 : : {
115 [ # # ]: 0 : std::for_each( maFavoritesHorizontal.begin(), maFavoritesHorizontal.end(), delete_bitmap );
116 [ # # ]: 0 : }
117 : :
118 : : // -----------------------------------------------------------------------
119 : :
120 : 0 : void FontWorkGalleryDialog::initfavorites(sal_uInt16 nThemeId, std::vector< Bitmap * >& rFavorites)
121 : : {
122 : : // Ueber die Gallery werden die Favoriten eingelesen
123 : 0 : sal_uIntPtr nFavCount = GalleryExplorer::GetSdrObjCount( nThemeId );
124 : :
125 : : // Gallery thema locken
126 : 0 : GalleryExplorer::BeginLocking(nThemeId);
127 : :
128 : : sal_uInt32 nModelPos;
129 : 0 : FmFormModel *pModel = NULL;
130 [ # # ]: 0 : for( nModelPos = 0; nModelPos < nFavCount; nModelPos++ )
131 : : {
132 [ # # ][ # # ]: 0 : Bitmap* pThumb = new Bitmap;
133 : :
134 [ # # ]: 0 : if( GalleryExplorer::GetSdrObj( nThemeId, nModelPos, pModel, pThumb ) )
135 : : {
136 : : }
137 : :
138 [ # # ]: 0 : rFavorites.push_back( pThumb );
139 : : }
140 : :
141 : : // Gallery thema freigeben
142 : 0 : GalleryExplorer::EndLocking(nThemeId);
143 : 0 : }
144 : :
145 : 0 : void FontWorkGalleryDialog::fillFavorites( sal_uInt16 nThemeId, std::vector< Bitmap * >& rFavorites )
146 : : {
147 : 0 : mnThemeId = nThemeId;
148 : :
149 [ # # ]: 0 : Size aThumbSize( maCtlFavorites.GetSizePixel() );
150 : 0 : aThumbSize.Width() /= nColCount;
151 : 0 : aThumbSize.Height() /= nLineCount;
152 : 0 : aThumbSize.Width() -= 12;
153 : 0 : aThumbSize.Height() -= 12;
154 : :
155 : 0 : std::vector< Bitmap * >::size_type nFavCount = rFavorites.size();
156 : :
157 : : // ValueSet Favoriten
158 [ # # ]: 0 : if( nFavCount > (nColCount * nLineCount) )
159 : : {
160 [ # # ]: 0 : WinBits nWinBits = maCtlFavorites.GetStyle();
161 : 0 : nWinBits |= WB_VSCROLL;
162 [ # # ]: 0 : maCtlFavorites.SetStyle( nWinBits );
163 : : }
164 : :
165 [ # # ]: 0 : maCtlFavorites.Clear();
166 : :
167 : : sal_uInt32 nFavorite;
168 [ # # ]: 0 : for( nFavorite = 1; nFavorite <= nFavCount; nFavorite++ )
169 : : {
170 [ # # ][ # # ]: 0 : String aStr(SVX_RES(RID_SVXFLOAT3D_FAVORITE));
171 [ # # ]: 0 : aStr += sal_Unicode(' ');
172 [ # # ][ # # ]: 0 : aStr += String::CreateFromInt32((sal_Int32)nFavorite);
[ # # ]
173 [ # # ][ # # ]: 0 : Image aThumbImage( *rFavorites[nFavorite-1] );
174 [ # # ]: 0 : maCtlFavorites.InsertItem( (sal_uInt16)nFavorite, aThumbImage, aStr );
175 [ # # ][ # # ]: 0 : }
176 : 0 : }
177 : :
178 : 0 : void FontWorkGalleryDialog::SetSdrObjectRef( SdrObject** ppSdrObject, SdrModel* pModel )
179 : : {
180 : 0 : mppSdrObject = ppSdrObject;
181 : 0 : mpDestModel = pModel;
182 : 0 : }
183 : :
184 : 0 : void FontWorkGalleryDialog::insertSelectedFontwork()
185 : : {
186 : 0 : sal_uInt16 nItemId = maCtlFavorites.GetSelectItemId();
187 : :
188 [ # # ]: 0 : if( nItemId > 0 )
189 : : {
190 [ # # ]: 0 : FmFormModel* pModel = new FmFormModel();
191 : 0 : pModel->GetItemPool().FreezeIdRanges();
192 : :
193 [ # # ]: 0 : if( GalleryExplorer::GetSdrObj( mnThemeId, nItemId-1, pModel ) )
194 : : {
195 : 0 : SdrPage* pPage = pModel->GetPage(0);
196 [ # # ][ # # ]: 0 : if( pPage && pPage->GetObjCount() )
[ # # ]
197 : : {
198 : 0 : SdrObject* pNewObject = pPage->GetObj(0)->Clone();
199 : :
200 : : // center shape on current view
201 : 0 : OutputDevice* pOutDev = mpSdrView->GetFirstOutputDevice();
202 [ # # ]: 0 : if( pOutDev )
203 : : {
204 [ # # ]: 0 : Rectangle aObjRect( pNewObject->GetLogicRect() );
205 [ # # ][ # # ]: 0 : Rectangle aVisArea = pOutDev->PixelToLogic(Rectangle(Point(0,0), pOutDev->GetOutputSizePixel()));
206 [ # # ]: 0 : Point aPagePos = aVisArea.Center();
207 [ # # ]: 0 : aPagePos.X() -= aObjRect.GetWidth() / 2;
208 [ # # ]: 0 : aPagePos.Y() -= aObjRect.GetHeight() / 2;
209 [ # # ][ # # ]: 0 : Rectangle aNewObjectRectangle(aPagePos, aObjRect.GetSize());
210 : 0 : SdrPageView* pPV = mpSdrView->GetSdrPageView();
211 : :
212 [ # # ]: 0 : pNewObject->SetLogicRect(aNewObjectRectangle);
213 [ # # ]: 0 : if ( mppSdrObject )
214 : : {
215 : 0 : *mppSdrObject = pNewObject;
216 [ # # ]: 0 : (*mppSdrObject)->SetModel( mpDestModel );
217 : : }
218 [ # # ]: 0 : else if( pPV )
219 : : {
220 [ # # ]: 0 : mpSdrView->InsertObjectAtView( pNewObject, *pPV );
221 : : }
222 : : }
223 : : }
224 : : }
225 : :
226 [ # # ]: 0 : delete pModel;
227 : : }
228 : 0 : }
229 : :
230 : : // -----------------------------------------------------------------------
231 : :
232 : 0 : IMPL_LINK_NOARG(FontWorkGalleryDialog, ClickOKHdl)
233 : : {
234 : 0 : insertSelectedFontwork();
235 : 0 : EndDialog( true );
236 : 0 : return 0;
237 : : }
238 : :
239 : : // -----------------------------------------------------------------------
240 : :
241 : 0 : IMPL_LINK_NOARG(FontWorkGalleryDialog, DoubleClickFavoriteHdl)
242 : : {
243 : 0 : insertSelectedFontwork();
244 : 0 : EndDialog( true );
245 : 0 : return( 0L );
246 : : }
247 : :
248 : : //------------------------------------------------------------------------
249 : :
250 [ # # ]: 149 : SFX_IMPL_TOOLBOX_CONTROL( FontWorkShapeTypeControl, SfxStringItem );
251 : 0 : FontWorkShapeTypeControl::FontWorkShapeTypeControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox &rTbx )
252 : 0 : : SfxToolBoxControl( nSlotId, nId, rTbx )
253 : : {
254 [ # # ][ # # ]: 0 : rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
255 [ # # ]: 0 : rTbx.Invalidate();
256 : 0 : }
257 : :
258 : : // -----------------------------------------------------------------------
259 : :
260 : 0 : FontWorkShapeTypeControl::~FontWorkShapeTypeControl()
261 : : {
262 [ # # ]: 0 : }
263 : :
264 : : // -----------------------------------------------------------------------
265 : :
266 : 0 : SfxPopupWindowType FontWorkShapeTypeControl::GetPopupWindowType() const
267 : : {
268 : 0 : return SFX_POPUPWINDOW_ONCLICK; //( aLastAction.getLength() == 0 ? SFX_POPUPWINDOW_ONCLICK : SFX_POPUPWINDOW_ONTIMEOUT );
269 : : }
270 : :
271 : : // -----------------------------------------------------------------------
272 : :
273 : 0 : SfxPopupWindow* FontWorkShapeTypeControl::CreatePopupWindow()
274 : : {
275 [ # # ]: 0 : rtl::OUString aSubTbxResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/fontworkshapetype" ) );
276 [ # # ]: 0 : createAndPositionSubToolBar( aSubTbxResName );
277 : 0 : return NULL;
278 : : }
279 : :
280 : : // -----------------------------------------------------------------------
281 : :
282 : 0 : void FontWorkShapeTypeControl::Select( sal_Bool )
283 : : {
284 : :
285 : 0 : }
286 : :
287 : : // ========================================================================
288 : : // FontWorkAlignmentWindow
289 : : // ========================================================================
290 : :
291 [ # # ][ # # ]: 0 : class FontWorkAlignmentWindow : public ToolbarMenu
[ # # ][ # # ]
[ # # ][ # # ]
292 : : {
293 : : public:
294 : : FontWorkAlignmentWindow( svt::ToolboxController& rController, const Reference< XFrame >& rFrame, Window* pParentWindow );
295 : :
296 : : virtual void SAL_CALL statusChanged( const frame::FeatureStateEvent& Event ) throw ( RuntimeException );
297 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
298 : :
299 : : private:
300 : : svt::ToolboxController& mrController;
301 : :
302 : : Image maImgAlgin1;
303 : : Image maImgAlgin2;
304 : : Image maImgAlgin3;
305 : : Image maImgAlgin4;
306 : : Image maImgAlgin5;
307 : :
308 : : const rtl::OUString msFontworkAlignment;
309 : :
310 : : DECL_LINK( SelectHdl, void * );
311 : :
312 : : void implSetAlignment( int nAlignmentMode, bool bEnabled );
313 : : };
314 : :
315 : 0 : FontWorkAlignmentWindow::FontWorkAlignmentWindow( svt::ToolboxController& rController, const Reference< XFrame >& rFrame, Window* pParentWindow )
316 : 0 : : ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_FONTWORK_ALIGNMENT ))
317 : : , mrController( rController )
318 [ # # ]: 0 : , maImgAlgin1( SVX_RES( IMG_FONTWORK_ALIGN_LEFT_16 ) )
319 [ # # ]: 0 : , maImgAlgin2( SVX_RES( IMG_FONTWORK_ALIGN_CENTER_16 ) )
320 [ # # ]: 0 : , maImgAlgin3( SVX_RES( IMG_FONTWORK_ALIGN_RIGHT_16 ) )
321 [ # # ]: 0 : , maImgAlgin4( SVX_RES( IMG_FONTWORK_ALIGN_WORD_16 ) )
322 [ # # ]: 0 : , maImgAlgin5( SVX_RES( IMG_FONTWORK_ALIGN_STRETCH_16 ) )
323 [ # # ][ # # ]: 0 : , msFontworkAlignment( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkAlignment" ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
324 : : {
325 [ # # ]: 0 : SetHelpId( HID_POPUP_FONTWORK_ALIGN );
326 [ # # ][ # # ]: 0 : SetSelectHdl( LINK( this, FontWorkAlignmentWindow, SelectHdl ) );
327 : :
328 [ # # ][ # # ]: 0 : appendEntry( 0, String( SVX_RES( STR_ALIGN_LEFT ) ), maImgAlgin1 );
[ # # ][ # # ]
329 [ # # ][ # # ]: 0 : appendEntry( 1, String( SVX_RES( STR_ALIGN_CENTER ) ), maImgAlgin2 );
[ # # ][ # # ]
330 [ # # ][ # # ]: 0 : appendEntry( 2, String( SVX_RES( STR_ALIGN_RIGHT ) ), maImgAlgin3 );
[ # # ][ # # ]
331 [ # # ][ # # ]: 0 : appendEntry( 3, String( SVX_RES( STR_ALIGN_WORD ) ), maImgAlgin4 );
[ # # ][ # # ]
332 [ # # ][ # # ]: 0 : appendEntry( 4, String( SVX_RES( STR_ALIGN_STRETCH ) ), maImgAlgin5 );
[ # # ][ # # ]
333 : :
334 [ # # ][ # # ]: 0 : SetOutputSizePixel( getMenuSize() );
335 : :
336 [ # # ]: 0 : FreeResource();
337 : :
338 [ # # ]: 0 : AddStatusListener( msFontworkAlignment );
339 : 0 : }
340 : :
341 : : // -----------------------------------------------------------------------
342 : :
343 : 0 : void FontWorkAlignmentWindow::implSetAlignment( int nSurface, bool bEnabled )
344 : : {
345 : : int i;
346 [ # # ]: 0 : for( i = 0; i < 5; i++ )
347 : : {
348 [ # # ][ # # ]: 0 : checkEntry( i, (i == nSurface) && bEnabled );
349 : 0 : enableEntry( i, bEnabled );
350 : : }
351 : 0 : }
352 : :
353 : : // -----------------------------------------------------------------------
354 : :
355 : 0 : void SAL_CALL FontWorkAlignmentWindow::statusChanged( const frame::FeatureStateEvent& Event ) throw ( RuntimeException )
356 : : {
357 [ # # ]: 0 : if( Event.FeatureURL.Main.equals( msFontworkAlignment ) )
358 : : {
359 [ # # ]: 0 : if( !Event.IsEnabled )
360 : : {
361 : 0 : implSetAlignment( 0, false );
362 : : }
363 : : else
364 : : {
365 : 0 : sal_Int32 nValue = 0;
366 [ # # ]: 0 : if( Event.State >>= nValue )
367 [ # # ]: 0 : implSetAlignment( nValue, true );
368 : : }
369 : : }
370 : 0 : }
371 : :
372 : : // -----------------------------------------------------------------------
373 : :
374 : 0 : void FontWorkAlignmentWindow::DataChanged( const DataChangedEvent& rDCEvt )
375 : : {
376 : 0 : ToolbarMenu::DataChanged( rDCEvt );
377 : :
378 [ # # ][ # # ]: 0 : if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
[ # # ]
379 : : {
380 [ # # ][ # # ]: 0 : appendEntry( 0, String( SVX_RES( STR_ALIGN_LEFT ) ), maImgAlgin1 );
[ # # ]
381 [ # # ][ # # ]: 0 : appendEntry( 1, String( SVX_RES( STR_ALIGN_CENTER ) ), maImgAlgin2 );
[ # # ]
382 [ # # ][ # # ]: 0 : appendEntry( 2, String( SVX_RES( STR_ALIGN_RIGHT ) ), maImgAlgin3 );
[ # # ]
383 [ # # ][ # # ]: 0 : appendEntry( 3, String( SVX_RES( STR_ALIGN_WORD ) ), maImgAlgin4 );
[ # # ]
384 [ # # ][ # # ]: 0 : appendEntry( 4, String( SVX_RES( STR_ALIGN_STRETCH ) ), maImgAlgin5 );
[ # # ]
385 : : }
386 : 0 : }
387 : :
388 : : // -----------------------------------------------------------------------
389 : :
390 : 0 : IMPL_LINK_NOARG(FontWorkAlignmentWindow, SelectHdl)
391 : : {
392 [ # # ]: 0 : if ( IsInPopupMode() )
393 : 0 : EndPopupMode();
394 : :
395 : 0 : sal_Int32 nAlignment = getSelectedEntryId();
396 [ # # ]: 0 : if( nAlignment >= 0 )
397 : : {
398 [ # # ]: 0 : Sequence< PropertyValue > aArgs( 1 );
399 [ # # ]: 0 : aArgs[0].Name = msFontworkAlignment.copy(5);
400 [ # # ][ # # ]: 0 : aArgs[0].Value <<= (sal_Int32)nAlignment;
401 : :
402 [ # # ]: 0 : mrController.dispatchCommand( msFontworkAlignment, aArgs );
403 : :
404 [ # # ][ # # ]: 0 : implSetAlignment( nAlignment, true );
405 : : }
406 : :
407 : 0 : return 0;
408 : : }
409 : :
410 : : // ========================================================================
411 : : // FontWorkAlignmentControl
412 : : // ========================================================================
413 : :
414 [ # # ]: 0 : class FontWorkAlignmentControl : public svt::PopupWindowController
415 : : {
416 : : public:
417 : : FontWorkAlignmentControl( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager );
418 : :
419 : : virtual ::Window* createPopupWindow( ::Window* pParent );
420 : :
421 : : // XServiceInfo
422 : : virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
423 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
424 : :
425 : : using svt::PopupWindowController::createPopupWindow;
426 : : };
427 : :
428 : :
429 : : // -----------------------------------------------------------------------
430 : :
431 : 0 : FontWorkAlignmentControl::FontWorkAlignmentControl( const Reference< lang::XMultiServiceFactory >& rServiceManager )
432 [ # # ]: 0 : : svt::PopupWindowController( rServiceManager, Reference< frame::XFrame >(), OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkAlignment" ) ) )
433 : : {
434 : 0 : }
435 : :
436 : : // -----------------------------------------------------------------------
437 : :
438 : 0 : ::Window* FontWorkAlignmentControl::createPopupWindow( ::Window* pParent )
439 : : {
440 [ # # ]: 0 : return new FontWorkAlignmentWindow( *this, m_xFrame, pParent );
441 : : }
442 : :
443 : : // -----------------------------------------------------------------------
444 : : // XServiceInfo
445 : : // -----------------------------------------------------------------------
446 : :
447 : 0 : OUString SAL_CALL FontWorkAlignmentControl_getImplementationName()
448 : : {
449 : 0 : return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.FontworkAlignmentController" ));
450 : : }
451 : :
452 : : // --------------------------------------------------------------------
453 : :
454 : 0 : Sequence< OUString > SAL_CALL FontWorkAlignmentControl_getSupportedServiceNames() throw( RuntimeException )
455 : : {
456 : 0 : Sequence< OUString > aSNS( 1 );
457 [ # # ][ # # ]: 0 : aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ));
458 : 0 : return aSNS;
459 : : }
460 : :
461 : : // --------------------------------------------------------------------
462 : :
463 : 0 : Reference< XInterface > SAL_CALL SAL_CALL FontWorkAlignmentControl_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException )
464 : : {
465 [ # # ]: 0 : return *new FontWorkAlignmentControl( rSMgr );
466 : : }
467 : :
468 : : // --------------------------------------------------------------------
469 : :
470 : 0 : OUString SAL_CALL FontWorkAlignmentControl::getImplementationName( ) throw (RuntimeException)
471 : : {
472 : 0 : return FontWorkAlignmentControl_getImplementationName();
473 : : }
474 : :
475 : : // --------------------------------------------------------------------
476 : :
477 : 0 : Sequence< OUString > SAL_CALL FontWorkAlignmentControl::getSupportedServiceNames( ) throw (RuntimeException)
478 : : {
479 : 0 : return FontWorkAlignmentControl_getSupportedServiceNames();
480 : : }
481 : :
482 : :
483 : : // ####################################################################
484 : :
485 [ # # ]: 0 : class FontWorkCharacterSpacingWindow : public ToolbarMenu
486 : : {
487 : : public:
488 : : FontWorkCharacterSpacingWindow( svt::ToolboxController& rController, const Reference< XFrame >& rFrame, Window* pParentWindow );
489 : :
490 : : virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
491 : : private:
492 : : svt::ToolboxController& mrController;
493 : :
494 : : const rtl::OUString msFontworkCharacterSpacing;
495 : : const rtl::OUString msFontworkKernCharacterPairs;
496 : :
497 : : DECL_LINK( SelectHdl, void * );
498 : :
499 : : void implSetCharacterSpacing( sal_Int32 nCharacterSpacing, bool bEnabled );
500 : : void implSetKernCharacterPairs( sal_Bool bKernOnOff, bool bEnabled );
501 : :
502 : : };
503 : :
504 : : // -----------------------------------------------------------------------
505 : :
506 : 0 : FontWorkCharacterSpacingWindow::FontWorkCharacterSpacingWindow( svt::ToolboxController& rController, const Reference< XFrame >& rFrame, Window* pParentWindow )
507 : 0 : : ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_FONTWORK_CHARSPACING ))
508 : : , mrController( rController )
509 : : , msFontworkCharacterSpacing( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkCharacterSpacing" ) )
510 [ # # ][ # # ]: 0 : , msFontworkKernCharacterPairs( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkKernCharacterPairs" ) )
[ # # ]
511 : : {
512 [ # # ]: 0 : SetHelpId( HID_POPUP_FONTWORK_CHARSPACE );
513 [ # # ][ # # ]: 0 : SetSelectHdl( LINK( this, FontWorkCharacterSpacingWindow, SelectHdl ) );
514 : :
515 [ # # ][ # # ]: 0 : appendEntry( 0, String( SVX_RES( STR_CHARS_SPACING_VERY_TIGHT ) ), MIB_RADIOCHECK );
[ # # ][ # # ]
516 [ # # ][ # # ]: 0 : appendEntry( 1, String( SVX_RES( STR_CHARS_SPACING_TIGHT ) ), MIB_RADIOCHECK );
[ # # ][ # # ]
517 [ # # ][ # # ]: 0 : appendEntry( 2, String( SVX_RES( STR_CHARS_SPACING_NORMAL ) ), MIB_RADIOCHECK );
[ # # ][ # # ]
518 [ # # ][ # # ]: 0 : appendEntry( 3, String( SVX_RES( STR_CHARS_SPACING_LOOSE ) ), MIB_RADIOCHECK );
[ # # ][ # # ]
519 [ # # ][ # # ]: 0 : appendEntry( 4, String( SVX_RES( STR_CHARS_SPACING_VERY_LOOSE ) ), MIB_RADIOCHECK );
[ # # ][ # # ]
520 [ # # ][ # # ]: 0 : appendEntry( 5, String( SVX_RES( STR_CHARS_SPACING_CUSTOM ) ), MIB_RADIOCHECK );
[ # # ][ # # ]
521 [ # # ]: 0 : appendSeparator();
522 [ # # ][ # # ]: 0 : appendEntry( 6, String( SVX_RES( STR_CHARS_SPACING_KERN_PAIRS ) ), MIB_CHECKABLE );
[ # # ][ # # ]
523 : :
524 [ # # ][ # # ]: 0 : SetOutputSizePixel( getMenuSize() );
525 : :
526 [ # # ]: 0 : FreeResource();
527 : :
528 [ # # ]: 0 : AddStatusListener( msFontworkCharacterSpacing );
529 [ # # ]: 0 : AddStatusListener( msFontworkKernCharacterPairs );
530 : 0 : }
531 : :
532 : : // -----------------------------------------------------------------------
533 : :
534 : 0 : void FontWorkCharacterSpacingWindow::implSetCharacterSpacing( sal_Int32 nCharacterSpacing, bool bEnabled )
535 : : {
536 : : sal_Int32 i;
537 [ # # ]: 0 : for ( i = 0; i < 6; i++ )
538 : : {
539 : 0 : checkEntry( i, sal_False );
540 : 0 : enableEntry( i, bEnabled );
541 : : }
542 [ # # ]: 0 : if ( nCharacterSpacing != -1 )
543 : : {
544 : : sal_Int32 nEntry;
545 [ # # # # : 0 : switch( nCharacterSpacing )
# # ]
546 : : {
547 : 0 : case 80 : nEntry = 0; break;
548 : 0 : case 90 : nEntry = 1; break;
549 : 0 : case 100 : nEntry = 2; break;
550 : 0 : case 120 : nEntry = 3; break;
551 : 0 : case 150 : nEntry = 4; break;
552 : 0 : default : nEntry = 5; break;
553 : : }
554 : 0 : checkEntry( nEntry, bEnabled );
555 : : }
556 : 0 : }
557 : :
558 : : // -----------------------------------------------------------------------
559 : :
560 : 0 : void FontWorkCharacterSpacingWindow::implSetKernCharacterPairs( sal_Bool, bool bEnabled )
561 : : {
562 : 0 : enableEntry( 6, bEnabled );
563 : 0 : checkEntry( 6, bEnabled );
564 : 0 : }
565 : :
566 : : // -----------------------------------------------------------------------
567 : :
568 : 0 : void SAL_CALL FontWorkCharacterSpacingWindow::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException )
569 : : {
570 [ # # ]: 0 : if( Event.FeatureURL.Main.equals( msFontworkCharacterSpacing ) )
571 : : {
572 [ # # ]: 0 : if( !Event.IsEnabled )
573 : : {
574 : 0 : implSetCharacterSpacing( 0, false );
575 : : }
576 : : else
577 : : {
578 : 0 : sal_Int32 nValue = 0;
579 [ # # ]: 0 : if( Event.State >>= nValue )
580 [ # # ]: 0 : implSetCharacterSpacing( nValue, true );
581 : : }
582 : : }
583 [ # # ]: 0 : else if( Event.FeatureURL.Main.equals( msFontworkKernCharacterPairs ) )
584 : : {
585 [ # # ]: 0 : if( !Event.IsEnabled )
586 : : {
587 : 0 : implSetKernCharacterPairs( 0, false );
588 : : }
589 : : else
590 : : {
591 : 0 : sal_Bool bValue = sal_False;
592 [ # # ]: 0 : if( Event.State >>= bValue )
593 [ # # ]: 0 : implSetKernCharacterPairs( bValue, true );
594 : : }
595 : : }
596 : 0 : }
597 : :
598 : : // -----------------------------------------------------------------------
599 : :
600 : 0 : IMPL_LINK_NOARG(FontWorkCharacterSpacingWindow, SelectHdl)
601 : : {
602 [ # # ]: 0 : if ( IsInPopupMode() )
603 : 0 : EndPopupMode();
604 : :
605 : 0 : sal_Int32 nSelection = getSelectedEntryId();
606 : : sal_Int32 nCharacterSpacing;
607 [ # # # # : 0 : switch( nSelection )
# # ]
608 : : {
609 : 0 : case 0 : nCharacterSpacing = 80; break;
610 : 0 : case 1 : nCharacterSpacing = 90; break;
611 : 0 : case 2 : nCharacterSpacing = 100; break;
612 : 0 : case 3 : nCharacterSpacing = 120; break;
613 : 0 : case 4 : nCharacterSpacing = 150; break;
614 : 0 : default : nCharacterSpacing = 100; break;
615 : : }
616 [ # # ]: 0 : if ( nSelection == 5 ) // custom spacing
617 : : {
618 [ # # ]: 0 : Sequence< PropertyValue > aArgs( 1 );
619 [ # # ]: 0 : aArgs[0].Name = msFontworkCharacterSpacing.copy(5);
620 [ # # ][ # # ]: 0 : aArgs[0].Value <<= (sal_Int32)nCharacterSpacing;
621 : :
622 [ # # ][ # # ]: 0 : mrController.dispatchCommand( OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkCharacterSpacingDialog" )), aArgs );
[ # # ]
623 : : }
624 [ # # ]: 0 : else if ( nSelection == 6 ) // KernCharacterPairs
625 : : {
626 [ # # ]: 0 : Sequence< PropertyValue > aArgs( 1 );
627 [ # # ]: 0 : aArgs[0].Name = msFontworkKernCharacterPairs.copy(5);
628 [ # # ][ # # ]: 0 : aArgs[0].Value <<= (sal_Bool) sal_True;
629 : :
630 [ # # ]: 0 : mrController.dispatchCommand( msFontworkKernCharacterPairs, aArgs );
631 : :
632 [ # # ][ # # ]: 0 : implSetKernCharacterPairs( sal_True, true );
633 : : }
634 [ # # ]: 0 : else if( nSelection >= 0 )
635 : : {
636 [ # # ]: 0 : Sequence< PropertyValue > aArgs( 1 );
637 [ # # ]: 0 : aArgs[0].Name = msFontworkCharacterSpacing.copy(5);
638 [ # # ][ # # ]: 0 : aArgs[0].Value <<=( sal_Int32)nCharacterSpacing;
639 : :
640 [ # # ]: 0 : mrController.dispatchCommand( msFontworkCharacterSpacing, aArgs );
641 : :
642 [ # # ][ # # ]: 0 : implSetCharacterSpacing( nCharacterSpacing, true );
643 : : }
644 : :
645 : 0 : return 0;
646 : : }
647 : :
648 : : // ========================================================================
649 : : // FontWorkCharacterSpacingControl
650 : : // ========================================================================
651 : :
652 [ # # ]: 0 : class FontWorkCharacterSpacingControl : public svt::PopupWindowController
653 : : {
654 : : public:
655 : : FontWorkCharacterSpacingControl( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager );
656 : :
657 : : virtual ::Window* createPopupWindow( ::Window* pParent );
658 : :
659 : : // XServiceInfo
660 : : virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
661 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
662 : :
663 : : using svt::PopupWindowController::createPopupWindow;
664 : : };
665 : :
666 : :
667 : 0 : FontWorkCharacterSpacingControl::FontWorkCharacterSpacingControl( const Reference< lang::XMultiServiceFactory >& rServiceManager )
668 [ # # ]: 0 : : svt::PopupWindowController( rServiceManager, Reference< frame::XFrame >(), OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkCharacterSpacingFloater" ) ) )
669 : : {
670 : 0 : }
671 : :
672 : : // -----------------------------------------------------------------------
673 : :
674 : 0 : ::Window* FontWorkCharacterSpacingControl::createPopupWindow( ::Window* pParent )
675 : : {
676 [ # # ]: 0 : return new FontWorkCharacterSpacingWindow( *this, m_xFrame, pParent );
677 : : }
678 : :
679 : : // -----------------------------------------------------------------------
680 : : // XServiceInfo
681 : : // -----------------------------------------------------------------------
682 : :
683 : 0 : OUString SAL_CALL FontWorkCharacterSpacingControl_getImplementationName()
684 : : {
685 : 0 : return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.FontworkCharacterSpacingController" ));
686 : : }
687 : :
688 : : // --------------------------------------------------------------------
689 : :
690 : 0 : Sequence< OUString > SAL_CALL FontWorkCharacterSpacingControl_getSupportedServiceNames() throw( RuntimeException )
691 : : {
692 : 0 : Sequence< OUString > aSNS( 1 );
693 [ # # ][ # # ]: 0 : aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ));
694 : 0 : return aSNS;
695 : : }
696 : :
697 : : // --------------------------------------------------------------------
698 : :
699 : 0 : Reference< XInterface > SAL_CALL SAL_CALL FontWorkCharacterSpacingControl_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException )
700 : : {
701 [ # # ]: 0 : return *new FontWorkCharacterSpacingControl( rSMgr );
702 : : }
703 : :
704 : : // --------------------------------------------------------------------
705 : :
706 : 0 : OUString SAL_CALL FontWorkCharacterSpacingControl::getImplementationName( ) throw (RuntimeException)
707 : : {
708 : 0 : return FontWorkCharacterSpacingControl_getImplementationName();
709 : : }
710 : :
711 : : // --------------------------------------------------------------------
712 : :
713 : 0 : Sequence< OUString > SAL_CALL FontWorkCharacterSpacingControl::getSupportedServiceNames( ) throw (RuntimeException)
714 : : {
715 : 0 : return FontWorkCharacterSpacingControl_getSupportedServiceNames();
716 : : }
717 : :
718 : : // ========================================================================
719 : : // FontworkCharacterSpacingDialog
720 : : // ========================================================================
721 : :
722 : 0 : FontworkCharacterSpacingDialog::FontworkCharacterSpacingDialog( Window* pParent, sal_Int32 nScale )
723 : 0 : : ModalDialog( pParent, SVX_RES( RID_SVX_MDLG_FONTWORK_CHARSPACING ) ),
724 [ # # ]: 0 : maFLScale( this, SVX_RES( FT_VALUE ) ),
725 [ # # ]: 0 : maMtrScale( this, SVX_RES( MF_VALUE ) ),
726 [ # # ]: 0 : maOKButton( this, SVX_RES( BTN_OK ) ),
727 [ # # ]: 0 : maCancelButton( this, SVX_RES( BTN_CANCEL ) ),
728 [ # # ][ # # ]: 0 : maHelpButton( this, SVX_RES( BTN_HELP ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
729 : : {
730 [ # # ]: 0 : maMtrScale.SetValue( nScale );
731 [ # # ]: 0 : FreeResource();
732 : 0 : }
733 : :
734 [ # # ][ # # ]: 0 : FontworkCharacterSpacingDialog::~FontworkCharacterSpacingDialog()
[ # # ][ # # ]
[ # # ]
735 : : {
736 [ # # ]: 0 : }
737 : :
738 : 0 : sal_Int32 FontworkCharacterSpacingDialog::getScale() const
739 : : {
740 : 0 : return (sal_Int32)maMtrScale.GetValue();
741 : : }
742 : :
743 : : }
744 : :
745 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|