From 0b7aef113cefd7a7fecc81910660d0cdc95add3e Mon Sep 17 00:00:00 2001
From: Vishv Brahmbhatt <vishvbrahmbhatt19@gmail.com>
Date: Tue, 29 Jan 2013 00:07:51 +0530
Subject:  fdo#59397 Use more precise wording at 'Find & Replace - More Options
 - Styles' Change-Id: I5013e8b2ce99478f2445756e181f009b93d4e746 Reviewed-on:
 https://gerrit.libreoffice.org/1905 Tested-by: Caolán McNamara
 <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 svx/inc/svx/dialogs.hrc       |  4 +--
 svx/inc/svx/srchdlg.hxx       |  2 ++
 svx/source/dialog/srchdlg.cxx | 63 ++++++++++++++++++++++++++++++++++++++++---
 svx/source/dialog/srchdlg.src |  8 ++++++
 4 files changed, 71 insertions(+), 6 deletions(-)

(limited to 'svx')

diff --git a/svx/inc/svx/dialogs.hrc b/svx/inc/svx/dialogs.hrc
index d9420b59fb8b..2ab14c7f41e6 100644
--- a/svx/inc/svx/dialogs.hrc
+++ b/svx/inc/svx/dialogs.hrc
@@ -265,8 +265,8 @@
 #define RID_SVXSTR_SEARCH_STYLES            (RID_SVX_START +  80)
 #define RID_SVXSTR_SEARCH                   (RID_SVX_START +  81)
 #define RID_SVXSTR_REPLACE                  (RID_SVX_START +  82)
-
-
+#define RID_SVXSTR_WRITER_STYLES            (RID_SVX_START +  83)
+#define RID_SVXSTR_CALC_STYLES              (RID_SVX_START +  85)
 // ResIds for the PageDialog
 
 // Strings of the ToolBox-Controls from tbcontrl.cxx
diff --git a/svx/inc/svx/srchdlg.hxx b/svx/inc/svx/srchdlg.hxx
index f95626f53384..b34dd89c7249 100644
--- a/svx/inc/svx/srchdlg.hxx
+++ b/svx/inc/svx/srchdlg.hxx
@@ -203,6 +203,8 @@ private:
     sal_uIntPtr         nModifyFlag;
     String          aStylesStr;
     String          aLayoutStr;
+    String          aLayoutWriterStr;
+    String          aLayoutCalcStr;
     String aCalcStr;
 
     std::vector<rtl::OUString> aSearchStrings;
diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx
index bb3876c73e80..250642380860 100644
--- a/svx/source/dialog/srchdlg.cxx
+++ b/svx/source/dialog/srchdlg.cxx
@@ -371,6 +371,8 @@ void SvxSearchDialog::Construct_Impl()
     aCalcStr += aWordBtn.GetText();
 
     aLayoutStr = SVX_RESSTR( RID_SVXSTR_SEARCH_STYLES );
+    aLayoutWriterStr = SVX_RESSTR( RID_SVXSTR_WRITER_STYLES );
+    aLayoutCalcStr = SVX_RESSTR( RID_SVXSTR_CALC_STYLES );
     aStylesStr = aLayoutBtn.GetText();
 
     // Get stored search-strings from the application
