Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hi Michael, *

I attached the patches that fix bug fdo#32895. I eliminated the baroque
castings and reused the duplicated function as you suggested.

A review and push to the -3-4 branch would be highly appreciated.

Best regards,
  Péter
From 81ccaf9f7d422e17b5c0271ae71156ce5a4c0d4f Mon Sep 17 00:00:00 2001
From: Peter Rabi <prabi@caesar.elte.hu>
Date: Thu, 28 Jul 2011 12:06:00 +0200
Subject: [PATCH] Clean-up of bugfix fdo#32895 for the -3-4 branch

Contributed under license LGPLv3+/MPL.
---
 sfx2/AllLangResTarget_sfx2.mk        |    1 +
 sfx2/Package_inc.mk                  |    1 +
 sfx2/inc/sfx2/doctempl.hxx           |    7 +
 sfx2/inc/sfx2/templatelocnames.hrc   |   81 ++++++++++
 sfx2/source/doc/doctempl.cxx         |   31 ++++-
 sfx2/source/doc/templatelocnames.src |  281 ++++++++++++++++++++++++++++++++++
 6 files changed, 400 insertions(+), 2 deletions(-)
 create mode 100644 sfx2/inc/sfx2/templatelocnames.hrc
 create mode 100644 sfx2/source/doc/templatelocnames.src

diff --git a/sfx2/AllLangResTarget_sfx2.mk b/sfx2/AllLangResTarget_sfx2.mk
index 77691fe..665d53f 100755
--- a/sfx2/AllLangResTarget_sfx2.mk
+++ b/sfx2/AllLangResTarget_sfx2.mk
@@ -75,6 +75,7 @@ $(eval $(call gb_SrsTarget_add_files,sfx/res,\
     sfx2/source/doc/docvor.src \
     sfx2/source/doc/graphhelp.src \
     sfx2/source/doc/new.src \
+    sfx2/source/doc/templatelocnames.src \
     sfx2/source/menu/menu.src \
     sfx2/source/view/view.src \
 ))
diff --git a/sfx2/Package_inc.mk b/sfx2/Package_inc.mk
index 5731762..53b7cf9 100755
--- a/sfx2/Package_inc.mk
+++ b/sfx2/Package_inc.mk
@@ -128,6 +128,7 @@ $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/tabdlg.hxx,sfx2/tabdlg.hxx))
 $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/taskpane.hxx,sfx2/taskpane.hxx))
 $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/tbxctrl.hxx,sfx2/tbxctrl.hxx))
 $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templdlg.hxx,sfx2/templdlg.hxx))
+$(eval $(call 
gb_Package_add_file,sfx2_inc,inc/sfx2/templatelocnames.hrc,sfx2/templatelocnames.hrc))
 $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/titledockwin.hxx,sfx2/titledockwin.hxx))
 $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/tplpitem.hxx,sfx2/tplpitem.hxx))
 $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/unoctitm.hxx,sfx2/unoctitm.hxx))
diff --git a/sfx2/inc/sfx2/doctempl.hxx b/sfx2/inc/sfx2/doctempl.hxx
index 56cadd0..3c48bab 100644
--- a/sfx2/inc/sfx2/doctempl.hxx
+++ b/sfx2/inc/sfx2/doctempl.hxx
@@ -96,6 +96,13 @@ public:
     ::rtl::OUString            GetTemplateTargetURLFromComponent( const ::rtl::OUString& 
aGroupName,
                                                          const ::rtl::OUString& aTitle );
 
