summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-04-21 11:41:21 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-05-03 12:46:07 +0200
commitf087bc1cb476931f0b93c7b4a153129c8969b946 (patch)
tree1e1c91202d3565b228a8f0a1e819d0cb2a0cde35
parent016bf0d749eebad63e322563bff8ef87e88a607b (diff)
tdf#107211 sw: ODF import: add a horrible hack to import "Default"
... character style for hyperlinks and index-entry-templates. The problem is that the "Default" character style doesn't actually exist, it is just displayed in the UI so you can remove a character style that is set. So for the most part there is no need to store "Default" in ODF files, except that for hyperlinks the default isn't "Default" but "Internet Link"/"Visited Internet Link". Hence it was not really a good idea to rename "Default" to "Default Style", because when importing existing documents the text:style-name="Default" is not found, and for new documents text:style-name="Default_20_Style" is not found either because there is no style:style element that sets up the mapping between the encoded style-name and the unencoded display-style-name. Add some hack in SwXMLBodyContext_Impl::SwXMLBodyContext_Impl(), when all style:style elements have been read (so we don't override what's in the document) to create the mapping for "Default", "Default_20_Style" and whatever the translation of that is. (regression from 783d13a9276931e274a90b9b53de2c92dc8c055e) Change-Id: I8a80847571f194204c5df267cb48e826a82328b2 (cherry picked from commit 157013219230f251346a5aa662c39d02f15420ec) Reviewed-on: https://gerrit.libreoffice.org/36788 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit 05710ae52ff9962c0852a4e2e59e1814c785b461) Reviewed-on: https://gerrit.libreoffice.org/36936 Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> Reviewed-by: Eike Rathke <erack@redhat.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/source/filter/xml/xmlimp.cxx24
-rw-r--r--sw/source/ui/utlui/poolfmt.src1
2 files changed, 25 insertions, 0 deletions
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index a72fd26e1a06..a2f911417da0 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -52,6 +52,7 @@
#include <poolfmt.hxx>
#include <ndtxt.hxx>
#include <editsh.hxx>
+#include <poolfmt.hrc>
#include "xmlimp.hxx"
#include "xmltexti.hxx"
#include <xmloff/DocumentSettingsContext.hxx>
@@ -138,6 +139,29 @@ SwXMLBodyContext_Impl::SwXMLBodyContext_Impl( SwXMLImport& rImport,
const Reference< xml::sax::XAttributeList > & /*xAttrList*/ ) :
SvXMLImportContext( rImport, nPrfx, rLName )
{
+ // tdf#107211: if at this point we don't have a defined char style "Default"
+ // or "Default Style", add a mapping for it as it is not written
+ // into the file since it's not really a style but "no style"
+ // (hence referencing it actually makes no sense except for hyperlinks
+ // which default to something other than "Default")
+ OUString const sDefault(SW_RES(STR_POOLCOLL_STANDARD));
+ uno::Reference<container::XNameContainer> const& xStyles(
+ rImport.GetTextImport()->GetTextStyles());
+ if (!xStyles->hasByName("Default"))
+ { // this old name was used before LO 4.0
+ rImport.AddStyleDisplayName(XML_STYLE_FAMILY_TEXT_TEXT, "Default", sDefault);
+ }
+ if (!xStyles->hasByName("Default_20_Style"))
+ { // this new name contains a space which is converted to _20_ on export
+ rImport.AddStyleDisplayName(XML_STYLE_FAMILY_TEXT_TEXT, "Default_20_Style", sDefault);
+ }
+ bool isEncoded(false);
+ OUString const defaultEncoded(
+ rImport.GetMM100UnitConverter().encodeStyleName(sDefault, &isEncoded));
+ if (isEncoded && !xStyles->hasByName(defaultEncoded))
+ { // new name may contain a space which is converted to _20_ on export
+ rImport.AddStyleDisplayName(XML_STYLE_FAMILY_TEXT_TEXT, defaultEncoded, sDefault);
+ }
}
SwXMLBodyContext_Impl::~SwXMLBodyContext_Impl()
diff --git a/sw/source/ui/utlui/poolfmt.src b/sw/source/ui/utlui/poolfmt.src
index c6efa70a35d2..c0a876b64797 100644
--- a/sw/source/ui/utlui/poolfmt.src
+++ b/sw/source/ui/utlui/poolfmt.src
@@ -155,6 +155,7 @@ String STR_POOLFRM_LABEL
// Template names
+// tdf#107211 please don't change STANDARD, except back to "Default"
String STR_POOLCOLL_STANDARD
{
Text [ en-US ] = "Default Style" ;