diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2021-06-09 20:03:04 +0200 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2021-06-09 21:28:05 +0200 |
commit | 58d218df8c5e36468183ebae666120a6d5d0a4f7 (patch) | |
tree | 3cc30e0702146f896c5c8abbbb264f46b8eb0f22 /sfx2 | |
parent | da44de883f205736fffeacc148c32dcfd638ad66 (diff) |
Simplify Sequences initializations (sfx2)
Change-Id: I1384dd80e910ba1c55ec7481ab481bc48740fc5c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116937
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/bastyp/helper.cxx | 13 | ||||
-rw-r--r-- | sfx2/source/doc/doctempl.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/doc/doctemplates.cxx | 32 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 25 |
4 files changed, 23 insertions, 55 deletions
diff --git a/sfx2/source/bastyp/helper.cxx b/sfx2/source/bastyp/helper.cxx index 7918cfcceec1..d9d1a4bb4da4 100644 --- a/sfx2/source/bastyp/helper.cxx +++ b/sfx2/source/bastyp/helper.cxx @@ -49,15 +49,10 @@ std::vector<OUString> SfxContentHelper::GetResultSet( const OUString& rURL ) ::ucbhelper::Content aCnt( rURL, uno::Reference< ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext() ); uno::Reference< sdbc::XResultSet > xResultSet; uno::Reference< ucb::XDynamicResultSet > xDynResultSet; - uno::Sequence< OUString > aProps(3); - OUString* pProps = aProps.getArray(); - pProps[0] = "Title"; - pProps[1] = "ContentType"; - pProps[2] = "IsFolder"; try { - xDynResultSet = aCnt.createDynamicCursor( aProps ); + xDynResultSet = aCnt.createDynamicCursor( { "Title", "ContentType", "IsFolder" } ); if ( xDynResultSet.is() ) xResultSet = xDynResultSet->getStaticResultSet(); } @@ -112,14 +107,10 @@ std::vector< OUString > SfxContentHelper::GetHelpTreeViewContents( const OUStrin ::ucbhelper::Content aCnt( rURL, new ::ucbhelper::CommandEnvironment( xInteractionHandler, uno::Reference< ucb::XProgressHandler >() ), comphelper::getProcessComponentContext() ); uno::Reference< sdbc::XResultSet > xResultSet; - uno::Sequence< OUString > aProps(2); - OUString* pProps = aProps.getArray(); - pProps[0] = "Title"; - pProps[1] = "IsFolder"; try { - uno::Reference< ucb::XDynamicResultSet > xDynResultSet = aCnt.createDynamicCursor( aProps ); + uno::Reference< ucb::XDynamicResultSet > xDynResultSet = aCnt.createDynamicCursor( { "Title", "IsFolder" } ); if ( xDynResultSet.is() ) xResultSet = xDynResultSet->getStaticResultSet(); } diff --git a/sfx2/source/doc/doctempl.cxx b/sfx2/source/doc/doctempl.cxx index 5e6dd0e6260b..cea3d30f4f1d 100644 --- a/sfx2/source/doc/doctempl.cxx +++ b/sfx2/source/doc/doctempl.cxx @@ -1488,16 +1488,10 @@ void SfxDocTemplate_Impl::AddRegion( const OUString& rTitle, // now get the content of the region uno::Reference< XResultSet > xResultSet; - Sequence< OUString > aProps(2); - aProps[0] = TITLE; - aProps[1] = TARGET_URL; try { - Sequence< NumberedSortingInfo > aSortingInfo(1); - aSortingInfo.getArray()->ColumnIndex = 1; - aSortingInfo.getArray()->Ascending = true; - xResultSet = rContent.createSortedCursor( aProps, aSortingInfo, m_rCompareFactory, INCLUDE_DOCUMENTS_ONLY ); + xResultSet = rContent.createSortedCursor( { TITLE, TARGET_URL }, { { 1, true } }, m_rCompareFactory, INCLUDE_DOCUMENTS_ONLY ); } catch ( Exception& ) {} diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx index 4e01f35583c7..50d11b8b043b 100644 --- a/sfx2/source/doc/doctemplates.cxx +++ b/sfx2/source/doc/doctemplates.cxx @@ -699,11 +699,6 @@ bool SfxDocTplService_Impl::addEntry( Content& rParentFolder, if ( ! Content::create( aLinkURL, maCmdEnv, comphelper::getProcessComponentContext(), aLink ) ) { - Sequence< OUString > aNames(3); - aNames[0] = TITLE; - aNames[1] = IS_FOLDER; - aNames[2] = TARGET_URL; - Sequence< Any > aValues(3); aValues[0] <<= rTitle; aValues[1] <<= false; @@ -711,7 +706,7 @@ bool SfxDocTplService_Impl::addEntry( Content& rParentFolder, try { - rParentFolder.insertNewContent( TYPE_LINK, aNames, aValues, aLink ); + rParentFolder.insertNewContent( TYPE_LINK, { TITLE, IS_FOLDER, TARGET_URL }, aValues, aLink ); setProperty( aLink, PROPERTY_TYPE, makeAny( rType ) ); bAddedEntry = true; } @@ -747,10 +742,6 @@ bool SfxDocTplService_Impl::createFolder( const OUString& rNewFolderURL, { try { - Sequence< OUString > aNames(2); - aNames[0] = TITLE; - aNames[1] = IS_FOLDER; - Sequence< Any > aValues(2); aValues[0] <<= aFolderName; aValues[1] <<= true; @@ -762,7 +753,7 @@ bool SfxDocTplService_Impl::createFolder( const OUString& rNewFolderURL, else aType = TYPE_FOLDER; - aParent.insertNewContent( aType, aNames, aValues, rNewFolder ); + aParent.insertNewContent( aType, { TITLE, IS_FOLDER }, aValues, rNewFolder ); bCreatedFolder = true; } catch( Exception const & ) @@ -808,15 +799,11 @@ bool SfxDocTplService_Impl::CreateNewUniqueFolderWithPrefix( const OUString& aPa try { - Sequence< OUString > aNames(2); - aNames[0] = TITLE; - aNames[1] = IS_FOLDER; - Sequence< Any > aValues(2); aValues[0] <<= aTryName; aValues[1] <<= true; - bCreated = aParent.insertNewContent( TYPE_FSYS_FOLDER, aNames, aValues, aNewFolder ); + bCreated = aParent.insertNewContent( TYPE_FSYS_FOLDER, { TITLE, IS_FOLDER }, aValues, aNewFolder ); } catch( ucb::NameClashException& ) { @@ -872,15 +859,11 @@ OUString SfxDocTplService_Impl::CreateNewUniqueFileWithPrefix( const OUString& a try { - Sequence< OUString > aNames(2); - aNames[0] = TITLE; - aNames[1] = IS_DOCUMENT; - Sequence< Any > aValues(2); aValues[0] <<= aTryName; aValues[1] <<= true; - bCreated = aParent.insertNewContent( TYPE_FSYS_FILE, aNames, aValues, aNewFile ); + bCreated = aParent.insertNewContent( TYPE_FSYS_FILE, { TITLE, IS_DOCUMENT }, aValues, aNewFile ); } catch( ucb::NameClashException& ) { @@ -2295,16 +2278,11 @@ void SfxDocTplService_Impl::addHierGroup( GroupList_Impl& rList, // now get the content of the Group Content aContent; uno::Reference<XResultSet> xResultSet; - Sequence<OUString> aProps(3); - - aProps[0] = TITLE; - aProps[1] = TARGET_URL; - aProps[2] = PROPERTY_TYPE; try { aContent = Content(rOwnURL, maCmdEnv, comphelper::getProcessComponentContext()); - xResultSet = aContent.createCursor( aProps, INCLUDE_DOCUMENTS_ONLY ); + xResultSet = aContent.createCursor( { TITLE, TARGET_URL, PROPERTY_TYPE }, INCLUDE_DOCUMENTS_ONLY ); } catch (ContentCreationException&) { diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 5ef7e7829da5..35e4bd106635 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -64,6 +64,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/sequenceashashmap.hxx> #include <comphelper/namedvaluecollection.hxx> +#include <o3tl/safeint.hxx> #include <svl/itemset.hxx> #include <svl/stritem.hxx> #include <svl/eitem.hxx> @@ -976,11 +977,13 @@ Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getArgs2(const Sequence< tools::Rectangle aTmpRect = m_pData->m_pObjectShell->GetVisArea( ASPECT_CONTENT ); aTmpRect = OutputDevice::LogicToLogic(aTmpRect, MapMode(m_pData->m_pObjectShell->GetMapUnit()), MapMode(MapUnit::Map100thMM)); - Sequence< sal_Int32 > aRectSeq(4); - aRectSeq[0] = aTmpRect.Left(); - aRectSeq[1] = aTmpRect.Top(); - aRectSeq[2] = aTmpRect.IsWidthEmpty() ? aTmpRect.Left() : aTmpRect.Right(); - aRectSeq[3] = aTmpRect.IsHeightEmpty() ? aTmpRect.Top() : aTmpRect.Bottom(); + Sequence< sal_Int32 > aRectSeq + { + o3tl::narrowing<int>(aTmpRect.Left()), + o3tl::narrowing<int>(aTmpRect.Top()), + o3tl::narrowing<int>(aTmpRect.IsWidthEmpty() ? aTmpRect.Left() : aTmpRect.Right()), + o3tl::narrowing<int>(aTmpRect.IsHeightEmpty() ? aTmpRect.Top() : aTmpRect.Bottom()) + }; seqArgsNew.realloc( ++nNewLength ); seqArgsNew[ nNewLength - 1 ].Name = "WinExtent"; @@ -1004,11 +1007,13 @@ Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getArgs2(const Sequence< { SvBorder aBorder = pFrame->GetBorderPixelImpl(); - Sequence< sal_Int32 > aBorderSeq(4); - aBorderSeq[0] = aBorder.Left(); - aBorderSeq[1] = aBorder.Top(); - aBorderSeq[2] = aBorder.Right(); - aBorderSeq[3] = aBorder.Bottom(); + Sequence< sal_Int32 > aBorderSeq + { + o3tl::narrowing<int>(aBorder.Left()), + o3tl::narrowing<int>(aBorder.Top()), + o3tl::narrowing<int>(aBorder.Right()), + o3tl::narrowing<int>(aBorder.Bottom()) + }; seqArgsNew.realloc( ++nNewLength ); seqArgsNew[ nNewLength - 1 ].Name = "DocumentBorder"; |