Kaydet (Commit) dcf76c75 authored tarafından Michael Meeks's avatar Michael Meeks

gallery: add auxiliary .desktop style translation files.

Change-Id: I2f2f0d5d30fbcab83343f94fd16d9371baa380e5
üst d5051efa
......@@ -42,6 +42,7 @@ private:
INetURLObject aThmURL;
INetURLObject aSdgURL;
INetURLObject aSdvURL;
INetURLObject aStrURL;
sal_uInt32 nId;
sal_Bool bReadOnly;
sal_Bool bModified;
......@@ -62,6 +63,9 @@ public:
const INetURLObject& GetThmURL() const { return aThmURL; }
const INetURLObject& GetSdgURL() const { return aSdgURL; }
const INetURLObject& GetSdvURL() const { return aSdvURL; }
const INetURLObject& GetStrURL() const { return aStrURL; }
OUString ReadStrFromIni(const OUString &aKeyName );
sal_Bool IsReadOnly() const { return bReadOnly; }
sal_Bool IsDefault() const;
......
......@@ -95,7 +95,7 @@ private:
SotStorageRef aSvDrawStorageRef;
Gallery* pParent;
GalleryThemeEntry* pThm;
sal_uIntPtr mnThemeLockCount;
sal_uIntPtr mnThemeLockCount;
sal_uIntPtr mnBroadcasterLockCount;
sal_uIntPtr nDragPos;
sal_Bool bDragging;
......@@ -149,6 +149,7 @@ public:
const INetURLObject& GetThmURL() const;
SVX_DLLPUBLIC const INetURLObject& GetSdgURL() const;
const INetURLObject& GetSdvURL() const;
const INetURLObject& GetStrURL() const;
SVX_DLLPUBLIC sal_uInt32 GetId() const;
void SetId( sal_uInt32 nNewId, sal_Bool bResetThemeName );
......
......@@ -123,6 +123,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
svx/source/gallery2/galbrws2 \
svx/source/gallery2/galctrl \
svx/source/gallery2/galexpl \
svx/source/gallery2/galini \
svx/source/gallery2/gallery1 \
svx/source/gallery2/galmisc \
svx/source/gallery2/galobj \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/*
* The world's quickest and lamest .desktop / .ini file parser.
* Ideally the .thm file would move to a .desktop file in
* future.
*/
#include <sal/config.h>
#include <unotools/streamwrap.hxx>
#include <unotools/ucbstreamhelper.hxx>
#include <unotools/tempfile.hxx>
#include <svx/gallery1.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <unotools/syslocale.hxx>
#include <vcl/svapp.hxx>
OUString GalleryThemeEntry::ReadStrFromIni(const OUString &aKeyName )
{
SvStream *pStrm = ::utl::UcbStreamHelper::CreateStream(
GetStrURL().GetMainURL( INetURLObject::NO_DECODE ),
STREAM_READ );
const LanguageTag &rLangTag = Application::GetSettings().GetUILanguageTag();
::std::vector< OUString > aFallbacks = rLangTag.getFallbackStrings();
OUString aResult;
sal_Int32 nRank = 42;
if( pStrm )
{
OString aLine;
while( pStrm->ReadLine( aLine ) )
{
OUString aKey;
OUString aLocale;
OUString aValue;
sal_Int32 n;
if( ( n = aLine.indexOf( '=' ) ) >= 1)
{
aKey = OStringToOUString(
aLine.copy( 0, n ).trim(), RTL_TEXTENCODING_ASCII_US );
aValue = OStringToOUString(
aLine.copy( n + 1 ).trim(), RTL_TEXTENCODING_UTF8 );
if( ( n = aKey.indexOf( '[' ) ) >= 1 )
{
aLocale = aKey.copy( n + 1 ).trim();
aKey = aKey.copy( 0, n ).trim();
if( (n = aLocale.indexOf( ']' ) ) >= 1 )
aLocale = aLocale.copy( 0, n ).trim();
}
}
SAL_INFO("svx", "ini file has '" << aKey << "' [ '" << aLocale << "' ] = '" << aValue << "'");
// grisly language matching, is this not available somewhere else?
if( aKey == aKeyName )
{
n = 0;
OUString aLang = aLocale.replace('_','-');
for( std::vector< OUString >::const_iterator i = aFallbacks.begin();
i != aFallbacks.end(); ++i, ++n )
{
SAL_INFO( "svx", "compare '" << aLang << "' with '" << *i << "' rank " << nRank << " vs. " << n );
if( *i == aLang && n < nRank ) {
nRank = n; // try to get the most accurate match
aResult = aValue;
}
}
}
}
delete pStrm;
}
SAL_INFO( "svx", "readStrFromIni returns '" << aResult << "'");
return aResult;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -64,9 +64,16 @@ GalleryThemeEntry::GalleryThemeEntry( const INetURLObject& rBaseURL, const Strin
aURL.setExtension( "sdv" );
aSdvURL = ImplGetURLIgnoreCase( aURL );
aURL.setExtension( "str" );
aStrURL = ImplGetURLIgnoreCase( aURL );
SetModified( _bNewFile );
if( nId && bThemeNameFromResource )
aName = ReadStrFromIni( "name" );
// This is awful - we shouldn't use these resources if we
// possibly can avoid them
if( aName.isEmpty() && nId && bThemeNameFromResource )
aName = GAL_RESSTR( RID_GALLERYSTR_THEME_START + (sal_uInt16) nId );
if( aName.isEmpty() )
......@@ -573,12 +580,14 @@ sal_Bool Gallery::RemoveTheme( const String& rThemeName )
INetURLObject aThmURL( pThm->GetThmURL() );
INetURLObject aSdgURL( pThm->GetSdgURL() );
INetURLObject aSdvURL( pThm->GetSdvURL() );
INetURLObject aStrURL( pThm->GetSdvURL() );
ReleaseTheme( pThm, aListener );
KillFile( aThmURL );
KillFile( aSdgURL );
KillFile( aSdvURL );
KillFile( aStrURL );
}
for ( GalleryThemeList::iterator it = aThemeList.begin(); it != aThemeList.end(); ++it )
......
......@@ -1564,6 +1564,7 @@ void GalleryTheme::ImplSetModified( sal_Bool bModified )
const OUString& GalleryTheme::GetRealName() const { return pThm->GetThemeName(); }
const INetURLObject& GalleryTheme::GetThmURL() const { return pThm->GetThmURL(); }
const INetURLObject& GalleryTheme::GetSdgURL() const { return pThm->GetSdgURL(); }
const INetURLObject& GalleryTheme::GetStrURL() const { return pThm->GetStrURL(); }
const INetURLObject& GalleryTheme::GetSdvURL() const { return pThm->GetSdvURL(); }
sal_uInt32 GalleryTheme::GetId() const { return pThm->GetId(); }
void GalleryTheme::SetId( sal_uInt32 nNewId, sal_Bool bResetThemeName ) { pThm->SetId( nNewId, bResetThemeName ); }
......
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