[Libreoffice-commits] .: Branch 'feature/cmclayouttrans' - 5 commits - cui/Module_cui.mk cui/Package_uiconfig.mk cui/UI_cui.mk l10ntools/inc l10ntools/source solenv/gbuild sw/Module_sw.mk sw/Package_uiconfig.mk sw/UI_sw.mk sw/UI_swriter.mk

Caolán McNamara caolan at kemper.freedesktop.org
Tue Aug 7 04:11:29 PDT 2012


 cui/Module_cui.mk                |    2 
 cui/Package_uiconfig.mk          |   32 -----
 cui/UI_cui.mk                    |   16 ++
 l10ntools/inc/export.hxx         |    6 -
 l10ntools/source/merge.cxx       |    6 -
 l10ntools/source/uimerge.cxx     |  120 ++++++++++++++++-----
 solenv/gbuild/TargetLocations.mk |    6 +
 solenv/gbuild/UI.mk              |  215 +++++++++++++++++++++++++++++++++++++++
 solenv/gbuild/gbuild.mk          |    1 
 sw/Module_sw.mk                  |    2 
 sw/Package_uiconfig.mk           |    5 
 sw/UI_sw.mk                      |   18 +++
 sw/UI_swriter.mk                 |   16 ++
 13 files changed, 374 insertions(+), 71 deletions(-)

New commits:
commit 1404c6d3ed47779a40a9a6f60de9dd084b8df8db
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Aug 7 12:08:37 2012 +0100

    merge tool not filtering on requested input file name
    
    isFileEmpty = !sFileNormalized.isEmpty doesn't make sense to me
    from commit 8b8162e0 I imagine it should be
    isFileEmpty = sFileNormalized.isEmpty
    which gives me the expected result of filtering out the files
    I don't care about
    
    Change-Id: Ic0967ac382a1fb912e7ad98d2fc5dcb626d4ff87

diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx
index 0dd7eb7..efe338b 100644
--- a/l10ntools/source/merge.cxx
+++ b/l10ntools/source/merge.cxx
@@ -151,7 +151,7 @@ MergeDataFile::MergeDataFile(
     std::ifstream aInputStream(rFileName.getStr());
     const ::rtl::OString sHACK(RTL_CONSTASCII_STRINGPARAM("HACK"));
     const ::rtl::OString sFileNormalized(lcl_NormalizeFilename(rFile));
-    const bool isFileEmpty = !sFileNormalized.isEmpty();
+    const bool isFileEmpty = sFileNormalized.isEmpty();
 
     if (!aInputStream.is_open())
     {
@@ -166,7 +166,7 @@ MergeDataFile::MergeDataFile(
         sal_Int32 n = 0;
         // Skip all wrong filenames
         const ::rtl::OString filename = lcl_NormalizeFilename(sLine.getToken(1, '\t', n)); // token 1
-        if(isFileEmpty || sFileNormalized.equals("") || (!isFileEmpty && filename.equals(sFileNormalized)) )
+        if (isFileEmpty || (!isFileEmpty && filename.equals(sFileNormalized)) )
         {
             const rtl::OString sTYP = sLine.getToken( 1, '\t', n ); // token 3
             const rtl::OString sGID = sLine.getToken( 0, '\t', n ); // token 4
commit 0fd26f6cc2a97aae802551b8928877791c2166ef
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Aug 7 12:08:08 2012 +0100

    merge .ui translations back to runtime files
    
    Change-Id: Ia01ef21441220293343370df7d865c7eb889bc84

diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx
index bf1809b..94f0e6e 100644
--- a/l10ntools/inc/export.hxx
+++ b/l10ntools/inc/export.hxx
@@ -405,8 +405,7 @@ class MergeDataFile;
 
 class MergeData
 {
-friend class MergeDataFile;
-private:
+public:
     rtl::OString sTyp;
     rtl::OString sGID;
     rtl::OString sLID;
@@ -452,7 +451,8 @@ class MergeDataFile
         ~MergeDataFile();
 
 
-        std::vector<rtl::OString> GetLanguages();
+        std::vector<rtl::OString> GetLanguages() const;
+        const MergeDataHashMap& getMap() const { return aMap; }
 
         PFormEntrys *GetPFormEntrys( ResData *pResData );
         PFormEntrys *GetPFormEntrysCaseSensitive( ResData *pResData );
diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx
index 1388460..0dd7eb7 100644
--- a/l10ntools/source/merge.cxx
+++ b/l10ntools/source/merge.cxx
@@ -195,7 +195,7 @@ MergeDataFile::~MergeDataFile()
         delete aI->second;
 }
 
-std::vector<rtl::OString> MergeDataFile::GetLanguages()
+std::vector<rtl::OString> MergeDataFile::GetLanguages() const
 {
     return std::vector<rtl::OString>(aLanguageSet.begin(),aLanguageSet.end());
 }
diff --git a/l10ntools/source/uimerge.cxx b/l10ntools/source/uimerge.cxx
index d84eaa6..cd7443e 100644
--- a/l10ntools/source/uimerge.cxx
+++ b/l10ntools/source/uimerge.cxx
@@ -118,33 +118,8 @@ void GetOutputFile( int argc, char* argv[])
     }
 }
 
-SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
+int extractTranslations()
 {
-    int nRetValue = 0;
-    xsltStylesheetPtr stylesheet = 0;
-
-    GetOutputFile( argc, argv );
-
-    if (sOutputFile.isEmpty())
-    {
-        fprintf( stdout, "Syntax: UIEX[-p Prj][-r PrjRoot]-i FileIn [-o FileOut][-m DataBase][-e][-L l1,l2,...]\n" );
-        fprintf( stdout, " Prj:      Project\n" );
-        fprintf( stdout, " PrjRoot:  Path to project root (..\\.. etc.)\n" );
-        fprintf( stdout, " FileIn:   Source files (*.src)\n" );
-        fprintf( stdout, " FileOut:  Destination file (*.*)\n" );
-        fprintf( stdout, " DataBase: Mergedata (*.sdf)\n" );
-        fprintf( stdout, " -e: Disable writing errorlog\n" );
-        fprintf( stdout, " -b: Break when Token \"HelpText\" found in source\n" );
-        fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US,es...)\n" );
-        return 1;
-    }
-
-    if (Export::sLanguages != "en-US")
-    {
-        fprintf(stderr, "can only extract en-US\n");
-        return 1;
-    }
-
     FILE *pOutFile = fopen(sOutputFile.getStr(), "w");
     if (!pOutFile)
     {
@@ -156,7 +131,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
 
     rtl::OString sStyleSheet = rtl::OString(getenv("SRC_ROOT"))  + rtl::OString("/solenv/bin/uilangfilter.xslt");
 
-    stylesheet = xsltParseStylesheetFile ((const xmlChar *)sStyleSheet.getStr());
+    xsltStylesheetPtr stylesheet = xsltParseStylesheetFile ((const xmlChar *)sStyleSheet.getStr());
 
     xmlDocPtr doc = xmlParseFile(sInputFileName.getStr());
 
@@ -188,6 +163,97 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
 
     fclose(pOutFile);
 
+    return 0;
+}
+
+
+bool Merge(
+    const rtl::OString &rSDFFile,
+    const rtl::OString &rSourceFile,
+    const rtl::OString &rDestinationFile)
+{
+    Export::InitLanguages( true );
+    std::ofstream aDestination(
+        rDestinationFile.getStr(), std::ios_base::out | std::ios_base::trunc);
+    if (!aDestination.is_open()) {
+        return false;
+    }
+
+    aDestination << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+    aDestination << "<t>\n";
+
+    MergeDataFile aMergeDataFile( rSDFFile, rSourceFile, sal_False );
+    rtl::OString sTmp( Export::sLanguages );
+    if( sTmp.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("ALL")) )
+        Export::SetLanguages( aMergeDataFile.GetLanguages() );
+
+    std::vector<rtl::OString> aLanguages = Export::GetLanguages();
+
+    const MergeDataHashMap& rMap = aMergeDataFile.getMap();
+
+    for(size_t n = 0; n < aLanguages.size(); ++n)
+    {
+        rtl::OString sCur = aLanguages[ n ];
+        if (sCur.isEmpty() || sCur.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("en-US")))
+            continue;
+        for (MergeDataHashMap::const_iterator aI = rMap.begin(), aEnd = rMap.end(); aI != aEnd; ++aI)
+        {
+            if (aI->second->sGID.isEmpty())
+                continue;
+
+            PFormEntrys* pFoo = aI->second->GetPFormEntries();
+            rtl::OString sOut;
+            pFoo->GetText( sOut, STRING_TYP_TEXT, sCur);
+
+            if (sOut.isEmpty())
+                continue;
+
+            aDestination << " <e "
+                << "g=\"" << aI->second->sGID.getStr() << "\" "
+                << "i=\"" << aI->second->sLID.getStr() << "\">"
+                << sOut.getStr() << "</e>\n";
+        }
+    }
+
+    aDestination << "</t>";
+    aDestination.close();
+    return sal_True;
+}
+
+SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
+{
+    int nRetValue = 0;
+
+    GetOutputFile( argc, argv );
+
+    if (sOutputFile.isEmpty())
+    {
+        fprintf( stdout, "Syntax: UIEX[-p Prj][-r PrjRoot]-i FileIn [-o FileOut][-m DataBase][-e][-L l1,l2,...]\n" );
+        fprintf( stdout, " Prj:      Project\n" );
+        fprintf( stdout, " PrjRoot:  Path to project root (..\\.. etc.)\n" );
+        fprintf( stdout, " FileIn:   Source files (*.src)\n" );
+        fprintf( stdout, " FileOut:  Destination file (*.*)\n" );
+        fprintf( stdout, " DataBase: Mergedata (*.sdf)\n" );
+        fprintf( stdout, " -e: Disable writing errorlog\n" );
+        fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US,es...)\n" );
+        return 1;
+    }
+
+    if (!bMergeMode)
+    {
+        if (Export::sLanguages != "en-US")
+        {
+            fprintf(stderr, "only en-US can exist in source .ui files\n");
+            nRetValue = 1;
+        }
+        else
+            nRetValue = extractTranslations();
+    }
+    else
+    {
+        Merge(sMergeSrc, sInputFileName, sOutputFile);
+    }
+
     return nRetValue;
 }
 
