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: fontworkgallery.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_svx.hxx"
33 #include <com/sun/star/text/WritingMode.hpp>
34 #include <sfx2/app.hxx>
35 #include <svtools/itempool.hxx>
36 #include <svx/fmmodel.hxx>
37 #include <sfx2/dispatch.hxx>
38 #include <dlgutil.hxx>
40 #include <svx/svxids.hrc>
41 #include <svx/dialmgr.hxx>
42 #include <svx/dialogs.hrc>
43 #include "gallery.hxx"
44 #include <svx/svdpage.hxx>
45 #include <svx/svdobj.hxx>
46 #include <svx/svdview.hxx>
47 #include <svx/svdoutl.hxx>
48 #include <svx/eeitem.hxx>
49 #include <svx/frmdiritem.hxx>
50 #include "toolbarmenu.hxx"
52 #include "fontworkgallery.hxx"
53 #include "fontworkgallery.hrc"
57 #ifndef _TOOLBOX_HXX //autogen
58 #include <vcl/toolbox.hxx>
60 #ifndef _SVX_HELPID_HRC
64 using namespace ::com::sun::star::uno
;
65 using namespace ::com::sun::star::lang
;
66 using namespace ::com::sun::star::beans
;
68 const int nColCount
= 4;
69 const int nLineCount
= 4;
71 /*************************************************************************
72 |* Svx3DWin - FloatingWindow
73 \************************************************************************/
74 FontWorkGalleryDialog::FontWorkGalleryDialog( SdrView
* pSdrView
, Window
* pParent
, sal_uInt16
/*nSID*/ ) :
75 ModalDialog( pParent
, SVX_RES( RID_SVX_MDLG_FONTWORK_GALLERY
) ),
76 maCtlFavorites ( this, SVX_RES( CTL_FAVORITES
) ),
77 maFLFavorites ( this, SVX_RES( FL_FAVORITES
) ),
78 maOKButton ( this, SVX_RES( BTN_OK
) ),
79 maCancelButton ( this, SVX_RES( BTN_CANCEL
) ),
80 maHelpButton ( this, SVX_RES( BTN_HELP
) ),
82 mpSdrView ( pSdrView
),
83 mpModel ( (FmFormModel
*)pSdrView
->GetModel() ),
84 maStrClickToAddText ( SVX_RES( STR_CLICK_TO_ADD_TEXT
) ),
85 mppSdrObject ( NULL
),
90 maCtlFavorites
.SetDoubleClickHdl( LINK( this, FontWorkGalleryDialog
, DoubleClickFavoriteHdl
) );
91 maOKButton
.SetClickHdl( LINK( this, FontWorkGalleryDialog
, ClickOKHdl
) );
93 maCtlFavorites
.SetColCount( nColCount
);
94 maCtlFavorites
.SetLineCount( nLineCount
);
95 maCtlFavorites
.SetExtraSpacing( 3 );
97 initfavorites( GALLERY_THEME_FONTWORK
, maFavoritesHorizontal
);
98 fillFavorites( GALLERY_THEME_FONTWORK
, maFavoritesHorizontal
);
101 static void delete_bitmap( Bitmap
* p
) { delete p
; }
103 // -----------------------------------------------------------------------
104 FontWorkGalleryDialog::~FontWorkGalleryDialog()
106 std::for_each( maFavoritesHorizontal
.begin(), maFavoritesHorizontal
.end(), delete_bitmap
);
109 // -----------------------------------------------------------------------
111 void FontWorkGalleryDialog::initfavorites(sal_uInt16 nThemeId
, std::vector
< Bitmap
* >& rFavorites
)
113 // Ueber die Gallery werden die Favoriten eingelesen
114 ULONG nFavCount
= GalleryExplorer::GetSdrObjCount( nThemeId
);
116 // Gallery thema locken
117 GalleryExplorer::BeginLocking(nThemeId
);
119 sal_uInt32 nModelPos
;
120 FmFormModel
*pModel
= NULL
;
121 for( nModelPos
= 0; nModelPos
< nFavCount
; nModelPos
++ )
123 Bitmap
* pThumb
= new Bitmap
;
125 if( GalleryExplorer::GetSdrObj( nThemeId
, nModelPos
, pModel
, pThumb
) )
129 Size aRenderSize( aThumbSize.Width() * 4, aThumbSize.Height() * 4 );
130 aVDev.SetOutputSizePixel( aRenderSize );
132 if( GalleryExplorer::DrawCentered( &aVDev, *pModel ) )
134 aThumb = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() );
137 BmpFilterParam aParam( aMS );
138 aThumb.Filter( BMP_FILTER_MOSAIC, &aParam );
139 aThumb.Scale( aThumbSize );
144 rFavorites
.push_back( pThumb
);
147 // Gallery thema freigeben
148 GalleryExplorer::EndLocking(nThemeId
);
151 void FontWorkGalleryDialog::fillFavorites( sal_uInt16 nThemeId
, std::vector
< Bitmap
* >& rFavorites
)
153 mnThemeId
= nThemeId
;
155 Size
aThumbSize( maCtlFavorites
.GetSizePixel() );
156 aThumbSize
.Width() /= nColCount
;
157 aThumbSize
.Height() /= nLineCount
;
158 aThumbSize
.Width() -= 12;
159 aThumbSize
.Height() -= 12;
161 std::vector
< Bitmap
* >::size_type nFavCount
= rFavorites
.size();
163 // ValueSet Favoriten
164 if( nFavCount
> (nColCount
* nLineCount
) )
166 WinBits nWinBits
= maCtlFavorites
.GetStyle();
167 nWinBits
|= WB_VSCROLL
;
168 maCtlFavorites
.SetStyle( nWinBits
);
171 maCtlFavorites
.Clear();
173 sal_uInt32 nFavorite
;
174 for( nFavorite
= 1; nFavorite
<= nFavCount
; nFavorite
++ )
176 String
aStr(SVX_RES(RID_SVXFLOAT3D_FAVORITE
));
177 aStr
+= sal_Unicode(' ');
178 aStr
+= String::CreateFromInt32((sal_Int32
)nFavorite
);
179 Image
aThumbImage( *rFavorites
[nFavorite
-1] );
180 maCtlFavorites
.InsertItem( (sal_uInt16
)nFavorite
, aThumbImage
, aStr
);
184 void FontWorkGalleryDialog::changeText( SdrTextObj
* pObj
)
188 SdrOutliner
& rOutl
= mpModel
->GetDrawOutliner(pObj
);
190 USHORT nOutlMode
= rOutl
.GetMode();
191 Size aPaperSize
= rOutl
.GetPaperSize();
192 BOOL bUpdateMode
= rOutl
.GetUpdateMode();
193 rOutl
.SetUpdateMode(FALSE
);
194 rOutl
.SetParaAttribs( 0, rOutl
.GetEmptyItemSet() );
196 // #95114# Always set the object's StyleSheet at the Outliner to
197 // use the current objects StyleSheet. Thus it's the same as in
199 // #95114# Moved this implementation from where SetObjText(...) was called
200 // to inside this method to work even when outliner is fetched here.
201 rOutl
.SetStyleSheet(0, pObj
->GetStyleSheet());
203 rOutl
.SetPaperSize( pObj
->GetLogicRect().GetSize() );
205 rOutl
.SetText( maStrClickToAddText
, rOutl
.GetParagraph( 0 ) );
206 pObj
->SetOutlinerParaObject( rOutl
.CreateParaObject() );
208 rOutl
.Init( nOutlMode
);
209 rOutl
.SetParaAttribs( 0, rOutl
.GetEmptyItemSet() );
210 rOutl
.SetUpdateMode( bUpdateMode
);
211 rOutl
.SetPaperSize( aPaperSize
);
217 void FontWorkGalleryDialog::SetSdrObjectRef( SdrObject
** ppSdrObject
, SdrModel
* pModel
)
219 mppSdrObject
= ppSdrObject
;
220 mpDestModel
= pModel
;
223 void FontWorkGalleryDialog::insertSelectedFontwork()
225 USHORT nItemId
= maCtlFavorites
.GetSelectItemId();
229 FmFormModel
* pModel
= new FmFormModel();
230 pModel
->GetItemPool().FreezeIdRanges();
232 if( GalleryExplorer::GetSdrObj( mnThemeId
, nItemId
-1, pModel
) )
234 SdrPage
* pPage
= pModel
->GetPage(0);
235 if( pPage
&& pPage
->GetObjCount() )
237 SdrObject
* pNewObject
= pPage
->GetObj(0)->Clone();
239 // center shape on current view
240 OutputDevice
* pOutDev
= mpSdrView
->GetFirstOutputDevice();
243 Rectangle
aObjRect( pNewObject
->GetLogicRect() );
244 Rectangle aVisArea
= pOutDev
->PixelToLogic(Rectangle(Point(0,0), pOutDev
->GetOutputSizePixel()));
246 sal_Int32 nObjHeight = aObjRect.GetHeight();
247 VirtualDevice aVirDev( 1 ); // calculating the optimal textwidth
249 aFont.SetHeight( nObjHeight );
250 aVirDev.SetMapMode( MAP_100TH_MM );
251 aVirDev.SetFont( aFont );
252 aObjRect.SetSize( Size( aVirDev.GetTextWidth( maStrClickToAddText ), nObjHeight ) );
254 Point aPagePos
= aVisArea
.Center();
255 aPagePos
.X() -= aObjRect
.GetWidth() / 2;
256 aPagePos
.Y() -= aObjRect
.GetHeight() / 2;
257 Rectangle
aNewObjectRectangle(aPagePos
, aObjRect
.GetSize());
258 SdrPageView
* pPV
= mpSdrView
->GetSdrPageView();
260 pNewObject
->SetLogicRect(aNewObjectRectangle
);
263 *mppSdrObject
= pNewObject
;
264 (*mppSdrObject
)->SetModel( mpDestModel
);
268 mpSdrView
->InsertObjectAtView( pNewObject
, *pPV
);
269 // changeText( PTR_CAST( SdrTextObj, pNewObject ) );
279 // -----------------------------------------------------------------------
281 IMPL_LINK( FontWorkGalleryDialog
, ClickOKHdl
, void*, EMPTYARG
)
283 insertSelectedFontwork();
288 // -----------------------------------------------------------------------
290 IMPL_LINK( FontWorkGalleryDialog
, DoubleClickFavoriteHdl
, void*, EMPTYARG
)
292 insertSelectedFontwork();
297 // -----------------------------------------------------------------------
299 SFX_IMPL_TOOLBOX_CONTROL( FontWorkShapeTypeControl
, SfxStringItem
);
300 FontWorkShapeTypeControl::FontWorkShapeTypeControl( USHORT nSlotId
, USHORT nId
, ToolBox
&rTbx
)
301 : SfxToolBoxControl( nSlotId
, nId
, rTbx
)
303 rTbx
.SetItemBits( nId
, TIB_DROPDOWNONLY
| rTbx
.GetItemBits( nId
) );
307 // -----------------------------------------------------------------------
309 FontWorkShapeTypeControl::~FontWorkShapeTypeControl()
313 // -----------------------------------------------------------------------
315 SfxPopupWindowType
FontWorkShapeTypeControl::GetPopupWindowType() const
317 return SFX_POPUPWINDOW_ONCLICK
; //( aLastAction.getLength() == 0 ? SFX_POPUPWINDOW_ONCLICK : SFX_POPUPWINDOW_ONTIMEOUT );
320 // -----------------------------------------------------------------------
322 SfxPopupWindow
* FontWorkShapeTypeControl::CreatePopupWindow()
324 rtl::OUString
aSubTbxResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/fontworkshapetype" ) );
325 createAndPositionSubToolBar( aSubTbxResName
);
329 // -----------------------------------------------------------------------
331 void FontWorkShapeTypeControl::StateChanged( USHORT nSID
, SfxItemState eState
, const SfxPoolItem
* pState
)
333 SfxToolBoxControl::StateChanged( nSID
, eState
, pState
);
336 // -----------------------------------------------------------------------
338 void FontWorkShapeTypeControl::Select( BOOL
)
343 // ####################################################################
345 SFX_IMPL_TOOLBOX_CONTROL( FontWorkAlignmentControl
, SfxBoolItem
);
347 FontWorkAlignmentWindow::FontWorkAlignmentWindow(
349 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
) :
353 SVX_RES( RID_SVXFLOAT_FONTWORK_ALIGNMENT
)),
354 maImgAlgin1( SVX_RES( IMG_FONTWORK_ALIGN_LEFT_16
) ),
355 maImgAlgin2( SVX_RES( IMG_FONTWORK_ALIGN_CENTER_16
) ),
356 maImgAlgin3( SVX_RES( IMG_FONTWORK_ALIGN_RIGHT_16
) ),
357 maImgAlgin4( SVX_RES( IMG_FONTWORK_ALIGN_WORD_16
) ),
358 maImgAlgin5( SVX_RES( IMG_FONTWORK_ALIGN_STRETCH_16
) ),
359 maImgAlgin1h( SVX_RES( IMG_FONTWORK_ALIGN_LEFT_16_H
) ),
360 maImgAlgin2h( SVX_RES( IMG_FONTWORK_ALIGN_CENTER_16_H
) ),
361 maImgAlgin3h( SVX_RES( IMG_FONTWORK_ALIGN_RIGHT_16_H
) ),
362 maImgAlgin4h( SVX_RES( IMG_FONTWORK_ALIGN_WORD_16_H
) ),
363 maImgAlgin5h( SVX_RES( IMG_FONTWORK_ALIGN_STRETCH_16_H
) ),
367 SetHelpId( HID_WIN_FONTWORK_ALIGN
);
371 FontWorkAlignmentWindow::FontWorkAlignmentWindow(
373 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
,
374 Window
* /*pParentWindow*/ ) :
378 SVX_RES( RID_SVXFLOAT_FONTWORK_ALIGNMENT
)),
379 maImgAlgin1( SVX_RES( IMG_FONTWORK_ALIGN_LEFT_16
) ),
380 maImgAlgin2( SVX_RES( IMG_FONTWORK_ALIGN_CENTER_16
) ),
381 maImgAlgin3( SVX_RES( IMG_FONTWORK_ALIGN_RIGHT_16
) ),
382 maImgAlgin4( SVX_RES( IMG_FONTWORK_ALIGN_WORD_16
) ),
383 maImgAlgin5( SVX_RES( IMG_FONTWORK_ALIGN_STRETCH_16
) ),
384 maImgAlgin1h( SVX_RES( IMG_FONTWORK_ALIGN_LEFT_16_H
) ),
385 maImgAlgin2h( SVX_RES( IMG_FONTWORK_ALIGN_CENTER_16_H
) ),
386 maImgAlgin3h( SVX_RES( IMG_FONTWORK_ALIGN_RIGHT_16_H
) ),
387 maImgAlgin4h( SVX_RES( IMG_FONTWORK_ALIGN_WORD_16_H
) ),
388 maImgAlgin5h( SVX_RES( IMG_FONTWORK_ALIGN_STRETCH_16_H
) ),
392 SetHelpId( HID_WIN_FONTWORK_ALIGN
);
396 void FontWorkAlignmentWindow::implInit()
398 SetHelpId( HID_POPUP_FONTWORK_ALIGN
);
400 bool bHighContrast
= GetDisplayBackground().GetColor().IsDark();
402 mpMenu
= new ToolbarMenu( this, WB_CLIPCHILDREN
);
403 mpMenu
->SetHelpId( HID_POPUP_FONTWORK_ALIGN
);
404 mpMenu
->SetSelectHdl( LINK( this, FontWorkAlignmentWindow
, SelectHdl
) );
406 mpMenu
->appendEntry( 0, String( SVX_RES( STR_ALIGN_LEFT
) ), bHighContrast
? maImgAlgin1h
: maImgAlgin1
);
407 mpMenu
->appendEntry( 1, String( SVX_RES( STR_ALIGN_CENTER
) ), bHighContrast
? maImgAlgin2h
: maImgAlgin2
);
408 mpMenu
->appendEntry( 2, String( SVX_RES( STR_ALIGN_RIGHT
) ), bHighContrast
? maImgAlgin3h
: maImgAlgin3
);
409 mpMenu
->appendEntry( 3, String( SVX_RES( STR_ALIGN_WORD
) ), bHighContrast
? maImgAlgin4h
: maImgAlgin4
);
410 mpMenu
->appendEntry( 4, String( SVX_RES( STR_ALIGN_STRETCH
) ), bHighContrast
? maImgAlgin5h
: maImgAlgin5
);
412 SetOutputSizePixel( mpMenu
->getMenuSize() );
413 mpMenu
->SetOutputSizePixel( GetOutputSizePixel() );
419 AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkAlignment" )));
422 SfxPopupWindow
* FontWorkAlignmentWindow::Clone() const
424 return new FontWorkAlignmentWindow( GetId(), mxFrame
);
427 // -----------------------------------------------------------------------
429 FontWorkAlignmentWindow::~FontWorkAlignmentWindow()
434 // -----------------------------------------------------------------------
436 void FontWorkAlignmentWindow::implSetAlignment( int nSurface
, bool bEnabled
)
441 for( i
= 0; i
< 5; i
++ )
443 mpMenu
->checkEntry( i
, (i
== nSurface
) && bEnabled
);
444 mpMenu
->enableEntry( i
, bEnabled
);
449 // -----------------------------------------------------------------------
451 void FontWorkAlignmentWindow::StateChanged( USHORT nSID
, SfxItemState eState
, const SfxPoolItem
* pState
)
455 case SID_FONTWORK_ALIGNMENT
:
457 if( eState
== SFX_ITEM_DISABLED
)
459 implSetAlignment( 0, false );
463 const SfxInt32Item
* pStateItem
= PTR_CAST( SfxInt32Item
, pState
);
465 implSetAlignment( pStateItem
->GetValue(), true );
472 // -----------------------------------------------------------------------
474 void FontWorkAlignmentWindow::DataChanged( const DataChangedEvent
& rDCEvt
)
476 SfxPopupWindow::DataChanged( rDCEvt
);
478 if( ( rDCEvt
.GetType() == DATACHANGED_SETTINGS
) && ( rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
480 bool bHighContrast
= GetDisplayBackground().GetColor().IsDark();
482 mpMenu
->appendEntry( 0, String( SVX_RES( STR_ALIGN_LEFT
) ), bHighContrast
? maImgAlgin1h
: maImgAlgin1
);
483 mpMenu
->appendEntry( 1, String( SVX_RES( STR_ALIGN_CENTER
) ), bHighContrast
? maImgAlgin2h
: maImgAlgin2
);
484 mpMenu
->appendEntry( 2, String( SVX_RES( STR_ALIGN_RIGHT
) ), bHighContrast
? maImgAlgin3h
: maImgAlgin3
);
485 mpMenu
->appendEntry( 3, String( SVX_RES( STR_ALIGN_WORD
) ), bHighContrast
? maImgAlgin4h
: maImgAlgin4
);
486 mpMenu
->appendEntry( 4, String( SVX_RES( STR_ALIGN_STRETCH
) ), bHighContrast
? maImgAlgin5h
: maImgAlgin5
);
490 // -----------------------------------------------------------------------
492 IMPL_LINK( FontWorkAlignmentWindow
, SelectHdl
, void *, EMPTYARG
)
494 if ( IsInPopupMode() )
497 // SfxDispatcher* pDisp = GetBindings().GetDispatcher();
499 sal_Int32 nAlignment
= mpMenu
->getSelectedEntryId();
500 if( nAlignment
>= 0 )
502 SfxInt32Item
aItem( SID_FONTWORK_ALIGNMENT
, nAlignment
);
503 rtl::OUString
aCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkAlignment" ));
506 INetURLObject
aObj( aCommand
);
507 Sequence
< PropertyValue
> aArgs( 1 );
508 aArgs
[0].Name
= aObj
.GetURLPath();
509 aItem
.QueryValue( a
);
512 SfxToolBoxControl::Dispatch( Reference
< ::com::sun::star::frame::XDispatchProvider
>(
513 mxFrame
->getController(), UNO_QUERY
),
517 implSetAlignment( nAlignment
, true );
523 // -----------------------------------------------------------------------
525 void FontWorkAlignmentWindow::StartSelection()
529 // -----------------------------------------------------------------------
531 BOOL
FontWorkAlignmentWindow::Close()
533 return SfxPopupWindow::Close();
536 // -----------------------------------------------------------------------
538 void FontWorkAlignmentWindow::PopupModeEnd()
544 SfxPopupWindow::PopupModeEnd();
547 // -----------------------------------------------------------------------
549 void FontWorkAlignmentWindow::GetFocus (void)
551 SfxPopupWindow::GetFocus();
552 // Grab the focus to the line ends value set so that it can be controlled
553 // with the keyboard.
558 // ========================================================================
560 FontWorkAlignmentControl::FontWorkAlignmentControl(
561 USHORT nSlotId
, USHORT nId
, ToolBox
&rTbx
)
562 : SfxToolBoxControl( nSlotId
, nId
, rTbx
)
564 rTbx
.SetItemBits( nId
, TIB_DROPDOWNONLY
| rTbx
.GetItemBits( nId
) );
567 // -----------------------------------------------------------------------
569 FontWorkAlignmentControl::~FontWorkAlignmentControl()
573 // -----------------------------------------------------------------------
575 SfxPopupWindowType
FontWorkAlignmentControl::GetPopupWindowType() const
577 return SFX_POPUPWINDOW_ONCLICK
;
580 // -----------------------------------------------------------------------
582 SfxPopupWindow
* FontWorkAlignmentControl::CreatePopupWindow()
584 FontWorkAlignmentWindow
* pWin
= new FontWorkAlignmentWindow( GetId(), m_xFrame
, &GetToolBox() );
585 pWin
->StartPopupMode( &GetToolBox(), TRUE
);
586 pWin
->StartSelection();
587 SetPopupWindow( pWin
);
591 // -----------------------------------------------------------------------
593 void FontWorkAlignmentControl::StateChanged( USHORT
/*nSID*/, SfxItemState eState
, const SfxPoolItem
* /*pState*/ )
595 USHORT nId
= GetId();
596 ToolBox
& rTbx
= GetToolBox();
598 rTbx
.EnableItem( nId
, SFX_ITEM_DISABLED
!= eState
);
599 rTbx
.SetItemState( nId
, ( SFX_ITEM_DONTCARE
== eState
) ? STATE_DONTKNOW
: STATE_NOCHECK
);
602 // ####################################################################
604 SFX_IMPL_TOOLBOX_CONTROL( FontWorkCharacterSpacingControl
, SfxBoolItem
);
606 FontWorkCharacterSpacingWindow::FontWorkCharacterSpacingWindow(
608 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
) :
612 SVX_RES( RID_SVXFLOAT_FONTWORK_CHARSPACING
)),
616 SetHelpId( HID_WIN_FONTWORK_CHARSPACE
);
620 FontWorkCharacterSpacingWindow::FontWorkCharacterSpacingWindow(
622 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
,
623 Window
* pParentWindow
) :
628 SVX_RES( RID_SVXFLOAT_FONTWORK_CHARSPACING
)),
632 SetHelpId( HID_WIN_FONTWORK_CHARSPACE
);
636 void FontWorkCharacterSpacingWindow::implInit()
638 SetHelpId( HID_POPUP_FONTWORK_CHARSPACE
);
640 // bool bHighContrast = GetDisplayBackground().GetColor().IsDark();
642 mpMenu
= new ToolbarMenu( this, WB_CLIPCHILDREN
);
643 mpMenu
->SetHelpId( HID_POPUP_FONTWORK_CHARSPACE
);
644 mpMenu
->SetSelectHdl( LINK( this, FontWorkCharacterSpacingWindow
, SelectHdl
) );
646 mpMenu
->appendEntry( 0, String( SVX_RES( STR_CHARS_SPACING_VERY_TIGHT
) ), MIB_RADIOCHECK
);
647 mpMenu
->appendEntry( 1, String( SVX_RES( STR_CHARS_SPACING_TIGHT
) ), MIB_RADIOCHECK
);
648 mpMenu
->appendEntry( 2, String( SVX_RES( STR_CHARS_SPACING_NORMAL
) ), MIB_RADIOCHECK
);
649 mpMenu
->appendEntry( 3, String( SVX_RES( STR_CHARS_SPACING_LOOSE
) ), MIB_RADIOCHECK
);
650 mpMenu
->appendEntry( 4, String( SVX_RES( STR_CHARS_SPACING_VERY_LOOSE
) ), MIB_RADIOCHECK
);
651 mpMenu
->appendEntry( 5, String( SVX_RES( STR_CHARS_SPACING_CUSTOM
) ), MIB_RADIOCHECK
);
652 mpMenu
->appendSeparator();
653 mpMenu
->appendEntry( 6, String( SVX_RES( STR_CHARS_SPACING_KERN_PAIRS
) ), MIB_CHECKABLE
);
655 SetOutputSizePixel( mpMenu
->getMenuSize() );
656 mpMenu
->SetOutputSizePixel( GetOutputSizePixel() );
662 AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkCharacterSpacing" )));
665 SfxPopupWindow
* FontWorkCharacterSpacingWindow::Clone() const
667 return new FontWorkCharacterSpacingWindow( GetId(), mxFrame
);
670 // -----------------------------------------------------------------------
672 FontWorkCharacterSpacingWindow::~FontWorkCharacterSpacingWindow()
677 // -----------------------------------------------------------------------
679 void FontWorkCharacterSpacingWindow::implSetCharacterSpacing( sal_Int32 nCharacterSpacing
, bool bEnabled
)
684 for ( i
= 0; i
< 6; i
++ )
686 mpMenu
->checkEntry( i
, sal_False
);
687 mpMenu
->enableEntry( i
, bEnabled
);
689 if ( nCharacterSpacing
!= -1 )
692 switch( nCharacterSpacing
)
694 case 80 : nEntry
= 0; break;
695 case 90 : nEntry
= 1; break;
696 case 100 : nEntry
= 2; break;
697 case 120 : nEntry
= 3; break;
698 case 150 : nEntry
= 4; break;
699 default : nEntry
= 5; break;
701 mpMenu
->checkEntry( nEntry
, bEnabled
);
706 void FontWorkCharacterSpacingWindow::implSetKernCharacterPairs( sal_Bool
, bool bEnabled
)
710 mpMenu
->enableEntry( 6, bEnabled
);
711 mpMenu
->checkEntry( 6, bEnabled
);
715 // -----------------------------------------------------------------------
717 void FontWorkCharacterSpacingWindow::StateChanged( USHORT nSID
, SfxItemState eState
, const SfxPoolItem
* pState
)
721 case SID_FONTWORK_CHARACTER_SPACING
:
723 if( eState
== SFX_ITEM_DISABLED
)
724 implSetCharacterSpacing( 0, false );
727 const SfxInt32Item
* pStateItem
= PTR_CAST( SfxInt32Item
, pState
);
729 implSetCharacterSpacing( pStateItem
->GetValue(), true );
734 case SID_FONTWORK_KERN_CHARACTER_PAIRS
:
736 if( eState
== SFX_ITEM_DISABLED
)
737 implSetKernCharacterPairs( 0, false );
740 const SfxBoolItem
* pStateItem
= PTR_CAST( SfxBoolItem
, pState
);
742 implSetKernCharacterPairs( pStateItem
->GetValue(), true );
749 // -----------------------------------------------------------------------
751 void FontWorkCharacterSpacingWindow::DataChanged( const DataChangedEvent
& rDCEvt
)
753 SfxPopupWindow::DataChanged( rDCEvt
);
755 if( ( rDCEvt
.GetType() == DATACHANGED_SETTINGS
) && ( rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
757 // bool bHighContrast = GetDisplayBackground().GetColor().IsDark();
759 mpMenu
->appendEntry( 0, String( SVX_RES( STR_CHARS_SPACING_VERY_TIGHT
) ), MIB_CHECKABLE
);
760 mpMenu
->appendEntry( 1, String( SVX_RES( STR_CHARS_SPACING_TIGHT
) ), MIB_CHECKABLE
);
761 mpMenu
->appendEntry( 2, String( SVX_RES( STR_CHARS_SPACING_NORMAL
) ), MIB_CHECKABLE
);
762 mpMenu
->appendEntry( 3, String( SVX_RES( STR_CHARS_SPACING_LOOSE
) ), MIB_CHECKABLE
);
763 mpMenu
->appendEntry( 4, String( SVX_RES( STR_CHARS_SPACING_VERY_LOOSE
) ), MIB_CHECKABLE
);
764 mpMenu
->appendEntry( 5, String( SVX_RES( STR_CHARS_SPACING_CUSTOM
) ), MIB_CHECKABLE
);
765 mpMenu
->appendSeparator();
766 mpMenu
->appendEntry( 6, String( SVX_RES( STR_CHARS_SPACING_KERN_PAIRS
) ), MIB_CHECKABLE
);
770 // -----------------------------------------------------------------------
772 IMPL_LINK( FontWorkCharacterSpacingWindow
, SelectHdl
, void *, EMPTYARG
)
774 if ( IsInPopupMode() )
777 sal_Int32 nSelection
= mpMenu
->getSelectedEntryId();
778 sal_Int32 nCharacterSpacing
;
781 case 0 : nCharacterSpacing
= 80; break;
782 case 1 : nCharacterSpacing
= 90; break;
783 case 2 : nCharacterSpacing
= 100; break;
784 case 3 : nCharacterSpacing
= 120; break;
785 case 4 : nCharacterSpacing
= 150; break;
786 default : nCharacterSpacing
= 100; break;
788 if ( nSelection
== 5 ) // custom spacing
790 SfxInt32Item
aItem( SID_FONTWORK_CHARACTER_SPACING
, nCharacterSpacing
);
791 rtl::OUString
aCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkCharacterSpacingDialog" ));
794 Sequence
< PropertyValue
> aArgs( 1 );
795 aArgs
[0].Name
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontworkCharacterSpacing" ));
796 aItem
.QueryValue( a
);
798 SfxToolBoxControl::Dispatch( Reference
< ::com::sun::star::frame::XDispatchProvider
>(
799 mxFrame
->getController(), UNO_QUERY
),
803 else if ( nSelection
== 6 ) // KernCharacterPairs
805 sal_Bool bOnOff
= sal_True
;
806 SfxBoolItem
aItem( SID_FONTWORK_KERN_CHARACTER_PAIRS
, bOnOff
);
807 rtl::OUString
aCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkKernCharacterPairs" ));
810 Sequence
< PropertyValue
> aArgs( 1 );
811 aArgs
[0].Name
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontworkKernCharacterPairs" ));
812 aItem
.QueryValue( a
);
814 SfxToolBoxControl::Dispatch( Reference
< ::com::sun::star::frame::XDispatchProvider
>(
815 mxFrame
->getController(), UNO_QUERY
),
819 implSetKernCharacterPairs( bOnOff
, true );
821 else if( nSelection
>= 0 )
823 SfxInt32Item
aItem( SID_FONTWORK_CHARACTER_SPACING
, nCharacterSpacing
);
824 rtl::OUString
aCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkCharacterSpacing" ));
827 INetURLObject
aObj( aCommand
);
828 Sequence
< PropertyValue
> aArgs( 1 );
829 aArgs
[0].Name
= aObj
.GetURLPath();
830 aItem
.QueryValue( a
);
833 SfxToolBoxControl::Dispatch( Reference
< ::com::sun::star::frame::XDispatchProvider
>(
834 mxFrame
->getController(), UNO_QUERY
),
838 implSetCharacterSpacing( nCharacterSpacing
, true );
844 // -----------------------------------------------------------------------
846 void FontWorkCharacterSpacingWindow::StartSelection()
850 // -----------------------------------------------------------------------
852 BOOL
FontWorkCharacterSpacingWindow::Close()
854 return SfxPopupWindow::Close();
857 // -----------------------------------------------------------------------
859 void FontWorkCharacterSpacingWindow::PopupModeEnd()
865 SfxPopupWindow::PopupModeEnd();
868 // -----------------------------------------------------------------------
870 void FontWorkCharacterSpacingWindow::GetFocus (void)
872 SfxPopupWindow::GetFocus();
873 // Grab the focus to the line ends value set so that it can be controlled
874 // with the keyboard.
879 // ========================================================================
881 FontWorkCharacterSpacingControl::FontWorkCharacterSpacingControl(
882 USHORT nSlotId
, USHORT nId
, ToolBox
&rTbx
)
883 : SfxToolBoxControl( nSlotId
, nId
, rTbx
)
885 rTbx
.SetItemBits( nId
, TIB_DROPDOWNONLY
| rTbx
.GetItemBits( nId
) );
888 // -----------------------------------------------------------------------
890 FontWorkCharacterSpacingControl::~FontWorkCharacterSpacingControl()
894 // -----------------------------------------------------------------------
896 SfxPopupWindowType
FontWorkCharacterSpacingControl::GetPopupWindowType() const
898 return SFX_POPUPWINDOW_ONCLICK
;
901 // -----------------------------------------------------------------------
903 SfxPopupWindow
* FontWorkCharacterSpacingControl::CreatePopupWindow()
905 FontWorkCharacterSpacingWindow
* pWin
= new FontWorkCharacterSpacingWindow( GetId(), m_xFrame
, &GetToolBox() );
906 pWin
->StartPopupMode( &GetToolBox(), TRUE
);
907 pWin
->StartSelection();
908 SetPopupWindow( pWin
);
912 // -----------------------------------------------------------------------
914 void FontWorkCharacterSpacingControl::StateChanged( USHORT
, SfxItemState eState
, const SfxPoolItem
* )
916 USHORT nId
= GetId();
917 ToolBox
& rTbx
= GetToolBox();
919 rTbx
.EnableItem( nId
, SFX_ITEM_DISABLED
!= eState
);
920 rTbx
.SetItemState( nId
, ( SFX_ITEM_DONTCARE
== eState
) ? STATE_DONTKNOW
: STATE_NOCHECK
);
923 // -----------------------------------------------------------------------
925 FontworkCharacterSpacingDialog::FontworkCharacterSpacingDialog( Window
* pParent
, sal_Int32 nScale
)
926 : ModalDialog( pParent
, SVX_RES( RID_SVX_MDLG_FONTWORK_CHARSPACING
) ),
927 maFLScale( this, SVX_RES( FT_VALUE
) ),
928 maMtrScale( this, SVX_RES( MF_VALUE
) ),
929 maOKButton( this, SVX_RES( BTN_OK
) ),
930 maCancelButton( this, SVX_RES( BTN_CANCEL
) ),
931 maHelpButton( this, SVX_RES( BTN_HELP
) )
933 maMtrScale
.SetValue( nScale
);
937 FontworkCharacterSpacingDialog::~FontworkCharacterSpacingDialog()
941 sal_Int32
FontworkCharacterSpacingDialog::getScale() const
943 return (sal_Int32
)maMtrScale
.GetValue();