Kaydet (Commit) a1f1a640 authored tarafından Matteo Casalin's avatar Matteo Casalin

Optimize OUStrings

Change-Id: I67e8e9e2ecd7ec89d51bd9597b54be53c3203d46
üst 4ede22cf
...@@ -312,9 +312,8 @@ void ContentListBox_Impl::dispose() ...@@ -312,9 +312,8 @@ void ContentListBox_Impl::dispose()
void ContentListBox_Impl::InitRoot() void ContentListBox_Impl::InitRoot()
{ {
OUString const aHelpTreeviewURL( "vnd.sun.star.hier://com.sun.star.help.TreeView/" );
std::vector< OUString > aList = std::vector< OUString > aList =
SfxContentHelper::GetHelpTreeViewContents( aHelpTreeviewURL ); SfxContentHelper::GetHelpTreeViewContents( "vnd.sun.star.hier://com.sun.star.help.TreeView/" );
for(const OUString & aRow : aList) for(const OUString & aRow : aList)
{ {
...@@ -350,9 +349,8 @@ void ContentListBox_Impl::RequestingChildren( SvTreeListEntry* pParent ) ...@@ -350,9 +349,8 @@ void ContentListBox_Impl::RequestingChildren( SvTreeListEntry* pParent )
{ {
if ( pParent->GetUserData() ) if ( pParent->GetUserData() )
{ {
OUString aTmpURL( static_cast<ContentEntry_Impl*>(pParent->GetUserData())->aURL );
std::vector<OUString > aList = std::vector<OUString > aList =
SfxContentHelper::GetHelpTreeViewContents( aTmpURL ); SfxContentHelper::GetHelpTreeViewContents( static_cast<ContentEntry_Impl*>(pParent->GetUserData())->aURL );
for (const OUString & aRow : aList) for (const OUString & aRow : aList)
{ {
...@@ -816,11 +814,10 @@ bool IndexTabPage_Impl::HasKeywordIgnoreCase() ...@@ -816,11 +814,10 @@ bool IndexTabPage_Impl::HasKeywordIgnoreCase()
if ( !sKeyword.isEmpty() ) if ( !sKeyword.isEmpty() )
{ {
sal_Int32 nEntries = m_pIndexCB->GetEntryCount(); sal_Int32 nEntries = m_pIndexCB->GetEntryCount();
OUString sIndexItem;
const vcl::I18nHelper& rI18nHelper = GetSettings().GetLocaleI18nHelper(); const vcl::I18nHelper& rI18nHelper = GetSettings().GetLocaleI18nHelper();
for ( sal_Int32 n = 0; n < nEntries; n++) for ( sal_Int32 n = 0; n < nEntries; n++)
{ {
sIndexItem = m_pIndexCB->GetEntry( n ); const OUString sIndexItem {m_pIndexCB->GetEntry( n )};
if (rI18nHelper.MatchString( sIndexItem, sKeyword )) if (rI18nHelper.MatchString( sIndexItem, sKeyword ))
{ {
sKeyword = sIndexItem; sKeyword = sIndexItem;
...@@ -1159,9 +1156,8 @@ void BookmarksBox_Impl::dispose() ...@@ -1159,9 +1156,8 @@ void BookmarksBox_Impl::dispose()
const sal_Int32 nCount = GetEntryCount(); const sal_Int32 nCount = GetEntryCount();
for ( sal_Int32 i = 0; i < nCount; ++i ) for ( sal_Int32 i = 0; i < nCount; ++i )
{ {
OUString aTitle = GetEntry(i);
OUString* pURL = static_cast<OUString*>(GetEntryData(i)); OUString* pURL = static_cast<OUString*>(GetEntryData(i));
aHistOpt.AppendItem(eHELPBOOKMARKS, *pURL, "", aTitle, boost::none); aHistOpt.AppendItem(eHELPBOOKMARKS, *pURL, "", GetEntry(i), boost::none);
delete pURL; delete pURL;
} }
ListBox::dispose(); ListBox::dispose();
...@@ -1187,9 +1183,7 @@ void BookmarksBox_Impl::DoAction( sal_uInt16 nAction ) ...@@ -1187,9 +1183,7 @@ void BookmarksBox_Impl::DoAction( sal_uInt16 nAction )
{ {
OUString* pURL = static_cast<OUString*>(GetEntryData( nPos )); OUString* pURL = static_cast<OUString*>(GetEntryData( nPos ));
RemoveEntry( nPos ); RemoveEntry( nPos );
OUString aImageURL = IMAGE_URL; nPos = InsertEntry( aDlg.GetTitle(), SvFileInformationManager::GetImage( INetURLObject(IMAGE_URL+INetURLObject( *pURL ).GetHost()) ) );
aImageURL += INetURLObject( *pURL ).GetHost();
nPos = InsertEntry( aDlg.GetTitle(), SvFileInformationManager::GetImage( INetURLObject(aImageURL) ) );
SetEntryData( nPos, new OUString( *pURL ) ); SetEntryData( nPos, new OUString( *pURL ) );
SelectEntryPos( nPos ); SelectEntryPos( nPos );
delete pURL; delete pURL;
...@@ -1336,8 +1330,7 @@ OUString BookmarksTabPage_Impl::GetSelectedEntry() const ...@@ -1336,8 +1330,7 @@ OUString BookmarksTabPage_Impl::GetSelectedEntry() const
void BookmarksTabPage_Impl::AddBookmarks( const OUString& rTitle, const OUString& rURL ) void BookmarksTabPage_Impl::AddBookmarks( const OUString& rTitle, const OUString& rURL )
{ {
OUString aImageURL = IMAGE_URL; const OUString aImageURL {IMAGE_URL + INetURLObject( rURL ).GetHost()};
aImageURL += INetURLObject( rURL ).GetHost();
const sal_Int32 nPos = m_pBookmarksBox->InsertEntry( rTitle, SvFileInformationManager::GetImage( INetURLObject(aImageURL) ) ); const sal_Int32 nPos = m_pBookmarksBox->InsertEntry( rTitle, SvFileInformationManager::GetImage( INetURLObject(aImageURL) ) );
m_pBookmarksBox->SetEntryData( nPos, new OUString( rURL ) ); m_pBookmarksBox->SetEntryData( nPos, new OUString( rURL ) );
} }
...@@ -1995,9 +1988,7 @@ void SfxHelpTextWindow_Impl::InitOnStartupBox() ...@@ -1995,9 +1988,7 @@ void SfxHelpTextWindow_Impl::InitOnStartupBox()
sCurrentFactory = SfxHelp::GetCurrentModuleIdentifier(); sCurrentFactory = SfxHelp::GetCurrentModuleIdentifier();
Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext(); Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
OUString sPath( PATH_OFFICE_FACTORIES ); const OUString sPath { PATH_OFFICE_FACTORIES + sCurrentFactory };
sPath += sCurrentFactory;
OUString sKey( KEY_HELP_ON_OPEN );
// Attention: This check boy knows two states: // Attention: This check boy knows two states:
// 1) Reading of the config key fails with an exception or by getting an empty Any (!) => check box must be hidden // 1) Reading of the config key fails with an exception or by getting an empty Any (!) => check box must be hidden
...@@ -2011,7 +2002,7 @@ void SfxHelpTextWindow_Impl::InitOnStartupBox() ...@@ -2011,7 +2002,7 @@ void SfxHelpTextWindow_Impl::InitOnStartupBox()
xContext, PACKAGE_SETUP, EConfigurationModes::Standard ); xContext, PACKAGE_SETUP, EConfigurationModes::Standard );
if ( xConfiguration.is() ) if ( xConfiguration.is() )
{ {
Any aAny = ConfigurationHelper::readRelativeKey( xConfiguration, sPath, sKey ); Any aAny = ConfigurationHelper::readRelativeKey( xConfiguration, sPath, KEY_HELP_ON_OPEN );
if (aAny >>= bHelpAtStartup) if (aAny >>= bHelpAtStartup)
bHideBox = false; bHideBox = false;
} }
...@@ -2031,10 +2022,9 @@ void SfxHelpTextWindow_Impl::InitOnStartupBox() ...@@ -2031,10 +2022,9 @@ void SfxHelpTextWindow_Impl::InitOnStartupBox()
if ( xConfiguration.is() ) if ( xConfiguration.is() )
{ {
OUString sTemp; OUString sTemp;
sKey = KEY_UI_NAME;
try try
{ {
Any aAny = ConfigurationHelper::readRelativeKey( xConfiguration, sPath, sKey ); Any aAny = ConfigurationHelper::readRelativeKey( xConfiguration, sPath, KEY_UI_NAME );
aAny >>= sTemp; aAny >>= sTemp;
} }
catch( Exception& ) catch( Exception& )
...@@ -2047,9 +2037,7 @@ void SfxHelpTextWindow_Impl::InitOnStartupBox() ...@@ -2047,9 +2037,7 @@ void SfxHelpTextWindow_Impl::InitOnStartupBox()
if ( !sModuleName.isEmpty() ) if ( !sModuleName.isEmpty() )
{ {
// set module name in checkbox text // set module name in checkbox text
OUString sText( aOnStartupText ); aOnStartupCB->SetText( aOnStartupText.replaceFirst( "%MODULENAME", sModuleName ) );
sText = sText.replaceFirst( "%MODULENAME", sModuleName );
aOnStartupCB->SetText( sText );
// and show it // and show it
aOnStartupCB->Show(); aOnStartupCB->Show();
// set check state // set check state
...@@ -2057,9 +2045,7 @@ void SfxHelpTextWindow_Impl::InitOnStartupBox() ...@@ -2057,9 +2045,7 @@ void SfxHelpTextWindow_Impl::InitOnStartupBox()
aOnStartupCB->SaveValue(); aOnStartupCB->SaveValue();
// calculate and set optimal width of the onstartup checkbox // calculate and set optimal width of the onstartup checkbox
OUString sCBText( "XXX" ); long nTextWidth = aOnStartupCB->GetTextWidth( "XXX" + aOnStartupCB->GetText() );
sCBText += aOnStartupCB->GetText();
long nTextWidth = aOnStartupCB->GetTextWidth( sCBText );
Size aSize = aOnStartupCB->GetSizePixel(); Size aSize = aOnStartupCB->GetSizePixel();
aSize.setWidth( nTextWidth ); aSize.setWidth( nTextWidth );
aOnStartupCB->SetSizePixel( aSize ); aOnStartupCB->SetSizePixel( aSize );
...@@ -2167,8 +2153,7 @@ IMPL_LINK_NOARG(SfxHelpTextWindow_Impl, SelectHdl, Timer *, void) ...@@ -2167,8 +2153,7 @@ IMPL_LINK_NOARG(SfxHelpTextWindow_Impl, SelectHdl, Timer *, void)
if ( bIsFullWordSearch ) if ( bIsFullWordSearch )
xSrchDesc->setPropertyValue( "SearchWords", makeAny( true ) ); xSrchDesc->setPropertyValue( "SearchWords", makeAny( true ) );
OUString sSearchString = sfx2::PrepareSearchString( aSearchText, GetBreakIterator(), false ); xSrchDesc->setSearchString( sfx2::PrepareSearchString( aSearchText, GetBreakIterator(), false ) );
xSrchDesc->setSearchString( sSearchString );
Reference< XIndexAccess > xSelection = xSearchable->findAll( xSrchDesc ); Reference< XIndexAccess > xSelection = xSearchable->findAll( xSrchDesc );
// then select all found words // then select all found words
...@@ -2205,7 +2190,6 @@ void SfxHelpTextWindow_Impl::FindHdl(sfx2::SearchDialog* pDlg) ...@@ -2205,7 +2190,6 @@ void SfxHelpTextWindow_Impl::FindHdl(sfx2::SearchDialog* pDlg)
if ( bWrapAround ) if ( bWrapAround )
pDlg = m_xSrchDlg.get(); pDlg = m_xSrchDlg.get();
DBG_ASSERT( pDlg, "invalid search dialog" ); DBG_ASSERT( pDlg, "invalid search dialog" );
OUString sSearchText = pDlg->GetSearchText();
try try
{ {
// select the words, which are equal to the search text of the search page // select the words, which are equal to the search text of the search page
...@@ -2221,7 +2205,7 @@ void SfxHelpTextWindow_Impl::FindHdl(sfx2::SearchDialog* pDlg) ...@@ -2221,7 +2205,7 @@ void SfxHelpTextWindow_Impl::FindHdl(sfx2::SearchDialog* pDlg)
xSrchDesc->setPropertyValue( "SearchWords", makeAny(pDlg->IsOnlyWholeWords()) ); xSrchDesc->setPropertyValue( "SearchWords", makeAny(pDlg->IsOnlyWholeWords()) );
xSrchDesc->setPropertyValue( "SearchCaseSensitive", makeAny(pDlg->IsMarchCase()) ); xSrchDesc->setPropertyValue( "SearchCaseSensitive", makeAny(pDlg->IsMarchCase()) );
xSrchDesc->setPropertyValue( "SearchBackwards", makeAny(pDlg->IsSearchBackwards()) ); xSrchDesc->setPropertyValue( "SearchBackwards", makeAny(pDlg->IsSearchBackwards()) );
xSrchDesc->setSearchString( sSearchText ); xSrchDesc->setSearchString( pDlg->GetSearchText() );
Reference< XInterface > xSelection; Reference< XInterface > xSelection;
Reference< XTextRange > xCursor = getCursor(); Reference< XTextRange > xCursor = getCursor();
...@@ -2289,12 +2273,10 @@ IMPL_LINK( SfxHelpTextWindow_Impl, CheckHdl, Button*, pButton, void ) ...@@ -2289,12 +2273,10 @@ IMPL_LINK( SfxHelpTextWindow_Impl, CheckHdl, Button*, pButton, void )
if ( xConfiguration.is() ) if ( xConfiguration.is() )
{ {
bool bChecked = pBox->IsChecked(); bool bChecked = pBox->IsChecked();
OUString sPath( PATH_OFFICE_FACTORIES );
sPath += sCurrentFactory;
try try
{ {
ConfigurationHelper::writeRelativeKey( ConfigurationHelper::writeRelativeKey(
xConfiguration, sPath, KEY_HELP_ON_OPEN, makeAny( bChecked ) ); xConfiguration, PATH_OFFICE_FACTORIES + sCurrentFactory, KEY_HELP_ON_OPEN, makeAny( bChecked ) );
ConfigurationHelper::flush( xConfiguration ); ConfigurationHelper::flush( xConfiguration );
} }
catch( Exception& ) catch( Exception& )
...@@ -2716,12 +2698,10 @@ void SfxHelpWindow_Impl::LoadConfig() ...@@ -2716,12 +2698,10 @@ void SfxHelpWindow_Impl::LoadConfig()
if ( aViewOpt.Exists() ) if ( aViewOpt.Exists() )
{ {
bIndex = aViewOpt.IsVisible(); bIndex = aViewOpt.IsVisible();
OUString aUserData;
Any aUserItem = aViewOpt.GetUserItem( USERITEM_NAME ); Any aUserItem = aViewOpt.GetUserItem( USERITEM_NAME );
OUString aTemp; OUString aUserData;
if ( aUserItem >>= aTemp ) if ( aUserItem >>= aUserData )
{ {
aUserData = aTemp;
DBG_ASSERT( comphelper::string::getTokenCount(aUserData, ';') == 6, "invalid user data" ); DBG_ASSERT( comphelper::string::getTokenCount(aUserData, ';') == 6, "invalid user data" );
sal_Int32 nIdx = 0; sal_Int32 nIdx = 0;
nIndexSize = aUserData.getToken( 0, ';', nIdx ).toInt32(); nIndexSize = aUserData.getToken( 0, ';', nIdx ).toInt32();
...@@ -2760,20 +2740,15 @@ void SfxHelpWindow_Impl::SaveConfig() ...@@ -2760,20 +2740,15 @@ void SfxHelpWindow_Impl::SaveConfig()
} }
aViewOpt.SetVisible( bIndex ); aViewOpt.SetVisible( bIndex );
OUString aUserData = OUString::number( nIndexSize );
aUserData += ";";
aUserData += OUString::number( nTextSize );
aUserData += ";";
aUserData += OUString::number( nW );
aUserData += ";";
aUserData += OUString::number( nH );
VclPtr<vcl::Window> pScreenWin = VCLUnoHelper::GetWindow( xWindow ); VclPtr<vcl::Window> pScreenWin = VCLUnoHelper::GetWindow( xWindow );
aWinPos = pScreenWin->GetWindowExtentsRelative( nullptr ).TopLeft(); aWinPos = pScreenWin->GetWindowExtentsRelative( nullptr ).TopLeft();
aUserData += ";"; const OUString aUserData = OUString::number( nIndexSize )
aUserData += OUString::number( aWinPos.X() ); + ";" + OUString::number( nTextSize )
aUserData += ";"; + ";" + OUString::number( nW )
aUserData += OUString::number( aWinPos.Y() ); + ";" + OUString::number( nH )
+ ";" + OUString::number( aWinPos.X() )
+ ";" + OUString::number( aWinPos.Y() );
aViewOpt.SetUserItem( USERITEM_NAME, makeAny( aUserData ) ); aViewOpt.SetUserItem( USERITEM_NAME, makeAny( aUserData ) );
} }
...@@ -2781,10 +2756,7 @@ void SfxHelpWindow_Impl::SaveConfig() ...@@ -2781,10 +2756,7 @@ void SfxHelpWindow_Impl::SaveConfig()
void SfxHelpWindow_Impl::ShowStartPage() void SfxHelpWindow_Impl::ShowStartPage()
{ {
OUString sHelpURL = SfxHelpWindow_Impl::buildHelpURL(pIndexWin->GetFactory(), loadHelpContent(SfxHelpWindow_Impl::buildHelpURL(pIndexWin->GetFactory(), "/start", OUString()));
"/start",
OUString());
loadHelpContent(sHelpURL);
} }
...@@ -2824,12 +2796,7 @@ IMPL_LINK_NOARG(SfxHelpWindow_Impl, OpenHdl, Control*, bool) ...@@ -2824,12 +2796,7 @@ IMPL_LINK_NOARG(SfxHelpWindow_Impl, OpenHdl, Control*, bool)
else else
aId = aEntry; aId = aEntry;
aEntry = "/"; sHelpURL = SfxHelpWindow_Impl::buildHelpURL(pIndexWin->GetFactory(), "/" + aId, aAnchor);
aEntry += aId;
sHelpURL = SfxHelpWindow_Impl::buildHelpURL(pIndexWin->GetFactory(),
aEntry,
aAnchor);
} }
loadHelpContent(sHelpURL); loadHelpContent(sHelpURL);
...@@ -2843,11 +2810,9 @@ IMPL_LINK( SfxHelpWindow_Impl, SelectFactoryHdl, SfxHelpIndexWindow_Impl* , pWin ...@@ -2843,11 +2810,9 @@ IMPL_LINK( SfxHelpWindow_Impl, SelectFactoryHdl, SfxHelpIndexWindow_Impl* , pWin
if ( sTitle.isEmpty() ) if ( sTitle.isEmpty() )
sTitle = GetParent()->GetText(); sTitle = GetParent()->GetText();
OUString aNewTitle = sTitle + " - " + pIndexWin->GetActiveFactoryTitle();
Reference< XTitle > xTitle(xFrame, UNO_QUERY); Reference< XTitle > xTitle(xFrame, UNO_QUERY);
if (xTitle.is ()) if (xTitle.is ())
xTitle->setTitle (aNewTitle); xTitle->setTitle(sTitle + " - " + pIndexWin->GetActiveFactoryTitle());
if ( pWin ) if ( pWin )
ShowStartPage(); ShowStartPage();
...@@ -3090,13 +3055,11 @@ void SfxHelpWindow_Impl::DoAction( sal_uInt16 nActionId ) ...@@ -3090,13 +3055,11 @@ void SfxHelpWindow_Impl::DoAction( sal_uInt16 nActionId )
OUString aValue; OUString aValue;
if ( aAny >>= aValue ) if ( aAny >>= aValue )
{ {
OUString aTitle(aValue);
SfxAddHelpBookmarkDialog_Impl aDlg(GetFrameWeld(), false); SfxAddHelpBookmarkDialog_Impl aDlg(GetFrameWeld(), false);
aDlg.SetTitle(aTitle); aDlg.SetTitle(aValue);
if (aDlg.run() == RET_OK ) if (aDlg.run() == RET_OK )
{ {
aTitle = aDlg.GetTitle(); pIndexWin->AddBookmarks( aDlg.GetTitle(), aURL );
pIndexWin->AddBookmarks( aTitle, aURL );
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment