From d649afe84ba659df845d2c4733dfba3fa4c657a3 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 2 Sep 2013 09:29:47 +0100 Subject: convert apply styles dialog to .ui Change-Id: Id596ceaebc0dda3be046be89f22b6bf1a304fa4e --- sw/UIConfig_swriter.mk | 1 + sw/inc/globals.hrc | 1 - sw/inc/helpid.h | 1 - sw/source/ui/inc/cnttab.hxx | 8 + sw/source/ui/index/cntex.cxx | 1 - sw/source/ui/index/cnttab.cxx | 142 +++++++++-------- sw/source/ui/index/cnttab.hrc | 11 -- sw/source/ui/index/cnttab.src | 80 ---------- sw/uiconfig/swriter/ui/assignstylesdialog.ui | 227 +++++++++++++++++++++++++++ 9 files changed, 311 insertions(+), 161 deletions(-) create mode 100644 sw/uiconfig/swriter/ui/assignstylesdialog.ui (limited to 'sw') diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk index 4d22eea529b0..ceb96115808d 100644 --- a/sw/UIConfig_swriter.mk +++ b/sw/UIConfig_swriter.mk @@ -61,6 +61,7 @@ $(eval $(call gb_UIConfig_add_toolbarfiles,modules/swriter,\ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\ sw/uiconfig/swriter/ui/abstractdialog \ sw/uiconfig/swriter/ui/asciifilterdialog \ + sw/uiconfig/swriter/ui/assignstylesdialog \ sw/uiconfig/swriter/ui/authenticationsettingsdialog \ sw/uiconfig/swriter/ui/autoformattable \ sw/uiconfig/swriter/ui/autotext \ diff --git a/sw/inc/globals.hrc b/sw/inc/globals.hrc index c13fac8e80ed..5d0d28fc9132 100644 --- a/sw/inc/globals.hrc +++ b/sw/inc/globals.hrc @@ -124,7 +124,6 @@ #define TP_OPTCAPTION_PAGE (RC_GLOBALS_BEGIN + 77) #define DLG_SVXTEST_NUM_BULLET (RC_GLOBALS_BEGIN + 79) -#define DLG_ADD_IDX_STYLES (RC_GLOBALS_BEGIN + 94) //maximum: RC_GLOBALS_BEGIN + 120 diff --git a/sw/inc/helpid.h b/sw/inc/helpid.h index 3b76017a7683..83b8cd4fb3f5 100644 --- a/sw/inc/helpid.h +++ b/sw/inc/helpid.h @@ -137,7 +137,6 @@ #define HID_REDLINE_CTRL "SW_HID_REDLINE_CTRL" #define HID_OPTCAPTION_PAGE "SW_HID_OPTCAPTION_PAGE" -#define HID_DLG_ADD_IDX_STYLES "SW_HID_DLG_ADD_IDX_STYLES" #define HID_ADD_STYLES_TLB "SW_HID_ADD_STYLES_TLB" #define HID_COMPATIBILITY_OPTIONS_BOX "SW_HID_COMPATIBILITY_OPTIONS_BOX" diff --git a/sw/source/ui/inc/cnttab.hxx b/sw/source/ui/inc/cnttab.hxx index 0da1276ad20e..30dc8e13663a 100644 --- a/sw/source/ui/inc/cnttab.hxx +++ b/sw/source/ui/inc/cnttab.hxx @@ -43,6 +43,14 @@ #define TOX_PAGE_ENTRY 2 #define TOX_PAGE_STYLES 3 +#define TO_CONTENT 1 +#define TO_INDEX 2 +#define TO_ILLUSTRATION 4 +#define TO_TABLE 8 +#define TO_USER 16 +#define TO_OBJECT 32 +#define TO_AUTHORITIES 64 + struct CurTOXType { TOXTypes eType; diff --git a/sw/source/ui/index/cntex.cxx b/sw/source/ui/index/cntex.cxx index 33c1d906f2b8..a3f96c304fac 100644 --- a/sw/source/ui/index/cntex.cxx +++ b/sw/source/ui/index/cntex.cxx @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index 802a73dc5e4c..77dd117fd9b5 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -68,7 +68,7 @@ #include #include #include -#include +#include #include #include #include @@ -562,10 +562,13 @@ sal_Bool SwMultiTOXTabDialog::IsNoNum(SwWrtShell& rSh, const String& rName) class SwIndexTreeLB : public SvSimpleTable { +private: public: - SwIndexTreeLB(SvSimpleTableContainer& rParent, WinBits nBits = WB_BORDER); + SwIndexTreeLB(SvSimpleTableContainer& rParent, WinBits nBits = 0); virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void Resize(); virtual sal_IntPtr GetTabPos( SvTreeListEntry*, SvLBoxTab* ); + void setColSizes(); }; @@ -573,7 +576,8 @@ SwIndexTreeLB::SwIndexTreeLB(SvSimpleTableContainer& rParent, WinBits nBits) : SvSimpleTable(rParent, nBits) { HeaderBar& rStylesHB = GetTheHeaderBar(); - rStylesHB.SetStyle(rStylesHB.GetStyle()|WB_BUTTONSTYLE|WB_TABSTOP|WB_BORDER); + rStylesHB.SetStyle(rStylesHB.GetStyle()|WB_BUTTONSTYLE); + SetStyle(GetStyle() & ~(WB_AUTOHSCROLL|WB_HSCROLL)); } sal_IntPtr SwIndexTreeLB::GetTabPos( SvTreeListEntry* pEntry, SvLBoxTab* pTab) @@ -625,19 +629,40 @@ void SwIndexTreeLB::KeyInput( const KeyEvent& rKEvt ) SvTreeListBox::KeyInput(rKEvt); } +void SwIndexTreeLB::Resize() +{ + SvSimpleTable::Resize(); + setColSizes(); +} + +void SwIndexTreeLB::setColSizes() +{ + HeaderBar &rHB = GetTheHeaderBar(); + if (rHB.GetItemCount() < MAXLEVEL+1) + return; + + long nWidth = rHB.GetSizePixel().Width(); + nWidth /= 14; + nWidth--; + + long nTabs_Impl[MAXLEVEL+2]; + + nTabs_Impl[0] = MAXLEVEL+1; + nTabs_Impl[1] = 3 * nWidth; + + for(sal_uInt16 i = 1; i <= MAXLEVEL; ++i) + nTabs_Impl[i+1] = nTabs_Impl[i] + nWidth; + SvSimpleTable::SetTabs(&nTabs_Impl[0], MAP_PIXEL); +} + class SwAddStylesDlg_Impl : public SfxModalDialog { - OKButton aOk; - CancelButton aCancel; - HelpButton aHelp; + OKButton* m_pOk; - FixedLine aStylesFL; - SvSimpleTableContainer aHeaderTreeContainer; - SwIndexTreeLB aHeaderTree; - ImageButton aLeftPB; - ImageButton aRightPB; + SwIndexTreeLB* m_pHeaderTree; + PushButton* m_pLeftPB; + PushButton* m_pRightPB; - String sHBFirst; String* pStyleArr; DECL_LINK(OkHdl, void *); @@ -650,61 +675,43 @@ public: }; SwAddStylesDlg_Impl::SwAddStylesDlg_Impl(Window* pParent, - SwWrtShell& rWrtSh, String rStringArr[]) : - SfxModalDialog(pParent, SW_RES(DLG_ADD_IDX_STYLES)), - aOk( this, SW_RES(PB_OK )), - aCancel( this, SW_RES(PB_CANCEL )), - aHelp( this, SW_RES(PB_HELP )), - - aStylesFL( this, SW_RES(FL_STYLES )), - aHeaderTreeContainer(this, SW_RES(TR_HEADER )), - aHeaderTree(aHeaderTreeContainer), - aLeftPB( this, SW_RES(PB_LEFT )), - aRightPB( this, SW_RES(PB_RIGHT )), - - sHBFirst( SW_RES(ST_HB_FIRST)), - pStyleArr(rStringArr) -{ - FreeResource(); - - aHeaderTreeContainer.SetAccessibleRelationMemberOf(&aStylesFL); - aLeftPB.SetAccessibleRelationMemberOf(&aStylesFL); - aRightPB.SetAccessibleRelationMemberOf(&aStylesFL); - - aOk.SetClickHdl(LINK(this, SwAddStylesDlg_Impl, OkHdl)); - aLeftPB.SetClickHdl(LINK(this, SwAddStylesDlg_Impl, LeftRightHdl)); - aRightPB.SetClickHdl(LINK(this, SwAddStylesDlg_Impl, LeftRightHdl)); - - HeaderBar& rHB = aHeaderTree.GetTheHeaderBar(); + SwWrtShell& rWrtSh, String rStringArr[]) + : SfxModalDialog(pParent, "AssignStylesDialog", + "modules/swriter/ui/assignstylesdialog.ui") + , pStyleArr(rStringArr) +{ + get(m_pOk, "ok"); + get(m_pLeftPB, "left"); + get(m_pRightPB, "right"); + OUString sHBFirst = get("notapplied")->GetText(); + SvSimpleTableContainer *pHeaderTreeContainer = get("styles"); + Size aSize = pHeaderTreeContainer->LogicToPixel(Size(273, 164), MAP_APPFONT); + pHeaderTreeContainer->set_width_request(aSize.Width()); + pHeaderTreeContainer->set_height_request(aSize.Height()); + m_pHeaderTree = new SwIndexTreeLB(*get("styles")); + + m_pOk->SetClickHdl(LINK(this, SwAddStylesDlg_Impl, OkHdl)); + m_pLeftPB->SetClickHdl(LINK(this, SwAddStylesDlg_Impl, LeftRightHdl)); + m_pRightPB->SetClickHdl(LINK(this, SwAddStylesDlg_Impl, LeftRightHdl)); + + HeaderBar& rHB = m_pHeaderTree->GetTheHeaderBar(); rHB.SetEndDragHdl(LINK(this, SwAddStylesDlg_Impl, HeaderDragHdl)); - long nWidth = rHB.GetSizePixel().Width(); - nWidth /= 14; - nWidth--; - - long nTabs_Impl[MAXLEVEL+2]; - - nTabs_Impl[0] = MAXLEVEL+1; - nTabs_Impl[1] = 3 * nWidth; - OUStringBuffer sHeader(sHBFirst); for(sal_uInt16 i = 1; i <= MAXLEVEL; ++i) - { sHeader.append("\t").append(OUString::number(i)); - nTabs_Impl[i+1] = nTabs_Impl[i] + nWidth; - } - aHeaderTree.SvSimpleTable::SetTabs(&nTabs_Impl[0], MAP_PIXEL); - aHeaderTree.InsertHeaderEntry(sHeader.makeStringAndClear()); + m_pHeaderTree->InsertHeaderEntry(sHeader.makeStringAndClear()); + m_pHeaderTree->setColSizes(); - aHeaderTree.SetStyle(aHeaderTree.GetStyle()|WB_CLIPCHILDREN|WB_SORT); - aHeaderTree.GetModel()->SetSortMode(SortAscending); + m_pHeaderTree->SetStyle(m_pHeaderTree->GetStyle()|WB_CLIPCHILDREN|WB_SORT); + m_pHeaderTree->GetModel()->SetSortMode(SortAscending); for (sal_uInt16 i = 0; i < MAXLEVEL; ++i) { String sStyles(rStringArr[i]); for(sal_uInt16 nToken = 0; nToken < comphelper::string::getTokenCount(sStyles, TOX_STYLE_DELIMITER); nToken++) { String sTmp(sStyles.GetToken(nToken, TOX_STYLE_DELIMITER)); - SvTreeListEntry* pEntry = aHeaderTree.InsertEntry(sTmp); + SvTreeListEntry* pEntry = m_pHeaderTree->InsertEntry(sTmp); pEntry->SetUserData(reinterpret_cast(i)); } } @@ -722,22 +729,23 @@ SwAddStylesDlg_Impl::SwAddStylesDlg_Impl(Window* pParent, const OUString aName = pColl->GetName(); if (!aName.isEmpty()) { - SvTreeListEntry* pEntry = aHeaderTree.First(); - while (pEntry && aHeaderTree.GetEntryText(pEntry)!=aName) + SvTreeListEntry* pEntry = m_pHeaderTree->First(); + while (pEntry && m_pHeaderTree->GetEntryText(pEntry)!=aName) { - pEntry = aHeaderTree.Next(pEntry); + pEntry = m_pHeaderTree->Next(pEntry); } if (!pEntry) { - aHeaderTree.InsertEntry(aName)->SetUserData((void*)USHRT_MAX); + m_pHeaderTree->InsertEntry(aName)->SetUserData((void*)USHRT_MAX); } } } - aHeaderTree.GetModel()->Resort(); + m_pHeaderTree->GetModel()->Resort(); } SwAddStylesDlg_Impl::~SwAddStylesDlg_Impl() { + delete m_pHeaderTree; } IMPL_LINK_NOARG(SwAddStylesDlg_Impl, OkHdl) @@ -745,18 +753,18 @@ IMPL_LINK_NOARG(SwAddStylesDlg_Impl, OkHdl) for(sal_uInt16 i = 0; i < MAXLEVEL; i++) pStyleArr[i].Erase(); - SvTreeListEntry* pEntry = aHeaderTree.First(); + SvTreeListEntry* pEntry = m_pHeaderTree->First(); while(pEntry) { sal_IntPtr nLevel = (sal_IntPtr)pEntry->GetUserData(); if(nLevel != USHRT_MAX) { - String sName(aHeaderTree.GetEntryText(pEntry)); + String sName(m_pHeaderTree->GetEntryText(pEntry)); if(pStyleArr[nLevel].Len()) pStyleArr[nLevel] += TOX_STYLE_DELIMITER; pStyleArr[nLevel] += sName; } - pEntry = aHeaderTree.Next(pEntry); + pEntry = m_pHeaderTree->Next(pEntry); } //TODO write back style names @@ -766,14 +774,14 @@ IMPL_LINK_NOARG(SwAddStylesDlg_Impl, OkHdl) IMPL_LINK_NOARG(SwAddStylesDlg_Impl, HeaderDragHdl) { - aHeaderTree.Invalidate(); + m_pHeaderTree->Invalidate(); return 0; } IMPL_LINK(SwAddStylesDlg_Impl, LeftRightHdl, PushButton*, pBtn) { - sal_Bool bLeft = pBtn == &aLeftPB; - SvTreeListEntry* pEntry = aHeaderTree.FirstSelected(); + sal_Bool bLeft = pBtn == m_pLeftPB; + SvTreeListEntry* pEntry = m_pHeaderTree->FirstSelected(); if(pEntry) { sal_IntPtr nLevel = (sal_IntPtr)pEntry->GetUserData(); @@ -792,7 +800,7 @@ IMPL_LINK(SwAddStylesDlg_Impl, LeftRightHdl, PushButton*, pBtn) nLevel = 0; } pEntry->SetUserData((void*)nLevel); - aHeaderTree.Invalidate(); + m_pHeaderTree->Invalidate(); } return 0; } diff --git a/sw/source/ui/index/cnttab.hrc b/sw/source/ui/index/cnttab.hrc index b8ab4787737e..8121705691a7 100644 --- a/sw/source/ui/index/cnttab.hrc +++ b/sw/source/ui/index/cnttab.hrc @@ -17,17 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#define TLB_STYLES 100 -#define FL_STYLES 101 -#define PB_OK 102 -#define PB_CANCEL 103 -#define PB_HELP 104 -#define TR_HEADER 109 -#define PB_LEFT 110 -#define PB_RIGHT 111 -#define HB_STYLES 112 -#define ST_HB_FIRST 113 - #define TO_CONTENT 1 #define TO_INDEX 2 #define TO_ILLUSTRATION 4 diff --git a/sw/source/ui/index/cnttab.src b/sw/source/ui/index/cnttab.src index 55716b94b008..39baa4424bc8 100644 --- a/sw/source/ui/index/cnttab.src +++ b/sw/source/ui/index/cnttab.src @@ -19,7 +19,6 @@ #include "index.hrc" #include "globals.hrc" -#include "cnttab.hrc" #include "cmdid.h" #include "helpid.h" @@ -166,83 +165,4 @@ String STR_AUTOMARK_TYPE Text [ en-US ] = "Selection file for the alphabetical index (*.sdi)"; }; -//------------------------------------------------------------------ -ModalDialog DLG_ADD_IDX_STYLES -{ - HelpId = HID_DLG_ADD_IDX_STYLES; - OutputSize = TRUE ; - SVLook = TRUE ; - Size = MAP_APPFONT ( 350 , 200 ) ; - Moveable = TRUE ; - Control TR_HEADER - { - Pos = MAP_APPFONT ( 12 , 15 ) ; - Size = MAP_APPFONT ( 273 , 164 ) ; - Border = TRUE; - TabStop = TRUE; - }; - ImageButton PB_LEFT - { - HelpID = "sw:ImageButton:DLG_ADD_IDX_STYLES:PB_LEFT"; - Pos = MAP_APPFONT ( 12 , 182 ) ; - Size = MAP_APPFONT ( 50 , 12 ) ; - TabStop = TRUE ; - ButtonImage = Image - { - ImageBitmap = Bitmap - { - File = "all_left.bmp" ; - }; - MaskColor = IMAGE_MASK_COLOR ; - }; - QuickHelpText [ en-US ] = "Left" ; - }; - ImageButton PB_RIGHT - { - HelpID = "sw:ImageButton:DLG_ADD_IDX_STYLES:PB_RIGHT"; - Pos = MAP_APPFONT ( 65 , 182 ) ; - Size = MAP_APPFONT ( 50 , 12 ) ; - TabStop = TRUE ; - ButtonImage = Image - { - ImageBitmap = Bitmap - { - File = "all_right.bmp" ; - }; - MaskColor = IMAGE_MASK_COLOR ; - }; - QuickHelpText [ en-US ] = "Right" ; - }; - FixedLine FL_STYLES - { - Pos = MAP_APPFONT ( 6 , 3 ) ; - Size = MAP_APPFONT ( 285 , 8 ) ; - Text [ en-US ] = "Styl~es"; - }; - OKButton PB_OK - { - Pos = MAP_APPFONT ( 297 , 6 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - TabStop = TRUE ; - DefButton = TRUE ; - }; - CancelButton PB_CANCEL - { - Pos = MAP_APPFONT ( 297 , 23 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - TabStop = TRUE ; - }; - HelpButton PB_HELP - { - Pos = MAP_APPFONT ( 297 , 40 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - TabStop = TRUE ; - }; - String ST_HB_FIRST - { - Text [ en-US ] = "Not applied"; - }; - Text [ en-US ] = "Assign Styles"; -}; - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/uiconfig/swriter/ui/assignstylesdialog.ui b/sw/uiconfig/swriter/ui/assignstylesdialog.ui new file mode 100644 index 000000000000..5b60b243df7c --- /dev/null +++ b/sw/uiconfig/swriter/ui/assignstylesdialog.ui @@ -0,0 +1,227 @@ + + + + + + True + False + sw/res/all_left.png + + + True + False + sw/res/all_right.png + + + False + 6 + Insert Database Columns + dialog + + + False + 12 + + + False + vertical + start + + + gtk-ok + True + True + True + True + True + True + + + False + True + 0 + + + + + gtk-cancel + True + True + True + True + + + False + True + 1 + + + + + gtk-help + True + True + True + True + + + False + True + 2 + + + + + False + True + end + 0 + + + + + True + False + True + True + 0 + none + + + True + False + True + True + 6 + 12 + + + True + False + 6 + + + True + False + start + 12 + + + True + False + start + 12 + start + + + True + True + True + image1 + + + Left + + + + + False + True + 0 + + + + + True + True + True + image2 + + + Right + + + + + False + True + 1 + + + + + 0 + 0 + 1 + 1 + + + + + 0 + 2 + 1 + 1 + + + + + True + True + True + True + + + + + + 0 + 1 + 1 + 1 + + + + + False + True + 0 + Not applied + + + 0 + 0 + 1 + 1 + + + + + + + + + True + False + Styles + + + + + + + + False + True + 1 + + + + + + ok + cancel + help + + + -- cgit