diff options
author | Eike Rathke <erack@redhat.com> | 2016-02-26 00:13:07 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-02-26 01:41:50 +0100 |
commit | 393f11f88648e1c7cace6224aa7afcbf9d68ddd6 (patch) | |
tree | c7b7856b498e10e371400fca8a43472c80f1eb87 | |
parent | 82e23b52acf52fe8334d0fcba62d6b956d222445 (diff) |
add Wildcards to Find&Replace dialog
Enabled only for Calc. Writer needs to be adapted to support wildcards.
The global escape character is '\' set in SvxSearchItem ctor.
Change-Id: I1af78f296deff81e023ee9f0e936f5f506f80c83
-rw-r--r-- | include/svl/srchdefs.hxx | 5 | ||||
-rw-r--r-- | include/svx/srchdlg.hxx | 1 | ||||
-rw-r--r-- | svx/source/dialog/srchdlg.cxx | 55 | ||||
-rw-r--r-- | svx/uiconfig/ui/findreplacedialog.ui | 29 |
4 files changed, 78 insertions, 12 deletions
diff --git a/include/svl/srchdefs.hxx b/include/svl/srchdefs.hxx index 8fb303ce9a50..8c84b03ae28b 100644 --- a/include/svl/srchdefs.hxx +++ b/include/svl/srchdefs.hxx @@ -39,11 +39,12 @@ enum class SearchOptionFlags MORE = 0x0800, SIMILARITY = 0x1000, CONTENT = 0x2000, - ALL = 0x3fff + WILDCARD = 0x4000, + ALL = 0x7fff }; namespace o3tl { - template<> struct typed_flags<SearchOptionFlags> : is_typed_flags<SearchOptionFlags, 0x3fff> {}; + template<> struct typed_flags<SearchOptionFlags> : is_typed_flags<SearchOptionFlags, 0x7fff> {}; } #endif diff --git a/include/svx/srchdlg.hxx b/include/svx/srchdlg.hxx index cc4beda36eab..cd08fc8c577a 100644 --- a/include/svx/srchdlg.hxx +++ b/include/svx/srchdlg.hxx @@ -180,6 +180,7 @@ private: VclPtr<CheckBox> m_pSelectionBtn; VclPtr<CheckBox> m_pBackwardsBtn; VclPtr<CheckBox> m_pRegExpBtn; + VclPtr<CheckBox> m_pWildcardBtn; VclPtr<CheckBox> m_pSimilarityBox; VclPtr<PushButton> m_pSimilarityBtn; VclPtr<CheckBox> m_pLayoutBtn; diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx index d0424bcf8b53..d54cce84ef47 100644 --- a/svx/source/dialog/srchdlg.cxx +++ b/svx/source/dialog/srchdlg.cxx @@ -97,6 +97,7 @@ using namespace comphelper; #define MODIFY_COLUMNS 0x00002000 #define MODIFY_ALLTABLES 0x00004000 #define MODIFY_NOTES 0x00008000 +#define MODIFY_WILDCARD 0x00010000 namespace { @@ -304,6 +305,7 @@ SvxSearchDialog::SvxSearchDialog( vcl::Window* pParent, SfxChildWindow* pChildWi get(m_pSelectionBtn, "selection"); get(m_pBackwardsBtn, "backwards"); get(m_pRegExpBtn, "regexp"); + get(m_pWildcardBtn, "wildcard"); get(m_pSimilarityBox, "similarity"); get(m_pSimilarityBtn, "similaritybtn"); get(m_pLayoutBtn, "layout"); @@ -384,6 +386,7 @@ void SvxSearchDialog::dispose() m_pSelectionBtn.clear(); m_pBackwardsBtn.clear(); m_pRegExpBtn.clear(); + m_pWildcardBtn.clear(); m_pSimilarityBox.clear(); m_pSimilarityBtn.clear(); m_pLayoutBtn.clear(); @@ -552,6 +555,7 @@ bool SvxSearchDialog::Close() aOpt.SetWholeWordsOnly ( m_pWordBtn->IsChecked() ); aOpt.SetBackwards ( m_pBackwardsBtn->IsChecked() ); aOpt.SetUseRegularExpression ( m_pRegExpBtn->IsChecked() ); + aOpt.SetUseWildcard ( m_pWildcardBtn->IsChecked() ); aOpt.SetSearchForStyles ( m_pLayoutBtn->IsChecked() ); aOpt.SetSimilaritySearch ( m_pSimilarityBox->IsChecked() ); aOpt.SetUseAsianOptions ( m_pJapOptionsCB->IsChecked() ); @@ -651,6 +655,7 @@ void SvxSearchDialog::InitControls_Impl() m_pSelectionBtn->SetClickHdl( aLink2 ); m_pMatchCaseCB->SetClickHdl( aLink2 ); m_pRegExpBtn->SetClickHdl( aLink2 ); + m_pWildcardBtn->SetClickHdl( aLink2 ); m_pBackwardsBtn->SetClickHdl( aLink2 ); m_pNotesBtn->SetClickHdl( aLink2 ); m_pSimilarityBox->SetClickHdl( aLink2 ); @@ -706,6 +711,7 @@ void SvxSearchDialog::ShowOptionalControls_Impl() m_pNotesBtn->Show(bWriterApp); m_pBackwardsBtn->Show(); m_pRegExpBtn->Show(!bDrawApp); + m_pWildcardBtn->Show(bCalcApp); /* TODO:WILDCARD enable for other apps if hey handle it */ m_pSimilarityBox->Show(); m_pSimilarityBtn->Show(); m_pSelectionBtn->Show(); @@ -780,6 +786,8 @@ void SvxSearchDialog::Init_Impl( bool bSearchPattern ) m_pSelectionBtn->Check( pSearchItem->GetSelection() ); if ( ( nModifyFlag & MODIFY_REGEXP ) == 0 ) m_pRegExpBtn->Check( pSearchItem->GetRegExp() ); + if ( ( nModifyFlag & MODIFY_WILDCARD ) == 0 ) + m_pWildcardBtn->Check( pSearchItem->GetWildcard() ); if ( ( nModifyFlag & MODIFY_LAYOUT ) == 0 ) m_pLayoutBtn->Check( pSearchItem->GetPattern() ); if (m_pNotesBtn->IsChecked()) @@ -854,6 +862,7 @@ void SvxSearchDialog::Init_Impl( bool bSearchPattern ) m_pSearchAllBtn->Hide(); m_pRegExpBtn->Hide(); + m_pWildcardBtn->Hide(); m_pLayoutBtn->Hide(); // only look for formatting in Writer @@ -863,6 +872,8 @@ void SvxSearchDialog::Init_Impl( bool bSearchPattern ) } else { + m_pWildcardBtn->Hide(); /* TODO:WILDCARD do not hide for other apps if they handle it */ + if ( !pSearchList ) { // Get attribute sets, if it not has been done already @@ -942,6 +953,7 @@ void SvxSearchDialog::Init_Impl( bool bSearchPattern ) m_pWordBtn->Disable(); m_pRegExpBtn->Disable(); + m_pWildcardBtn->Disable(); m_pMatchCaseCB->Disable(); bDisableSearch = !m_pSearchTmplLB->GetEntryCount(); @@ -980,6 +992,7 @@ void SvxSearchDialog::Init_Impl( bool bSearchPattern ) m_pReplaceTmplLB->Hide(); EnableControl_Impl(m_pRegExpBtn); + EnableControl_Impl(m_pWildcardBtn); EnableControl_Impl(m_pMatchCaseCB); if ( m_pRegExpBtn->IsChecked() ) @@ -1121,6 +1134,8 @@ void SvxSearchDialog::ClickHdl_Impl(void* pCtrl) m_pSimilarityBtn->Enable(); m_pRegExpBtn->Check( false ); m_pRegExpBtn->Disable(); + m_pWildcardBtn->Check( false ); + m_pWildcardBtn->Disable(); EnableControl_Impl(m_pWordBtn); if ( m_pLayoutBtn->IsChecked() ) @@ -1129,6 +1144,7 @@ void SvxSearchDialog::ClickHdl_Impl(void* pCtrl) m_pLayoutBtn->Check( false ); } m_pRegExpBtn->Disable(); + m_pWildcardBtn->Disable(); m_pLayoutBtn->Disable(); m_pFormatBtn->Disable(); m_pNoFormatBtn->Disable(); @@ -1137,6 +1153,7 @@ void SvxSearchDialog::ClickHdl_Impl(void* pCtrl) else { EnableControl_Impl(m_pRegExpBtn); + EnableControl_Impl(m_pWildcardBtn); if (!m_pNotesBtn->IsChecked()) EnableControl_Impl(m_pLayoutBtn); EnableControl_Impl(m_pFormatBtn); @@ -1167,6 +1184,8 @@ void SvxSearchDialog::ClickHdl_Impl(void* pCtrl) m_pWordBtn->Disable(); m_pRegExpBtn->Check( false ); m_pRegExpBtn->Disable(); + m_pWildcardBtn->Check( false ); + m_pWildcardBtn->Disable(); m_pMatchCaseCB->Check( false ); m_pMatchCaseCB->Disable(); m_pNotesBtn->Disable(); @@ -1182,6 +1201,7 @@ void SvxSearchDialog::ClickHdl_Impl(void* pCtrl) else { EnableControl_Impl(m_pRegExpBtn); + EnableControl_Impl(m_pWildcardBtn); EnableControl_Impl(m_pMatchCaseCB); EnableControl_Impl(m_pNotesBtn); @@ -1189,6 +1209,17 @@ void SvxSearchDialog::ClickHdl_Impl(void* pCtrl) { m_pWordBtn->Check( false ); m_pWordBtn->Disable(); + m_pWildcardBtn->Check( false ); + m_pWildcardBtn->Disable(); + m_pSimilarityBox->Check( false ); + m_pSimilarityBox->Disable(); + m_pSimilarityBtn->Disable(); + } + else if ( m_pWildcardBtn->IsChecked() ) + { + m_pRegExpBtn->Check( false ); + m_pRegExpBtn->Disable(); + m_pSimilarityBox->Check( false ); m_pSimilarityBox->Disable(); m_pSimilarityBtn->Disable(); } @@ -1254,9 +1285,12 @@ IMPL_LINK_TYPED( SvxSearchDialog, CommandHdl_Impl, Button *, pBtn, void ) } pSearchItem->SetRegExp( false ); + pSearchItem->SetWildcard( false ); pSearchItem->SetLevenshtein( false ); if (GetCheckBoxValue(m_pRegExpBtn)) pSearchItem->SetRegExp( true ); + else if (GetCheckBoxValue(m_pWildcardBtn)) + pSearchItem->SetWildcard( true ); else if (GetCheckBoxValue(m_pSimilarityBox)) pSearchItem->SetLevenshtein( true ); @@ -1652,6 +1686,10 @@ void SvxSearchDialog::EnableControls_Impl( const SearchOptionFlags nFlags ) m_pRegExpBtn->Enable(); else m_pRegExpBtn->Disable(); + if ( ( SearchOptionFlags::WILDCARD & nOptions ) ) + m_pWildcardBtn->Enable(); + else + m_pWildcardBtn->Disable(); if ( ( SearchOptionFlags::EXACT & nOptions ) ) m_pMatchCaseCB->Enable(); else @@ -1735,11 +1773,17 @@ void SvxSearchDialog::EnableControl_Impl( Control* pCtrl ) return; } if ( m_pRegExpBtn == pCtrl && ( SearchOptionFlags::REG_EXP & nOptions ) - && !m_pSimilarityBox->IsChecked()) + && !m_pSimilarityBox->IsChecked() && !m_pWildcardBtn->IsChecked()) { m_pRegExpBtn->Enable(); return; } + if ( m_pWildcardBtn == pCtrl && ( SearchOptionFlags::WILDCARD & nOptions ) + && !m_pSimilarityBox->IsChecked() && !m_pRegExpBtn->IsChecked()) + { + m_pWildcardBtn->Enable(); + return; + } if ( m_pMatchCaseCB == pCtrl && ( SearchOptionFlags::EXACT & nOptions ) ) { if (!m_pJapOptionsCB->IsChecked()) @@ -1772,8 +1816,8 @@ void SvxSearchDialog::EnableControl_Impl( Control* pCtrl ) m_pNoFormatBtn->Enable(); return; } - if ( m_pSimilarityBox == pCtrl && - ( SearchOptionFlags::SIMILARITY & nOptions ) ) + if ( m_pSimilarityBox == pCtrl && ( SearchOptionFlags::SIMILARITY & nOptions ) + && !m_pRegExpBtn->IsChecked() && !m_pWildcardBtn->IsChecked()) { m_pSimilarityBox->Enable(); @@ -2132,6 +2176,8 @@ void SvxSearchDialog::SetModifyFlag_Impl( const Control* pCtrl ) nModifyFlag |= MODIFY_SELECTION; else if ( m_pRegExpBtn == pCtrl ) nModifyFlag |= MODIFY_REGEXP; + else if ( m_pWildcardBtn == pCtrl ) + nModifyFlag |= MODIFY_WILDCARD; else if ( m_pLayoutBtn == pCtrl ) nModifyFlag |= MODIFY_LAYOUT; else if ( m_pSimilarityBox == pCtrl ) @@ -2169,9 +2215,12 @@ void SvxSearchDialog::SaveToModule_Impl() } pSearchItem->SetRegExp( false ); + pSearchItem->SetWildcard( false ); pSearchItem->SetLevenshtein( false ); if (GetCheckBoxValue(m_pRegExpBtn)) pSearchItem->SetRegExp( true ); + else if (GetCheckBoxValue(m_pWildcardBtn)) + pSearchItem->SetWildcard( true ); else if (GetCheckBoxValue(m_pSimilarityBox)) pSearchItem->SetLevenshtein( true ); diff --git a/svx/uiconfig/ui/findreplacedialog.ui b/svx/uiconfig/ui/findreplacedialog.ui index aa25614eb5fe..bf2989c8945b 100644 --- a/svx/uiconfig/ui/findreplacedialog.ui +++ b/svx/uiconfig/ui/findreplacedialog.ui @@ -510,6 +510,21 @@ </packing> </child> <child> + <object class="GtkCheckButton" id="wildcard"> + <property name="label" translatable="yes">Wil_dcards</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="no_show_all">True</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">2</property> + </packing> + </child> + <child> <object class="GtkButtonBox" id="buttonbox1"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -561,7 +576,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">5</property> + <property name="top_attach">6</property> <property name="width">2</property> </packing> </child> @@ -607,7 +622,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">4</property> + <property name="top_attach">5</property> </packing> </child> <child> @@ -652,7 +667,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">2</property> + <property name="top_attach">3</property> </packing> </child> <child> @@ -742,7 +757,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">3</property> + <property name="top_attach">4</property> </packing> </child> <child> @@ -757,7 +772,7 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">3</property> + <property name="top_attach">4</property> </packing> </child> <child> @@ -772,7 +787,7 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">4</property> + <property name="top_attach">5</property> </packing> </child> </object> @@ -823,7 +838,7 @@ <property name="can_focus">False</property> <property name="no_show_all">True</property> <property name="xalign">0</property> - <property name="label" translatable="yes">Search _direction:</property> + <property name="label" translatable="yes">Search direction:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">calcsearchin</property> </object> |