summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJakub Trzebiatowski <ubap.dev@gmail.com>2016-07-14 11:35:59 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-15 16:08:53 +0000
commit0710fcd58d29d7ba98f0305caab79f9b7b1519a2 (patch)
treee5358ea9e53a89f4c6b512cb631ed5666ffee3a2 /sw
parentbc9b4fd4c83af3532204237157821d4884c42d8e (diff)
GSoC Writer Table Styles; Cell Style XPropertyState
Implemented XPropertyState for SwXTextCellStyle, that allows to skip export of default valued attributes. Implemented odfexport tests. Change-Id: I906c63d4937e378cf89750616fc9ec929c7f3e44 Reviewed-on: https://gerrit.libreoffice.org/27215 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/odfexport/data/table_styles_3.odtbin0 -> 9376 bytes
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx59
-rw-r--r--sw/source/core/unocore/unostyle.cxx120
3 files changed, 177 insertions, 2 deletions
diff --git a/sw/qa/extras/odfexport/data/table_styles_3.odt b/sw/qa/extras/odfexport/data/table_styles_3.odt
new file mode 100644
index 000000000000..736786489043
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/table_styles_3.odt
Binary files differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index fc8fd71e6ed7..1e8febf87b45 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -1064,6 +1064,65 @@ DECLARE_ODFEXPORT_TEST(testTableStyles2, "table_styles_2.odt")
CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nInt16);
}
+DECLARE_ODFEXPORT_TEST(testTableStyles3, "table_styles_3.odt")
+{
+ // This test checks if default valued attributes aren't exported.
+ if (xmlDocPtr pXmlDoc = parseExport("styles.xml"))
+ {
+ // <style:paragraph-properties>
+ // For this element the only exported attributes are: "border-left", "border-bottom"
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "background-color");
+ // border-left place
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "border-right");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "border-top");
+ // border-bottom place
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "padding");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "padding-left");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "padding-right");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "padding-top");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "padding-bottom");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:table-cell-properties", "writing-mode");
+
+ // <style:paragraph-properties> should be absent, because it has only "text-align" attribute, which shouldn't be exported.
+ // Assume that style:paragraph-properties and style:text-properties exists.
+ assertXPathChildren(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']", 2);
+
+ // <style:text-properties>
+ // For this element the only exported attributes are: "use-window-font-color place", "font-size-asian", "font-name-asian", "font-family-asian", "font-name-complex", "font-family-complex"
+ // use-window-font-color place
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "text-shadow");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "text-outline");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "text-line-through-style");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "text-line-through-type");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "text-underline-style");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "text-underline-color");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-size");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-weight");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-style");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-name");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-family");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-style-name");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-family-generic");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-pitch");
+ // font-size-asian place
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-weight-asian");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-style-asian");
+ // font-name-asian place
+ // font-family-asian place
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-style-name-asian");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-family-generic-asian");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-pitch-asian");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-size-complex");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-weight-complex");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-style-complex");
+ // font-name-complex place
+ // font-family-complex place
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-style-name-complex");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-family-generic-complex");
+ assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:display-name='Test style3.2']/style:text-properties", "font-pitch-complex");
+ }
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index a61ea18df487..8d7e8a1e0000 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -5312,15 +5312,131 @@ css::uno::Sequence<css::beans::PropertyState> SAL_CALL SwXTextCellStyle::getProp
const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(sPropName);
if(pEntry)
{
+ uno::Any aAny1, aAny2;
switch(pEntry->nWID)
{
+ case RES_BACKGROUND:
+ m_pBoxAutoFormat->GetBackground().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetBackground().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ case RES_BOX:
+ m_pBoxAutoFormat->GetBox().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetBox().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
case RES_VERT_ORIENT:
- if (m_pBoxAutoFormat->GetVerticalAlignment() == rDefaultBoxFormat.GetVerticalAlignment())
- pStates[i] = beans::PropertyState_DEFAULT_VALUE;
+ m_pBoxAutoFormat->GetVerticalAlignment().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetVerticalAlignment().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ case RES_FRAMEDIR:
+ m_pBoxAutoFormat->GetTextOrientation().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetTextOrientation().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ case RES_BOXATR_FORMAT:
+ {
+ OUString sFormat;
+ LanguageType eLng, eSys;
+ m_pBoxAutoFormat->GetValueFormat(sFormat, eLng, eSys);
+ pStates[i] = sFormat.isEmpty() ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ }
+ case RES_PARATR_ADJUST:
+ m_pBoxAutoFormat->GetAdjust().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetAdjust().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ case RES_CHRATR_COLOR:
+ m_pBoxAutoFormat->GetColor().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetColor().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ case RES_CHRATR_SHADOWED:
+ m_pBoxAutoFormat->GetShadowed().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetShadowed().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ case RES_CHRATR_CONTOUR:
+ m_pBoxAutoFormat->GetContour().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetContour().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ case RES_CHRATR_CROSSEDOUT:
+ m_pBoxAutoFormat->GetCrossedOut().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetCrossedOut().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ case RES_CHRATR_UNDERLINE:
+ m_pBoxAutoFormat->GetUnderline().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetUnderline().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ case RES_CHRATR_FONTSIZE:
+ m_pBoxAutoFormat->GetHeight().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetHeight().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ case RES_CHRATR_WEIGHT:
+ m_pBoxAutoFormat->GetWeight().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetWeight().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ case RES_CHRATR_POSTURE:
+ m_pBoxAutoFormat->GetPosture().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetPosture().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ case RES_CHRATR_FONT:
+ m_pBoxAutoFormat->GetFont().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetFont().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ case RES_CHRATR_CJK_FONTSIZE:
+ m_pBoxAutoFormat->GetCJKHeight().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetCJKHeight().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ case RES_CHRATR_CJK_WEIGHT:
+ m_pBoxAutoFormat->GetCJKWeight().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetCJKWeight().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ case RES_CHRATR_CJK_POSTURE:
+ m_pBoxAutoFormat->GetCJKPosture().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetCJKPosture().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ case RES_CHRATR_CJK_FONT:
+ m_pBoxAutoFormat->GetCJKFont().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetCJKFont().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ case RES_CHRATR_CTL_FONTSIZE:
+ m_pBoxAutoFormat->GetCTLHeight().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetCTLHeight().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ case RES_CHRATR_CTL_WEIGHT:
+ m_pBoxAutoFormat->GetCTLWeight().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetCTLWeight().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ case RES_CHRATR_CTL_POSTURE:
+ m_pBoxAutoFormat->GetCTLPosture().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetCTLPosture().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ break;
+ case RES_CHRATR_CTL_FONT:
+ m_pBoxAutoFormat->GetCTLFont().QueryValue(aAny1, pEntry->nMemberId);
+ rDefaultBoxFormat.GetCTLFont().QueryValue(aAny2, pEntry->nMemberId);
+ pStates[i] = aAny1 == aAny2 ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
break;
default:
// falltrough to DIRECT_VALUE, to export properties for which getPropertyStates is not implemented
pStates[i] = beans::PropertyState_DIRECT_VALUE;
+ SAL_WARN("sw.uno", "SwXTextCellStyle getPropertyStates unknown nWID");
}
}
else