diff options
author | Szymon Kłos <eszkadev@gmail.com> | 2016-04-16 16:38:43 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2016-04-20 07:53:17 +0000 |
commit | ccaf108651ee7e477b09f496f33ea778307fe60b (patch) | |
tree | 11c22a3675a8ee06ab248d4879d582e6d1970c84 | |
parent | f7aa4344e4fec0e8bb49d6ba210bc3a78b7e1365 (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>
-rw-r--r-- | include/svx/TextCharacterSpacingPopup.hxx (renamed from svx/source/sidebar/text/TextCharacterSpacingPopup.hxx) | 24 | ||||
-rw-r--r-- | include/svx/dialogs.hrc | 1 | ||||
-rw-r--r-- | sc/source/ui/app/scdll.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/app/sddll.cxx | 2 | ||||
-rw-r--r-- | svx/UIConfig_svx.mk | 1 | ||||
-rw-r--r-- | svx/source/sidebar/text/TextCharacterSpacingControl.cxx | 502 | ||||
-rw-r--r-- | svx/source/sidebar/text/TextCharacterSpacingControl.hxx | 57 | ||||
-rw-r--r-- | svx/source/sidebar/text/TextCharacterSpacingPopup.cxx | 46 | ||||
-rw-r--r-- | svx/source/sidebar/text/TextPropertyPanel.cxx | 81 | ||||
-rw-r--r-- | svx/source/sidebar/text/TextPropertyPanel.hrc | 42 | ||||
-rw-r--r-- | svx/source/sidebar/text/TextPropertyPanel.hxx | 12 | ||||
-rw-r--r-- | svx/source/sidebar/text/TextPropertyPanel.src | 180 | ||||
-rw-r--r-- | svx/uiconfig/ui/textcharacterspacingcontrol.ui | 269 | ||||
-rw-r--r-- | sw/source/uibase/app/swmodule.cxx | 2 |
14 files changed, 500 insertions, 721 deletions
diff --git a/svx/source/sidebar/text/TextCharacterSpacingPopup.hxx b/include/svx/TextCharacterSpacingPopup.hxx index 548a9d929b81..68077b25f0c9 100644 --- a/svx/source/sidebar/text/TextCharacterSpacingPopup.hxx +++ b/include/svx/TextCharacterSpacingPopup.hxx @@ -16,30 +16,28 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_SVX_SOURCE_SIDEBAR_TEXT_TEXTCHARACTERSPACINGPOPUP_HXX -#define INCLUDED_SVX_SOURCE_SIDEBAR_TEXT_TEXTCHARACTERSPACINGPOPUP_HXX +#ifndef INCLUDED_SVX_TEXTCHARACTERSPACINGPOPUP_HXX +#define INCLUDED_SVX_TEXTCHARACTERSPACINGPOPUP_HXX -#include "svx/sidebar/Popup.hxx" +#include <sfx2/tbxctrl.hxx> +#include <svx/svxdllapi.h> #include <functional> -namespace svx { namespace sidebar { +namespace svx { -class TextCharacterSpacingPopup - : public Popup +class SVX_DLLPUBLIC TextCharacterSpacingPopup : public SfxToolBoxControl { public: - TextCharacterSpacingPopup ( - vcl::Window* pParent, - const ::std::function<VclPtr<PopupControl> (PopupContainer*)>& rControlCreator); + SFX_DECL_TOOLBOX_CONTROL(); + + TextCharacterSpacingPopup(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx); virtual ~TextCharacterSpacingPopup(); - void Rearrange (bool bLBAvailable,bool bAvailable, long nKerning); -private: - void PopupModeEndCallback(); + virtual VclPtr<SfxPopupWindow> CreatePopupWindow() override; }; -} } // end of namespace svx::sidebar +} // end of namespace svx #endif diff --git a/include/svx/dialogs.hrc b/include/svx/dialogs.hrc index 59a2de415ad7..5c9b5e4743a7 100644 --- a/include/svx/dialogs.hrc +++ b/include/svx/dialogs.hrc @@ -196,7 +196,6 @@ #define RID_SIDEBAR_TEXT_PANEL (RID_SVX_START + 314) #define RID_POPUPPANEL_TEXTPAGE_UNDERLINE (RID_SVX_START + 315) #define RID_POPUPPANEL_TEXTPAGE_FONT_COLOR (RID_SVX_START + 316) -#define RID_POPUPPANEL_TEXTPAGE_SPACING (RID_SVX_START + 317) #define RID_POPUPPANEL_AREAPAGE_TRGR (RID_SVX_START + 320) diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx index d35328a901b2..ad5217d188db 100644 --- a/sc/source/ui/app/scdll.cxx +++ b/sc/source/ui/app/scdll.cxx @@ -33,6 +33,7 @@ #include <avmedia/mediatoolbox.hxx> #include <comphelper/types.hxx> #include <svx/ParaLineSpacingPopup.hxx> +#include <svx/TextCharacterSpacingPopup.hxx> #include <svtools/parhtml.hxx> #include <sot/formats.hxx> @@ -169,6 +170,7 @@ void ScDLL::Init() SvxUndoRedoControl ::RegisterControl(SID_UNDO, pMod ); SvxUndoRedoControl ::RegisterControl(SID_REDO, pMod ); svx::ParaLineSpacingPopup ::RegisterControl(SID_ATTR_PARA_LINESPACE, pMod ); + svx::TextCharacterSpacingPopup ::RegisterControl(SID_ATTR_CHAR_KERNING, pMod ); svx::FormatPaintBrushToolBoxControl::RegisterControl(SID_FORMATPAINTBRUSH, pMod ); SvxGrafModeToolBoxControl ::RegisterControl(SID_ATTR_GRAF_MODE, pMod); diff --git a/sd/source/ui/app/sddll.cxx b/sd/source/ui/app/sddll.cxx index c229ff992063..4251f5f07702 100644 --- a/sd/source/ui/app/sddll.cxx +++ b/sd/source/ui/app/sddll.cxx @@ -69,6 +69,7 @@ #include <svx/fontwork.hxx> #include <svx/formatpaintbrushctrl.hxx> #include <svx/ParaLineSpacingPopup.hxx> +#include <svx/TextCharacterSpacingPopup.hxx> #include <svx/grafctrl.hxx> #include <svx/hyperdlg.hxx> #include <svx/imapdlg.hxx> @@ -227,6 +228,7 @@ void SdDLL::RegisterControllers() SvxColorToolBoxControl::RegisterControl( SID_EXTRUSION_3D_COLOR, pMod ); svx::ParaLineSpacingPopup::RegisterControl(SID_ATTR_PARA_LINESPACE, pMod); + svx::TextCharacterSpacingPopup::RegisterControl(SID_ATTR_CHAR_KERNING, pMod); ::avmedia::MediaToolBoxControl::RegisterControl( SID_AVMEDIA_TOOLBOX, pMod ); XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE, pMod ); diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk index e56c9bd80f04..df6167d862a0 100644 --- a/svx/UIConfig_svx.mk +++ b/svx/UIConfig_svx.mk @@ -68,6 +68,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\ svx/uiconfig/ui/sidebarpossize \ svx/uiconfig/ui/sidebarstylespanel \ svx/uiconfig/ui/sidebartextpanel \ + svx/uiconfig/ui/textcharacterspacingcontrol \ svx/uiconfig/ui/textcontrolchardialog \ svx/uiconfig/ui/textcontrolparadialog \ svx/uiconfig/ui/xformspage \ 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: */ diff --git a/svx/source/sidebar/text/TextCharacterSpacingControl.hxx b/svx/source/sidebar/text/TextCharacterSpacingControl.hxx index db189051bee8..cd0cdd04a2a7 100644 --- a/svx/source/sidebar/text/TextCharacterSpacingControl.hxx +++ b/svx/source/sidebar/text/TextCharacterSpacingControl.hxx @@ -20,13 +20,12 @@ #define INCLUDED_SVX_SOURCE_SIDEBAR_TEXT_TEXTCHARACTERSPACINGCONTROL_HXX #include "svx/sidebar/PopupControl.hxx" -#include "svx/sidebar/ValueSetWithTextControl.hxx" #include <sfx2/bindings.hxx> -#include "TextPropertyPanel.hxx" #include <vcl/fixed.hxx> +#include <vcl/field.hxx> +#include <sfx2/tbxctrl.hxx> - -namespace svx { namespace sidebar { +namespace svx { #define SPACING_NOCUSTOM 0 #define SPACING_CLOSE_BY_CLICK_ICON -1 #define SPACING_CLOSE_BY_CUS_EDIT 1 @@ -37,60 +36,44 @@ namespace svx { namespace sidebar { #define SIDEBAR_SPACE_EXPAND 1 #define SIDEBAR_SPACE_CONDENSED 2 -class TextCharacterSpacingControl:public svx::sidebar::PopupControl +class TextCharacterSpacingControl : public SfxPopupWindow { public: - TextCharacterSpacingControl ( - vcl::Window* pParent, - svx::sidebar::TextPropertyPanel& rPanel, - SfxBindings* pBindings); + TextCharacterSpacingControl(sal_uInt16 nId); virtual ~TextCharacterSpacingControl(); virtual void dispose() override; - void Rearrange(bool bLBAvailable,bool bAvailable, long nKerning); - //virtual void Paint(const Rectangle& rect); - //add short GetLastCustomState() { return mnLastCus;} long GetLastCustomValue() { return mnCustomKern;} - //add end private: - svx::sidebar::TextPropertyPanel& mrTextPropertyPanel; - SfxBindings* mpBindings; - - VclPtr<ValueSetWithTextControl> maVSSpacing; - - VclPtr<FixedText> maLastCus; - VclPtr<FixedText> maFTSpacing; VclPtr<ListBox> maLBKerning; VclPtr<FixedText> maFTBy; VclPtr<MetricField> maEditKerning; - Image* mpImg; - Image* mpImgSel; - OUString* mpStr; - OUString* mpStrTip; - - Image maImgCus; - Image maImgCusGrey; - OUString maStrCus; - OUString maStrCusE; - OUString maStrCusC; - OUString maStrCusN; - OUString maStrUnit; + VclPtr<PushButton> maNormal; + VclPtr<PushButton> maVeryTight; + VclPtr<PushButton> maTight; + VclPtr<PushButton> maVeryLoose; + VclPtr<PushButton> maLoose; + VclPtr<PushButton> maLastCustom; + sal_uInt16 mnId; long mnCustomKern; short mnLastCus; - bool mbCusEnable; - bool mbVS; - void initial(); - DECL_LINK_TYPED(VSSelHdl, ValueSet*, void); + void Initialize(); + void ExecuteCharacterSpacing(long nValue, bool bClose = true); + + DECL_LINK_TYPED(PredefinedValuesHdl, Button*, void); DECL_LINK_TYPED(KerningSelectHdl, ListBox&, void); DECL_LINK_TYPED(KerningModifyHdl, Edit&, void); + + SfxMapUnit GetCoreMetric() const; + long GetSelFontSize() const; }; -}} +} #endif diff --git a/svx/source/sidebar/text/TextCharacterSpacingPopup.cxx b/svx/source/sidebar/text/TextCharacterSpacingPopup.cxx index 148b864297d5..266b9d392aae 100644 --- a/svx/source/sidebar/text/TextCharacterSpacingPopup.cxx +++ b/svx/source/sidebar/text/TextCharacterSpacingPopup.cxx @@ -16,53 +16,35 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "TextCharacterSpacingPopup.hxx" +#include <svx/TextCharacterSpacingPopup.hxx> #include "TextCharacterSpacingControl.hxx" #include <unotools/viewoptions.hxx> +#include <vcl/toolbox.hxx> +#include <editeng/kernitem.hxx> -namespace svx { namespace sidebar { +using namespace svx; -TextCharacterSpacingPopup::TextCharacterSpacingPopup ( - vcl::Window* pParent, - const ::std::function<VclPtr<PopupControl>(PopupContainer*)>& rControlCreator) - : Popup( - pParent, - rControlCreator, - OUString( "Character Spacing")) +SFX_IMPL_TOOLBOX_CONTROL(TextCharacterSpacingPopup, SvxKerningItem); + +TextCharacterSpacingPopup::TextCharacterSpacingPopup(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx) + : SfxToolBoxControl(nSlotId, nId, rTbx) { - SetPopupModeEndHandler([this] () { return this->PopupModeEndCallback(); }); + rTbx.SetItemBits(nId, ToolBoxItemBits::DROPDOWNONLY | rTbx.GetItemBits(nId)); } TextCharacterSpacingPopup::~TextCharacterSpacingPopup() { } -void TextCharacterSpacingPopup::Rearrange (bool bLBAvailable,bool bAvailable, long nKerning) +VclPtr<SfxPopupWindow> TextCharacterSpacingPopup::CreatePopupWindow() { - ProvideContainerAndControl(); + VclPtr<TextCharacterSpacingControl> pControl = VclPtr<TextCharacterSpacingControl>::Create(GetSlotId()); - TextCharacterSpacingControl* pControl = dynamic_cast<TextCharacterSpacingControl*>(mxControl.get()); - if (pControl != nullptr) - pControl->Rearrange(bLBAvailable,bAvailable,nKerning); -} + pControl->StartPopupMode(&GetToolBox(), FloatWinPopupFlags::GrabFocus|FloatWinPopupFlags::NoAppFocusClose); -void TextCharacterSpacingPopup::PopupModeEndCallback() -{ - ProvideContainerAndControl(); - TextCharacterSpacingControl* pControl = dynamic_cast<TextCharacterSpacingControl*>(mxControl.get()); - if (pControl == nullptr) - return; + SetPopupWindow(pControl); - if( pControl->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(pControl->GetLastCustomValue())) } }; - aWinOpt.SetUserData( aSeq ); - - } + return pControl; } -} } // end of namespace svx::sidebar - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sidebar/text/TextPropertyPanel.cxx b/svx/source/sidebar/text/TextPropertyPanel.cxx index ec237d039d9c..b4794efd7a37 100644 --- a/svx/source/sidebar/text/TextPropertyPanel.cxx +++ b/svx/source/sidebar/text/TextPropertyPanel.cxx @@ -28,7 +28,6 @@ #include <vcl/toolbox.hxx> #include "TextCharacterSpacingControl.hxx" -#include "TextCharacterSpacingPopup.hxx" #include "TextUnderlineControl.hxx" #include "TextUnderlinePopup.hxx" #include <svx/sidebar/PopupContainer.hxx> @@ -37,30 +36,15 @@ using namespace css; using namespace css::uno; -const char UNO_SPACING[] = ".uno:Spacing"; const char UNO_UNDERLINE[] = ".uno:Underline"; namespace svx { namespace sidebar { -VclPtr<PopupControl> TextPropertyPanel::CreateCharacterSpacingControl (PopupContainer* pParent) -{ - return VclPtrInstance<TextCharacterSpacingControl>(pParent, *this, mpBindings); -} - VclPtr<PopupControl> TextPropertyPanel::CreateUnderlinePopupControl (PopupContainer* pParent) { return VclPtrInstance<TextUnderlineControl>(pParent, *this, mpBindings); } -long TextPropertyPanel::GetSelFontSize() -{ - long nH = 240; - SfxMapUnit eUnit = maSpacingControl.GetCoreMetric(); - if (mpHeightItem) - nH = LogicToLogic( mpHeightItem->GetHeight(), (MapUnit)eUnit, MAP_TWIP ); - return nH; -} - VclPtr<vcl::Window> TextPropertyPanel::Create ( vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, @@ -85,9 +69,7 @@ TextPropertyPanel::TextPropertyPanel ( vcl::Window* pParent, const css::uno::Ref : PanelLayout(pParent, "SidebarTextPanel", "svx/ui/sidebartextpanel.ui", rxFrame), maFontSizeControl (SID_ATTR_CHAR_FONTHEIGHT, *pBindings, *this, OUString("FontHeight"), rxFrame), maUnderlineControl (SID_ATTR_CHAR_UNDERLINE, *pBindings, *this, OUString("Underline"), rxFrame), - maSpacingControl (SID_ATTR_CHAR_KERNING, *pBindings, *this, OUString("Spacing"), rxFrame), - maCharSpacePopup(this, [this] (PopupContainer *const pContainer) { return this->CreateCharacterSpacingControl(pContainer); }), maUnderlinePopup(this, [this] (PopupContainer *const pContainer) { return this->CreateUnderlinePopupControl(pContainer); }), maContext(), mpBindings(pBindings) @@ -102,15 +84,11 @@ TextPropertyPanel::TextPropertyPanel ( vcl::Window* pParent, const css::uno::Ref //toolbox SetupToolboxItems(); InitToolBoxFont(); - InitToolBoxSpacing(); //init state mpHeightItem = nullptr; meUnderline = LINESTYLE_NONE; meUnderlineColor = COL_AUTO; - mbKernAvailable = true; - mbKernLBAvailable = true; - mlKerning = 0; } TextPropertyPanel::~TextPropertyPanel() @@ -128,9 +106,7 @@ void TextPropertyPanel::dispose() maFontSizeControl.dispose(); maUnderlineControl.dispose(); - maSpacingControl.dispose(); - maCharSpacePopup.dispose(); maUnderlinePopup.dispose(); PanelLayout::dispose(); @@ -192,11 +168,6 @@ void TextPropertyPanel::DataChanged (const DataChangedEvent& /*rEvent*/) SetupToolboxItems(); } -void TextPropertyPanel::EndSpacingPopupMode() -{ - maCharSpacePopup.Hide(); -} - void TextPropertyPanel::EndUnderlinePopupMode() { maUnderlinePopup.Hide(); @@ -208,20 +179,9 @@ void TextPropertyPanel::InitToolBoxFont() mpToolBoxFont->SetDropdownClickHdl(aLink); } -void TextPropertyPanel::InitToolBoxSpacing() -{ - const sal_uInt16 nId = mpToolBoxSpacing->GetItemId(UNO_SPACING); - mpToolBoxSpacing->SetItemBits(nId, mpToolBoxSpacing->GetItemBits(nId) | ToolBoxItemBits::DROPDOWNONLY); - - Link<ToolBox *, void> aLink = LINK(this, TextPropertyPanel, SpacingClickHdl); - mpToolBoxSpacing->SetDropdownClickHdl ( aLink ); - mpToolBoxSpacing->SetSelectHdl( aLink ); -} - void TextPropertyPanel::SetupToolboxItems() { maUnderlineControl.SetupToolBoxItem(*mpToolBoxFont, mpToolBoxFont->GetItemId(UNO_UNDERLINE)); - maSpacingControl.SetupToolBoxItem(*mpToolBoxSpacing, mpToolBoxSpacing->GetItemId(UNO_SPACING)); } IMPL_LINK_TYPED(TextPropertyPanel, UnderlineClickHdl, ToolBox*, pToolBox, void) @@ -237,19 +197,6 @@ IMPL_LINK_TYPED(TextPropertyPanel, UnderlineClickHdl, ToolBox*, pToolBox, void) } } -IMPL_LINK_TYPED(TextPropertyPanel, SpacingClickHdl, ToolBox*, pToolBox, void) -{ - const sal_uInt16 nId = pToolBox->GetCurItemId(); - const OUString aCommand(pToolBox->GetItemCommand(nId)); - - if (aCommand == UNO_SPACING) - { - pToolBox->SetItemDown( nId, true ); - maCharSpacePopup.Rearrange(mbKernLBAvailable,mbKernAvailable,mlKerning); - maCharSpacePopup.Show(*pToolBox); - } -} - void TextPropertyPanel::NotifyItemUpdate ( const sal_uInt16 nSID, const SfxItemState eState, @@ -280,34 +227,6 @@ void TextPropertyPanel::NotifyItemUpdate ( break; case SID_ATTR_CHAR_KERNING: { - if ( SfxItemState::DEFAULT == eState ) - { - mbKernLBAvailable = true; - - if(dynamic_cast<const SvxKerningItem*>( pState) != nullptr) - { - const SvxKerningItem* pKerningItem = static_cast<const SvxKerningItem*>(pState); - mlKerning = (long)pKerningItem->GetValue(); - mbKernAvailable = true; - } - else - { - mlKerning = 0; - mbKernAvailable =false; - } - } - else if (SfxItemState::DISABLED == eState) - { - mbKernLBAvailable = false; - mbKernAvailable = false; - mlKerning = 0; - } - else - { - mbKernLBAvailable = true; - mbKernAvailable = false; - mlKerning = 0; - } mpToolBoxSpacing->Enable(bIsEnabled); } break; diff --git a/svx/source/sidebar/text/TextPropertyPanel.hrc b/svx/source/sidebar/text/TextPropertyPanel.hrc index 7f563f778cff..4271ddf749dd 100644 --- a/svx/source/sidebar/text/TextPropertyPanel.hrc +++ b/svx/source/sidebar/text/TextPropertyPanel.hrc @@ -65,48 +65,6 @@ #define STR_WITHOUT 50 -//POPUP WINDOW OF SPACING -#define VS_SPACING 1 - -#define CT_BORDER 7 -#define LB_KERNING 8 -#define ED_KERNING 9 - -#define FT_SPACING 18 -#define FT_BY 19 -#define FT_LASTCUSTOM 20 - -#define IMG_NORMAL 31 -#define IMG_VERY_TIGHT 32 -#define IMG_TIGHT 33 -#define IMG_LOOSE 34 -#define IMG_VERY_LOOSE 35 -#define IMG_CUSTOM 36 -#define IMG_CUSTOM_GRAY 37 - -#define IMG_NORMAL_S 51 -#define IMG_VERY_TIGHT_S 52 -#define IMG_TIGHT_S 53 -#define IMG_LOOSE_S 54 -#define IMG_VERY_LOOSE_S 55 - -#define STR_VERY_TIGHT 61 -#define STR_TIGHT 62 -#define STR_NORMAL 63 -#define STR_LOOSE 64 -#define STR_VERY_LOOSE 65 -#define STR_CUSTOM 66 - -#define STR_VERY_TIGHT_TIP 67 -#define STR_TIGHT_TIP 68 -#define STR_NORMAL_TIP 69 -#define STR_LOOSE_TIP 70 -#define STR_VERY_LOOSE_TIP 71 - -#define STR_CUSTOM_C_TIP 72 -#define STR_CUSTOM_E_TIP 73 -#define STR_PT 74 - //help ids #define HID_UNDERLINE_BTN "SVX_HID_UNDERLINE_BTN" #define HID_SPACING_CB_KERN "SVX_HID_SPACING_CB_KERN" diff --git a/svx/source/sidebar/text/TextPropertyPanel.hxx b/svx/source/sidebar/text/TextPropertyPanel.hxx index 16e62cefaa01..863a0379e634 100644 --- a/svx/source/sidebar/text/TextPropertyPanel.hxx +++ b/svx/source/sidebar/text/TextPropertyPanel.hxx @@ -29,7 +29,6 @@ #include <com/sun/star/ui/XSidebar.hpp> #include <com/sun/star/frame/XToolbarController.hpp> -#include "TextCharacterSpacingPopup.hxx" #include "TextUnderlinePopup.hxx" #include <svx/sidebar/PanelLayout.hxx> @@ -57,9 +56,6 @@ public: virtual void DataChanged (const DataChangedEvent& rEvent) override; - ::sfx2::sidebar::ControllerItem& GetSpaceController() { return maSpacingControl;} - long GetSelFontSize(); - void EndSpacingPopupMode(); void EndUnderlinePopupMode(); Color& GetUnderlineColor() { return meUnderlineColor;} @@ -92,29 +88,21 @@ private: //control items ::sfx2::sidebar::ControllerItem maFontSizeControl; ::sfx2::sidebar::ControllerItem maUnderlineControl; - ::sfx2::sidebar::ControllerItem maSpacingControl; FontLineStyle meUnderline; Color meUnderlineColor; - bool mbKernAvailable; - bool mbKernLBAvailable; - long mlKerning; SvxFontHeightItem* mpHeightItem; - TextCharacterSpacingPopup maCharSpacePopup; TextUnderlinePopup maUnderlinePopup; ::sfx2::sidebar::EnumContext maContext; SfxBindings* mpBindings; - VclPtr<PopupControl> CreateCharacterSpacingControl (PopupContainer* pParent); VclPtr<PopupControl> CreateUnderlinePopupControl (PopupContainer* pParent); - DECL_LINK_TYPED(SpacingClickHdl, ToolBox*, void); DECL_LINK_TYPED(UnderlineClickHdl, ToolBox*, void); void SetupToolboxItems(); void InitToolBoxFont(); - void InitToolBoxSpacing(); }; } } // end of namespace svx::sidebar diff --git a/svx/source/sidebar/text/TextPropertyPanel.src b/svx/source/sidebar/text/TextPropertyPanel.src index 62811f617079..74a8198ca842 100644 --- a/svx/source/sidebar/text/TextPropertyPanel.src +++ b/svx/source/sidebar/text/TextPropertyPanel.src @@ -178,184 +178,4 @@ Control RID_POPUPPANEL_TEXTPAGE_UNDERLINE }; -Control RID_POPUPPANEL_TEXTPAGE_SPACING -{ - OutputSize = TRUE; - DialogControl = TRUE; - Border = FALSE; - - Size = MAP_APPFONT( POPUPPANEL_MARGIN_SMALL * 2 + POPUP_BORDER_WIDTH + VS_SPACING_WIDTH , POPUPPANEL_MARGIN_SMALL * 3 + 15 * 6 + CUSTOM_HEIGHT + TEXT_HEIGHT + POPUPPANEL_MARGIN_LARGE + POPUP_BORDER_WIDTH + 1); - - Control VS_SPACING - { - HelpId = HID_PPROPERTYPANEL_TEXT_SPACING_VS ; - Hide = TRUE ; - Pos = MAP_APPFONT( POPUPPANEL_MARGIN_SMALL + OFFSET_X , POPUPPANEL_MARGIN_SMALL + OFFSET_Y ); - Size = MAP_APPFONT ( VS_SPACING_WIDTH , 15 * 6); - TabStop = TRUE ; - Text = "Character Spacing"; - }; - - FixedText FT_LASTCUSTOM - { - Pos = MAP_APPFONT ( POPUPPANEL_MARGIN_LARGE + OFFSET_X ,POPUPPANEL_MARGIN_SMALL + OFFSET_Y + POPUPPANEL_MARGIN_SMALL + 15 * 6) ; - Size = MAP_APPFONT ( CUSTOM_WIDTH , TEXT_HEIGHT ); - Left = TRUE ; - Text [ en-US ] = "Custom:" ; - }; - //custom area - FixedText FT_SPACING - { - Pos = MAP_APPFONT ( CUSTOM_X + POPUPPANEL_MARGIN_LARGE, CUSTOM_Y + POPUPPANEL_MARGIN_LARGE); - Size = MAP_APPFONT ( CUSTOM_WIDTH - POPUPPANEL_MARGIN_LARGE * 2 , TEXT_HEIGHT ); - Left = TRUE ; - Text [ en-US ] = "~Character spacing: " ; - }; - ListBox LB_KERNING - { - Border = TRUE; - Pos = MAP_APPFONT ( CUSTOM_X + POPUPPANEL_MARGIN_LARGE, CUSTOM_Y + POPUPPANEL_MARGIN_LARGE + TEXT_HEIGHT + POPUPPANEL_MARGIN_SMALL);//20 - Size = MAP_APPFONT ( CUSTOM_WIDTH - POPUPPANEL_MARGIN_LARGE * 2 , 80 ) ; - TabStop = TRUE; - DropDown = TRUE ; - HelpID = HID_SPACING_CB_KERN; - StringList [ en-US ] = - { - < "Default" ; Default ; > ; - < "Expanded" ; Default ; > ; - < "Condensed" ; Default ; > ; - }; - }; - FixedText FT_BY - { - Pos = MAP_APPFONT ( CUSTOM_X + POPUPPANEL_MARGIN_LARGE, CUSTOM_Y + POPUPPANEL_MARGIN_LARGE * 2 + TEXT_HEIGHT + POPUPPANEL_MARGIN_SMALL + CBOX_HEIGHT ); - Size = MAP_APPFONT ( CUSTOM_WIDTH - POPUPPANEL_MARGIN_LARGE * 2 , TEXT_HEIGHT ); - Left = TRUE ; - Text [ en-US ] = "Change ~by: " ; - }; - MetricField ED_KERNING - { - HelpID = HID_SPACING_MB_KERN; - Border = TRUE; - Pos = MAP_APPFONT ( CUSTOM_X + POPUPPANEL_MARGIN_LARGE, CUSTOM_Y + POPUPPANEL_MARGIN_LARGE * 2 + TEXT_HEIGHT * 2 + POPUPPANEL_MARGIN_SMALL * 2 + CBOX_HEIGHT);//60 - Size = MAP_APPFONT ( CUSTOM_WIDTH - POPUPPANEL_MARGIN_LARGE * 2 , MBOX_HEIGHT ); - TabStop = TRUE; - Repeat = TRUE ; - Spin = TRUE ; - Maximum = 9999 ; - DecimalDigits = 1 ; - Unit = FUNIT_POINT ; - SpinSize = 10 ; - }; - - Image IMG_NORMAL - { - ImageBitmap = Bitmap{File = "symphony/spacing_normal.bmp" ;};//"spacing_normal.bmp" - }; - Image IMG_VERY_TIGHT - { - ImageBitmap = Bitmap{File = "symphony/spacing_very tight.bmp";}; - }; - Image IMG_TIGHT - { - ImageBitmap = Bitmap{File = "symphony/spacing_tight.bmp";}; - }; - Image IMG_LOOSE - { - ImageBitmap = Bitmap{File = "symphony/spacing_loose.bmp";}; - }; - Image IMG_VERY_LOOSE - { - ImageBitmap = Bitmap{File = "symphony/spacing_very loose.bmp";}; - }; - - Image IMG_NORMAL_S - { - ImageBitmap = Bitmap{File = "symphony/spacing_normal_s.bmp";}; - }; - Image IMG_VERY_TIGHT_S - { - ImageBitmap = Bitmap{File = "symphony/spacing_very tight_s.bmp";}; - }; - Image IMG_TIGHT_S - { - ImageBitmap = Bitmap{File = "symphony/spacing_tight_s.bmp";}; - }; - Image IMG_LOOSE_S - { - ImageBitmap = Bitmap{File = "symphony/spacing_loose_s.bmp";}; - }; - Image IMG_VERY_LOOSE_S - { - ImageBitmap = Bitmap{File = "symphony/spacing_very loose_s.bmp";}; - }; - - Image IMG_CUSTOM - { - ImageBitmap = Bitmap{File = "symphony/last_custom_common.png";}; - }; - Image IMG_CUSTOM_GRAY - { - ImageBitmap = Bitmap{File = "symphony/last_custom_common_grey.png";}; - }; - - String STR_VERY_TIGHT - { - Text [ en-US ] = "Very Tight"; - }; - String STR_TIGHT - { - Text [ en-US ] = "Tight"; - }; - String STR_NORMAL - { - Text [ en-US ] = "Normal"; - }; - String STR_LOOSE - { - Text [ en-US ] = "Loose"; - }; - String STR_VERY_LOOSE - { - Text [ en-US ] = "Very Loose"; - }; - String STR_CUSTOM - { - Text [ en-US ] = "Last Custom Value"; - }; - - String STR_VERY_TIGHT_TIP - { - Text [ en-US ] = " Spacing: Condensed By: 3 pt"; - }; - String STR_TIGHT_TIP - { - Text [ en-US ] = " Spacing: Condensed By: 1.5 pt"; - }; - String STR_NORMAL_TIP - { - Text [ en-US ] = " Spacing: Normal"; - }; - String STR_LOOSE_TIP - { - Text [ en-US ] = " Spacing: Expanded By: 3 pt"; - }; - String STR_VERY_LOOSE_TIP - { - Text [ en-US ] = " Spacing: Expanded By: 6 pt"; - }; - String STR_CUSTOM_C_TIP - { - Text [ en-US ] = " Spacing: Condensed By: "; - }; - String STR_CUSTOM_E_TIP - { - Text [ en-US ] = " Spacing: Expanded By: "; - }; - String STR_PT - { - Text[ en-US ] = "pt"; - }; -}; - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/uiconfig/ui/textcharacterspacingcontrol.ui b/svx/uiconfig/ui/textcharacterspacingcontrol.ui new file mode 100644 index 000000000000..7fd26786e490 --- /dev/null +++ b/svx/uiconfig/ui/textcharacterspacingcontrol.ui @@ -0,0 +1,269 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.18.3 --> +<interface> + <requires lib="gtk+" version="3.10"/> + <object class="GtkAdjustment" id="adjustment1"> + <property name="upper">9999</property> + <property name="step_increment">1</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/spacing_very tight.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/spacing_tight.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/spacing_normal.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> + <property name="margin_right">6</property> + <property name="xalign">0</property> + <property name="pixbuf">svx/res/symphony/spacing_loose.png</property> + <property name="icon_size">1</property> + </object> + <object class="GtkImage" id="image_spacing_3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="xalign">0</property> + <property name="pixbuf">svx/res/symphony/spacing_very loose.png</property> + <property name="icon_size">1</property> + </object> + <object class="GtkImage" id="image_spacing_4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="xalign">0</property> + <property name="pixbuf">svx/res/symphony/last_custom_common.png</property> + <property name="icon_size">1</property> + </object> + <object class="GtkWindow" id="TextCharacterSpacingControl"> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="border_width">4</property> + <property name="resizable">False</property> + <property name="destroy_with_parent">True</property> + <property name="type_hint">popup-menu</property> + <property name="skip_pager_hint">True</property> + <property name="deletable">False</property> + <child> + <object class="GtkGrid" id="grid2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_right">6</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <child> + <object class="GtkButton" id="very_tight"> + <property name="label" translatable="yes">Very Tight</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="image">image_spacing_1</property> + <property name="relief">none</property> + <property name="xalign">0</property> + <property name="always_show_image">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="tight"> + <property name="label" translatable="yes">Tight</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="image">image_spacing_115</property> + <property name="relief">none</property> + <property name="xalign">0</property> + <property name="always_show_image">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="normal"> + <property name="label" translatable="yes">Normal</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="image">image_spacing_15</property> + <property name="relief">none</property> + <property name="xalign">0</property> + <property name="always_show_image">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkButton" id="loose"> + <property name="label" translatable="yes">Loose</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="image">image_spacing_2</property> + <property name="relief">none</property> + <property name="xalign">0</property> + <property name="always_show_image">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <object class="GtkFrame" id="frame1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">3</property> + <property name="margin_top">6</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <object class="GtkAlignment" id="alignment1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_top">6</property> + <property name="left_padding">12</property> + <child> + <object class="GtkGrid" id="grid3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="row_spacing">6</property> + <child> + <object class="GtkLabel" id="spacing_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Character Spacing:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">kerninglb</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="kerninglb"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <items> + <item translatable="yes">Default</item> + <item translatable="yes">Expanded</item> + <item translatable="yes">Condensed</item> + </items> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="change_by_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Change _by:</property> + <property name="use_underline">True</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="kerning:0pt"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="invisible_char">●</property> + <property name="width_chars">0</property> + <property name="adjustment">adjustment1</property> + <property name="digits">1</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">3</property> + </packing> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Custom Value</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">6</property> + </packing> + </child> + <child> + <object class="GtkButton" id="very_loose"> + <property name="label" translatable="yes">Very Loose</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="image">image_spacing_3</property> + <property name="relief">none</property> + <property name="xalign">0</property> + <property name="always_show_image">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">4</property> + </packing> + </child> + <child> + <object class="GtkButton" id="last_custom"> + <property name="label" translatable="yes">Last Custom Value</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="image">image_spacing_4</property> + <property name="relief">none</property> + <property name="xalign">0</property> + <property name="always_show_image">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">5</property> + </packing> + </child> + </object> + </child> + </object> +</interface> diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx index 54fe827fe9ac..9067e61ed0f8 100644 --- a/sw/source/uibase/app/swmodule.cxx +++ b/sw/source/uibase/app/swmodule.cxx @@ -25,6 +25,7 @@ #include <vcl/graph.hxx> #include <svtools/ehdl.hxx> #include <svx/ParaLineSpacingPopup.hxx> +#include <svx/TextCharacterSpacingPopup.hxx> #include <svx/svdobj.hxx> #include <svx/pszctrl.hxx> #include <svx/insctrl.hxx> @@ -284,6 +285,7 @@ void SwDLL::RegisterControls() SvxTbxCtlDraw::RegisterControl(SID_TRACK_CHANGES_BAR, pMod ); SwTbxAutoTextCtrl::RegisterControl(FN_GLOSSARY_DLG, pMod ); svx::ParaLineSpacingPopup::RegisterControl(SID_ATTR_PARA_LINESPACE, pMod); + svx::TextCharacterSpacingPopup::RegisterControl(SID_ATTR_CHAR_KERNING, pMod); SvxColorToolBoxControl::RegisterControl( SID_EXTRUSION_3D_COLOR, pMod ); |