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

Generated by: LCOV version 1.10