summaryrefslogtreecommitdiff
path: root/svx/source/sidebar/text/TextCharacterSpacingControl.cxx
diff options
context:
space:
mode:
authorSzymon Kłos <eszkadev@gmail.com>2016-04-16 16:38:43 +0200
committerJan Holesovsky <kendy@collabora.com>2016-04-20 07:53:17 +0000
commitccaf108651ee7e477b09f496f33ea778307fe60b (patch)
tree11c22a3675a8ee06ab248d4879d582e6d1970c84 /svx/source/sidebar/text/TextCharacterSpacingControl.cxx
parentf7aa4344e4fec0e8bb49d6ba210bc3a78b7e1365 (diff)
character spacing control possible to use outside sidebar
Change-Id: Ic0c6458268b529bd0107d6ed5a35f49241cfb833 Reviewed-on: https://gerrit.libreoffice.org/24146 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'svx/source/sidebar/text/TextCharacterSpacingControl.cxx')
-rw-r--r--svx/source/sidebar/text/TextCharacterSpacingControl.cxx502
1 files changed, 179 insertions, 323 deletions
diff --git a/svx/source/sidebar/text/TextCharacterSpacingControl.cxx b/svx/source/sidebar/text/TextCharacterSpacingControl.cxx
index fc615541ec00..fc56ee3188ac 100644
--- a/svx/source/sidebar/text/TextCharacterSpacingControl.cxx
+++ b/svx/source/sidebar/text/TextCharacterSpacingControl.cxx
@@ -16,6 +16,7 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sfx2/bindings.hxx>
#include "TextCharacterSpacingControl.hxx"
#include "TextPropertyPanel.hrc"
#include <sfx2/sidebar/ResourceDefinitions.hrc>
@@ -23,442 +24,297 @@
#include <svx/dialmgr.hxx>
#include <unotools/viewoptions.hxx>
#include <editeng/kernitem.hxx>
+#include <editeng/fhgtitem.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/sidebar/Theme.hxx>
#include <vcl/settings.hxx>
+#include <vcl/lstbox.hxx>
+#include <svl/itempool.hxx>
-namespace svx { namespace sidebar {
-
-TextCharacterSpacingControl::TextCharacterSpacingControl (
- vcl::Window* pParent,
- svx::sidebar::TextPropertyPanel& rPanel,
- SfxBindings* pBindings)
-: PopupControl( pParent,SVX_RES(RID_POPUPPANEL_TEXTPAGE_SPACING))
-, mrTextPropertyPanel(rPanel)
-, mpBindings(pBindings)
-, maVSSpacing (VclPtr<ValueSetWithTextControl>::Create(ValueSetWithTextControl::IMAGE_TEXT,this, SVX_RES(VS_SPACING)))
-, maLastCus (VclPtr<FixedText>::Create(this, SVX_RES(FT_LASTCUSTOM)))
-//, maBorder (this, SVX_RES(CT_BORDER))
-, maFTSpacing (VclPtr<FixedText>::Create(this, SVX_RES(FT_SPACING)))
-, maLBKerning (VclPtr<ListBox>::Create(this, SVX_RES(LB_KERNING)))
-, maFTBy (VclPtr<FixedText>::Create(this, SVX_RES(FT_BY)))
-, maEditKerning (VclPtr<MetricField>::Create(this, SVX_RES(ED_KERNING)))
-
-, mpImg (nullptr)
-, mpImgSel (nullptr)
-, mpStr (nullptr)
-, mpStrTip (nullptr)
-
-, maImgCus (SVX_RES(IMG_CUSTOM))
-, maImgCusGrey (SVX_RES(IMG_CUSTOM_GRAY))
-, maStrCus (SVX_RESSTR(STR_CUSTOM))
-, maStrCusE (SVX_RESSTR(STR_CUSTOM_E_TIP)) //add
-, maStrCusC (SVX_RESSTR(STR_CUSTOM_C_TIP)) //add
-, maStrCusN (SVX_RESSTR(STR_NORMAL_TIP)) //add
-, maStrUnit (SVX_RESSTR(STR_PT)) //add
+#define SPACING_VERY_TIGHT -30
+#define SPACING_TIGHT -15
+#define SPACING_NORMAL 0
+#define SPACING_LOOSE 30
+#define SPACING_VERY_LOOSE 60
+namespace svx {
+
+TextCharacterSpacingControl::TextCharacterSpacingControl(sal_uInt16 nId)
+ : SfxPopupWindow(nId, "TextCharacterSpacingControl", "svx/ui/textcharacterspacingcontrol.ui")
+, mnId(nId)
, mnCustomKern(0)
-, mnLastCus ( SPACING_NOCUSTOM )
-, mbCusEnable(false)
-, mbVS(true)
+, mnLastCus(SPACING_NOCUSTOM)
{
- initial();
- FreeResource();
+ get(maEditKerning, "kerning");
+ get(maLBKerning, "kerninglb");
+ get(maFTBy, "change_by_label");
+ get(maFTSpacing, "spacing_label");
+ maEditKerning->Disable();
+ maFTBy->Disable();
+
+ get(maNormal, "normal");
+ get(maVeryTight, "very_tight");
+ get(maTight, "tight");
+ get(maVeryLoose, "very_loose");
+ get(maLoose, "loose");
+ get(maLastCustom, "last_custom");
+
maLBKerning->SetSelectHdl(LINK(this, TextCharacterSpacingControl, KerningSelectHdl));
+ maLBKerning->SetHelpId(HID_SPACING_CB_KERN);
maEditKerning->SetModifyHdl(LINK(this, TextCharacterSpacingControl, KerningModifyHdl));
+ maEditKerning->SetHelpId(HID_SPACING_MB_KERN);
+ Link<Button*,void> aLink = LINK(this, TextCharacterSpacingControl, PredefinedValuesHdl);
+ maNormal->SetClickHdl(aLink);
+ maVeryTight->SetClickHdl(aLink);
+ maTight->SetClickHdl(aLink);
+ maVeryLoose->SetClickHdl(aLink);
+ maLoose->SetClickHdl(aLink);
+ maLastCustom->SetClickHdl(aLink);
+
+ Initialize();
}
TextCharacterSpacingControl::~TextCharacterSpacingControl()
{
+ if(GetLastCustomState() == SPACING_CLOSE_BY_CUS_EDIT)
+ {
+ SvtViewOptions aWinOpt(E_WINDOW, SIDEBAR_SPACING_GLOBAL_VALUE);
+ css::uno::Sequence<css::beans::NamedValue> aSeq
+ { { "Spacing", css::uno::makeAny(OUString::number(GetLastCustomValue())) } };
+ aWinOpt.SetUserData(aSeq);
+
+ }
+
disposeOnce();
}
void TextCharacterSpacingControl::dispose()
{
- delete[] mpImg;
- delete[] mpImgSel;
- delete[] mpStr;
- delete[] mpStrTip;
- maVSSpacing.disposeAndClear();
- maLastCus.disposeAndClear();
- maFTSpacing.disposeAndClear();
- maLBKerning.disposeAndClear();
- maFTBy.disposeAndClear();
- maEditKerning.disposeAndClear();
- svx::sidebar::PopupControl::dispose();
-}
+ maFTBy.clear();
+ maFTSpacing.clear();
+ maLBKerning.clear();
+ maEditKerning.clear();
-void TextCharacterSpacingControl::initial()
-{
- maVSSpacing->SetStyle( maVSSpacing->GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT );
- {
- maVSSpacing->SetControlBackground(GetSettings().GetStyleSettings().GetHighContrastMode()?
- GetSettings().GetStyleSettings().GetMenuColor():
- sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
- maVSSpacing->SetColor(GetSettings().GetStyleSettings().GetHighContrastMode()?
- GetSettings().GetStyleSettings().GetMenuColor():
- sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
- maVSSpacing->SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()?
- GetSettings().GetStyleSettings().GetMenuColor():
- sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
- maFTSpacing->SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()?
- GetSettings().GetStyleSettings().GetMenuColor():
- sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
- maFTBy->SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()?
- GetSettings().GetStyleSettings().GetMenuColor():
- sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
- }
- mpImg = new Image[5];
- mpImg[0] = Image(SVX_RES(IMG_VERY_TIGHT));
- mpImg[1] = Image(SVX_RES(IMG_TIGHT));
- mpImg[2] = Image(SVX_RES(IMG_NORMAL));
- mpImg[3] = Image(SVX_RES(IMG_LOOSE));
- mpImg[4] = Image(SVX_RES(IMG_VERY_LOOSE));
-
- mpImgSel = new Image[5];
- mpImgSel[0] = Image(SVX_RES(IMG_VERY_TIGHT_S));
- mpImgSel[1] = Image(SVX_RES(IMG_TIGHT_S));
- mpImgSel[2] = Image(SVX_RES(IMG_NORMAL_S));
- mpImgSel[3] = Image(SVX_RES(IMG_LOOSE_S));
- mpImgSel[4] = Image(SVX_RES(IMG_VERY_LOOSE_S));
-
- mpStr = new OUString[5];
- mpStr[0] = SVX_RESSTR(STR_VERY_TIGHT);
- mpStr[1] = SVX_RESSTR(STR_TIGHT);
- mpStr[2] = SVX_RESSTR(STR_NORMAL);
- mpStr[3] = SVX_RESSTR(STR_LOOSE);
- mpStr[4] = SVX_RESSTR(STR_VERY_LOOSE);
-
-
- mpStrTip = new OUString[5];
- mpStrTip[0] = SVX_RESSTR(STR_VERY_TIGHT_TIP);
- mpStrTip[1] = SVX_RESSTR(STR_TIGHT_TIP);
- mpStrTip[2] = SVX_RESSTR(STR_NORMAL_TIP);
- mpStrTip[3] = SVX_RESSTR(STR_LOOSE_TIP);
- mpStrTip[4] = SVX_RESSTR(STR_VERY_LOOSE_TIP);
-
- for (int i=0;i<5;i++)
- maVSSpacing->AddItem(mpImg[i], &mpImgSel[i],mpStr[i],&mpStrTip[i]);
-
- maVSSpacing->AddItem( maImgCus, nullptr, maStrCus, nullptr );
-
- maVSSpacing->SetNoSelection();
- maVSSpacing->SetSelectHdl(LINK(this, TextCharacterSpacingControl,VSSelHdl ));
- maVSSpacing->StartSelection();
- maVSSpacing->Show();
+ maNormal.clear();
+ maVeryTight.clear();
+ maTight.clear();
+ maVeryLoose.clear();
+ maLoose.clear();
+ maLastCustom.clear();
+
+ SfxPopupWindow::dispose();
}
-void TextCharacterSpacingControl::Rearrange(bool bLBAvailable,bool bAvailable, long nKerning)
+void TextCharacterSpacingControl::Initialize()
{
- mbVS = true;
- maVSSpacing->SetNoSelection();
- SvtViewOptions aWinOpt( E_WINDOW, SIDEBAR_SPACING_GLOBAL_VALUE );
- if ( aWinOpt.Exists() )
+ const SfxPoolItem* pItem;
+ SfxItemState eState = SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_CHAR_KERNING, pItem);
+
+ const SvxKerningItem* pKerningItem = static_cast<const SvxKerningItem*>(pItem);
+ long nKerning = 0;
+
+ if(pKerningItem)
+ nKerning = pKerningItem->GetValue();
+
+ SvtViewOptions aWinOpt(E_WINDOW, SIDEBAR_SPACING_GLOBAL_VALUE);
+ if(aWinOpt.Exists())
{
- css::uno::Sequence < css::beans::NamedValue > aSeq = aWinOpt.GetUserData();
+ css::uno::Sequence<css::beans::NamedValue> aSeq = aWinOpt.GetUserData();
::rtl::OUString aTmp;
- if ( aSeq.getLength())
+ if(aSeq.getLength())
aSeq[0].Value >>= aTmp;
- OUString aWinData( aTmp );
+ OUString aWinData(aTmp);
mnCustomKern = aWinData.toInt32();
mnLastCus = SPACING_CLOSE_BY_CUS_EDIT;
- mbCusEnable = true;
}
else
{
mnLastCus = SPACING_NOCUSTOM;
- mbCusEnable = false;
- }
-
- if( !mnLastCus )
- {
- maVSSpacing->ReplaceItemImages(6, maImgCusGrey,nullptr);
- }
- else
- {
- //set custom tips
- maVSSpacing->ReplaceItemImages(6, maImgCus,nullptr);
- if(mnCustomKern > 0)
- {
- OUString aStrTip( maStrCusE); //LAST CUSTOM no tip defect //add
- aStrTip += OUString::number( (double)mnCustomKern / 10);
- aStrTip += " " + maStrUnit; // modify
- maVSSpacing->SetItemText(6,aStrTip);
- }
- else if(mnCustomKern < 0)
- {
- OUString aStrTip(maStrCusC) ; //LAST CUSTOM no tip defect //add
- aStrTip += OUString::number( (double)-mnCustomKern / 10);
- aStrTip += " " + maStrUnit; // modify
- maVSSpacing->SetItemText( 6, aStrTip );
- }
- else
- {
- OUString aStrTip(maStrCusN) ; //LAST CUSTOM no tip defect //add
- maVSSpacing->SetItemText( 6, aStrTip );
- }
-
}
- if(bLBAvailable && bAvailable)
+ if(eState >= SfxItemState::DEFAULT)
{
maLBKerning->Enable();
maFTSpacing->Enable();
- SfxMapUnit eUnit = mrTextPropertyPanel.GetSpaceController().GetCoreMetric();
+ SfxMapUnit eUnit = GetCoreMetric();
MapUnit eOrgUnit = (MapUnit)eUnit;
- MapUnit ePntUnit( MAP_POINT );
+ MapUnit ePntUnit(MAP_POINT);
long nBig = maEditKerning->Normalize(nKerning);
- nKerning = LogicToLogic( nBig, eOrgUnit, ePntUnit );
+ nKerning = LogicToLogic(nBig, eOrgUnit, ePntUnit);
- if ( nKerning > 0 )
+ if(nKerning > 0)
{
maFTBy->Enable();
maEditKerning->Enable();
- maEditKerning->SetMax( 9999 );
- maEditKerning->SetLast( 9999 );
- maEditKerning->SetValue( nKerning );
- maLBKerning->SelectEntryPos( SIDEBAR_SPACE_EXPAND );
- if(nKerning == 30)
- {
- maVSSpacing->SelectItem(4);
- }
- else if(nKerning == 60)
- {
- maVSSpacing->SelectItem(5);
- }
- else
- {
- maVSSpacing->SetNoSelection();
- maVSSpacing->SelectItem(0);
- mbVS = false;
- }
+ maEditKerning->SetMax(9999);
+ maEditKerning->SetLast(9999);
+ maEditKerning->SetValue(nKerning);
+ maLBKerning->SelectEntryPos(SIDEBAR_SPACE_EXPAND);
}
- else if ( nKerning < 0 )
+ else if(nKerning < 0)
{
maFTBy->Enable();
maEditKerning->Enable();
- maEditKerning->SetValue( -nKerning );
- maLBKerning->SelectEntryPos( SIDEBAR_SPACE_CONDENSED );
- long nMax = mrTextPropertyPanel.GetSelFontSize()/6;
- maEditKerning->SetMax( maEditKerning->Normalize( nMax ), FUNIT_POINT );
- maEditKerning->SetLast( maEditKerning->GetMax( maEditKerning->GetUnit() ) );
- if( nKerning == -30 )
- {
- maVSSpacing->SelectItem(1);
- }
- else if( nKerning == -15 )
- {
- maVSSpacing->SelectItem(2);
- }
- else
- {
- maVSSpacing->SetNoSelection();
- maVSSpacing->SelectItem(0);
- mbVS = false;
- }
+ maEditKerning->SetValue(-nKerning);
+ maLBKerning->SelectEntryPos(SIDEBAR_SPACE_CONDENSED);
+ long nMax = GetSelFontSize()/6;
+ maEditKerning->SetMax(maEditKerning->Normalize(nMax), FUNIT_POINT);
+ maEditKerning->SetLast(maEditKerning->GetMax(maEditKerning->GetUnit()));
}
else
{
- maVSSpacing->SelectItem(3);
- maLBKerning->SelectEntryPos( SIDEBAR_SPACE_NORMAL );
+ maLBKerning->SelectEntryPos(SIDEBAR_SPACE_NORMAL);
maFTBy->Disable();
maEditKerning->Disable();
- maEditKerning->SetValue( 0 );
- maEditKerning->SetMax( 9999 );
- maEditKerning->SetLast( 9999 );
+ maEditKerning->SetValue(0);
+ maEditKerning->SetMax(9999);
+ maEditKerning->SetLast(9999);
}
}
- else if(bLBAvailable && !bAvailable)
+ else if(SfxItemState::DISABLED == eState)
{
- //modified
- maVSSpacing->SetNoSelection();
- maVSSpacing->SelectItem(0);
- mbVS = false;
- maLBKerning->Enable();
- maFTSpacing->Enable();
- maLBKerning->SetNoSelection();
maEditKerning->SetText(OUString());
+ maLBKerning->SetNoSelection();
+ maLBKerning->Disable();
+ maFTSpacing->Disable();
maEditKerning->Disable();
maFTBy->Disable();
}
else
{
- maVSSpacing->SetNoSelection();
- maVSSpacing->SelectItem(0);
- mbVS = false;
- maEditKerning->SetText(OUString());
+ maLBKerning->Enable();
+ maFTSpacing->Enable();
maLBKerning->SetNoSelection();
- maLBKerning->Disable();
- maFTSpacing->Disable();
+ maEditKerning->SetText(OUString());
maEditKerning->Disable();
maFTBy->Disable();
}
- GetFocus();
- maVSSpacing->SetFormat();
- maVSSpacing->Invalidate();
- maVSSpacing->StartSelection();
}
-IMPL_LINK_TYPED(TextCharacterSpacingControl, VSSelHdl, ValueSet*, pControl, void)
+void TextCharacterSpacingControl::ExecuteCharacterSpacing(long nValue, bool bClose)
+{
+ SfxMapUnit eUnit = GetCoreMetric();
+
+ long nSign = (nValue < 0) ? -1 : 1;
+ nValue = nValue * nSign;
+
+ long nVal = LogicToLogic(nValue, MAP_POINT, (MapUnit)eUnit);
+ short nKern = (nValue == 0) ? 0 : (short)maEditKerning->Denormalize(nVal);
+
+ SvxKerningItem aKernItem(nSign * nKern, SID_ATTR_CHAR_KERNING);
+
+ SfxViewFrame::Current()->GetBindings().GetDispatcher()->ExecuteList(SID_ATTR_CHAR_KERNING,
+ SfxCallMode::RECORD, { &aKernItem });
+
+ if(bClose)
+ EndPopupMode();
+}
+
+IMPL_LINK_TYPED(TextCharacterSpacingControl, PredefinedValuesHdl, Button*, pControl, void)
{
mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
- if(pControl == maVSSpacing.get())
+ if(pControl == maNormal)
{
- sal_uInt16 iPos = maVSSpacing->GetSelectItemId();
- short nKern = 0;
- SfxMapUnit eUnit = mrTextPropertyPanel.GetSpaceController().GetCoreMetric();
- long nVal = 0;
- if(iPos == 1)
- {
- nVal = LogicToLogic(30, MAP_POINT, (MapUnit)eUnit);
- nKern = (short)maEditKerning->Denormalize(nVal);
- SvxKerningItem aKernItem(-nKern, SID_ATTR_CHAR_KERNING);
- mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_CHAR_KERNING,
- SfxCallMode::RECORD, { &aKernItem });
- mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
- }
- else if(iPos == 2)
- {
- nVal = LogicToLogic(15, MAP_POINT, (MapUnit)eUnit);
- nKern = (short)maEditKerning->Denormalize(nVal);
- SvxKerningItem aKernItem(-nKern, SID_ATTR_CHAR_KERNING);
- mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_CHAR_KERNING,
- SfxCallMode::RECORD, { &aKernItem });
- mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
- }
- else if(iPos == 3)
- {
- SvxKerningItem aKernItem(0, SID_ATTR_CHAR_KERNING);
- mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_CHAR_KERNING,
- SfxCallMode::RECORD, { &aKernItem });
- mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
- }
- else if(iPos == 4)
- {
- nVal = LogicToLogic(30, MAP_POINT, (MapUnit)eUnit);
- nKern = (short)maEditKerning->Denormalize(nVal);
- SvxKerningItem aKernItem(nKern, SID_ATTR_CHAR_KERNING);
- mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_CHAR_KERNING,
- SfxCallMode::RECORD, { &aKernItem });
- mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
- }
- else if(iPos == 5)
- {
- nVal = LogicToLogic(60, MAP_POINT, (MapUnit)eUnit);
- nKern = (short)maEditKerning->Denormalize(nVal);
- SvxKerningItem aKernItem(nKern, SID_ATTR_CHAR_KERNING);
- mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_CHAR_KERNING,
- SfxCallMode::RECORD, { &aKernItem });
- mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
- }
- else if(iPos == 6)
- {
- //modified
- if(mbCusEnable)
- {
- nVal = LogicToLogic(mnCustomKern, MAP_POINT, (MapUnit)eUnit);
- nKern = (short)maEditKerning->Denormalize(nVal);
- SvxKerningItem aKernItem(nKern , SID_ATTR_CHAR_KERNING);
- mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_CHAR_KERNING,
- SfxCallMode::RECORD, { &aKernItem });
- mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
- }
- else
- {
- maVSSpacing->SetNoSelection(); //add , set no selection and keep the last select item
- maVSSpacing->SetFormat();
- maVSSpacing->Invalidate();
- Invalidate();
- maVSSpacing->StartSelection();
- }
- //modify end
- }
-
- if(iPos < 6 || (iPos == 6 && mbCusEnable)) //add
- mrTextPropertyPanel.EndSpacingPopupMode();
+ ExecuteCharacterSpacing(SPACING_NORMAL);
+ }
+ else if(pControl == maVeryTight)
+ {
+ ExecuteCharacterSpacing(SPACING_VERY_TIGHT);
+ }
+ else if(pControl == maTight)
+ {
+ ExecuteCharacterSpacing(SPACING_TIGHT);
+ }
+ else if(pControl == maVeryLoose)
+ {
+ ExecuteCharacterSpacing(SPACING_VERY_LOOSE);
+ }
+ else if(pControl == maLoose)
+ {
+ ExecuteCharacterSpacing(SPACING_LOOSE);
+ }
+ else if(pControl == maLastCustom)
+ {
+ ExecuteCharacterSpacing(mnCustomKern);
}
}
IMPL_LINK_NOARG_TYPED(TextCharacterSpacingControl, KerningSelectHdl, ListBox&, void)
{
- if ( maLBKerning->GetSelectEntryPos() > 0 )
+ if(maLBKerning->GetSelectEntryPos() > 0)
{
maFTBy->Enable();
maEditKerning->Enable();
}
else
{
- maEditKerning->SetValue( 0 );
+ maEditKerning->SetValue(0);
maFTBy->Disable();
maEditKerning->Disable();
}
- if ( maVSSpacing->GetSelectItemId() > 0 )
- {
- maVSSpacing->SetNoSelection();
- maVSSpacing->SelectItem(0);
- maVSSpacing->SetFormat();
- maVSSpacing->Invalidate();
- Invalidate();
- maVSSpacing->StartSelection();
- }
- KerningModifyHdl( *maEditKerning );
+ KerningModifyHdl(*maEditKerning);
}
IMPL_LINK_NOARG_TYPED(TextCharacterSpacingControl, KerningModifyHdl, Edit&, void)
{
- if ( maVSSpacing->GetSelectItemId() > 0 )
- {
- maVSSpacing->SetNoSelection();
- maVSSpacing->SelectItem(0);
- maVSSpacing->SetFormat();
- maVSSpacing->Invalidate();
- Invalidate();
- maVSSpacing->StartSelection();
- }
const sal_Int32 nPos = maLBKerning->GetSelectEntryPos();
- short nKern = 0;
- SfxMapUnit eUnit = mrTextPropertyPanel.GetSpaceController().GetCoreMetric();
+
mnLastCus = SPACING_CLOSE_BY_CUS_EDIT;
- if ( nPos == SIDEBAR_SPACE_EXPAND || nPos == SIDEBAR_SPACE_CONDENSED )
+ if(nPos == SIDEBAR_SPACE_EXPAND || nPos == SIDEBAR_SPACE_CONDENSED)
{
long nTmp = static_cast<long>(maEditKerning->GetValue());
- if ( nPos == SIDEBAR_SPACE_CONDENSED )
+ if(nPos == SIDEBAR_SPACE_CONDENSED)
{
- long nMax = mrTextPropertyPanel.GetSelFontSize()/6;
- maEditKerning->SetMax( maEditKerning->Normalize( nMax ), FUNIT_TWIP );
- maEditKerning->SetLast( maEditKerning->GetMax( maEditKerning->GetUnit() ) );
+ long nMax = GetSelFontSize()/6;
+ maEditKerning->SetMax(maEditKerning->Normalize(nMax), FUNIT_TWIP);
+ maEditKerning->SetLast(maEditKerning->GetMax(maEditKerning->GetUnit()));
if(nTmp > maEditKerning->GetMax())
nTmp = maEditKerning->GetMax();
mnCustomKern = -nTmp;
- long nVal = LogicToLogic( nTmp, MAP_POINT, (MapUnit)eUnit );
- nKern = (short)maEditKerning->Denormalize( nVal );
- nKern *= - 1;
}
else
{
- maEditKerning->SetMax( 9999 );
- maEditKerning->SetLast( 9999 );
+ maEditKerning->SetMax(9999);
+ maEditKerning->SetLast(9999);
if(nTmp > maEditKerning->GetMax(FUNIT_TWIP))
nTmp = maEditKerning->GetMax(FUNIT_TWIP);
mnCustomKern = nTmp;
- long nVal = LogicToLogic( nTmp, MAP_POINT, (MapUnit)eUnit );
- nKern = (short)maEditKerning->Denormalize( nVal );
}
}
else
{
mnCustomKern = 0;
}
- SvxKerningItem aKernItem(nKern, SID_ATTR_CHAR_KERNING);
- mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_CHAR_KERNING,
- SfxCallMode::RECORD, { &aKernItem });
+
+ ExecuteCharacterSpacing(mnCustomKern, false);
+}
+
+SfxMapUnit TextCharacterSpacingControl::GetCoreMetric() const
+{
+ SfxItemPool &rPool = SfxGetpApp()->GetPool();
+ sal_uInt16 nWhich = rPool.GetWhich(mnId);
+ return rPool.GetMetric(nWhich);
+}
+
+long TextCharacterSpacingControl::GetSelFontSize() const
+{
+ const SfxPoolItem* pItem;
+ SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_CHAR_FONTHEIGHT, pItem);
+
+ const SvxFontHeightItem* pHeightItem = static_cast<const SvxFontHeightItem*>(pItem);
+
+ long nH = 240;
+ SfxMapUnit eUnit = GetCoreMetric();
+ if(pHeightItem)
+ nH = LogicToLogic(pHeightItem->GetHeight(), (MapUnit)eUnit, MAP_TWIP);
+ return nH;
}
-}} // end of namespace sidebar
+} // end of namespace svx
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */