summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuhammet Kara <muhammet.kara@pardus.org.tr>2018-09-20 17:16:28 +0300
committerMuhammet Kara <muhammet.kara@pardus.org.tr>2018-09-20 21:44:48 +0200
commit4cc71fef5a4fd05b2ee2953dd8a297ffffff29a0 (patch)
treefc2d56b6bc9383c2b3fd88d4d33a57a07b37d421
parent66232248ff55639052ddb76918d555e21dc9c46b (diff)
Use slug instead of name to store Personas
Persona names aren't necessarily unique, but the slug is a unique id (also called pretty name) for personas. It can also be directly used to retrieve/reach the original url of an installed persona. Change-Id: Ieb81671a0fd654a727063d00a4f78a3b5cb29cbd Reviewed-on: https://gerrit.libreoffice.org/60821 Tested-by: Jenkins Reviewed-by: Muhammet Kara <muhammet.kara@pardus.org.tr>
-rw-r--r--cui/source/options/personalization.cxx62
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/Common.xcs5
-rw-r--r--vcl/source/app/settings.cxx5
3 files changed, 52 insertions, 20 deletions
diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx
index 9c4178d0b987..fde5872aeaf2 100644
--- a/cui/source/options/personalization.cxx
+++ b/cui/source/options/personalization.cxx
@@ -213,9 +213,14 @@ IMPL_LINK( SelectPersonaDialog, SelectPersona, Button*, pButton, void )
{
m_aSelectedPersona = m_vPersonaSettings[index];
// get the persona name from the setting variable to show in the progress.
- sal_Int32 nNameIndex = m_aSelectedPersona.indexOf( ';' );
- OUString aName = m_aSelectedPersona.copy( 0, nNameIndex );
- OUString aProgress = CuiResId(RID_SVXSTR_SELECTEDPERSONA) + aName;
+ sal_Int32 nSlugIndex, nNameIndex;
+ OUString aName, aProgress;
+
+ // Skip the slug
+ nSlugIndex = m_aSelectedPersona.indexOf( ';' );
+ nNameIndex = m_aSelectedPersona.indexOf( ';', nSlugIndex );
+ aName = m_aSelectedPersona.copy( nSlugIndex + 1, nNameIndex );
+ aProgress = CuiResId(RID_SVXSTR_SELECTEDPERSONA) + aName;
SetProgress( aProgress );
}
break;
@@ -409,8 +414,12 @@ void SvxPersonalizationTabPage::CheckAppliedTheme()
void SvxPersonalizationTabPage::ShowAppliedThemeLabel(const OUString& aPersonaSetting)
{
- sal_Int32 nNameIndex = aPersonaSetting.indexOf( '/' );
- OUString aName = "(" + aPersonaSetting.copy( 0, nNameIndex ) +")";
+ sal_Int32 nSlugIndex, nNameIndex;
+ OUString aName;
+
+ nSlugIndex = aPersonaSetting.indexOf( ';' ) + 1;
+ nNameIndex = aPersonaSetting.indexOf( ';', nSlugIndex );
+ aName = "(" + aPersonaSetting.copy( nSlugIndex, nNameIndex ) +")";
m_pAppliedThemeLabel->Show();
m_pAppliedThemeLabel->SetText( aName );
}
@@ -469,8 +478,12 @@ void SvxPersonalizationTabPage::LoadExtensionThemes()
for( sal_Int32 nIndex = 0; nIndex < nLength; nIndex++ )
{
Reference< XPropertySet > xPropertySet( officecfg::Office::Common::Misc::PersonasList::get()->getByName( installedPersonas[nIndex] ), UNO_QUERY_THROW );
- OUString aPersonaName, aPreviewFile, aHeaderFile, aFooterFile, aTextColor, aAccentColor, aPersonaSettings;
- Any aValue = xPropertySet->getPropertyValue( "Name" );
+ OUString aPersonaSlug, aPersonaName, aPreviewFile, aHeaderFile, aFooterFile, aTextColor, aAccentColor, aPersonaSettings;
+
+ Any aValue = xPropertySet->getPropertyValue( "Slug" );
+ aValue >>= aPersonaSlug;
+
+ aValue = xPropertySet->getPropertyValue( "Name" );
aValue >>= aPersonaName;
m_pPersonaList->InsertEntry( aPersonaName );
@@ -489,7 +502,8 @@ void SvxPersonalizationTabPage::LoadExtensionThemes()
aValue = xPropertySet->getPropertyValue( "AccentColor" );
aValue >>= aAccentColor;
- aPersonaSettings = aPreviewFile + ";" + aHeaderFile + ";" + aFooterFile + ";" + aTextColor + ";" + aAccentColor;
+ aPersonaSettings = aPersonaSlug + ";" + aPersonaName + ";" + aPreviewFile
+ + ";" + aHeaderFile + ";" + aFooterFile + ";" + aTextColor + ";" + aAccentColor;
rtl::Bootstrap::expandMacros( aPersonaSettings );
m_vExtensionPersonaSettings.push_back( aPersonaSettings );
}
@@ -569,7 +583,7 @@ static OUString searchValue( const OString &rBuffer, sal_Int32 from, const OStri
/// Parse the Persona web page, and find where to get the bitmaps + the color values.
static bool parsePersonaInfo( const OString &rBufferArg, OUString *pHeaderURL, OUString *pFooterURL,
OUString *pTextColor, OUString *pAccentColor, OUString *pPreviewURL,
- OUString *pName )
+ OUString *pName, OUString *pSlug )
{
// tdf#115417: buffer retrieved from html response can contain &quot; or &#34;
// let's replace the whole buffer with last one so we can treat it easily
@@ -601,7 +615,12 @@ static bool parsePersonaInfo( const OString &rBufferArg, OUString *pHeaderURL, O
return false;
*pName = searchValue( rBuffer, persona, "\"name\":\"" );
- return !pName->isEmpty();
+ if ( pName->isEmpty() )
+ return false;
+
+ *pSlug = searchValue( rBuffer, persona, "\"bySlug\":{\"" );
+
+ return !pSlug->isEmpty();
}
SearchAndParseThread::SearchAndParseThread( SelectPersonaDialog* pDialog,
@@ -660,15 +679,15 @@ bool getPreviewFile( const OUString& rURL, OUString *pPreviewFile, OUString *pPe
xStream->closeInput();
// get the important bits of info
- OUString aHeaderURL, aFooterURL, aTextColor, aAccentColor, aPreviewURL, aName;
+ OUString aHeaderURL, aFooterURL, aTextColor, aAccentColor, aPreviewURL, aName, aSlug;
- if ( !parsePersonaInfo( aBuffer.makeStringAndClear(), &aHeaderURL, &aFooterURL, &aTextColor, &aAccentColor, &aPreviewURL, &aName ) )
+ if ( !parsePersonaInfo( aBuffer.makeStringAndClear(), &aHeaderURL, &aFooterURL, &aTextColor, &aAccentColor, &aPreviewURL, &aName, &aSlug ) )
return false;
// copy the images to the user's gallery
OUString gallery = "${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}";
rtl::Bootstrap::expandMacros( gallery );
- gallery += "/user/gallery/personas/" + aName + "/";
+ gallery += "/user/gallery/personas/" + aSlug + "/";
osl::Directory::createPath( gallery );
OUString aPreviewFile( INetURLObject( aPreviewURL ).getName() );
@@ -681,7 +700,7 @@ bool getPreviewFile( const OUString& rURL, OUString *pPreviewFile, OUString *pPe
return false;
}
*pPreviewFile = gallery + aPreviewFile;
- *pPersonaSetting = aName + ";" + aHeaderURL + ";" + aFooterURL + ";" + aTextColor + ";" + aAccentColor;
+ *pPersonaSetting = aSlug + ";" + aName + ";" + aHeaderURL + ";" + aFooterURL + ";" + aTextColor + ";" + aAccentColor;
return true;
}
@@ -825,13 +844,17 @@ void SearchAndParseThread::execute()
if ( !xFileAccess.is() )
return;
- OUString aName, aHeaderURL, aFooterURL, aTextColor, aAccentColor;
+ OUString aSlug, aName, aHeaderURL, aFooterURL, aTextColor, aAccentColor;
OUString aPersonaSetting;
// get the required fields from m_aURL
sal_Int32 nOldIndex = 0;
sal_Int32 nNewIndex = m_aURL.indexOf( ';', nOldIndex );
- aName = m_aURL.copy( nOldIndex, ( nNewIndex - nOldIndex ) );
+ aSlug = m_aURL.copy( nOldIndex, ( nNewIndex - nOldIndex ) );
+
+ nOldIndex = nNewIndex + 1;
+ nNewIndex = m_aURL.indexOf( ';', nOldIndex );
+ aName = m_aURL.copy(nOldIndex , ( nNewIndex - nOldIndex ) );
nOldIndex = nNewIndex + 1;
nNewIndex = m_aURL.indexOf( ';', nOldIndex );
@@ -858,8 +881,8 @@ void SearchAndParseThread::execute()
OUString aHeaderFile( INetURLObject( aHeaderURL ).getName() );
OUString aFooterFile( INetURLObject( aFooterURL ).getName() );
- aHeaderFile = aName + "/" + aHeaderFile;
- aFooterFile = aName + "/" + aFooterFile;
+ aHeaderFile = aSlug + "/" + aHeaderFile;
+ aFooterFile = aSlug + "/" + aFooterFile;
try {
xFileAccess->copy( aHeaderURL, gallery + aHeaderFile );
@@ -883,7 +906,8 @@ void SearchAndParseThread::execute()
SolarMutexGuard aGuard;
- aPersonaSetting = aHeaderFile + ";" + aFooterFile + ";" + aTextColor + ";" + aAccentColor;
+ aPersonaSetting = aSlug + ";" + aName + ";" + aHeaderFile + ";" + aFooterFile
+ + ";" + aTextColor + ";" + aAccentColor;
m_pPersonaDialog->SetAppliedPersonaSetting( aPersonaSetting );
m_pPersonaDialog->EndDialog( RET_OK );
}
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 948fddc7cc31..d7c01d389780 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -810,6 +810,11 @@
<info>
<desc>Stores the details of the installed personas.</desc>
</info>
+ <prop oor:name="Slug" oor:type="xs:string" oor:nillable="false">
+ <info>
+ <desc>Unique pretty id of the persona, also part of its url</desc>
+ </info>
+ </prop>
<prop oor:name="Name" oor:type="xs:string" oor:nillable="false">
<info>
<desc>The Persona's name</desc>
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 0dc2558ab36a..8da8c0355e7d 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -2122,7 +2122,10 @@ static void setupPersonaHeaderFooter( WhichPersona eWhich, OUString& rHeaderFoot
if ( aPersona == "own" || aPersona == "default" )
{
sal_Int32 nIndex = 0;
- aHeader = aPersonaSettings.getToken( 0, ';', nIndex );
+
+ // Skip the persona slug and name
+ aHeader = aPersonaSettings.getToken( 2, ';', nIndex );
+
if ( nIndex > 0 )
aFooter = aPersonaSettings.getToken( 0, ';', nIndex );