LCOV - code coverage report
Current view: top level - svx/source/sidebar/paragraph - ParaPropertyPanel.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 196 313 62.6 %
Date: 2015-06-13 12:38:46 Functions: 15 24 62.5 %
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             : #include "ParaPropertyPanel.hxx"
      20             : #include <svx/dialogs.hrc>
      21             : #include <sfx2/sidebar/ResourceDefinitions.hrc>
      22             : #include <sfx2/sidebar/Tools.hxx>
      23             : #include <sfx2/dispatch.hxx>
      24             : #include <editeng/lrspitem.hxx>
      25             : #include <editeng/ulspitem.hxx>
      26             : #include <vcl/toolbox.hxx>
      27             : #include <vcl/fixed.hxx>
      28             : #include <vcl/svapp.hxx>
      29             : #include <vcl/settings.hxx>
      30             : #include <svx/svxids.hrc>
      31             : #include <svl/intitem.hxx>
      32             : #include "svx/dialmgr.hxx"
      33             : #include <sfx2/objsh.hxx>
      34             : #include <svtools/unitconv.hxx>
      35             : #include <boost/bind.hpp>
      36             : using namespace css;
      37             : using namespace css::uno;
      38             : 
      39             : const char UNO_INCREMENTINDENT[]  = ".uno:IncrementIndent";
      40             : const char UNO_DECREMENTINDENT[]  = ".uno:DecrementIndent";
      41             : const char UNO_HANGINGINDENT[]    = ".uno:HangingIndent";
      42             : 
      43             : namespace svx {namespace sidebar {
      44             : #define DEFAULT_VALUE          0
      45             : 
      46             : #define MAX_DURCH             5670
      47             : 
      48             : #define INDENT_STEP            706
      49             : 
      50             : #define MAX_SW                  1709400
      51             : #define MAX_SC_SD               116220200
      52             : #define NEGA_MAXVALUE          -10000000
      53             : 
      54         341 : VclPtr<vcl::Window> ParaPropertyPanel::Create (
      55             :     vcl::Window* pParent,
      56             :     const css::uno::Reference<css::frame::XFrame>& rxFrame,
      57             :     SfxBindings* pBindings,
      58             :     const css::uno::Reference<css::ui::XSidebar>& rxSidebar)
      59             : {
      60         341 :     if (pParent == NULL)
      61           0 :         throw lang::IllegalArgumentException("no parent Window given to ParaPropertyPanel::Create", NULL, 0);
      62         341 :     if ( ! rxFrame.is())
      63           0 :         throw lang::IllegalArgumentException("no XFrame given to ParaPropertyPanel::Create", NULL, 1);
      64         341 :     if (pBindings == NULL)
      65           0 :         throw lang::IllegalArgumentException("no SfxBindings given to ParaPropertyPanel::Create", NULL, 2);
      66             : 
      67             :     return VclPtr<ParaPropertyPanel>::Create(
      68             :                 pParent,
      69             :                 rxFrame,
      70             :                 pBindings,
      71         341 :                 rxSidebar);
      72             : }
      73             : 
      74         347 : void ParaPropertyPanel::HandleContextChange (
      75             :     const ::sfx2::sidebar::EnumContext& rContext)
      76             : {
      77         347 :     if (maContext == rContext)
      78             :     {
      79             :         // Nothing to do.
      80         347 :         return;
      81             :     }
      82             : 
      83         347 :     maContext = rContext;
      84         347 :     switch (maContext.GetCombinedContext_DI())
      85             :     {
      86             :         case CombinedEnumContext(Application_Calc, Context_DrawText):
      87             :         case CombinedEnumContext(Application_WriterVariants, Context_DrawText):
      88           0 :             mpTBxVertAlign->Show();
      89           0 :             mpTBxBackColor->Hide();
      90           0 :             mpTBxNumBullet->Hide();
      91           0 :             ReSize(false);
      92           0 :             break;
      93             : 
      94             :         case CombinedEnumContext(Application_DrawImpress, Context_Draw):
      95             :         case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
      96             :         case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
      97           1 :             mpTBxVertAlign->Hide();
      98           1 :             mpTBxBackColor->Hide();
      99           1 :             mpTBxNumBullet->Show();
     100           1 :             ReSize(true);
     101           1 :             break;
     102             : 
     103             :         case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
     104             :         case CombinedEnumContext(Application_DrawImpress, Context_Table):
     105           0 :             mpTBxVertAlign->Show();
     106           0 :             mpTBxBackColor->Hide();
     107           0 :             mpTBxNumBullet->Show();
     108           0 :             ReSize(true);
     109           0 :             break;
     110             : 
     111             :         case CombinedEnumContext(Application_WriterVariants, Context_Default):
     112             :         case CombinedEnumContext(Application_WriterVariants, Context_Text):
     113         344 :             mpTBxVertAlign->Hide();
     114         344 :             mpTBxBackColor->Show();
     115         344 :             mpTBxNumBullet->Show();
     116         344 :             ReSize(true);
     117         344 :             break;
     118             : 
     119             :         case CombinedEnumContext(Application_WriterVariants, Context_Table):
     120           1 :             mpTBxVertAlign->Show();
     121           1 :             mpTBxBackColor->Show();
     122           1 :             mpTBxNumBullet->Show();
     123           1 :             ReSize(true);
     124           1 :             break;
     125             : 
     126             :         case CombinedEnumContext(Application_WriterVariants, Context_Annotation):
     127           0 :             mpTBxVertAlign->Hide();
     128           0 :             mpTBxBackColor->Hide();
     129           0 :             mpTBxNumBullet->Hide();
     130           0 :             ReSize(false);
     131           0 :             break;
     132             : 
     133             :         case CombinedEnumContext(Application_Calc, Context_EditCell):
     134             :         case CombinedEnumContext(Application_Calc, Context_Cell):
     135             :         case CombinedEnumContext(Application_Calc, Context_Pivot):
     136             :         case CombinedEnumContext(Application_DrawImpress, Context_Text):
     137             :         case CombinedEnumContext(Application_DrawImpress, Context_OutlineText):
     138             :         /*{
     139             :             mpToolBoxScriptSw->Hide();
     140             :             mpToolBoxScript->Show();
     141             :             mpToolBoxSpacing->Show();
     142             :             mpToolBoxHighlight->Hide();
     143             : 
     144             :             Size aSize(PROPERTYPAGE_WIDTH,TEXT_SECTIONPAGE_HEIGHT);
     145             :             aSize = LogicToPixel( aSize,MapMode(MAP_APPFONT) );
     146             :             aSize.setWidth(GetOutputSizePixel().Width());
     147             :             SetSizePixel(aSize);
     148             :         }*/
     149           0 :             break;
     150             : 
     151             :         default:
     152           1 :             break;
     153             :     }
     154             : 
     155         347 :     mpTBxOutline->Show( maContext.GetApplication_DI() == sfx2::sidebar::EnumContext::Application_DrawImpress );
     156             : }
     157             : 
     158           0 : void ParaPropertyPanel::DataChanged (const DataChangedEvent& rEvent)
     159             : {
     160             :     (void)rEvent;
     161           0 : }
     162             : 
     163         346 : void ParaPropertyPanel::ReSize(bool /* bSize */)
     164             : {
     165         346 :     if (mxSidebar.is())
     166         346 :         mxSidebar->requestLayout();
     167         346 : }
     168             : 
     169         338 : void ParaPropertyPanel::InitToolBoxIndent()
     170             : {
     171         338 :     Link<> aLink = LINK( this, ParaPropertyPanel, ModifyIndentHdl_Impl );
     172         338 :     mpLeftIndent->SetModifyHdl( aLink );
     173         338 :     mpRightIndent->SetModifyHdl( aLink );
     174         338 :     mpFLineIndent->SetModifyHdl( aLink );
     175             : 
     176         338 :     mpLeftIndent->SetAccessibleName(mpLeftIndent->GetQuickHelpText());
     177         338 :     mpRightIndent->SetAccessibleName(mpRightIndent->GetQuickHelpText());
     178         338 :     mpFLineIndent->SetAccessibleName(mpFLineIndent->GetQuickHelpText());
     179             : 
     180         338 :     const sal_uInt16 nIdIncrement = mpTbxIndent_IncDec->GetItemId(UNO_INCREMENTINDENT);
     181         338 :     const sal_uInt16 nIdDecrement = mpTbxIndent_IncDec->GetItemId(UNO_DECREMENTINDENT);
     182         338 :     const sal_uInt16 nIdHanging   = mpTbxIndent_IncDec->GetItemId(UNO_HANGINGINDENT);
     183         338 :     mpTbxIndent_IncDec->SetItemImage(nIdIncrement, maIncIndentControl.GetIcon());
     184         338 :     mpTbxIndent_IncDec->SetItemImage(nIdDecrement, maDecIndentControl.GetIcon());
     185         338 :     mpTbxIndent_IncDec->SetItemImage(nIdHanging, maIndHang);
     186             : 
     187         338 :     mpTbxIndent_IncDec->SetSelectHdl(LINK( this, ParaPropertyPanel, ClickIndent_IncDec_Hdl_Impl ));
     188         338 :     m_eLRSpaceUnit = maLRSpaceControl.GetCoreMetric();
     189         338 :     m_eLRSpaceUnit = maLRSpaceControl.GetCoreMetric();
     190         338 : }
     191             : 
     192         338 : void ParaPropertyPanel::InitToolBoxSpacing()
     193             : {
     194         338 :     Link<> aLink = LINK( this, ParaPropertyPanel, ULSpaceHdl_Impl );
     195         338 :     mpTopDist->SetModifyHdl(aLink);
     196         338 :     mpBottomDist->SetModifyHdl( aLink );
     197             : 
     198         338 :     mpTopDist->SetAccessibleName(mpTopDist->GetQuickHelpText());
     199         338 :     mpBottomDist->SetAccessibleName(mpBottomDist->GetQuickHelpText());
     200         338 :     m_eULSpaceUnit = maULSpaceControl.GetCoreMetric();
     201         338 : }
     202             : 
     203         338 : void ParaPropertyPanel::initial()
     204             : {
     205             :     //toolbox
     206         338 :     InitToolBoxIndent();
     207         338 :     InitToolBoxSpacing();
     208         338 : }
     209             : 
     210             : // for Paragraph Indent
     211           0 : IMPL_LINK_NOARG( ParaPropertyPanel, ModifyIndentHdl_Impl)
     212             : {
     213           0 :     SvxLRSpaceItem aMargin( SID_ATTR_PARA_LRSPACE );
     214           0 :     aMargin.SetTextLeft( (const long)GetCoreValue( *mpLeftIndent, m_eLRSpaceUnit ) );
     215           0 :     aMargin.SetRight( (const long)GetCoreValue( *mpRightIndent, m_eLRSpaceUnit ) );
     216           0 :     aMargin.SetTextFirstLineOfst( (const short)GetCoreValue( *mpFLineIndent, m_eLRSpaceUnit ) );
     217             : 
     218             :     GetBindings()->GetDispatcher()->Execute(
     219           0 :         SID_ATTR_PARA_LRSPACE, SfxCallMode::RECORD, &aMargin, 0L);
     220           0 :     return 0;
     221             : }
     222             : 
     223           0 : IMPL_LINK_TYPED(ParaPropertyPanel, ClickIndent_IncDec_Hdl_Impl, ToolBox *, pControl, void)
     224             : {
     225           0 :     const OUString aCommand(pControl->GetItemCommand(pControl->GetCurItemId()));
     226             : 
     227           0 :         if (aCommand == UNO_INCREMENTINDENT)
     228             :         {
     229           0 :             switch (maContext.GetCombinedContext_DI())
     230             :             {
     231             :             case CombinedEnumContext(Application_WriterVariants, Context_Default):
     232             :             case CombinedEnumContext(Application_WriterVariants, Context_Text):
     233             :             case CombinedEnumContext(Application_WriterVariants, Context_Table):
     234             :                 {
     235           0 :                     SfxBoolItem aMargin( SID_INC_INDENT, true );
     236             :                     GetBindings()->GetDispatcher()->Execute(
     237           0 :                         SID_INC_INDENT, SfxCallMode::RECORD, &aMargin, 0L);
     238             :                 }
     239           0 :                 break;
     240             :             default:
     241             :                 {
     242           0 :                     SvxLRSpaceItem aMargin( SID_ATTR_PARA_LRSPACE );
     243             : 
     244           0 :                     maTxtLeft += INDENT_STEP;
     245           0 :                     sal_Int64 nVal = OutputDevice::LogicToLogic( maTxtLeft, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
     246           0 :                     nVal = OutputDevice::LogicToLogic( (long)nVal, MAP_100TH_MM, (MapUnit)m_eLRSpaceUnit );
     247           0 :                     aMargin.SetTextLeft( (const long)nVal );
     248           0 :                     aMargin.SetRight( (const long)GetCoreValue( *mpRightIndent, m_eLRSpaceUnit ) );
     249           0 :                     aMargin.SetTextFirstLineOfst( (const short)GetCoreValue( *mpFLineIndent, m_eLRSpaceUnit ) );
     250             : 
     251             :                     GetBindings()->GetDispatcher()->Execute(
     252           0 :                         SID_ATTR_PARA_LRSPACE, SfxCallMode::RECORD, &aMargin, 0L);
     253             :                 }
     254             :             }
     255             :         }
     256           0 :         else if (aCommand == UNO_DECREMENTINDENT)
     257             :         {
     258           0 :             switch (maContext.GetCombinedContext_DI())
     259             :             {
     260             :             case CombinedEnumContext(Application_WriterVariants, Context_Default):
     261             :             case CombinedEnumContext(Application_WriterVariants, Context_Text):
     262             :             case CombinedEnumContext(Application_WriterVariants, Context_Table):
     263             :                 {
     264           0 :                     SfxBoolItem aMargin( SID_DEC_INDENT, true );
     265             :                     GetBindings()->GetDispatcher()->Execute(
     266           0 :                         SID_DEC_INDENT, SfxCallMode::RECORD, &aMargin, 0L);
     267             :                 }
     268           0 :                 break;
     269             :             default:
     270             :                 {
     271           0 :                     if((maTxtLeft - INDENT_STEP) < 0)
     272           0 :                         maTxtLeft = DEFAULT_VALUE;
     273             :                     else
     274           0 :                         maTxtLeft -= INDENT_STEP;
     275             : 
     276           0 :                     SvxLRSpaceItem aMargin( SID_ATTR_PARA_LRSPACE );
     277             : 
     278           0 :                     sal_Int64 nVal = OutputDevice::LogicToLogic( maTxtLeft, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
     279           0 :                     nVal = OutputDevice::LogicToLogic( (long)nVal, MAP_100TH_MM, (MapUnit)m_eLRSpaceUnit );
     280             : 
     281           0 :                     aMargin.SetTextLeft( (const long)nVal );
     282           0 :                     aMargin.SetRight( (const long)GetCoreValue( *mpRightIndent, m_eLRSpaceUnit ) );
     283           0 :                     aMargin.SetTextFirstLineOfst( (const short)GetCoreValue( *mpFLineIndent, m_eLRSpaceUnit ) );
     284             : 
     285             :                     GetBindings()->GetDispatcher()->Execute(
     286           0 :                         SID_ATTR_PARA_LRSPACE, SfxCallMode::RECORD, &aMargin, 0L);
     287             :                 }
     288             :             }
     289             :         }
     290           0 :         else if (aCommand == UNO_HANGINGINDENT)
     291             :         {
     292           0 :             SvxLRSpaceItem aMargin( SID_ATTR_PARA_LRSPACE );
     293           0 :             aMargin.SetTextLeft( (const long)GetCoreValue( *mpLeftIndent, m_eLRSpaceUnit ) + (const short)GetCoreValue( *mpFLineIndent, m_eLRSpaceUnit ) );
     294           0 :             aMargin.SetRight( (const long)GetCoreValue( *mpRightIndent, m_eLRSpaceUnit ) );
     295           0 :             aMargin.SetTextFirstLineOfst( ((const short)GetCoreValue( *mpFLineIndent, m_eLRSpaceUnit ))*(-1) );
     296             : 
     297             :             GetBindings()->GetDispatcher()->Execute(
     298           0 :                 SID_ATTR_PARA_LRSPACE, SfxCallMode::RECORD, &aMargin, 0L);
     299           0 :         }
     300           0 : }
     301             : 
     302             : // for Paragraph Spacing
     303           0 : IMPL_LINK_NOARG( ParaPropertyPanel, ULSpaceHdl_Impl)
     304             : {
     305           0 :     SvxULSpaceItem aMargin( SID_ATTR_PARA_ULSPACE );
     306           0 :     aMargin.SetUpper( (sal_uInt16)GetCoreValue( *mpTopDist, m_eULSpaceUnit ) );
     307           0 :     aMargin.SetLower( (sal_uInt16)GetCoreValue( *mpBottomDist, m_eULSpaceUnit ) );
     308             : 
     309             :     GetBindings()->GetDispatcher()->Execute(
     310           0 :         SID_ATTR_PARA_ULSPACE, SfxCallMode::RECORD, &aMargin, 0L);
     311           0 :     return 0L;
     312             : }
     313             : 
     314             : // for Paragraph State change
     315        1646 : void ParaPropertyPanel::NotifyItemUpdate(
     316             :     sal_uInt16 nSID,
     317             :     SfxItemState eState,
     318             :     const SfxPoolItem* pState,
     319             :     const bool bIsEnabled)
     320             : {
     321             :     (void)bIsEnabled;
     322             : 
     323        1646 :     switch (nSID)
     324             :     {
     325             :     case SID_ATTR_METRIC:
     326             :         {
     327         601 :             m_eMetricUnit = GetCurrentUnit(eState,pState);
     328         601 :             if( m_eMetricUnit!=m_last_eMetricUnit )
     329             :             {
     330         338 :                 SetFieldUnit( *mpLeftIndent, m_eMetricUnit );
     331         338 :                 SetFieldUnit( *mpRightIndent, m_eMetricUnit );
     332         338 :                 SetFieldUnit( *mpFLineIndent, m_eMetricUnit );
     333         338 :                 SetFieldUnit( *mpTopDist, m_eMetricUnit );
     334         338 :                 SetFieldUnit( *mpBottomDist, m_eMetricUnit );
     335             :             }
     336         601 :             m_last_eMetricUnit = m_eMetricUnit;
     337             :         }
     338         601 :         break;
     339             : 
     340             :     case SID_ATTR_PARA_LRSPACE:
     341         261 :         StateChangedIndentImpl( nSID, eState, pState );
     342         261 :         break;
     343             : 
     344             :     case SID_ATTR_PARA_ULSPACE:
     345         264 :         StateChangedULImpl( nSID, eState, pState );
     346         264 :         break;
     347             : 
     348             :     case SID_INC_INDENT:
     349             :     case SID_DEC_INDENT:
     350         520 :         StateChangeIncDecImpl( nSID, eState, pState );
     351         520 :         break;
     352             :     }
     353        1646 : }
     354             : 
     355         261 : void ParaPropertyPanel::StateChangedIndentImpl( sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState )
     356             : {
     357         261 :     switch (maContext.GetCombinedContext_DI())
     358             :     {
     359             : 
     360             :     case CombinedEnumContext(Application_WriterVariants, Context_DrawText):
     361             :     case CombinedEnumContext(Application_WriterVariants, Context_Annotation):
     362             :     case CombinedEnumContext(Application_Calc, Context_DrawText):
     363             :     case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
     364             :     case CombinedEnumContext(Application_DrawImpress, Context_Draw):
     365             :     case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
     366             :     case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
     367             :     case CombinedEnumContext(Application_DrawImpress, Context_Table):
     368             :         {
     369           0 :             mpLeftIndent->SetMin( DEFAULT_VALUE );
     370           0 :             mpRightIndent->SetMin( DEFAULT_VALUE );
     371           0 :             mpFLineIndent->SetMin( DEFAULT_VALUE );
     372             :         }
     373           0 :         break;
     374             :     case CombinedEnumContext(Application_WriterVariants, Context_Default):
     375             :     case CombinedEnumContext(Application_WriterVariants, Context_Text):
     376             :     case CombinedEnumContext(Application_WriterVariants, Context_Table):
     377             :         {
     378         261 :             mpLeftIndent->SetMin( NEGA_MAXVALUE, FUNIT_100TH_MM );
     379         261 :             mpRightIndent->SetMin( NEGA_MAXVALUE, FUNIT_100TH_MM );
     380         261 :             mpFLineIndent->SetMin( NEGA_MAXVALUE, FUNIT_100TH_MM );
     381             :         }
     382         261 :         break;
     383             :     }
     384             : 
     385         261 :     const sal_uInt16 nIdHangingIndent   = mpTbxIndent_IncDec->GetItemId(UNO_HANGINGINDENT);
     386         261 :     if( pState && eState >= SfxItemState::DEFAULT )
     387             :     {
     388         261 :         const SvxLRSpaceItem* pSpace = static_cast<const SvxLRSpaceItem*>(pState);
     389         261 :         maTxtLeft = pSpace->GetTextLeft();
     390         261 :         maTxtLeft = OutputDevice::LogicToLogic( maTxtLeft, (MapUnit)m_eLRSpaceUnit, MAP_100TH_MM );
     391         261 :         maTxtLeft = OutputDevice::LogicToLogic( maTxtLeft, MAP_100TH_MM, (MapUnit)(SFX_MAPUNIT_TWIP) );
     392             : 
     393         261 :         long aTxtRight = pSpace->GetRight();
     394         261 :         aTxtRight = OutputDevice::LogicToLogic( aTxtRight, (MapUnit)m_eLRSpaceUnit, MAP_100TH_MM );
     395         261 :         aTxtRight = OutputDevice::LogicToLogic( aTxtRight, MAP_100TH_MM, (MapUnit)(SFX_MAPUNIT_TWIP) );
     396             : 
     397         261 :         long aTxtFirstLineOfst = pSpace->GetTextFirstLineOfst();
     398         261 :         aTxtFirstLineOfst = OutputDevice::LogicToLogic( aTxtFirstLineOfst, (MapUnit)m_eLRSpaceUnit, MAP_100TH_MM );
     399         261 :         aTxtFirstLineOfst = OutputDevice::LogicToLogic( aTxtFirstLineOfst, MAP_100TH_MM, (MapUnit)(SFX_MAPUNIT_TWIP) );
     400             : 
     401         261 :         long nVal = OutputDevice::LogicToLogic( maTxtLeft, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
     402         261 :         nVal = (long)mpLeftIndent->Normalize( (long)nVal );
     403             : 
     404         522 :         if ( maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Text)
     405           5 :              && maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Default)
     406         262 :              && maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Table))
     407             :         {
     408           0 :             mpFLineIndent->SetMin( nVal*(-1), FUNIT_100TH_MM );
     409             :         }
     410             : 
     411         261 :         long nrVal = OutputDevice::LogicToLogic( aTxtRight, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
     412         261 :         nrVal = (long)mpRightIndent->Normalize( (long)nrVal );
     413             : 
     414         261 :         switch (maContext.GetCombinedContext_DI())
     415             :         {
     416             :         case CombinedEnumContext(Application_WriterVariants, Context_DrawText):
     417             :         case CombinedEnumContext(Application_WriterVariants, Context_Text):
     418             :         case CombinedEnumContext(Application_WriterVariants, Context_Default):
     419             :         case CombinedEnumContext(Application_WriterVariants, Context_Table):
     420             :         case CombinedEnumContext(Application_WriterVariants, Context_Annotation):
     421             :             {
     422         261 :                 mpLeftIndent->SetMax( MAX_SW - nrVal, FUNIT_100TH_MM );
     423         261 :                 mpRightIndent->SetMax( MAX_SW - nVal, FUNIT_100TH_MM );
     424         261 :                 mpFLineIndent->SetMax( MAX_SW - nVal - nrVal, FUNIT_100TH_MM );
     425             :             }
     426         261 :             break;
     427             :         case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
     428             :         case CombinedEnumContext(Application_DrawImpress, Context_Draw):
     429             :         case CombinedEnumContext(Application_DrawImpress, Context_Table):
     430             :         case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
     431             :         case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
     432             :             {
     433           0 :                 mpLeftIndent->SetMax( MAX_SC_SD - nrVal, FUNIT_100TH_MM );
     434           0 :                 mpRightIndent->SetMax( MAX_SC_SD - nVal, FUNIT_100TH_MM );
     435           0 :                 mpFLineIndent->SetMax( MAX_SC_SD - nVal - nrVal, FUNIT_100TH_MM );
     436             :             }
     437             :         }
     438             : 
     439         261 :         mpLeftIndent->SetValue( nVal, FUNIT_100TH_MM );
     440         261 :         mpRightIndent->SetValue( nrVal, FUNIT_100TH_MM );
     441             : 
     442         261 :         long nfVal = OutputDevice::LogicToLogic( aTxtFirstLineOfst, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
     443         261 :         nfVal = (long)mpFLineIndent->Normalize( (long)nfVal );
     444         261 :         mpFLineIndent->SetValue( nfVal, FUNIT_100TH_MM );
     445             : 
     446         261 :         mpTbxIndent_IncDec->Enable();
     447             : 
     448         261 :         const sal_uInt16 nIdIncrIndent  = mpTbxIndent_IncDec->GetItemId(UNO_INCREMENTINDENT);
     449         261 :         const sal_uInt16 nIdDecrIndent  = mpTbxIndent_IncDec->GetItemId(UNO_DECREMENTINDENT);
     450             : 
     451         261 :         mpTbxIndent_IncDec->EnableItem(nIdHangingIndent, true);
     452         522 :         if ( maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Text)
     453           5 :              && maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Default)
     454         262 :              && maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Table) )
     455             :         {
     456           0 :             mpTbxIndent_IncDec->EnableItem(nIdIncrIndent, true);
     457           0 :             mpTbxIndent_IncDec->EnableItem(nIdDecrIndent, true);
     458         261 :         }
     459             :     }
     460           0 :     else if( eState == SfxItemState::DISABLED )
     461             :     {
     462           0 :         mpLeftIndent-> Disable();
     463           0 :         mpRightIndent->Disable();
     464           0 :         mpFLineIndent->Disable();
     465           0 :         if( maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Text)  &&
     466           0 :             maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Default) &&
     467           0 :             maContext.GetCombinedContext_DI() !=  CombinedEnumContext(Application_WriterVariants, Context_Table) )
     468           0 :             mpTbxIndent_IncDec->Disable();
     469             :         else
     470           0 :             mpTbxIndent_IncDec->EnableItem(nIdHangingIndent, false);
     471             :     }
     472             :     else
     473             :     {
     474           0 :         mpLeftIndent->SetEmptyFieldValue();
     475           0 :         mpRightIndent->SetEmptyFieldValue();
     476           0 :         mpFLineIndent->SetEmptyFieldValue();
     477           0 :         if( maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Text)  &&
     478           0 :             maContext.GetCombinedContext_DI() != CombinedEnumContext(Application_WriterVariants, Context_Default) &&
     479           0 :             maContext.GetCombinedContext_DI() !=  CombinedEnumContext(Application_WriterVariants, Context_Table) )
     480           0 :             mpTbxIndent_IncDec->Disable();
     481             :         else
     482           0 :             mpTbxIndent_IncDec->EnableItem(nIdHangingIndent, false);
     483             :     }
     484         261 : }
     485             : 
     486         264 : void ParaPropertyPanel::StateChangedULImpl( sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState )
     487             : {
     488         264 :     mpTopDist->SetMax( mpTopDist->Normalize( MAX_DURCH ), MapToFieldUnit(m_eULSpaceUnit) );
     489         264 :     mpBottomDist->SetMax( mpBottomDist->Normalize( MAX_DURCH ), MapToFieldUnit(m_eULSpaceUnit) );
     490             : 
     491         264 :     if( pState && eState >= SfxItemState::DEFAULT )
     492             :     {
     493         264 :         const SvxULSpaceItem* pOldItem = static_cast<const SvxULSpaceItem*>(pState);
     494             : 
     495         264 :         maUpper = pOldItem->GetUpper();
     496         264 :         maUpper = OutputDevice::LogicToLogic( maUpper, (MapUnit)m_eULSpaceUnit, MAP_100TH_MM );
     497         264 :         maUpper = OutputDevice::LogicToLogic( maUpper, MAP_100TH_MM, (MapUnit)(SFX_MAPUNIT_TWIP) );
     498             : 
     499         264 :         maLower = pOldItem->GetLower();
     500         264 :         maLower = OutputDevice::LogicToLogic( maLower, (MapUnit)m_eULSpaceUnit, MAP_100TH_MM );
     501         264 :         maLower = OutputDevice::LogicToLogic( maLower, MAP_100TH_MM, (MapUnit)(SFX_MAPUNIT_TWIP) );
     502             : 
     503         264 :         sal_Int64 nVal = OutputDevice::LogicToLogic( maUpper, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
     504         264 :         nVal = mpTopDist->Normalize( nVal );
     505         264 :         mpTopDist->SetValue( nVal, FUNIT_100TH_MM );
     506             : 
     507         264 :         nVal = OutputDevice::LogicToLogic( maLower, (MapUnit)(SFX_MAPUNIT_TWIP), MAP_100TH_MM );
     508         264 :         nVal = mpBottomDist->Normalize( nVal );
     509         264 :         mpBottomDist->SetValue( nVal, FUNIT_100TH_MM );
     510             :     }
     511           0 :     else if(eState == SfxItemState::DISABLED )
     512             :     {
     513           0 :         mpTopDist->Disable();
     514           0 :         mpBottomDist->Disable();
     515             :     }
     516             :     else
     517             :     {
     518           0 :         mpTopDist->SetEmptyFieldValue();
     519           0 :         mpBottomDist->SetEmptyFieldValue();
     520             :     }
     521         264 : }
     522             : 
     523         520 : void ParaPropertyPanel::StateChangeIncDecImpl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
     524             : {
     525        1040 :     if ( ( maContext.GetCombinedContext_DI() == CombinedEnumContext(Application_WriterVariants, Context_Text)
     526          10 :            || maContext.GetCombinedContext_DI() == CombinedEnumContext(Application_WriterVariants, Context_Default)
     527           2 :            || maContext.GetCombinedContext_DI() ==  CombinedEnumContext(Application_WriterVariants, Context_Table) )
     528        1040 :          && ( nSID == SID_INC_INDENT || nSID == SID_DEC_INDENT ) )
     529             :     {
     530             :         // Writer's text shell is the only one which provides reasonable states for Slots SID_INC_INDENT and SID_DEC_INDENT
     531             :         // - namely SfxItemState::UNKNOWN and SfxItemState::DISABLED
     532         520 :         const sal_uInt16 nIdIncrIndent = mpTbxIndent_IncDec->GetItemId(UNO_INCREMENTINDENT);
     533         520 :         const sal_uInt16 nIdDecrIndent = mpTbxIndent_IncDec->GetItemId(UNO_DECREMENTINDENT);
     534             : 
     535             :         mpTbxIndent_IncDec->EnableItem(
     536             :             nSID == SID_INC_INDENT ? nIdIncrIndent : nIdDecrIndent,
     537         520 :             pState && eState == SfxItemState::UNKNOWN );
     538             :     }
     539         520 : }
     540             : 
     541         601 : FieldUnit ParaPropertyPanel::GetCurrentUnit( SfxItemState eState, const SfxPoolItem* pState )
     542             : {
     543         601 :     FieldUnit eUnit = FUNIT_NONE;
     544             : 
     545         601 :     if ( pState && eState >= SfxItemState::DEFAULT )
     546         601 :         eUnit = (FieldUnit) static_cast<const SfxUInt16Item*>(pState)->GetValue();
     547             :     else
     548             :     {
     549           0 :         SfxViewFrame* pFrame = SfxViewFrame::Current();
     550           0 :         SfxObjectShell* pSh = NULL;
     551           0 :         if ( pFrame )
     552           0 :             pSh = pFrame->GetObjectShell();
     553           0 :         if ( pSh )  //the object shell is not always available during reload
     554             :         {
     555           0 :             SfxModule* pModule = pSh->GetModule();
     556           0 :             if ( pModule )
     557             :             {
     558           0 :                 const SfxPoolItem* pItem = pModule->GetItem( SID_ATTR_METRIC );
     559           0 :                 if ( pItem )
     560           0 :                     eUnit = (FieldUnit) static_cast<const SfxUInt16Item*>(pItem)->GetValue();
     561             :             }
     562             :             else
     563             :             {
     564             :                 SAL_WARN("svx.sidebar", "GetModuleFieldUnit(): no module found");
     565             :             }
     566             :         }
     567             :     }
     568             : 
     569         601 :     return eUnit;
     570             : }
     571             : 
     572         341 : ParaPropertyPanel::ParaPropertyPanel(vcl::Window* pParent,
     573             :     const css::uno::Reference<css::frame::XFrame>& rxFrame,
     574             :     SfxBindings* pBindings,
     575             :     const css::uno::Reference<css::ui::XSidebar>& rxSidebar)
     576             :     : PanelLayout(pParent, "ParaPropertyPanel", "svx/ui/sidebarparagraph.ui", rxFrame),
     577             : 
     578         338 :       maSpace3 (SVX_RES(IMG_SPACE3)),
     579         338 :       maIndHang (SVX_RES(IMG_INDENT_HANG)),
     580             :       maTxtLeft (0),
     581             :       maUpper (0),
     582             :       maLower (0),
     583             :       m_eMetricUnit(FUNIT_NONE),
     584             :       m_last_eMetricUnit(FUNIT_NONE),
     585             :       m_eLRSpaceUnit(),
     586             :       m_eULSpaceUnit(),
     587             :       maLRSpaceControl (SID_ATTR_PARA_LRSPACE,*pBindings,*this),
     588             :       maULSpaceControl (SID_ATTR_PARA_ULSPACE, *pBindings,*this),
     589             :       maDecIndentControl(SID_DEC_INDENT, *pBindings,*this, OUString("DecrementIndent"), rxFrame),
     590             :       maIncIndentControl(SID_INC_INDENT, *pBindings,*this, OUString("IncrementIndent"), rxFrame),
     591             :       m_aMetricCtl (SID_ATTR_METRIC, *pBindings,*this),
     592             :       mxFrame(rxFrame),
     593             :       maContext(),
     594             :       mpBindings(pBindings),
     595        1020 :       mxSidebar(rxSidebar)
     596             : {
     597             :     //Alignment
     598         338 :     get(mpTBxVertAlign, "verticalalignment");
     599             :     //NumBullet&Backcolor
     600         338 :     get(mpTBxNumBullet, "numberbullet");
     601         338 :     get(mpTBxBackColor, "backgroundcolor");
     602         338 :     get(mpTBxOutline, "outline");
     603             :     //Paragraph spacing
     604         338 :     get(mpTopDist,      "aboveparaspacing");
     605         338 :     mpTopDist->set_width_request(mpTopDist->get_preferred_size().Width());
     606         338 :     get(mpBottomDist,   "belowparaspacing");
     607         338 :     mpBottomDist->set_width_request(mpBottomDist->get_preferred_size().Width());
     608         338 :     get(mpLeftIndent,   "beforetextindent");
     609         338 :     mpLeftIndent->set_width_request(mpLeftIndent->get_preferred_size().Width());
     610         338 :     get(mpRightIndent,  "aftertextindent");
     611         338 :     mpRightIndent->set_width_request(mpRightIndent->get_preferred_size().Width());
     612         338 :     get(mpFLineIndent,  "firstlineindent");
     613         338 :     mpFLineIndent->set_width_request(mpFLineIndent->get_preferred_size().Width());
     614         338 :     get(mpTbxIndent_IncDec, "indent");
     615             : 
     616         338 :     initial();
     617         338 :     m_aMetricCtl.RequestUpdate();
     618         338 : }
     619             : 
     620           0 : ParaPropertyPanel::~ParaPropertyPanel()
     621             : {
     622           0 :     disposeOnce();
     623           0 : }
     624             : 
     625         338 : void ParaPropertyPanel::dispose()
     626             : {
     627         338 :     mpTBxVertAlign.clear();
     628         338 :     mpTBxNumBullet.clear();
     629         338 :     mpTBxBackColor.clear();
     630         338 :     mpTBxOutline.clear();
     631         338 :     mpTopDist.clear();
     632         338 :     mpBottomDist.clear();
     633         338 :     mpTbxIndent_IncDec.clear();
     634         338 :     mpLeftIndent.clear();
     635         338 :     mpRightIndent.clear();
     636         338 :     mpFLineIndent.clear();
     637             : 
     638         338 :     maLRSpaceControl.dispose();
     639         338 :     maULSpaceControl.dispose();
     640         338 :     maDecIndentControl.dispose();
     641         338 :     maIncIndentControl.dispose();
     642         338 :     m_aMetricCtl.dispose();
     643             : 
     644         338 :     PanelLayout::dispose();
     645         338 : }
     646             : 
     647         390 : } } // end of namespace svx::sidebar
     648             : 
     649             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11