summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorTroy Rollo <libreoffice@troy.rollo.name>2017-06-06 17:41:33 +1000
committerMichael Stahl <mstahl@redhat.com>2017-06-13 18:55:15 +0200
commita5b4cb3f836c991d0647f55e1ef4920ce6115eac (patch)
treecb69d051ed559d806dd60657ddd0186a6b962b60 /sw
parent3c641c9c1f2ec01a9ae61e955ceb69c52e45f31e (diff)
tdf#103091 conditional style conditions not saved
Change-Id: Iccf3eb531ee3382d27105e5ccce6013707a646b6 Reviewed-on: https://gerrit.libreoffice.org/38451 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/unocore/unostyle.cxx3
-rw-r--r--sw/source/filter/xml/xmlfmt.cxx52
2 files changed, 53 insertions, 2 deletions
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index f9d3a06acbf2..2cce53ca24b6 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -1997,7 +1997,8 @@ void SwXStyle::SetPropertyValues_Impl(const uno::Sequence<OUString>& rPropertyNa
{
if(!m_pDoc)
throw uno::RuntimeException();
- const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(m_rEntry.m_nPropMapType);
+ sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
+ const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap();
if(rPropertyNames.getLength() != rValues.getLength())
throw lang::IllegalArgumentException();
diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx
index 685e7bc1dd75..ec0ac4cb77d0 100644
--- a/sw/source/filter/xml/xmlfmt.cxx
+++ b/sw/source/filter/xml/xmlfmt.cxx
@@ -31,6 +31,7 @@
#include "docary.hxx"
#include <IDocumentStylePoolAccess.hxx>
#include "unostyle.hxx"
+#include "unoprnms.hxx"
#include "fmtpdsc.hxx"
#include "pagedesc.hxx"
#include <xmloff/xmlnmspe.hxx>
@@ -44,6 +45,7 @@
#include <xmloff/XMLTextMasterStylesContext.hxx>
#include <xmloff/XMLTextShapeStyleContext.hxx>
#include <xmloff/XMLGraphicsDefaultStyle.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
#include "xmlimp.hxx"
#include "xmltbli.hxx"
#include "cellatr.hxx"
@@ -51,10 +53,13 @@
#include <xmloff/attrlist.hxx>
#include <unotxdoc.hxx>
#include <docsh.hxx>
+#include <ccoll.hxx>
#include <memory>
using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
using namespace ::xmloff::token;
class SwXMLConditionParser_Impl
@@ -205,6 +210,10 @@ public:
const uno::Reference< xml::sax::XAttributeList > & xAttrList );
bool IsValid() const { return Master_CollCondition::NONE != nCondition; }
+
+ Master_CollCondition getCondition() const { return nCondition; }
+ sal_uInt32 getSubCondition() const { return nSubCondition; }
+ OUString const &getApplyStyle() const { return sApplyStyle; }
};
SwXMLConditionContext_Impl::SwXMLConditionContext_Impl(
@@ -250,10 +259,12 @@ typedef std::vector<rtl::Reference<SwXMLConditionContext_Impl>> SwXMLConditions_
class SwXMLTextStyleContext_Impl : public XMLTextStyleContext
{
std::unique_ptr<SwXMLConditions_Impl> pConditions;
+ uno::Reference < style::XStyle > xNewStyle;
protected:
virtual uno::Reference < style::XStyle > Create() override;
+ virtual void Finish( bool bOverwrite ) override;
public:
@@ -273,7 +284,6 @@ public:
uno::Reference < style::XStyle > SwXMLTextStyleContext_Impl::Create()
{
- uno::Reference < style::XStyle > xNewStyle;
if( pConditions && XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() )
{
@@ -295,6 +305,46 @@ uno::Reference < style::XStyle > SwXMLTextStyleContext_Impl::Create()
return xNewStyle;
}
+void
+SwXMLTextStyleContext_Impl::Finish( bool bOverwrite )
+{
+
+ if( pConditions && XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() && xNewStyle.is() )
+ {
+ CommandStruct const *aCommands = SwCondCollItem::GetCmds();
+
+ Reference< XPropertySet > xPropSet( xNewStyle, UNO_QUERY );
+
+ uno::Sequence< beans::NamedValue > aSeq( pConditions->size() );
+
+ std::vector<rtl::Reference<SwXMLConditionContext_Impl>>::size_type i;
+ unsigned j;
+
+ for( i = 0; i < pConditions->size(); ++i )
+ {
+ if( (*pConditions)[i]->IsValid() )
+ {
+ Master_CollCondition nCond = (*pConditions)[i]->getCondition();
+ sal_uInt32 nSubCond = (*pConditions)[i]->getSubCondition();
+
+ for( j = 0; j < COND_COMMAND_COUNT; ++j )
+ {
+ if( aCommands[j].nCnd == nCond &&
+ aCommands[j].nSubCond == nSubCond )
+ {
+ aSeq[i].Name = GetCommandContextByIndex( j );
+ aSeq[i].Value <<= GetImport().GetStyleDisplayName( GetFamily(), (*pConditions)[i]->getApplyStyle() );
+ break;
+ }
+ }
+ }
+ }
+
+ xPropSet->setPropertyValue( UNO_NAME_PARA_STYLE_CONDITIONS, uno::makeAny( aSeq ) );
+ }
+ XMLTextStyleContext::Finish( bOverwrite );
+}
+
SwXMLTextStyleContext_Impl::SwXMLTextStyleContext_Impl( SwXMLImport& rImport,
sal_uInt16 nPrfx, const OUString& rLName,
const uno::Reference< xml::sax::XAttributeList > & xAttrList,