commit ebe4c82a6551f91c4d3234da02f0f933c5c365d3
Author: David Tardon <dtardon at redhat.com>
Date:   Sat Aug 4 14:37:55 2012 +0200

    use UI gbuild class to package .ui files in sw
    
    Change-Id: I3c6a8d3cbd9fad20506c1deb34d7a65c4fa76bc6

diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 59e2612..eded3d5 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -37,6 +37,8 @@ $(eval $(call gb_Module_add_targets,sw,\
     Package_misc \
     Package_uiconfig \
     Package_xml \
+	UI_sw \
+	UI_swriter \
 ))
 
 ifneq ($(DISABLE_SCRIPTING),TRUE)
diff --git a/sw/Package_uiconfig.mk b/sw/Package_uiconfig.mk
index 414630d..150b3ae 100644
--- a/sw/Package_uiconfig.mk
+++ b/sw/Package_uiconfig.mk
@@ -28,11 +28,6 @@
 
 $(eval $(call gb_Package_Package,sw_uiconfig,$(SRCDIR)/sw/uiconfig))
 
-$(eval $(call gb_Package_add_file,sw_uiconfig,xml/uiconfig/modules/swriter/ui/titlepage.ui,swriter/ui/titlepage.ui))
-$(eval $(call gb_Package_add_file,sw_uiconfig,xml/uiconfig/sw/ui/20705.ui,sw/ui/20705.ui))
-$(eval $(call gb_Package_add_file,sw_uiconfig,xml/uiconfig/sw/ui/20872.ui,sw/ui/20872.ui))
-$(eval $(call gb_Package_add_file,sw_uiconfig,xml/uiconfig/sw/ui/20876.ui,sw/ui/20876.ui))
-
 $(eval $(call gb_Package_add_file,sw_uiconfig,xml/uiconfig/modules/sglobal/menubar/menubar.xml,sglobal/menubar/menubar.xml))
 $(eval $(call gb_Package_add_file,sw_uiconfig,xml/uiconfig/modules/sglobal/statusbar/statusbar.xml,sglobal/statusbar/statusbar.xml))
 $(eval $(call gb_Package_add_file,sw_uiconfig,xml/uiconfig/modules/sglobal/toolbar/alignmentbar.xml,sglobal/toolbar/alignmentbar.xml))
