From 92d43df81e282d20c129b105b2c7300a312091eb Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 4 Apr 2016 16:19:06 +0100 Subject: convert src line width popup to .ui format Change-Id: I39e8bfd89538c36c97afb3e4e86c3ba9156274e0 --- svx/Library_svx.mk | 1 - svx/UIConfig_svx.mk | 1 + svx/inc/helpid.hrc | 2 - svx/source/dialog/sdstring.src | 10 + svx/source/sidebar/line/LinePropertyPanel.cxx | 1 - svx/source/sidebar/line/LinePropertyPanel.hrc | 11 - svx/source/sidebar/line/LinePropertyPanel.hxx | 1 - svx/source/sidebar/line/LinePropertyPanel.src | 71 +---- svx/source/sidebar/line/LinePropertyPanelBase.cxx | 18 +- svx/source/sidebar/line/LineWidthControl.cxx | 323 ---------------------- svx/source/sidebar/line/LineWidthControl.hxx | 82 ------ svx/source/sidebar/line/LineWidthPopup.cxx | 229 +++++++++++++-- svx/source/sidebar/line/LineWidthValueSet.cxx | 23 +- svx/source/sidebar/line/LineWidthValueSet.hxx | 4 +- svx/uiconfig/ui/floatinglineproperty.ui | 85 ++++++ 15 files changed, 329 insertions(+), 533 deletions(-) delete mode 100644 svx/source/sidebar/line/LineWidthControl.cxx delete mode 100644 svx/source/sidebar/line/LineWidthControl.hxx create mode 100644 svx/uiconfig/ui/floatinglineproperty.ui (limited to 'svx') diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk index 8869014381a7..b22dfa2ad999 100644 --- a/svx/Library_svx.mk +++ b/svx/Library_svx.mk @@ -194,7 +194,6 @@ $(eval $(call gb_Library_add_exception_objects,svx,\ svx/source/sidebar/graphic/GraphicPropertyPanel \ svx/source/sidebar/line/LinePropertyPanel \ svx/source/sidebar/line/LinePropertyPanelBase \ - svx/source/sidebar/line/LineWidthControl \ svx/source/sidebar/line/LineWidthValueSet \ svx/source/sidebar/line/LineWidthPopup \ svx/source/sidebar/possize/PosSizePropertyPanel \ diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk index 39df1db7c2b8..c7853f8778c6 100644 --- a/svx/UIConfig_svx.mk +++ b/svx/UIConfig_svx.mk @@ -36,6 +36,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\ svx/uiconfig/ui/extrustiondepthdialog \ svx/uiconfig/ui/findreplacedialog \ svx/uiconfig/ui/floatingcontour \ + svx/uiconfig/ui/floatinglineproperty \ svx/uiconfig/ui/floatingundoredo \ svx/uiconfig/ui/fontworkgallerydialog \ svx/uiconfig/ui/fontworkspacingdialog \ diff --git a/svx/inc/helpid.hrc b/svx/inc/helpid.hrc index 82269b1c8da7..66b01938e985 100644 --- a/svx/inc/helpid.hrc +++ b/svx/inc/helpid.hrc @@ -89,8 +89,6 @@ #define HID_PPROPERTYPANEL_AREA_BTN_LEFT_SECOND "SVX_HID_PPROPERTYPANEL_AREA_BTN_LEFT_SECOND" #define HID_PPROPERTYPANEL_AREA_BTN_RIGHT_FIRST "SVX_HID_PPROPERTYPANEL_AREA_BTN_RIGHT_FIRST" #define HID_PPROPERTYPANEL_TEXT_UNDERLINE_VS "SVX_HID_PPROPERTYPANEL_TEXT_UNDERLINE_VS" -#define HID_PPROPERTYPANEL_LINE_VS_WIDTH "SVX_HID_PPROPERTYPANEL_LINE_VS_WIDTH" -#define HID_PPROPERTYPANEL_LINE_MTR_WIDTH "SVX_HID_PPROPERTYPANEL_LINE_MTR_WIDTH" #define HID_PPROPERTYPANEL_TEXT_SPACING_VS "SVX_HID_PPROPERTYPANEL_TEXT_SPACING_VS" #define HID_PPROPERTYPANEL_AREA_LB_FILL_TYPES "SVX_HID_PPROPERTYPANEL_AREA_LB_FILL_TYPES" diff --git a/svx/source/dialog/sdstring.src b/svx/source/dialog/sdstring.src index ce7ed3c392e1..e4726d81c886 100644 --- a/svx/source/dialog/sdstring.src +++ b/svx/source/dialog/sdstring.src @@ -2362,4 +2362,14 @@ String RID_SVXSTR_RECOVERYONLY_FINISH Text[ en-US ] = "~Finish"; }; +String RID_SVXSTR_WIDTH_LAST_CUSTOM +{ + Text[ en-US ] = "Last Custom Value"; +}; + +String RID_SVXSTR_PT +{ + Text[ en-US ] = "pt"; +}; + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sidebar/line/LinePropertyPanel.cxx b/svx/source/sidebar/line/LinePropertyPanel.cxx index 135bd210af39..925cd2056dd8 100644 --- a/svx/source/sidebar/line/LinePropertyPanel.cxx +++ b/svx/source/sidebar/line/LinePropertyPanel.cxx @@ -48,7 +48,6 @@ #include #include "svx/sidebar/PopupContainer.hxx" #include "svx/sidebar/PopupControl.hxx" -#include "LineWidthControl.hxx" using namespace css; using namespace css::uno; diff --git a/svx/source/sidebar/line/LinePropertyPanel.hrc b/svx/source/sidebar/line/LinePropertyPanel.hrc index 764ebfd2d7cc..dc46dd81784a 100644 --- a/svx/source/sidebar/line/LinePropertyPanel.hrc +++ b/svx/source/sidebar/line/LinePropertyPanel.hrc @@ -25,15 +25,4 @@ //style popup page #define PB_OPTIONS 2 -//width popup page -#define VS_WIDTH 1 -#define MF_WIDTH 2 -#define FT_CUSTOME 3 -#define FT_LINE_WIDTH 4 -#define IMG_WIDTH_CUSTOM 5 -#define IMG_WIDTH_CUSTOM_GRAY 6 -#define CT_BORDER 7 -#define STR_WIDTH_LAST_CUSTOM 8 -#define STR_PT 9 - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sidebar/line/LinePropertyPanel.hxx b/svx/source/sidebar/line/LinePropertyPanel.hxx index 594109bdac00..595cc457290a 100644 --- a/svx/source/sidebar/line/LinePropertyPanel.hxx +++ b/svx/source/sidebar/line/LinePropertyPanel.hxx @@ -56,7 +56,6 @@ namespace sidebar { class PopupContainer; -class LineWidthControl; class LinePropertyPanel : public LinePropertyPanelBase, public sfx2::sidebar::IContextChangeReceiver, diff --git a/svx/source/sidebar/line/LinePropertyPanel.src b/svx/source/sidebar/line/LinePropertyPanel.src index 28ccd5d90a7a..41dbb970b257 100644 --- a/svx/source/sidebar/line/LinePropertyPanel.src +++ b/svx/source/sidebar/line/LinePropertyPanel.src @@ -58,72 +58,13 @@ Image IMG_WIDTH8_ICON { ImageBitmap = Bitmap{File = "symphony/width8.png";}; }; - -Control RID_POPUPPANEL_LINEPAGE_WIDTH +Image RID_SVXIMG_WIDTH_CUSTOM { - OutputSize = TRUE; - DialogControl = TRUE; - Border = FALSE; - - Size = MAP_APPFONT( POPUPPANEL_MARGIN_SMALL * 2 + POPUP_BORDER_WIDTH + 80, POPUPPANEL_MARGIN_SMALL + POPUPPANEL_MARGIN_LARGE + POPUP_BORDER_WIDTH + 12 * 9 + POPUPPANEL_MARGIN_SMALL * 2 + TEXT_HEIGHT + (POPUPPANEL_MARGIN_LARGE * 2 + TEXT_HEIGHT + 12 + TEXT_CONTROL_SPACING_VERTICAL)); - - Control VS_WIDTH - { - HelpId = HID_PPROPERTYPANEL_LINE_VS_WIDTH ; - Hide = TRUE ; - Pos = MAP_APPFONT( POPUPPANEL_MARGIN_SMALL + OFFSET_X , POPUPPANEL_MARGIN_SMALL + OFFSET_Y ); - Size = MAP_APPFONT ( 80 , 12 * 9); - TabStop = TRUE ; - Text = "Width"; - }; - FixedText FT_CUSTOME - { - Pos = MAP_APPFONT ( POPUPPANEL_MARGIN_LARGE + OFFSET_X, POPUPPANEL_MARGIN_SMALL + OFFSET_Y + 12 * 9 + POPUPPANEL_MARGIN_SMALL ) ; - Size = MAP_APPFONT ( 80 , TEXT_HEIGHT ) ; - Text [ en-US ] = "Custom:" ; - }; - FixedText FT_LINE_WIDTH - { - Pos = MAP_APPFONT ( CUSTOM_X + POPUPPANEL_MARGIN_LARGE, CUSTOM_Y + POPUPPANEL_MARGIN_LARGE) ; - Size = MAP_APPFONT ( 74 - POPUPPANEL_MARGIN_LARGE * 2 , TEXT_HEIGHT ) ; - Text [ en-US ] = "Line ~width:" ; - }; - MetricField MF_WIDTH - { - Border = TRUE ; - HelpID = HID_PPROPERTYPANEL_LINE_MTR_WIDTH ; - Pos = MAP_APPFONT ( CUSTOM_X + POPUPPANEL_MARGIN_LARGE , CUSTOM_Y + POPUPPANEL_MARGIN_LARGE + TEXT_HEIGHT + TEXT_CONTROL_SPACING_VERTICAL) ; - Size = MAP_APPFONT ( 40 , 12 ) ; - TabStop = TRUE ; - Right = TRUE ; - Repeat = TRUE ; - Spin = TRUE ; - Maximum = 5000 ; - StrictFormat = TRUE ; - DecimalDigits = 2 ; - Value = 1 ; - Unit = FUNIT_MM ; - Last = 5000 ; - SpinSize = 10 ; - QuickHelpText [ en-US ] = "Specify the width of the line."; - }; - - Image IMG_WIDTH_CUSTOM - { - ImageBitmap = Bitmap{File = "symphony/last_custom_common.png";}; - }; - Image IMG_WIDTH_CUSTOM_GRAY - { - ImageBitmap = Bitmap{File = "symphony/last_custom_common_grey.png";}; - }; - String STR_WIDTH_LAST_CUSTOM - { - Text [ en-US ] = "Last Custom Value"; - }; - String STR_PT - { - Text [ en-US ] = "pt"; - }; + ImageBitmap = Bitmap{File = "symphony/last_custom_common.png";}; +}; +Image RID_SVXIMG_WIDTH_CUSTOM_GRAY +{ + ImageBitmap = Bitmap{File = "symphony/last_custom_common_grey.png";}; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sidebar/line/LinePropertyPanelBase.cxx b/svx/source/sidebar/line/LinePropertyPanelBase.cxx index 2c99eb90a2f8..2efc6d63e521 100644 --- a/svx/source/sidebar/line/LinePropertyPanelBase.cxx +++ b/svx/source/sidebar/line/LinePropertyPanelBase.cxx @@ -48,7 +48,6 @@ #include #include "svx/sidebar/PopupContainer.hxx" #include "svx/sidebar/PopupControl.hxx" -#include "LineWidthControl.hxx" using namespace css; using namespace css::uno; @@ -174,7 +173,7 @@ LinePropertyPanelBase::LinePropertyPanelBase( mnWidthCoreValue(0), mpStartItem(), mpEndItem(), - maLineWidthPopup(this, [this] (PopupContainer *const pContainer) { return this->CreateLineWidthPopupControl(pContainer); }), + mxLineWidthPopup(VclPtr::Create(*this)), maIMGNone(SVX_RES(IMG_NONE_ICON)), mpIMGWidthIcon(), mbWidthValuable(true), @@ -205,6 +204,7 @@ LinePropertyPanelBase::~LinePropertyPanelBase() void LinePropertyPanelBase::dispose() { + mxLineWidthPopup.disposeAndClear(); mpFTWidth.clear(); mpTBWidth.clear(); mpTBColor.clear(); @@ -683,8 +683,8 @@ IMPL_LINK_TYPED(LinePropertyPanelBase, ToolboxWidthSelectHdl,ToolBox*, pToolBox, { if (pToolBox->GetItemCommand(pToolBox->GetCurItemId()) == UNO_SELECTWIDTH) { - maLineWidthPopup.SetWidthSelect(mnWidthCoreValue, mbWidthValuable, meMapUnit); - maLineWidthPopup.Show(*pToolBox); + mxLineWidthPopup->SetWidthSelect(mnWidthCoreValue, mbWidthValuable, meMapUnit); + mxLineWidthPopup->StartPopupMode(pToolBox, FloatWinPopupFlags::GrabFocus); } } @@ -696,16 +696,6 @@ IMPL_LINK_NOARG_TYPED( LinePropertyPanelBase, ChangeTransparentHdl, Edit&, void setLineTransparency(aItem); } -VclPtr LinePropertyPanelBase::CreateLineWidthPopupControl (PopupContainer* pParent) -{ - return VclPtrInstance(pParent, *this); -} - -void LinePropertyPanelBase::EndLineWidthPopupMode() -{ - maLineWidthPopup.Hide(); -} - void LinePropertyPanelBase::SetWidthIcon(int n) { const sal_uInt16 nIdWidth = mpTBWidth->GetItemId(UNO_SELECTWIDTH); diff --git a/svx/source/sidebar/line/LineWidthControl.cxx b/svx/source/sidebar/line/LineWidthControl.cxx deleted file mode 100644 index c938102c401f..000000000000 --- a/svx/source/sidebar/line/LineWidthControl.cxx +++ /dev/null @@ -1,323 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#include "LineWidthControl.hxx" -#include "LinePropertyPanel.hrc" -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "svx/sidebar/PopupContainer.hxx" - -namespace svx { namespace sidebar { - -LineWidthControl::LineWidthControl ( - vcl::Window* pParent, - LinePropertyPanelBase& rPanel) - : svx::sidebar::PopupControl(pParent,SVX_RES(RID_POPUPPANEL_LINEPAGE_WIDTH)), - mrLinePropertyPanel(rPanel), - maVSWidth(VclPtr::Create(this, SVX_RES(VS_WIDTH))), - maFTCus( VclPtr::Create(this, SVX_RES(FT_CUSTOME))), - maFTWidth( VclPtr::Create(this, SVX_RES(FT_LINE_WIDTH))), - maMFWidth( VclPtr::Create(this, SVX_RES(MF_WIDTH))), - meMapUnit(SFX_MAPUNIT_TWIP), - rStr(nullptr), - mstrPT(SVX_RESSTR(STR_PT)), - mnCustomWidth(0), - mbCustom(false), - mbCloseByEdit(false), - mnTmpCustomWidth(0), - mbVSFocus(true), - maIMGCus(SVX_RES(IMG_WIDTH_CUSTOM)), - maIMGCusGray(SVX_RES(IMG_WIDTH_CUSTOM_GRAY)) -{ - Initialize(); - FreeResource(); -} - -LineWidthControl::~LineWidthControl() -{ - disposeOnce(); -} - -void LineWidthControl::dispose() -{ - delete[] rStr; - maVSWidth.disposeAndClear(); - maFTCus.disposeAndClear(); - maFTWidth.disposeAndClear(); - maMFWidth.disposeAndClear(); - svx::sidebar::PopupControl::dispose(); -} - -void LineWidthControl::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rect) -{ - svx::sidebar::PopupControl::Paint(rRenderContext, rect); - - rRenderContext.Push(PushFlags::LINECOLOR | PushFlags::FILLCOLOR); - - Point aPos(rRenderContext.LogicToPixel(Point(CUSTOM_X, CUSTOM_Y), MAP_APPFONT)); - Size aSize(rRenderContext.LogicToPixel(Size(CUSTOM_W, CUSTOM_H), MAP_APPFONT)); - Rectangle aRect(aPos, aSize); - aRect.Left() -= 1; - aRect.Top() -= 1; - aRect.Right() += 1; - aRect.Bottom() += 1; - - Color aLineColor(189, 201, 219); - if (!GetSettings().GetStyleSettings().GetHighContrastMode()) - rRenderContext.SetLineColor(aLineColor); - else - rRenderContext.SetLineColor(GetSettings().GetStyleSettings().GetShadowColor()); - rRenderContext.SetFillColor(COL_TRANSPARENT); - rRenderContext.DrawRect(aRect); - - rRenderContext.Pop(); -} - -void LineWidthControl::Initialize() -{ - maVSWidth->SetStyle( maVSWidth->GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT );// WB_NAMEFIELD | WB_ITEMBORDER |WB_DOUBLEBORDER | WB_NONEFIELD | - //for high contrast wj - if(GetSettings().GetStyleSettings().GetHighContrastMode()) - { - maVSWidth->SetColor(GetSettings().GetStyleSettings().GetMenuColor()); - // maBorder.SetBackground(GetSettings().GetStyleSettings().GetMenuColor()); - maFTWidth->SetBackground(GetSettings().GetStyleSettings().GetMenuColor()); - } - else - { - maVSWidth->SetColor(COL_WHITE); - // maBorder.SetBackground(Wallpaper(COL_WHITE)); - maFTWidth->SetBackground(Wallpaper(COL_WHITE)); - } - - sal_Int64 nFirst= maMFWidth->Denormalize( maMFWidth->GetFirst( FUNIT_TWIP ) ); - sal_Int64 nLast = maMFWidth->Denormalize( maMFWidth->GetLast( FUNIT_TWIP ) ); - sal_Int64 nMin = maMFWidth->Denormalize( maMFWidth->GetMin( FUNIT_TWIP ) ); - sal_Int64 nMax = maMFWidth->Denormalize( maMFWidth->GetMax( FUNIT_TWIP ) ); - maMFWidth->SetSpinSize( 10 ); - maMFWidth->SetUnit( FUNIT_POINT ); - if( maMFWidth->GetDecimalDigits() > 1 ) - maMFWidth->SetDecimalDigits( 1 ); - maMFWidth->SetFirst( maMFWidth->Normalize( nFirst ), FUNIT_TWIP ); - maMFWidth->SetLast( maMFWidth->Normalize( nLast ), FUNIT_TWIP ); - maMFWidth->SetMin( maMFWidth->Normalize( nMin ), FUNIT_TWIP ); - maMFWidth->SetMax( maMFWidth->Normalize( nMax ), FUNIT_TWIP ); - - rStr = new OUString[9]; - //modify, - rStr[0] = "0.5"; - rStr[1] = "0.8"; - rStr[2] = "1.0"; - rStr[3] = "1.5"; - rStr[4] = "2.3"; - rStr[5] = "3.0"; - rStr[6] = "4.5"; - rStr[7] = "6.0"; - rStr[8] = SVX_RESSTR(STR_WIDTH_LAST_CUSTOM); - - const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() ); - const sal_Unicode cSep = rLocaleWrapper.getNumDecimalSep()[0]; - - for(int i = 0; i <= 7 ; i++) - { - rStr[i] = rStr[i].replace('.', cSep);//Modify - rStr[i] += " "; - rStr[i] += mstrPT; - } - //end - - for(sal_uInt16 i = 1 ; i <= 9 ; i++) - { - maVSWidth->InsertItem(i); - maVSWidth->SetItemText(i, rStr[i-1]); - } - maVSWidth->SetUnit(rStr); - maVSWidth->SetItemData(1, reinterpret_cast(5)); - maVSWidth->SetItemData(2, reinterpret_cast(8)); - maVSWidth->SetItemData(3, reinterpret_cast(10)); - maVSWidth->SetItemData(4, reinterpret_cast(15)); - maVSWidth->SetItemData(5, reinterpret_cast(23)); - maVSWidth->SetItemData(6, reinterpret_cast(30)); - maVSWidth->SetItemData(7, reinterpret_cast(45)); - maVSWidth->SetItemData(8, reinterpret_cast(60)); - maVSWidth->SetImage(maIMGCusGray); - - maVSWidth->SetSelItem(0); - - maVSWidth->SetSelectHdl(LINK( this, LineWidthControl, VSSelectHdl )); - maMFWidth->SetModifyHdl(LINK(this, LineWidthControl, MFModifyHdl)); - - maVSWidth->StartSelection(); - maVSWidth->Show(); -} - -void LineWidthControl::GetFocus() -{ - if (!mbVSFocus && maMFWidth) - maMFWidth->GrabFocus(); - else if (maVSWidth) - maVSWidth->GrabFocus(); -} - -void LineWidthControl::SetWidthSelect( long lValue, bool bValuable, SfxMapUnit eMapUnit) -{ - mbVSFocus = true; - maVSWidth->SetSelItem(0); - mbCloseByEdit = false; - meMapUnit = eMapUnit; - SvtViewOptions aWinOpt( E_WINDOW, SIDEBAR_LINE_WIDTH_GLOBAL_VALUE ); - if (aWinOpt.Exists()) - { - css::uno::Sequence aSeq = aWinOpt.GetUserData(); - OUString aTmp; - if ( aSeq.getLength()) - aSeq[0].Value >>= aTmp; - - OUString aWinData( aTmp ); - mnCustomWidth = aWinData.toInt32(); - mbCustom = true; - maVSWidth->SetImage(maIMGCus); - maVSWidth->SetCusEnable(true); - - OUString aStrTip( OUString::number( (double)mnCustomWidth / 10)); - aStrTip += mstrPT; - maVSWidth->SetItemText(9, aStrTip); - } - else - { - mbCustom = false; - maVSWidth->SetImage(maIMGCusGray); - maVSWidth->SetCusEnable(false); - //modify - //String aStrTip(String(SVX_RES(STR_WIDTH_LAST_CUSTOM))); - //maVSWidth->SetItemText(9, aStrTip); - maVSWidth->SetItemText(9, rStr[8]); - } - - if (bValuable) - { - sal_Int64 nVal = OutputDevice::LogicToLogic(lValue, (MapUnit) eMapUnit, MAP_100TH_MM ); - nVal = maMFWidth->Normalize(nVal); - maMFWidth->SetValue( nVal, FUNIT_100TH_MM ); - } - else - { - maMFWidth->SetText( "" ); - } - - OUString strCurrValue = maMFWidth->GetText(); - sal_uInt16 i = 0; - for(; i < 8; i++) - { - if(strCurrValue == rStr[i]) - { - maVSWidth->SetSelItem(i+1); - break; - } - } - - if (i>=8) - { - mbVSFocus = false; - maVSWidth->SetSelItem(0); - } - maVSWidth->SetFormat(); - maVSWidth->Invalidate(); - maVSWidth->StartSelection(); -} - -IMPL_LINK_TYPED(LineWidthControl, VSSelectHdl, ValueSet*, pControl, void) -{ - if (pControl == maVSWidth.get()) - { - sal_uInt16 iPos = maVSWidth->GetSelectItemId(); - if (iPos >= 1 && iPos <= 8) - { - sal_IntPtr nVal = LogicToLogic(reinterpret_cast(maVSWidth->GetItemData( iPos )), MAP_POINT, (MapUnit)meMapUnit); - nVal = maMFWidth->Denormalize(nVal); - XLineWidthItem aWidthItem( nVal ); - mrLinePropertyPanel.setLineWidth(aWidthItem); - mrLinePropertyPanel.SetWidthIcon(iPos); - mrLinePropertyPanel.SetWidth(nVal); - mbCloseByEdit = false; - mnTmpCustomWidth = 0; - } - else if (iPos == 9) - {//last custom - //modified - if (mbCustom) - { - long nVal = LogicToLogic(mnCustomWidth , MAP_POINT, (MapUnit)meMapUnit); - nVal = maMFWidth->Denormalize(nVal); - XLineWidthItem aWidthItem( nVal ); - mrLinePropertyPanel.setLineWidth(aWidthItem); - mrLinePropertyPanel.SetWidth(nVal); - mbCloseByEdit = false; - mnTmpCustomWidth = 0; - } - else - { - maVSWidth->SetNoSelection(); //add , set no selection and keep the last select item - maVSWidth->SetFormat(); - maVSWidth->Invalidate(); - Invalidate(); - maVSWidth->StartSelection(); - } - //modify end - } - if ((iPos >= 1 && iPos <= 8) || (iPos == 9 && mbCustom)) //add - mrLinePropertyPanel.EndLineWidthPopupMode(); - } -} - -IMPL_LINK_TYPED(LineWidthControl, MFModifyHdl, Edit&, rControl, void) -{ - if (&rControl == maMFWidth.get()) - { - if(maVSWidth->GetSelItem()) - { - maVSWidth->SetSelItem(0); - maVSWidth->SetFormat(); - maVSWidth->Invalidate(); - Invalidate(); - maVSWidth->StartSelection(); - } - long nTmp = static_cast(maMFWidth->GetValue()); - long nVal = LogicToLogic( nTmp, MAP_POINT, (MapUnit)meMapUnit ); - sal_Int32 nNewWidth = (short)maMFWidth->Denormalize( nVal ); - XLineWidthItem aWidthItem(nNewWidth); - mrLinePropertyPanel.setLineWidth(aWidthItem); - - mbCloseByEdit = true; - mnTmpCustomWidth = nTmp; - } -} - -} } // end of namespace svx::sidebar - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sidebar/line/LineWidthControl.hxx b/svx/source/sidebar/line/LineWidthControl.hxx deleted file mode 100644 index faad9d751d31..000000000000 --- a/svx/source/sidebar/line/LineWidthControl.hxx +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * 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_LINE_LINEWIDTHCONTROL_HXX -#define INCLUDED_SVX_SOURCE_SIDEBAR_LINE_LINEWIDTHCONTROL_HXX - -#include "svx/sidebar/PopupControl.hxx" -#include "LineWidthValueSet.hxx" -#include -#include -#include - -class SfxBindings; - -namespace svx { namespace sidebar { - -class LinePropertyPanelBase; - -class LineWidthControl : public svx::sidebar::PopupControl -{ -public: - LineWidthControl (vcl::Window* pParent, LinePropertyPanelBase& rPanel); - virtual ~LineWidthControl(); - virtual void dispose() override; - - virtual void GetFocus() override; - virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& aRect) override; - - void SetWidthSelect( long lValue, bool bValuable, SfxMapUnit eMapUnit); - bool IsCloseByEdit() - { - return mbCloseByEdit; - } - long GetTmpCustomWidth() - { - return mnTmpCustomWidth; - } - -private: - LinePropertyPanelBase& mrLinePropertyPanel; - VclPtr maVSWidth; - VclPtr maFTCus; - VclPtr maFTWidth; - VclPtr maMFWidth; - SfxMapUnit meMapUnit; - OUString* rStr; - OUString mstrPT; - long mnCustomWidth; - bool mbCustom; - bool mbCloseByEdit; - long mnTmpCustomWidth; - bool mbVSFocus; - - Image maIMGCus; - Image maIMGCusGray; - - void Initialize(); - DECL_LINK_TYPED(VSSelectHdl, ValueSet*, void); - DECL_LINK_TYPED(MFModifyHdl, Edit&, void); -}; - -} } // end of namespace svx::sidebar - -#endif // INCLUDED_SVX_SOURCE_SIDEBAR_LINE_LINEWIDTHCONTROL_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sidebar/line/LineWidthPopup.cxx b/svx/source/sidebar/line/LineWidthPopup.cxx index 02cc9022fdab..9112eb8d0473 100644 --- a/svx/source/sidebar/line/LineWidthPopup.cxx +++ b/svx/source/sidebar/line/LineWidthPopup.cxx @@ -17,52 +17,231 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include -#include "LineWidthControl.hxx" - #include - +#include +#include +#include #include - +#include +#include "LineWidthValueSet.hxx" namespace svx { namespace sidebar { -LineWidthPopup::LineWidthPopup ( - vcl::Window* pParent, - const ::std::function& rControlCreator) - : Popup( - pParent, - rControlCreator, - OUString( "Width")) +LineWidthPopup::LineWidthPopup(LinePropertyPanelBase& rParent) + : FloatingWindow(&rParent, "FloatingLineProperty", "svx/ui/floatinglineproperty.ui") + , m_rParent(rParent) + , m_pStr(nullptr) + , m_sPt(SVX_RESSTR(RID_SVXSTR_PT)) + , m_eMapUnit(SFX_MAPUNIT_TWIP) + , m_bVSFocus(true) + , m_bCustom(false) + , m_bCloseByEdit(false) + , m_nCustomWidth(0) + , m_nTmpCustomWidth(0) + , m_aIMGCus(SVX_RES(RID_SVXIMG_WIDTH_CUSTOM)) + , m_aIMGCusGray(SVX_RES(RID_SVXIMG_WIDTH_CUSTOM_GRAY)) { - SetPopupModeEndHandler([this] () { return this->PopupModeEndCallback(); }); + get(m_xMFWidth, "spin"); + + get(m_xBox, "box"); + + m_xVSWidth = VclPtr::Create(m_xBox); + + m_xVSWidth->SetStyle(m_xVSWidth->GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT); + + m_pStr = new OUString[9]; + + m_pStr[0] = "0.5"; + m_pStr[1] = "0.8"; + m_pStr[2] = "1.0"; + m_pStr[3] = "1.5"; + m_pStr[4] = "2.3"; + m_pStr[5] = "3.0"; + m_pStr[6] = "4.5"; + m_pStr[7] = "6.0"; + m_pStr[8] = SVX_RESSTR(RID_SVXSTR_WIDTH_LAST_CUSTOM); + + const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() ); + const sal_Unicode cSep = rLocaleWrapper.getNumDecimalSep()[0]; + + for(int i = 0; i <= 7 ; i++) + { + m_pStr[i] = m_pStr[i].replace('.', cSep);//Modify + m_pStr[i] += " "; + m_pStr[i] += m_sPt; + } + + for (sal_uInt16 i = 1 ; i <= 9; ++i) + { + m_xVSWidth->InsertItem(i); + m_xVSWidth->SetItemText(i, m_pStr[i-1]); + } + + m_xVSWidth->SetUnit(m_pStr); + m_xVSWidth->SetItemData(1, reinterpret_cast(5)); + m_xVSWidth->SetItemData(2, reinterpret_cast(8)); + m_xVSWidth->SetItemData(3, reinterpret_cast(10)); + m_xVSWidth->SetItemData(4, reinterpret_cast(15)); + m_xVSWidth->SetItemData(5, reinterpret_cast(23)); + m_xVSWidth->SetItemData(6, reinterpret_cast(30)); + m_xVSWidth->SetItemData(7, reinterpret_cast(45)); + m_xVSWidth->SetItemData(8, reinterpret_cast(60)); + m_xVSWidth->SetImage(m_aIMGCusGray); + + m_xVSWidth->SetSelItem(0); + + m_xVSWidth->SetSelectHdl(LINK(this, LineWidthPopup, VSSelectHdl)); + m_xMFWidth->SetModifyHdl(LINK(this, LineWidthPopup, MFModifyHdl)); + + m_xVSWidth->StartSelection(); + m_xVSWidth->Show(); +} + +void LineWidthPopup::dispose() +{ + delete[] m_pStr; + m_xVSWidth.disposeAndClear(); + m_xBox.clear(); + m_xMFWidth.clear(); + FloatingWindow::dispose(); } LineWidthPopup::~LineWidthPopup() { + disposeOnce(); } -void LineWidthPopup::SetWidthSelect (long lValue, bool bValuable, SfxMapUnit eMapUnit) +IMPL_LINK_TYPED(LineWidthPopup, VSSelectHdl, ValueSet*, /*pControl*/, void) { - ProvideContainerAndControl(); + sal_uInt16 iPos = m_xVSWidth->GetSelectItemId(); + if (iPos >= 1 && iPos <= 8) + { + sal_IntPtr nVal = LogicToLogic(reinterpret_cast(m_xVSWidth->GetItemData( iPos )), MAP_POINT, (MapUnit)m_eMapUnit); + nVal = m_xMFWidth->Denormalize(nVal); + XLineWidthItem aWidthItem( nVal ); + m_rParent.setLineWidth(aWidthItem); + m_rParent.SetWidthIcon(iPos); + m_rParent.SetWidth(nVal); + m_bCloseByEdit = false; + m_nTmpCustomWidth = 0; + } + else if (iPos == 9) + {//last custom + //modified + if (m_bCustom) + { + long nVal = LogicToLogic(m_nCustomWidth , MAP_POINT, (MapUnit)m_eMapUnit); + nVal = m_xMFWidth->Denormalize(nVal); + XLineWidthItem aWidthItem( nVal ); + m_rParent.setLineWidth(aWidthItem); + m_rParent.SetWidth(nVal); + m_bCloseByEdit = false; + m_nTmpCustomWidth = 0; + } + else + { + m_xVSWidth->SetNoSelection(); //add , set no selection and keep the last select item + m_xVSWidth->SetFormat(); + m_xVSWidth->Invalidate(); + Invalidate(); + m_xVSWidth->StartSelection(); + } + //modify end + } + if ((iPos >= 1 && iPos <= 8) || (iPos == 9 && m_bCustom)) //add + { + EndPopupMode(); + } +} - LineWidthControl* pControl = dynamic_cast(mxControl.get()); - if (pControl != nullptr) - pControl->SetWidthSelect(lValue, bValuable, eMapUnit); +IMPL_LINK_TYPED(LineWidthPopup, MFModifyHdl, Edit&, /*rControl*/, void) +{ + if (m_xVSWidth->GetSelItem()) + { + m_xVSWidth->SetSelItem(0); + m_xVSWidth->SetFormat(); + m_xVSWidth->Invalidate(); + Invalidate(); + m_xVSWidth->StartSelection(); + } + long nTmp = static_cast(m_xMFWidth->GetValue()); + long nVal = LogicToLogic( nTmp, MAP_POINT, (MapUnit)m_eMapUnit ); + sal_Int32 nNewWidth = (short)m_xMFWidth->Denormalize( nVal ); + XLineWidthItem aWidthItem(nNewWidth); + m_rParent.setLineWidth(aWidthItem); + + m_bCloseByEdit = true; + m_nTmpCustomWidth = nTmp; } -void LineWidthPopup::PopupModeEndCallback() +void LineWidthPopup::SetWidthSelect(long lValue, bool bValuable, SfxMapUnit eMapUnit) { - LineWidthControl* pControl = dynamic_cast(mxControl.get()); - if (pControl != nullptr) + m_bVSFocus = true; + m_xVSWidth->SetSelItem(0); + m_bCloseByEdit = false; + m_eMapUnit = eMapUnit; + SvtViewOptions aWinOpt( E_WINDOW, SIDEBAR_LINE_WIDTH_GLOBAL_VALUE ); + if (aWinOpt.Exists()) + { + css::uno::Sequence aSeq = aWinOpt.GetUserData(); + OUString aTmp; + if ( aSeq.getLength()) + aSeq[0].Value >>= aTmp; + + OUString aWinData( aTmp ); + m_nCustomWidth = aWinData.toInt32(); + m_bCustom = true; + m_xVSWidth->SetImage(m_aIMGCus); + m_xVSWidth->SetCusEnable(true); + + OUString aStrTip( OUString::number( (double)m_nCustomWidth / 10)); + aStrTip += m_sPt; + m_xVSWidth->SetItemText(9, aStrTip); + } + else { - if (pControl->IsCloseByEdit()) + m_bCustom = false; + m_xVSWidth->SetImage(m_aIMGCusGray); + m_xVSWidth->SetCusEnable(false); + m_xVSWidth->SetItemText(9, m_pStr[8]); + } + + if (bValuable) + { + sal_Int64 nVal = OutputDevice::LogicToLogic(lValue, (MapUnit) eMapUnit, MAP_100TH_MM ); + nVal = m_xMFWidth->Normalize(nVal); + m_xMFWidth->SetValue( nVal, FUNIT_100TH_MM ); + } + else + { + m_xMFWidth->SetText( "" ); + } + + OUString strCurrValue = m_xMFWidth->GetText(); + sal_uInt16 i = 0; + for(; i < 8; i++) + { + if (strCurrValue == m_pStr[i]) { - SvtViewOptions aWinOpt( E_WINDOW, SIDEBAR_LINE_WIDTH_GLOBAL_VALUE ); - css::uno::Sequence < css::beans::NamedValue > aSeq - { { "LineWidth", css::uno::makeAny(OUString::number(pControl->GetTmpCustomWidth())) } }; - aWinOpt.SetUserData( aSeq ); + m_xVSWidth->SetSelItem(i+1); + break; } } + + if (i>=8) + { + m_bVSFocus = false; + m_xVSWidth->SetSelItem(0); + } + + m_xVSWidth->SetFormat(); + m_xVSWidth->Invalidate(); + m_xVSWidth->StartSelection(); + + if (m_bVSFocus) + m_xVSWidth->GrabFocus(); + else + m_xMFWidth->GrabFocus(); } } } // end of namespace svx::sidebar diff --git a/svx/source/sidebar/line/LineWidthValueSet.cxx b/svx/source/sidebar/line/LineWidthValueSet.cxx index a260709bb678..d4172d420267 100644 --- a/svx/source/sidebar/line/LineWidthValueSet.cxx +++ b/svx/source/sidebar/line/LineWidthValueSet.cxx @@ -23,16 +23,20 @@ namespace svx { namespace sidebar { -LineWidthValueSet::LineWidthValueSet ( - vcl::Window* pParent, const ResId& rResId) - : ValueSet( pParent, rResId ), - pVDev(nullptr), - nSelItem(0), - bCusEnable(false) +LineWidthValueSet::LineWidthValueSet(vcl::Window* pParent) + : ValueSet(pParent, WB_TABSTOP) + , pVDev(nullptr) + , nSelItem(0) + , bCusEnable(false) { strUnit = new OUString[9]; +} + +void LineWidthValueSet::Resize() +{ SetColCount(); - SetLineCount( 9); + SetLineCount(9); + ValueSet::Resize(); } LineWidthValueSet::~LineWidthValueSet() @@ -167,6 +171,11 @@ void LineWidthValueSet::UserDraw( const UserDrawEvent& rUDEvt ) pDev->SetFont(aOldFont); } +Size LineWidthValueSet::GetOptimalSize() const +{ + return LogicToPixel(Size(80, 12 * 9), MAP_APPFONT); +} + } } // end of namespace svx::sidebar /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sidebar/line/LineWidthValueSet.hxx b/svx/source/sidebar/line/LineWidthValueSet.hxx index b99e0dbbb402..36a17ad3d45d 100644 --- a/svx/source/sidebar/line/LineWidthValueSet.hxx +++ b/svx/source/sidebar/line/LineWidthValueSet.hxx @@ -28,7 +28,7 @@ class LineWidthValueSet : public ValueSet { public: - LineWidthValueSet (vcl::Window* pParent, const ResId& rResId); + LineWidthValueSet(vcl::Window* pParent); virtual ~LineWidthValueSet(); virtual void dispose() override; @@ -39,6 +39,8 @@ public: void SetCusEnable(bool bEnable); virtual void UserDraw( const UserDrawEvent& rUDEvt ) override; + virtual void Resize() override; + virtual Size GetOptimalSize() const override; protected: VclPtr pVDev; diff --git a/svx/uiconfig/ui/floatinglineproperty.ui b/svx/uiconfig/ui/floatinglineproperty.ui new file mode 100644 index 000000000000..17daafe0e836 --- /dev/null +++ b/svx/uiconfig/ui/floatinglineproperty.ui @@ -0,0 +1,85 @@ + + + + + + 500 + 1 + 10 + + + True + True + True + True + 6 + False + True + popup-menu + True + False + + + True + False + True + True + 6 + + + True + False + True + True + vertical + + + + + + 0 + 0 + + + + + True + False + 12 + + + True + False + Custom Line Width: + True + spin:0.0pt + middle + + + 0 + 0 + + + + + True + True + adjustment1 + 10 + 1 + + + 1 + 0 + + + + + 0 + 1 + + + + + + -- cgit