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

Noel Grandin noel.grandin at collabora.co.uk
Wed Sep 13 09:04:27 UTC 2017


 sfx2/source/appl/linkmgr2.cxx           |    2 
 sfx2/source/dialog/backingwindow.cxx    |    2 
 sfx2/source/dialog/filedlghelper.cxx    |    2 
 sfx2/source/dialog/filtergrouping.cxx   |   10 ++--
 sfx2/source/dialog/infobar.cxx          |    2 
 sfx2/source/dialog/splitwin.cxx         |    4 -
 sfx2/source/dialog/styfitem.cxx         |    2 
 sfx2/source/doc/SfxDocumentMetaData.cxx |   73 +++++++++++---------------------
 sfx2/source/sidebar/ContextList.cxx     |    2 
 sfx2/source/sidebar/FocusManager.cxx    |    4 -
 sfx2/source/view/frame.cxx              |   10 ++--
 sfx2/source/view/viewfrm.cxx            |    2 
 12 files changed, 48 insertions(+), 67 deletions(-)

New commits:
commit c460201dfdfae3a15db70ccefd689048c1ba2996
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Sep 13 10:19:00 2017 +0200

    clang-tidy modernize-use-emplace in sfx2
    
    Change-Id: I3d6b9dfa86c3637e5cb6fad81702c15d4c894e72
    Reviewed-on: https://gerrit.libreoffice.org/42229
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx
index cb7541be015a..bf8907fd1f6b 100644
--- a/sfx2/source/appl/linkmgr2.cxx
+++ b/sfx2/source/appl/linkmgr2.cxx
@@ -161,7 +161,7 @@ bool LinkManager::Insert( SvBaseLink* pLink )
     }
 
     pLink->SetLinkManager( this );
-    aLinkTbl.push_back( tools::SvRef<SvBaseLink>(pLink) );
+    aLinkTbl.emplace_back(pLink );
     return true;
 }
 
diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx
index 516bb5418d3b..3ca873ed74e5 100644
--- a/sfx2/source/dialog/backingwindow.cxx
+++ b/sfx2/source/dialog/backingwindow.cxx
@@ -123,7 +123,7 @@ BackingWindow::BackingWindow( vcl::Window* i_pParent ) :
     get(mpAllRecentThumbnails, "all_recent");
     get(mpLocalView, "local_view");
 