diff --git a/sw/UI_sw.mk b/sw/UI_sw.mk
new file mode 100644
index 0000000..789da4f
--- /dev/null
+++ b/sw/UI_sw.mk
@@ -0,0 +1,18 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_UI_UI,sw))
+
+$(eval $(call gb_UI_add_uifiles,sw,\
+	sw/uiconfig/sw/ui/20705 \
+	sw/uiconfig/sw/ui/20872 \
+	sw/uiconfig/sw/ui/20876 \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/UI_swriter.mk b/sw/UI_swriter.mk
new file mode 100644
index 0000000..f1419eb
--- /dev/null
+++ b/sw/UI_swriter.mk
@@ -0,0 +1,16 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_UI_UI,modules/swriter))
+
+$(eval $(call gb_UI_add_uifiles,modules/swriter,\
+	sw/uiconfig/swriter/ui/titlepage \
+))
+
+# vim: set noet sw=4 ts=4:
commit 5bb3b5bf53777950a494082e8ef3cb7134846ee5
Author: David Tardon <dtardon at redhat.com>
Date:   Tue Aug 7 10:53:02 2012 +0100

    use UI gbuild class to package .ui files in cui
    
    Change-Id: I4ddeacdbf2bbe86d0351a2d6027e2d608b378731

diff --git a/cui/Module_cui.mk b/cui/Module_cui.mk
index 6ed6ba3..895013e 100644
--- a/cui/Module_cui.mk
+++ b/cui/Module_cui.mk
@@ -30,7 +30,7 @@ $(eval $(call gb_Module_Module,cui))
 $(eval $(call gb_Module_add_targets,cui,\
 	AllLangResTarget_cui \
 	Library_cui \
-	Package_uiconfig \
+	UI_cui \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/cui/Package_uiconfig.mk b/cui/Package_uiconfig.mk
deleted file mode 100644
index 524a542..0000000
--- a/cui/Package_uiconfig.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-# Version: MPL 1.1 / GPLv3+ / LGPLv3+
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License or as specified alternatively below. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# Major Contributor(s):
-# Copyright (C) 2012 Red Hat, Inc., Caolán McNamara <caolanm at redhat.com>
-#  (initial developer)
-#
-# All Rights Reserved.
-#
-# For minor contributions see the git repository.
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
-# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
-# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
-# instead of those above.
-
-$(eval $(call gb_Package_Package,cui_uiconfig,$(SRCDIR)/cui/uiconfig))
-
-$(eval $(call gb_Package_add_file,cui_uiconfig,xml/uiconfig/cui/ui/10000.ui,ui/10000.ui))
-
-# vim: set noet sw=4 ts=4:
diff --git a/cui/UI_cui.mk b/cui/UI_cui.mk
new file mode 100644
index 0000000..a98e905
--- /dev/null
+++ b/cui/UI_cui.mk
@@ -0,0 +1,16 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_UI_UI,cui))
+
+$(eval $(call gb_UI_add_uifiles,cui,\
+	cui/uiconfig/ui/10000 \
+))
+
+# vim: set noet sw=4 ts=4:
commit c871a55dee877b839a81d3219b2ff6a3a71bb291
Author: David Tardon <dtardon at redhat.com>
Date:   Sat Aug 4 14:36:17 2012 +0200

    add support for .ui files to gbuild
    
    Change-Id: I2817a6e354e13f5261825701bdbc836e2da347aa

