Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/1803

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/03/1803/1

tools/string.hxx: add operator==/!= for OUString/String

This has the disadvantage that it makes comparisons involving fast
OUString concatenation via operator+ ambiguous, as can be seen in
scriptdlg.cxx, but it allows comparing String and OUString wihout
explicit conversion, which is nice for incrementally converting code.

Change-Id: Ibfc728bdb161a01e0f8311915c97bcbba8b58c0b
---
M cui/source/dialogs/scriptdlg.cxx
M cui/source/options/opthtml.cxx
M forms/source/solar/control/navtoolbar.cxx
M sc/source/ui/app/inputwin.cxx
M sc/source/ui/dbgui/dbnamdlg.cxx
M sd/source/ui/dlg/paragr.cxx
M tools/inc/tools/string.hxx
7 files changed, 39 insertions(+), 16 deletions(-)



diff --git a/cui/source/dialogs/scriptdlg.cxx b/cui/source/dialogs/scriptdlg.cxx
index f4b1e94..944ca6f 100644
--- a/cui/source/dialogs/scriptdlg.cxx
+++ b/cui/source/dialogs/scriptdlg.cxx
@@ -910,7 +910,7 @@
             }
             for( sal_Int32 index = 0; index < childNodes.getLength(); index++ )
             {
-                if ( (aNewName+extn) == childNodes[index]->getName() )
+                if (OUString(aNewName+extn) == childNodes[index]->getName())
                 {
                     bFound = sal_True;
                     break;
@@ -939,7 +939,8 @@
                 bValid = sal_True;
                 for( sal_Int32 index = 0; index < childNodes.getLength(); index++ )
                 {
-                    if ( (aUserSuppliedName+extn) == childNodes[index]->getName() )
+                    if (OUString(aUserSuppliedName+extn)
+                            == childNodes[index]->getName())
                     {
                         bValid = sal_False;
                         String aError( m_createErrStr );
diff --git a/cui/source/options/opthtml.cxx b/cui/source/options/opthtml.cxx
index 49a57fc..9993030 100644
--- a/cui/source/options/opthtml.cxx
+++ b/cui/source/options/opthtml.cxx
@@ -111,19 +111,19 @@
 sal_Bool OfaHtmlTabPage::FillItemSet( SfxItemSet& )
 {
     SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
-    if(OUString(aSize1NF.GetSavedValue()) != aSize1NF.GetText())
+    if(aSize1NF.GetSavedValue() != aSize1NF.GetText())
         rHtmlOpt.SetFontSize(0, (sal_uInt16)aSize1NF.GetValue());
-    if(OUString(aSize2NF.GetSavedValue()) != aSize2NF.GetText())
+    if(aSize2NF.GetSavedValue() != aSize2NF.GetText())
         rHtmlOpt.SetFontSize(1, (sal_uInt16)aSize2NF.GetValue());
-    if(OUString(aSize3NF.GetSavedValue()) != aSize3NF.GetText())
+    if(aSize3NF.GetSavedValue() != aSize3NF.GetText())
         rHtmlOpt.SetFontSize(2, (sal_uInt16)aSize3NF.GetValue());
-    if(OUString(aSize4NF.GetSavedValue()) != aSize4NF.GetText())
+    if(aSize4NF.GetSavedValue() != aSize4NF.GetText())
         rHtmlOpt.SetFontSize(3, (sal_uInt16)aSize4NF.GetValue());
-    if(OUString(aSize5NF.GetSavedValue()) != aSize5NF.GetText())
+    if(aSize5NF.GetSavedValue() != aSize5NF.GetText())
         rHtmlOpt.SetFontSize(4, (sal_uInt16)aSize5NF.GetValue());
-    if(OUString(aSize6NF.GetSavedValue()) != aSize6NF.GetText())
+    if(aSize6NF.GetSavedValue() != aSize6NF.GetText())
         rHtmlOpt.SetFontSize(5, (sal_uInt16)aSize6NF.GetValue());
-    if(OUString(aSize7NF.GetSavedValue()) != aSize7NF.GetText())
+    if(aSize7NF.GetSavedValue() != aSize7NF.GetText())
         rHtmlOpt.SetFontSize(6, (sal_uInt16)aSize7NF.GetValue());
 
     if(aNumbersEnglishUSCB.IsChecked() != aNumbersEnglishUSCB.GetSavedValue())
diff --git a/forms/source/solar/control/navtoolbar.cxx b/forms/source/solar/control/navtoolbar.cxx
index a356a7f..f146a7e 100644
--- a/forms/source/solar/control/navtoolbar.cxx
+++ b/forms/source/solar/control/navtoolbar.cxx
@@ -685,7 +685,7 @@
     //---------------------------------------------------------------------
     void RecordPositionInput::FirePosition( sal_Bool _bForce )
     {
-        if ( _bForce || ( GetText() != OUString(GetSavedValue()) ) )
+        if ( _bForce || (GetText() != GetSavedValue()) )
         {
             sal_Int64 nRecord = GetValue();
             if ( nRecord < GetMin() || nRecord > GetMax() )
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 64be1b4..79b71d8 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1373,7 +1373,7 @@
     pEditEngine->SetUpdateMode( sal_True );
 
     // aString ist die Wahrheit...
-    if ( bFilled && pEditEngine->GetText() == OUString(aString) )
+    if (bFilled && pEditEngine->GetText() == aString)
         Invalidate();                                          // Repaint fuer (hinterlegte) Felder
     else
         pEditEngine->SetText(aString);         // dann wenigstens den richtigen Text
@@ -1754,7 +1754,7 @@
         pEditEngine->SetUpdateMode( sal_True );
 
         //  aString ist die Wahrheit...
-        if ( bFilled && pEditEngine->GetText() == OUString(aString) )
+        if (bFilled && pEditEngine->GetText() == aString)
             Invalidate();                       // Repaint fuer (hinterlegte) Felder
         else
             pEditEngine->SetText(aString);      // dann wenigstens den richtigen Text
diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx
index 24a1fce..e958bf9 100644
--- a/sc/source/ui/dbgui/dbnamdlg.cxx
+++ b/sc/source/ui/dbgui/dbnamdlg.cxx
@@ -601,7 +601,7 @@
 
     if ( theName.isEmpty() )
     {
-        if ( aBtnAdd.GetText() != OUString(aStrAdd) )
+        if (aBtnAdd.GetText() != aStrAdd)
             aBtnAdd.SetText( aStrAdd );
         aBtnAdd     .Disable();
         aBtnRemove  .Disable();
@@ -624,7 +624,7 @@
     {
         if ( bNameFound )
         {
-            if ( aBtnAdd.GetText() != OUString(aStrModify) )
+            if (aBtnAdd.GetText() != aStrModify)
                 aBtnAdd.SetText( aStrModify );
 
             if(!bSaved)
@@ -636,7 +636,7 @@
         }
         else
         {
-            if ( aBtnAdd.GetText() != OUString(aStrAdd) )
+            if (aBtnAdd.GetText() != aStrAdd)
                 aBtnAdd.SetText( aStrAdd );
 
             bSaved=false;
diff --git a/sd/source/ui/dlg/paragr.cxx b/sd/source/ui/dlg/paragr.cxx
index 8cb3b77..1029bae 100644
--- a/sd/source/ui/dlg/paragr.cxx
+++ b/sd/source/ui/dlg/paragr.cxx
@@ -97,7 +97,7 @@
 {
     if(maNewStartCB.GetState() != maNewStartCB.GetSavedValue() ||
         maNewStartNumberCB.GetState() != maNewStartNumberCB.GetSavedValue()||
-       maNewStartNF.GetText() != OUString(maNewStartNF.GetSavedValue()))
+       maNewStartNF.GetText() != maNewStartNF.GetSavedValue())
     {
         mbModified = true;
         sal_Bool bNewStartChecked = STATE_CHECK == maNewStartCB.GetState();
diff --git a/tools/inc/tools/string.hxx b/tools/inc/tools/string.hxx
index 03276c1..0adf08c 100644
--- a/tools/inc/tools/string.hxx
+++ b/tools/inc/tools/string.hxx
@@ -333,6 +333,28 @@
 
 #endif
 
+// some compare operators, so that conversions from String to OUString don't
+// have to insert conversions all over the place
+inline bool operator==(UniString const& rLeft, ::rtl::OUString const& rRight)
+{
+    return ::rtl::OUString(rLeft) == rRight;
+}
+
+inline bool operator==(::rtl::OUString const& rLeft, UniString const& rRight)
+{
+    return rLeft == ::rtl::OUString(rRight);
+}
+
+inline bool operator!=(UniString const& rLeft, ::rtl::OUString const& rRight)
+{
+    return ::rtl::OUString(rLeft) != rRight;
+}
+
+inline bool operator!=(::rtl::OUString const& rLeft, UniString const& rRight)
+{
+    return rLeft != ::rtl::OUString(rRight);
+}
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

-- 
To view, visit https://gerrit.libreoffice.org/1803
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibfc728bdb161a01e0f8311915c97bcbba8b58c0b
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Michael Stahl <mstahl@redhat.com>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.