1f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5f6e50924SAndrew Rist * distributed with this work for additional information 6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14f6e50924SAndrew Rist * software distributed under the License is distributed on an 15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17f6e50924SAndrew Rist * specific language governing permissions and limitations 18f6e50924SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20f6e50924SAndrew Rist *************************************************************/ 21f6e50924SAndrew Rist 22f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/text/WritingMode.hpp> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <vcl/toolbox.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <svl/itempool.hxx> 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <svtools/toolbarmenu.hxx> 34cdf0e10cSrcweir #include <svtools/popupwindowcontroller.hxx> 35cdf0e10cSrcweir #include <svtools/popupmenucontrollerbase.hxx> 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include <sfx2/app.hxx> 38cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include <editeng/eeitem.hxx> 41cdf0e10cSrcweir #include <editeng/frmdiritem.hxx> 42cdf0e10cSrcweir 43cdf0e10cSrcweir #include <svx/fmmodel.hxx> 44cdf0e10cSrcweir #include <svx/svxids.hrc> 45cdf0e10cSrcweir #include <svx/dialmgr.hxx> 46cdf0e10cSrcweir #include <svx/dialogs.hrc> 47cdf0e10cSrcweir #include <svx/svdpage.hxx> 48cdf0e10cSrcweir #include <svx/svdobj.hxx> 49cdf0e10cSrcweir #include <svx/svdview.hxx> 50cdf0e10cSrcweir #include <svx/svdoutl.hxx> 51cdf0e10cSrcweir 52cdf0e10cSrcweir #include "svx/gallery.hxx" 53cdf0e10cSrcweir #include <svx/dlgutil.hxx> 54cdf0e10cSrcweir 55cdf0e10cSrcweir #include <svx/fontworkgallery.hxx> 56cdf0e10cSrcweir #include "fontworkgallery.hrc" 57cdf0e10cSrcweir 58cdf0e10cSrcweir #include <algorithm> 59cdf0e10cSrcweir 60cdf0e10cSrcweir #include "helpid.hrc" 61cdf0e10cSrcweir 62cdf0e10cSrcweir using ::rtl::OUString; 63cdf0e10cSrcweir using ::svtools::ToolbarMenu; 64cdf0e10cSrcweir 65cdf0e10cSrcweir using namespace ::com::sun::star; 66cdf0e10cSrcweir using namespace ::com::sun::star::uno; 67cdf0e10cSrcweir using namespace ::com::sun::star::lang; 68cdf0e10cSrcweir using namespace ::com::sun::star::beans; 69cdf0e10cSrcweir using namespace ::com::sun::star::frame; 70cdf0e10cSrcweir 71cdf0e10cSrcweir namespace svx 72cdf0e10cSrcweir { 73cdf0e10cSrcweir 74cdf0e10cSrcweir const int nColCount = 4; 75cdf0e10cSrcweir const int nLineCount = 4; 76cdf0e10cSrcweir 77cdf0e10cSrcweir /************************************************************************* 78cdf0e10cSrcweir |* Svx3DWin - FloatingWindow 79cdf0e10cSrcweir \************************************************************************/ 80cdf0e10cSrcweir FontWorkGalleryDialog::FontWorkGalleryDialog( SdrView* pSdrView, Window* pParent, sal_uInt16 /*nSID*/ ) : 81cdf0e10cSrcweir ModalDialog( pParent, SVX_RES( RID_SVX_MDLG_FONTWORK_GALLERY ) ), 82cdf0e10cSrcweir maFLFavorites ( this, SVX_RES( FL_FAVORITES ) ), 83cdf0e10cSrcweir maCtlFavorites ( this, SVX_RES( CTL_FAVORITES ) ), 84cdf0e10cSrcweir maOKButton ( this, SVX_RES( BTN_OK ) ), 85cdf0e10cSrcweir maCancelButton ( this, SVX_RES( BTN_CANCEL ) ), 86cdf0e10cSrcweir maHelpButton ( this, SVX_RES( BTN_HELP ) ), 87cdf0e10cSrcweir mnThemeId ( 0xffff ), 88cdf0e10cSrcweir mpSdrView ( pSdrView ), 89cdf0e10cSrcweir mpModel ( (FmFormModel*)pSdrView->GetModel() ), 90cdf0e10cSrcweir maStrClickToAddText ( SVX_RES( STR_CLICK_TO_ADD_TEXT ) ), 91cdf0e10cSrcweir mppSdrObject ( NULL ), 92cdf0e10cSrcweir mpDestModel ( NULL ) 93cdf0e10cSrcweir { 94cdf0e10cSrcweir FreeResource(); 95cdf0e10cSrcweir 96cdf0e10cSrcweir maCtlFavorites.SetDoubleClickHdl( LINK( this, FontWorkGalleryDialog, DoubleClickFavoriteHdl ) ); 97cdf0e10cSrcweir maOKButton.SetClickHdl( LINK( this, FontWorkGalleryDialog, ClickOKHdl ) ); 98cdf0e10cSrcweir 99cdf0e10cSrcweir maCtlFavorites.SetColCount( nColCount ); 100cdf0e10cSrcweir maCtlFavorites.SetLineCount( nLineCount ); 101cdf0e10cSrcweir maCtlFavorites.SetExtraSpacing( 3 ); 102cdf0e10cSrcweir 1036dd94783SArmin Le Grand initFavorites( GALLERY_THEME_FONTWORK ); 1046dd94783SArmin Le Grand fillFavorites( GALLERY_THEME_FONTWORK ); 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir // ----------------------------------------------------------------------- 108cdf0e10cSrcweir FontWorkGalleryDialog::~FontWorkGalleryDialog() 109cdf0e10cSrcweir { 110cdf0e10cSrcweir } 111cdf0e10cSrcweir 112cdf0e10cSrcweir // ----------------------------------------------------------------------- 113cdf0e10cSrcweir 1146dd94783SArmin Le Grand void FontWorkGalleryDialog::initFavorites(sal_uInt16 nThemeId) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir // Ueber die Gallery werden die Favoriten eingelesen 117cdf0e10cSrcweir sal_uIntPtr nFavCount = GalleryExplorer::GetSdrObjCount( nThemeId ); 118cdf0e10cSrcweir 119cdf0e10cSrcweir // Gallery thema locken 120cdf0e10cSrcweir GalleryExplorer::BeginLocking(nThemeId); 121cdf0e10cSrcweir 122cdf0e10cSrcweir sal_uInt32 nModelPos; 123cdf0e10cSrcweir FmFormModel *pModel = NULL; 124*35726d9dSArmin Le Grand const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); 125*35726d9dSArmin Le Grand 126cdf0e10cSrcweir for( nModelPos = 0; nModelPos < nFavCount; nModelPos++ ) 127cdf0e10cSrcweir { 1286dd94783SArmin Le Grand BitmapEx aThumb; 129cdf0e10cSrcweir 1306dd94783SArmin Le Grand GalleryExplorer::GetSdrObj(nThemeId, nModelPos, pModel, &aThumb); 1316dd94783SArmin Le Grand 1326dd94783SArmin Le Grand if(!!aThumb) 133cdf0e10cSrcweir { 134cdf0e10cSrcweir VirtualDevice aVDev; 1356dd94783SArmin Le Grand const Point aNull(0, 0); 1366dd94783SArmin Le Grand const Size aSize(aThumb.GetSizePixel()); 137cdf0e10cSrcweir 1386dd94783SArmin Le Grand aVDev.SetOutputSizePixel(aSize); 139cdf0e10cSrcweir 140*35726d9dSArmin Le Grand if(rStyleSettings.GetUIPreviewUsesCheckeredBackground()) 141*35726d9dSArmin Le Grand { 142*35726d9dSArmin Le Grand static const sal_uInt32 nLen(8); 143*35726d9dSArmin Le Grand static const Color aW(COL_WHITE); 144*35726d9dSArmin Le Grand static const Color aG(0xef, 0xef, 0xef); 145*35726d9dSArmin Le Grand 146*35726d9dSArmin Le Grand aVDev.DrawCheckered(aNull, aSize, nLen, aW, aG); 147*35726d9dSArmin Le Grand } 148*35726d9dSArmin Le Grand else 149*35726d9dSArmin Le Grand { 150*35726d9dSArmin Le Grand aVDev.SetBackground(rStyleSettings.GetFieldColor()); 151*35726d9dSArmin Le Grand aVDev.Erase(); 152*35726d9dSArmin Le Grand } 153*35726d9dSArmin Le Grand 154*35726d9dSArmin Le Grand aVDev.DrawBitmapEx(aNull, aThumb); 1556dd94783SArmin Le Grand maFavoritesHorizontal.push_back(aVDev.GetBitmap(aNull, aSize)); 156cdf0e10cSrcweir } 157cdf0e10cSrcweir } 158cdf0e10cSrcweir 159cdf0e10cSrcweir // Gallery thema freigeben 160cdf0e10cSrcweir GalleryExplorer::EndLocking(nThemeId); 161cdf0e10cSrcweir } 162cdf0e10cSrcweir 1636dd94783SArmin Le Grand void FontWorkGalleryDialog::fillFavorites(sal_uInt16 nThemeId) 164cdf0e10cSrcweir { 165cdf0e10cSrcweir mnThemeId = nThemeId; 166cdf0e10cSrcweir 167cdf0e10cSrcweir Size aThumbSize( maCtlFavorites.GetSizePixel() ); 168cdf0e10cSrcweir aThumbSize.Width() /= nColCount; 169cdf0e10cSrcweir aThumbSize.Height() /= nLineCount; 170cdf0e10cSrcweir aThumbSize.Width() -= 12; 171cdf0e10cSrcweir aThumbSize.Height() -= 12; 172cdf0e10cSrcweir 1736dd94783SArmin Le Grand std::vector< Bitmap * >::size_type nFavCount = maFavoritesHorizontal.size(); 174cdf0e10cSrcweir 175cdf0e10cSrcweir // ValueSet Favoriten 176cdf0e10cSrcweir if( nFavCount > (nColCount * nLineCount) ) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir WinBits nWinBits = maCtlFavorites.GetStyle(); 179cdf0e10cSrcweir nWinBits |= WB_VSCROLL; 180cdf0e10cSrcweir maCtlFavorites.SetStyle( nWinBits ); 181cdf0e10cSrcweir } 182cdf0e10cSrcweir 183cdf0e10cSrcweir maCtlFavorites.Clear(); 184cdf0e10cSrcweir 185cdf0e10cSrcweir sal_uInt32 nFavorite; 186cdf0e10cSrcweir for( nFavorite = 1; nFavorite <= nFavCount; nFavorite++ ) 187cdf0e10cSrcweir { 188cdf0e10cSrcweir String aStr(SVX_RES(RID_SVXFLOAT3D_FAVORITE)); 189cdf0e10cSrcweir aStr += sal_Unicode(' '); 190cdf0e10cSrcweir aStr += String::CreateFromInt32((sal_Int32)nFavorite); 1916dd94783SArmin Le Grand Image aThumbImage( maFavoritesHorizontal[nFavorite-1] ); 192cdf0e10cSrcweir maCtlFavorites.InsertItem( (sal_uInt16)nFavorite, aThumbImage, aStr ); 193cdf0e10cSrcweir } 194cdf0e10cSrcweir } 195cdf0e10cSrcweir 196cdf0e10cSrcweir void FontWorkGalleryDialog::changeText( SdrTextObj* pObj ) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir if( pObj ) 199cdf0e10cSrcweir { 200cdf0e10cSrcweir SdrOutliner& rOutl = mpModel->GetDrawOutliner(pObj); 201cdf0e10cSrcweir 202cdf0e10cSrcweir sal_uInt16 nOutlMode = rOutl.GetMode(); 203cdf0e10cSrcweir Size aPaperSize = rOutl.GetPaperSize(); 204cdf0e10cSrcweir sal_Bool bUpdateMode = rOutl.GetUpdateMode(); 205cdf0e10cSrcweir rOutl.SetUpdateMode(sal_False); 206cdf0e10cSrcweir rOutl.SetParaAttribs( 0, rOutl.GetEmptyItemSet() ); 207cdf0e10cSrcweir 208cdf0e10cSrcweir // #95114# Always set the object's StyleSheet at the Outliner to 209cdf0e10cSrcweir // use the current objects StyleSheet. Thus it's the same as in 210cdf0e10cSrcweir // SetText(...). 211cdf0e10cSrcweir // #95114# Moved this implementation from where SetObjText(...) was called 212cdf0e10cSrcweir // to inside this method to work even when outliner is fetched here. 213cdf0e10cSrcweir rOutl.SetStyleSheet(0, pObj->GetStyleSheet()); 214cdf0e10cSrcweir 215cdf0e10cSrcweir rOutl.SetPaperSize( pObj->GetLogicRect().GetSize() ); 216cdf0e10cSrcweir 217cdf0e10cSrcweir rOutl.SetText( maStrClickToAddText, rOutl.GetParagraph( 0 ) ); 218cdf0e10cSrcweir pObj->SetOutlinerParaObject( rOutl.CreateParaObject() ); 219cdf0e10cSrcweir 220cdf0e10cSrcweir rOutl.Init( nOutlMode ); 221cdf0e10cSrcweir rOutl.SetParaAttribs( 0, rOutl.GetEmptyItemSet() ); 222cdf0e10cSrcweir rOutl.SetUpdateMode( bUpdateMode ); 223cdf0e10cSrcweir rOutl.SetPaperSize( aPaperSize ); 224cdf0e10cSrcweir 225cdf0e10cSrcweir rOutl.Clear(); 226cdf0e10cSrcweir } 227cdf0e10cSrcweir } 228cdf0e10cSrcweir 229cdf0e10cSrcweir void FontWorkGalleryDialog::SetSdrObjectRef( SdrObject** ppSdrObject, SdrModel* pModel ) 230cdf0e10cSrcweir { 231cdf0e10cSrcweir mppSdrObject = ppSdrObject; 232cdf0e10cSrcweir mpDestModel = pModel; 233cdf0e10cSrcweir } 234cdf0e10cSrcweir 235cdf0e10cSrcweir void FontWorkGalleryDialog::insertSelectedFontwork() 236cdf0e10cSrcweir { 237cdf0e10cSrcweir sal_uInt16 nItemId = maCtlFavorites.GetSelectItemId(); 238cdf0e10cSrcweir 239cdf0e10cSrcweir if( nItemId > 0 ) 240cdf0e10cSrcweir { 241cdf0e10cSrcweir FmFormModel* pModel = new FmFormModel(); 242cdf0e10cSrcweir pModel->GetItemPool().FreezeIdRanges(); 243cdf0e10cSrcweir 244cdf0e10cSrcweir if( GalleryExplorer::GetSdrObj( mnThemeId, nItemId-1, pModel ) ) 245cdf0e10cSrcweir { 246cdf0e10cSrcweir SdrPage* pPage = pModel->GetPage(0); 247cdf0e10cSrcweir if( pPage && pPage->GetObjCount() ) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir SdrObject* pNewObject = pPage->GetObj(0)->Clone(); 250cdf0e10cSrcweir 251cdf0e10cSrcweir // center shape on current view 252cdf0e10cSrcweir OutputDevice* pOutDev = mpSdrView->GetFirstOutputDevice(); 253cdf0e10cSrcweir if( pOutDev ) 254cdf0e10cSrcweir { 255cdf0e10cSrcweir Rectangle aObjRect( pNewObject->GetLogicRect() ); 256cdf0e10cSrcweir Rectangle aVisArea = pOutDev->PixelToLogic(Rectangle(Point(0,0), pOutDev->GetOutputSizePixel())); 257cdf0e10cSrcweir /* 258cdf0e10cSrcweir sal_Int32 nObjHeight = aObjRect.GetHeight(); 259cdf0e10cSrcweir VirtualDevice aVirDev( 1 ); // calculating the optimal textwidth 260cdf0e10cSrcweir Font aFont; 261cdf0e10cSrcweir aFont.SetHeight( nObjHeight ); 262cdf0e10cSrcweir aVirDev.SetMapMode( MAP_100TH_MM ); 263cdf0e10cSrcweir aVirDev.SetFont( aFont ); 264cdf0e10cSrcweir aObjRect.SetSize( Size( aVirDev.GetTextWidth( maStrClickToAddText ), nObjHeight ) ); 265cdf0e10cSrcweir */ 266cdf0e10cSrcweir Point aPagePos = aVisArea.Center(); 267cdf0e10cSrcweir aPagePos.X() -= aObjRect.GetWidth() / 2; 268cdf0e10cSrcweir aPagePos.Y() -= aObjRect.GetHeight() / 2; 269cdf0e10cSrcweir Rectangle aNewObjectRectangle(aPagePos, aObjRect.GetSize()); 270cdf0e10cSrcweir SdrPageView* pPV = mpSdrView->GetSdrPageView(); 271cdf0e10cSrcweir 272cdf0e10cSrcweir pNewObject->SetLogicRect(aNewObjectRectangle); 273cdf0e10cSrcweir if ( mppSdrObject ) 274cdf0e10cSrcweir { 275cdf0e10cSrcweir *mppSdrObject = pNewObject; 276cdf0e10cSrcweir (*mppSdrObject)->SetModel( mpDestModel ); 277cdf0e10cSrcweir } 278cdf0e10cSrcweir else if( pPV ) 279cdf0e10cSrcweir { 280cdf0e10cSrcweir mpSdrView->InsertObjectAtView( pNewObject, *pPV ); 281cdf0e10cSrcweir // changeText( PTR_CAST( SdrTextObj, pNewObject ) ); 282cdf0e10cSrcweir } 283cdf0e10cSrcweir } 284cdf0e10cSrcweir } 285cdf0e10cSrcweir } 286cdf0e10cSrcweir 287cdf0e10cSrcweir delete pModel; 288cdf0e10cSrcweir } 289cdf0e10cSrcweir } 290cdf0e10cSrcweir 291cdf0e10cSrcweir // ----------------------------------------------------------------------- 292cdf0e10cSrcweir 293cdf0e10cSrcweir IMPL_LINK( FontWorkGalleryDialog, ClickOKHdl, void*, EMPTYARG ) 294cdf0e10cSrcweir { 295cdf0e10cSrcweir insertSelectedFontwork(); 296cdf0e10cSrcweir EndDialog( true ); 297cdf0e10cSrcweir return 0; 298cdf0e10cSrcweir } 299cdf0e10cSrcweir 300cdf0e10cSrcweir // ----------------------------------------------------------------------- 301cdf0e10cSrcweir 302cdf0e10cSrcweir IMPL_LINK( FontWorkGalleryDialog, DoubleClickFavoriteHdl, void*, EMPTYARG ) 303cdf0e10cSrcweir { 304cdf0e10cSrcweir insertSelectedFontwork(); 305cdf0e10cSrcweir EndDialog( true ); 306cdf0e10cSrcweir return( 0L ); 307cdf0e10cSrcweir } 308cdf0e10cSrcweir 309cdf0e10cSrcweir //------------------------------------------------------------------------ 310cdf0e10cSrcweir 311cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL( FontWorkShapeTypeControl, SfxStringItem ); 312cdf0e10cSrcweir FontWorkShapeTypeControl::FontWorkShapeTypeControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox &rTbx ) 313cdf0e10cSrcweir : SfxToolBoxControl( nSlotId, nId, rTbx ) 314cdf0e10cSrcweir { 315cdf0e10cSrcweir rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) ); 316cdf0e10cSrcweir rTbx.Invalidate(); 317cdf0e10cSrcweir } 318cdf0e10cSrcweir 319cdf0e10cSrcweir // ----------------------------------------------------------------------- 320cdf0e10cSrcweir 321cdf0e10cSrcweir FontWorkShapeTypeControl::~FontWorkShapeTypeControl() 322cdf0e10cSrcweir { 323cdf0e10cSrcweir } 324cdf0e10cSrcweir 325cdf0e10cSrcweir // ----------------------------------------------------------------------- 326cdf0e10cSrcweir 327cdf0e10cSrcweir SfxPopupWindowType FontWorkShapeTypeControl::GetPopupWindowType() const 328cdf0e10cSrcweir { 329cdf0e10cSrcweir return SFX_POPUPWINDOW_ONCLICK; //( aLastAction.getLength() == 0 ? SFX_POPUPWINDOW_ONCLICK : SFX_POPUPWINDOW_ONTIMEOUT ); 330cdf0e10cSrcweir } 331cdf0e10cSrcweir 332cdf0e10cSrcweir // ----------------------------------------------------------------------- 333cdf0e10cSrcweir 334cdf0e10cSrcweir SfxPopupWindow* FontWorkShapeTypeControl::CreatePopupWindow() 335cdf0e10cSrcweir { 336cdf0e10cSrcweir rtl::OUString aSubTbxResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/fontworkshapetype" ) ); 337cdf0e10cSrcweir createAndPositionSubToolBar( aSubTbxResName ); 338cdf0e10cSrcweir return NULL; 339cdf0e10cSrcweir } 340cdf0e10cSrcweir 341cdf0e10cSrcweir // ----------------------------------------------------------------------- 342cdf0e10cSrcweir 343cdf0e10cSrcweir void FontWorkShapeTypeControl::Select( sal_Bool ) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir 346cdf0e10cSrcweir } 347cdf0e10cSrcweir 348cdf0e10cSrcweir // ======================================================================== 349199633b5SHerbert Dürr // FontworkAlignmentWindow 350cdf0e10cSrcweir // ======================================================================== 351cdf0e10cSrcweir 352199633b5SHerbert Dürr class FontworkAlignmentWindow : public ToolbarMenu 353cdf0e10cSrcweir { 354cdf0e10cSrcweir public: 355199633b5SHerbert Dürr FontworkAlignmentWindow( svt::ToolboxController& rController, const Reference< XFrame >& rFrame, Window* pParentWindow ); 356cdf0e10cSrcweir 357cdf0e10cSrcweir virtual void SAL_CALL statusChanged( const frame::FeatureStateEvent& Event ) throw ( RuntimeException ); 358cdf0e10cSrcweir virtual void DataChanged( const DataChangedEvent& rDCEvt ); 359cdf0e10cSrcweir 360cdf0e10cSrcweir private: 361cdf0e10cSrcweir svt::ToolboxController& mrController; 362cdf0e10cSrcweir 363cdf0e10cSrcweir Image maImgAlgin1; 364cdf0e10cSrcweir Image maImgAlgin2; 365cdf0e10cSrcweir Image maImgAlgin3; 366cdf0e10cSrcweir Image maImgAlgin4; 367cdf0e10cSrcweir Image maImgAlgin5; 368cdf0e10cSrcweir Image maImgAlgin1h; 369cdf0e10cSrcweir Image maImgAlgin2h; 370cdf0e10cSrcweir Image maImgAlgin3h; 371cdf0e10cSrcweir Image maImgAlgin4h; 372cdf0e10cSrcweir Image maImgAlgin5h; 373cdf0e10cSrcweir 374cdf0e10cSrcweir const rtl::OUString msFontworkAlignment; 375cdf0e10cSrcweir 376cdf0e10cSrcweir DECL_LINK( SelectHdl, void * ); 377cdf0e10cSrcweir 378cdf0e10cSrcweir void implSetAlignment( int nAlignmentMode, bool bEnabled ); 379cdf0e10cSrcweir }; 380cdf0e10cSrcweir 381199633b5SHerbert Dürr FontworkAlignmentWindow::FontworkAlignmentWindow( svt::ToolboxController& rController, const Reference< XFrame >& rFrame, Window* pParentWindow ) 382cdf0e10cSrcweir : ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_FONTWORK_ALIGNMENT )) 383cdf0e10cSrcweir , mrController( rController ) 384cdf0e10cSrcweir , maImgAlgin1( SVX_RES( IMG_FONTWORK_ALIGN_LEFT_16 ) ) 385cdf0e10cSrcweir , maImgAlgin2( SVX_RES( IMG_FONTWORK_ALIGN_CENTER_16 ) ) 386cdf0e10cSrcweir , maImgAlgin3( SVX_RES( IMG_FONTWORK_ALIGN_RIGHT_16 ) ) 387cdf0e10cSrcweir , maImgAlgin4( SVX_RES( IMG_FONTWORK_ALIGN_WORD_16 ) ) 388cdf0e10cSrcweir , maImgAlgin5( SVX_RES( IMG_FONTWORK_ALIGN_STRETCH_16 ) ) 389cdf0e10cSrcweir , maImgAlgin1h( SVX_RES( IMG_FONTWORK_ALIGN_LEFT_16_H ) ) 390cdf0e10cSrcweir , maImgAlgin2h( SVX_RES( IMG_FONTWORK_ALIGN_CENTER_16_H ) ) 391cdf0e10cSrcweir , maImgAlgin3h( SVX_RES( IMG_FONTWORK_ALIGN_RIGHT_16_H ) ) 392cdf0e10cSrcweir , maImgAlgin4h( SVX_RES( IMG_FONTWORK_ALIGN_WORD_16_H ) ) 393cdf0e10cSrcweir , maImgAlgin5h( SVX_RES( IMG_FONTWORK_ALIGN_STRETCH_16_H ) ) 394cdf0e10cSrcweir , msFontworkAlignment( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkAlignment" ) ) 395cdf0e10cSrcweir { 396cdf0e10cSrcweir bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); 397cdf0e10cSrcweir 398cdf0e10cSrcweir SetHelpId( HID_POPUP_FONTWORK_ALIGN ); 399199633b5SHerbert Dürr SetSelectHdl( LINK( this, FontworkAlignmentWindow, SelectHdl ) ); 400cdf0e10cSrcweir 401cdf0e10cSrcweir appendEntry( 0, String( SVX_RES( STR_ALIGN_LEFT ) ), bHighContrast ? maImgAlgin1h : maImgAlgin1 ); 402cdf0e10cSrcweir appendEntry( 1, String( SVX_RES( STR_ALIGN_CENTER ) ), bHighContrast ? maImgAlgin2h : maImgAlgin2 ); 403cdf0e10cSrcweir appendEntry( 2, String( SVX_RES( STR_ALIGN_RIGHT ) ), bHighContrast ? maImgAlgin3h : maImgAlgin3 ); 404cdf0e10cSrcweir appendEntry( 3, String( SVX_RES( STR_ALIGN_WORD ) ), bHighContrast ? maImgAlgin4h : maImgAlgin4 ); 405cdf0e10cSrcweir appendEntry( 4, String( SVX_RES( STR_ALIGN_STRETCH ) ), bHighContrast ? maImgAlgin5h : maImgAlgin5 ); 406cdf0e10cSrcweir 407cdf0e10cSrcweir SetOutputSizePixel( getMenuSize() ); 408cdf0e10cSrcweir 409cdf0e10cSrcweir FreeResource(); 410cdf0e10cSrcweir 411cdf0e10cSrcweir AddStatusListener( msFontworkAlignment ); 412cdf0e10cSrcweir } 413cdf0e10cSrcweir 414cdf0e10cSrcweir // ----------------------------------------------------------------------- 415cdf0e10cSrcweir 416199633b5SHerbert Dürr void FontworkAlignmentWindow::implSetAlignment( int nSurface, bool bEnabled ) 417cdf0e10cSrcweir { 418cdf0e10cSrcweir int i; 419cdf0e10cSrcweir for( i = 0; i < 5; i++ ) 420cdf0e10cSrcweir { 421cdf0e10cSrcweir checkEntry( i, (i == nSurface) && bEnabled ); 422cdf0e10cSrcweir enableEntry( i, bEnabled ); 423cdf0e10cSrcweir } 424cdf0e10cSrcweir } 425cdf0e10cSrcweir 426cdf0e10cSrcweir // ----------------------------------------------------------------------- 427cdf0e10cSrcweir 428199633b5SHerbert Dürr void SAL_CALL FontworkAlignmentWindow::statusChanged( const frame::FeatureStateEvent& Event ) throw ( RuntimeException ) 429cdf0e10cSrcweir { 430cdf0e10cSrcweir if( Event.FeatureURL.Main.equals( msFontworkAlignment ) ) 431cdf0e10cSrcweir { 432cdf0e10cSrcweir if( !Event.IsEnabled ) 433cdf0e10cSrcweir { 434cdf0e10cSrcweir implSetAlignment( 0, false ); 435cdf0e10cSrcweir } 436cdf0e10cSrcweir else 437cdf0e10cSrcweir { 438cdf0e10cSrcweir sal_Int32 nValue = 0; 439cdf0e10cSrcweir if( Event.State >>= nValue ) 440cdf0e10cSrcweir implSetAlignment( nValue, true ); 441cdf0e10cSrcweir } 442cdf0e10cSrcweir } 443cdf0e10cSrcweir } 444cdf0e10cSrcweir 445cdf0e10cSrcweir // ----------------------------------------------------------------------- 446cdf0e10cSrcweir 447199633b5SHerbert Dürr void FontworkAlignmentWindow::DataChanged( const DataChangedEvent& rDCEvt ) 448cdf0e10cSrcweir { 449cdf0e10cSrcweir ToolbarMenu::DataChanged( rDCEvt ); 450cdf0e10cSrcweir 451cdf0e10cSrcweir if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) ) 452cdf0e10cSrcweir { 453cdf0e10cSrcweir bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); 454cdf0e10cSrcweir 455cdf0e10cSrcweir appendEntry( 0, String( SVX_RES( STR_ALIGN_LEFT ) ), bHighContrast ? maImgAlgin1h : maImgAlgin1 ); 456cdf0e10cSrcweir appendEntry( 1, String( SVX_RES( STR_ALIGN_CENTER ) ), bHighContrast ? maImgAlgin2h : maImgAlgin2 ); 457cdf0e10cSrcweir appendEntry( 2, String( SVX_RES( STR_ALIGN_RIGHT ) ), bHighContrast ? maImgAlgin3h : maImgAlgin3 ); 458cdf0e10cSrcweir appendEntry( 3, String( SVX_RES( STR_ALIGN_WORD ) ), bHighContrast ? maImgAlgin4h : maImgAlgin4 ); 459cdf0e10cSrcweir appendEntry( 4, String( SVX_RES( STR_ALIGN_STRETCH ) ), bHighContrast ? maImgAlgin5h : maImgAlgin5 ); 460cdf0e10cSrcweir } 461cdf0e10cSrcweir } 462cdf0e10cSrcweir 463cdf0e10cSrcweir // ----------------------------------------------------------------------- 464cdf0e10cSrcweir 465199633b5SHerbert Dürr IMPL_LINK( FontworkAlignmentWindow, SelectHdl, void *, EMPTYARG ) 466cdf0e10cSrcweir { 467cdf0e10cSrcweir if ( IsInPopupMode() ) 468cdf0e10cSrcweir EndPopupMode(); 469cdf0e10cSrcweir 470cdf0e10cSrcweir sal_Int32 nAlignment = getSelectedEntryId(); 471cdf0e10cSrcweir if( nAlignment >= 0 ) 472cdf0e10cSrcweir { 473cdf0e10cSrcweir Sequence< PropertyValue > aArgs( 1 ); 474cdf0e10cSrcweir aArgs[0].Name = msFontworkAlignment.copy(5); 475cdf0e10cSrcweir aArgs[0].Value <<= (sal_Int32)nAlignment; 476cdf0e10cSrcweir 477cdf0e10cSrcweir mrController.dispatchCommand( msFontworkAlignment, aArgs ); 478cdf0e10cSrcweir 479cdf0e10cSrcweir implSetAlignment( nAlignment, true ); 480cdf0e10cSrcweir } 481cdf0e10cSrcweir 482cdf0e10cSrcweir return 0; 483cdf0e10cSrcweir } 484cdf0e10cSrcweir 485cdf0e10cSrcweir // ======================================================================== 486199633b5SHerbert Dürr // FontworkAlignmentControl 487cdf0e10cSrcweir // ======================================================================== 488cdf0e10cSrcweir 489199633b5SHerbert Dürr class FontworkAlignmentControl : public svt::PopupWindowController 490cdf0e10cSrcweir { 491cdf0e10cSrcweir public: 492199633b5SHerbert Dürr FontworkAlignmentControl( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager ); 493cdf0e10cSrcweir 494cdf0e10cSrcweir virtual ::Window* createPopupWindow( ::Window* pParent ); 495cdf0e10cSrcweir 496cdf0e10cSrcweir // XServiceInfo 497cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); 498cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); 499cdf0e10cSrcweir 500cdf0e10cSrcweir using svt::PopupWindowController::createPopupWindow; 501cdf0e10cSrcweir }; 502cdf0e10cSrcweir 503cdf0e10cSrcweir 504cdf0e10cSrcweir // ----------------------------------------------------------------------- 505cdf0e10cSrcweir 506199633b5SHerbert Dürr FontworkAlignmentControl::FontworkAlignmentControl( const Reference< lang::XMultiServiceFactory >& rServiceManager ) 507cdf0e10cSrcweir : svt::PopupWindowController( rServiceManager, Reference< frame::XFrame >(), OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkAlignment" ) ) ) 508cdf0e10cSrcweir { 509cdf0e10cSrcweir } 510cdf0e10cSrcweir 511cdf0e10cSrcweir // ----------------------------------------------------------------------- 512cdf0e10cSrcweir 513199633b5SHerbert Dürr ::Window* FontworkAlignmentControl::createPopupWindow( ::Window* pParent ) 514cdf0e10cSrcweir { 515199633b5SHerbert Dürr return new FontworkAlignmentWindow( *this, m_xFrame, pParent ); 516cdf0e10cSrcweir } 517cdf0e10cSrcweir 518cdf0e10cSrcweir // ----------------------------------------------------------------------- 519cdf0e10cSrcweir // XServiceInfo 520cdf0e10cSrcweir // ----------------------------------------------------------------------- 521cdf0e10cSrcweir 522199633b5SHerbert Dürr OUString SAL_CALL FontworkAlignmentControl_getImplementationName() 523cdf0e10cSrcweir { 524199633b5SHerbert Dürr return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.FontworkAlignmentController" )); 525cdf0e10cSrcweir } 526cdf0e10cSrcweir 527cdf0e10cSrcweir // -------------------------------------------------------------------- 528cdf0e10cSrcweir 529199633b5SHerbert Dürr Sequence< OUString > SAL_CALL FontworkAlignmentControl_getSupportedServiceNames() throw( RuntimeException ) 530cdf0e10cSrcweir { 531cdf0e10cSrcweir Sequence< OUString > aSNS( 1 ); 532cdf0e10cSrcweir aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" )); 533cdf0e10cSrcweir return aSNS; 534cdf0e10cSrcweir } 535cdf0e10cSrcweir 536cdf0e10cSrcweir // -------------------------------------------------------------------- 537cdf0e10cSrcweir 538199633b5SHerbert Dürr Reference< XInterface > SAL_CALL SAL_CALL FontworkAlignmentControl_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException ) 539cdf0e10cSrcweir { 540199633b5SHerbert Dürr return *new FontworkAlignmentControl( rSMgr ); 541cdf0e10cSrcweir } 542cdf0e10cSrcweir 543cdf0e10cSrcweir // -------------------------------------------------------------------- 544cdf0e10cSrcweir 545199633b5SHerbert Dürr OUString SAL_CALL FontworkAlignmentControl::getImplementationName( ) throw (RuntimeException) 546cdf0e10cSrcweir { 547199633b5SHerbert Dürr return FontworkAlignmentControl_getImplementationName(); 548cdf0e10cSrcweir } 549cdf0e10cSrcweir 550cdf0e10cSrcweir // -------------------------------------------------------------------- 551cdf0e10cSrcweir 552199633b5SHerbert Dürr Sequence< OUString > SAL_CALL FontworkAlignmentControl::getSupportedServiceNames( ) throw (RuntimeException) 553cdf0e10cSrcweir { 554199633b5SHerbert Dürr return FontworkAlignmentControl_getSupportedServiceNames(); 555cdf0e10cSrcweir } 556cdf0e10cSrcweir 557cdf0e10cSrcweir 558cdf0e10cSrcweir // #################################################################### 559cdf0e10cSrcweir 560199633b5SHerbert Dürr class FontworkCharacterSpacingWindow : public ToolbarMenu 561cdf0e10cSrcweir { 562cdf0e10cSrcweir public: 563199633b5SHerbert Dürr FontworkCharacterSpacingWindow( svt::ToolboxController& rController, const Reference< XFrame >& rFrame, Window* pParentWindow ); 564cdf0e10cSrcweir 565cdf0e10cSrcweir virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ); 566cdf0e10cSrcweir private: 567cdf0e10cSrcweir svt::ToolboxController& mrController; 568cdf0e10cSrcweir 569cdf0e10cSrcweir const rtl::OUString msFontworkCharacterSpacing; 570cdf0e10cSrcweir const rtl::OUString msFontworkKernCharacterPairs; 571cdf0e10cSrcweir 572cdf0e10cSrcweir DECL_LINK( SelectHdl, void * ); 573cdf0e10cSrcweir 574cdf0e10cSrcweir void implSetCharacterSpacing( sal_Int32 nCharacterSpacing, bool bEnabled ); 575cdf0e10cSrcweir void implSetKernCharacterPairs( sal_Bool bKernOnOff, bool bEnabled ); 576cdf0e10cSrcweir 577cdf0e10cSrcweir }; 578cdf0e10cSrcweir 579cdf0e10cSrcweir // ----------------------------------------------------------------------- 580cdf0e10cSrcweir 581199633b5SHerbert Dürr FontworkCharacterSpacingWindow::FontworkCharacterSpacingWindow( svt::ToolboxController& rController, const Reference< XFrame >& rFrame, Window* pParentWindow ) 582cdf0e10cSrcweir : ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_FONTWORK_CHARSPACING )) 583cdf0e10cSrcweir , mrController( rController ) 584cdf0e10cSrcweir , msFontworkCharacterSpacing( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkCharacterSpacing" ) ) 585cdf0e10cSrcweir , msFontworkKernCharacterPairs( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkKernCharacterPairs" ) ) 586cdf0e10cSrcweir { 587cdf0e10cSrcweir SetHelpId( HID_POPUP_FONTWORK_CHARSPACE ); 588199633b5SHerbert Dürr SetSelectHdl( LINK( this, FontworkCharacterSpacingWindow, SelectHdl ) ); 589cdf0e10cSrcweir 590cdf0e10cSrcweir appendEntry( 0, String( SVX_RES( STR_CHARS_SPACING_VERY_TIGHT ) ), MIB_RADIOCHECK ); 591cdf0e10cSrcweir appendEntry( 1, String( SVX_RES( STR_CHARS_SPACING_TIGHT ) ), MIB_RADIOCHECK ); 592cdf0e10cSrcweir appendEntry( 2, String( SVX_RES( STR_CHARS_SPACING_NORMAL ) ), MIB_RADIOCHECK ); 593cdf0e10cSrcweir appendEntry( 3, String( SVX_RES( STR_CHARS_SPACING_LOOSE ) ), MIB_RADIOCHECK ); 594cdf0e10cSrcweir appendEntry( 4, String( SVX_RES( STR_CHARS_SPACING_VERY_LOOSE ) ), MIB_RADIOCHECK ); 595cdf0e10cSrcweir appendEntry( 5, String( SVX_RES( STR_CHARS_SPACING_CUSTOM ) ), MIB_RADIOCHECK ); 596cdf0e10cSrcweir appendSeparator(); 597cdf0e10cSrcweir appendEntry( 6, String( SVX_RES( STR_CHARS_SPACING_KERN_PAIRS ) ), MIB_CHECKABLE ); 598cdf0e10cSrcweir 599cdf0e10cSrcweir SetOutputSizePixel( getMenuSize() ); 600cdf0e10cSrcweir 601cdf0e10cSrcweir FreeResource(); 602cdf0e10cSrcweir 603cdf0e10cSrcweir AddStatusListener( msFontworkCharacterSpacing ); 604cdf0e10cSrcweir AddStatusListener( msFontworkKernCharacterPairs ); 605cdf0e10cSrcweir } 606cdf0e10cSrcweir 607cdf0e10cSrcweir // ----------------------------------------------------------------------- 608cdf0e10cSrcweir 609199633b5SHerbert Dürr void FontworkCharacterSpacingWindow::implSetCharacterSpacing( sal_Int32 nCharacterSpacing, bool bEnabled ) 610cdf0e10cSrcweir { 611cdf0e10cSrcweir sal_Int32 i; 612cdf0e10cSrcweir for ( i = 0; i < 6; i++ ) 613cdf0e10cSrcweir { 614cdf0e10cSrcweir checkEntry( i, sal_False ); 615cdf0e10cSrcweir enableEntry( i, bEnabled ); 616cdf0e10cSrcweir } 617cdf0e10cSrcweir if ( nCharacterSpacing != -1 ) 618cdf0e10cSrcweir { 619cdf0e10cSrcweir sal_Int32 nEntry; 620cdf0e10cSrcweir switch( nCharacterSpacing ) 621cdf0e10cSrcweir { 622cdf0e10cSrcweir case 80 : nEntry = 0; break; 623cdf0e10cSrcweir case 90 : nEntry = 1; break; 624cdf0e10cSrcweir case 100 : nEntry = 2; break; 625cdf0e10cSrcweir case 120 : nEntry = 3; break; 626cdf0e10cSrcweir case 150 : nEntry = 4; break; 627cdf0e10cSrcweir default : nEntry = 5; break; 628cdf0e10cSrcweir } 629cdf0e10cSrcweir checkEntry( nEntry, bEnabled ); 630cdf0e10cSrcweir } 631cdf0e10cSrcweir } 632cdf0e10cSrcweir 633cdf0e10cSrcweir // ----------------------------------------------------------------------- 634cdf0e10cSrcweir 635199633b5SHerbert Dürr void FontworkCharacterSpacingWindow::implSetKernCharacterPairs( sal_Bool, bool bEnabled ) 636cdf0e10cSrcweir { 637cdf0e10cSrcweir enableEntry( 6, bEnabled ); 638cdf0e10cSrcweir checkEntry( 6, bEnabled ); 639cdf0e10cSrcweir } 640cdf0e10cSrcweir 641cdf0e10cSrcweir // ----------------------------------------------------------------------- 642cdf0e10cSrcweir 643199633b5SHerbert Dürr void SAL_CALL FontworkCharacterSpacingWindow::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ) 644cdf0e10cSrcweir { 645cdf0e10cSrcweir if( Event.FeatureURL.Main.equals( msFontworkCharacterSpacing ) ) 646cdf0e10cSrcweir { 647cdf0e10cSrcweir if( !Event.IsEnabled ) 648cdf0e10cSrcweir { 649cdf0e10cSrcweir implSetCharacterSpacing( 0, false ); 650cdf0e10cSrcweir } 651cdf0e10cSrcweir else 652cdf0e10cSrcweir { 653cdf0e10cSrcweir sal_Int32 nValue = 0; 654cdf0e10cSrcweir if( Event.State >>= nValue ) 655cdf0e10cSrcweir implSetCharacterSpacing( nValue, true ); 656cdf0e10cSrcweir } 657cdf0e10cSrcweir } 658cdf0e10cSrcweir else if( Event.FeatureURL.Main.equals( msFontworkKernCharacterPairs ) ) 659cdf0e10cSrcweir { 660cdf0e10cSrcweir if( !Event.IsEnabled ) 661cdf0e10cSrcweir { 662cdf0e10cSrcweir implSetKernCharacterPairs( 0, false ); 663cdf0e10cSrcweir } 664cdf0e10cSrcweir else 665cdf0e10cSrcweir { 666cdf0e10cSrcweir sal_Bool bValue = sal_False; 667cdf0e10cSrcweir if( Event.State >>= bValue ) 668cdf0e10cSrcweir implSetKernCharacterPairs( bValue, true ); 669cdf0e10cSrcweir } 670cdf0e10cSrcweir } 671cdf0e10cSrcweir } 672cdf0e10cSrcweir 673cdf0e10cSrcweir // ----------------------------------------------------------------------- 674cdf0e10cSrcweir 675199633b5SHerbert Dürr IMPL_LINK( FontworkCharacterSpacingWindow, SelectHdl, void *, EMPTYARG ) 676cdf0e10cSrcweir { 677cdf0e10cSrcweir if ( IsInPopupMode() ) 678cdf0e10cSrcweir EndPopupMode(); 679cdf0e10cSrcweir 680cdf0e10cSrcweir sal_Int32 nSelection = getSelectedEntryId(); 681cdf0e10cSrcweir sal_Int32 nCharacterSpacing; 682cdf0e10cSrcweir switch( nSelection ) 683cdf0e10cSrcweir { 684cdf0e10cSrcweir case 0 : nCharacterSpacing = 80; break; 685cdf0e10cSrcweir case 1 : nCharacterSpacing = 90; break; 686cdf0e10cSrcweir case 2 : nCharacterSpacing = 100; break; 687cdf0e10cSrcweir case 3 : nCharacterSpacing = 120; break; 688cdf0e10cSrcweir case 4 : nCharacterSpacing = 150; break; 689cdf0e10cSrcweir default : nCharacterSpacing = 100; break; 690cdf0e10cSrcweir } 691cdf0e10cSrcweir if ( nSelection == 5 ) // custom spacing 692cdf0e10cSrcweir { 693cdf0e10cSrcweir Sequence< PropertyValue > aArgs( 1 ); 694cdf0e10cSrcweir aArgs[0].Name = msFontworkCharacterSpacing.copy(5); 695cdf0e10cSrcweir aArgs[0].Value <<= (sal_Int32)nCharacterSpacing; 696cdf0e10cSrcweir 697cdf0e10cSrcweir mrController.dispatchCommand( OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkCharacterSpacingDialog" )), aArgs ); 698cdf0e10cSrcweir } 699cdf0e10cSrcweir else if ( nSelection == 6 ) // KernCharacterPairs 700cdf0e10cSrcweir { 701cdf0e10cSrcweir rtl::OUString aCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkKernCharacterPairs" )); 702cdf0e10cSrcweir 703cdf0e10cSrcweir Sequence< PropertyValue > aArgs( 1 ); 704cdf0e10cSrcweir aArgs[0].Name = msFontworkKernCharacterPairs.copy(5); 705cdf0e10cSrcweir aArgs[0].Value <<= (sal_Bool) sal_True; 706cdf0e10cSrcweir 707cdf0e10cSrcweir mrController.dispatchCommand( msFontworkKernCharacterPairs, aArgs ); 708cdf0e10cSrcweir 709cdf0e10cSrcweir implSetKernCharacterPairs( sal_True, true ); 710cdf0e10cSrcweir } 711cdf0e10cSrcweir else if( nSelection >= 0 ) 712cdf0e10cSrcweir { 713cdf0e10cSrcweir Sequence< PropertyValue > aArgs( 1 ); 714cdf0e10cSrcweir aArgs[0].Name = msFontworkCharacterSpacing.copy(5); 715cdf0e10cSrcweir aArgs[0].Value <<=( sal_Int32)nCharacterSpacing; 716cdf0e10cSrcweir 717cdf0e10cSrcweir mrController.dispatchCommand( msFontworkCharacterSpacing, aArgs ); 718cdf0e10cSrcweir 719cdf0e10cSrcweir implSetCharacterSpacing( nCharacterSpacing, true ); 720cdf0e10cSrcweir } 721cdf0e10cSrcweir 722cdf0e10cSrcweir return 0; 723cdf0e10cSrcweir } 724cdf0e10cSrcweir 725cdf0e10cSrcweir // ======================================================================== 726199633b5SHerbert Dürr // FontworkCharacterSpacingControl 727cdf0e10cSrcweir // ======================================================================== 728cdf0e10cSrcweir 729199633b5SHerbert Dürr class FontworkCharacterSpacingControl : public svt::PopupWindowController 730cdf0e10cSrcweir { 731cdf0e10cSrcweir public: 732199633b5SHerbert Dürr FontworkCharacterSpacingControl( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager ); 733cdf0e10cSrcweir 734cdf0e10cSrcweir virtual ::Window* createPopupWindow( ::Window* pParent ); 735cdf0e10cSrcweir 736cdf0e10cSrcweir // XServiceInfo 737cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); 738cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); 739cdf0e10cSrcweir 740cdf0e10cSrcweir using svt::PopupWindowController::createPopupWindow; 741cdf0e10cSrcweir }; 742cdf0e10cSrcweir 743cdf0e10cSrcweir 744199633b5SHerbert Dürr FontworkCharacterSpacingControl::FontworkCharacterSpacingControl( const Reference< lang::XMultiServiceFactory >& rServiceManager ) 745cdf0e10cSrcweir : svt::PopupWindowController( rServiceManager, Reference< frame::XFrame >(), OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkCharacterSpacingFloater" ) ) ) 746cdf0e10cSrcweir { 747cdf0e10cSrcweir } 748cdf0e10cSrcweir 749cdf0e10cSrcweir // ----------------------------------------------------------------------- 750cdf0e10cSrcweir 751199633b5SHerbert Dürr ::Window* FontworkCharacterSpacingControl::createPopupWindow( ::Window* pParent ) 752cdf0e10cSrcweir { 753199633b5SHerbert Dürr return new FontworkCharacterSpacingWindow( *this, m_xFrame, pParent ); 754cdf0e10cSrcweir } 755cdf0e10cSrcweir 756cdf0e10cSrcweir // ----------------------------------------------------------------------- 757cdf0e10cSrcweir // XServiceInfo 758cdf0e10cSrcweir // ----------------------------------------------------------------------- 759cdf0e10cSrcweir 760199633b5SHerbert Dürr OUString SAL_CALL FontworkCharacterSpacingControl_getImplementationName() 761cdf0e10cSrcweir { 762199633b5SHerbert Dürr return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.FontworkCharacterSpacingController" )); 763cdf0e10cSrcweir } 764cdf0e10cSrcweir 765cdf0e10cSrcweir // -------------------------------------------------------------------- 766cdf0e10cSrcweir 767199633b5SHerbert Dürr Sequence< OUString > SAL_CALL FontworkCharacterSpacingControl_getSupportedServiceNames() throw( RuntimeException ) 768cdf0e10cSrcweir { 769cdf0e10cSrcweir Sequence< OUString > aSNS( 1 ); 770cdf0e10cSrcweir aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" )); 771cdf0e10cSrcweir return aSNS; 772cdf0e10cSrcweir } 773cdf0e10cSrcweir 774cdf0e10cSrcweir // -------------------------------------------------------------------- 775cdf0e10cSrcweir 776199633b5SHerbert Dürr Reference< XInterface > SAL_CALL SAL_CALL FontworkCharacterSpacingControl_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException ) 777cdf0e10cSrcweir { 778199633b5SHerbert Dürr return *new FontworkCharacterSpacingControl( rSMgr ); 779cdf0e10cSrcweir } 780cdf0e10cSrcweir 781cdf0e10cSrcweir // -------------------------------------------------------------------- 782cdf0e10cSrcweir 783199633b5SHerbert Dürr OUString SAL_CALL FontworkCharacterSpacingControl::getImplementationName( ) throw (RuntimeException) 784cdf0e10cSrcweir { 785199633b5SHerbert Dürr return FontworkCharacterSpacingControl_getImplementationName(); 786cdf0e10cSrcweir } 787cdf0e10cSrcweir 788cdf0e10cSrcweir // -------------------------------------------------------------------- 789cdf0e10cSrcweir 790199633b5SHerbert Dürr Sequence< OUString > SAL_CALL FontworkCharacterSpacingControl::getSupportedServiceNames( ) throw (RuntimeException) 791cdf0e10cSrcweir { 792199633b5SHerbert Dürr return FontworkCharacterSpacingControl_getSupportedServiceNames(); 793cdf0e10cSrcweir } 794cdf0e10cSrcweir 795cdf0e10cSrcweir // ======================================================================== 796cdf0e10cSrcweir // FontworkCharacterSpacingDialog 797cdf0e10cSrcweir // ======================================================================== 798cdf0e10cSrcweir 799cdf0e10cSrcweir FontworkCharacterSpacingDialog::FontworkCharacterSpacingDialog( Window* pParent, sal_Int32 nScale ) 800cdf0e10cSrcweir : ModalDialog( pParent, SVX_RES( RID_SVX_MDLG_FONTWORK_CHARSPACING ) ), 801cdf0e10cSrcweir maFLScale( this, SVX_RES( FT_VALUE ) ), 802cdf0e10cSrcweir maMtrScale( this, SVX_RES( MF_VALUE ) ), 803cdf0e10cSrcweir maOKButton( this, SVX_RES( BTN_OK ) ), 804cdf0e10cSrcweir maCancelButton( this, SVX_RES( BTN_CANCEL ) ), 805cdf0e10cSrcweir maHelpButton( this, SVX_RES( BTN_HELP ) ) 806cdf0e10cSrcweir { 807cdf0e10cSrcweir maMtrScale.SetValue( nScale ); 808cdf0e10cSrcweir FreeResource(); 809cdf0e10cSrcweir } 810cdf0e10cSrcweir 811cdf0e10cSrcweir FontworkCharacterSpacingDialog::~FontworkCharacterSpacingDialog() 812cdf0e10cSrcweir { 813cdf0e10cSrcweir } 814cdf0e10cSrcweir 815cdf0e10cSrcweir sal_Int32 FontworkCharacterSpacingDialog::getScale() const 816cdf0e10cSrcweir { 817cdf0e10cSrcweir return (sal_Int32)maMtrScale.GetValue(); 818cdf0e10cSrcweir } 819cdf0e10cSrcweir 820cdf0e10cSrcweir } 821