diff --git a/solenv/gbuild/TargetLocations.mk b/solenv/gbuild/TargetLocations.mk
index 60290af..24f8f17 100644
--- a/solenv/gbuild/TargetLocations.mk
+++ b/solenv/gbuild/TargetLocations.mk
@@ -143,6 +143,9 @@ gb_SrsTarget_get_target = $(WORKDIR)/SrsTarget/$(1).srs
 gb_SrsTemplatePartTarget_get_target = $(WORKDIR)/SrsTemplatePartTarget/$(firstword $(subst /, ,$(1)))/$(subst _tmpl,,$(notdir $(1)))
 gb_SrsTemplateTarget_get_include_dir = $(WORKDIR)/SrsTemplatePartTarget/$(firstword $(subst /, ,$(1)))
 gb_SrsTemplateTarget_get_target = $(WORKDIR)/SrsTemplateTarget/$(1)
+gb_UI_get_target = $(WORKDIR)/UI/$(1).done
+gb_UILocalizeTarget_get_target = $(WORKDIR)/UILocalizeTarget/$(1).ui
+gb_UITarget_get_target = $(WORKDIR)/UITarget/$(1).done
 gb_UnoApiTarget_get_target = $(WORKDIR)/UnoApiTarget/$(1).rdb
 gb_UnoApiHeadersTarget_get_bootstrap_dir = $(WORKDIR)/UnoApiHeadersTarget/$(1)/bootstrap$(2)
 gb_UnoApiHeadersTarget_get_comprehensive_dir = $(WORKDIR)/UnoApiHeadersTarget/$(1)/comprehensive$(2)
