LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/source/dialog - fontwork.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 379 0.5 %
Date: 2013-07-09 Functions: 4 41 9.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <sfx2/module.hxx>
      21             : #include <sfx2/dispatch.hxx>
      22             : #include <tools/shl.hxx>
      23             : 
      24             : #include <svx/svdobj.hxx>
      25             : #include <svx/svdopath.hxx>
      26             : #include <svx/svdview.hxx>
      27             : #include <svx/svdocirc.hxx>
      28             : #include <svx/xtextit.hxx>
      29             : 
      30             : #include <svx/dialmgr.hxx>
      31             : #include "svx/dlgutil.hxx"
      32             : 
      33             : #include <svx/dialogs.hrc>
      34             : #include "fontwork.hrc"
      35             : #include <svx/fontwork.hxx>
      36             : #include <editeng/outlobj.hxx>
      37             : #include <basegfx/polygon/b2dpolygon.hxx>
      38             : #include <basegfx/point/b2dpoint.hxx>
      39             : 
      40         225 : SFX_IMPL_DOCKINGWINDOW_WITHID( SvxFontWorkChildWindow, SID_FONTWORK );
      41             : 
      42             : // ControllerItem for Fontwork
      43             : 
      44           0 : SvxFontWorkControllerItem::SvxFontWorkControllerItem
      45             : (
      46             :     sal_uInt16 _nId,
      47             :     SvxFontWorkDialog& rDlg,
      48             :     SfxBindings& rBindings
      49             : ) :
      50             : 
      51             :     SfxControllerItem( _nId, rBindings ),
      52             : 
      53           0 :     rFontWorkDlg( rDlg )
      54             : {
      55           0 : }
      56             : 
      57             : // StateChanged method for FontWork items
      58             : 
      59           0 : void SvxFontWorkControllerItem::StateChanged( sal_uInt16 /*nSID*/, SfxItemState /*eState*/,
      60             :                                               const SfxPoolItem* pItem )
      61             : {
      62           0 :     switch ( GetId() )
      63             :     {
      64             :         case SID_FORMTEXT_STYLE:
      65             :         {
      66             :             const XFormTextStyleItem* pStateItem =
      67           0 :                                 PTR_CAST(XFormTextStyleItem, pItem);
      68             :             DBG_ASSERT(pStateItem || pItem == 0, "XFormTextStyleItem expected");
      69           0 :             rFontWorkDlg.SetStyle_Impl(pStateItem);
      70           0 :             break;
      71             :         }
      72             :         case SID_FORMTEXT_ADJUST:
      73             :         {
      74             :             const XFormTextAdjustItem* pStateItem =
      75           0 :                                 PTR_CAST(XFormTextAdjustItem, pItem);
      76             :             DBG_ASSERT(pStateItem || pItem == 0, "XFormTextAdjustItem expected");
      77           0 :             rFontWorkDlg.SetAdjust_Impl(pStateItem);
      78           0 :             break;
      79             :         }
      80             :         case SID_FORMTEXT_DISTANCE:
      81             :         {
      82             :             const XFormTextDistanceItem* pStateItem =
      83           0 :                                 PTR_CAST(XFormTextDistanceItem, pItem);
      84             :             DBG_ASSERT(pStateItem || pItem == 0, "XFormTextDistanceItem erwartet");
      85           0 :             rFontWorkDlg.SetDistance_Impl(pStateItem);
      86           0 :             break;
      87             :         }
      88             :         case SID_FORMTEXT_START:
      89             :         {
      90             :             const XFormTextStartItem* pStateItem =
      91           0 :                                 PTR_CAST(XFormTextStartItem, pItem);
      92             :             DBG_ASSERT(pStateItem || pItem == 0, "XFormTextStartItem expected");
      93           0 :             rFontWorkDlg.SetStart_Impl(pStateItem);
      94           0 :             break;
      95             :         }
      96             :         case SID_FORMTEXT_MIRROR:
      97             :         {
      98             :             const XFormTextMirrorItem* pStateItem =
      99           0 :                                 PTR_CAST(XFormTextMirrorItem, pItem);
     100             :             DBG_ASSERT(pStateItem || pItem == 0, "XFormTextMirrorItem expected");
     101           0 :             rFontWorkDlg.SetMirror_Impl(pStateItem);
     102           0 :             break;
     103             :         }
     104             :         case SID_FORMTEXT_HIDEFORM:
     105             :         {
     106             :             const XFormTextHideFormItem* pStateItem =
     107           0 :                                 PTR_CAST(XFormTextHideFormItem, pItem);
     108             :             DBG_ASSERT(pStateItem || pItem == 0, "XFormTextHideFormItem expected");
     109           0 :             rFontWorkDlg.SetShowForm_Impl(pStateItem);
     110           0 :             break;
     111             :         }
     112             :         case SID_FORMTEXT_OUTLINE:
     113             :         {
     114             :             const XFormTextOutlineItem* pStateItem =
     115           0 :                                 PTR_CAST(XFormTextOutlineItem, pItem);
     116             :             DBG_ASSERT(pStateItem || pItem == 0, "XFormTextOutlineItem expected");
     117           0 :             rFontWorkDlg.SetOutline_Impl(pStateItem);
     118           0 :             break;
     119             :         }
     120             :         case SID_FORMTEXT_SHADOW:
     121             :         {
     122             :             const XFormTextShadowItem* pStateItem =
     123           0 :                                 PTR_CAST(XFormTextShadowItem, pItem);
     124             :             DBG_ASSERT(pStateItem || pItem == 0, "XFormTextShadowItem expected");
     125           0 :             rFontWorkDlg.SetShadow_Impl(pStateItem);
     126           0 :             break;
     127             :         }
     128             :         case SID_FORMTEXT_SHDWCOLOR:
     129             :         {
     130             :             const XFormTextShadowColorItem* pStateItem =
     131           0 :                                 PTR_CAST(XFormTextShadowColorItem, pItem);
     132             :             DBG_ASSERT(pStateItem || pItem == 0, "XFormTextShadowColorItem expected");
     133           0 :             rFontWorkDlg.SetShadowColor_Impl(pStateItem);
     134           0 :             break;
     135             :         }
     136             :         case SID_FORMTEXT_SHDWXVAL:
     137             :         {
     138             :             const XFormTextShadowXValItem* pStateItem =
     139           0 :                                 PTR_CAST(XFormTextShadowXValItem, pItem);
     140             :             DBG_ASSERT(pStateItem || pItem == 0, "XFormTextShadowXValItem expected");
     141           0 :             rFontWorkDlg.SetShadowXVal_Impl(pStateItem);
     142           0 :             break;
     143             :         }
     144             :         case SID_FORMTEXT_SHDWYVAL:
     145             :         {
     146             :             const XFormTextShadowYValItem* pStateItem =
     147           0 :                                 PTR_CAST(XFormTextShadowYValItem, pItem);
     148             :             DBG_ASSERT(pStateItem || pItem == 0, "XFormTextShadowYValItem expected");
     149           0 :             rFontWorkDlg.SetShadowYVal_Impl(pStateItem);
     150           0 :             break;
     151             :         }
     152             :     }
     153           0 : }
     154             : 
     155             : // Derivation from SfxChildWindow as "containers" for Fontwork dialog
     156             : 
     157           0 : SvxFontWorkChildWindow::SvxFontWorkChildWindow
     158             : (
     159             :     Window* _pParent,
     160             :     sal_uInt16 nId,
     161             :     SfxBindings* pBindings,
     162             :     SfxChildWinInfo* pInfo
     163             : ) :
     164             : 
     165           0 :     SfxChildWindow( _pParent, nId )
     166             : 
     167             : {
     168             :     pWindow = new SvxFontWorkDialog( pBindings, this, _pParent,
     169           0 :                                      SVX_RES( RID_SVXDLG_FONTWORK ) );
     170           0 :     SvxFontWorkDialog* pDlg = (SvxFontWorkDialog*) pWindow;
     171             : 
     172           0 :     eChildAlignment = SFX_ALIGN_NOALIGNMENT;
     173             : 
     174           0 :     pDlg->Initialize( pInfo );
     175           0 : }
     176             : 
     177             : // Floating Window to the attribution of text effects
     178             : 
     179           0 : SvxFontWorkDialog::SvxFontWorkDialog( SfxBindings *pBindinx,
     180             :                                       SfxChildWindow *pCW,
     181             :                                       Window* _pParent,
     182             :                                       const ResId& rResId ) :
     183             :     SfxDockingWindow( pBindinx, pCW, _pParent, rResId ),
     184             : 
     185           0 :     aTbxStyle       (this, ResId(TBX_STYLE,*rResId.GetResMgr())),
     186           0 :     aTbxAdjust      (this, ResId(TBX_ADJUST,*rResId.GetResMgr())),
     187             : 
     188           0 :     aFbDistance     (this, ResId(FB_DISTANCE,*rResId.GetResMgr())),
     189           0 :     aMtrFldDistance (this, ResId(MTR_FLD_DISTANCE,*rResId.GetResMgr())),
     190           0 :     aFbTextStart    (this, ResId(FB_TEXTSTART,*rResId.GetResMgr())),
     191           0 :     aMtrFldTextStart(this, ResId(MTR_FLD_TEXTSTART,*rResId.GetResMgr())),
     192             : 
     193           0 :     aTbxShadow      (this, ResId(TBX_SHADOW,*rResId.GetResMgr())),
     194             : 
     195           0 :     aFbShadowX      (this, ResId(FB_SHADOW_X,*rResId.GetResMgr())),
     196           0 :     aMtrFldShadowX  (this, ResId(MTR_FLD_SHADOW_X,*rResId.GetResMgr())),
     197           0 :     aFbShadowY      (this, ResId(FB_SHADOW_Y,*rResId.GetResMgr())),
     198           0 :     aMtrFldShadowY  (this, ResId(MTR_FLD_SHADOW_Y,*rResId.GetResMgr())),
     199             : 
     200           0 :     aShadowColorLB  (this, ResId(CLB_SHADOW_COLOR,*rResId.GetResMgr())),
     201             :     rBindings       (*pBindinx),
     202             : 
     203             :     nLastStyleTbxId(0),
     204             :     nLastAdjustTbxId(0),
     205             :     nLastShadowTbxId(0),
     206             :     nSaveShadowX    (0),
     207             :     nSaveShadowY    (0),
     208             :     nSaveShadowAngle(450),
     209             :     nSaveShadowSize (100),
     210             : 
     211           0 :     maImageList     (ResId(IL_FONTWORK,*rResId.GetResMgr()))
     212             : {
     213           0 :     FreeResource();
     214             : 
     215           0 :     ApplyImageList();
     216             : 
     217           0 :     pCtrlItems[0] = new SvxFontWorkControllerItem(SID_FORMTEXT_STYLE, *this, rBindings);
     218           0 :     pCtrlItems[1] = new SvxFontWorkControllerItem(SID_FORMTEXT_ADJUST, *this, rBindings);
     219           0 :     pCtrlItems[2] = new SvxFontWorkControllerItem(SID_FORMTEXT_DISTANCE, *this, rBindings);
     220           0 :     pCtrlItems[3] = new SvxFontWorkControllerItem(SID_FORMTEXT_START, *this, rBindings);
     221           0 :     pCtrlItems[4] = new SvxFontWorkControllerItem(SID_FORMTEXT_MIRROR, *this, rBindings);
     222           0 :     pCtrlItems[5] = new SvxFontWorkControllerItem(SID_FORMTEXT_HIDEFORM, *this, rBindings);
     223           0 :     pCtrlItems[6] = new SvxFontWorkControllerItem(SID_FORMTEXT_OUTLINE, *this, rBindings);
     224           0 :     pCtrlItems[7] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHADOW, *this, rBindings);
     225           0 :     pCtrlItems[8] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHDWCOLOR, *this, rBindings);
     226           0 :     pCtrlItems[9] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHDWXVAL, *this, rBindings);
     227           0 :     pCtrlItems[10] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHDWYVAL, *this, rBindings);
     228             : 
     229           0 :     Size aSize = aTbxStyle.CalcWindowSizePixel();
     230           0 :     aTbxStyle.SetSizePixel(aSize);
     231           0 :     aTbxStyle.SetSelectHdl( LINK(this, SvxFontWorkDialog, SelectStyleHdl_Impl) );
     232             : 
     233           0 :     aTbxAdjust.SetSizePixel(aSize);
     234           0 :     aTbxAdjust.SetSelectHdl( LINK(this, SvxFontWorkDialog, SelectAdjustHdl_Impl) );
     235             : 
     236           0 :     aTbxShadow.SetSizePixel(aSize);
     237           0 :     aTbxShadow.SetSelectHdl( LINK(this, SvxFontWorkDialog, SelectShadowHdl_Impl) );
     238             : 
     239           0 :     Link aLink = LINK(this, SvxFontWorkDialog, ModifyInputHdl_Impl);
     240           0 :     aMtrFldDistance.SetModifyHdl( aLink );
     241           0 :     aMtrFldTextStart.SetModifyHdl( aLink );
     242           0 :     aMtrFldShadowX.SetModifyHdl( aLink );
     243           0 :     aMtrFldShadowY.SetModifyHdl( aLink );
     244             : 
     245             :     // Set System metric
     246           0 :     const FieldUnit eDlgUnit = rBindings.GetDispatcher()->GetModule()->GetFieldUnit();
     247           0 :     SetFieldUnit( aMtrFldDistance, eDlgUnit, sal_True );
     248           0 :     SetFieldUnit( aMtrFldTextStart, eDlgUnit, sal_True );
     249           0 :     SetFieldUnit( aMtrFldShadowX, eDlgUnit, sal_True );
     250           0 :     SetFieldUnit( aMtrFldShadowY, eDlgUnit, sal_True );
     251           0 :     if( eDlgUnit == FUNIT_MM )
     252             :     {
     253           0 :         aMtrFldDistance.SetSpinSize( 50 );
     254           0 :         aMtrFldTextStart.SetSpinSize( 50 );
     255           0 :         aMtrFldShadowX.SetSpinSize( 50 );
     256           0 :         aMtrFldShadowY.SetSpinSize( 50 );
     257             :     }
     258             :     else
     259             :     {
     260           0 :         aMtrFldDistance.SetSpinSize( 10 );
     261           0 :         aMtrFldTextStart.SetSpinSize( 10 );
     262           0 :         aMtrFldShadowX.SetSpinSize( 10 );
     263           0 :         aMtrFldShadowY.SetSpinSize( 10 );
     264             :     }
     265             : 
     266           0 :     aShadowColorLB.SetSelectHdl( LINK(this, SvxFontWorkDialog, ColorSelectHdl_Impl) );
     267             : 
     268           0 :     aInputTimer.SetTimeout(500);
     269           0 :     aInputTimer.SetTimeoutHdl(LINK(this, SvxFontWorkDialog, InputTimoutHdl_Impl));
     270           0 : }
     271             : 
     272           0 : SvxFontWorkDialog::~SvxFontWorkDialog()
     273             : {
     274           0 :     for (sal_uInt16 i = 0; i < CONTROLLER_COUNT; i++)
     275           0 :         DELETEZ(pCtrlItems[i]);
     276           0 : }
     277             : 
     278           0 : void SvxFontWorkDialog::Zoom()
     279             : {
     280           0 :     SfxDockingWindow::Roll();
     281           0 : }
     282             : 
     283           0 : SfxChildAlignment SvxFontWorkDialog::CheckAlignment( SfxChildAlignment eActAlign,
     284             :                                                      SfxChildAlignment eAlign )
     285             : {
     286             :     SfxChildAlignment eAlignment;
     287             : 
     288           0 :     switch ( eAlign )
     289             :     {
     290             :         case SFX_ALIGN_TOP:
     291             :         case SFX_ALIGN_HIGHESTTOP:
     292             :         case SFX_ALIGN_LOWESTTOP:
     293             :         case SFX_ALIGN_BOTTOM:
     294             :         case SFX_ALIGN_LOWESTBOTTOM:
     295             :         case SFX_ALIGN_HIGHESTBOTTOM:
     296             :         {
     297           0 :             eAlignment = eActAlign;
     298             :         }
     299           0 :         break;
     300             : 
     301             :         case SFX_ALIGN_LEFT:
     302             :         case SFX_ALIGN_RIGHT:
     303             :         case SFX_ALIGN_FIRSTLEFT:
     304             :         case SFX_ALIGN_LASTLEFT:
     305             :         case SFX_ALIGN_FIRSTRIGHT:
     306             :         case SFX_ALIGN_LASTRIGHT:
     307             :         {
     308           0 :             eAlignment = eAlign;
     309             :         }
     310           0 :         break;
     311             : 
     312             :         default:
     313             :         {
     314           0 :             eAlignment = eAlign;
     315             :         }
     316           0 :         break;
     317             :     }
     318             : 
     319           0 :     return eAlignment;
     320             : }
     321             : 
     322             : // Set style buttons
     323             : 
     324           0 : void SvxFontWorkDialog::SetStyle_Impl(const XFormTextStyleItem* pItem)
     325             : {
     326           0 :     if ( pItem )
     327             :     {
     328           0 :         sal_uInt16 nId = TBI_STYLE_OFF;
     329             : 
     330           0 :         switch ( pItem->GetValue() )
     331             :         {
     332           0 :             case XFT_ROTATE : nId = TBI_STYLE_ROTATE;   break;
     333           0 :             case XFT_UPRIGHT: nId = TBI_STYLE_UPRIGHT;  break;
     334           0 :             case XFT_SLANTX : nId = TBI_STYLE_SLANTX;   break;
     335           0 :             case XFT_SLANTY : nId = TBI_STYLE_SLANTY;   break;
     336             :             default: ;//prevent warning
     337             :         }
     338           0 :         aTbxStyle.Enable();
     339             : 
     340             :         // Make sure that there is always exactly one checked toolbox item.
     341           0 :         if ( pItem->GetValue() == XFT_NONE )
     342             :         {
     343           0 :             aTbxStyle.CheckItem(TBI_STYLE_ROTATE, sal_False);
     344           0 :             aTbxStyle.CheckItem(TBI_STYLE_UPRIGHT, sal_False);
     345           0 :             aTbxStyle.CheckItem(TBI_STYLE_SLANTX, sal_False);
     346           0 :             aTbxStyle.CheckItem(TBI_STYLE_SLANTY, sal_False);
     347             : 
     348           0 :             aTbxStyle.CheckItem(TBI_STYLE_OFF, sal_True);
     349             :         }
     350             :         else
     351             :         {
     352           0 :             aTbxStyle.CheckItem(TBI_STYLE_OFF, sal_False);
     353           0 :             aTbxStyle.CheckItem(nId);
     354             :         }
     355             : 
     356           0 :         nLastStyleTbxId = nId;
     357             :     }
     358             :     else
     359           0 :         aTbxStyle.Disable();
     360           0 : }
     361             : 
     362             : // Set adjust buttons
     363             : 
     364           0 : void SvxFontWorkDialog::SetAdjust_Impl(const XFormTextAdjustItem* pItem)
     365             : {
     366           0 :     if ( pItem )
     367             :     {
     368             :         sal_uInt16 nId;
     369             : 
     370           0 :         aTbxAdjust.Enable();
     371           0 :         aMtrFldDistance.Enable();
     372             : 
     373           0 :         if ( pItem->GetValue() == XFT_LEFT || pItem->GetValue() == XFT_RIGHT )
     374             :         {
     375           0 :             if ( pItem->GetValue() == XFT_LEFT )    nId = TBI_ADJUST_LEFT;
     376           0 :             else                                    nId = TBI_ADJUST_RIGHT;
     377           0 :             aMtrFldTextStart.Enable();
     378             :         }
     379             :         else
     380             :         {
     381           0 :             if ( pItem->GetValue() == XFT_CENTER )  nId = TBI_ADJUST_CENTER;
     382           0 :             else                                    nId = TBI_ADJUST_AUTOSIZE;
     383           0 :             aMtrFldTextStart.Disable();
     384             :         }
     385             : 
     386           0 :         if ( !aTbxAdjust.IsItemChecked(nId) )
     387             :         {
     388           0 :             aTbxAdjust.CheckItem(nId);
     389             :         }
     390           0 :         nLastAdjustTbxId = nId;
     391             :     }
     392             :     else
     393             :     {
     394           0 :         aTbxAdjust.Disable();
     395           0 :         aMtrFldTextStart.Disable();
     396           0 :         aMtrFldDistance.Disable();
     397             :     }
     398           0 : }
     399             : 
     400             : // Enter Distance value in the edit field
     401             : 
     402           0 : void SvxFontWorkDialog::SetDistance_Impl(const XFormTextDistanceItem* pItem)
     403             : {
     404             :     // Use HasChildPathFocus() instead of HasFocus() at SpinFields
     405           0 :     if ( pItem && !aMtrFldDistance.HasChildPathFocus() )
     406             :     {
     407           0 :         SetMetricValue( aMtrFldDistance, pItem->GetValue(), SFX_MAPUNIT_100TH_MM );
     408             :     }
     409           0 : }
     410             : 
     411             : // Enter indent value in the edit field
     412             : 
     413           0 : void SvxFontWorkDialog::SetStart_Impl(const XFormTextStartItem* pItem)
     414             : {
     415             :     // Use HasChildPathFocus() instead of HasFocus() at SpinFields
     416           0 :     if ( pItem && !aMtrFldTextStart.HasChildPathFocus() )
     417             :     {
     418           0 :         SetMetricValue( aMtrFldTextStart, pItem->GetValue(), SFX_MAPUNIT_100TH_MM );
     419             :     }
     420           0 : }
     421             : 
     422             : // Set button for reversing the direction of text
     423             : 
     424           0 : void SvxFontWorkDialog::SetMirror_Impl(const XFormTextMirrorItem* pItem)
     425             : {
     426           0 :     if ( pItem )
     427           0 :         aTbxAdjust.CheckItem(TBI_ADJUST_MIRROR, pItem->GetValue());
     428           0 : }
     429             : 
     430             : // Set button for contour display
     431             : 
     432           0 : void SvxFontWorkDialog::SetShowForm_Impl(const XFormTextHideFormItem* pItem)
     433             : {
     434           0 :     if ( pItem )
     435           0 :         aTbxShadow.CheckItem(TBI_SHOWFORM, !pItem->GetValue());
     436           0 : }
     437             : 
     438             : // Set button for text border
     439             : 
     440           0 : void SvxFontWorkDialog::SetOutline_Impl(const XFormTextOutlineItem* pItem)
     441             : {
     442           0 :     if ( pItem )
     443           0 :         aTbxShadow.CheckItem(TBI_OUTLINE, pItem->GetValue());
     444           0 : }
     445             : 
     446             : // Set shadow buttons
     447             : 
     448           0 : void SvxFontWorkDialog::SetShadow_Impl(const XFormTextShadowItem* pItem,
     449             :                                         bool bRestoreValues)
     450             : {
     451           0 :     if ( pItem )
     452             :     {
     453             :         sal_uInt16 nId;
     454             : 
     455           0 :         aTbxShadow.Enable();
     456             : 
     457           0 :         if ( pItem->GetValue() == XFTSHADOW_NONE )
     458             :         {
     459           0 :             nId = TBI_SHADOW_OFF;
     460           0 :             aFbShadowX.Hide();
     461           0 :             aFbShadowY.Hide();
     462           0 :             aMtrFldShadowX.Disable();
     463           0 :             aMtrFldShadowY.Disable();
     464           0 :             aShadowColorLB.Disable();
     465             :         }
     466             :         else
     467             :         {
     468           0 :             aFbShadowX.Show();
     469           0 :             aFbShadowY.Show();
     470           0 :             aMtrFldShadowX.Enable();
     471           0 :             aMtrFldShadowY.Enable();
     472           0 :             aShadowColorLB.Enable();
     473             : 
     474           0 :             if ( pItem->GetValue() == XFTSHADOW_NORMAL )
     475             :             {
     476           0 :                 nId = TBI_SHADOW_NORMAL;
     477           0 :                 const FieldUnit eDlgUnit = rBindings.GetDispatcher()->GetModule()->GetFieldUnit();
     478             : 
     479           0 :                 aMtrFldShadowX.SetUnit( eDlgUnit );
     480           0 :                 aMtrFldShadowX.SetDecimalDigits(2);
     481           0 :                 aMtrFldShadowX.SetMin(LONG_MIN);
     482           0 :                 aMtrFldShadowX.SetMax(LONG_MAX);
     483           0 :                 if( eDlgUnit == FUNIT_MM )
     484           0 :                     aMtrFldShadowX.SetSpinSize( 50 );
     485             :                 else
     486           0 :                     aMtrFldShadowX.SetSpinSize( 10 );
     487             : 
     488           0 :                 aMtrFldShadowY.SetUnit( eDlgUnit );
     489           0 :                 aMtrFldShadowY.SetDecimalDigits(2);
     490           0 :                 aMtrFldShadowY.SetMin(LONG_MIN);
     491           0 :                 aMtrFldShadowY.SetMax(LONG_MAX);
     492           0 :                 if( eDlgUnit == FUNIT_MM )
     493           0 :                     aMtrFldShadowY.SetSpinSize( 50 );
     494             :                 else
     495           0 :                     aMtrFldShadowY.SetSpinSize( 10 );
     496             : 
     497           0 :                 if ( bRestoreValues )
     498             :                 {
     499           0 :                     SetMetricValue( aMtrFldShadowX, nSaveShadowX, SFX_MAPUNIT_100TH_MM );
     500           0 :                     SetMetricValue( aMtrFldShadowY, nSaveShadowY, SFX_MAPUNIT_100TH_MM );
     501             : 
     502           0 :                     XFormTextShadowXValItem aXItem( nSaveShadowX );
     503           0 :                     XFormTextShadowYValItem aYItem( nSaveShadowY );
     504             : 
     505           0 :                     GetBindings().GetDispatcher()->Execute(
     506           0 :                         SID_FORMTEXT_SHDWXVAL, SFX_CALLMODE_RECORD, &aXItem, &aYItem, 0L );
     507             :                 }
     508             :             }
     509             :             else
     510             :             {
     511           0 :                 nId = TBI_SHADOW_SLANT;
     512             : 
     513           0 :                 aMtrFldShadowX.SetUnit(FUNIT_CUSTOM);
     514           0 :                 aMtrFldShadowX.SetDecimalDigits(1);
     515           0 :                 aMtrFldShadowX.SetMin(-1800);
     516           0 :                 aMtrFldShadowX.SetMax( 1800);
     517           0 :                 aMtrFldShadowX.SetSpinSize(10);
     518             : 
     519           0 :                 aMtrFldShadowY.SetUnit(FUNIT_CUSTOM);
     520           0 :                 aMtrFldShadowY.SetDecimalDigits(0);
     521           0 :                 aMtrFldShadowY.SetMin(-999);
     522           0 :                 aMtrFldShadowY.SetMax( 999);
     523           0 :                 aMtrFldShadowY.SetSpinSize(10);
     524             : 
     525           0 :                 if ( bRestoreValues )
     526             :                 {
     527           0 :                     aMtrFldShadowX.SetValue(nSaveShadowAngle);
     528           0 :                     aMtrFldShadowY.SetValue(nSaveShadowSize);
     529           0 :                     XFormTextShadowXValItem aXItem(nSaveShadowAngle);
     530           0 :                     XFormTextShadowYValItem aYItem(nSaveShadowSize);
     531           0 :                     GetBindings().GetDispatcher()->Execute(
     532           0 :                         SID_FORMTEXT_SHDWXVAL, SFX_CALLMODE_RECORD, &aXItem, &aYItem, 0L );
     533             :                 }
     534             :             }
     535             :         }
     536             : 
     537           0 :         if ( !aTbxShadow.IsItemChecked(nId) )
     538             :         {
     539           0 :             aTbxShadow.CheckItem(nId);
     540             :         }
     541           0 :         nLastShadowTbxId = nId;
     542             : 
     543           0 :         ApplyImageList();
     544             :     }
     545             :     else
     546             :     {
     547           0 :         aTbxShadow.Disable();
     548           0 :         aMtrFldShadowX.Disable();
     549           0 :         aMtrFldShadowY.Disable();
     550           0 :         aShadowColorLB.Disable();
     551             :     }
     552           0 : }
     553             : 
     554             : // Insert shadow color in listbox
     555             : 
     556           0 : void SvxFontWorkDialog::SetShadowColor_Impl(const XFormTextShadowColorItem* pItem)
     557             : {
     558           0 :     if ( pItem )
     559           0 :         aShadowColorLB.SelectEntry(pItem->GetColorValue());
     560           0 : }
     561             : 
     562             : // Enter X-value for shadow in edit field
     563             : 
     564           0 : void SvxFontWorkDialog::SetShadowXVal_Impl(const XFormTextShadowXValItem* pItem)
     565             : {
     566             :     // Use HasChildPathFocus() instead of HasFocus() at SpinFields
     567           0 :     if ( pItem && !aMtrFldShadowX.HasChildPathFocus() )
     568             :     {
     569             :         // #i19251#
     570             :         // sal_Int32 nValue = pItem->GetValue();
     571             : 
     572             :         // #i19251#
     573             :         // The two involved fields/items are used double and contain/give different
     574             :         // values regarding to the access method. Thus, here we need to separate the access
     575             :         // methos regarding to the kind of value accessed.
     576           0 :         if(aTbxShadow.IsItemChecked(TBI_SHADOW_SLANT))
     577             :         {
     578             :             // #i19251#
     579             :             // There is no value correction necessary at all, i think this
     580             :             // was only tried to be done without understanding that the two
     581             :             // involved fields/items are used double and contain/give different
     582             :             // values regarding to the access method.
     583             :             // nValue = nValue - ( int( float( nValue ) / 360.0 ) * 360 );
     584           0 :             aMtrFldShadowX.SetValue(pItem->GetValue());
     585             :         }
     586             :         else
     587             :         {
     588           0 :             SetMetricValue( aMtrFldShadowX, pItem->GetValue(), SFX_MAPUNIT_100TH_MM );
     589             :         }
     590             :     }
     591           0 : }
     592             : 
     593             : // Enter Y-value for shadow in edit field
     594             : 
     595           0 : void SvxFontWorkDialog::SetShadowYVal_Impl(const XFormTextShadowYValItem* pItem)
     596             : {
     597             :     // Use HasChildPathFocus() instead of HasFocus() at SpinFields
     598           0 :     if ( pItem && !aMtrFldShadowY.HasChildPathFocus() )
     599             :     {
     600             :         // #i19251#
     601             :         // The two involved fields/items are used double and contain/give different
     602             :         // values regarding to the access method. Thus, here we need to separate the access
     603             :         // methos regarding to the kind of value accessed.
     604           0 :         if(aTbxShadow.IsItemChecked(TBI_SHADOW_SLANT))
     605             :         {
     606           0 :             aMtrFldShadowY.SetValue(pItem->GetValue());
     607             :         }
     608             :         else
     609             :         {
     610           0 :             SetMetricValue( aMtrFldShadowY, pItem->GetValue(), SFX_MAPUNIT_100TH_MM );
     611             :         }
     612             :     }
     613           0 : }
     614             : 
     615           0 : IMPL_LINK_NOARG(SvxFontWorkDialog, SelectStyleHdl_Impl)
     616             : {
     617           0 :     sal_uInt16 nId = aTbxStyle.GetCurItemId();
     618             : 
     619             :     // Execute this block when a different toolbox item has been clicked or
     620             :     // when the off item has been clicked.  The later is necessary to
     621             :     // override the toolbox behaviour of unchecking the item after second
     622             :     // click on it: One of the items has to be checked at all times (when
     623             :     // enabled that is.)
     624           0 :     if (nId == TBI_STYLE_OFF || nId != nLastStyleTbxId )
     625             :     {
     626           0 :         XFormTextStyle eStyle = XFT_NONE;
     627             : 
     628           0 :         switch ( nId )
     629             :         {
     630           0 :             case TBI_STYLE_ROTATE   : eStyle = XFT_ROTATE;  break;
     631           0 :             case TBI_STYLE_UPRIGHT  : eStyle = XFT_UPRIGHT; break;
     632           0 :             case TBI_STYLE_SLANTX   : eStyle = XFT_SLANTX;  break;
     633           0 :             case TBI_STYLE_SLANTY   : eStyle = XFT_SLANTY;  break;
     634             :         }
     635           0 :         XFormTextStyleItem aItem( eStyle );
     636           0 :         GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_STYLE, SFX_CALLMODE_RECORD, &aItem, 0L );
     637           0 :         SetStyle_Impl( &aItem );
     638           0 :         nLastStyleTbxId = nId;
     639             :     }
     640           0 :     return 0;
     641             : }
     642             : 
     643           0 : IMPL_LINK_NOARG(SvxFontWorkDialog, SelectAdjustHdl_Impl)
     644             : {
     645           0 :     sal_uInt16 nId = aTbxAdjust.GetCurItemId();
     646             : 
     647           0 :     if ( nId == TBI_ADJUST_MIRROR )
     648             :     {
     649           0 :         XFormTextMirrorItem aItem(aTbxAdjust.IsItemChecked(nId));
     650           0 :         GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_MIRROR, SFX_CALLMODE_SLOT, &aItem, 0L );
     651             :     }
     652           0 :     else if ( nId != nLastAdjustTbxId )
     653             :     {
     654           0 :         XFormTextAdjust eAdjust = XFT_AUTOSIZE;
     655             : 
     656           0 :         switch ( nId )
     657             :         {
     658           0 :             case TBI_ADJUST_LEFT    : eAdjust = XFT_LEFT;   break;
     659           0 :             case TBI_ADJUST_CENTER  : eAdjust = XFT_CENTER; break;
     660           0 :             case TBI_ADJUST_RIGHT   : eAdjust = XFT_RIGHT;  break;
     661             :         }
     662           0 :         XFormTextAdjustItem aItem(eAdjust);
     663           0 :         GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_ADJUST, SFX_CALLMODE_RECORD, &aItem, 0L );
     664           0 :         SetAdjust_Impl(&aItem);
     665           0 :         nLastAdjustTbxId = nId;
     666             :     }
     667           0 :     return 0;
     668             : }
     669             : 
     670           0 : IMPL_LINK_NOARG(SvxFontWorkDialog, SelectShadowHdl_Impl)
     671             : {
     672           0 :     sal_uInt16 nId = aTbxShadow.GetCurItemId();
     673             : 
     674           0 :     if ( nId == TBI_SHOWFORM )
     675             :     {
     676           0 :         XFormTextHideFormItem aItem(!aTbxShadow.IsItemChecked(nId));
     677           0 :         GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_HIDEFORM, SFX_CALLMODE_RECORD, &aItem, 0L );
     678             :     }
     679           0 :     else if ( nId == TBI_OUTLINE )
     680             :     {
     681           0 :         XFormTextOutlineItem aItem(aTbxShadow.IsItemChecked(nId));
     682           0 :         GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_OUTLINE, SFX_CALLMODE_RECORD, &aItem, 0L );
     683             :     }
     684           0 :     else if ( nId != nLastShadowTbxId )
     685             :     {
     686           0 :         XFormTextShadow eShadow = XFTSHADOW_NONE;
     687             : 
     688           0 :         if ( nLastShadowTbxId == TBI_SHADOW_NORMAL )
     689             :         {
     690           0 :             nSaveShadowX = GetCoreValue( aMtrFldShadowX, SFX_MAPUNIT_100TH_MM );
     691           0 :             nSaveShadowY = GetCoreValue( aMtrFldShadowY, SFX_MAPUNIT_100TH_MM );
     692             :         }
     693           0 :         else if ( nLastShadowTbxId == TBI_SHADOW_SLANT )
     694             :         {
     695           0 :             nSaveShadowAngle = static_cast<long>(aMtrFldShadowX.GetValue());
     696           0 :             nSaveShadowSize  = static_cast<long>(aMtrFldShadowY.GetValue());
     697             :         }
     698           0 :         nLastShadowTbxId = nId;
     699             : 
     700           0 :         if ( nId == TBI_SHADOW_NORMAL )     eShadow = XFTSHADOW_NORMAL;
     701           0 :         else if ( nId == TBI_SHADOW_SLANT ) eShadow = XFTSHADOW_SLANT;
     702             : 
     703           0 :         XFormTextShadowItem aItem(eShadow);
     704           0 :         GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_SHADOW, SFX_CALLMODE_RECORD, &aItem, 0L );
     705           0 :         SetShadow_Impl(&aItem, true);
     706             :     }
     707           0 :     return 0;
     708             : }
     709             : 
     710           0 : IMPL_LINK_NOARG_INLINE_START(SvxFontWorkDialog, ModifyInputHdl_Impl)
     711             : {
     712           0 :     aInputTimer.Start();
     713           0 :     return 0;
     714             : }
     715           0 : IMPL_LINK_NOARG_INLINE_END(SvxFontWorkDialog, ModifyInputHdl_Impl)
     716             : 
     717           0 : IMPL_LINK_NOARG(SvxFontWorkDialog, InputTimoutHdl_Impl)
     718             : {
     719             :     // Possibly set the Metric system again. This should be done with a
     720             :     // listen, this is however not possible at the moment due to compabillity
     721             :     // issues.
     722           0 :     const FieldUnit eDlgUnit = rBindings.GetDispatcher()->GetModule()->GetFieldUnit();
     723           0 :     if( eDlgUnit != aMtrFldDistance.GetUnit() )
     724             :     {
     725           0 :         SetFieldUnit( aMtrFldDistance, eDlgUnit, sal_True );
     726           0 :         SetFieldUnit( aMtrFldTextStart, eDlgUnit, sal_True );
     727           0 :         aMtrFldDistance.SetSpinSize( eDlgUnit == FUNIT_MM ? 50 : 10 );
     728           0 :         aMtrFldTextStart.SetSpinSize( eDlgUnit == FUNIT_MM ? 50 : 10 );
     729             :     }
     730           0 :     if( eDlgUnit != aMtrFldShadowX.GetUnit() &&
     731           0 :         aTbxShadow.IsItemChecked( TBI_SHADOW_NORMAL ) )
     732             :     {
     733           0 :         SetFieldUnit( aMtrFldShadowX, eDlgUnit, sal_True );
     734           0 :         SetFieldUnit( aMtrFldShadowY, eDlgUnit, sal_True );
     735           0 :         aMtrFldShadowX.SetSpinSize( eDlgUnit == FUNIT_MM ? 50 : 10 );
     736           0 :         aMtrFldShadowY.SetSpinSize( eDlgUnit == FUNIT_MM ? 50 : 10 );
     737             :     }
     738             : 
     739           0 :     long nValue = GetCoreValue( aMtrFldDistance, SFX_MAPUNIT_100TH_MM );
     740           0 :     XFormTextDistanceItem aDistItem( nValue );
     741           0 :     nValue = GetCoreValue( aMtrFldTextStart, SFX_MAPUNIT_100TH_MM );
     742           0 :     XFormTextStartItem aStartItem( nValue );
     743             : 
     744           0 :     sal_Int32 nValueX(0L);
     745           0 :     sal_Int32 nValueY(0L);
     746             : 
     747             :     // #i19251#
     748             :     // The two involved fields/items are used double and contain/give different
     749             :     // values regarding to the access method. Thus, here we need to separate the access
     750             :     // methos regarding to the kind of value accessed.
     751           0 :     if(nLastShadowTbxId == TBI_SHADOW_NORMAL)
     752             :     {
     753           0 :         nValueX = GetCoreValue( aMtrFldShadowX, SFX_MAPUNIT_100TH_MM );
     754           0 :         nValueY = GetCoreValue( aMtrFldShadowY, SFX_MAPUNIT_100TH_MM );
     755             :     }
     756           0 :     else if(nLastShadowTbxId == TBI_SHADOW_SLANT)
     757             :     {
     758           0 :         nValueX = static_cast<long>(aMtrFldShadowX.GetValue());
     759           0 :         nValueY = static_cast<long>(aMtrFldShadowY.GetValue());
     760             :     }
     761             : 
     762           0 :     XFormTextShadowXValItem aShadowXItem( nValueX );
     763           0 :     XFormTextShadowYValItem aShadowYItem( nValueY );
     764             : 
     765             :     // Slot-ID does not matter, the Exec method evaluates the entire item set
     766           0 :     GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_DISTANCE, SFX_CALLMODE_RECORD, &aDistItem,
     767           0 :                                             &aStartItem, &aShadowXItem, &aShadowYItem, 0L );
     768           0 :     return 0;
     769             : }
     770             : 
     771           0 : IMPL_LINK_NOARG(SvxFontWorkDialog, ColorSelectHdl_Impl)
     772             : {
     773             :     XFormTextShadowColorItem aItem( (const String &) String(),
     774           0 :                                     (const Color &) aShadowColorLB.GetSelectEntryColor() );
     775           0 :     GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_SHDWCOLOR, SFX_CALLMODE_RECORD, &aItem, 0L );
     776           0 :     return 0;
     777             : }
     778             : 
     779           0 : void SvxFontWorkDialog::SetColorList(const XColorListRef &pList)
     780             : {
     781           0 :     if ( pList.is() && pList != pColorList )
     782             :     {
     783           0 :         pColorList = pList;
     784           0 :         aShadowColorLB.Clear();
     785           0 :         aShadowColorLB.Fill(pColorList);
     786             :     }
     787           0 : }
     788             : 
     789           0 : void SvxFontWorkDialog::SetActive(bool /*bActivate*/)
     790             : {
     791           0 : }
     792             : 
     793           0 : void SvxFontWorkDialog::DataChanged( const DataChangedEvent& rDCEvt )
     794             : {
     795           0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     796           0 :             ApplyImageList();
     797             : 
     798           0 :     SfxDockingWindow::DataChanged( rDCEvt );
     799           0 : }
     800             : 
     801           0 : void SvxFontWorkDialog::ApplyImageList()
     802             : {
     803           0 :     ImageList& rImgLst = maImageList;
     804             : 
     805           0 :     aTbxStyle.SetImageList( rImgLst );
     806           0 :     aTbxAdjust.SetImageList( rImgLst );
     807           0 :     aTbxShadow.SetImageList( rImgLst );
     808             : 
     809           0 :     switch( nLastShadowTbxId )
     810             :     {
     811             :     case TBI_SHADOW_SLANT:
     812           0 :         aFbShadowX.SetImage( rImgLst.GetImage( TBI_SHADOW_ANGLE ) );
     813           0 :         aFbShadowY.SetImage( rImgLst.GetImage( TBI_SHADOW_SIZE ) );
     814           0 :         break;
     815             :     default:
     816           0 :         aFbShadowX.SetImage( rImgLst.GetImage( TBI_SHADOW_XDIST ) );
     817           0 :         aFbShadowY.SetImage( rImgLst.GetImage( TBI_SHADOW_YDIST ) );
     818           0 :         break;
     819             :     }
     820             : 
     821           0 :     aFbDistance.SetImage( rImgLst.GetImage( TBI_DISTANCE ) );
     822           0 :     aFbTextStart.SetImage( rImgLst.GetImage( TBI_TEXTSTART ) );
     823             : 
     824         216 : }
     825             : 
     826             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10