-    maDndWindows.push_back(mpAllRecentThumbnails);
+    maDndWindows.emplace_back(mpAllRecentThumbnails);
 
     try
     {
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index 45d840854e79..53f706761454 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -2199,7 +2199,7 @@ bool FileDialogHelper_Impl::isShowFilterExtensionEnabled() const
 void FileDialogHelper_Impl::addFilterPair( const OUString& rFilter,
                                            const OUString& rFilterWithExtension )
 {
-    maFilters.push_back( css::beans::StringPair( rFilter, rFilterWithExtension ) );
+    maFilters.emplace_back( rFilter, rFilterWithExtension );
 
 }
 
diff --git a/sfx2/source/dialog/filtergrouping.cxx b/sfx2/source/dialog/filtergrouping.cxx
index b8762a49318f..04e09f66807b 100644
--- a/sfx2/source/dialog/filtergrouping.cxx
+++ b/sfx2/source/dialog/filtergrouping.cxx
@@ -176,7 +176,7 @@ namespace sfx2
         void operator() ( const FilterName& _rLogicalFilterName )
         {
             // insert a new (empty) class
-            m_rClassList.push_back( FilterClass() );
+            m_rClassList.emplace_back( );
             // get the position of this new entry
             FilterClassList::iterator aInsertPos = m_rClassList.end();
             --aInsertPos;
@@ -476,7 +476,7 @@ namespace sfx2
         {
             if ( ( s_cWildcardSeparator == *pTokenLoop ) && ( pTokenLoop > pTokenStart ) )
             {   // found a new token separator (and a non-empty token)
-                aWildCards.push_back( OUString( pTokenStart, pTokenLoop - pTokenStart ) );
+                aWildCards.emplace_back( pTokenStart, pTokenLoop - pTokenStart );
 
                 // search the start of the next token
                 while ( ( pTokenStart != pTokenLoopEnd ) && ( *pTokenStart != s_cWildcardSeparator ) )
@@ -492,7 +492,7 @@ namespace sfx2
         }
         if ( pTokenLoop > pTokenStart )
             // the last one ....
-            aWildCards.push_back( OUString( pTokenStart, pTokenLoop - pTokenStart ) );
+            aWildCards.emplace_back( pTokenStart, pTokenLoop - pTokenStart );
     }
 
 
@@ -575,7 +575,7 @@ namespace sfx2
         // (this assumes that both numbers are the same, which, speaking strictly, must not hold - but it does, as we know ...)
         sal_Int32 nGlobalClasses = aGlobalClasses.size();
         while ( nGlobalClasses-- )
-            _rAllFilters.push_back( FilterGroup() );
+            _rAllFilters.emplace_back( );
 
 
         // for the local classes:
@@ -685,7 +685,7 @@ namespace sfx2
                     FilterGroup::iterator aInsertPos = aCurrentGroup->end();
                     --aInsertPos;
                     // remember this pos
-                    aLocalFinalPositions.push_back( MapGroupEntry2GroupEntry::value_type( aBelongsToLocal->second, aInsertPos ) );
+                    aLocalFinalPositions.emplace_back( aBelongsToLocal->second, aInsertPos );
                 }
             }
             else
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx
index e51a24520d96..43200f0ac00d 100644
--- a/sfx2/source/dialog/infobar.cxx
+++ b/sfx2/source/dialog/infobar.cxx
@@ -210,7 +210,7 @@ SfxInfoBarWindow::SfxInfoBarWindow(vcl::Window* pParent, const OUString& sId,
 void SfxInfoBarWindow::addButton(PushButton* pButton) {
     pButton->SetParent(this);
     pButton->Show();
-    m_aActionBtns.push_back(pButton);
+    m_aActionBtns.emplace_back(pButton);
     Resize();
 }
 
diff --git a/sfx2/source/dialog/splitwin.cxx b/sfx2/source/dialog/splitwin.cxx
index 9dfd524349e8..232d41106a52 100644
--- a/sfx2/source/dialog/splitwin.cxx
+++ b/sfx2/source/dialog/splitwin.cxx
@@ -408,7 +408,7 @@ void SfxSplitWindow::Split()
 
             rD.pWin->SetItemSize_Impl( aSize );
 
-            aNewOrgSizes.push_back( std::pair< sal_uInt16, long >( nId, nSize ) );
+            aNewOrgSizes.emplace_back( nId, nSize );
         }
     }
 
@@ -744,7 +744,7 @@ void SfxSplitWindow::InsertWindow_Impl( SfxDock_Impl const * pDock,
             {
                 const sal_uInt16 nId = rD.nType;
                 const long nSize    = GetItemSize( nId, SplitWindowItemFlags::Fixed );
-                aNewOrgSizes.push_back( std::pair< sal_uInt16, long >( nId, nSize ) );
+                aNewOrgSizes.emplace_back( nId, nSize );
             }
         }
         // apply new item sizes
