summaryrefslogtreecommitdiff
path: root/xmlhelp/source
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-10-26 17:55:14 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-10-26 17:55:14 +0100
commit6948c546fdc00dddec7d58e03150dcc87921d6b2 (patch)
treecb0afa155279289cb8853f02bfbca97415f6aad4 /xmlhelp/source
parentf5174c89cd037d35b975590083cf91b36633808d (diff)
tdf#75637: Resolve help images via a vnd.libreoffice.image UCP
...which uses the logic already available in VCL's ImplImageTree to locate the image zip files and find fallbacks for incomplete themes and for localized images. Change-Id: Ic1c15fcacb6596a27a2b051093232902202bf472
Diffstat (limited to 'xmlhelp/source')
-rw-r--r--xmlhelp/source/cxxhelp/provider/databases.cxx122
-rw-r--r--xmlhelp/source/cxxhelp/provider/databases.hxx6
-rw-r--r--xmlhelp/source/cxxhelp/provider/provider.cxx14
-rw-r--r--xmlhelp/source/cxxhelp/provider/urlparameter.cxx4
4 files changed, 26 insertions, 120 deletions
diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx
index 908fdab56177..5f2d0b991f66 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.cxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.cxx
@@ -120,7 +120,6 @@ OUString Databases::expandURL( const OUString& aURL, Reference< uno::XComponentC
Databases::Databases( bool showBasic,
const OUString& instPath,
- const com::sun::star::uno::Sequence< OUString >& imagesZipPaths,
const OUString& productName,
const OUString& productVersion,
const OUString& styleSheet,
@@ -137,9 +136,7 @@ Databases::Databases( bool showBasic,
prodVersion( "%PRODUCTVERSION" ),
vendName( "%VENDORNAME" ),
vendVersion( "%VENDORVERSION" ),
- vendShort( "%VENDORSHORT" ),
- m_aImagesZipPaths( imagesZipPaths ),
- m_aSymbolsStyleName( "" )
+ vendShort( "%VENDORSHORT" )
{
m_xSMgr = Reference< XMultiComponentFactory >( m_xContext->getServiceManager(), UNO_QUERY );
@@ -207,106 +204,33 @@ Databases::~Databases()
}
}
-static bool impl_getZipFile(
- Sequence< OUString > & rImagesZipPaths,
- const OUString & rZipName,
- OUString & rFileName )
-{
- OUString aWorkingDir;
- osl_getProcessWorkingDir( &aWorkingDir.pData );
- const OUString *pPathArray = rImagesZipPaths.getArray();
- for ( int i = 0; i < rImagesZipPaths.getLength(); ++i )
- {
- OUString aFileName = pPathArray[ i ];
- if ( !aFileName.isEmpty() )
- {
- if ( !aFileName.endsWith("/") )
- {
- aFileName += "/";
- }
- aFileName += rZipName;
- // the icons are not read when the URL is a symlink
- osl::File::getAbsoluteFileURL( aWorkingDir, aFileName, rFileName );
-
- // test existence
- osl::DirectoryItem aDirItem;
- if ( osl::DirectoryItem::get( rFileName, aDirItem ) == osl::FileBase::E_None )
- return true;
- }
- }
- return false;
-}
-
-OString Databases::getImagesZipFileURL()
+OString Databases::getImageTheme()
{
+ uno::Reference< lang::XMultiServiceFactory > xConfigProvider =
+ configuration::theDefaultProvider::get(m_xContext);
+
+ // set root path
+ uno::Sequence < uno::Any > lParams(1);
+ beans::PropertyValue aParam ;
+ aParam.Name = "nodepath";
+ aParam.Value <<= OUString("org.openoffice.Office.Common");
+ lParams[0] = uno::makeAny(aParam);
+
+ // open it
+ uno::Reference< uno::XInterface > xCFG( xConfigProvider->createInstanceWithArguments(
+ OUString("com.sun.star.configuration.ConfigurationAccess"),
+ lParams) );
+
+ uno::Reference< container::XHierarchicalNameAccess > xAccess(xCFG, uno::UNO_QUERY_THROW);
+ uno::Any aResult = xAccess->getByHierarchicalName(OUString("Misc/SymbolStyle"));
OUString aSymbolsStyleName;
- try
- {
- uno::Reference< lang::XMultiServiceFactory > xConfigProvider =
- configuration::theDefaultProvider::get(m_xContext);
-
- // set root path
- uno::Sequence < uno::Any > lParams(1);
- beans::PropertyValue aParam ;
- aParam.Name = "nodepath";
- aParam.Value <<= OUString("org.openoffice.Office.Common");
- lParams[0] = uno::makeAny(aParam);
-
- // open it
- uno::Reference< uno::XInterface > xCFG( xConfigProvider->createInstanceWithArguments(
- OUString("com.sun.star.configuration.ConfigurationAccess"),
- lParams) );
-
- bool bChanged = false;
- uno::Reference< container::XHierarchicalNameAccess > xAccess(xCFG, uno::UNO_QUERY_THROW);
- uno::Any aResult = xAccess->getByHierarchicalName(OUString("Misc/SymbolStyle"));
- if ( (aResult >>= aSymbolsStyleName) && m_aSymbolsStyleName != aSymbolsStyleName )
- {
- m_aSymbolsStyleName = aSymbolsStyleName;
- bChanged = true;
- }
-
- if ( m_aImagesZipFileURL.isEmpty() || bChanged )
- {
- OUString aImageZip;
- bool bFound = false;
-
- if ( !aSymbolsStyleName.isEmpty() )
- {
- if ( aSymbolsStyleName == "auto" )
- {
- // with the layered images*.zip, tango is the most
- // complete theme, so show that one
- // FIXME instead of using a general vnd.sun.star.zip://
- // for imgrepos, we should have some vnd.sun.star.image://
- // so that we don't have to re-open the stream for every
- // image in the help
- aSymbolsStyleName = "tango";
- }
- OUString aZipName = "images_" + aSymbolsStyleName + ".zip";
+ aResult >>= aSymbolsStyleName;
- bFound = impl_getZipFile( m_aImagesZipPaths, aZipName, aImageZip );
- }
-
- if ( ! bFound )
- bFound = impl_getZipFile( m_aImagesZipPaths, OUString( "images.zip" ), aImageZip );
-
- if ( ! bFound )
- aImageZip.clear();
-
- m_aImagesZipFileURL = OUStringToOString(
- rtl::Uri::encode(
- aImageZip,
- rtl_UriCharClassPchar,
- rtl_UriEncodeIgnoreEscapes,
- RTL_TEXTENCODING_UTF8 ), RTL_TEXTENCODING_UTF8 );
- }
- }
- catch ( NoSuchElementException const & )
+ if ( aSymbolsStyleName.isEmpty() || aSymbolsStyleName == "auto" )
{
+ aSymbolsStyleName = "tango";
}
-
- return m_aImagesZipFileURL;
+ return aSymbolsStyleName.toUtf8();
}
void Databases::replaceName( OUString& oustring ) const
diff --git a/xmlhelp/source/cxxhelp/provider/databases.hxx b/xmlhelp/source/cxxhelp/provider/databases.hxx
index 9e33a98e02cf..9b331cc96af2 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.hxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.hxx
@@ -140,7 +140,6 @@ namespace chelp {
Databases( bool showBasic,
const OUString& instPath,
- const com::sun::star::uno::Sequence< OUString >& imagesZipPaths,
const OUString& productName,
const OUString& productVersion,
const OUString& styleSheet,
@@ -148,7 +147,7 @@ namespace chelp {
~Databases();
- OString getImagesZipFileURL();
+ OString getImageTheme();
OUString getInstallPathAsURL();
@@ -265,9 +264,6 @@ namespace chelp {
prodName,prodVersion,vendName,vendVersion,vendShort;
OUString m_aInstallDirectory; // Installation directory
- com::sun::star::uno::Sequence< OUString > m_aImagesZipPaths;
- OString m_aImagesZipFileURL;
- OUString m_aSymbolsStyleName;
std::vector< OUString > m_avModules;
diff --git a/xmlhelp/source/cxxhelp/provider/provider.cxx b/xmlhelp/source/cxxhelp/provider/provider.cxx
index 781554d8a445..95b1c6de4d7b 100644
--- a/xmlhelp/source/cxxhelp/provider/provider.cxx
+++ b/xmlhelp/source/cxxhelp/provider/provider.cxx
@@ -35,7 +35,6 @@
#include <cppuhelper/supportsservice.hxx>
#include <unotools/configmgr.hxx>
#include <unotools/pathoptions.hxx>
-#include <rtl/bootstrap.hxx>
#include "databases.hxx"
#include "provider.hxx"
@@ -324,22 +323,9 @@ void ContentProvider::init()
}
OUString productversion( setupversion + " " + setupextension );
-
- uno::Sequence< OUString > aImagesZipPaths( 2 );
- xHierAccess = getHierAccess( sProvider, "org.openoffice.Office.Common" );
-
- OUString aPath( getKey( xHierAccess, "Path/Current/UserConfig" ) );
- subst( aPath );
- aImagesZipPaths[ 0 ] = aPath;
-
- aPath = "$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR/config";
- rtl::Bootstrap::expandMacros(aPath);
- aImagesZipPaths[ 1 ] = aPath;
-
bool showBasic = getBooleanKey(xHierAccess,"Help/ShowBasic");
m_pDatabases = new Databases( showBasic,
instPath,
- aImagesZipPaths,
utl::ConfigManager::getProductName(),
productversion,
stylesheet,
diff --git a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx
index 14f6240d6da5..72a57d1d24f3 100644
--- a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx
+++ b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx
@@ -890,8 +890,8 @@ InputStreamTransformer::InputStreamTransformer( URLParameter* urlParam,
pDatabases->getProductVersion().getLength(),
RTL_TEXTENCODING_UTF8 ) + OString('\'');
- parString[last++] = "imgrepos";
- parString[last++] = OString('\'') + pDatabases->getImagesZipFileURL() + OString('\'');
+ parString[last++] = "imgtheme";
+ parString[last++] = OString('\'') + pDatabases->getImageTheme() + OString('\'');
parString[last++] = "hp";
parString[last++] = OString('\'') + urlParam->getByName( "HelpPrefix" ) + OString('\'');