+    // Convert a resource string - a template name - to its localised pair
+    // if it exists in templatelocnames.src
+    static ::rtl::OUString ConvertResourceString(int nSourceResIds,
+                            int nDestResIds,
+                            int nCount,
+                            const ::rtl::OUString& rString);
+
     // Speichern als Vorlage hat geklappt -> Aktualisieren
     void                       NewTemplate(sal_uInt16 nRegion,
                                 const String &rLongName,
diff --git a/sfx2/inc/sfx2/templatelocnames.hrc b/sfx2/inc/sfx2/templatelocnames.hrc
new file mode 100644
index 0000000..f8034ed
--- /dev/null
+++ b/sfx2/inc/sfx2/templatelocnames.hrc
@@ -0,0 +1,81 @@
+/*
+ * 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. 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.
+ *
+ * The Initial Developer of the Original Code is
+ *       Péter Rabi <prabi@caesar.elte.hu>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * 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.
+ */
+
+#define NUM_TEMPLATE_NAMES             25
+#define TEMPL_LOC_OFFSET               2190
+
+#define STR_TEMPLATE_NAME1_DEF         (TEMPL_LOC_OFFSET + 1)
+#define STR_TEMPLATE_NAME2_DEF         (TEMPL_LOC_OFFSET + 2)
+#define STR_TEMPLATE_NAME3_DEF         (TEMPL_LOC_OFFSET + 3)
+#define STR_TEMPLATE_NAME4_DEF         (TEMPL_LOC_OFFSET + 4)
+#define STR_TEMPLATE_NAME5_DEF         (TEMPL_LOC_OFFSET + 5)
+#define STR_TEMPLATE_NAME6_DEF         (TEMPL_LOC_OFFSET + 6)
+#define STR_TEMPLATE_NAME7_DEF         (TEMPL_LOC_OFFSET + 7)
+#define STR_TEMPLATE_NAME8_DEF         (TEMPL_LOC_OFFSET + 8)
+#define STR_TEMPLATE_NAME9_DEF         (TEMPL_LOC_OFFSET + 9)
+#define STR_TEMPLATE_NAME10_DEF                (TEMPL_LOC_OFFSET + 10)
+#define STR_TEMPLATE_NAME11_DEF                (TEMPL_LOC_OFFSET + 11)
+#define STR_TEMPLATE_NAME12_DEF                (TEMPL_LOC_OFFSET + 12)
+#define STR_TEMPLATE_NAME13_DEF                (TEMPL_LOC_OFFSET + 13)
+#define STR_TEMPLATE_NAME14_DEF                (TEMPL_LOC_OFFSET + 14)
+#define STR_TEMPLATE_NAME15_DEF                (TEMPL_LOC_OFFSET + 15)
+#define STR_TEMPLATE_NAME16_DEF                (TEMPL_LOC_OFFSET + 16)
+#define STR_TEMPLATE_NAME17_DEF                (TEMPL_LOC_OFFSET + 17)
+#define STR_TEMPLATE_NAME18_DEF                (TEMPL_LOC_OFFSET + 18)
+#define STR_TEMPLATE_NAME19_DEF                (TEMPL_LOC_OFFSET + 19)
+#define STR_TEMPLATE_NAME20_DEF                (TEMPL_LOC_OFFSET + 20)
+#define STR_TEMPLATE_NAME21_DEF                (TEMPL_LOC_OFFSET + 21)
+#define STR_TEMPLATE_NAME22_DEF                (TEMPL_LOC_OFFSET + 22)
+#define STR_TEMPLATE_NAME23_DEF                (TEMPL_LOC_OFFSET + 23)
+#define STR_TEMPLATE_NAME24_DEF                (TEMPL_LOC_OFFSET + 24)
+#define STR_TEMPLATE_NAME25_DEF                (TEMPL_LOC_OFFSET + 25)
+
+#define STR_TEMPLATE_NAME1             (TEMPL_LOC_OFFSET + 51)
+#define STR_TEMPLATE_NAME2             (TEMPL_LOC_OFFSET + 52)
+#define STR_TEMPLATE_NAME3             (TEMPL_LOC_OFFSET + 53)
+#define STR_TEMPLATE_NAME4             (TEMPL_LOC_OFFSET + 54)
+#define STR_TEMPLATE_NAME5             (TEMPL_LOC_OFFSET + 55)
+#define STR_TEMPLATE_NAME6             (TEMPL_LOC_OFFSET + 56)
+#define STR_TEMPLATE_NAME7             (TEMPL_LOC_OFFSET + 57)
+#define STR_TEMPLATE_NAME8             (TEMPL_LOC_OFFSET + 58)
+#define STR_TEMPLATE_NAME9             (TEMPL_LOC_OFFSET + 59)
+#define STR_TEMPLATE_NAME10            (TEMPL_LOC_OFFSET + 60)
+#define STR_TEMPLATE_NAME11            (TEMPL_LOC_OFFSET + 61)
+#define STR_TEMPLATE_NAME12            (TEMPL_LOC_OFFSET + 62)
+#define STR_TEMPLATE_NAME13            (TEMPL_LOC_OFFSET + 63)
+#define STR_TEMPLATE_NAME14            (TEMPL_LOC_OFFSET + 64)
+#define STR_TEMPLATE_NAME15            (TEMPL_LOC_OFFSET + 65)
+#define STR_TEMPLATE_NAME16            (TEMPL_LOC_OFFSET + 66)
+#define STR_TEMPLATE_NAME17            (TEMPL_LOC_OFFSET + 67)
+#define STR_TEMPLATE_NAME18            (TEMPL_LOC_OFFSET + 68)
+#define STR_TEMPLATE_NAME19            (TEMPL_LOC_OFFSET + 69)
+#define STR_TEMPLATE_NAME20            (TEMPL_LOC_OFFSET + 70)
+#define STR_TEMPLATE_NAME21            (TEMPL_LOC_OFFSET + 71)
+#define STR_TEMPLATE_NAME22            (TEMPL_LOC_OFFSET + 72)
+#define STR_TEMPLATE_NAME23            (TEMPL_LOC_OFFSET + 73)
+#define STR_TEMPLATE_NAME24            (TEMPL_LOC_OFFSET + 74)
+#define STR_TEMPLATE_NAME25            (TEMPL_LOC_OFFSET + 75)
diff --git a/sfx2/source/doc/doctempl.cxx b/sfx2/source/doc/doctempl.cxx
index d28d0e6..640c645 100644
--- a/sfx2/source/doc/doctempl.cxx
+++ b/sfx2/source/doc/doctempl.cxx
@@ -94,6 +94,7 @@ using namespace ::ucbhelper;
 #include "sfxtypes.hxx"
 #include <sfx2/app.hxx>
 #include "sfx2/sfxresid.hxx"
+#include <sfx2/templatelocnames.hrc>
 #include "doc.hrc"
 #include <sfx2/fcontnr.hxx>
 #include <svtools/templatefoldercache.hxx>
@@ -775,6 +776,31 @@ String SfxDocumentTemplates::GetDefaultTemplatePath
 
 //------------------------------------------------------------------------
 
+/** Convert a resource string - a template name - to its localised pair if it exists.
+    @param nSourceResIds
+        Resource ID where the list of original en-US template names begin.
+    @param nDestResIds
+        Resource ID where the list of localised template names begin.
+    @param nCount
+        The number of names that have been localised.
+    @param rString
+        Name to be translated.
+    @return
+        The localised pair of rString or rString if the former does not exist.
+*/
+OUString SfxDocumentTemplates::ConvertResourceString (
+    int nSourceResIds, int nDestResIds, int nCount, const OUString& rString )
+{
+    for( int i = 0; i < nCount; ++i )
+    {
+        if( rString == ResId::toString( SfxResId( nSourceResIds + i) ) )
+            return ResId::toString( SfxResId( nDestResIds + i ) );
+    }
+    return rString;
+}
+
+//------------------------------------------------------------------------
+
 sal_Bool SfxDocumentTemplates::SaveDir
 (
 //  SfxTemplateDir& rDir        //  Save Directory
@@ -1761,7 +1787,8 @@ DocTempl_EntryData_Impl::DocTempl_EntryData_Impl( RegionData_Impl* pParent,
                                 const OUString& rTitle )
 {
     mpParent    = pParent;
-    maTitle     = rTitle;
+    maTitle     = SfxDocumentTemplates::ConvertResourceString(
+                  STR_TEMPLATE_NAME1_DEF, STR_TEMPLATE_NAME1, NUM_TEMPLATE_NAMES, rTitle );
     mbIsOwner   = sal_False;
     mbDidConvert= sal_False;
 }
@@ -1772,7 +1799,7 @@ int DocTempl_EntryData_Impl::Compare( const OUString& rTitle ) const
     return maTitle.compareTo( rTitle );
 }
 
-//------------------------------------------------------------------------
+// -----------------------------------------------------------------------
 SfxObjectShellRef DocTempl_EntryData_Impl::CreateObjectShell()
 {
     if( ! mxObjShell.Is() )
diff --git a/sfx2/source/doc/templatelocnames.src b/sfx2/source/doc/templatelocnames.src
new file mode 100644
index 0000000..03c3caf
--- /dev/null
+++ b/sfx2/source/doc/templatelocnames.src
@@ -0,0 +1,281 @@
+/*
+ * 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. 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.
+ *
+ * The Initial Developer of the Original Code is
+ *       Péter Rabi <prabi@caesar.elte.hu>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * 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.
+ */
+
+#include <sfx2/templatelocnames.hrc>
+
+// Do not translate STR_TEMPLATE_NAME*_DEF names!!
+String STR_TEMPLATE_NAME1_DEF
+{
+    Text = "Blue Border" ;
+};
+
+String STR_TEMPLATE_NAME2_DEF
+{
+    Text = "Black and White" ;
+};
+
+String STR_TEMPLATE_NAME3_DEF
+{
+    Text = "Blue and Grey" ;
+};
+
+String STR_TEMPLATE_NAME4_DEF
+{
+    Text = "Blue Lines and Gradients" ;
+};
+
+String STR_TEMPLATE_NAME5_DEF
+{
+    Text = "Blue with Bottom Title " ;
+};
+
+String STR_TEMPLATE_NAME6_DEF
+{
+    Text = "Notebook" ;
+};
+
+String STR_TEMPLATE_NAME7_DEF
+{
+    Text = "Brown" ;
+};
+
+String STR_TEMPLATE_NAME8_DEF
+{
+    Text = "Characters with Glow" ;
+};
+
+String STR_TEMPLATE_NAME9_DEF
+{
+    Text = "Forest" ;
+};
+
+String STR_TEMPLATE_NAME10_DEF
+{
+    Text = "Fresco" ;
+};
+
+String STR_TEMPLATE_NAME11_DEF
+{
+    Text = "Glacier" ;
+};
+
+String STR_TEMPLATE_NAME12_DEF
+{
+    Text = "Green with White Lines" ;
+};
+
+String STR_TEMPLATE_NAME13_DEF
+{
+    Text = "Keyboard" ;
+};
+
+String STR_TEMPLATE_NAME14_DEF
+{
+    Text = "Light Blue Shapes" ;
+};
+
+String STR_TEMPLATE_NAME15_DEF
+{
+    Text = "Numbers on Dark Background" ;
+};
+
+String STR_TEMPLATE_NAME16_DEF
+{
+    Text = "Blue Step Gradients" ;
+};
+
+String STR_TEMPLATE_NAME17_DEF
+{
+    Text = "White Blue and Lightnings" ;
+};
+
+String STR_TEMPLATE_NAME18_DEF
+{
+    Text = "Noise Paper" ;
+};
+
+String STR_TEMPLATE_NAME19_DEF
+{
+    Text = "Red Noise Shapes" ;
+};
+
+String STR_TEMPLATE_NAME20_DEF
+{
+    Text = "Rounded Rectangles" ;
+};
+
+String STR_TEMPLATE_NAME21_DEF
+{
+    Text = "Blue and Red Gradient" ;
+};
+
+String STR_TEMPLATE_NAME22_DEF
+{
+    Text = "Technical Polygon" ;
+};
+
+String STR_TEMPLATE_NAME23_DEF
+{
+    Text = "Tunnel" ;
+};
+
+String STR_TEMPLATE_NAME24_DEF
+{
+    Text = "Water" ;
+};
+
+String STR_TEMPLATE_NAME25_DEF
+{
+    Text = "Wine" ;
+};
+
+/////////////////////////////////////////////////
+
+String STR_TEMPLATE_NAME1
+{
+    Text [ en-US ] = "Blue Border" ;
+};
+
+String STR_TEMPLATE_NAME2
+{
+    Text [ en-US ] = "Black and White" ;
+};
+
+String STR_TEMPLATE_NAME3
+{
+    Text [ en-US ] = "Blue and Grey" ;
+};
+
+String STR_TEMPLATE_NAME4
+{
+    Text [ en-US ] = "Blue Lines and Gradients" ;
+};
+
+String STR_TEMPLATE_NAME5
+{
+    Text [ en-US ] = "Blue with Bottom Title" ;
+};
+
+String STR_TEMPLATE_NAME6
+{
+    Text [ en-US ] = "Notebook" ;
+};
+
+String STR_TEMPLATE_NAME7
+{
+    Text [ en-US ] = "Brown" ;
+};
+
+String STR_TEMPLATE_NAME8
+{
+    Text [ en-US ] = "Characters with Glow" ;
+};
+
+String STR_TEMPLATE_NAME9
+{
+    Text [ en-US ] = "Forest" ;
+};
+
+String STR_TEMPLATE_NAME10
+{
+    Text [ en-US ] = "Fresco" ;
+};
+
+String STR_TEMPLATE_NAME11
+{
+    Text [ en-US ] = "Glacier" ;
+};
+
+String STR_TEMPLATE_NAME12
+{
+    Text [ en-US ] = "Green with White Lines" ;
+};
+
+String STR_TEMPLATE_NAME13
+{
+    Text [ en-US ] = "Keyboard" ;
+};
+
+String STR_TEMPLATE_NAME14
+{
+    Text [ en-US ] = "Light Blue Shapes" ;
+};
+
+String STR_TEMPLATE_NAME15
+{
+    Text [ en-US ] = "Numbers on Dark Background" ;
+};
+
+String STR_TEMPLATE_NAME16
+{
+    Text [ en-US ] = "Blue Step Gradients" ;
+};
+
+String STR_TEMPLATE_NAME17
+{
+    Text [ en-US ] = "White Blue and Lightnings" ;
+};
+
+String STR_TEMPLATE_NAME18
+{
+    Text [ en-US ] = "Noise Paper" ;
+};
+
+String STR_TEMPLATE_NAME19
+{
+    Text [ en-US ] = "Red Noise Shapes" ;
+};
+
+String STR_TEMPLATE_NAME20
+{
+    Text [ en-US ] = "Rounded Rectangles" ;
+};
+
+String STR_TEMPLATE_NAME21
+{
+    Text [ en-US ] = "Blue and Red Gradient" ;
+};
+
+String STR_TEMPLATE_NAME22
+{
+    Text [ en-US ] = "Technical Polygon" ;
+};
+
+String STR_TEMPLATE_NAME23
+{
+    Text [ en-US ] = "Tunnel" ;
+};
+
+String STR_TEMPLATE_NAME24
+{
+    Text [ en-US ] = "Water" ;
+};
+
+String STR_TEMPLATE_NAME25
+{
+    Text [ en-US ] = "Wine" ;
+};
-- 
1.7.4.1

From 5ad7b66b3818e19bf6dd603a0e61aebbba0eb919 Mon Sep 17 00:00:00 2001
From: Peter Rabi <prabi@caesar.elte.hu>
Date: Thu, 28 Jul 2011 12:17:36 +0200
Subject: [PATCH] Clean-up of bugfix fdo#32895 for the -3-4 branch

Contributed under license LGPLv3+/MPL.
---
 sd/source/ui/dlg/TemplateScanner.cxx |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/sd/source/ui/dlg/TemplateScanner.cxx b/sd/source/ui/dlg/TemplateScanner.cxx
index 360d9e6..a773d4d 100644
--- a/sd/source/ui/dlg/TemplateScanner.cxx
+++ b/sd/source/ui/dlg/TemplateScanner.cxx
@@ -37,6 +37,8 @@
 #include <tools/debug.hxx>
 #include <osl/mutex.hxx>
 #include <vcl/svapp.hxx>
+#include <sfx2/doctempl.hxx>
+#include <sfx2/templatelocnames.hrc>
 #include <com/sun/star/frame/XDocumentTemplates.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
@@ -263,7 +265,9 @@ TemplateScanner::State TemplateScanner::ScanEntry (void)
                     ||  (sContentType == IMPRESS_XML_TEMPLATE)
                     ||  (sContentType == IMPRESS_XML_TEMPLATE_B))
                 {
-                    mpLastAddedEntry = new TemplateEntry(sTitle, sTargetURL);
+                    ::rtl::OUString sLocalisedTitle = SfxDocumentTemplates::ConvertResourceString(
+                        STR_TEMPLATE_NAME1_DEF, STR_TEMPLATE_NAME1, NUM_TEMPLATE_NAMES, sTitle );
+                    mpLastAddedEntry = new TemplateEntry(sLocalisedTitle, sTargetURL);
                     mpTemplateDirectory->maEntries.push_back(mpLastAddedEntry);
                 }
             }
-- 
1.7.4.1


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.