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
This commit is contained in:
Eike Rathke
2016-02-26 00:13:07 +01:00
parent 82e23b52ac
commit 393f11f886
4 changed files with 78 additions and 12 deletions

View File

@@ -39,11 +39,12 @@ enum class SearchOptionFlags
MORE = 0x0800, MORE = 0x0800,
SIMILARITY = 0x1000, SIMILARITY = 0x1000,
CONTENT = 0x2000, CONTENT = 0x2000,
ALL = 0x3fff WILDCARD = 0x4000,
ALL = 0x7fff
}; };
namespace o3tl namespace o3tl
{ {
template<> struct typed_flags<SearchOptionFlags> : is_typed_flags<SearchOptionFlags, 0x3fff> {}; template<> struct typed_flags<SearchOptionFlags> : is_typed_flags<SearchOptionFlags, 0x7fff> {};
} }
#endif #endif

View File

@@ -180,6 +180,7 @@ private:
VclPtr<CheckBox> m_pSelectionBtn; VclPtr<CheckBox> m_pSelectionBtn;
VclPtr<CheckBox> m_pBackwardsBtn; VclPtr<CheckBox> m_pBackwardsBtn;
VclPtr<CheckBox> m_pRegExpBtn; VclPtr<CheckBox> m_pRegExpBtn;
VclPtr<CheckBox> m_pWildcardBtn;
VclPtr<CheckBox> m_pSimilarityBox; VclPtr<CheckBox> m_pSimilarityBox;
VclPtr<PushButton> m_pSimilarityBtn; VclPtr<PushButton> m_pSimilarityBtn;
VclPtr<CheckBox> m_pLayoutBtn; VclPtr<CheckBox> m_pLayoutBtn;

View File

