summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-04-21 11:41:21 +0200
committerMichael Stahl <mstahl@redhat.com>2017-04-21 12:06:31 +0200
commit157013219230f251346a5aa662c39d02f15420ec (patch)
treece3cdcc8491080b19b7db5006d37769def3eed6a
parent4e3d14deb74c57632db57663d2fc2ead9d8aa0f0 (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
-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 1a6c33753775..225850bb13cb 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -50,6 +50,7 @@
#include <poolfmt.hxx>
#include <ndtxt.hxx>
#include <editsh.hxx>
+#include <poolfmt.hrc>
#include "xmlimp.hxx"
#include "xmltexti.hxx"
#include <xmloff/DocumentSettingsContext.hxx>
@@ -133,6 +134,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);
+ }
}
SvXMLImportContext *SwXMLBodyContext_Impl::CreateChildContext(
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" ;