diff options
author | Jan Holesovsky <kendy@collabora.com> | 2014-11-04 16:53:20 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2014-11-04 20:26:20 +0100 |
commit | caa4c09ce4407dcbcbcf38117db63f68f022bc53 (patch) | |
tree | d519064ade2e4696b355962ce9d811ce280dfcb8 /svx | |
parent | bafd505409e163abcd2261e2cf26737e2202ba24 (diff) |
line spacing: Setup the Custom value according to the current state.
Change-Id: I16d34d501385c57ba32dece1eb8032ff38d5f4a6
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx | 240 | ||||
-rw-r--r-- | svx/source/sidebar/paragraph/ParaLineSpacingControl.hxx | 11 | ||||
-rw-r--r-- | svx/uiconfig/ui/paralinespacingcontrol.ui | 74 |
3 files changed, 116 insertions, 209 deletions
diff --git a/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx b/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx index fb2d5b51dd31..0328dce086f7 100644 --- a/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx +++ b/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx @@ -55,7 +55,6 @@ using namespace svx::sidebar; ParaLineSpacingControl::ParaLineSpacingControl(sal_uInt16 nId) : SfxPopupWindow(nId, "ParaLineSpacingControl", "svx/ui/paralinespacingcontrol.ui") -// , maLineSpacing(ValueSetWithTextControl::IMAGE_TEXT,this, SVX_RES( LINE_SPACING ) ) { mpSpacing1Button = get<PushButton>("spacing_1"); mpSpacing115Button = get<PushButton>("spacing_115"); @@ -68,16 +67,8 @@ ParaLineSpacingControl::ParaLineSpacingControl(sal_uInt16 nId) mpActLineDistFld = mpLineDistAtPercentBox; - initial(); meLNSpaceUnit = SFX_MAPUNIT_100TH_MM; -} - -ParaLineSpacingControl::~ParaLineSpacingControl() -{ -} -void ParaLineSpacingControl::initial() -{ Link aLink = LINK(this, ParaLineSpacingControl, PredefinedValuesHandler); mpSpacing1Button->SetClickHdl(aLink); mpSpacing115Button->SetClickHdl(aLink); @@ -86,23 +77,32 @@ void ParaLineSpacingControl::initial() aLink = LINK( this, ParaLineSpacingControl, LineSPDistHdl_Impl ); mpLineDist->SetSelectHdl(aLink); - mpLineDist->SelectEntryPos( LLINESPACE_1 ) ; + SelectEntryPos(LLINESPACE_1); aLink = LINK( this, ParaLineSpacingControl, LineSPDistAtHdl_Impl ); mpLineDistAtPercentBox->SetModifyHdl( aLink ); mpLineDistAtMetricBox->SetModifyHdl( aLink ); + + initialize(); } -void ParaLineSpacingControl::Rearrange(SfxItemState currSPState,FieldUnit currMetricUnit,SvxLineSpacingItem* currSPItem,const ::sfx2::sidebar::EnumContext currentContext) +ParaLineSpacingControl::~ParaLineSpacingControl() { - SfxItemState eState = currSPState; +} +void ParaLineSpacingControl::initialize() +{ + const SfxPoolItem* pItem; + SfxItemState eState = SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PARA_LINESPACE, pItem); + + const SvxLineSpacingItem* currSPItem = static_cast<const SvxLineSpacingItem*>(pItem); + + /* TODO - according to the current units setting + FieldUnit currMetricUnit = FUNIT_CM; SetFieldUnit(*mpLineDistAtMetricBox, currMetricUnit); + */ mpLineDist->Enable(); - mpActLineDistFld->Enable(); - mpActLineDistFld->SetText( "" ); - //bool bValueSetFocus = sal_False; //wj if( eState >= SfxItemState::DEFAULT ) { @@ -119,106 +119,35 @@ void ParaLineSpacingControl::Rearrange(SfxItemState currSPState,FieldUnit currMe switch( eInter ) { case SVX_INTER_LINE_SPACE_OFF: - { - mpLineDist->SelectEntryPos( LLINESPACE_1 ); - mpActLineDistFld->Disable(); - mpActLineDistFld->SetText( "" ); - if ( LINESPACE_1 == currSPItem->GetPropLineSpace() ) - { -// maLineSpacing.SelectItem(1); - //bValueSetFocus = sal_True; //wj - } - } + SelectEntryPos(LLINESPACE_1); break; case SVX_INTER_LINE_SPACE_PROP: { if ( LINESPACE_1 == currSPItem->GetPropLineSpace() ) { - mpLineDist->SelectEntryPos( LLINESPACE_1 ); - mpActLineDistFld->Disable(); - mpActLineDistFld->SetText( "" ); -// maLineSpacing.SelectItem(1); - //bValueSetFocus = sal_True; //wj - break; + SelectEntryPos(LLINESPACE_1); } - if ( LINESPACE_15 == currSPItem->GetPropLineSpace() ) + else if ( LINESPACE_15 == currSPItem->GetPropLineSpace() ) { - mpLineDist->SelectEntryPos( LLINESPACE_15 ); - mpActLineDistFld->Disable(); - mpActLineDistFld->SetText( "" ); - -// maLineSpacing.SelectItem(3); - //bValueSetFocus = sal_True; //wj - break; + SelectEntryPos(LLINESPACE_15); } - if ( LINESPACE_2 == currSPItem->GetPropLineSpace() ) - { - mpLineDist->SelectEntryPos( LLINESPACE_2 ); - mpActLineDistFld->Disable(); - mpActLineDistFld->SetText( "" ); - -// maLineSpacing.SelectItem(4); - //bValueSetFocus = sal_True; //wj - break; - } - - mpLineDist->SelectEntryPos( LLINESPACE_PROP ); - if(mpActLineDistFld != mpLineDistAtPercentBox) + else if ( LINESPACE_2 == currSPItem->GetPropLineSpace() ) { - mpActLineDistFld->Disable(); - mpActLineDistFld->Hide(); - mpActLineDistFld = mpLineDistAtPercentBox; + SelectEntryPos(LLINESPACE_2); } else { - mpActLineDistFld = mpLineDistAtMetricBox; - mpActLineDistFld->Disable(); - mpActLineDistFld->Hide(); - mpActLineDistFld = mpLineDistAtPercentBox; - } - mpActLineDistFld->Enable(); - mpActLineDistFld->Show(); - mpLineDistAtPercentBox-> - SetValue( mpLineDistAtPercentBox->Normalize( - currSPItem->GetPropLineSpace() ) ); - - if( currSPItem->GetPropLineSpace() == LINESPACE_115 ) - { -// maLineSpacing.SelectItem(2); - //bValueSetFocus = sal_True; //wj - } - else - { -// maLineSpacing.SetNoSelection(); -// maLineSpacing.SelectItem(0); + SelectEntryPos(LLINESPACE_PROP); + mpLineDistAtPercentBox->SetValue(mpLineDistAtPercentBox->Normalize(currSPItem->GetPropLineSpace())); } } break; case SVX_INTER_LINE_SPACE_FIX: { - if(mpActLineDistFld != mpLineDistAtMetricBox) - { - mpActLineDistFld->Disable(); - mpActLineDistFld->Hide(); - mpActLineDistFld = mpLineDistAtMetricBox; - } - else - { - mpActLineDistFld = mpLineDistAtPercentBox; - mpActLineDistFld->Disable(); - mpActLineDistFld->Hide(); - mpActLineDistFld = mpLineDistAtMetricBox; - } - mpActLineDistFld->Enable(); - mpActLineDistFld->Show(); -// maLineSpacing.SetNoSelection(); -// maLineSpacing.SelectItem(0); - + SelectEntryPos(LLINESPACE_DURCH); SetMetricValue(*mpLineDistAtMetricBox, currSPItem->GetInterLineSpace(), eUnit); - mpLineDist->SelectEntryPos( LLINESPACE_DURCH ); - } break; default: @@ -228,51 +157,15 @@ void ParaLineSpacingControl::Rearrange(SfxItemState currSPState,FieldUnit currMe break; case SVX_LINE_SPACE_FIX: { - if(mpActLineDistFld != mpLineDistAtMetricBox) - { - mpActLineDistFld->Disable(); - mpActLineDistFld->Hide(); - mpActLineDistFld = mpLineDistAtMetricBox; - } - else - { - mpActLineDistFld = mpLineDistAtPercentBox; - mpActLineDistFld->Disable(); - mpActLineDistFld->Hide(); - mpActLineDistFld = mpLineDistAtMetricBox; - } - mpActLineDistFld->Enable(); - mpActLineDistFld->Show(); -// maLineSpacing.SetNoSelection(); -// maLineSpacing.SelectItem(0); - + SelectEntryPos(LLINESPACE_FIX); SetMetricValue(*mpLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit); - mpLineDist->SelectEntryPos( LLINESPACE_FIX ); } break; case SVX_LINE_SPACE_MIN: { - if(mpActLineDistFld != mpLineDistAtMetricBox) - { - mpActLineDistFld->Disable(); - mpActLineDistFld->Hide(); - mpActLineDistFld = mpLineDistAtMetricBox; - } - else - { - mpActLineDistFld = mpLineDistAtPercentBox; - mpActLineDistFld->Disable(); - mpActLineDistFld->Hide(); - mpActLineDistFld = mpLineDistAtMetricBox; - } - mpActLineDistFld->Enable(); - mpActLineDistFld->Show(); -// maLineSpacing.SetNoSelection(); -// maLineSpacing.SelectItem(0); - + SelectEntryPos(LLINESPACE_MIN); SetMetricValue(*mpLineDistAtMetricBox, currSPItem->GetLineHeight(), eUnit); - mpLineDist->SelectEntryPos( LLINESPACE_MIN ); } break; default: @@ -282,23 +175,20 @@ void ParaLineSpacingControl::Rearrange(SfxItemState currSPState,FieldUnit currMe else if( eState == SfxItemState::DISABLED ) { mpLineDist->Disable(); - mpActLineDistFld->Enable(false); - mpActLineDistFld->SetText( "" ); -// maLineSpacing.SetNoSelection(); -// maLineSpacing.SelectItem(0); + mpActLineDistFld->Disable(); + mpActLineDistFld->SetText(""); } else { - mpActLineDistFld->Enable(false); - mpActLineDistFld->SetText( "" ); + mpActLineDistFld->Disable(); + mpActLineDistFld->SetText(""); mpLineDist->SetNoSelection(); -// maLineSpacing.SetNoSelection(); -// maLineSpacing.SelectItem(0); } mpLineDist->SaveValue(); + /* TODO const sal_uInt16 uCount = mpLineDist->GetEntryCount(); if( uCount == LLINESPACE_FIX + 1 ) { @@ -329,80 +219,90 @@ void ParaLineSpacingControl::Rearrange(SfxItemState currSPState,FieldUnit currMe } } } -// maLineSpacing.Format(); -// maLineSpacing.StartSelection(); + */ } -IMPL_LINK( ParaLineSpacingControl, LineSPDistHdl_Impl, ListBox*, pBox ) +void ParaLineSpacingControl::UpdateMetricFields() { -// maLineSpacing.SetNoSelection(); -// maLineSpacing.SelectItem(0); -// maLineSpacing.Format(); -// maLineSpacing.StartSelection(); - - switch( pBox->GetSelectEntryPos() ) + switch (mpLineDist->GetSelectEntryPos()) { case LLINESPACE_1: case LLINESPACE_15: case LLINESPACE_2: - mpActLineDistFld->Enable(false); - mpActLineDistFld->SetText( "" ); + if (mpActLineDistFld == mpLineDistAtPercentBox) + mpLineDistAtMetricBox->Hide(); + else + mpLineDistAtPercentBox->Hide(); + + mpActLineDistFld->Show(); + mpActLineDistFld->Disable(); + mpActLineDistFld->SetText(""); break; case LLINESPACE_DURCH: mpLineDistAtPercentBox->Hide(); + mpActLineDistFld = mpLineDistAtMetricBox; mpLineDistAtMetricBox->SetMin(0); + if (mpLineDistAtMetricBox->GetText().isEmpty()) + mpLineDistAtMetricBox->SetValue(mpLineDistAtMetricBox->Normalize(0)); - if ( mpLineDistAtMetricBox->GetText().isEmpty() ) - mpLineDistAtMetricBox->SetValue( - mpLineDistAtMetricBox->Normalize( 0 ) ); - mpLineDistAtPercentBox->Hide(); mpActLineDistFld->Show(); mpActLineDistFld->Enable(); break; case LLINESPACE_MIN: mpLineDistAtPercentBox->Hide(); + mpActLineDistFld = mpLineDistAtMetricBox; mpLineDistAtMetricBox->SetMin(0); - if ( mpLineDistAtMetricBox->GetText().isEmpty() ) - mpLineDistAtMetricBox->SetValue( - mpLineDistAtMetricBox->Normalize( 0 ), FUNIT_TWIP ); - mpLineDistAtPercentBox->Hide(); + if (mpLineDistAtMetricBox->GetText().isEmpty()) + mpLineDistAtMetricBox->SetValue(mpLineDistAtMetricBox->Normalize(0), FUNIT_TWIP); + mpActLineDistFld->Show(); mpActLineDistFld->Enable(); break; case LLINESPACE_PROP: mpLineDistAtMetricBox->Hide(); + mpActLineDistFld = mpLineDistAtPercentBox; - if ( mpLineDistAtPercentBox->GetText().isEmpty() ) - mpLineDistAtPercentBox->SetValue( - mpLineDistAtPercentBox->Normalize( 100 ), FUNIT_TWIP ); - mpLineDistAtMetricBox->Hide(); + if (mpLineDistAtPercentBox->GetText().isEmpty()) + mpLineDistAtPercentBox->SetValue(mpLineDistAtPercentBox->Normalize(100), FUNIT_TWIP); + mpActLineDistFld->Show(); mpActLineDistFld->Enable(); break; case LLINESPACE_FIX: { mpLineDistAtPercentBox->Hide(); + mpActLineDistFld = mpLineDistAtMetricBox; sal_Int64 nTemp = mpLineDistAtMetricBox->GetValue(); mpLineDistAtMetricBox->SetMin(mpLineDistAtMetricBox->Normalize(MIN_FIXED_DISTANCE), FUNIT_TWIP); - if ( mpLineDistAtMetricBox->GetValue() != nTemp ) + if (mpLineDistAtMetricBox->GetValue() != nTemp) SetMetricValue(*mpLineDistAtMetricBox, FIX_DIST_DEF, SFX_MAPUNIT_TWIP); - mpLineDistAtPercentBox->Hide(); mpActLineDistFld->Show(); mpActLineDistFld->Enable(); } break; } +} + +void ParaLineSpacingControl::SelectEntryPos(sal_Int32 nPos) +{ + mpLineDist->SelectEntryPos(nPos); + UpdateMetricFields(); +} + +IMPL_LINK( ParaLineSpacingControl, LineSPDistHdl_Impl, ListBox*, pBox ) +{ + UpdateMetricFields(); ExecuteLineSpace(); return 0; } @@ -416,7 +316,6 @@ IMPL_LINK_NOARG( ParaLineSpacingControl, LineSPDistAtHdl_Impl ) void ParaLineSpacingControl::ExecuteLineSpace() { mpLineDist->SaveValue(); -// maLineSpacing.SetNoSelection(); SvxLineSpacingItem aSpacing(DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE); sal_uInt16 nPos = mpLineDist->GetSelectEntryPos(); @@ -426,7 +325,7 @@ void ParaLineSpacingControl::ExecuteLineSpace() case LLINESPACE_1: case LLINESPACE_15: case LLINESPACE_2: - SetLineSpace( aSpacing, nPos ); + SetLineSpace(aSpacing, nPos); break; case LLINESPACE_PROP: @@ -448,8 +347,7 @@ void ParaLineSpacingControl::ExecuteLineSpace() SID_ATTR_PARA_LINESPACE, SfxCallMode::RECORD, &aSpacing, 0L); } -void ParaLineSpacingControl::SetLineSpace( SvxLineSpacingItem& rLineSpace, - int eSpace, long lValue ) +void ParaLineSpacingControl::SetLineSpace(SvxLineSpacingItem& rLineSpace, int eSpace, long lValue) { switch ( eSpace ) { @@ -515,8 +413,6 @@ IMPL_LINK(ParaLineSpacingControl, PredefinedValuesHandler, void *, pControl) void ParaLineSpacingControl::ExecuteLineSpacing(sal_uInt16 nEntry) { - mpLineDist->SelectEntryPos(nEntry) ; - mpLineDist->SaveValue(); SvxLineSpacingItem aSpacing(DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE); // special-case the 1.15 line spacing diff --git a/svx/source/sidebar/paragraph/ParaLineSpacingControl.hxx b/svx/source/sidebar/paragraph/ParaLineSpacingControl.hxx index 968b09c4bfe4..0995380a2441 100644 --- a/svx/source/sidebar/paragraph/ParaLineSpacingControl.hxx +++ b/svx/source/sidebar/paragraph/ParaLineSpacingControl.hxx @@ -37,8 +37,6 @@ public: ParaLineSpacingControl(sal_uInt16 nId); virtual ~ParaLineSpacingControl(); - void Rearrange(SfxItemState currSPState,FieldUnit currMetricUnit,SvxLineSpacingItem* currSPItem,const ::sfx2::sidebar::EnumContext currentContext); - short GetLastCustomState(); long GetLastCustomValue(); @@ -64,7 +62,14 @@ private: MetricField* mpLineDistAtMetricBox; private: - void initial(); + void initialize(); + + /// Set mpActlineDistFld and visibility of mpLineDist* fields according to what is just selected. + void UpdateMetricFields(); + + /// Set the entry and update the metric fields. + void SelectEntryPos(sal_Int32 nPos); + DECL_LINK(LineSPDistHdl_Impl, ListBox*); DECL_LINK(LineSPDistAtHdl_Impl, void*); DECL_LINK(PredefinedValuesHandler, void*); diff --git a/svx/uiconfig/ui/paralinespacingcontrol.ui b/svx/uiconfig/ui/paralinespacingcontrol.ui index 9f9e5570669d..455a709e242a 100644 --- a/svx/uiconfig/ui/paralinespacingcontrol.ui +++ b/svx/uiconfig/ui/paralinespacingcontrol.ui @@ -1,6 +1,41 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> <!-- interface-requires gtk+ 3.10 --> + <object class="GtkAdjustment" id="adjustment1"> + <property name="lower">50</property> + <property name="upper">200</property> + <property name="value">100</property> + <property name="step_increment">10</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustment2"> + <property name="lower">0.01</property> + <property name="upper">9999</property> + <property name="value">0.5</property> + <property name="step_increment">0.10000000000000001</property> + <property name="page_increment">1</property> + </object> + <object class="GtkImage" id="image_spacing_1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="pixbuf">svx/res/symphony/lpspacing-1.png</property> + </object> + <object class="GtkImage" id="image_spacing_115"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_right">6</property> + <property name="xalign">0</property> + <property name="pixbuf">svx/res/symphony/lpspacing-1_15.png</property> + <property name="icon-size">1</property> + </object> + <object class="GtkImage" id="image_spacing_15"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_right">6</property> + <property name="xalign">0</property> + <property name="pixbuf">svx/res/symphony/lpspacing-1_5.png</property> + <property name="icon-size">1</property> + </object> <object class="GtkImage" id="image_spacing_2"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -125,6 +160,8 @@ <property name="can_focus">False</property> <property name="xalign">0</property> <property name="label" translatable="yes">Line Spacing:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">line_dist</property> </object> <packing> <property name="left_attach">0</property> @@ -163,6 +200,8 @@ <property name="can_focus">False</property> <property name="xalign">0</property> <property name="label" translatable="yes">Value:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">grid1</property> </object> <packing> <property name="left_attach">0</property> @@ -179,7 +218,6 @@ <property name="vexpand">True</property> <child> <object class="GtkSpinButton" id="percent_box:0%"> - <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="invisible_char">●</property> @@ -201,6 +239,7 @@ <property name="invisible_char">●</property> <property name="invisible_char_set">True</property> <property name="adjustment">adjustment2</property> + <property name="digits">2</property> </object> <packing> <property name="left_attach">0</property> @@ -242,37 +281,4 @@ </object> </child> </object> - <object class="GtkAdjustment" id="adjustment1"> - <property name="lower">50</property> - <property name="upper">200</property> - <property name="value">100</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkAdjustment" id="adjustment2"> - <property name="upper">9999</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkImage" id="image_spacing_1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="pixbuf">svx/res/symphony/lpspacing-1.png</property> - </object> - <object class="GtkImage" id="image_spacing_115"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="margin_right">6</property> - <property name="xalign">0</property> - <property name="pixbuf">svx/res/symphony/lpspacing-1_15.png</property> - <property name="icon-size">1</property> - </object> - <object class="GtkImage" id="image_spacing_15"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="margin_right">6</property> - <property name="xalign">0</property> - <property name="pixbuf">svx/res/symphony/lpspacing-1_5.png</property> - <property name="icon-size">1</property> - </object> </interface> |