From d6407c8804841dbb94d6a4398e4300e9f188049f Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 6 Dec 2013 13:35:26 +0000 Subject: convert search dialog to .ui Change-Id: I737da11ed6978edf824f00dfb3dfc29c2c5416ed --- sfx2/AllLangResTarget_sfx2.mk | 1 - sfx2/UIConfig_sfx.mk | 1 + sfx2/inc/srchdlg.hxx | 33 +++--- sfx2/source/dialog/srchdlg.cxx | 83 ++++++--------- sfx2/source/dialog/srchdlg.hrc | 36 ------- sfx2/source/dialog/srchdlg.src | 103 ------------------- sfx2/source/inc/helpid.hrc | 2 - sfx2/uiconfig/ui/searchdialog.ui | 217 +++++++++++++++++++++++++++++++++++++++ 8 files changed, 265 insertions(+), 211 deletions(-) delete mode 100644 sfx2/source/dialog/srchdlg.hrc delete mode 100644 sfx2/source/dialog/srchdlg.src create mode 100644 sfx2/uiconfig/ui/searchdialog.ui (limited to 'sfx2') diff --git a/sfx2/AllLangResTarget_sfx2.mk b/sfx2/AllLangResTarget_sfx2.mk index b845e20c58e9..8b3e6a25c6b8 100644 --- a/sfx2/AllLangResTarget_sfx2.mk +++ b/sfx2/AllLangResTarget_sfx2.mk @@ -48,7 +48,6 @@ $(eval $(call gb_SrsTarget_add_files,sfx/res,\ sfx2/source/dialog/inputdlg.src \ sfx2/source/dialog/newstyle.src \ sfx2/source/dialog/recfloat.src \ - sfx2/source/dialog/srchdlg.src \ sfx2/source/dialog/taskpane.src \ sfx2/source/dialog/templateinfodlg.src \ sfx2/source/dialog/templdlg.src \ diff --git a/sfx2/UIConfig_sfx.mk b/sfx2/UIConfig_sfx.mk index a62f479f7947..a693f2da5cfc 100644 --- a/sfx2/UIConfig_sfx.mk +++ b/sfx2/UIConfig_sfx.mk @@ -25,6 +25,7 @@ $(eval $(call gb_UIConfig_add_uifiles,sfx,\ sfx2/uiconfig/ui/password \ sfx2/uiconfig/ui/printeroptionsdialog \ sfx2/uiconfig/ui/querysavedialog \ + sfx2/uiconfig/ui/searchdialog \ sfx2/uiconfig/ui/securityinfopage \ sfx2/uiconfig/ui/singletabdialog \ sfx2/uiconfig/ui/versionsofdialog \ diff --git a/sfx2/inc/srchdlg.hxx b/sfx2/inc/srchdlg.hxx index 66ec03d99560..1e6bd3bb2f02 100644 --- a/sfx2/inc/srchdlg.hxx +++ b/sfx2/inc/srchdlg.hxx @@ -36,14 +36,12 @@ namespace sfx2 { class SearchDialog : public ModelessDialog { private: - FixedText m_aSearchLabel; - ComboBox m_aSearchEdit; - CheckBox m_aWholeWordsBox; - CheckBox m_aMatchCaseBox; - CheckBox m_aWrapAroundBox; - CheckBox m_aBackwardsBox; - PushButton m_aFindBtn; - CancelButton m_aCancelBtn; + ComboBox* m_pSearchEdit; + CheckBox* m_pWholeWordsBox; + CheckBox* m_pMatchCaseBox; + CheckBox* m_pWrapAroundBox; + CheckBox* m_pBackwardsBox; + PushButton* m_pFindBtn; Link m_aFindHdl; Link m_aCloseHdl; @@ -58,25 +56,24 @@ private: void SaveConfig(); DECL_LINK(FindHdl, void *); - DECL_LINK(ToggleHdl, void *); public: SearchDialog( Window* pWindow, const OUString& rConfigName ); ~SearchDialog(); - inline void SetFindHdl( const Link& rLink ) { m_aFindHdl = rLink; } - inline void SetCloseHdl( const Link& rLink ) { m_aCloseHdl = rLink; } + void SetFindHdl( const Link& rLink ) { m_aFindHdl = rLink; } + void SetCloseHdl( const Link& rLink ) { m_aCloseHdl = rLink; } - inline OUString GetSearchText() const { return m_aSearchEdit.GetText(); } - inline void SetSearchText( const OUString& _rText ) { m_aSearchEdit.SetText( _rText ); } - inline bool IsOnlyWholeWords() const { return ( m_aWholeWordsBox.IsChecked() != sal_False ); } - inline bool IsMarchCase() const { return ( m_aMatchCaseBox.IsChecked() != sal_False ); } - inline bool IsWrapAround() const { return ( m_aWrapAroundBox.IsChecked() != sal_False ); } - inline bool IsSearchBackwards() const { return ( m_aBackwardsBox.IsChecked() != sal_False ); } + OUString GetSearchText() const { return m_pSearchEdit->GetText(); } + void SetSearchText( const OUString& _rText ) { m_pSearchEdit->SetText( _rText ); } + bool IsOnlyWholeWords() const { return ( m_pWholeWordsBox->IsChecked() ); } + bool IsMarchCase() const { return ( m_pMatchCaseBox->IsChecked() ); } + bool IsWrapAround() const { return ( m_pWrapAroundBox->IsChecked() ); } + bool IsSearchBackwards() const { return ( m_pBackwardsBox->IsChecked() ); } void SetFocusOnEdit(); - virtual sal_Bool Close(); + virtual sal_Bool Close(); virtual void Move(); virtual void StateChanged( StateChangedType nStateChange ); }; diff --git a/sfx2/source/dialog/srchdlg.cxx b/sfx2/source/dialog/srchdlg.cxx index 6d3c5852b6f4..3c14275d705e 100644 --- a/sfx2/source/dialog/srchdlg.cxx +++ b/sfx2/source/dialog/srchdlg.cxx @@ -23,7 +23,6 @@ #include #include -#include "srchdlg.hrc" #include "dialog.hrc" #include #include @@ -40,35 +39,25 @@ namespace sfx2 { // SearchDialog // ============================================================================ -SearchDialog::SearchDialog( Window* pWindow, const OUString& rConfigName ) : - - ModelessDialog( pWindow, SfxResId( RID_DLG_SEARCH ) ), - - m_aSearchLabel ( this, SfxResId( FT_SEARCH ) ), - m_aSearchEdit ( this, SfxResId( ED_SEARCH ) ), - m_aWholeWordsBox ( this, SfxResId( CB_WHOLEWORDS ) ), - m_aMatchCaseBox ( this, SfxResId( CB_MATCHCASE ) ), - m_aWrapAroundBox ( this, SfxResId( CB_WRAPAROUND ) ), - m_aBackwardsBox ( this, SfxResId( CB_BACKWARDS ) ), - m_aFindBtn ( this, SfxResId( PB_FIND ) ), - m_aCancelBtn ( this, SfxResId( PB_CANCELFIND ) ), - m_sToggleText ( SfxResId( STR_TOGGLE ).toString() ), - m_sConfigName ( rConfigName ), - m_bIsConstructed ( false ) +SearchDialog::SearchDialog(Window* pWindow, const OUString& rConfigName) + : ModelessDialog(pWindow, "SearchDialog", "sfx/ui/searchdialog.ui") + , m_sConfigName(rConfigName) + , m_bIsConstructed(false) { - FreeResource(); + get(m_pSearchEdit, "searchterm"); + get(m_pWholeWordsBox, "wholewords"); + get(m_pMatchCaseBox, "matchcase"); + get(m_pWrapAroundBox, "wrap"); + get(m_pBackwardsBox, "backwards"); + get(m_pFindBtn, "search"); // set handler - m_aFindBtn.SetClickHdl( LINK( this, SearchDialog, FindHdl ) ); - m_aBackwardsBox.SetClickHdl( LINK( this, SearchDialog, ToggleHdl ) ); + m_pFindBtn->SetClickHdl( LINK( this, SearchDialog, FindHdl ) ); // load config: old search strings and the status of the check boxes LoadConfig(); - // we need to change the text of the WrapAround box, depends on the status of the Backwards box - if ( m_aBackwardsBox.IsChecked() ) - ToggleHdl( &m_aBackwardsBox ); // the search edit should have the focus - m_aSearchEdit.GrabFocus(); + m_pSearchEdit->GrabFocus(); } SearchDialog::~SearchDialog() @@ -91,19 +80,19 @@ void SearchDialog::LoadConfig() DBG_ASSERT( comphelper::string::getTokenCount(sUserData, ';') == 5, "invalid config data" ); sal_Int32 nIdx = 0; OUString sSearchText = sUserData.getToken( 0, ';', nIdx ); - m_aWholeWordsBox.Check( sUserData.getToken( 0, ';', nIdx ).toInt32() == 1 ); - m_aMatchCaseBox.Check( sUserData.getToken( 0, ';', nIdx ).toInt32() == 1 ); - m_aWrapAroundBox.Check( sUserData.getToken( 0, ';', nIdx ).toInt32() == 1 ); - m_aBackwardsBox.Check( sUserData.getToken( 0, ';', nIdx ).toInt32() == 1 ); + m_pWholeWordsBox->Check( sUserData.getToken( 0, ';', nIdx ).toInt32() == 1 ); + m_pMatchCaseBox->Check( sUserData.getToken( 0, ';', nIdx ).toInt32() == 1 ); + m_pWrapAroundBox->Check( sUserData.getToken( 0, ';', nIdx ).toInt32() == 1 ); + m_pBackwardsBox->Check( sUserData.getToken( 0, ';', nIdx ).toInt32() == 1 ); nIdx = 0; while ( nIdx != -1 ) - m_aSearchEdit.InsertEntry( sSearchText.getToken( 0, '\t', nIdx ) ); - m_aSearchEdit.SelectEntryPos(0); + m_pSearchEdit->InsertEntry( sSearchText.getToken( 0, '\t', nIdx ) ); + m_pSearchEdit->SelectEntryPos(0); } } else - m_aWrapAroundBox.Check( sal_True ); + m_pWrapAroundBox->Check( sal_True ); } void SearchDialog::SaveConfig() @@ -111,21 +100,21 @@ void SearchDialog::SaveConfig() SvtViewOptions aViewOpt( E_DIALOG, m_sConfigName ); aViewOpt.SetWindowState(OStringToOUString(m_sWinState, RTL_TEXTENCODING_ASCII_US)); OUString sUserData; - sal_uInt16 i = 0, nCount = std::min( m_aSearchEdit.GetEntryCount(), MAX_SAVE_COUNT ); + sal_uInt16 i = 0, nCount = std::min( m_pSearchEdit->GetEntryCount(), MAX_SAVE_COUNT ); for ( ; i < nCount; ++i ) { - sUserData += m_aSearchEdit.GetEntry(i); + sUserData += m_pSearchEdit->GetEntry(i); sUserData += "\t"; } sUserData = comphelper::string::stripStart(sUserData, '\t'); sUserData += ";"; - sUserData += OUString::number( m_aWholeWordsBox.IsChecked() ? 1 : 0 ); + sUserData += OUString::number( m_pWholeWordsBox->IsChecked() ? 1 : 0 ); sUserData += ";"; - sUserData += OUString::number( m_aMatchCaseBox.IsChecked() ? 1 : 0 ); + sUserData += OUString::number( m_pMatchCaseBox->IsChecked() ? 1 : 0 ); sUserData += ";"; - sUserData += OUString::number( m_aWrapAroundBox.IsChecked() ? 1 : 0 ); + sUserData += OUString::number( m_pWrapAroundBox->IsChecked() ? 1 : 0 ); sUserData += ";"; - sUserData += OUString::number( m_aBackwardsBox.IsChecked() ? 1 : 0 ); + sUserData += OUString::number( m_pBackwardsBox->IsChecked() ? 1 : 0 ); Any aUserItem = makeAny( OUString( sUserData ) ); aViewOpt.SetUserItem( "UserItem", aUserItem ); @@ -133,29 +122,21 @@ void SearchDialog::SaveConfig() IMPL_LINK_NOARG(SearchDialog, FindHdl) { - OUString sSrchTxt = m_aSearchEdit.GetText(); - sal_uInt16 nPos = m_aSearchEdit.GetEntryPos( sSrchTxt ); + OUString sSrchTxt = m_pSearchEdit->GetText(); + sal_uInt16 nPos = m_pSearchEdit->GetEntryPos( sSrchTxt ); if ( nPos > 0 && nPos != COMBOBOX_ENTRY_NOTFOUND ) - m_aSearchEdit.RemoveEntryAt(nPos); + m_pSearchEdit->RemoveEntryAt(nPos); if ( nPos > 0 ) - m_aSearchEdit.InsertEntry( sSrchTxt, 0 ); + m_pSearchEdit->InsertEntry( sSrchTxt, 0 ); m_aFindHdl.Call( this ); return 0; } -IMPL_LINK_NOARG(SearchDialog, ToggleHdl) -{ - OUString sTemp = m_aWrapAroundBox.GetText(); - m_aWrapAroundBox.SetText( m_sToggleText ); - m_sToggleText = sTemp; - return 0; -} - void SearchDialog::SetFocusOnEdit() { - Selection aSelection( 0, m_aSearchEdit.GetText().getLength() ); - m_aSearchEdit.SetSelection( aSelection ); - m_aSearchEdit.GrabFocus(); + Selection aSelection( 0, m_pSearchEdit->GetText().getLength() ); + m_pSearchEdit->SetSelection( aSelection ); + m_pSearchEdit->GrabFocus(); } sal_Bool SearchDialog::Close() diff --git a/sfx2/source/dialog/srchdlg.hrc b/sfx2/source/dialog/srchdlg.hrc deleted file mode 100644 index 703b93f5c8fa..000000000000 --- a/sfx2/source/dialog/srchdlg.hrc +++ /dev/null @@ -1,36 +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 _SFX_SRCHDLG_HRC_ -#define _SFX_SRCHDLG_HRC_ - -#define FT_SEARCH 10 -#define ED_SEARCH 11 -#define FL_OPTIONS 12 -#define CB_WHOLEWORDS 13 -#define CB_MATCHCASE 14 -#define CB_WRAPAROUND 15 -#define CB_BACKWARDS 16 -#define PB_FIND 17 -#define PB_CANCELFIND 18 - -#define STR_TOGGLE 50 - -#endif // _SFX_SRCHDLG_HRC_ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/dialog/srchdlg.src b/sfx2/source/dialog/srchdlg.src deleted file mode 100644 index 1f41ef40bc1b..000000000000 --- a/sfx2/source/dialog/srchdlg.src +++ /dev/null @@ -1,103 +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 "srchdlg.hrc" -#include "dialog.hrc" -#include "helpid.hrc" - -ModelessDialog RID_DLG_SEARCH -{ - HelpId = HID_SEARCHDIALOG; - OutputSize = TRUE; - Moveable = TRUE; - Closeable = TRUE; - Hide = TRUE; - Size = MAP_APPFONT( 218, 84 ); - Text [ en-US ] = "Find on this Page"; - FixedText FT_SEARCH - { - Pos = MAP_APPFONT( 6, 3 ); - Size = MAP_APPFONT( 150, 8 ); - Text [ en-US ] = "~Search for"; - }; - ComboBox ED_SEARCH - { - HelpID = "sfx2:ComboBox:RID_DLG_SEARCH:ED_SEARCH"; - Border = TRUE; - Pos = MAP_APPFONT( 6, 14 ); - Size = MAP_APPFONT( 150, 50 ); - DropDown = TRUE ; - TabStop = TRUE; - }; - CheckBox CB_WHOLEWORDS - { - HelpID = "sfx2:CheckBox:RID_DLG_SEARCH:CB_WHOLEWORDS"; - Pos = MAP_APPFONT( 6, 29 ); - Size = MAP_APPFONT( 150, 10 ); - Text [ en-US ] = "~Whole words only" ; - TabStop = TRUE; - }; - CheckBox CB_MATCHCASE - { - HelpID = "sfx2:CheckBox:RID_DLG_SEARCH:CB_MATCHCASE"; - Pos = MAP_APPFONT( 6, 42 ); - Size = MAP_APPFONT( 150, 10 ); - Text[ en-US ] = "~Match case"; - TabStop = TRUE; - }; - CheckBox CB_WRAPAROUND - { - HelpID = "sfx2:CheckBox:RID_DLG_SEARCH:CB_WRAPAROUND"; - Pos = MAP_APPFONT( 6, 55 ); - Size = MAP_APPFONT( 150, 10 ); - Text [ en-US ] = "Wrap ~around" ; - TabStop = TRUE; - }; - CheckBox CB_BACKWARDS - { - HelpID = "sfx2:CheckBox:RID_DLG_SEARCH:CB_BACKWARDS"; - Pos = MAP_APPFONT( 6, 68 ); - Size = MAP_APPFONT( 150, 10 ); - Text [ en-US ] = "~Backwards" ; - TabStop = TRUE; - }; - PushButton PB_FIND - { - HelpID = "sfx2:PushButton:RID_DLG_SEARCH:PB_FIND"; - Pos = MAP_APPFONT( 162, 6 ); - Size = MAP_APPFONT( 50, 14 ); - Text [ en-US ] = "~Find" ; - TabStop = TRUE; - DefButton = TRUE ; - }; - CancelButton PB_CANCELFIND - { - Pos = MAP_APPFONT( 162, 23 ); - Size = MAP_APPFONT( 50, 14 ); - Text [ en-US ] = "~Close" ; - TabStop = TRUE; - }; - - String STR_TOGGLE - { - Text [ en-US ] = "Wrap ~around" ; - }; -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/inc/helpid.hrc b/sfx2/source/inc/helpid.hrc index d26d3f44ad73..e80939bdd768 100644 --- a/sfx2/source/inc/helpid.hrc +++ b/sfx2/source/inc/helpid.hrc @@ -122,8 +122,6 @@ #define HID_CONFIG_SAVE "SFX2_HID_CONFIG_SAVE" -#define HID_SEARCHDIALOG "SFX2_HID_SEARCHDIALOG" - #define HID_XMLSEC_QUERY_SAVEBEFORESIGN "SFX2_HID_XMLSEC_QUERY_SAVEBEFORESIGN" #define HID_XMLSECDLG_MACROWARN "SFX2_HID_XMLSECDLG_MACROWARN" #define HID_XMLSEC_INFO_WRONGDOCFORMAT "SFX2_HID_XMLSEC_INFO_WRONGDOCFORMAT" diff --git a/sfx2/uiconfig/ui/searchdialog.ui b/sfx2/uiconfig/ui/searchdialog.ui new file mode 100644 index 000000000000..3b2691f9569d --- /dev/null +++ b/sfx2/uiconfig/ui/searchdialog.ui @@ -0,0 +1,217 @@ + + + + + False + 6 + Find on this Page + dialog + + + False + vertical + 12 + + + False + end + + + _Find + True + True + True + True + True + True + + + False + True + 0 + + + + + gtk-close + True + True + True + True + top + + + False + True + 2 + + + + + False + True + end + 0 + + + + + True + False + True + vertical + 12 + + + True + False + True + 0 + none + + + True + False + True + 6 + 12 + + + True + False + center + True + True + + + + + + + True + False + _Search for + True + + + + + + + + False + True + 0 + + + + + True + False + True + 6 + + + True + False + 6 + 12 + True + + + Ma_tch case + True + True + False + True + 0 + True + + + 0 + 0 + 1 + 1 + + + + + Whole wor_ds only + True + True + False + True + 0 + True + + + 1 + 0 + 1 + 1 + + + + + Bac_kwards + True + True + False + True + 0 + True + + + 1 + 1 + 1 + 1 + + + + + Wrap _around + True + True + False + True + 0 + True + + + 0 + 1 + 1 + 1 + + + + + 0 + 0 + 1 + 1 + + + + + False + True + 2 + + + + + False + True + 1 + + + + + + search + close + + + -- cgit v1.2.3