1 |
From 1f04cd4415c88d3bcb27b118fa3121fe58de87db Mon Sep 17 00:00:00 2001 |
2 |
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com> |
3 |
Date: Thu, 17 Jan 2013 12:41:11 +0000 |
4 |
Subject: [PATCH 2/2] Resolves: fdo#58730 workaround [UL|LR]Space 100% problem |
5 |
|
6 |
If all paragraph margins are 100% on import, ignore that as being the implicit |
7 |
default. That avoids explicit 100% being set onto the awesome [UL|LR]Space |
8 |
which takes a relative propsize of 100% as a flag that its value field is |
9 |
absolute and so rejected by SwTxtFmtColl::Modify as a candidate for getting its |
10 |
true value initialized relative to its parent, so it ends up as an absolute 0 |
11 |
|
12 |
Always elide the property on export because writing individual |
13 |
margin-foos provides better backward compatibility with older versions |
14 |
anyway. |
15 |
|
16 |
Trigged by 3c5facfce42a0dbe362d6b9fa5ac374fd76f51a1 |
17 |
|
18 |
Change-Id: I55f6ceeae287b7d8e99befa4bd3cc06738a21299 |
19 |
(cherry picked from commit 23c099a0236062724430efb986251637095c8d4f) |
20 |
|
21 |
Signed-off-by: Michael Stahl <mstahl@redhat.com> |
22 |
(cherry picked from commit abb84c2cce54a903ef846cbfe297b2bbc62ff260) |
23 |
--- |
24 |
xmloff/source/text/txtexppr.cxx | 8 ++++++++ |
25 |
xmloff/source/text/txtimppr.cxx | 23 ++++++++++++++++++++++- |
26 |
2 files changed, 30 insertions(+), 1 deletion(-) |
27 |
|
28 |
diff --git a/xmloff/source/text/txtexppr.cxx b/xmloff/source/text/txtexppr.cxx |
29 |
index 48c2e64..17991ec 100644 |
30 |
--- a/xmloff/source/text/txtexppr.cxx |
31 |
+++ b/xmloff/source/text/txtexppr.cxx |
32 |
@@ -467,6 +467,8 @@ void XMLTextExportPropertySetMapper::ContextFilter( |
33 |
XMLPropertyState* pClip11State = NULL; |
34 |
XMLPropertyState* pClipState = NULL; |
35 |
|
36 |
+ // filter fo:margin |
37 |
+ XMLPropertyState* pAllParaMarginRel = NULL; |
38 |
XMLPropertyState* pAllParaMargin = NULL; |
39 |
XMLPropertyState* pAllMargin = NULL; |
40 |
|
41 |
@@ -584,6 +586,7 @@ void XMLTextExportPropertySetMapper::ContextFilter( |
42 |
case CTF_NUMBERINGSTYLENAME: pListStyleName = propertie; break; |
43 |
case CTF_TEXT_CLIP11: pClip11State = propertie; break; |
44 |
case CTF_TEXT_CLIP: pClipState = propertie; break; |
45 |
+ case CTF_PARAMARGINALL_REL: pAllParaMarginRel = propertie; break; |
46 |
case CTF_PARAMARGINALL: pAllParaMargin = propertie; break; |
47 |
case CTF_MARGINALL: pAllMargin = propertie; break; |
48 |
} |
49 |
@@ -637,6 +640,11 @@ void XMLTextExportPropertySetMapper::ContextFilter( |
50 |
lcl_checkMultiProperty(pParaBottomMarginState, pParaBottomMarginRelState); |
51 |
lcl_checkMultiProperty(pParaFirstLineState, pParaFirstLineRelState); |
52 |
|
53 |
+ if (pAllParaMarginRel) |
54 |
+ { // because older OOo/LO versions can't read fo:margin: |
55 |
+ pAllParaMarginRel->mnIndex = -1; // just export individual attributes... |
56 |
+ pAllParaMarginRel->maValue.clear(); |
57 |
+ } |
58 |
if (pAllParaMargin) |
59 |
{ |
60 |
pAllParaMargin->mnIndex = -1; // just export individual attributes... |
61 |
diff --git a/xmloff/source/text/txtimppr.cxx b/xmloff/source/text/txtimppr.cxx |
62 |
index 5c63fcb..c403794 100644 |
63 |
--- a/xmloff/source/text/txtimppr.cxx |
64 |
+++ b/xmloff/source/text/txtimppr.cxx |
65 |
@@ -266,6 +266,26 @@ void XMLTextImportPropertyMapper::FontDefaultsCheck( |
66 |
} |
67 |
} |
68 |
|
69 |
+//fdo#58730 The [UL|LR]Space class has a deficiency where "100%" also serves as |
70 |
+//a flag that the value is an absolute value so we can't truly handle an |
71 |
+//up/lower space property which wants to specify its 200% upper but 100% lower |
72 |
+//of its parent (try typing 100% vs 200% into the edit style dialog and revisit |
73 |
+//your style). So on xml load that ends up meaning 200%, 0 lower. This is a |
74 |
+//crock. |
75 |
+// |
76 |
+//On import clear 100% all-margins relative sizes. |
77 |
+static bool |
78 |
+isNotDefaultRelSize(const XMLPropertyState* pRelState, const UniReference<XMLPropertySetMapper>& rPrMap) |
79 |
+{ |
80 |
+ if (rPrMap->GetEntryContextId(pRelState->mnIndex) == CTF_PARAMARGINALL_REL) |
81 |
+ { |
82 |
+ sal_Int32 nTemp = 0; |
83 |
+ pRelState->maValue >>= nTemp; |
84 |
+ return nTemp != 100; |
85 |
+ } |
86 |
+ return true; |
87 |
+} |
88 |
+ |
89 |
void XMLTextImportPropertyMapper::finished( |
90 |
::std::vector< XMLPropertyState >& rProperties, |
91 |
sal_Int32 /*nStartIndex*/, sal_Int32 /*nEndIndex*/ ) const |
92 |
@@ -434,7 +454,8 @@ void XMLTextImportPropertyMapper::finished( |
93 |
|
94 |
for (sal_uInt16 i = 0; i < 4; i++) |
95 |
{ |
96 |
- if (pAllParaMargin && !pParaMargins[i]) |
97 |
+ if (pAllParaMargin && !pParaMargins[i] |
98 |
+ && isNotDefaultRelSize(pAllParaMargin, getPropertySetMapper())) |
99 |
{ |
100 |
#if OSL_DEBUG_LEVEL > 0 |
101 |
sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId( |
102 |
-- |
103 |
1.7.11.7 |
104 |
|