[Libreoffice-commits] core.git: sw/source

Jochen Nitschke j.nitschke+logerrit at ok.de
Thu Dec 15 06:55:36 UTC 2016


 sw/source/filter/ww8/wrtw8esh.cxx |    3 +--
 sw/source/filter/ww8/wrtww8.cxx   |   10 ++++------
 sw/source/filter/ww8/wrtww8gr.cxx |    6 ++----
 sw/source/filter/ww8/ww8glsy.cxx  |    4 ++--
 sw/source/filter/ww8/ww8par.cxx   |   13 ++++++-------
 sw/source/filter/ww8/ww8par3.cxx  |    6 +++---
 sw/source/filter/ww8/ww8par4.cxx  |    2 +-
 sw/source/filter/ww8/ww8par5.cxx  |    2 +-
 sw/source/filter/ww8/ww8scan.cxx  |   15 ---------------
 sw/source/filter/ww8/ww8scan.hxx  |   21 +++++++++------------
 10 files changed, 29 insertions(+), 53 deletions(-)

New commits:
commit 3fefcf1e4b5f53f281aee0a1860e8a0ed1acc6ae
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date:   Wed Dec 14 17:53:14 2016 +0100

    decloak some string literals
    
    and remove explicit OUString ctor calls, now criticised by
    [loplugin:stringconstant]
    
    Change-Id: I778df2f410108e1386431a0035101444ec44c951
    Reviewed-on: https://gerrit.libreoffice.org/32014
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index 6382e88..7368c79 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -3145,8 +3145,7 @@ void SwMSConvertControls::ExportControl(WW8Export &rWW8Wrt, const SdrUnoObj& rFo
     aSize.Height = TWIPS_TO_MM(aRect.Bottom());
 
     //Open the ObjectPool
-    tools::SvRef<SotStorage> xObjPool = rWW8Wrt.GetWriter().GetStorage().OpenSotStorage(
-        OUString(SL::aObjectPool));
+    tools::SvRef<SotStorage> xObjPool = rWW8Wrt.GetWriter().GetStorage().OpenSotStorage(SL::aObjectPool);
 
     //Create a destination storage for the microsoft control
     OUStringBuffer sStorageName;
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index 7c2dff0..a266688 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -2874,7 +2874,7 @@ void WW8Export::WriteFkpPlcUsw()
          some magic.
         */
         // avoid memory leak #i120098#, the unnamed obj will be released in destructor.
-        xEscherStg = GetWriter().GetStorage().OpenSotStorage(OUString(SL::aObjectPool));
+        xEscherStg = GetWriter().GetStorage().OpenSotStorage(SL::aObjectPool);
     }
 
     // dggInfo - escher stream
@@ -3214,10 +3214,8 @@ void WW8Export::ExportDocument_Impl()
     xWwStrm->SetBufferSize( 32768 );
 
     pFib->m_fWhichTableStm = true;
-    xTableStrm = GetWriter().GetStorage().OpenSotStream(OUString(SL::a1Table),
-        StreamMode::STD_WRITE );
-    xDataStrm = GetWriter().GetStorage().OpenSotStream(OUString(SL::aData),
-        StreamMode::STD_WRITE );
+    xTableStrm = GetWriter().GetStorage().OpenSotStream(SL::a1Table, StreamMode::STD_WRITE);
+    xDataStrm = GetWriter().GetStorage().OpenSotStream(SL::aData, StreamMode::STD_WRITE);
 
     xDataStrm->SetBufferSize( 32768 );  // for graphics
     xTableStrm->SetBufferSize( 16384 ); // for the Font-/Style-Table, etc.
@@ -3380,7 +3378,7 @@ void WW8Export::ExportDocument_Impl()
     {
         xDataStrm.Clear();
         pDataStrm = nullptr;
-        GetWriter().GetStorage().Remove(OUString(SL::aData));
+        GetWriter().GetStorage().Remove(SL::aData);
     }
 }
 
diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx
index 7af628b..a19451e 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -208,8 +208,7 @@ void WW8Export::OutputOLENode( const SwOLENode& rOLENode )
     nSize = sizeof( aSpecOLE_WW8 );
     pDataAdr = pSpecOLE + 2; //WW6 sprm is 1 but has 1 byte len as well.
 
