convert search dialog to .ui

Change-Id: I737da11ed6978edf824f00dfb3dfc29c2c5416ed
This commit is contained in:
Caolán McNamara
2013-12-06 13:35:26 +00:00
parent c2c7e4d8d9
commit d6407c8804
8 changed files with 265 additions and 211 deletions

View File

@@ -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 \

View File

@@ -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 \

View File

@@ -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 );
};

View File

@@ -23,7 +23,6 @@
#include <sfx2/sfxresid.hxx>
#include <sfx2/sfxuno.hxx>
#include "srchdlg.hrc"
#include "dialog.hrc"
#include <tools/debug.hxx>
#include <unotools/viewoptions.hxx>
@@ -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()

View File

@@ -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: */

View File

@@ -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: */

View File

@@ -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"

View File

@@ -0,0 +1,217 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkDialog" id="SearchDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes">Find on this Page</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox3">
<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_area3">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="search">
<property name="label" translatable="yes">_Find</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_underline">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="close">
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<property name="image_position">top</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="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkFrame" id="searchframe">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">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="hexpand">True</property>
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
<object class="GtkComboBox" id="searchterm">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="has_entry">True</property>
</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">_Search for</property>
<property name="use_underline">True</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">0</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="grid3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="row_spacing">6</property>
<child>
<object class="GtkGrid" id="grid13">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<property name="column_homogeneous">True</property>
<child>
<object class="GtkCheckButton" id="matchcase">
<property name="label" translatable="yes">Ma_tch case</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="wholewords">
<property name="label" translatable="yes">Whole wor_ds only</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="backwards">
<property name="label" translatable="yes">Bac_kwards</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="wrap">
<property name="label" translatable="yes">Wrap _around</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</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="position">1</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">search</action-widget>
<action-widget response="0">close</action-widget>
</action-widgets>
</object>
</interface>