diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2013-12-03 08:19:36 +0100 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2013-12-06 05:43:21 -0600 |
commit | c2f5e09900561d417d53a74fd6bc189cb7d898e1 (patch) | |
tree | 93580181d603dcdcfb73f5950cbed019be8c1a88 | |
parent | 9a37ce189881f12d678fdb054219b13c3e4c7e40 (diff) |
Zip .ui translations per UIConfig target.
Fix installer / scp2 to not ignore directory prefix in 'Name'.
Change-Id: Ib319363c8be73a72029f1ba3833e518e15c55e29
Reviewed-on: https://gerrit.libreoffice.org/6915
Reviewed-by: David Tardon <dtardon@redhat.com>
Tested-by: David Tardon <dtardon@redhat.com>
-rw-r--r-- | include/xmlreader/xmlreader.hxx | 2 | ||||
-rwxr-xr-x | scp2/inc/macros.inc | 8 | ||||
-rw-r--r-- | scp2/macros/macro.pl | 16 | ||||
-rw-r--r-- | scp2/source/ooo/file_library_ooo.scp | 2 | ||||
-rw-r--r-- | scp2/source/ooo/file_ooo.scp | 40 | ||||
-rw-r--r-- | scp2/source/ooo/ure.scp | 2 | ||||
-rw-r--r-- | solenv/bin/modules/installer/scriptitems.pm | 2 | ||||
-rw-r--r-- | solenv/gbuild/UIConfig.mk | 30 | ||||
-rw-r--r-- | solenv/gbuild/Zip.mk | 29 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 35 | ||||
-rw-r--r-- | xmlreader/source/xmlreader.cxx | 14 |
11 files changed, 128 insertions, 52 deletions
diff --git a/include/xmlreader/xmlreader.hxx b/include/xmlreader/xmlreader.hxx index e895d8dcbea8..4ffc84e749fd 100644 --- a/include/xmlreader/xmlreader.hxx +++ b/include/xmlreader/xmlreader.hxx @@ -39,6 +39,8 @@ namespace xmlreader { class OOO_DLLPUBLIC_XMLREADER XmlReader: private boost::noncopyable { public: + XmlReader(char const *sStr, size_t nLength); + explicit XmlReader(OUString const & fileUrl) SAL_THROW(( com::sun::star::container::NoSuchElementException, diff --git a/scp2/inc/macros.inc b/scp2/inc/macros.inc index 2f605a9b611d..d95c364bbe38 100755 --- a/scp2/inc/macros.inc +++ b/scp2/inc/macros.inc @@ -481,12 +481,12 @@ End #include <langmacros.inc> -#define UI_FILELIST_ALL_LANG(name, file, ext) \ +#define UI_FILELIST_ALL_LANG(name, file) \ File CONCAT3(gid_File_Share_Config_Sofficecfg_uiconfig_, name, _Lang) \ TXT_FILE_BODY; \ - Styles = (FILELIST); \ - Dir = FILELIST_DIR; \ - EXTRA_ALL_LANG_BUT_EN_US(file, ext); \ + Styles = (PACKED); \ + Dir = gid_Dir_Share_Config_Sofficecfg; \ + UI_ALL_LANG_BUT_EN_US(file); \ End #define URE_PRIVATE_LIB(id,name) \ diff --git a/scp2/macros/macro.pl b/scp2/macros/macro.pl index 3ebeabeeea76..3e7e415fe2a9 100644 --- a/scp2/macros/macro.pl +++ b/scp2/macros/macro.pl @@ -50,6 +50,7 @@ write_DIR_ISOLANGUAGE_ALL_LANG(); write_DIR_ISOLANGUAGE_ALL_LANG_LPROJ(); write_EXTRA_ALL_LANG(); write_EXTRA_ALL_LANG_BUT_EN_US(); +write_UI_ALL_LANG_BUT_EN_US(); write_EXTRA_ALL_GOOD_HELP_LOCALIZATIONS_LANG(); write_RESFILE_ALL_LANG(); write_README_ALL_LANG(); @@ -166,6 +167,21 @@ sub write_EXTRA_ALL_LANG_BUT_EN_US print OUTFILE "\n\n"; } +sub write_UI_ALL_LANG_BUT_EN_US +{ + print OUTFILE "#define UI_ALL_LANG_BUT_EN_US(name) "; + my $first = 1; + foreach $lang (@completelangiso) { + if ($lang ne "en-US") { + print OUTFILE "; " unless $first; + $first = 0; + print OUTFILE + "\\\n\tName ($lang) = STRING(CONCAT2(name,/ui/res/$lang.zip))"; + } + } + print OUTFILE "\n\n"; +} + sub write_EXTRA_ALL_GOOD_HELP_LOCALIZATIONS_LANG { my $first = 1; diff --git a/scp2/source/ooo/file_library_ooo.scp b/scp2/source/ooo/file_library_ooo.scp index 40b4e75dce25..9c5050190b0d 100644 --- a/scp2/source/ooo/file_library_ooo.scp +++ b/scp2/source/ooo/file_library_ooo.scp @@ -275,7 +275,7 @@ SPECIAL_LIB_FILE(gid_File_Lib_Sqlite3,sqlite3) #else #if !defined(MACOSX) File gid_File_Lib_Sqlite3 - Name = "sqlite/" SPECIAL_NAME(sqlite3); + Name = SPECIAL_NAME(sqlite3); PACKED_LIB_FILE_BODY; End #endif //!defined(MACOSX) diff --git a/scp2/source/ooo/file_ooo.scp b/scp2/source/ooo/file_ooo.scp index 965c89fa9709..ab2cfe4c2c7c 100644 --- a/scp2/source/ooo/file_ooo.scp +++ b/scp2/source/ooo/file_ooo.scp @@ -607,31 +607,31 @@ UI_FILELIST(uui, "UIConfig/uui.filelist") UI_FILELIST(vcl, "UIConfig/vcl.filelist") UI_FILELIST(xmlsec, "UIConfig/xmlsec.filelist") -UI_FILELIST_ALL_LANG(basicide, UIConfig/modules/BasicIDE, filelist) -UI_FILELIST_ALL_LANG(cui, UIConfig/cui, filelist) +UI_FILELIST_ALL_LANG(basicide, modules/BasicIDE) +UI_FILELIST_ALL_LANG(cui, cui) #ifdef DBCONNECTIVITY -UI_FILELIST_ALL_LANG(dbaccess, UIConfig/dbaccess, filelist) -#endif -UI_FILELIST_ALL_LANG(desktop, UIConfig/desktop, filelist) -UI_FILELIST_ALL_LANG(filter, UIConfig/filter, filelist) -UI_FILELIST_ALL_LANG(scalc, UIConfig/modules/scalc, filelist) -UI_FILELIST_ALL_LANG(schart, UIConfig/modules/schart, filelist) -UI_FILELIST_ALL_LANG(sdraw, UIConfig/modules/sdraw, filelist) -UI_FILELIST_ALL_LANG(sfx, UIConfig/sfx, filelist) -UI_FILELIST_ALL_LANG(simpress, UIConfig/modules/simpress, filelist) -UI_FILELIST_ALL_LANG(smath, UIConfig/modules/smath, filelist) +UI_FILELIST_ALL_LANG(dbaccess, dbaccess) +#endif +UI_FILELIST_ALL_LANG(desktop, desktop) +UI_FILELIST_ALL_LANG(filter, filter) +UI_FILELIST_ALL_LANG(scalc, modules/scalc) +UI_FILELIST_ALL_LANG(schart, modules/schart) +UI_FILELIST_ALL_LANG(sdraw, modules/sdraw) +UI_FILELIST_ALL_LANG(sfx, sfx) +UI_FILELIST_ALL_LANG(simpress, modules/simpress) +UI_FILELIST_ALL_LANG(smath, modules/smath) #ifdef GUIBASE_UNX -UI_FILELIST_ALL_LANG(spa, UIConfig/spa, filelist) +UI_FILELIST_ALL_LANG(spa, spa) #endif -UI_FILELIST_ALL_LANG(svt, UIConfig/svt, filelist) -UI_FILELIST_ALL_LANG(svx, UIConfig/svx, filelist) -UI_FILELIST_ALL_LANG(swriter, UIConfig/modules/swriter, filelist) +UI_FILELIST_ALL_LANG(svt, svt) +UI_FILELIST_ALL_LANG(svx, svx) +UI_FILELIST_ALL_LANG(swriter, modules/swriter) #ifdef ENABLE_TELEPATHY -UI_FILELIST_ALL_LANG(tubes, UIConfig/tubes, filelist) +UI_FILELIST_ALL_LANG(tubes, tubes) #endif -UI_FILELIST_ALL_LANG(uui, UIConfig/uui, filelist) -UI_FILELIST_ALL_LANG(vcl, UIConfig/vcl, filelist) -UI_FILELIST_ALL_LANG(xmlsec, UIConfig/xmlsec, filelist) +UI_FILELIST_ALL_LANG(uui, uui) +UI_FILELIST_ALL_LANG(vcl, vcl) +UI_FILELIST_ALL_LANG(xmlsec, xmlsec) #ifdef WNT diff --git a/scp2/source/ooo/ure.scp b/scp2/source/ooo/ure.scp index 653fb6f8d2df..3e9983bf9d83 100644 --- a/scp2/source/ooo/ure.scp +++ b/scp2/source/ooo/ure.scp @@ -571,7 +571,7 @@ End File gid_File_Misc_ServicesRdb TXT_FILE_BODY; Dir = GID_DIR_URE_SHARE_MISC; - Name = "ure/services.rdb"; + Name = "services.rdb"; Styles = (PACKED); End diff --git a/solenv/bin/modules/installer/scriptitems.pm b/solenv/bin/modules/installer/scriptitems.pm index fe767f71c712..be1123d658cf 100644 --- a/solenv/bin/modules/installer/scriptitems.pm +++ b/solenv/bin/modules/installer/scriptitems.pm @@ -874,7 +874,7 @@ sub get_Destination_Directory_For_Item_From_Directorylist # this is used f elsif ((!( $ispredefinedprogdir )) && (!( $ispredefinedconfigdir ))) { my $directorynameref = get_Directoryname_From_Directorygid($dirsarrayref, $searchdirgid, $onelanguage, $oneitemgid); - $destfilename = $$directorynameref . $installer::globals::separator . $oneitemname; + $destfilename = $$directorynameref . $installer::globals::separator . $oneitem->{'Name'}; } else { diff --git a/solenv/gbuild/UIConfig.mk b/solenv/gbuild/UIConfig.mk index 07e6a13225c1..f8c6e85af290 100644 --- a/solenv/gbuild/UIConfig.mk +++ b/solenv/gbuild/UIConfig.mk @@ -61,17 +61,17 @@ $(call gb_UILocalizeTarget_get_clean_target,%) : # # gb_UILocalizeTarget_UILocalizeTarget target define gb_UILocalizeTarget_UILocalizeTarget -$(call gb_UILocalizeTarget__UILocalizeTarget_impl,$(1),$(wildcard $(foreach lang,$(gb_TRANS_LANGS),$(gb_POLOCATION)/$(lang)/$(patsubst %/,%,$(dir $(1))).po))) +$(call gb_UILocalizeTarget__UILocalizeTarget_impl,$(1),$(2),$(wildcard $(foreach lang,$(gb_TRANS_LANGS),$(gb_POLOCATION)/$(lang)/$(patsubst %/,%,$(dir $(2))).po))) endef # gb_UILocalizeTarget__UILocalizeTarget_impl target pofiles define gb_UILocalizeTarget__UILocalizeTarget_impl -$(call gb_UILocalizeTarget_get_target,$(1)) : POFILES := $(2) -$(call gb_UILocalizeTarget_get_target,$(1)) : UIConfig_FILE := $(SRCDIR)/$(1).ui +$(call gb_UILocalizeTarget_get_target,$(1)) : POFILES := $(3) +$(call gb_UILocalizeTarget_get_target,$(1)) : UIConfig_FILE := $(SRCDIR)/$(2).ui -$(call gb_UILocalizeTarget_get_target,$(1)) : $(2) -$(call gb_UILocalizeTarget_get_target,$(1)) : $(SRCDIR)/$(1).ui +$(call gb_UILocalizeTarget_get_target,$(1)) : $(3) +$(call gb_UILocalizeTarget_get_target,$(1)) : $(SRCDIR)/$(2).ui $(call gb_UILocalizeTarget_get_target,$(1)) :| \ $(dir $(call gb_UILocalizeTarget_get_target,$(1))).dir \ $(call gb_UILocalizeTarget_get_workdir,$(1))/.dir @@ -196,8 +196,8 @@ $(call gb_UIConfig_get_clean_target,%) : ) gb_UIConfig_get_packagename = UIConfig/$(1) -gb_UIConfig_get_packagename_for_lang = UIConfig/$(1)_$(2) gb_UIConfig_get_packagesetname = UIConfig/$(1) +gb_UIConfig_get_zipname_for_lang = UIConfig/$(1)/$(2) # Processes and delivers a set of UI configuration files. # @@ -227,9 +227,8 @@ $(call gb_Postprocess_register_target,AllUIConfigs,UIConfig,$(1)) endef define gb_UIConfig__UIConfig_for_lang -$(call gb_Package_Package_internal,$(call gb_UIConfig_get_packagename_for_lang,$(1),$(2)),$(gb_UILocalizeTarget_WORKDIR)) -$(call gb_UIConfig_get_target,$(1)) : $(call gb_Package_get_target,$(call gb_UIConfig_get_packagename_for_lang,$(1),$(2))) -$(call gb_UIConfig_get_clean_target,$(1)) : $(call gb_Package_get_clean_target,$(call gb_UIConfig_get_packagename_for_lang,$(1),$(2))) +$(call gb_Zip_Zip_internal,$(call gb_UIConfig_get_zipname_for_lang,$(1),$(2)),$(gb_UILocalizeTarget_WORKDIR)/$(1)) +$(call gb_Zip_get_target,$(call gb_UIConfig_get_zipname_for_lang,$(1),$(2))) : $(SRCDIR)/solenv/gbuild/UIConfig.mk endef @@ -260,8 +259,11 @@ endef # # gb_UIConfig__add_uifile_for_lang target file lang define gb_UIConfig__add_uifile_for_lang -$(call gb_UIConfig__package_uifile,$(1),$(call gb_UIConfig_get_packagename_for_lang,$(1),$(3)),res/$(3)/$(notdir $(2)),$(2)/$(3).ui) -$(call gb_Package_SOURCEDIR_$(call gb_UIConfig_get_packagename_for_lang,$(1),$(3)))/$(2)/$(3).ui : $(call gb_UILocalizeTarget_get_target,$(2)) +$(call gb_UIConfig_get_target,$(1)) : $(call gb_Zip_get_target,$(call gb_UIConfig_get_zipname_for_lang,$(1),$(3))) +$(call gb_UIConfig_get_clean_target,$(1)) : $(call gb_Zip_get_clean_target,$(call gb_UIConfig_get_zipname_for_lang,$(1),$(3))) +$(call gb_Zip_add_file,$(call gb_UIConfig_get_zipname_for_lang,$(1),$(3)),$(notdir $(2))/$(3).ui) +$(call gb_Zip_add_dependency,$(call gb_UIConfig_get_zipname_for_lang,$(1),$(3)),$(call gb_UILocalizeTarget_get_target,$(1)/$(notdir $(2)))) +$(call gb_Zip_set_install_name,$(call gb_UIConfig_get_zipname_for_lang,$(1),$(3)),$(INSTROOT)/$(gb_UIConfig_INSTDIR)/$(1)/ui/res/$(3).zip) endef @@ -278,9 +280,9 @@ endef # gb_UIConfig__add_translations_impl target uifile langs define gb_UIConfig__add_translations_impl -$(call gb_UILocalizeTarget_UILocalizeTarget,$(2)) -$(call gb_UIConfig_get_target,$(1)) : $(call gb_UILocalizeTarget_get_target,$(2)) -$(call gb_UIConfig_get_clean_target,$(1)) : $(call gb_UILocalizeTarget_get_clean_target,$(2)) +$(call gb_UILocalizeTarget_UILocalizeTarget,$(1)/$(notdir $(2)),$(2)) +$(call gb_UIConfig_get_target,$(1)) : $(call gb_UILocalizeTarget_get_target,$(1)/$(notdir $(2))) +$(call gb_UIConfig_get_clean_target,$(1)) : $(call gb_UILocalizeTarget_get_clean_target,$(1)/$(notdir $(2))) $(foreach lang,$(3),$(call gb_UIConfig__add_uifile_for_real_lang,$(1),$(2),$(lang))) endef diff --git a/solenv/gbuild/Zip.mk b/solenv/gbuild/Zip.mk index ae21f7f4cd7e..a675766bb10b 100644 --- a/solenv/gbuild/Zip.mk +++ b/solenv/gbuild/Zip.mk @@ -28,25 +28,33 @@ $(call gb_Zip_get_clean_target,%) : $(call gb_Output_announce,$*,$(false),ZIP,3) $(call gb_Helper_abbreviate_dirs,\ $(if $(CLEAR_LOCATION),rm -rf $(gb_Package_Location_$*) &&) \ + $(if $(INSTALL_NAME),rm -f $(INSTALL_NAME) &&) \ rm -f $(call gb_Zip_get_target,$*) && \ rm -f $(call gb_Zip__get_preparation_target,$*)) +$(dir $(call gb_Zip_get_target,%)).dir : + $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@)) + +$(dir $(call gb_Zip_get_target,%))%/.dir : + $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@)) + # rule to create zip package in workdir # --filesync makes sure that all files in the zip package will be removed that no longer are in $(FILES) $(call gb_Zip_get_target,%) : $(call gb_Output_announce,$*,$(true),ZIP,3) - $(call gb_Helper_abbreviate_dirs,\ + $(if $(FILES),$(call gb_Helper_abbreviate_dirs,\ RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),500,\ $(FILES)) && \ - mkdir -p $(dir $(call gb_Zip_get_target,$*)) && \ cd $(LOCATION) && cat $${RESPONSEFILE} | tr "[:space:]" "\n" | $(gb_Zip_ZIPCOMMAND) -@rX --filesync --must-match $(call gb_Zip_get_target,$*) && \ - rm -f $${RESPONSEFILE} ) + rm -f $${RESPONSEFILE} && \ + touch $@ \ + $(if $(INSTALL_NAME),&& cp $(call gb_Zip_get_target,$*) $(INSTALL_NAME)) \ + )) # the preparation target is here to ensure proper ordering of actions in cases # when we want to, e.g., create a zip from files created by a custom target $(call gb_Zip__get_preparation_target,%) : - $(call gb_Helper_abbreviate_dirs,\ - mkdir -p $(dir $@) && touch $@) + touch $@ # clear file list, set location (zipping uses relative paths) # register target and clean target @@ -57,8 +65,12 @@ $(call gb_Zip__get_preparation_target,%) : # the location can't be stored in a scoped variable as it is needed in the add_file macro (see rule above) define gb_Zip_Zip_internal_nodeliver $(call gb_Zip_get_target,$(1)) : FILES := +$(call gb_Zip_get_target,$(1)) : INSTALL_NAME := $(call gb_Zip_get_target,$(1)) : LOCATION := $(2) +$(call gb_Zip_get_target,$(1)) :| $(dir $(call gb_Zip_get_target,$(1))).dir +$(call gb_Zip__get_preparation_target,$(1)) :| $(dir $(call gb_Zip__get_preparation_target,$(1))).dir $(call gb_Zip_get_clean_target,$(1)) : CLEAR_LOCATION := +$(call gb_Zip_get_clean_target,$(1)) : INSTALL_NAME := $(eval gb_Package_Location_$(1) := $(2)) endef @@ -118,6 +130,13 @@ $(call gb_Zip_get_target,$(1)) : gb_Zip_ZIPCOMMAND += $(2) endef +define gb_Zip_set_install_name +$(call gb_Zip_get_target,$(1)) : INSTALL_NAME := $(2) +$(call gb_Zip_get_target,$(1)) :| $(dir $(2)).dir +$(call gb_Zip_get_clean_target,$(1)) : INSTALL_NAME := $(2) + +endef + define gb_Zip_use_unpacked $(call gb_Zip__get_preparation_target,$(1)) \ :| $(call gb_UnpackedTarball_get_final_target,$(2)) diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index e2f306dbf780..577eb8609398 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -7,6 +7,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <com/sun/star/packages/zip/ZipFileAccess.hpp> + +#include <comphelper/processfactory.hxx> #include <osl/module.hxx> #include <sal/log.hxx> #include <unotools/configmgr.hxx> @@ -98,24 +101,44 @@ void VclBuilder::loadTranslations(const LanguageTag &rLanguageTag, const OUStrin aTransBuf.append('.'); nLastSlash = 0; } - aTransBuf.append("/res/").append(rLanguageTag.getLanguage()); + aTransBuf.append("/res/"); + OUString sLang(rLanguageTag.getLanguage()); switch (i) { case 0: - aTransBuf.append('-').append(rLanguageTag.getCountry()); + sLang = sLang + "-" + rLanguageTag.getCountry(); break; default: break; } + aTransBuf.append(sLang); + aTransBuf.append(".zip"); sal_Int32 nEndName = rUri.lastIndexOf('.'); if (nEndName == -1) nEndName = rUri.getLength(); - aTransBuf.append(rUri.copy(nLastSlash, nEndName-nLastSlash)); - - OUString sTransUri = aTransBuf.makeStringAndClear(); + OUString sZippedFile(rUri.copy(nLastSlash + 1, nEndName - nLastSlash - 1) + "/" + sLang + ".ui"); try { - xmlreader::XmlReader reader(sTransUri); + uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = + packages::zip::ZipFileAccess::createWithURL( + comphelper::getProcessComponentContext(), aTransBuf.makeStringAndClear()); + if (!xNameAccess.is()) + continue; + uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName(sZippedFile), uno::UNO_QUERY); + if (!xInputStream.is()) + continue; + OStringBuffer sStr; + for (;;) + { + sal_Int32 const size = 2048; + css::uno::Sequence< sal_Int8 > data(size); + sal_Int32 n = xInputStream->readBytes(data, size); + sStr.append(reinterpret_cast<const sal_Char *>(data.getConstArray()), n); + if (n < size) + break; + } + + xmlreader::XmlReader reader(const_cast<char *>(sStr.getStr()), sStr.getLength()); handleTranslations(reader); break; } diff --git a/xmlreader/source/xmlreader.cxx b/xmlreader/source/xmlreader.cxx index 13e278091f86..3e1d24e24530 100644 --- a/xmlreader/source/xmlreader.cxx +++ b/xmlreader/source/xmlreader.cxx @@ -54,6 +54,18 @@ bool isSpace(char c) { } +XmlReader::XmlReader(char const *sStr, size_t nLength) + : fileUrl_("stream") + , fileHandle_(0) +{ + namespaceIris_.push_back(Span("http://www.w3.org/XML/1998/namespace")); + namespaces_.push_back(NamespaceData(Span("xml"), NAMESPACE_XML)); + pos_ = sStr; + end_ = pos_ + nLength; + state_ = STATE_CONTENT; + firstAttribute_ = true; +} + XmlReader::XmlReader(OUString const & fileUrl) SAL_THROW(( css::container::NoSuchElementException, css::uno::RuntimeException)): @@ -99,6 +111,8 @@ XmlReader::XmlReader(OUString const & fileUrl) } XmlReader::~XmlReader() { + if (!fileHandle_) + return; oslFileError e = osl_unmapMappedFile(fileHandle_, fileAddress_, fileSize_); if (e != osl_File_E_None) { SAL_WARN( |