[Libreoffice-commits] core.git: writerfilter/source xmlhelp/source

Noel Grandin noel.grandin at collabora.co.uk
Wed Jun 28 10:37:54 UTC 2017


 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   19 +++++++------------
 writerfilter/source/filter/RtfFilter.cxx          |    6 ++++--
 writerfilter/source/filter/WriterFilter.cxx       |    6 ++++--
 writerfilter/source/ooxml/OOXMLDocumentImpl.cxx   |    9 +++------
 writerfilter/source/rtftok/rtfdocumentimpl.cxx    |    2 +-
 xmlhelp/source/cxxhelp/provider/databases.cxx     |    9 +++------
 xmlhelp/source/cxxhelp/provider/db.cxx            |    3 +--
 7 files changed, 23 insertions(+), 31 deletions(-)

New commits:
commit bdabb4c07d89bf57fa5cc52455c889337052a8c8
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Jun 28 09:13:04 2017 +0200

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

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 7e4da2b359a5..89783dde0597 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -773,7 +773,7 @@ static void lcl_MoveBorderPropertiesToFrame(std::vector<beans::PropertyValue>& r
         if(!xTextRangeProperties.is())
             return ;
 
-        PropertyIds aBorderProperties[] =
+        static PropertyIds const aBorderProperties[] =
         {
             PROP_LEFT_BORDER,
             PROP_RIGHT_BORDER,
@@ -785,9 +785,7 @@ static void lcl_MoveBorderPropertiesToFrame(std::vector<beans::PropertyValue>& r
             PROP_BOTTOM_BORDER_DISTANCE
         };
 
-        sal_uInt32 const nBorderPropertyCount = SAL_N_ELEMENTS( aBorderProperties );
-
-        for( sal_uInt32 nProperty = 0; nProperty < nBorderPropertyCount; ++nProperty)
+        for( sal_uInt32 nProperty = 0; nProperty < SAL_N_ELEMENTS( aBorderProperties ); ++nProperty)
         {
             OUString sPropertyName = getPropertyName(aBorderProperties[nProperty]);
             beans::PropertyValue aValue;
@@ -1188,7 +1186,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap )
                     {
                         // Workaround to make sure char props of the field are not lost.
                         // Not relevant for editeng-based comments.
-                        OUString sMarker("X");
+                        OUString const sMarker("X");
                         xCursor = xTextAppend->getText()->createTextCursor();
                         if (xCursor.is())
                             xCursor->gotoEnd(false);
@@ -3080,10 +3078,9 @@ void DomainMapper_Impl::handleFieldFormula
 
     // we don't copy the = symbol from the command
     OUString formula = command.copy(1);
-    sal_Int32 standardFormat = 0;
 
     xFieldProperties->setPropertyValue(getPropertyName(PROP_CONTENT), uno::makeAny(formula));
-    xFieldProperties->setPropertyValue(getPropertyName(PROP_NUMBER_FORMAT), uno::makeAny(standardFormat));
+    xFieldProperties->setPropertyValue(getPropertyName(PROP_NUMBER_FORMAT), uno::makeAny(sal_Int32(0)));
     xFieldProperties->setPropertyValue("IsShowFormula", uno::makeAny(false));
 }
 
@@ -3574,7 +3571,7 @@ void DomainMapper_Impl::handleToc
     pContext->SetTOC( xTOC );
     m_bParaHadField = false;
 
-    OUString sMarker("Y");
+    OUString const sMarker("Y");
     //insert index
     uno::Reference< text::XTextContent > xToInsert( xTOC, uno::UNO_QUERY );
     uno::Reference< text::XTextAppend >  xTextAppend = m_aTextAppendStack.top().xTextAppend;
@@ -3864,8 +3861,7 @@ void DomainMapper_Impl::CloseFieldCommand()
                         msfilter::util::EquationResult aResult(msfilter::util::ParseCombinedChars(aCommand));
                         if (!aResult.sType.isEmpty() && m_xTextFactory.is())
                         {
-                            OUString sServiceName("com.sun.star.text.TextField.");
-                            xFieldInterface = m_xTextFactory->createInstance(sServiceName + aResult.sType);
+                            xFieldInterface = m_xTextFactory->createInstance("com.sun.star.text.TextField." + aResult.sType);
                             xFieldProperties =
                                 uno::Reference< beans::XPropertySet >( xFieldInterface,
                                     uno::UNO_QUERY_THROW);
@@ -4964,8 +4960,7 @@ void  DomainMapper_Impl::ImportGraphic(const writerfilter::Reference< Properties
         if (eGraphicImportType == IMPORT_AS_DETECTED_ANCHOR)
         {
             uno::Reference<beans::XPropertySet> xEmbeddedProps(m_xEmbedded, uno::UNO_QUERY);
-            text::TextContentAnchorType eAnchorType = text::TextContentAnchorType_AT_CHARACTER;
-            xEmbeddedProps->setPropertyValue("AnchorType", uno::makeAny(eAnchorType));
+            xEmbeddedProps->setPropertyValue("AnchorType", uno::makeAny(text::TextContentAnchorType_AT_CHARACTER));
             uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
             xEmbeddedProps->setPropertyValue("HoriOrient", xShapeProps->getPropertyValue("HoriOrient"));
             xEmbeddedProps->setPropertyValue("HoriOrientPosition", xShapeProps->getPropertyValue("HoriOrientPosition"));
diff --git a/writerfilter/source/filter/RtfFilter.cxx b/writerfilter/source/filter/RtfFilter.cxx
index 34e6e4aa3861..61dcaac29c01 100644
--- a/writerfilter/source/filter/RtfFilter.cxx
+++ b/writerfilter/source/filter/RtfFilter.cxx
@@ -137,8 +137,10 @@ sal_Bool RtfFilter::filter(const uno::Sequence< beans::PropertyValue >& aDescrip
         xStatusIndicator = aMediaDesc.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_STATUSINDICATOR(),
                            uno::Reference<task::XStatusIndicator>());
 
-        writerfilter::dmapper::SourceDocumentType eType = writerfilter::dmapper::SourceDocumentType::RTF;
-        writerfilter::Stream::Pointer_t pStream(writerfilter::dmapper::DomainMapperFactory::createMapper(m_xContext, xInputStream, m_xDstDoc, bRepairStorage, eType, aMediaDesc));
+        writerfilter::Stream::Pointer_t pStream(
+            writerfilter::dmapper::DomainMapperFactory::createMapper(
+                    m_xContext, xInputStream, m_xDstDoc, bRepairStorage,
+                    writerfilter::dmapper::SourceDocumentType::RTF, aMediaDesc));
         writerfilter::rtftok::RTFDocument::Pointer_t pDocument(
             writerfilter::rtftok::RTFDocumentFactory::createDocument(m_xContext, xInputStream, m_xDstDoc, xFrame, xStatusIndicator, aMediaDesc));
         pDocument->resolve(*pStream);
diff --git a/writerfilter/source/filter/WriterFilter.cxx b/writerfilter/source/filter/WriterFilter.cxx
index df23ef38bb0c..63c4d50a29be 100644
--- a/writerfilter/source/filter/WriterFilter.cxx
+++ b/writerfilter/source/filter/WriterFilter.cxx
@@ -169,8 +169,10 @@ sal_Bool WriterFilter::filter(const uno::Sequence< beans::PropertyValue >& aDesc
         if (!xInputStream.is())
             return false;
 
-        writerfilter::dmapper::SourceDocumentType eType = writerfilter::dmapper::SourceDocumentType::OOXML;
-        writerfilter::Stream::Pointer_t pStream(writerfilter::dmapper::DomainMapperFactory::createMapper(m_xContext, xInputStream, m_xDstDoc, bRepairStorage, eType, aMediaDesc));
+        writerfilter::Stream::Pointer_t pStream(
+            writerfilter::dmapper::DomainMapperFactory::createMapper(
+                m_xContext, xInputStream, m_xDstDoc, bRepairStorage,
+                writerfilter::dmapper::SourceDocumentType::OOXML, aMediaDesc));
         //create the tokenizer and domain mapper
         writerfilter::ooxml::OOXMLStream::Pointer_t pDocStream = writerfilter::ooxml::OOXMLDocumentFactory::createStream(m_xContext, xInputStream, bRepairStorage);
         uno::Reference<task::XStatusIndicator> xStatusIndicator = aMediaDesc.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_STATUSINDICATOR(), uno::Reference<task::XStatusIndicator>());
diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
index 74f3ef3e7dc7..fa9ff2d16cbc 100644
--- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
@@ -562,7 +562,6 @@ void OOXMLDocumentImpl::resolveCustomXmlStream(Stream & rStream)
     {
         static const char sCustomType[] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml";
         static const char sCustomTypeStrict[] = "http://purl.oclc.org/ooxml/officeDocument/relationships/customXml";
-        OUString sTarget("Target");
         bool bFound = false;
         sal_Int32 counter = 0;
         uno::Sequence< uno::Sequence< beans::StringPair > >aSeqs = xRelationshipAccess->getAllRelationships();
@@ -579,7 +578,7 @@ void OOXMLDocumentImpl::resolveCustomXmlStream(Stream & rStream)
                 if (aPair.Second == sCustomType ||
                         aPair.Second == sCustomTypeStrict)
                     bFound = true;
-                else if(aPair.First == sTarget && bFound)
+                else if(aPair.First == "Target" && bFound)
                 {
                     // Adding value to extern variable customTarget. It will be used in ooxmlstreamimpl
                     // to ensure customxml target is visited in lcl_getTarget.
@@ -727,7 +726,6 @@ void OOXMLDocumentImpl::resolveEmbeddingsStream(const OOXMLStream::Pointer_t& pS
         OUString sHeaderType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/header");
         OUString sHeaderTypeStrict("http://purl.oclc.org/ooxml/officeDocument/relationships/header");
 
-        OUString sTarget("Target");
         bool bFound = false;
         bool bHeaderFooterFound = false;
         OOXMLStream::StreamType_t streamType = OOXMLStream::UNKNOWN;
@@ -755,7 +753,7 @@ void OOXMLDocumentImpl::resolveEmbeddingsStream(const OOXMLStream::Pointer_t& pS
                     bHeaderFooterFound = true;
                     streamType = OOXMLStream::HEADER;
                 }
-                else if(aPair.First == sTarget && ( bFound || bHeaderFooterFound ))
+                else if(aPair.First == "Target" && ( bFound || bHeaderFooterFound ))
                 {
                     // Adding value to extern variable customTarget. It will be used in ooxmlstreamimpl
                     // to ensure chart.xml target is visited in lcl_getTarget.
@@ -814,7 +812,6 @@ void OOXMLDocumentImpl::resolveActiveXStream(Stream & rStream)
     {
         static const char sCustomType[] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/control";
         static const char sCustomTypeStrict[] = "http://purl.oclc.org/ooxml/officeDocument/relationships/control";
-        OUString sTarget("Target");
         bool bFound = false;
         sal_Int32 counter = 0;
         uno::Sequence< uno::Sequence< beans::StringPair > > aSeqs = xRelationshipAccess->getAllRelationships();
@@ -831,7 +828,7 @@ void OOXMLDocumentImpl::resolveActiveXStream(Stream & rStream)
                 if (aPair.Second == sCustomType ||
                         aPair.Second == sCustomTypeStrict)
                     bFound = true;
-                else if(aPair.First == sTarget && bFound)
+                else if(aPair.First == "Target" && bFound)
                 {
                     // Adding value to extern variable customTarget. It will be used in ooxmlstreamimpl
                     // to ensure ActiveX.xml target is visited in lcl_getTarget.
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 33d0eefd5b6c..036b47b73fcd 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -3352,7 +3352,7 @@ RTFSprms RTFFrame::getSprms()
         NS_ooxml::LN_CT_FramePr_lines
     };
 
-    for (int i = 0, len = SAL_N_ELEMENTS(pNames); i < len; ++i)
+    for (int i = 0; i < int(SAL_N_ELEMENTS(pNames)); ++i)
     {
         Id nId = pNames[i];
         RTFValue::Pointer_t pValue;
diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx
index 3fc71e0f87c1..1038566cc3f0 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.cxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.cxx
@@ -755,9 +755,8 @@ KeywordInfo* Databases::getKeyword( const OUString& Database,
                     helpdatafileproxy::Hdf* pHdf = getHelpDataFile( Database,Language );
                     if( pHdf != nullptr )
                     {
-                        bool bOptimizeForPerformance = true;
                         pHdf->releaseHashMap();
-                        pHdf->createHashMap( bOptimizeForPerformance );
+                        pHdf->createHashMap( true/*bOptimizeForPerformance*/ );
                     }
 
                     while( aHdf.getNextKeyAndValue( aKey, aValue ) )
@@ -1788,8 +1787,6 @@ OUString IndexFolderIterator::implGetIndexFolderFromPackage( bool& o_rbTemporary
                 else
                     aLang = "en";
 
-                OUString aMod("help");
-
                 OUString aZipDir = aLangURL;
                 if( !bIsWriteAccess )
                 {
@@ -1811,8 +1808,8 @@ OUString IndexFolderIterator::implGetIndexFolderFromPackage( bool& o_rbTemporary
                     }
                 }
 
-        HelpIndexer aIndexer(aLang, aMod, aLangURL, aZipDir);
-        aIndexer.indexDocuments();
+                HelpIndexer aIndexer(aLang, "help", aLangURL, aZipDir);
+                aIndexer.indexDocuments();
 
                 if( bIsWriteAccess )
                     aIndexFolder = implGetFileFromPackage( ".idxl", xPackage );
diff --git a/xmlhelp/source/cxxhelp/provider/db.cxx b/xmlhelp/source/cxxhelp/provider/db.cxx
index 2510e80c0fb6..9c3c2fa9fe2a 100644
--- a/xmlhelp/source/cxxhelp/provider/db.cxx
+++ b/xmlhelp/source/cxxhelp/provider/db.cxx
@@ -147,8 +147,7 @@ bool Hdf::getValueForKey( const OString& rKey, HDFData& rValue )
 
     if( m_pStringToDataMap == nullptr && m_pStringToValPosMap == nullptr )
     {
-        bool bOptimizeForPerformance = false;
-        createHashMap( bOptimizeForPerformance );
+        createHashMap( false/*bOptimizeForPerformance*/ );
     }
 
     if( m_pStringToValPosMap != nullptr )


More information about the Libreoffice-commits mailing list