@@ -1985,6 +1987,23 @@ void SvxSearchDialog::SetItem_Impl( const SvxSearchItem* pItem )
 IMPL_LINK( SvxSearchDialog, FocusHdl_Impl, Control *, pCtrl )
 {
     sal_Int32 nTxtLen;
+    bool bDrawApp = false;
+    bool bCalcApp = false;
+    bool bWriterApp = false;
+    bool bImpressApp = false;
+    const uno::Reference< frame::XFrame > xFrame = rBindings.GetActiveFrame();
+    uno::Reference< frame::XModuleManager2 > xModuleManager( frame::ModuleManager::create(::comphelper::getProcessComponentContext()) );
+    try
+    {
+        ::rtl::OUString aModuleIdentifier = xModuleManager->identify( xFrame );
+        bCalcApp = aModuleIdentifier == "com.sun.star.sheet.SpreadsheetDocument";
+        bDrawApp = aModuleIdentifier == "com.sun.star.drawing.DrawingDocument";
+        bImpressApp = aModuleIdentifier == "com.sun.star.presentation.PresentationDocument";
+        bWriterApp = aModuleIdentifier == "com.sun.star.text.TextDocument";
+    }
+    catch ( uno::Exception& )
+    {
+    }
 
     if ( !pImpl->bMultiLineEdit )
         nTxtLen = aSearchAttrText.GetText().getLength();
@@ -2022,8 +2041,16 @@ IMPL_LINK( SvxSearchDialog, FocusHdl_Impl, Control *, pCtrl )
     aSearchLB.SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) );
 
     ModifyHdl_Impl( (ComboBox*)pCtrl );
-
-    aLayoutBtn.SetText( bFormat && nTxtLen ? aLayoutStr : aStylesStr );
+    
+    if(bWriterApp)    
+        aLayoutBtn.SetText( bFormat && nTxtLen ? aLayoutStr : aLayoutWriterStr );
+    else
+        {
+        if(bCalcApp)
+            aLayoutBtn.SetText( bFormat && nTxtLen ? aLayoutStr : aLayoutCalcStr );
+        else
+            aLayoutBtn.SetText( bFormat && nTxtLen ? aLayoutStr : aStylesStr );
+        }
     return 0;
 }
 
@@ -2134,8 +2161,36 @@ IMPL_LINK_NOARG(SvxSearchDialog, FormatHdl_Impl)
 // -----------------------------------------------------------------------
 
 IMPL_LINK_NOARG(SvxSearchDialog, NoFormatHdl_Impl)
-{
-    aLayoutBtn.SetText( aStylesStr );
+{   
+    bool bDrawApp = false;
+    bool bCalcApp = false;
+    bool bWriterApp = false;
+    bool bImpressApp = false;
+    const uno::Reference< frame::XFrame > xFrame = rBindings.GetActiveFrame();
+    uno::Reference< frame::XModuleManager2 > xModuleManager( frame::ModuleManager::create(::comphelper::getProcessComponentContext()) );
+    try
+    {
+        ::rtl::OUString aModuleIdentifier = xModuleManager->identify( xFrame );
+        bCalcApp = aModuleIdentifier == "com.sun.star.sheet.SpreadsheetDocument";
+        bDrawApp = aModuleIdentifier == "com.sun.star.drawing.DrawingDocument";
+        bImpressApp = aModuleIdentifier == "com.sun.star.presentation.PresentationDocument";
+        bWriterApp = aModuleIdentifier == "com.sun.star.text.TextDocument";
+    }
+    catch ( uno::Exception& )
+    {
+    }
+
+    if(bCalcApp)
+        aLayoutBtn.SetText( aLayoutCalcStr );
+    else 
+    {
+        if(bWriterApp)
+            aLayoutBtn.SetText( aLayoutWriterStr);
+        else
+            aLayoutBtn.SetText( aStylesStr );        
+    }
+        
+        
     bFormat = sal_False;
     aLayoutBtn.Check( sal_False );
 
diff --git a/svx/source/dialog/srchdlg.src b/svx/source/dialog/srchdlg.src
index 8b45d9346554..a6c7d6bd52af 100644
--- a/svx/source/dialog/srchdlg.src
+++ b/svx/source/dialog/srchdlg.src
@@ -28,6 +28,14 @@ String RID_SVXSTR_SEARCH_STYLES
 {
     Text [ en-US ] = "Including Styles" ;
 };
+String RID_SVXSTR_WRITER_STYLES
+{
+    Text [ en-US ] = "Search for Paragraph St~yles" ;
+};
+String RID_SVXSTR_CALC_STYLES
+{
+    Text [ en-US ] = "Search for Cell St~yles" ;
+};
 String RID_SVXSTR_SEARCH
 {
     Text [ en-US ] = "(Search)" ;
-- 
cgit