diff --git a/sfx2/source/dialog/styfitem.cxx b/sfx2/source/dialog/styfitem.cxx
index 6b4c453bfdd0..40d02cbeb480 100644
--- a/sfx2/source/dialog/styfitem.cxx
+++ b/sfx2/source/dialog/styfitem.cxx
@@ -26,7 +26,7 @@ SfxStyleFamilyItem::SfxStyleFamilyItem(SfxStyleFamily nFamily_, const OUString &
     , aImage(rImage)
 {
     for (const std::pair<const char*, int>* pItem = pStringArray; pItem->first; ++pItem)
-        aFilterList.push_back(SfxFilterTupel(Translate::get(pItem->first, rResLocale), pItem->second));
+        aFilterList.emplace_back(Translate::get(pItem->first, rResLocale), pItem->second);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx
index 5cb9e94f42b7..ecbdededf266 100644
--- a/sfx2/source/doc/SfxDocumentMetaData.cxx
+++ b/sfx2/source/doc/SfxDocumentMetaData.cxx
@@ -839,8 +839,7 @@ propsToStrings(css::uno::Reference<css::beans::XPropertySet> const & i_xPropSet)
         }
         const css::uno::Type & type = any.getValueType();
         std::vector<std::pair<const char*, OUString> > as;
-        as.push_back(std::make_pair(static_cast<const char*>("meta:name"),
-                                        name));
+        as.emplace_back("meta:name", name);
         const char* vt = "meta:value-type";
 
         // convert according to type
@@ -850,8 +849,7 @@ propsToStrings(css::uno::Reference<css::beans::XPropertySet> const & i_xPropSet)
             OUStringBuffer buf;
             ::sax::Converter::convertBool(buf, b);
             values.push_back(buf.makeStringAndClear());
-            as.push_back(std::make_pair(vt,
-                OUString("boolean")));
+            as.emplace_back(vt, OUString("boolean"));
         } else if (type == ::cppu::UnoType< OUString>::get()) {
             OUString s;
             any >>= s;
@@ -862,33 +860,28 @@ propsToStrings(css::uno::Reference<css::beans::XPropertySet> const & i_xPropSet)
 // => best backward compatibility: first 4 without @value-type, rest with
             if (4 <= i)
             {
-                as.push_back(std::make_pair(vt,
-                    OUString("string")));
+                as.emplace_back(vt, OUString("string"));
             }
         } else if (type == ::cppu::UnoType<css::util::DateTime>::get()) {
             css::util::DateTime dt;
             any >>= dt;
             values.push_back(dateTimeToText(dt));
-            as.push_back(std::make_pair(vt,
-                OUString("date")));
+            as.emplace_back(vt, OUString("date"));
         } else if (type == ::cppu::UnoType<css::util::Date>::get()) {
             css::util::Date d;
             any >>= d;
             values.push_back(dateToText(d, nullptr));
-            as.push_back(std::make_pair(vt,
-                OUString("date")));
+            as.emplace_back(vt,OUString("date"));
         } else if (type == ::cppu::UnoType<css::util::DateTimeWithTimezone>::get()) {
             css::util::DateTimeWithTimezone dttz;
             any >>= dttz;
             values.push_back(dateTimeToText(dttz.DateTimeInTZ, &dttz.Timezone));
-            as.push_back(std::make_pair(vt,
-                OUString("date")));
+            as.emplace_back(vt, OUString("date"));
         } else if (type == ::cppu::UnoType<css::util::DateWithTimezone>::get()) {
             css::util::DateWithTimezone dtz;
             any >>= dtz;
             values.push_back(dateToText(dtz.DateInTZ, &dtz.Timezone));
-            as.push_back(std::make_pair(vt,
-                OUString("date")));
+            as.emplace_back(vt, OUString("date"));
         } else if (type == ::cppu::UnoType<css::util::Time>::get()) {
             // #i97029#: replaced by Duration
             // Time is supported for backward compatibility with OOo 3.x, x<=2
@@ -900,14 +893,12 @@ propsToStrings(css::uno::Reference<css::beans::XPropertySet> const & i_xPropSet)
             ud.Seconds = ut.Seconds;
             ud.NanoSeconds = ut.NanoSeconds;
             values.push_back(durationToText(ud));
-            as.push_back(std::make_pair(vt,
-                OUString("time")));
+            as.emplace_back(vt, OUString("time"));
         } else if (type == ::cppu::UnoType<css::util::Duration>::get()) {
             css::util::Duration ud;
             any >>= ud;
             values.push_back(durationToText(ud));
-            as.push_back(std::make_pair(vt,
-                OUString("time")));
+            as.emplace_back(vt, OUString("time"));
         } else if (::cppu::UnoType<double>::get().isAssignableFrom(type)) {
             // support not just double, but anything that can be converted
             double d = 0;
@@ -915,8 +906,7 @@ propsToStrings(css::uno::Reference<css::beans::XPropertySet> const & i_xPropSet)
             OUStringBuffer buf;
             ::sax::Converter::convertDouble(buf, d);
             values.push_back(buf.makeStringAndClear());
-            as.push_back(std::make_pair(vt,
-                OUString("float")));
+            as.emplace_back(vt, OUString("float"));
         } else {
             SAL_WARN("sfx.doc", "Unsupported property type: " << any.getValueTypeName() );
             continue;
@@ -980,20 +970,13 @@ void SAL_CALL SfxDocumentMetaData::updateUserDefinedAndAttributes()
     std::vector<std::pair<const char *, OUString> > attributes;
     if (!m_TemplateName.isEmpty() || !m_TemplateURL.isEmpty()
             || isValidDateTime(m_TemplateDate)) {
-        attributes.push_back(std::make_pair(
-                static_cast<const char*>("xlink:type"),
-                OUString("simple")));
-        attributes.push_back(std::make_pair(
-                static_cast<const char*>("xlink:actuate"),
-                OUString("onRequest")));
-        attributes.push_back(std::make_pair(
-                static_cast<const char*>("xlink:title"), m_TemplateName));
-        attributes.push_back(std::make_pair(
-                static_cast<const char*>("xlink:href" ), m_TemplateURL ));
+        attributes.emplace_back("xlink:type", OUString("simple"));
+        attributes.emplace_back("xlink:actuate", OUString("onRequest"));
+        attributes.emplace_back("xlink:title", m_TemplateName);
+        attributes.emplace_back("xlink:href", m_TemplateURL );
         if (isValidDateTime(m_TemplateDate)) {
-            attributes.push_back(std::make_pair(
-                static_cast<const char*>("meta:date"  ),
-                dateTimeToText(m_TemplateDate)));
+            attributes.emplace_back(
+                "meta:date", dateTimeToText(m_TemplateDate));
         }
         updateElement("meta:template", &attributes);
     } else {
@@ -1002,11 +985,9 @@ void SAL_CALL SfxDocumentMetaData::updateUserDefinedAndAttributes()
     attributes.clear();
 
     if (!m_AutoloadURL.isEmpty() || (0 != m_AutoloadSecs)) {
-        attributes.push_back(std::make_pair(
-                static_cast<const char*>("xlink:href" ), m_AutoloadURL ));
-        attributes.push_back(std::make_pair(
-                static_cast<const char*>("meta:delay" ),
-                durationToText(m_AutoloadSecs)));
+        attributes.emplace_back("xlink:href", m_AutoloadURL );
+        attributes.emplace_back("meta:delay",
+                durationToText(m_AutoloadSecs));
         updateElement("meta:auto-reload", &attributes);
     } else {
         updateElement("meta:auto-reload");
@@ -1014,14 +995,14 @@ void SAL_CALL SfxDocumentMetaData::updateUserDefinedAndAttributes()
     attributes.clear();
 
     if (!m_DefaultTarget.isEmpty()) {
-        attributes.push_back(std::make_pair(
-                static_cast<const char*>("office:target-frame-name"),
-                m_DefaultTarget));
+        attributes.emplace_back(
+                "office:target-frame-name",
+                m_DefaultTarget);
         // xlink:show: _blank -> new, any other value -> replace
         const sal_Char* show = m_DefaultTarget == "_blank" ? "new" : "replace";
-        attributes.push_back(std::make_pair(
-                static_cast<const char*>("xlink:show"),
-                OUString::createFromAscii(show)));
+        attributes.emplace_back(
+                "xlink:show",
+                OUString::createFromAscii(show));
         updateElement("meta:hyperlink-behaviour", &attributes);
     } else {
         updateElement("meta:hyperlink-behaviour");
@@ -1641,8 +1622,8 @@ SfxDocumentMetaData::setDocumentStatistics(
                 const css::uno::Any any = the_value[i].Value;
                 sal_Int32 val = 0;
                 if (any >>= val) {
-                    attributes.push_back(std::make_pair(s_stdStatAttrs[j],
-                                OUString::number(val)));
+                    attributes.emplace_back(s_stdStatAttrs[j],
+                                OUString::number(val));
                 } else {
                     SAL_WARN("sfx.doc", "Invalid statistic: " << name);
                 }
diff --git a/sfx2/source/sidebar/ContextList.cxx b/sfx2/source/sidebar/ContextList.cxx
index f515dcfcb7ab..fb841f081543 100644
--- a/sfx2/source/sidebar/ContextList.cxx
+++ b/sfx2/source/sidebar/ContextList.cxx
@@ -79,7 +79,7 @@ void ContextList::AddContextDescription (
     const bool bIsInitiallyVisible,
     const OUString& rsMenuCommand)
 {
-    maEntries.push_back(Entry());
+    maEntries.emplace_back();
     maEntries.back().maContext = rContext;
     maEntries.back().mbIsInitiallyVisible = bIsInitiallyVisible;
     maEntries.back().msMenuCommand = rsMenuCommand;
diff --git a/sfx2/source/sidebar/FocusManager.cxx b/sfx2/source/sidebar/FocusManager.cxx
index dfd2527302f1..2f9730958252 100644
--- a/sfx2/source/sidebar/FocusManager.cxx
+++ b/sfx2/source/sidebar/FocusManager.cxx
@@ -121,7 +121,7 @@ void FocusManager::SetPanels (const SharedPanelContainer& rPanels)
         // Register also as child event listener at the panel.
         (*iPanel)->AddChildEventListener(LINK(this, FocusManager, ChildEventListener));
 
-        maPanels.push_back(iPanel->get());
+        maPanels.emplace_back(iPanel->get());
     }
 }
 
@@ -131,7 +131,7 @@ void FocusManager::SetButtons (const ::std::vector<Button*>& rButtons)
     for (auto iButton = rButtons.begin(); iButton != rButtons.end(); ++iButton)
     {
         RegisterWindow(**iButton);
-        maButtons.push_back(*iButton);
+        maButtons.emplace_back(*iButton);
     }
 }
 
diff --git a/sfx2/source/view/frame.cxx b/sfx2/source/view/frame.cxx
index a092eef150a5..9c79959935c0 100644
--- a/sfx2/source/view/frame.cxx
+++ b/sfx2/source/view/frame.cxx
@@ -374,11 +374,11 @@ SfxFrameDescriptor* SfxFrame::GetDescriptor() const
 void SfxFrame::GetDefaultTargetList(TargetList& rList)
 {
     // An empty string for 'No Target'
-    rList.push_back( OUString() );
-    rList.push_back( OUString( "_top" ) );
-    rList.push_back( OUString( "_parent" ) );
-    rList.push_back( OUString( "_blank" ) );
-    rList.push_back( OUString( "_self" ) );
+    rList.emplace_back( );
+    rList.emplace_back( "_top" );
+    rList.emplace_back( "_parent" );
+    rList.emplace_back( "_blank" );
+    rList.emplace_back( "_self" );
 }
 
 void SfxFrame::InsertTopFrame_Impl( SfxFrame* pFrame )
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index a8e83f9c95be..ca5283c65137 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -548,7 +548,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
                 {
                     Reference< XFrame > xFrame( pView->GetFrame().GetFrameInterface() );
                     SAL_WARN_IF( !xFrame.is(), "sfx.view", "SfxViewFrame::ExecReload_Impl: no XFrame?!");
-                    aViewFrames.push_back( ViewDescriptor( xFrame, pView->GetCurViewId() ) );
+                    aViewFrames.emplace_back( xFrame, pView->GetCurViewId() );
 
                     pView = GetNext( *pView, xOldObj );
                 }


More information about the Libreoffice-commits mailing list