diff options
author | Troy Rollo <libreoffice@troy.rollo.name> | 2017-06-06 17:41:33 +1000 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2017-06-15 11:20:17 +0200 |
commit | f8f7a0e8e158c905394c614f9d39127316dc8ee5 (patch) | |
tree | e5142a0924f222aeb16fbeed788bd583d812c5fc /sw | |
parent | 7daad240f62582e2b32bc3b1af951414e3db0a02 (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>
(cherry picked from commit a5b4cb3f836c991d0647f55e1ef4920ce6115eac)
Reviewed-on: https://gerrit.libreoffice.org/38747
(cherry picked from commit e9869b9b38d4e4e7f893aecb26f73d985f17e350)
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 3 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlfmt.cxx | 53 |
2 files changed, 53 insertions, 3 deletions
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 63ce5d95beb6..ad6dd78b687e 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2013,7 +2013,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 b65cb0dc525b..b5aabd8cd96f 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,8 +210,11 @@ public: const uno::Reference< xml::sax::XAttributeList > & xAttrList ); virtual ~SwXMLConditionContext_Impl() override; - bool IsValid() const { return 0 != nCondition; } + + sal_uInt32 getCondition() const { return nCondition; } + sal_uInt32 getSubCondition() const { return nSubCondition; } + OUString const &getApplyStyle() const { return sApplyStyle; } }; SwXMLConditionContext_Impl::SwXMLConditionContext_Impl( @@ -257,10 +265,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: @@ -280,7 +290,6 @@ public: uno::Reference < style::XStyle > SwXMLTextStyleContext_Impl::Create() { - uno::Reference < style::XStyle > xNewStyle; if( pConditions && XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() ) { @@ -302,6 +311,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() ) + { + sal_uInt32 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, |