@@ -218,6 +221,9 @@ $(eval $(call gb_Helper_make_clean_targets,\
 	CppunitTest \
 	CustomTarget \
 	ExternalLib \
+	UI \
+	UILocalizeTarget \
+	UITarget \
 	UnoApiHeadersTarget \
 	UnoApiTarget \
 	WinResTarget \
diff --git a/solenv/gbuild/UI.mk b/solenv/gbuild/UI.mk
new file mode 100644
index 0000000..509a087
--- /dev/null
+++ b/solenv/gbuild/UI.mk
@@ -0,0 +1,215 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+# class UILocalizeTarget
+
+gb_UILocalizeTarget_WORKDIR := $(WORKDIR)/UILocalizeTarget
+
+gb_UILocalizeTarget_TARGET := $(call gb_Executable_get_target_for_build,uiex)
+gb_UILocalizeTarget_COMMAND := $(gb_Helper_set_ldpath) $(gb_UILocalizeTarget_TARGET)
+
+define gb_UILocalizeTarget__command
+$(call gb_Output_announce,$(2),$(true),UIX,1)
+$(call gb_Helper_abbreviate_dirs,\
+	$(gb_UILocalizeTarget_COMMAND) \
+		-i $(UI_FILE) \
+		-o $(1) \
+		-l $(UI_LANG) \
+		-m $(SDF) \
+)
+endef
+
+$(dir $(call gb_UILocalizeTarget_get_target,%))%/.dir :
+	$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
+
+$(call gb_UILocalizeTarget_get_target,%) : $(gb_UILocalizeTarget_TARGET)
+	$(call gb_UILocalizeTarget__command,$@,$*)
+
+.PHONY : $(call gb_UILocalizeTarget_get_clean_target,%)
+$(call gb_UILocalizeTarget_get_clean_target,%) :
+	$(call gb_Output_announce,$*,$(false),UIX,1)
+	$(call gb_Helper_abbreviate_dirs,\
+		rm -f $(call gb_UILocalizeTarget_get_target,$*) \
+	)
+
+# Translates one .ui file
+#
+# gb_UILocalizeTarget_UILocalizeTarget target source lang
+define gb_UILocalizeTarget_UILocalizeTarget
+$(call gb_UILocalizeTarget_get_target,$(1)) : SDF := $(gb_SDFLOCATION)/$(dir $(2))localize.sdf
+$(call gb_UILocalizeTarget_get_target,$(1)) : UI_FILE := $(SRCDIR)/$(2).ui
+$(call gb_UILocalizeTarget_get_target,$(1)) : UI_LANG := $(3)
+
+$(call gb_UILocalizeTarget_get_target,$(1)) : $$(SDF)
+$(call gb_UILocalizeTarget_get_target,$(1)) : $$(UI_FILE)
+$(call gb_UILocalizeTarget_get_target,$(1)) :| $(dir $(call gb_UILocalizeTarget_get_target,$(1))).dir
+
+endef
+
+# class UITarget
+
+# en-US is a special case
+gb_UITarget_LANGS := $(filter-out en-US,$(gb_WITH_LANG))
+
+gb_UITarget_LOCALIZED_DIR := $(gb_UILocalizeTarget_WORKDIR)
+
+gb_UITarget_get_uifile_for_lang = $(subst $(gb_UITarget_LOCALIZED_DIR)/,,$(call gb_UILocalizeTarget_get_target,$(1)/$(2)))
+
+$(dir $(call gb_UITarget_get_target,%)).dir :
+	$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
+
+$(dir $(call gb_UITarget_get_target,%))%/.dir :
+	$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
+
+$(call gb_UITarget_get_target,%) :
+	$(call gb_Output_announce,$*,$(true),UI ,2)
+	$(call gb_Helper_abbreviate_dirs,\
+		touch $@ \
+	)
+
+.PHONY : $(call gb_UITarget_get_clean_target,%)
+$(call gb_UITarget_get_clean_target,%) :
+	$(call gb_Output_announce,$*,$(false),UI ,2)
+	$(call gb_Helper_abbreviate_dirs,\
+		rm -f $(call gb_UITarget_get_target,$*) \
+	)
+
+# Translates a set of .ui files
+#
+# gb_UITarget_UITarget modulename
+define gb_UITarget_UITarget
+$(call gb_UITarget_get_target,$(1)) :| $(dir $(call gb_UITarget_get_target,$(1))).dir
+
+endef
+
+define gb_UITarget__add_uifile_for_lang
+$(call gb_UILocalizeTarget_UILocalizeTarget,$(2)/$(3),$(2),$(3))
+$(call gb_UITarget_get_target,$(1)) : $(call gb_UILocalizeTarget_get_target,$(2)/$(3))
+$(call gb_UITarget_get_clean_target,$(1)) : $(call gb_UILocalizeTarget_get_clean_target,$(2)/$(3))
+
+endef
+
+# Adds an .ui file for translation
+#
+# gb_UITarget_add_uifile target uifile
+define gb_UITarget_add_uifile
+$(foreach lang,$(gb_UITarget_LANGS),$(call gb_UITarget__add_uifile_for_lang,$(1),$(2),$(lang)))
+
+endef
+
+# Adds multiple .ui files for translation
+#
+# gb_UITarget_add_uifiles target uifile(s)
+define gb_UITarget_add_uifiles
+$(foreach uifile,$(2),$(call gb_UITarget_add_uifile,$(1),$(uifile)))
+
+endef
+
+# class UI
+
+# Handles UI description files (suffix .ui) for the new layouting mechanism.
+
+gb_UI_LANGS := $(gb_UITarget_LANGS)
+
+$(dir $(call gb_UI_get_target,%)).dir :
+	$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
+
+$(dir $(call gb_UI_get_target,%))%/.dir :
+	$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
+
+$(call gb_UI_get_target,%) :
+	$(call gb_Helper_abbreviate_dirs,\
+		touch $@ \
+	)
+
+.PHONY : $(call gb_UI_get_clean_target,%)
+$(call gb_UI_get_clean_target,%) :
+	$(call gb_Helper_abbreviate_dirs,\
+		rm -f $(call gb_UI_get_target,$*) \
+	)
+
+# Translates and delivers a set of .ui files
+#
+# gb_UI_UI modulename
+define gb_UI_UI
+$(call gb_Package_Package_internal,$(1)_ui,$(SRCDIR))
+$(call gb_UI_get_target,$(1)) :| $(dir $(call gb_UI_get_target,$(1))).dir
+$(call gb_UI_get_target,$(1)) :| $(call gb_Package_get_target,$(1)_ui)
+$(call gb_UI_get_clean_target,$(1)) : $(call gb_Package_get_clean_target,$(1)_ui)
+
+ifneq ($(gb_UI_LANGS),)
+$(call gb_UITarget_UITarget,$(1))
+$(call gb_Package_Package_internal,$(1)_ui_localized,$(gb_UITarget_LOCALIZED_DIR))
+$(call gb_UI_get_target,$(1)) : $(call gb_UITarget_get_target,$(1))
+$(call gb_UI_get_target,$(1)) :| $(call gb_Package_get_target,$(1)_ui_localized)
+$(call gb_UI_get_clean_target,$(1)) : $(call gb_UITarget_get_clean_target,$(1))
+$(call gb_UI_get_clean_target,$(1)) : $(call gb_Package_get_clean_target,$(1)_ui_localized)
+endif
+
+$$(eval $$(call gb_Module_register_target,$(call gb_UI_get_target,$(1)),$(call gb_UI_get_clean_target,$(1))))
+endef
+
+# gb_UI__get_outdir_filename target file lang?
+gb_UI__get_outdir_filename = xml/uiconfig/$(1)/ui/$(if $(3),res/$(3)/)$(notdir $(2)).ui
+
+# gb_UI__add_uifile target package destfile srcfile lang?
+define gb_UI__package_uifile
+$(call gb_Package_add_file,$(2),$(call gb_UI__get_outdir_filename,$(1),$(3),$(5)),$(4))
+
+endef
+
+# gb_UI__add_uifile_direct target file
+define gb_UI__add_uifile_direct
+$(call gb_UI__package_uifile,$(1),$(1)_ui,$(2),$(2).ui)
+
+endef
+
+# gb_UI__add_uifile_for_lang target file lang
+define gb_UI__add_uifile_for_lang
+$(call gb_UI__package_uifile,$(1),$(1)_ui_localized,$(2),$(call gb_UITarget_get_uifile_for_lang,$(2),$(3)),$(3))
+
+endef
+
+define gb_UI__add_uifile
+$(call gb_UI__add_uifile_direct,$(1),$(2))
+
+ifneq ($(gb_UI_LANGS),)
+$(call gb_UITarget_add_uifile,$(1),$(2))
+$(foreach lang,$(gb_UI_LANGS),$(call gb_UI__add_uifile_for_lang,$(1),$(2),$(lang)))
+endif
+
+endef
+
+# Adds .ui file to the package
+#
+# The file is relative to $(SRCDIR) and without extension.
+#
+# gb_UI_add_uifile target uifile
+define gb_UI_add_uifile
+$(call gb_UI__add_uifile,$(1),$(2))
+
+ifneq ($(gb_UI_LANGS),)
+$(call gb_UITarget_add_uifile,$(1),$(2))
+endif
+
+endef
+
+# Adds multiple .ui files to the package
+#
+# gb_UI_add_uifiles target uifile(s)
+define gb_UI_add_uifiles
+$(foreach uifile,$(2),$(call gb_UI__add_uifile,$(1),$(uifile)))
+
+ifneq ($(gb_UI_LANGS),)
+$(call gb_UITarget_add_uifiles,$(1),$(2))
+endif
+
+endef
+
+# vim: set noet sw=4 ts=4:
diff --git a/solenv/gbuild/gbuild.mk b/solenv/gbuild/gbuild.mk
index a787e14..ea9e1df 100644
--- a/solenv/gbuild/gbuild.mk
+++ b/solenv/gbuild/gbuild.mk
@@ -314,6 +314,7 @@ include $(foreach class, \
 	JavaClassSet \
 	JunitTest \
 	Module \
+	UI \
 	UnoApiTarget \
 	UnoApi \
 	UnoApiMerge \


More information about the Libreoffice-commits mailing list