Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
da5adead
Kaydet (Commit)
da5adead
authored
Nis 02, 2013
tarafından
Eike Rathke
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
DescriptionInfoset with LanguageTag
Change-Id: I7957a4a773b2ea8e69c30a1152b90ce5623a26dc
üst
e7207202
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
119 deletions
+57
-119
Library_deployment.mk
desktop/Library_deployment.mk
+1
-0
dp_descriptioninfoset.hxx
desktop/source/deployment/inc/dp_descriptioninfoset.hxx
+2
-13
dp_resource.h
desktop/source/deployment/inc/dp_resource.h
+2
-10
dp_descriptioninfoset.cxx
desktop/source/deployment/misc/dp_descriptioninfoset.cxx
+18
-68
dp_resource.cxx
desktop/source/deployment/misc/dp_resource.cxx
+5
-16
dp_package.cxx
desktop/source/deployment/registry/package/dp_package.cxx
+29
-12
No files found.
desktop/Library_deployment.mk
Dosyayı görüntüle @
da5adead
...
...
@@ -49,6 +49,7 @@ $(eval $(call gb_Library_use_libraries,deployment,\
ucbhelper \
utl \
xmlscript \
i18nisolang1 \
$(gb_UWINAPI) \
))
...
...
desktop/source/deployment/inc/dp_descriptioninfoset.hxx
Dosyayı görüntüle @
da5adead
...
...
@@ -31,7 +31,6 @@
/// @HTML
namespace
com
{
namespace
sun
{
namespace
star
{
namespace
lang
{
struct
Locale
;
}
namespace
uno
{
class
XComponentContext
;
}
namespace
xml
{
namespace
dom
{
...
...
@@ -230,16 +229,9 @@ private:
SAL_DLLPRIVATE
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
xml
::
dom
::
XNode
>
getLocalizedChild
(
::
rtl
::
OUString
const
&
sParent
)
const
;
SAL_DLLPRIVATE
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
xml
::
dom
::
XNode
>
matchFullLocale
(
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
xml
::
dom
::
XNode
>
const
&
xParent
,
::
rtl
::
OUString
const
&
sLocale
)
const
;
SAL_DLLPRIVATE
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
xml
::
dom
::
XNode
>
matchCountryAndLanguage
(
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
xml
::
dom
::
XNode
>
const
&
xParent
,
::
com
::
sun
::
star
::
lang
::
Locale
const
&
officeLocale
)
const
;
SAL_DLLPRIVATE
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
xml
::
dom
::
XNode
>
matchLanguage
(
matchLanguageTag
(
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
xml
::
dom
::
XNode
>
const
&
xParent
,
::
com
::
sun
::
star
::
lang
::
Locale
const
&
officeLocale
)
const
;
OUString
const
&
rTag
)
const
;
/** If there is no child element with a locale matching the office locale, then we use
the first child. In the case of the simple-license we also use the former default locale, which
...
...
@@ -258,9 +250,6 @@ private:
SAL_DLLPRIVATE
::
rtl
::
OUString
getLocalizedHREFAttrFromChild
(
::
rtl
::
OUString
const
&
sXPathParent
,
bool
*
out_bParentExists
)
const
;
static
SAL_DLLPRIVATE
::
rtl
::
OUString
localeToString
(
::
com
::
sun
::
star
::
lang
::
Locale
const
&
locale
);
/** Gets the node value for a given expression. The expression is used in
m_xpath-selectSingleNode. The value of the returned node is return value
of this function.
...
...
desktop/source/deployment/inc/dp_resource.h
Dosyayı görüntüle @
da5adead
...
...
@@ -22,7 +22,7 @@
#include "tools/string.hxx"
#include "tools/resid.hxx"
#include
"com/sun/star/lang/Locale.hpp"
#include
<i18npool/languagetag.hxx>
#include "dp_misc.h"
#include <memory>
#include "dp_misc_api.hxx"
...
...
@@ -43,15 +43,7 @@ struct StaticResourceString :
//==============================================================================
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
::
com
::
sun
::
star
::
lang
::
Locale
toLocale
(
::
rtl
::
OUString
const
&
slang
);
//==============================================================================
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
::
com
::
sun
::
star
::
lang
::
Locale
getOfficeLocale
();
//==============================================================================
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
::
rtl
::
OUString
getOfficeLocaleString
();
const
LanguageTag
&
getOfficeLanguageTag
();
}
...
...
desktop/source/deployment/misc/dp_descriptioninfoset.cxx
Dosyayı görüntüle @
da5adead
...
...
@@ -33,7 +33,6 @@
#include "com/sun/star/beans/XPropertySet.hpp"
#include "com/sun/star/io/SequenceInputStream.hpp"
#include "com/sun/star/lang/XMultiComponentFactory.hpp"
#include "com/sun/star/lang/Locale.hpp"
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/RuntimeException.hpp"
#include "com/sun/star/uno/Sequence.hxx"
...
...
@@ -725,20 +724,24 @@ DescriptionInfoset::getLocalizedChild( const ::rtl::OUString & sParent) const
css
::
uno
::
Reference
<
css
::
xml
::
dom
::
XNode
>
nodeMatch
;
if
(
xParent
.
is
())
{
const
::
rtl
::
OUString
sLocale
=
getOfficeLocaleString
();
nodeMatch
=
matchFullLocale
(
xParent
,
sLocale
);
nodeMatch
=
matchLanguageTag
(
xParent
,
getOfficeLanguageTag
().
getBcp47
());
//office: en-DE, en, en-DE-altmark
if
(
!
nodeMatch
.
is
())
{
const
css
::
lang
::
Locale
officeLocale
=
getOfficeLocale
();
nodeMatch
=
matchCountryAndLanguage
(
xParent
,
officeLocale
);
if
(
!
nodeMatch
.
is
())
const
::
std
::
vector
<
OUString
>
aFallbacks
=
getOfficeLanguageTag
().
getFallbackStrings
();
// Already tried full tag, continue with first fallback.
::
std
::
vector
<
OUString
>::
const_iterator
it
(
aFallbacks
.
begin
());
if
(
it
!=
aFallbacks
.
end
())
++
it
;
for
(
;
it
!=
aFallbacks
.
end
();
++
it
)
{
nodeMatch
=
matchLanguage
(
xParent
,
officeLocale
);
if
(
!
nodeMatch
.
is
())
nodeMatch
=
getChildWithDefaultLocale
(
xParent
)
;
nodeMatch
=
matchLanguage
Tag
(
xParent
,
*
it
);
if
(
nodeMatch
.
is
())
break
;
}
if
(
!
nodeMatch
.
is
())
nodeMatch
=
getChildWithDefaultLocale
(
xParent
);
}
}
...
...
@@ -746,79 +749,26 @@ DescriptionInfoset::getLocalizedChild( const ::rtl::OUString & sParent) const
}
css
::
uno
::
Reference
<
css
::
xml
::
dom
::
XNode
>
DescriptionInfoset
::
matchFullLocale
(
css
::
uno
::
Reference
<
css
::
xml
::
dom
::
XNode
>
const
&
xParent
,
::
rtl
::
OUString
const
&
sLocale
)
const
{
OSL_ASSERT
(
xParent
.
is
());
const
::
rtl
::
OUString
exp1
(
"*[@lang=
\"
"
+
sLocale
+
"
\"
]"
);
try
{
return
m_xpath
->
selectSingleNode
(
xParent
,
exp1
);
}
catch
(
const
css
::
xml
::
xpath
::
XPathException
&
)
{
// ignore
return
0
;
}
}
css
::
uno
::
Reference
<
css
::
xml
::
dom
::
XNode
>
DescriptionInfoset
::
matchCountryAndLanguage
(
css
::
uno
::
Reference
<
css
::
xml
::
dom
::
XNode
>
const
&
xParent
,
css
::
lang
::
Locale
const
&
officeLocale
)
const
{
OSL_ASSERT
(
xParent
.
is
());
css
::
uno
::
Reference
<
css
::
xml
::
dom
::
XNode
>
nodeMatch
;
if
(
!
officeLocale
.
Country
.
isEmpty
())
{
const
::
rtl
::
OUString
sLangCountry
(
officeLocale
.
Language
+
"-"
+
officeLocale
.
Country
);
//first try exact match for lang-country
const
::
rtl
::
OUString
exp1
(
"*[@lang=
\"
"
+
sLangCountry
+
"
\"
]"
);
try
{
nodeMatch
=
m_xpath
->
selectSingleNode
(
xParent
,
exp1
);
}
catch
(
const
css
::
xml
::
xpath
::
XPathException
&
)
{
// ignore
}
//try to match in strings that also have a variant, for example en-US matches in
//en-US-montana
if
(
!
nodeMatch
.
is
())
{
const
::
rtl
::
OUString
exp2
(
"*[starts-with(@lang,
\"
"
+
sLangCountry
+
"-
\"
)]"
);
try
{
nodeMatch
=
m_xpath
->
selectSingleNode
(
xParent
,
exp2
);
}
catch
(
const
css
::
xml
::
xpath
::
XPathException
&
)
{
// ignore
}
}
}
return
nodeMatch
;
}
css
::
uno
::
Reference
<
css
::
xml
::
dom
::
XNode
>
DescriptionInfoset
::
matchLanguage
(
css
::
uno
::
Reference
<
css
::
xml
::
dom
::
XNode
>
const
&
xParent
,
css
::
lang
::
Locale
const
&
officeLocale
)
const
DescriptionInfoset
::
matchLanguageTag
(
css
::
uno
::
Reference
<
css
::
xml
::
dom
::
XNode
>
const
&
xParent
,
OUString
const
&
rTag
)
const
{
OSL_ASSERT
(
xParent
.
is
());
css
::
uno
::
Reference
<
css
::
xml
::
dom
::
XNode
>
nodeMatch
;
//first try exact match for lang
const
::
rtl
::
OUString
exp1
(
"*[@lang=
\"
"
+
officeLocale
.
Language
+
"
\"
]"
);
const
::
rtl
::
OUString
exp1
(
"*[@lang=
\"
"
+
rTag
+
"
\"
]"
);
try
{
nodeMatch
=
m_xpath
->
selectSingleNode
(
xParent
,
exp1
);
}
catch
(
const
css
::
xml
::
xpath
::
XPathException
&
)
{
// ignore
}
//try to match in strings that also have a country and/or
variant, for example en matches in
//en-US-montana, en-US, en-montana
//try to match in strings that also have a country and/or
variant, for
//e
xample en matches in e
n-US-montana, en-US, en-montana
if
(
!
nodeMatch
.
is
())
{
const
::
rtl
::
OUString
exp2
(
"*[starts-with(@lang,
\"
"
+
officeLocale
.
Language
+
"-
\"
)]"
);
"*[starts-with(@lang,
\"
"
+
rTag
+
"-
\"
)]"
);
try
{
nodeMatch
=
m_xpath
->
selectSingleNode
(
xParent
,
exp2
);
}
catch
(
const
css
::
xml
::
xpath
::
XPathException
&
)
{
...
...
desktop/source/deployment/misc/dp_resource.cxx
Dosyayı görüntüle @
da5adead
...
...
@@ -37,21 +37,21 @@ namespace dp_misc {
namespace
{
struct
OfficeLocale
:
public
rtl
::
StaticWithInit
<
OUStrin
g
,
OfficeLocale
>
{
const
OUStrin
g
operator
()
()
{
public
rtl
::
StaticWithInit
<
LanguageTa
g
,
OfficeLocale
>
{
const
LanguageTa
g
operator
()
()
{
OUString
slang
(
utl
::
ConfigManager
::
getLocale
());
//fallback, the locale is currently only set when the user starts the
//office for the first time.
if
(
slang
.
isEmpty
())
slang
=
"en-US"
;
return
slang
;
return
LanguageTag
(
slang
)
;
}
};
struct
DeploymentResMgr
:
public
rtl
::
StaticWithInit
<
ResMgr
*
,
DeploymentResMgr
>
{
ResMgr
*
operator
()
()
{
return
ResMgr
::
CreateResMgr
(
"deployment"
,
LanguageTag
(
OfficeLocale
::
get
()
)
);
return
ResMgr
::
CreateResMgr
(
"deployment"
,
OfficeLocale
::
get
(
)
);
}
};
...
...
@@ -76,19 +76,8 @@ String getResourceString( sal_uInt16 id )
return
ret
;
}
//=============================================================================
::
com
::
sun
::
star
::
lang
::
Locale
toLocale
(
::
rtl
::
OUString
const
&
slang
)
{
return
LanguageTag
(
slang
).
getLocale
();
}
//==============================================================================
lang
::
Locale
getOfficeLocale
()
{
return
toLocale
(
OfficeLocale
::
get
());
}
::
rtl
::
OUString
getOfficeLocaleString
()
const
LanguageTag
&
getOfficeLanguageTag
()
{
return
OfficeLocale
::
get
();
}
...
...
desktop/source/deployment/registry/package/dp_package.cxx
Dosyayı görüntüle @
da5adead
...
...
@@ -1419,9 +1419,11 @@ void BackendImpl::PackageImpl::scanBundle(
}
const
lang
::
Locale
officeLocale
=
getOfficeLocale
();
const
LanguageTag
&
officeLocale
=
getOfficeLanguageTag
();
const
::
std
::
vector
<
OUString
>
officeFallbacks
(
officeLocale
.
getFallbackStrings
());
const
size_t
nPenaltyMax
=
::
std
::
numeric_limits
<
size_t
>::
max
();
size_t
descrPenalty
=
nPenaltyMax
;
OUString
descrFile
;
lang
::
Locale
descrFileLocale
;
const
Reference
<
XComponentContext
>
xContext
(
getMyBackend
()
->
getComponentContext
()
);
...
...
@@ -1469,18 +1471,33 @@ void BackendImpl::PackageImpl::scanBundle(
}
else
{
// match best locale:
lang
::
Locale
locale
(
toLocale
(
param
->
m_sValue
)
);
if
(
locale
.
Language
==
officeLocale
.
Language
)
LanguageTag
descrTag
(
param
->
m_sValue
);
if
(
officeLocale
.
getLanguage
()
==
descrTag
.
getLanguage
()
)
{
if
(
descrFileLocale
.
Country
==
officeLocale
.
Country
&&
locale
.
Country
!=
officeLocale
.
Country
)
continue
;
if
(
descrFileLocale
.
Variant
==
officeLocale
.
Variant
&&
locale
.
Variant
!=
officeLocale
.
Variant
)
continue
;
descrFile
=
url
;
descrFileLocale
=
locale
;
size_t
nPenalty
=
nPenaltyMax
;
const
::
std
::
vector
<
OUString
>
descrFallbacks
(
descrTag
.
getFallbackStrings
());
for
(
size_t
o
=
0
;
o
<
officeFallbacks
.
size
()
&&
nPenalty
==
nPenaltyMax
;
++
o
)
{
for
(
size_t
d
=
0
;
d
<
descrFallbacks
.
size
()
&&
nPenalty
==
nPenaltyMax
;
++
d
)
{
if
(
officeFallbacks
[
o
]
==
descrFallbacks
[
d
])
{
// The last fallbacks are always language-only
// fallbacks, so we _will_ have _some_ match if
// we ever entered the overall if() condition.
nPenalty
=
o
*
1000
+
d
;
if
(
descrPenalty
>
nPenalty
)
{
descrPenalty
=
nPenalty
;
descrFile
=
url
;
}
}
}
}
}
// TODO: we could break here if descrPenalty==0 for an exact
// match of officeLocale, but the previous code didn't; are
// there side effects?
}
continue
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment