[Libreoffice-commits] core.git: vbahelper/source vcl/source vcl/unx writerfilter/source

Noel Grandin noel.grandin at collabora.co.uk
Mon Oct 31 10:03:24 UTC 2016


 vbahelper/source/vbahelper/vbacommandbarhelper.cxx |    3 +--
 vbahelper/source/vbahelper/vbadocumentsbase.cxx    |    7 ++-----
 vbahelper/source/vbahelper/vbahelper.cxx           |    6 ++----
 vcl/source/font/PhysicalFontCollection.cxx         |    4 +---
 vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx           |    7 ++-----
 vcl/unx/gtk/gtksalmenu.cxx                         |    2 +-
 writerfilter/source/dmapper/DomainMapper_Impl.cxx  |   12 ++++--------
 writerfilter/source/dmapper/FormControlHelper.cxx  |    5 +----
 writerfilter/source/dmapper/OLEHandler.cxx         |    3 +--
 9 files changed, 15 insertions(+), 34 deletions(-)

New commits:
commit 04bfdc0a82c306dbe16e7d79e78f2b1c8fd05475
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Oct 31 10:28:18 2016 +0200

    loplugin:oncevar in vbahelper..writerfilter
    
    Change-Id: Ifd7e91753d9652d6b1c535cde3cddf74757a2483
    Reviewed-on: https://gerrit.libreoffice.org/30430
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/vbahelper/source/vbahelper/vbacommandbarhelper.cxx b/vbahelper/source/vbahelper/vbacommandbarhelper.cxx
index fe65272..8bd5fb0 100644
--- a/vbahelper/source/vbahelper/vbacommandbarhelper.cxx
+++ b/vbahelper/source/vbahelper/vbacommandbarhelper.cxx
@@ -200,8 +200,7 @@ OUString VbaCommandBarHelper::findToolbarByName( const css::uno::Reference< css:
     }
 
     // the customize toolbars creating during importing, should found there.
-    static const char sToolbarPrefix[] = "private:resource/toolbar/custom_";
-    sResourceUrl = sToolbarPrefix + sName;
+    sResourceUrl = "private:resource/toolbar/custom_" + sName;
     if( hasToolbar( sResourceUrl, sName ) )
         return sResourceUrl;
 
diff --git a/vbahelper/source/vbahelper/vbadocumentsbase.cxx b/vbahelper/source/vbahelper/vbadocumentsbase.cxx
index 230a7f0..2816992 100644
--- a/vbahelper/source/vbahelper/vbadocumentsbase.cxx
+++ b/vbahelper/source/vbahelper/vbadocumentsbase.cxx
@@ -55,9 +55,6 @@
 using namespace ::ooo::vba;
 using namespace ::com::sun::star;
 
-static const char aSpreadsheetDocument[] = "com.sun.star.sheet.SpreadsheetDocument";
-static const char aTextDocument[] = "com.sun.star.text.TextDocument";
-
 typedef  std::unordered_map< OUString,
                              sal_Int32, OUStringHash > NameIndexHash;
 