-    tools::SvRef<SotStorage> xObjStg = GetWriter().GetStorage().OpenSotStorage(
-        OUString(SL::aObjectPool) );
+    tools::SvRef<SotStorage> xObjStg = GetWriter().GetStorage().OpenSotStorage(SL::aObjectPool);
 
     if( xObjStg.Is()  )
     {
@@ -323,8 +322,7 @@ void WW8Export::OutputLinkedOLE( const OUString& rOleId )
     uno::Reference< embed::XStorage > xOleStg = xDocStg->openStorageElement( "OLELinks", embed::ElementModes::READ );
     tools::SvRef<SotStorage> xObjSrc = SotStorage::OpenOLEStorage( xOleStg, rOleId, StreamMode::READ );
 
-    tools::SvRef<SotStorage> xObjStg = GetWriter().GetStorage().OpenSotStorage(
-        OUString(SL::aObjectPool) );
+    tools::SvRef<SotStorage> xObjStg = GetWriter().GetStorage().OpenSotStorage(SL::aObjectPool);
 
     if( xObjStg.Is() && xObjSrc.Is() )
     {
diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx
index 3b335d1..c80a260 100644
--- a/sw/source/filter/ww8/ww8glsy.cxx
+++ b/sw/source/filter/ww8/ww8glsy.cxx
@@ -42,8 +42,8 @@ WW8Glossary::WW8Glossary(tools::SvRef<SotStorageStream> &refStrm, sal_uInt8 nVer
 
     if (aWwFib.m_nFibBack >= 0x6A)   //Word97
     {
-        xTableStream = pStg->OpenSotStream(OUString::createFromAscii(
-            aWwFib.m_fWhichTableStm ? SL::a1Table : SL::a0Table), StreamMode::STD_READ);
+        xTableStream = pStg->OpenSotStream(
+            aWwFib.m_fWhichTableStm ? SL::a1Table : SL::a0Table, StreamMode::STD_READ);
 
         if (xTableStream.Is() && SVSTREAM_OK == xTableStream->GetError())
         {
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 8418167..0a42707 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4887,7 +4887,8 @@ void SwWW8ImplReader::ReadGlobalTemplateSettings( const OUString& sCreatedFrom,
         tools::SvRef<SotStorageStream> refMainStream = rRoot->OpenSotStream( "WordDocument");
         refMainStream->SetEndian(SvStreamEndian::LITTLE);
         WW8Fib aWwFib( *refMainStream, 8 );
-        tools::SvRef<SotStorageStream> xTableStream = rRoot->OpenSotStream(OUString::createFromAscii( aWwFib.m_fWhichTableStm ? SL::a1Table : SL::a0Table), StreamMode::STD_READ);
+        tools::SvRef<SotStorageStream> xTableStream =
+                rRoot->OpenSotStream(aWwFib.m_fWhichTableStm ? SL::a1Table : SL::a0Table, StreamMode::STD_READ);
 
         if (xTableStream.Is() && SVSTREAM_OK == xTableStream->GetError())
         {
@@ -5426,15 +5427,14 @@ sal_uLong SwWW8ImplReader::SetSubStreams(tools::SvRef<SotStorageStream> &rTableS
                 break;
             }
 
-            rTableStream = m_pStg->OpenSotStream( OUString::createFromAscii(
-                m_pWwFib->m_fWhichTableStm ? SL::a1Table : SL::a0Table),
+            rTableStream = m_pStg->OpenSotStream(
+                m_pWwFib->m_fWhichTableStm ? SL::a1Table : SL::a0Table,
                 StreamMode::STD_READ);
 
             m_pTableStream = rTableStream.get();
             m_pTableStream->SetEndian( SvStreamEndian::LITTLE );
 
-            rDataStream = m_pStg->OpenSotStream(OUString(SL::aData),
-                StreamMode::STD_READ );
+            rDataStream = m_pStg->OpenSotStream(SL::aData, StreamMode::STD_READ);
 
             if (rDataStream.Is() && SVSTREAM_OK == rDataStream->GetError())
             {
@@ -6426,8 +6426,7 @@ bool SwMSDffManager::GetOLEStorageName(long nOLEId, OUString& rStorageName,
     {
         rStorageName = "_";
         rStorageName += OUString::number(nPictureId);
-        rSrcStorage = rReader.m_pStg->OpenSotStorage(OUString(
-            SL::aObjectPool));
+        rSrcStorage = rReader.m_pStg->OpenSotStorage(SL::aObjectPool);
         if (!rReader.m_pDocShell)
             bRet=false;
         else
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index cd292a62..1c0e9ac 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -2258,7 +2258,7 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich,
 }
 
 WW8FormulaListBox::WW8FormulaListBox(SwWW8ImplReader &rR)
-    : WW8FormulaControl(OUString(SL::aListBox), rR)
+    : WW8FormulaControl(SL::aListBox, rR)
 {
 }
 
@@ -2466,7 +2466,7 @@ bool WW8FormulaListBox::Import(const uno::Reference <
 }
 
 WW8FormulaCheckBox::WW8FormulaCheckBox(SwWW8ImplReader &rR)
-    : WW8FormulaControl(OUString(SL::aCheckBox), rR)
+    : WW8FormulaControl(SL::aCheckBox, rR)
 {
 }
 
@@ -2531,7 +2531,7 @@ bool WW8FormulaCheckBox::Import(const uno::Reference <
 }
 
 WW8FormulaEditBox::WW8FormulaEditBox(SwWW8ImplReader &rR)
-    : WW8FormulaControl(OUString(SL::aTextField) ,rR)
+    : WW8FormulaControl(SL::aTextField ,rR)
 {
 }
 
diff --git a/sw/source/filter/ww8/ww8par4.cxx b/sw/source/filter/ww8/ww8par4.cxx
index b48c94a..8f23de2 100644
--- a/sw/source/filter/ww8/ww8par4.cxx
+++ b/sw/source/filter/ww8/ww8par4.cxx
@@ -347,7 +347,7 @@ SdrObject* SwWW8ImplReader::ImportOleBase( Graphic& rGraph,
     // results in the name "_4711"
     aSrcStgName += OUString::number( m_nObjLocFc );
 
-    tools::SvRef<SotStorage> xSrc0 = m_pStg->OpenSotStorage(OUString(SL::aObjectPool));
+    tools::SvRef<SotStorage> xSrc0 = m_pStg->OpenSotStorage(SL::aObjectPool);
     tools::SvRef<SotStorage> xSrc1 = xSrc0->OpenSotStorage( aSrcStgName );
 
     if (pGrf)
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 60adcd6..24eae0d 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -630,7 +630,7 @@ sal_uInt16 SwWW8ImplReader::End_Field()
                             OUString sOleId('_');
                             sOleId += OUString::number( m_aFieldStack.back().mnObjLocFc );
 
-                            tools::SvRef<SotStorage> xSrc0 = m_pStg->OpenSotStorage(OUString(SL::aObjectPool));
+                            tools::SvRef<SotStorage> xSrc0 = m_pStg->OpenSotStorage(SL::aObjectPool);
                             tools::SvRef<SotStorage> xSrc1 = xSrc0->OpenSotStorage( sOleId, StreamMode::READ );
 
                             // Store it now!
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 427e4f1..2be1b5b 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -51,21 +51,6 @@
 
 using namespace ::com::sun::star::lang;
 
-//-begin
-namespace SL
-{
-#   define IMPLCONSTSTRINGARRAY(X) const char a##X[] = #X
-    IMPLCONSTSTRINGARRAY(ObjectPool);
-    IMPLCONSTSTRINGARRAY(1Table);
-    IMPLCONSTSTRINGARRAY(0Table);
-    IMPLCONSTSTRINGARRAY(Data);
-    IMPLCONSTSTRINGARRAY(CheckBox);
-    IMPLCONSTSTRINGARRAY(ListBox);
-    IMPLCONSTSTRINGARRAY(TextBox);
-    IMPLCONSTSTRINGARRAY(TextField);
-    IMPLCONSTSTRINGARRAY(MSMacroCmds);
-}
-
 namespace
 {
     /**
diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx
index 3587a9f..f3e337e 100644
--- a/sw/source/filter/ww8/ww8scan.hxx
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -43,21 +43,18 @@
 
 class SvStream;
 
-//--Line below which the code has meaningful comments
-
 //Commonly used string literals for stream and storage names in word docs
 namespace SL
 {
-#   define DEFCONSTSTRINGARRAY(X) extern const char a##X[sizeof(#X)]
-    DEFCONSTSTRINGARRAY(ObjectPool);
-    DEFCONSTSTRINGARRAY(1Table);
-    DEFCONSTSTRINGARRAY(0Table);
-    DEFCONSTSTRINGARRAY(Data);
-    DEFCONSTSTRINGARRAY(CheckBox);
-    DEFCONSTSTRINGARRAY(ListBox);
-    DEFCONSTSTRINGARRAY(TextBox);
-    DEFCONSTSTRINGARRAY(TextField);
-    DEFCONSTSTRINGARRAY(MSMacroCmds);
+    const char aObjectPool[]    = "ObjectPool";
+    const char a1Table[]        = "1Table";
+    const char a0Table[]        = "0Table";
+    const char aData[]          = "Data";
+    const char aCheckBox[]      = "CheckBox";
+    const char aListBox[]       = "ListBox";
+    const char aTextBox[]       = "TextBox";
+    const char aTextField[]     = "TextField";
+    const char aMSMacroCmds[]   = "MSMacroCmds";
 }
 
 struct SprmInfo


More information about the Libreoffice-commits mailing list