@@ -97,6 +97,7 @@ using namespace comphelper;
#define MODIFY_COLUMNS 0x00002000 #define MODIFY_COLUMNS 0x00002000
#define MODIFY_ALLTABLES 0x00004000 #define MODIFY_ALLTABLES 0x00004000
#define MODIFY_NOTES 0x00008000 #define MODIFY_NOTES 0x00008000
#define MODIFY_WILDCARD 0x00010000
namespace namespace
{ {
@@ -304,6 +305,7 @@ SvxSearchDialog::SvxSearchDialog( vcl::Window* pParent, SfxChildWindow* pChildWi
get(m_pSelectionBtn, "selection"); get(m_pSelectionBtn, "selection");
get(m_pBackwardsBtn, "backwards"); get(m_pBackwardsBtn, "backwards");
get(m_pRegExpBtn, "regexp"); get(m_pRegExpBtn, "regexp");
get(m_pWildcardBtn, "wildcard");
get(m_pSimilarityBox, "similarity"); get(m_pSimilarityBox, "similarity");
get(m_pSimilarityBtn, "similaritybtn"); get(m_pSimilarityBtn, "similaritybtn");
get(m_pLayoutBtn, "layout"); get(m_pLayoutBtn, "layout");
@@ -384,6 +386,7 @@ void SvxSearchDialog::dispose()
m_pSelectionBtn.clear(); m_pSelectionBtn.clear();
m_pBackwardsBtn.clear(); m_pBackwardsBtn.clear();
m_pRegExpBtn.clear(); m_pRegExpBtn.clear();
m_pWildcardBtn.clear();
m_pSimilarityBox.clear(); m_pSimilarityBox.clear();
m_pSimilarityBtn.clear(); m_pSimilarityBtn.clear();
m_pLayoutBtn.clear(); m_pLayoutBtn.clear();
@@ -552,6 +555,7 @@ bool SvxSearchDialog::Close()
aOpt.SetWholeWordsOnly ( m_pWordBtn->IsChecked() ); aOpt.SetWholeWordsOnly ( m_pWordBtn->IsChecked() );
aOpt.SetBackwards ( m_pBackwardsBtn->IsChecked() ); aOpt.SetBackwards ( m_pBackwardsBtn->IsChecked() );
aOpt.SetUseRegularExpression ( m_pRegExpBtn->IsChecked() ); aOpt.SetUseRegularExpression ( m_pRegExpBtn->IsChecked() );
aOpt.SetUseWildcard ( m_pWildcardBtn->IsChecked() );
aOpt.SetSearchForStyles ( m_pLayoutBtn->IsChecked() ); aOpt.SetSearchForStyles ( m_pLayoutBtn->IsChecked() );
aOpt.SetSimilaritySearch ( m_pSimilarityBox->IsChecked() ); aOpt.SetSimilaritySearch ( m_pSimilarityBox->IsChecked() );
aOpt.SetUseAsianOptions ( m_pJapOptionsCB->IsChecked() ); aOpt.SetUseAsianOptions ( m_pJapOptionsCB->IsChecked() );
@@ -651,6 +655,7 @@ void SvxSearchDialog::InitControls_Impl()
m_pSelectionBtn->SetClickHdl( aLink2 ); m_pSelectionBtn->SetClickHdl( aLink2 );
m_pMatchCaseCB->SetClickHdl( aLink2 ); m_pMatchCaseCB->SetClickHdl( aLink2 );
m_pRegExpBtn->SetClickHdl( aLink2 ); m_pRegExpBtn->SetClickHdl( aLink2 );
m_pWildcardBtn->SetClickHdl( aLink2 );
m_pBackwardsBtn->SetClickHdl( aLink2 ); m_pBackwardsBtn->SetClickHdl( aLink2 );
m_pNotesBtn->SetClickHdl( aLink2 ); m_pNotesBtn->SetClickHdl( aLink2 );
m_pSimilarityBox->SetClickHdl( aLink2 ); m_pSimilarityBox->SetClickHdl( aLink2 );
@@ -706,6 +711,7 @@ void SvxSearchDialog::ShowOptionalControls_Impl()
m_pNotesBtn->Show(bWriterApp); m_pNotesBtn->Show(bWriterApp);
m_pBackwardsBtn->Show(); m_pBackwardsBtn->Show();
m_pRegExpBtn->Show(!bDrawApp); m_pRegExpBtn->Show(!bDrawApp);
m_pWildcardBtn->Show(bCalcApp); /* TODO:WILDCARD enable for other apps if hey handle it */
m_pSimilarityBox->Show(); m_pSimilarityBox->Show();
m_pSimilarityBtn->Show(); m_pSimilarityBtn->Show();
m_pSelectionBtn->Show(); m_pSelectionBtn->Show();
@@ -780,6 +786,8 @@ void SvxSearchDialog::Init_Impl( bool bSearchPattern )
m_pSelectionBtn->Check( pSearchItem->GetSelection() ); m_pSelectionBtn->Check( pSearchItem->GetSelection() );
if ( ( nModifyFlag & MODIFY_REGEXP ) == 0 ) if ( ( nModifyFlag & MODIFY_REGEXP ) == 0 )
m_pRegExpBtn->Check( pSearchItem->GetRegExp() ); m_pRegExpBtn->Check( pSearchItem->GetRegExp() );
if ( ( nModifyFlag & MODIFY_WILDCARD ) == 0 )
m_pWildcardBtn->Check( pSearchItem->GetWildcard() );
if ( ( nModifyFlag & MODIFY_LAYOUT ) == 0 ) if ( ( nModifyFlag & MODIFY_LAYOUT ) == 0 )
m_pLayoutBtn->Check( pSearchItem->GetPattern() ); m_pLayoutBtn->Check( pSearchItem->GetPattern() );
if (m_pNotesBtn->IsChecked()) if (m_pNotesBtn->IsChecked())
@@ -854,6 +862,7 @@ void SvxSearchDialog::Init_Impl( bool bSearchPattern )
m_pSearchAllBtn->Hide(); m_pSearchAllBtn->Hide();
m_pRegExpBtn->Hide(); m_pRegExpBtn->Hide();
m_pWildcardBtn->Hide();
m_pLayoutBtn->Hide(); m_pLayoutBtn->Hide();
// only look for formatting in Writer // only look for formatting in Writer
@@ -863,6 +872,8 @@ void SvxSearchDialog::Init_Impl( bool bSearchPattern )
} }
else else
{ {
m_pWildcardBtn->Hide(); /* TODO:WILDCARD do not hide for other apps if they handle it */
if ( !pSearchList ) if ( !pSearchList )
{ {
// Get attribute sets, if it not has been done already // Get attribute sets, if it not has been done already
@@ -942,6 +953,7 @@ void SvxSearchDialog::Init_Impl( bool bSearchPattern )
m_pWordBtn->Disable(); m_pWordBtn->Disable();
m_pRegExpBtn->Disable(); m_pRegExpBtn->Disable();
m_pWildcardBtn->Disable();
m_pMatchCaseCB->Disable(); m_pMatchCaseCB->Disable();
bDisableSearch = !m_pSearchTmplLB->GetEntryCount(); bDisableSearch = !m_pSearchTmplLB->GetEntryCount();
@@ -980,6 +992,7 @@ void SvxSearchDialog::Init_Impl( bool bSearchPattern )
m_pReplaceTmplLB->Hide(); m_pReplaceTmplLB->Hide();
EnableControl_Impl(m_pRegExpBtn); EnableControl_Impl(m_pRegExpBtn);
EnableControl_Impl(m_pWildcardBtn);
EnableControl_Impl(m_pMatchCaseCB); EnableControl_Impl(m_pMatchCaseCB);
if ( m_pRegExpBtn->IsChecked() ) if ( m_pRegExpBtn->IsChecked() )
@@ -1121,6 +1134,8 @@ void SvxSearchDialog::ClickHdl_Impl(void* pCtrl)
m_pSimilarityBtn->Enable(); m_pSimilarityBtn->Enable();
m_pRegExpBtn->Check( false ); m_pRegExpBtn->Check( false );
m_pRegExpBtn->Disable(); m_pRegExpBtn->Disable();
m_pWildcardBtn->Check( false );
m_pWildcardBtn->Disable();
EnableControl_Impl(m_pWordBtn); EnableControl_Impl(m_pWordBtn);
if ( m_pLayoutBtn->IsChecked() ) if ( m_pLayoutBtn->IsChecked() )
@@ -1129,6 +1144,7 @@ void SvxSearchDialog::ClickHdl_Impl(void* pCtrl)
m_pLayoutBtn->Check( false ); m_pLayoutBtn->Check( false );
} }
m_pRegExpBtn->Disable(); m_pRegExpBtn->Disable();
m_pWildcardBtn->Disable();
m_pLayoutBtn->Disable(); m_pLayoutBtn->Disable();
m_pFormatBtn->Disable(); m_pFormatBtn->Disable();
m_pNoFormatBtn->Disable(); m_pNoFormatBtn->Disable();
@@ -1137,6 +1153,7 @@ void SvxSearchDialog::ClickHdl_Impl(void* pCtrl)
else else
{ {
EnableControl_Impl(m_pRegExpBtn); EnableControl_Impl(m_pRegExpBtn);
EnableControl_Impl(m_pWildcardBtn);
if (!m_pNotesBtn->IsChecked()) if (!m_pNotesBtn->IsChecked())
EnableControl_Impl(m_pLayoutBtn); EnableControl_Impl(m_pLayoutBtn);
EnableControl_Impl(m_pFormatBtn); EnableControl_Impl(m_pFormatBtn);
@@ -1167,6 +1184,8 @@ void SvxSearchDialog::ClickHdl_Impl(void* pCtrl)
m_pWordBtn->Disable(); m_pWordBtn->Disable();
m_pRegExpBtn->Check( false ); m_pRegExpBtn->Check( false );
m_pRegExpBtn->Disable(); m_pRegExpBtn->Disable();
m_pWildcardBtn->Check( false );
m_pWildcardBtn->Disable();
m_pMatchCaseCB->Check( false ); m_pMatchCaseCB->Check( false );
m_pMatchCaseCB->Disable(); m_pMatchCaseCB->Disable();
m_pNotesBtn->Disable(); m_pNotesBtn->Disable();
@@ -1182,6 +1201,7 @@ void SvxSearchDialog::ClickHdl_Impl(void* pCtrl)
else else
{ {
EnableControl_Impl(m_pRegExpBtn); EnableControl_Impl(m_pRegExpBtn);
EnableControl_Impl(m_pWildcardBtn);
EnableControl_Impl(m_pMatchCaseCB); EnableControl_Impl(m_pMatchCaseCB);
EnableControl_Impl(m_pNotesBtn); EnableControl_Impl(m_pNotesBtn);
@@ -1189,6 +1209,17 @@ void SvxSearchDialog::ClickHdl_Impl(void* pCtrl)
{ {
m_pWordBtn->Check( false ); m_pWordBtn->Check( false );
m_pWordBtn->Disable(); 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_pSimilarityBox->Disable();
m_pSimilarityBtn->Disable(); m_pSimilarityBtn->Disable();
} }
@@ -1254,9 +1285,12 @@ IMPL_LINK_TYPED( SvxSearchDialog, CommandHdl_Impl, Button *, pBtn, void )
} }
pSearchItem->SetRegExp( false ); pSearchItem->SetRegExp( false );
pSearchItem->SetWildcard( false );
pSearchItem->SetLevenshtein( false ); pSearchItem->SetLevenshtein( false );
if (GetCheckBoxValue(m_pRegExpBtn)) if (GetCheckBoxValue(m_pRegExpBtn))
pSearchItem->SetRegExp( true ); pSearchItem->SetRegExp( true );
else if (GetCheckBoxValue(m_pWildcardBtn))
pSearchItem->SetWildcard( true );
else if (GetCheckBoxValue(m_pSimilarityBox)) else if (GetCheckBoxValue(m_pSimilarityBox))
pSearchItem->SetLevenshtein( true ); pSearchItem->SetLevenshtein( true );
@@ -1652,6 +1686,10 @@ void SvxSearchDialog::EnableControls_Impl( const SearchOptionFlags nFlags )
m_pRegExpBtn->Enable(); m_pRegExpBtn->Enable();
else else
m_pRegExpBtn->Disable(); m_pRegExpBtn->Disable();
if ( ( SearchOptionFlags::WILDCARD & nOptions ) )
m_pWildcardBtn->Enable();
else
m_pWildcardBtn->Disable();
if ( ( SearchOptionFlags::EXACT & nOptions ) ) if ( ( SearchOptionFlags::EXACT & nOptions ) )
m_pMatchCaseCB->Enable(); m_pMatchCaseCB->Enable();
else else
@@ -1735,11 +1773,17 @@ void SvxSearchDialog::EnableControl_Impl( Control* pCtrl )
return; return;
} }
if ( m_pRegExpBtn == pCtrl && ( SearchOptionFlags::REG_EXP & nOptions ) if ( m_pRegExpBtn == pCtrl && ( SearchOptionFlags::REG_EXP & nOptions )
&& !m_pSimilarityBox->IsChecked()) && !m_pSimilarityBox->IsChecked() && !m_pWildcardBtn->IsChecked())
{ {
m_pRegExpBtn->Enable(); m_pRegExpBtn->Enable();
return; 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_pMatchCaseCB == pCtrl && ( SearchOptionFlags::EXACT & nOptions ) )
{ {
if (!m_pJapOptionsCB->IsChecked()) if (!m_pJapOptionsCB->IsChecked())
@@ -1772,8 +1816,8 @@ void SvxSearchDialog::EnableControl_Impl( Control* pCtrl )
m_pNoFormatBtn->Enable(); m_pNoFormatBtn->Enable();
return; return;
} }
if ( m_pSimilarityBox == pCtrl && if ( m_pSimilarityBox == pCtrl && ( SearchOptionFlags::SIMILARITY & nOptions )
( SearchOptionFlags::SIMILARITY & nOptions ) ) && !m_pRegExpBtn->IsChecked() && !m_pWildcardBtn->IsChecked())
{ {
m_pSimilarityBox->Enable(); m_pSimilarityBox->Enable();
@@ -2132,6 +2176,8 @@ void SvxSearchDialog::SetModifyFlag_Impl( const Control* pCtrl )
nModifyFlag |= MODIFY_SELECTION; nModifyFlag |= MODIFY_SELECTION;
else if ( m_pRegExpBtn == pCtrl ) else if ( m_pRegExpBtn == pCtrl )
nModifyFlag |= MODIFY_REGEXP; nModifyFlag |= MODIFY_REGEXP;
else if ( m_pWildcardBtn == pCtrl )
nModifyFlag |= MODIFY_WILDCARD;
else if ( m_pLayoutBtn == pCtrl ) else if ( m_pLayoutBtn == pCtrl )
nModifyFlag |= MODIFY_LAYOUT; nModifyFlag |= MODIFY_LAYOUT;
else if ( m_pSimilarityBox == pCtrl ) else if ( m_pSimilarityBox == pCtrl )
@@ -2169,9 +2215,12 @@ void SvxSearchDialog::SaveToModule_Impl()
} }
pSearchItem->SetRegExp( false ); pSearchItem->SetRegExp( false );
pSearchItem->SetWildcard( false );
pSearchItem->SetLevenshtein( false ); pSearchItem->SetLevenshtein( false );
if (GetCheckBoxValue(m_pRegExpBtn)) if (GetCheckBoxValue(m_pRegExpBtn))
pSearchItem->SetRegExp( true ); pSearchItem->SetRegExp( true );
else if (GetCheckBoxValue(m_pWildcardBtn))
pSearchItem->SetWildcard( true );
else if (GetCheckBoxValue(m_pSimilarityBox)) else if (GetCheckBoxValue(m_pSimilarityBox))
pSearchItem->SetLevenshtein( true ); pSearchItem->SetLevenshtein( true );

View File

@@ -509,6 +509,21 @@
<property name="top_attach">1</property> <property name="top_attach">1</property>
</packing> </packing>
</child> </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> <child>
<object class="GtkButtonBox" id="buttonbox1"> <object class="GtkButtonBox" id="buttonbox1">
<property name="visible">True</property> <property name="visible">True</property>
@@ -561,7 +576,7 @@
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">5</property> <property name="top_attach">6</property>
<property name="width">2</property> <property name="width">2</property>
</packing> </packing>
</child> </child>
@@ -607,7 +622,7 @@
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">4</property> <property name="top_attach">5</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -652,7 +667,7 @@
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">2</property> <property name="top_attach">3</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -742,7 +757,7 @@
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">3</property> <property name="top_attach">4</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -757,7 +772,7 @@
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="top_attach">3</property> <property name="top_attach">4</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -772,7 +787,7 @@
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="top_attach">4</property> <property name="top_attach">5</property>
</packing> </packing>
</child> </child>
</object> </object>
@@ -823,7 +838,7 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="no_show_all">True</property> <property name="no_show_all">True</property>
<property name="xalign">0</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="use_underline">True</property>
<property name="mnemonic_widget">calcsearchin</property> <property name="mnemonic_widget">calcsearchin</property>
</object> </object>