@@ -131,8 +128,8 @@ public:
         {
             uno::Reference< lang::XServiceInfo > xServiceInfo( xEnum->nextElement(), uno::UNO_QUERY );
             if ( xServiceInfo.is()
-                && (  ( xServiceInfo->supportsService( aSpreadsheetDocument ) && meDocType == VbaDocumentsBase::EXCEL_DOCUMENT )
-                || ( xServiceInfo->supportsService( aTextDocument ) && meDocType == VbaDocumentsBase::WORD_DOCUMENT ) ) )
+                && (  ( xServiceInfo->supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) && meDocType == VbaDocumentsBase::EXCEL_DOCUMENT )
+                || ( xServiceInfo->supportsService( "com.sun.star.text.TextDocument" ) && meDocType == VbaDocumentsBase::WORD_DOCUMENT ) ) )
             {
                 uno::Reference< frame::XModel > xModel( xServiceInfo, uno::UNO_QUERY_THROW ); // that the spreadsheetdocument is a xmodel is a given
                 m_documents.push_back( xModel );
diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx
index 76b0e7e..e19c128 100644
--- a/vbahelper/source/vbahelper/vbahelper.cxx
+++ b/vbahelper/source/vbahelper/vbahelper.cxx
@@ -259,11 +259,10 @@ getThisWordDoc( const uno::Reference< uno::XComponentContext >& xContext ) throw
  uno::Reference< frame::XModel >
 getCurrentExcelDoc( const uno::Reference< uno::XComponentContext >& xContext ) throw (uno::RuntimeException)
 {
-    static const char sThisExcelDoc[] = "ThisExcelDoc";
     uno::Reference< frame::XModel > xModel;
     try
     {
-        xModel = getCurrentDoc( sThisExcelDoc );
+        xModel = getCurrentDoc( "ThisExcelDoc" );
     }
     catch (const uno::Exception&)
     {
@@ -275,11 +274,10 @@ getCurrentExcelDoc( const uno::Reference< uno::XComponentContext >& xContext ) t
  uno::Reference< frame::XModel >
 getCurrentWordDoc( const uno::Reference< uno::XComponentContext >& xContext ) throw (uno::RuntimeException)
 {
-    static const char sThisWordDoc[] = "ThisWordDoc";
     uno::Reference< frame::XModel > xModel;
     try
     {
-        xModel = getCurrentDoc( sThisWordDoc );
+        xModel = getCurrentDoc( "ThisWordDoc" );
     }
     catch (const uno::Exception&)
     {
diff --git a/vcl/source/font/PhysicalFontCollection.cxx b/vcl/source/font/PhysicalFontCollection.cxx
index 9bef807..0f744971 100644
--- a/vcl/source/font/PhysicalFontCollection.cxx
+++ b/vcl/source/font/PhysicalFontCollection.cxx
@@ -1138,9 +1138,7 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& r
             a korean bitmap font that is not suitable here. Use the font replacement table,
             that automatically leads to the desired "HG Mincho Light J". Same story for
             MS Gothic, there are thai and korean "Gothic" fonts, so we even prefer Andale */
-            static const char aMS_Mincho[] = "msmincho";
-            static const char aMS_Gothic[] = "msgothic";
-            if ((aSearchName != aMS_Mincho) && (aSearchName != aMS_Gothic))
+            if ((aSearchName != "msmincho") && (aSearchName != "msgothic"))
                 // TODO: add heuristic to only throw out the fake ms* fonts
 #endif
             {
diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
index 26d6c74..d4f8dfb 100644
--- a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
@@ -786,8 +786,6 @@ uno::Sequence<OUString> SAL_CALL SalGtkFilePicker::getSelectedFiles() throw( uno
 
                     if( sExtension.getLength() >= 3 ) // 3 = typical/minimum extension length
                     {
-                        static const char aStarDot[] = "*.";
-
                         OUString aNewFilter;
                         OUString aOldFilter = getCurrentFilter();
                         bool bChangeFilter = true;
@@ -797,7 +795,7 @@ uno::Sequence<OUString> SAL_CALL SalGtkFilePicker::getSelectedFiles() throw( uno
                                   ++aListIter
                                 )
                         {
-                            if( lcl_matchFilter( aListIter->getFilter(), aStarDot+sExtension ) )
+                            if( lcl_matchFilter( aListIter->getFilter(), "*." + sExtension ) )
                             {
                                 if( aNewFilter.isEmpty() )
                                     aNewFilter = aListIter->getTitle();
@@ -1831,7 +1829,6 @@ GtkFileFilter* SalGtkFilePicker::implAddFilter( const OUString& rFilter, const O
     OString aFilterName = OUStringToOString( aShrunkName, RTL_TEXTENCODING_UTF8 );
     gtk_file_filter_set_name( filter, aFilterName.getStr() );
 
-    static const char aStarDot[] = "*.";
     OUString aTokens;
 
     bool bAllGlob = rType == "*.*" || rType == "*";
@@ -1845,7 +1842,7 @@ GtkFileFilter* SalGtkFilePicker::implAddFilter( const OUString& rFilter, const O
         {
             aToken = rType.getToken( 0, ';', nIndex );
             // Assume all have the "*.<extn>" syntax
-            sal_Int32 nStarDot = aToken.lastIndexOf( aStarDot );
+            sal_Int32 nStarDot = aToken.lastIndexOf( "*." );
             if (nStarDot >= 0)
                 aToken = aToken.copy( nStarDot + 2 );
             if (!aToken.isEmpty())
diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx
index 2d32168..c5cbb54 100644
--- a/vcl/unx/gtk/gtksalmenu.cxx
+++ b/vcl/unx/gtk/gtksalmenu.cxx
@@ -623,7 +623,7 @@ void GtkSalMenu::ShowCloseButton(bool bShow)
     GtkStyleContext *pButtonContext = gtk_widget_get_style_context(GTK_WIDGET(mpCloseButton));
 
     GtkCssProvider *pProvider = gtk_css_provider_new();
-    const gchar data[] = "* { "
+    static const gchar data[] = "* { "
       "padding: 0;"
       "margin-left: 8px;"
       "margin-right: 8px;"
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index be369fa7..1408a62 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1348,10 +1348,9 @@ void DomainMapper_Impl::appendTextContent(
 
 void DomainMapper_Impl::appendOLE( const OUString& rStreamName, const OLEHandlerPtr& pOLEHandler )
 {
-    static const char sEmbeddedService[] = "com.sun.star.text.TextEmbeddedObject";
     try
     {
-        uno::Reference< text::XTextContent > xOLE( m_xTextFactory->createInstance(sEmbeddedService), uno::UNO_QUERY_THROW );
+        uno::Reference< text::XTextContent > xOLE( m_xTextFactory->createInstance("com.sun.star.text.TextEmbeddedObject"), uno::UNO_QUERY_THROW );
         uno::Reference< beans::XPropertySet > xOLEProperties(xOLE, uno::UNO_QUERY_THROW);
 
         OUString aCLSID = pOLEHandler->getCLSID(m_xComponentContext);
@@ -1419,10 +1418,9 @@ void DomainMapper_Impl::appendStarMath( const Value& val )
     val.getAny() >>= formula;
     if( formula.is() )
     {
-        static const char sEmbeddedService[] = "com.sun.star.text.TextEmbeddedObject";
         try
         {
-            uno::Reference< text::XTextContent > xStarMath( m_xTextFactory->createInstance(sEmbeddedService), uno::UNO_QUERY_THROW );
+            uno::Reference< text::XTextContent > xStarMath( m_xTextFactory->createInstance("com.sun.star.text.TextEmbeddedObject"), uno::UNO_QUERY_THROW );
             uno::Reference< beans::XPropertySet > xStarMathProperties(xStarMath, uno::UNO_QUERY_THROW);
 
             xStarMathProperties->setPropertyValue(getPropertyName( PROP_EMBEDDED_OBJECT ),
@@ -1470,8 +1468,7 @@ uno::Reference< beans::XPropertySet > DomainMapper_Impl::appendTextSectionAfter(
                 xCursor->gotoEnd( true );
             //the paragraph after this new section is already inserted
             xCursor->goLeft(1, true);
-            static const char sSectionService[] = "com.sun.star.text.TextSection";
-            uno::Reference< text::XTextContent > xSection( m_xTextFactory->createInstance(sSectionService), uno::UNO_QUERY_THROW );
+            uno::Reference< text::XTextContent > xSection( m_xTextFactory->createInstance("com.sun.star.text.TextSection"), uno::UNO_QUERY_THROW );
             xSection->attach( uno::Reference< text::XTextRange >( xCursor, uno::UNO_QUERY_THROW) );
             xRet.set(xSection, uno::UNO_QUERY );
         }
@@ -4629,10 +4626,9 @@ void DomainMapper_Impl::StartOrEndBookmark( const OUString& rId )
     {
         if( aBookmarkIter != m_aBookmarkMap.end() )
         {
-            static const char sBookmarkService[] = "com.sun.star.text.Bookmark";
             if (m_xTextFactory.is())
             {
-                uno::Reference< text::XTextContent > xBookmark( m_xTextFactory->createInstance( sBookmarkService ), uno::UNO_QUERY_THROW );
+                uno::Reference< text::XTextContent > xBookmark( m_xTextFactory->createInstance( "com.sun.star.text.Bookmark" ), uno::UNO_QUERY_THROW );
                 uno::Reference< text::XTextCursor > xCursor;
                 uno::Reference< text::XText > xText = aBookmarkIter->second.m_xTextRange->getText();
                 if( aBookmarkIter->second.m_bIsStartOfText && !bIsAfterDummyPara)
diff --git a/writerfilter/source/dmapper/FormControlHelper.cxx b/writerfilter/source/dmapper/FormControlHelper.cxx
index 93c3ae0..f4efa90 100644
--- a/writerfilter/source/dmapper/FormControlHelper.cxx
+++ b/writerfilter/source/dmapper/FormControlHelper.cxx
@@ -258,16 +258,13 @@ void FormControlHelper::insertControl(uno::Reference<text::XTextRange> const& xT
     if (! xFormComps.is())
         return;
 
-    static const char sControl[] = "Control";
-
     sal_Int32 nControl = 0;
     bool bDone = false;
     OUString sControlName;
 
     do
     {
-        OUString sTmp(sControl);
-        sTmp += OUString::number(nControl);
+        OUString sTmp = "Control" + OUString::number(nControl);
 
         nControl++;
         if (! xFormCompsByName->hasByName(sTmp))
diff --git a/writerfilter/source/dmapper/OLEHandler.cxx b/writerfilter/source/dmapper/OLEHandler.cxx
index 13ea16e..26f12c1 100644
--- a/writerfilter/source/dmapper/OLEHandler.cxx
+++ b/writerfilter/source/dmapper/OLEHandler.cxx
@@ -273,9 +273,8 @@ OUString OLEHandler::copyOLEOStream(
 
             ::oox::ole::SaveInteropProperties(xTextDocument, aURL, nullptr, m_sProgId, m_sDrawAspect);
 
-            static const char sProtocol[] = "vnd.sun.star.EmbeddedObject:";
             OUString aPersistName( xEmbeddedResolver->resolveEmbeddedObjectURL( aURL ) );
-            sRet = aPersistName.copy( strlen(sProtocol) );
+            sRet = aPersistName.copy( strlen("vnd.sun.star.EmbeddedObject:") );
 
         }
         uno::Reference< lang::XComponent > xComp( xEmbeddedResolver, uno::UNO_QUERY_THROW );


More information about the Libreoffice-commits mailing list