LCOV - code coverage report
Current view: top level - sc/source/ui/sidebar - AlignmentPropertyPanel.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 187 0.5 %
Date: 2014-11-03 Functions: 2 23 8.7 %
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 "AlignmentPropertyPanel.hxx"
      21             : #include <editeng/justifyitem.hxx>
      22             : #include "sc.hrc"
      23             : #include "scresid.hxx"
      24             : #include <sfx2/bindings.hxx>
      25             : #include <sfx2/dispatch.hxx>
      26             : #include <svx/algitem.hxx>
      27             : #include <svx/dlgutil.hxx>
      28             : #include <vcl/toolbox.hxx>
      29             : #include <svx/sidebar/SidebarDialControl.hxx>
      30             : 
      31             : using namespace css;
      32             : using namespace css::uno;
      33             : 
      34             : // namespace open
      35             : 
      36             : namespace sc { namespace sidebar {
      37             : 
      38           0 : AlignmentPropertyPanel::AlignmentPropertyPanel(
      39             :     vcl::Window* pParent,
      40             :     const css::uno::Reference<css::frame::XFrame>& rxFrame,
      41             :     SfxBindings* pBindings)
      42             :     : PanelLayout(pParent, "AlignmentPropertyPanel", "modules/scalc/ui/sidebaralignment.ui", rxFrame),
      43             :       maAlignHorControl(SID_H_ALIGNCELL, *pBindings, *this),
      44             :       maLeftIndentControl(SID_ATTR_ALIGN_INDENT, *pBindings, *this),
      45             :       maMergeCellControl(FID_MERGE_TOGGLE, *pBindings, *this),
      46             :       maWrapTextControl(SID_ATTR_ALIGN_LINEBREAK, *pBindings, *this),
      47             :       maAngleControl(SID_ATTR_ALIGN_DEGREES, *pBindings, *this),
      48             :       maStackControl(SID_ATTR_ALIGN_STACKED, *pBindings, *this),
      49             :       mbMultiDisable(false),
      50             :       mxFrame(rxFrame),
      51             :       maContext(),
      52           0 :       mpBindings(pBindings)
      53             : {
      54           0 :     get(mpFTLeftIndent, "leftindentlabel");
      55           0 :     get(mpMFLeftIndent, "leftindent");
      56           0 :     get(mpCBXWrapText, "wraptext");
      57           0 :     get(mpCBXMergeCell, "mergecells");
      58           0 :     get(mpFtRotate, "orientationlabel");
      59           0 :     get(mpCtrlDial, "orientationcontrol");
      60           0 :     get(mpMtrAngle, "orientationdegrees");
      61           0 :     get(mpCbStacked, "verticallystacked");
      62             : 
      63           0 :     Initialize();
      64             : 
      65           0 :     mpFTLeftIndent->SetBackground(Wallpaper());
      66           0 :     mpFtRotate->SetBackground(Wallpaper());
      67           0 : }
      68             : 
      69           0 : AlignmentPropertyPanel::~AlignmentPropertyPanel()
      70             : {
      71           0 : }
      72             : 
      73           0 : void AlignmentPropertyPanel::Initialize()
      74             : {
      75           0 :     mpFTLeftIndent->Disable();
      76           0 :     mpMFLeftIndent->Disable();
      77           0 :     mpMFLeftIndent->SetAccessibleName(OUString( "Left Indent"));    //wj acc
      78           0 :     Link aLink = LINK(this, AlignmentPropertyPanel, MFLeftIndentMdyHdl);
      79           0 :     mpMFLeftIndent->SetModifyHdl ( aLink );
      80             : 
      81           0 :     aLink = LINK(this, AlignmentPropertyPanel, CBOXMergnCellClkHdl);
      82           0 :     mpCBXMergeCell->SetClickHdl ( aLink );
      83             : 
      84           0 :     aLink = LINK(this, AlignmentPropertyPanel, CBOXWrapTextClkHdl);
      85           0 :     mpCBXWrapText->SetClickHdl ( aLink );
      86             : 
      87             :     //rotation control
      88           0 :     mpCtrlDial->SetAccessibleName(OUString( "Text Orientation"));   //wj acc
      89           0 :     mpCtrlDial->SetModifyHdl(LINK( this, AlignmentPropertyPanel, RotationHdl));
      90             : 
      91             :     //rotation
      92           0 :     mpMtrAngle->SetAccessibleName(OUString( "Text Orientation"));   //wj acc
      93           0 :     mpMtrAngle->SetModifyHdl(LINK( this, AlignmentPropertyPanel, AngleModifiedHdl));
      94           0 :     mpMtrAngle->EnableAutocomplete( false );
      95             : 
      96             :     //Vertical stacked
      97           0 :     mpCbStacked->SetClickHdl( LINK( this, AlignmentPropertyPanel, ClickStackHdl ) );
      98             : 
      99           0 :     mpMtrAngle->InsertValue(0, FUNIT_CUSTOM);
     100           0 :     mpMtrAngle->InsertValue(45, FUNIT_CUSTOM);
     101           0 :     mpMtrAngle->InsertValue(90, FUNIT_CUSTOM);
     102           0 :     mpMtrAngle->InsertValue(135, FUNIT_CUSTOM);
     103           0 :     mpMtrAngle->InsertValue(180, FUNIT_CUSTOM);
     104           0 :     mpMtrAngle->InsertValue(225, FUNIT_CUSTOM);
     105           0 :     mpMtrAngle->InsertValue(270, FUNIT_CUSTOM);
     106           0 :     mpMtrAngle->InsertValue(315, FUNIT_CUSTOM);
     107           0 :     mpMtrAngle->SetDropDownLineCount(mpMtrAngle->GetEntryCount());
     108             : 
     109           0 :     mpMFLeftIndent->SetAccessibleRelationLabeledBy(mpFTLeftIndent);
     110           0 :     mpMtrAngle->SetAccessibleRelationLabeledBy(mpFtRotate);
     111           0 : }
     112             : 
     113           0 : IMPL_LINK( AlignmentPropertyPanel, AngleModifiedHdl, void *, EMPTYARG )
     114             : {
     115           0 :     OUString sTmp = mpMtrAngle->GetText();
     116             : 
     117           0 :     sal_Unicode nChar = sTmp.isEmpty() ? 0 : sTmp[0];
     118           0 :     if((sTmp.getLength()== 1 &&  nChar == '-') ||
     119           0 :         (nChar != '-' && ((nChar < '0') || (nChar > '9') ) ))   ////modify
     120           0 :         return 0;
     121             : 
     122           0 :     double dTmp = sTmp.toDouble();
     123           0 :     FormatDegrees(dTmp);
     124             : 
     125           0 :     sal_Int64 nTmp = (sal_Int64)dTmp*100;
     126           0 :     SfxInt32Item aAngleItem( SID_ATTR_ALIGN_DEGREES,(sal_uInt32) nTmp);
     127             : 
     128             :     GetBindings()->GetDispatcher()->Execute(
     129           0 :         SID_ATTR_ALIGN_DEGREES, SfxCallMode::RECORD, &aAngleItem, 0L );
     130           0 :     return 0;
     131             : }
     132             : 
     133           0 : IMPL_LINK( AlignmentPropertyPanel, RotationHdl, void *, EMPTYARG )
     134             : {
     135           0 :     sal_Int32 nTmp = mpCtrlDial->GetRotation();
     136           0 :     SfxInt32Item aAngleItem( SID_ATTR_ALIGN_DEGREES,(sal_uInt32) nTmp);
     137             : 
     138             :     GetBindings()->GetDispatcher()->Execute(
     139           0 :         SID_ATTR_ALIGN_DEGREES, SfxCallMode::RECORD, &aAngleItem, 0L );
     140             : 
     141           0 :     return 0;
     142             : }
     143             : 
     144           0 : IMPL_LINK( AlignmentPropertyPanel, ClickStackHdl, void *, EMPTYARG )
     145             : {
     146           0 :     bool bVertical = mpCbStacked->IsChecked();
     147           0 :     SfxBoolItem  aStackItem( SID_ATTR_ALIGN_STACKED, bVertical );
     148             :     GetBindings()->GetDispatcher()->Execute(
     149           0 :         SID_ATTR_ALIGN_STACKED, SfxCallMode::RECORD, &aStackItem, 0L );
     150           0 :     return 0;
     151             : }
     152             : 
     153           0 : IMPL_LINK(AlignmentPropertyPanel, MFLeftIndentMdyHdl, void*, EMPTYARG)
     154             : {
     155           0 :     mpCBXWrapText->EnableTriState(false);
     156           0 :     sal_uInt16 nVal = (sal_uInt16)mpMFLeftIndent->GetValue();
     157           0 :     SfxUInt16Item aItem( SID_ATTR_ALIGN_INDENT,  (sal_uInt16)CalcToUnit( nVal,  SFX_MAPUNIT_TWIP ) );
     158             : 
     159           0 :     GetBindings()->GetDispatcher()->Execute(SID_ATTR_ALIGN_INDENT, SfxCallMode::RECORD, &aItem, 0L);
     160           0 :     return( 0L );
     161             : }
     162             : 
     163           0 : IMPL_LINK(AlignmentPropertyPanel, CBOXMergnCellClkHdl, void*, EMPTYARG)
     164             : {
     165           0 :     bool bState = mpCBXMergeCell->IsChecked();
     166             : 
     167             :     //Modified
     168             :     //SfxBoolItem aItem( FID_MERGE_TOGGLE , bState);
     169             :     //GetBindings()->GetDispatcher()->Execute(FID_MERGE_TOGGLE, SfxCallMode::RECORD, &aItem, false, 0L);
     170           0 :     if(bState)
     171           0 :         GetBindings()->GetDispatcher()->Execute(FID_MERGE_ON, SfxCallMode::RECORD);
     172             :     else
     173           0 :         GetBindings()->GetDispatcher()->Execute(FID_MERGE_OFF, SfxCallMode::RECORD);
     174           0 :     GetBindings()->Invalidate(FID_MERGE_TOGGLE,true,false);
     175             :     //modified end
     176             : 
     177           0 :     return 0;
     178             : }
     179             : 
     180           0 : IMPL_LINK(AlignmentPropertyPanel, CBOXWrapTextClkHdl, void*, EMPTYARG)
     181             : {
     182           0 :     bool bState = mpCBXWrapText->IsChecked();
     183           0 :     SfxBoolItem aItem( SID_ATTR_ALIGN_LINEBREAK , bState);
     184           0 :     GetBindings()->GetDispatcher()->Execute(SID_ATTR_ALIGN_LINEBREAK, SfxCallMode::RECORD, &aItem, 0L);
     185           0 :     return 0;
     186             : }
     187             : 
     188           0 : AlignmentPropertyPanel* AlignmentPropertyPanel::Create (
     189             :     vcl::Window* pParent,
     190             :     const css::uno::Reference<css::frame::XFrame>& rxFrame,
     191             :     SfxBindings* pBindings)
     192             : {
     193           0 :     if (pParent == NULL)
     194           0 :         throw lang::IllegalArgumentException("no parent Window given to AlignmentPropertyPanel::Create", NULL, 0);
     195           0 :     if ( ! rxFrame.is())
     196           0 :         throw lang::IllegalArgumentException("no XFrame given to AlignmentPropertyPanel::Create", NULL, 1);
     197           0 :     if (pBindings == NULL)
     198           0 :         throw lang::IllegalArgumentException("no SfxBindings given to AlignmentPropertyPanel::Create", NULL, 2);
     199             : 
     200             :     return new AlignmentPropertyPanel(
     201             :         pParent,
     202             :         rxFrame,
     203           0 :         pBindings);
     204             : }
     205             : 
     206           0 : void AlignmentPropertyPanel::DataChanged(
     207             :     const DataChangedEvent& rEvent)
     208             : {
     209             :     (void)rEvent;
     210           0 : }
     211             : 
     212           0 : void AlignmentPropertyPanel::HandleContextChange(
     213             :     const ::sfx2::sidebar::EnumContext aContext)
     214             : {
     215           0 :     if(maContext == aContext)
     216             :     {
     217             :         // Nothing to do.
     218           0 :         return;
     219             :     }
     220             : 
     221           0 :     maContext = aContext;
     222             : 
     223             :     // todo
     224             : }
     225             : 
     226           0 : void AlignmentPropertyPanel::NotifyItemUpdate(
     227             :     sal_uInt16 nSID,
     228             :     SfxItemState eState,
     229             :     const SfxPoolItem* pState,
     230             :     const bool bIsEnabled)
     231             : {
     232             :     (void)bIsEnabled;
     233             : 
     234           0 :     switch(nSID)
     235             :     {
     236             :     case SID_H_ALIGNCELL:
     237             :         {
     238           0 :             SvxCellHorJustify meHorAlignState = SVX_HOR_JUSTIFY_STANDARD;
     239           0 :             if(eState >= SfxItemState::DEFAULT && pState && pState->ISA(SvxHorJustifyItem) )
     240             :             {
     241           0 :                 const SvxHorJustifyItem* pItem = static_cast<const SvxHorJustifyItem*>(pState);
     242           0 :                 meHorAlignState = (SvxCellHorJustify)pItem->GetValue();
     243             :             }
     244             : 
     245           0 :             if( meHorAlignState == SVX_HOR_JUSTIFY_REPEAT )
     246             :             {
     247           0 :                 mpFtRotate->Disable();
     248           0 :                 mpCtrlDial->Disable();
     249           0 :                 mpMtrAngle->Disable();
     250             :             }
     251             :             else
     252             :             {
     253           0 :                 mpFtRotate->Enable(!mbMultiDisable);
     254           0 :                 mpCtrlDial->Enable(!mbMultiDisable);
     255           0 :                 mpMtrAngle->Enable(!mbMultiDisable);
     256             :             }
     257             : 
     258           0 :             mpCbStacked->Enable( meHorAlignState != SVX_HOR_JUSTIFY_REPEAT );
     259           0 :             mpFTLeftIndent->Enable( meHorAlignState == SVX_HOR_JUSTIFY_LEFT );
     260           0 :             mpMFLeftIndent->Enable( meHorAlignState == SVX_HOR_JUSTIFY_LEFT );
     261             :         }
     262           0 :         break;
     263             :     case SID_ATTR_ALIGN_INDENT:
     264           0 :         if(eState >= SfxItemState::DEFAULT && pState && pState->ISA(SfxUInt16Item) )
     265             :         {
     266           0 :                 const SfxUInt16Item* pItem = static_cast<const SfxUInt16Item*>(pState);
     267           0 :                 sal_uInt16 nVal = pItem->GetValue();
     268           0 :                 mpMFLeftIndent->SetValue( CalcToPoint(nVal, SFX_MAPUNIT_TWIP, 1) );
     269             :         }
     270             :         else
     271             :         {
     272           0 :             mpMFLeftIndent->SetValue(0);
     273           0 :             mpMFLeftIndent->SetText(OUString());
     274             :         }
     275           0 :         break;
     276             :     case FID_MERGE_TOGGLE:
     277           0 :         if(eState >= SfxItemState::DEFAULT && pState && pState->ISA(SfxBoolItem) )
     278             :         {
     279           0 :             mpCBXMergeCell->Enable();
     280           0 :             const SfxBoolItem* pItem = static_cast<const SfxBoolItem*>(pState);
     281           0 :             mpCBXMergeCell->Check(pItem->GetValue());
     282             :         }
     283             :         else
     284             :         {
     285           0 :             mpCBXMergeCell->Check(false);
     286           0 :             mpCBXMergeCell->Disable();
     287             :         }
     288           0 :         break;
     289             : 
     290             :     case SID_ATTR_ALIGN_LINEBREAK:
     291           0 :         if(eState == SfxItemState::DISABLED)
     292             :         {
     293           0 :             mpCBXWrapText->EnableTriState(false);
     294           0 :             mpCBXWrapText->Check(false);
     295           0 :             mpCBXWrapText->Disable();
     296             :         }
     297             :         else
     298             :         {
     299           0 :             mpCBXWrapText->Enable();
     300           0 :             if(eState >= SfxItemState::DEFAULT && pState && pState->ISA(SfxBoolItem) )
     301             :             {
     302           0 :                 mpCBXWrapText->EnableTriState(false);
     303           0 :                 const SfxBoolItem* pItem = static_cast<const SfxBoolItem*>(pState);
     304           0 :                 mpCBXWrapText->Check(pItem->GetValue());
     305             :             }
     306           0 :             else if(eState == SfxItemState::DONTCARE)
     307             :             {
     308           0 :                 mpCBXWrapText->EnableTriState(true);
     309           0 :                 mpCBXWrapText->SetState(TRISTATE_INDET);
     310             :             }
     311             :         }
     312           0 :         break;
     313             :     case SID_ATTR_ALIGN_DEGREES:
     314           0 :         if (eState >= SfxItemState::DEFAULT)
     315             :         {
     316           0 :             long nTmp = static_cast<const SfxInt32Item*>(pState)->GetValue();
     317           0 :             mpMtrAngle->SetValue( nTmp / 100);  //wj
     318           0 :             mpCtrlDial->SetRotation( nTmp );
     319           0 :             switch(nTmp)
     320             :             {
     321             :                 case 0:
     322           0 :                     mpMtrAngle->SelectEntryPos(0);
     323           0 :                 break;
     324             :                 case 4500:
     325           0 :                     mpMtrAngle->SelectEntryPos(1);
     326           0 :                 break;
     327             :                 case 9000:
     328           0 :                     mpMtrAngle->SelectEntryPos(2);
     329           0 :                 break;
     330             :                 case 13500:
     331           0 :                     mpMtrAngle->SelectEntryPos(3);
     332           0 :                 break;
     333             :                 case 18000:
     334           0 :                     mpMtrAngle->SelectEntryPos(4);
     335           0 :                 break;
     336             :                 case 22500:
     337           0 :                     mpMtrAngle->SelectEntryPos(5);
     338           0 :                 break;
     339             :                 case 27000:
     340           0 :                     mpMtrAngle->SelectEntryPos(6);
     341           0 :                 break;
     342             :                 case 31500:
     343           0 :                     mpMtrAngle->SelectEntryPos(7);
     344             :             }
     345             :         }
     346             :         else
     347             :         {
     348           0 :             mpMtrAngle->SetText( OUString() );
     349           0 :             mpCtrlDial->SetRotation( 0 );
     350             :         }
     351           0 :         break;
     352             :     case SID_ATTR_ALIGN_STACKED:
     353           0 :         if (eState >= SfxItemState::DEFAULT)
     354             :         {
     355           0 :             mpCbStacked->EnableTriState(false);
     356           0 :             const SfxBoolItem* aStackItem = static_cast<const SfxBoolItem*>(pState);
     357           0 :             mbMultiDisable = aStackItem->GetValue();
     358           0 :             mpCbStacked->Check(mbMultiDisable);
     359           0 :             mpFtRotate->Enable(!mbMultiDisable);
     360           0 :             mpMtrAngle->Enable(!mbMultiDisable);
     361           0 :             mpCtrlDial->Enable(!mbMultiDisable);
     362             :         }
     363             :         else
     364             :         {
     365           0 :             mbMultiDisable = true;
     366           0 :             mpFtRotate->Disable();
     367           0 :             mpMtrAngle->Disable();
     368           0 :             mpCtrlDial->Disable();
     369           0 :             mpCbStacked->EnableTriState(true);
     370           0 :             mpCbStacked->SetState(TRISTATE_INDET);
     371             :         }
     372             :     }
     373           0 : }
     374             : 
     375           0 : void AlignmentPropertyPanel::FormatDegrees(double& dTmp)
     376             : {
     377           0 :     while(dTmp<0)
     378           0 :         dTmp += 360;
     379           0 :     while (dTmp > 359)  //modify
     380           0 :         dTmp = 359;
     381           0 : }
     382             : 
     383             : // namespace close
     384             : 
     385         228 : }} // end of namespace ::sc::sidebar
     386             : 
     387             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10