diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-06-06 11:59:14 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-06-06 16:42:26 +0100 |
commit | 82ed0efee489b91037a41fc72b898582ea3e5ec4 (patch) | |
tree | a4c8f72aa2273e9ea6b97183c15cdb46180947fd /sw | |
parent | a4c3dc55951dd54882be9eac2c8f6057fa184f07 (diff) |
convert concordence entry dialog to .ui format
Change-Id: I52f88e6be67c4473ccf1b999ac7cb346b1c4f9ee
Diffstat (limited to 'sw')
-rw-r--r-- | sw/UIConfig_swriter.mk | 1 | ||||
-rw-r--r-- | sw/inc/helpid.h | 1 | ||||
-rw-r--r-- | sw/inc/index.hrc | 1 | ||||
-rw-r--r-- | sw/source/ui/index/cnttab.cxx | 142 | ||||
-rw-r--r-- | sw/source/ui/index/cnttab.hrc | 15 | ||||
-rw-r--r-- | sw/source/ui/index/cnttab.src | 80 | ||||
-rw-r--r-- | sw/uiconfig/swriter/ui/createautomarkdialog.ui | 241 |
7 files changed, 341 insertions, 140 deletions
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk index 618394b17e04..89e6eacd7834 100644 --- a/sw/UIConfig_swriter.mk +++ b/sw/UIConfig_swriter.mk @@ -73,6 +73,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\ sw/uiconfig/swriter/ui/columnwidth \ sw/uiconfig/swriter/ui/converttexttable \ sw/uiconfig/swriter/ui/createauthorentry \ + sw/uiconfig/swriter/ui/createautomarkdialog \ sw/uiconfig/swriter/ui/dropdownfielddialog \ sw/uiconfig/swriter/ui/endnotepage \ sw/uiconfig/swriter/ui/editcategories \ diff --git a/sw/inc/helpid.h b/sw/inc/helpid.h index 72dcb8086e31..1ea0ffcb9636 100644 --- a/sw/inc/helpid.h +++ b/sw/inc/helpid.h @@ -410,7 +410,6 @@ #define HID_AUTH_FIELD_ISBN "SW_HID_AUTH_FIELD_ISBN" #define HID_INSERT_INDEX_ENTRY_LEVEL_LB "SW_HID_INSERT_INDEX_ENTRY_LEVEL_LB" -#define HID_DLG_CREATE_AUTOMARK "SW_HID_DLG_CREATE_AUTOMARK" #define HID_BUSINESS_CARD_CONTENT "SW_HID_BUSINESS_CARD_CONTENT" #define HID_SAVE_LABEL_DLG "SW_HID_SAVE_LABEL_DLG" #define HID_BUSINESS_FMT_PAGE "SW_HID_BUSINESS_FMT_PAGE" diff --git a/sw/inc/index.hrc b/sw/inc/index.hrc index 6f3ec1eb7e2b..99ec6e56d7a0 100644 --- a/sw/inc/index.hrc +++ b/sw/inc/index.hrc @@ -40,7 +40,6 @@ #define STR_FILE_NOT_FOUND (RC_INDEX_BEGIN + 18) #define DLG_CHANGE_AUTH_ENTRY (RC_INDEX_BEGIN + 19) -#define DLG_CREATE_AUTOMARK (RC_INDEX_BEGIN + 20) #endif // _INDEX_HRC diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index bf7965e51da0..c3fe96774982 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -140,6 +140,7 @@ struct AutoMarkEntry typedef boost::ptr_vector<AutoMarkEntry> AutoMarkEntryArr; typedef ::svt::EditBrowseBox SwEntryBrowseBox_Base; + class SwEntryBrowseBox : public SwEntryBrowseBox_Base { Edit aCellEdit; @@ -173,25 +174,25 @@ protected: virtual ::svt::CellController* GetController(long nRow, sal_uInt16 nCol); virtual sal_Bool SaveModified(); + std::vector<long> GetOptimalColWidths() const; + public: - SwEntryBrowseBox(Window* pParent, const ResId& rId, - BrowserMode nMode = 0 ); + SwEntryBrowseBox(Window* pParent, VclBuilderContainer* pBuilder); void ReadEntries(SvStream& rInStr); void WriteEntries(SvStream& rOutStr); sal_Bool IsModified()const; virtual String GetCellText( long nRow, sal_uInt16 nColumn ) const; + virtual void Resize(); + virtual Size GetOptimalSize() const; }; class SwAutoMarkDlg_Impl : public ModalDialog { - OKButton aOKPB; - CancelButton aCancelPB; - HelpButton aHelpPB; + OKButton* m_pOKPB; - SwEntryBrowseBox aEntriesBB; - FixedLine aEntriesFL; + SwEntryBrowseBox* m_pEntriesBB; String sAutoMarkURL; const String sAutoMarkType; @@ -3879,9 +3880,8 @@ void SwTOXStylesTabPage::Modify() #define ITEM_WORDONLY 7 -SwEntryBrowseBox::SwEntryBrowseBox(Window* pParent, const ResId& rId, - BrowserMode nMode ) : - SwEntryBrowseBox_Base( pParent, rId, nMode, +SwEntryBrowseBox::SwEntryBrowseBox(Window* pParent, VclBuilderContainer* pBuilder) + : SwEntryBrowseBox_Base( pParent, EBBF_NONE, WB_TABSTOP | WB_BORDER, BROWSER_KEEPSELECTION | BROWSER_COLUMNSELECTION | BROWSER_MULTISELECTION | @@ -3889,22 +3889,21 @@ SwEntryBrowseBox::SwEntryBrowseBox(Window* pParent, const ResId& rId, BROWSER_HLINESFULL | BROWSER_VLINESFULL | BROWSER_AUTO_VSCROLL| - BROWSER_HIDECURSOR ), - aCellEdit(&GetDataWindow(), 0), - aCellCheckBox(&GetDataWindow()), - - sSearch( ResId(ST_SEARCH, *rId.GetResMgr() )), - sAlternative( ResId(ST_ALTERNATIVE, *rId.GetResMgr() )), - sPrimKey( ResId(ST_PRIMKEY, *rId.GetResMgr() )), - sSecKey( ResId(ST_SECKEY, *rId.GetResMgr() )), - sComment( ResId(ST_COMMENT, *rId.GetResMgr() )), - sCaseSensitive( ResId(ST_CASESENSITIVE, *rId.GetResMgr() )), - sWordOnly( ResId(ST_WORDONLY, *rId.GetResMgr() )), - sYes( ResId(ST_TRUE, *rId.GetResMgr() )), - sNo( ResId(ST_FALSE, *rId.GetResMgr() )), - bModified(false) -{ - FreeResource(); + BROWSER_HIDECURSOR ) + , aCellEdit(&GetDataWindow(), 0) + , aCellCheckBox(&GetDataWindow()) + , bModified(false) +{ + sSearch = pBuilder->get<Window>("searchterm")->GetText(); + sAlternative = pBuilder->get<Window>("alternative")->GetText(); + sPrimKey = pBuilder->get<Window>("key1")->GetText(); + sSecKey = pBuilder->get<Window>("key2")->GetText(); + sComment = pBuilder->get<Window>("comment")->GetText(); + sCaseSensitive = pBuilder->get<Window>("casesensitive")->GetText(); + sWordOnly = pBuilder->get<Window>("wordonly")->GetText(); + sYes = pBuilder->get<Window>("yes")->GetText(); + sNo = pBuilder->get<Window>("no")->GetText(); + aCellCheckBox.GetBox().EnableTriState(sal_False); xController = new ::svt::EditCellController(&aCellEdit); xCheckController = new ::svt::CheckBoxCellController(&aCellCheckBox); @@ -3939,6 +3938,63 @@ SwEntryBrowseBox::SwEntryBrowseBox(Window* pParent, const ResId& rId, } +void SwEntryBrowseBox::Resize() +{ + SwEntryBrowseBox_Base::Resize(); + + Dialog *pDlg = GetParentDialog(); + if (pDlg && pDlg->isCalculatingInitialLayoutSize()) + { + long nWidth = GetSizePixel().Width(); + std::vector<long> aWidths = GetOptimalColWidths(); + long nNaturalWidth(::std::accumulate(aWidths.begin(), aWidths.end(), 0)); + long nExcess = ((nWidth - nNaturalWidth) / aWidths.size()) - 1; + + for (size_t i = 0; i < aWidths.size(); ++i) + SetColumnWidth(i+1, aWidths[i] + nExcess); + } +} + +std::vector<long> SwEntryBrowseBox::GetOptimalColWidths() const +{ + std::vector<long> aWidths; + + long nStandardColMinWidth = approximate_char_width() * 16; + long nYesNoWidth = approximate_char_width() * 5; + nYesNoWidth = std::max(nYesNoWidth, GetTextWidth(sYes)); + nYesNoWidth = std::max(nYesNoWidth, GetTextWidth(sNo)); + for (sal_uInt16 i = 1; i < 6; i++) + { + OUString sTitle = GetColumnTitle(i); + long nColWidth = std::max(nStandardColMinWidth, GetTextWidth(sTitle)); + nColWidth += 12; + aWidths.push_back(nColWidth); + } + + for (sal_uInt16 i = 6; i < 8; i++) + { + OUString sTitle = GetColumnTitle(i); + long nColWidth = std::max(nYesNoWidth, GetTextWidth(sTitle)); + nColWidth += 12; + aWidths.push_back(nColWidth); + } + + return aWidths; +} + +Size SwEntryBrowseBox::GetOptimalSize() const +{ + Size aSize = LogicToPixel(Size(276 , 175), MapMode(MAP_APPFONT)); + + std::vector<long> aWidths = GetOptimalColWidths(); + + long nWidth(::std::accumulate(aWidths.begin(), aWidths.end(), 0)); + + aSize.Width() = std::max(aSize.Width(), nWidth); + + return aSize; +} + sal_Bool SwEntryBrowseBox::SeekRow( long nRow ) { nCurrentRow = nRow; @@ -4150,19 +4206,18 @@ sal_Bool SwEntryBrowseBox::IsModified()const } SwAutoMarkDlg_Impl::SwAutoMarkDlg_Impl(Window* pParent, const String& rAutoMarkURL, - const String& rAutoMarkType, bool bCreate) : - ModalDialog(pParent, SW_RES(DLG_CREATE_AUTOMARK)), - aOKPB( this, SW_RES(PB_OK )), - aCancelPB( this, SW_RES(PB_CANCEL )), - aHelpPB( this, SW_RES(PB_HELP )), - aEntriesBB( this, SW_RES(BB_ENTRIES )), - aEntriesFL( this, SW_RES(FL_ENTRIES )), - sAutoMarkURL(rAutoMarkURL), - sAutoMarkType(rAutoMarkType), - bCreateMode(bCreate) -{ - FreeResource(); - aOKPB.SetClickHdl(LINK(this, SwAutoMarkDlg_Impl, OkHdl)); + const String& rAutoMarkType, bool bCreate) + : ModalDialog(pParent, "CreateAutomarkDialog", + "modules/swriter/ui/createautomarkdialog.ui") + , sAutoMarkURL(rAutoMarkURL) + , sAutoMarkType(rAutoMarkType) + , bCreateMode(bCreate) +{ + get(m_pOKPB, "ok"); + m_pEntriesBB = new SwEntryBrowseBox(get<VclContainer>("area"), this); + m_pEntriesBB->set_expand(true); + m_pEntriesBB->Show(); + m_pOKPB->SetClickHdl(LINK(this, SwAutoMarkDlg_Impl, OkHdl)); String sTitle = GetText(); sTitle.AppendAscii( RTL_CONSTASCII_STRINGPARAM(": ")); @@ -4170,12 +4225,12 @@ SwAutoMarkDlg_Impl::SwAutoMarkDlg_Impl(Window* pParent, const String& rAutoMarkU SetText(sTitle); bool bError = false; if( bCreateMode ) - aEntriesBB.RowInserted(0, 1, sal_True); + m_pEntriesBB->RowInserted(0, 1, sal_True); else { SfxMedium aMed( sAutoMarkURL, STREAM_STD_READ ); if( aMed.GetInStream() && !aMed.GetInStream()->GetError() ) - aEntriesBB.ReadEntries( *aMed.GetInStream() ); + m_pEntriesBB->ReadEntries( *aMed.GetInStream() ); else bError = true; } @@ -4186,12 +4241,13 @@ SwAutoMarkDlg_Impl::SwAutoMarkDlg_Impl(Window* pParent, const String& rAutoMarkU SwAutoMarkDlg_Impl::~SwAutoMarkDlg_Impl() { + delete m_pEntriesBB; } IMPL_LINK_NOARG(SwAutoMarkDlg_Impl, OkHdl) { bool bError = false; - if(aEntriesBB.IsModified() || bCreateMode) + if(m_pEntriesBB->IsModified() || bCreateMode) { SfxMedium aMed( sAutoMarkURL, bCreateMode ? STREAM_WRITE @@ -4200,7 +4256,7 @@ IMPL_LINK_NOARG(SwAutoMarkDlg_Impl, OkHdl) pStrm->SetStreamCharSet( RTL_TEXTENCODING_MS_1253 ); if( !pStrm->GetError() ) { - aEntriesBB.WriteEntries( *pStrm ); + m_pEntriesBB->WriteEntries( *pStrm ); aMed.Commit(); } else diff --git a/sw/source/ui/index/cnttab.hrc b/sw/source/ui/index/cnttab.hrc index 8de766c97cdf..3ec75329ea4f 100644 --- a/sw/source/ui/index/cnttab.hrc +++ b/sw/source/ui/index/cnttab.hrc @@ -203,21 +203,6 @@ #define CB_SHOWEXAMPLE 14 -// AutoMark dialog -#define BB_ENTRIES 1 -#define FL_ENTRIES 2 - -#define ST_SEARCH 10 -#define ST_ALTERNATIVE 11 -#define ST_PRIMKEY 12 -#define ST_SECKEY 13 -#define ST_COMMENT 14 -#define ST_CASESENSITIVE 15 -#define ST_WORDONLY 16 -#define ST_TRUE 17 -#define ST_FALSE 18 - - //ButtonMenu #define MN_AUTOMARK_OPEN 1 #define MN_AUTOMARK_NEW 2 diff --git a/sw/source/ui/index/cnttab.src b/sw/source/ui/index/cnttab.src index 2f1e18a92eab..c3cecf0c6dfa 100644 --- a/sw/source/ui/index/cnttab.src +++ b/sw/source/ui/index/cnttab.src @@ -1248,84 +1248,4 @@ ModalDialog DLG_ADD_IDX_STYLES Text [ en-US ] = "Assign Styles"; }; -ModalDialog DLG_CREATE_AUTOMARK -{ - HelpId = HID_DLG_CREATE_AUTOMARK; - OutputSize = TRUE ; - SVLook = TRUE ; - Size = MAP_APPFONT ( 350 , 200 ) ; - Moveable = TRUE ; - 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 ; - }; - Control BB_ENTRIES - { - Pos = MAP_APPFONT ( 12 , 18 ) ; - Size = MAP_APPFONT ( 276 , 175 ) ; - TabStop = TRUE ; - Border = TRUE; - String ST_SEARCH - { - Text [ en-US ] = "Search term"; - }; - String ST_ALTERNATIVE - { - Text [ en-US ] = "Alternative entry"; - }; - String ST_PRIMKEY - { - Text [ en-US ] = "1st key"; - }; - String ST_SECKEY - { - Text [ en-US ] = "2nd key"; - }; - String ST_COMMENT - { - Text [ en-US ] = "Comment"; - }; - String ST_CASESENSITIVE - { - Text [ en-US ] = "Match case"; - }; - String ST_WORDONLY - { - Text [ en-US ] = "Word only"; - }; - String ST_TRUE - { - Text [ en-US ] = "Yes"; - }; - String ST_FALSE - { - Text [ en-US ] = "No"; - }; - }; - FixedLine FL_ENTRIES - { - Pos = MAP_APPFONT ( 6 , 3 ) ; - Size = MAP_APPFONT ( 288, 8 ) ; - Text [ en-US ] = "Entries"; - }; - - Text [ en-US ] = "Edit Concordance File"; -}; -// ----------------------------------------------------------------------------- - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/uiconfig/swriter/ui/createautomarkdialog.ui b/sw/uiconfig/swriter/ui/createautomarkdialog.ui new file mode 100644 index 000000000000..b5a3664f3220 --- /dev/null +++ b/sw/uiconfig/swriter/ui/createautomarkdialog.ui @@ -0,0 +1,241 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <!-- interface-requires gtk+ 3.0 --> + <object class="GtkDialog" id="CreateAutomarkDialog"> + <property name="can_focus">False</property> + <property name="border_width">6</property> + <property name="title" translatable="yes">Edit Concordance File</property> + <property name="type_hint">dialog</property> + <child internal-child="vbox"> + <object class="GtkBox" id="dialog-vbox1"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">12</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog-action_area1"> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="ok"> + <property name="label">gtk-ok</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="has_default">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="cancel"> + <property name="label">gtk-cancel</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="help"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkFrame" id="frame1"> + <property name="visible">True</property> + <property name="can_focus">False</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="top_padding">6</property> + <property name="left_padding">12</property> + <child> + <object class="GtkBox" id="area"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkBox" id="box3"> + <property name="can_focus">False</property> + <property name="no_show_all">True</property> + <property name="spacing">6</property> + <child> + <object class="GtkLabel" id="searchterm"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Search term</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="alternative"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Alternative entry</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="key1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">1st key</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="key2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">2nd key</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="comment"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Comment</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">4</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="casesensitive"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Match case</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">5</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="wordonly"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Word only</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">6</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="yes"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Yes</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">7</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="no"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">No</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">8</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <placeholder/> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Entries</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + <action-widgets> + <action-widget response="0">ok</action-widget> + <action-widget response="0">cancel</action-widget> + <action-widget response="0">help</action-widget> + </action-widgets> + </object> +</interface> |