[PATCH] "Sidebar conversion to .ui for sidebar-number-format"
Prashant Pandey (via Code Review)
gerrit at gerrit.libreoffice.org
Thu Jun 6 07:29:33 PDT 2013
Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/4176
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/76/4176/1
"Sidebar conversion to .ui for sidebar-number-format"
Change-Id: I25891c0acda620621f0af868914cbc58776d0f53
---
M sc/AllLangResTarget_sc.mk
M sc/UIConfig_scalc.mk
M sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
D sc/source/ui/sidebar/NumberFormatPropertyPanel.hrc
M sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx
D sc/source/ui/sidebar/NumberFormatPropertyPanel.src
6 files changed, 43 insertions(+), 287 deletions(-)
diff --git a/sc/AllLangResTarget_sc.mk b/sc/AllLangResTarget_sc.mk
index b83e0f9..485e868 100644
--- a/sc/AllLangResTarget_sc.mk
+++ b/sc/AllLangResTarget_sc.mk
@@ -87,7 +87,6 @@
sc/source/ui/formdlg/dwfunctr.src \
sc/source/ui/sidebar/AlignmentPropertyPanel.src \
sc/source/ui/sidebar/CellAppearancePropertyPanel.src \
- sc/source/ui/sidebar/NumberFormatPropertyPanel.src \
sc/source/core/src/compiler.src \
))
diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk
index 94a8aea..099d52b 100644
--- a/sc/UIConfig_scalc.mk
+++ b/sc/UIConfig_scalc.mk
@@ -91,6 +91,7 @@
sc/uiconfig/scalc/ui/sharedocumentdlg \
sc/uiconfig/scalc/ui/sharedfooterdialog \
sc/uiconfig/scalc/ui/sharedheaderdialog \
+ sc/uiconfig/scalc/ui/sidebarnumberformat \
sc/uiconfig/scalc/ui/solverdlg \
sc/uiconfig/scalc/ui/sortcriteriapage \
sc/uiconfig/scalc/ui/sortkey \
diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
index 10a12f7..bff9de6 100644
--- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
+++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
@@ -20,7 +20,6 @@
#include <sfx2/sidebar/Theme.hxx>
#include <sfx2/sidebar/ControlFactory.hxx>
#include <NumberFormatPropertyPanel.hxx>
-#include <NumberFormatPropertyPanel.hrc>
#include "sc.hrc"
#include "scresid.hxx"
#include <sfx2/bindings.hxx>
@@ -37,6 +36,12 @@
using namespace cssu;
using ::sfx2::sidebar::Theme;
+const char UNO_NUMERICFIELD[] = ".uno:NumericField";
+const char UNO_NUMBERFORMATPERCENT[] = ".uno:NumberFormatPercent";
+const char UNO_NUMBERFORMATCURRENCY[] = ".uno:NumberFormatCurrency";
+const char UNO_NUMBERFORMATDATE[] = ".uno:NumberFormatDate";
+const char UNO_INSERTFIXEDDATE[] = ".uno:InsertFixedText";
+
#define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
//////////////////////////////////////////////////////////////////////////////
@@ -50,19 +55,7 @@
Window* pParent,
const cssu::Reference<css::frame::XFrame>& rxFrame,
SfxBindings* pBindings)
-: Control(
- pParent,
- ScResId(RID_PROPERTYPANEL_SC_NUMBERFORMAT)),
- mpFtCategory(new FixedText(this, ScResId(FT_CATEGORY))),
- mpLbCategory(new ListBox(this, ScResId(LB_CATEGORY))),
- mpTBCategoryBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)),
- mpTBCategory(sfx2::sidebar::ControlFactory::CreateToolBox(mpTBCategoryBackground.get(), ScResId(TBX_CATEGORY))),
- mpFtDecimals(new FixedText(this, ScResId(FT_DECIMALS))),
- mpEdDecimals(new NumericField(this, ScResId(ED_DECIMALS))),
- mpFtLeadZeroes(new FixedText(this, ScResId(FT_LEADZEROES))),
- mpEdLeadZeroes(new NumericField(this, ScResId(ED_LEADZEROES))),
- mpBtnNegRed(new CheckBox(this, ScResId(BTN_NEGRED))),
- mpBtnThousand(new CheckBox(this, ScResId(BTN_THOUSAND))),
+ : PanelLayout(pParent,"NumberFormatPropertyPanel", "modules/scalc/ui/sidebarnumberformat.ui", rxFrame),
maNumFormatControl(SID_NUMBER_TYPE_FORMAT, *pBindings, *this),
// Caution! SID_NUMBER_FORMAT is reworked in symphony code, may be needed (!) If
@@ -74,17 +67,20 @@
maContext(),
mpBindings(pBindings)
{
+ get(mpLbCategory, "category");
+ get(mpTBCategory, "numberformat");
+ get(mpEdDecimals, "decimalplaces");
+ get(mpEdLeadZeroes, "leadingzeroes");
+ get(mpBtnNegRed, "negativenumbersred");
+ get(mpBtnThousand, "thousandseperator");
+
Initialize();
- FreeResource();
}
//////////////////////////////////////////////////////////////////////////////
NumberFormatPropertyPanel::~NumberFormatPropertyPanel()
{
- // Destroy the toolboxes, then their background windows.
- mpTBCategory.reset();
- mpTBCategoryBackground.reset();
}
//////////////////////////////////////////////////////////////////////////////
@@ -97,28 +93,30 @@
mpLbCategory->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Category"))); //wj acc
mpLbCategory->SetDropDownLineCount(mpLbCategory->GetEntryCount());
+ const sal_uInt16 nIdNumeric = mpTBCategory->GetItemId(UNO_NUMERICFIELD);
+ const sal_uInt16 nIdPercent = mpTBCategory->GetItemId(UNO_NUMBERFORMATPERCENT);
+ const sal_uInt16 nIdCurrency = mpTBCategory->GetItemId(UNO_NUMBERFORMATCURRENCY);
+ const sal_uInt16 nIdDate = mpTBCategory->GetItemId(UNO_NUMBERFORMATDATE);
+ const sal_uInt16 nIdInsertDate = mpTBCategory->GetItemId(UNO_INSERTFIXEDDATE);
+
// Note that we use icons from UNO commands that are not in every case the commands
// that are really dispatched. They just look right.
mpTBCategory->SetItemImage(
- ID_NUMBER,
+ nIdNumeric,
GetImage(mxFrame, A2S(".uno:NumericField"), sal_False));
mpTBCategory->SetItemImage(
- ID_PERCENT,
+ nIdPercent,
GetImage(mxFrame, A2S(".uno:NumberFormatPercent"), sal_False));
mpTBCategory->SetItemImage(
- ID_CURRENCY,
+ nIdCurrency,
GetImage(mxFrame, A2S(".uno:NumberFormatCurrency"), sal_False));
mpTBCategory->SetItemImage(
- ID_DATE,
+ nIdDate,
GetImage(mxFrame, A2S(".uno:NumberFormatDate"), sal_False));
mpTBCategory->SetItemImage(
- ID_TEXT,
+ nIdInsertDate,
GetImage(mxFrame, A2S(".uno:InsertFixedText"), sal_False));
- Size aTbxSize( mpTBCategory->CalcWindowSizePixel() );
- mpTBCategory->SetOutputSizePixel( aTbxSize );
- mpTBCategory->SetBackground(Wallpaper());
- mpTBCategory->SetPaintTransparent(true);
aLink = LINK(this, NumberFormatPropertyPanel, NumFormatHdl);
mpTBCategory->SetSelectHdl ( aLink );
@@ -131,38 +129,27 @@
mpBtnNegRed->SetClickHdl( aLink );
mpBtnThousand->SetClickHdl( aLink );
- mpLbCategory->SetAccessibleRelationLabeledBy(mpFtCategory.get());
- mpTBCategory->SetAccessibleRelationLabeledBy(mpTBCategory.get());
- mpEdDecimals->SetAccessibleRelationLabeledBy(mpFtDecimals.get());
- mpEdLeadZeroes->SetAccessibleRelationLabeledBy(mpFtLeadZeroes.get());
+ mpTBCategory->SetAccessibleRelationLabeledBy(mpTBCategory);
}
//////////////////////////////////////////////////////////////////////////////
IMPL_LINK( NumberFormatPropertyPanel, NumFormatHdl, ToolBox*, pBox )
{
- sal_uInt16 nVal = pBox->GetCurItemId();
+ const OUString aCommand(pBox->GetItemCommand(pBox->GetCurItemId()));
sal_uInt16 nId = 0;
- switch(nVal)
- {
- case ID_NUMBER:
+
+ if(aCommand == UNO_NUMERICFIELD)
nId = 1;
- break;
- case ID_PERCENT:
+ else if(aCommand == UNO_NUMBERFORMATPERCENT)
nId = 2;
- break;
- case ID_CURRENCY:
+ else if(aCommand == UNO_NUMBERFORMATCURRENCY)
nId = 3;
- break;
- case ID_DATE:
+ else if(aCommand == UNO_NUMBERFORMATDATE)
nId = 4;
- break;
- case ID_TEXT:
+ else if(aCommand == UNO_INSERTFIXEDDATE)
nId = 9;
- break;
- default:
- ;
- }
+
if( nId != mnCategorySelected )
{
SfxUInt16Item aItem( SID_NUMBER_TYPE_FORMAT, nId );
diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.hrc b/sc/source/ui/sidebar/NumberFormatPropertyPanel.hrc
deleted file mode 100644
index 08e66bc..0000000
--- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.hrc
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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 .
- */
-#define FT_CATEGORY 1
-#define LB_CATEGORY 2
-#define FT_DECIMALS 3
-#define ED_DECIMALS 4
-#define FT_LEADZEROES 5
-#define ED_LEADZEROES 6
-#define BTN_NEGRED 7
-#define BTN_THOUSAND 8
-#define TBX_CATEGORY 9
-#define ID_NUMBER 10
-#define ID_PERCENT 11
-#define ID_CURRENCY 12
-#define ID_DATE 13
-#define ID_TEXT 14
-
-//===============================================================position=============================================
-
-#define MBOX_WIDTH 28
-#define NF_TOOLBOX_ITEM_HEIGHT 12
-#define CHECKBOX_HEIGHT 10
-
-#define FT_CATEGORY_X SECTIONPAGE_MARGIN_HORIZONTAL
-#define FT_CATEGORY_Y SECTIONPAGE_MARGIN_VERTICAL_TOP
-#define LB_CATEGORY_X FT_CATEGORY_X
-#define LB_CATEGORY_Y FT_CATEGORY_Y + TEXT_HEIGHT + TEXT_CONTROL_SPACING_VERTICAL
-
-#define TBX_CATEGORY_X SECTIONPAGE_MARGIN_HORIZONTAL + 1
-#define TBX_CATEGORY_Y LB_CATEGORY_Y + MBOX_HEIGHT + CONTROL_SPACING_VERTICAL
-
-#define FT_DECIMALS_X SECTIONPAGE_MARGIN_HORIZONTAL
-#define FT_DECIMALS_Y TBX_CATEGORY_Y + NF_TOOLBOX_ITEM_HEIGHT + 4 + CONTROL_SPACING_VERTICAL
-#define LB_DECIMALS_X FT_CATEGORY_X
-#define LB_DECIMALS_Y FT_DECIMALS_Y + TEXT_HEIGHT + TEXT_CONTROL_SPACING_VERTICAL
-
-#define FT_LEADZEROES_X SECTIONPAGE_MARGIN_HORIZONTAL + MBOX_WIDTH*2 + CONTROL_SPACING_HORIZONTAL
-#define FT_LEADZEROES_Y FT_DECIMALS_Y
-#define LB_LEADZEROES_X FT_LEADZEROES_X
-#define LB_LEADZEROES_Y FT_LEADZEROES_Y + TEXT_HEIGHT + TEXT_CONTROL_SPACING_VERTICAL
-
-#define BTN_NEGRED_X SECTIONPAGE_MARGIN_HORIZONTAL
-#define BTN_NEGRED_Y LB_LEADZEROES_Y + MBOX_HEIGHT + CONTROL_SPACING_VERTICAL
-
-#define BTN_THOUSAND_X SECTIONPAGE_MARGIN_HORIZONTAL
-#define BTN_THOUSAND_Y BTN_NEGRED_Y + CHECKBOX_HEIGHT + CONTROL_SPACING_VERTICAL - 3
-
-#define PROPERTYPAGE_HEIGHT BTN_THOUSAND_Y + CHECKBOX_HEIGHT + 2
-
-// eof
diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx b/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx
index 0d1efe6..6bc898f 100644
--- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx
+++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx
@@ -20,6 +20,7 @@
#include <sfx2/sidebar/ControllerItem.hxx>
#include <sfx2/sidebar/IContextChangeReceiver.hxx>
+#include <svx/sidebar/PanelLayout.hxx>
#include <boost/scoped_ptr.hpp>
class FixedText;
@@ -29,7 +30,7 @@
namespace sc { namespace sidebar {
class NumberFormatPropertyPanel
-: public Control,
+: public PanelLayout,
public ::sfx2::sidebar::IContextChangeReceiver,
public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
{
@@ -56,16 +57,12 @@
private:
//ui controls
- ::boost::scoped_ptr< FixedText > mpFtCategory;
- ::boost::scoped_ptr< ListBox > mpLbCategory;
- ::boost::scoped_ptr< Window > mpTBCategoryBackground;
- ::boost::scoped_ptr< ToolBox > mpTBCategory;
- ::boost::scoped_ptr< FixedText > mpFtDecimals;
- ::boost::scoped_ptr< NumericField > mpEdDecimals;
- ::boost::scoped_ptr< FixedText > mpFtLeadZeroes;
- ::boost::scoped_ptr< NumericField > mpEdLeadZeroes;
- ::boost::scoped_ptr< CheckBox > mpBtnNegRed;
- ::boost::scoped_ptr< CheckBox > mpBtnThousand;
+ ListBox* mpLbCategory;
+ ToolBox* mpTBCategory;
+ NumericField* mpEdDecimals;
+ NumericField* mpEdLeadZeroes;
+ CheckBox* mpBtnNegRed;
+ CheckBox* mpBtnThousand;
::sfx2::sidebar::ControllerItem maNumFormatControl;
::sfx2::sidebar::ControllerItem maFormatControl;
diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.src b/sc/source/ui/sidebar/NumberFormatPropertyPanel.src
deleted file mode 100644
index 67b2843..0000000
--- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.src
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * 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 "NumberFormatPropertyPanel.hrc"
-#include <sfx2/sidebar/ResourceDefinitions.hrc>
-#include "sc.hrc"
-#include "helpids.h"
-
-Control RID_PROPERTYPANEL_SC_NUMBERFORMAT
-{
- OutputSize = TRUE;
- DialogControl = TRUE;
- Border = FALSE;
-
- Size = MAP_APPFONT( PROPERTYPAGE_WIDTH, PROPERTYPAGE_HEIGHT );
- HelpID = HID_PROPERTYPANEL_SC_NUM_SECTION ;
- Text = "Number Format";
-
- FixedText FT_CATEGORY
- {
- Pos = MAP_APPFONT ( FT_CATEGORY_X , FT_CATEGORY_Y ) ;
- Size = MAP_APPFONT ( MBOX_WIDTH*4 , TEXT_HEIGHT ) ;
- Text [ en-US ] = "~Category:" ;
- };
- ListBox LB_CATEGORY
- {
- Border = TRUE ;
- Pos = MAP_APPFONT ( LB_CATEGORY_X , LB_CATEGORY_Y ) ;
- Size = MAP_APPFONT ( MBOX_WIDTH *2 , MBOX_HEIGHT ) ;
- HelpID = HID_PROPERTY_PANEL_NUMFMT_LB_CATEGORY;
- QuickHelpText [ en-US ] = "Select a category of contents.";
- TabStop = TRUE ;
- DropDown = TRUE ;
- StringList [ en-US ] =
- {
- < "General" ; Default ; > ;
- < "Number" ;> ;
- < "Percent" ;> ;
- < "Currency" ;> ;
- < "Date" ;> ;
- < "Time" ;> ;
- < "Scientific" ;> ;
- < "Fraction" ;> ;
- < "Boolean Value" ;> ;
- < "Text" ;> ;
- };
- };
- ToolBox TBX_CATEGORY
- {
- Pos = MAP_APPFONT ( TBX_CATEGORY_X , TBX_CATEGORY_Y );
- SVLook = TRUE ;
- Border = FALSE ;
- HelpID = HID_PROPERTY_PANEL_NUMFMT_TBX_CATEGORY;
- Text = "Format";
- ItemList =
- {
- ToolBoxItem
- {
- Identifier = ID_NUMBER ;
- Text [ en-US ] = "Number" ;
- HelpID = HID_PROPERTY_PANEL_NUMFMT_ID_NUMBER;
- };
- ToolBoxItem
- {
- Identifier = ID_PERCENT ;
- Text [ en-US ] = "Percent" ;
- HelpID = HID_PROPERTY_PANEL_NUMFMT_ID_PERCENT;
- };
- ToolBoxItem
- {
- Identifier = ID_CURRENCY ;
- Text [ en-US ] = "Currency" ;
- HelpID = HID_PROPERTY_PANEL_NUMFMT_ID_CURRENCY;
- };
- ToolBoxItem
- {
- Identifier = ID_DATE ;
- Text [ en-US ] = "Date" ;
- HelpID = HID_PROPERTY_PANEL_NUMFMT_ID_DATE;
- };
- ToolBoxItem
- {
- Identifier = ID_TEXT ;
- Text [ en-US ] = "Text" ;
- HelpID = HID_PROPERTY_PANEL_NUMFMT_ID_TEXT;
- };
- };
- };
- FixedText FT_DECIMALS
- {
- Pos = MAP_APPFONT ( FT_DECIMALS_X , FT_DECIMALS_Y ) ;
- Size = MAP_APPFONT ( MBOX_WIDTH *2, TEXT_HEIGHT ) ;
- Text [ en-US ] = "~Decimal places:" ;
- };
- NumericField ED_DECIMALS
- {
- Border = TRUE ;
- Pos = MAP_APPFONT ( LB_DECIMALS_X , LB_DECIMALS_Y ) ;
- Size = MAP_APPFONT ( MBOX_WIDTH , MBOX_HEIGHT ) ;
- HelpID = HID_PROPERTY_PANEL_NUMFMT_ED_DECIMALS;
- QuickHelpText [ en-US ] = "Enter the number of decimal places that you want to display.";
- Spin = TRUE ;
- Maximum = 20 ;
- Last = 15 ;
- First = 0 ;
- StrictFormat = TRUE ;
- SpinSize = 1 ;
- Repeat = TRUE ;
- };
- FixedText FT_LEADZEROES
- {
- Pos = MAP_APPFONT ( FT_LEADZEROES_X , FT_LEADZEROES_Y ) ;
- Size = MAP_APPFONT (PROPERTYPAGE_WIDTH - MBOX_WIDTH *2 - SECTIONPAGE_MARGIN_HORIZONTAL * 2, TEXT_HEIGHT ) ; //
- Text [ en-US ] = "Leading ~zeroes:" ;
- };
- NumericField ED_LEADZEROES
- {
- Border = TRUE ;
- Pos = MAP_APPFONT ( LB_LEADZEROES_X , LB_LEADZEROES_Y ) ;
- Size = MAP_APPFONT ( MBOX_WIDTH , MBOX_HEIGHT ) ;
- HelpID = HID_PROPERTY_PANEL_NUMFMT_ED_LEADZEROES;
- QuickHelpText [ en-US ] = "Enter the maximum number of zeroes to display before the decimal point.";
- Spin = TRUE ;
- Maximum = 20 ;
- Last = 15 ;
- First = 0 ;
- StrictFormat = TRUE ;
- SpinSize = 1 ;
- Repeat = TRUE ;
- };
- CheckBox BTN_NEGRED
- {
- Pos = MAP_APPFONT ( BTN_NEGRED_X , BTN_NEGRED_Y ) ;
- Size = MAP_APPFONT ( 100 , CHECKBOX_HEIGHT ) ;
- HelpID = HID_PROPERTY_PANEL_NUMFMT_BTN_NEGRED;
- QuickHelpText [ en-US ] = "Changes the font color of negative numbers to red.";
- Text [ en-US ] = "~Negative numbers red" ;
- };
- CheckBox BTN_THOUSAND
- {
- Pos = MAP_APPFONT ( BTN_THOUSAND_X , BTN_THOUSAND_Y ) ;
- Size = MAP_APPFONT ( 100 , CHECKBOX_HEIGHT ) ;
- HelpID = HID_PROPERTY_PANEL_NUMFMT_BTN_THOUSAND;
- QuickHelpText [ en-US ] = "Inserts a separator between thousands.";
- Text [ en-US ] = "~Thousands separator" ;
- };
-};
-
-// eof
--
To view, visit https://gerrit.libreoffice.org/4176
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I25891c0acda620621f0af868914cbc58776d0f53
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Prashant Pandey <prashant3.yishu at gmail.com>
More information about the LibreOffice
mailing list