diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-04-07 23:22:22 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-04-08 12:12:24 +0200 |
commit | d477ff4a81ecba8a77ead5ff1a33d3e3ceed622e (patch) | |
tree | a054daa25836403aeb8c45e1abcee5d91be10bf3 /sw/source | |
parent | bda01cf116c324e4082c7cffb156dc2d5fee9d3d (diff) |
fdo#69416: make footnote positions available to XProofreader
- ModelToViewHelper: add new flag REPLACEMODE, which causes fields and
footnotes to be replaced with ZWSP instead of expanding them
- SwXFlatParagraph: add FootnotePositions and FieldPositions properties
- GrammarCheckingIterator: invoke XProofreader::doProofreading with
properties FootnotePositions and FieldPositions
Change-Id: I9b66a37aac94f940546e812d8b85a35aebd8181a
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/inc/unoflatpara.hxx | 53 | ||||
-rw-r--r-- | sw/source/core/txtnode/modeltoviewhelper.cxx | 33 | ||||
-rw-r--r-- | sw/source/core/txtnode/txtedt.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unoflatpara.cxx | 92 |
4 files changed, 171 insertions, 9 deletions
diff --git a/sw/source/core/inc/unoflatpara.hxx b/sw/source/core/inc/unoflatpara.hxx index af4db776443c..ceeff519dfaf 100644 --- a/sw/source/core/inc/unoflatpara.hxx +++ b/sw/source/core/inc/unoflatpara.hxx @@ -21,6 +21,9 @@ #define INCLUDED_SW_SOURCE_CORE_INC_UNOFLATPARA_HXX #include <cppuhelper/implbase1.hxx> +#include <cppuhelper/implbase3.hxx> + +#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/text/XFlatParagraph.hpp> #include <com/sun/star/text/XFlatParagraphIterator.hpp> @@ -46,8 +49,9 @@ class SwDoc; ******************************************************************************/ class SwXFlatParagraph: - public ::cppu::WeakImplHelper2 + public ::cppu::WeakImplHelper3 < + css::beans::XPropertySet, css::text::XFlatParagraph, css::lang::XUnoTunnel >, @@ -64,6 +68,53 @@ public: virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL setPropertyValue( + const OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL addPropertyChangeListener( + const OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL removePropertyChangeListener( + const OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL addVetoableChangeListener( + const OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL removeVetoableChangeListener( + const OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + // text::XTextMarkup: virtual css::uno::Reference< css::container::XStringKeyMap > SAL_CALL getMarkupInfoContainer() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; diff --git a/sw/source/core/txtnode/modeltoviewhelper.cxx b/sw/source/core/txtnode/modeltoviewhelper.cxx index 2a338ad9764c..085d3c5eff9d 100644 --- a/sw/source/core/txtnode/modeltoviewhelper.cxx +++ b/sw/source/core/txtnode/modeltoviewhelper.cxx @@ -37,6 +37,7 @@ struct FieldResult { sal_Int32 m_nFieldPos; OUString m_sExpand; + enum { FIELD, FOOTNOTE } m_eType; }; class sortfieldresults : @@ -144,9 +145,11 @@ ModelToViewHelper::ModelToViewHelper(const SwTxtNode &rNode, sal_uInt16 eMode) case RES_TXTATR_ANNOTATION: if (eMode & EXPANDFIELDS) { - aFieldResult.m_sExpand = - static_cast<SwTxtFld const*>(pAttr)->GetFmtFld().GetField() - ->ExpandField(true); + aFieldResult.m_sExpand = (eMode & REPLACEMODE) + ? OUString(CHAR_ZWSP) + : static_cast<SwTxtFld const*>(pAttr)-> + GetFmtFld().GetField()->ExpandField(true); + aFieldResult.m_eType = FieldResult::FIELD; } break; case RES_TXTATR_FTN: @@ -154,7 +157,10 @@ ModelToViewHelper::ModelToViewHelper(const SwTxtNode &rNode, sal_uInt16 eMode) { const SwFmtFtn& rFtn = static_cast<SwTxtFtn const*>(pAttr)->GetFtn(); const SwDoc *pDoc = rNode.GetDoc(); - aFieldResult.m_sExpand = rFtn.GetViewNumStr(*pDoc); + aFieldResult.m_sExpand = (eMode & REPLACEMODE) + ? OUString(CHAR_ZWSP) + : rFtn.GetViewNumStr(*pDoc); + aFieldResult.m_eType = FieldResult::FOOTNOTE; } break; default: @@ -186,7 +192,10 @@ ModelToViewHelper::ModelToViewHelper(const SwTxtNode &rNode, sal_uInt16 eMode) { FieldResult aFieldResult; aFieldResult.m_nFieldPos = nDummyCharPos; - aFieldResult.m_sExpand = sw::mark::ExpandFieldmark(pMark); + aFieldResult.m_sExpand = (eMode & REPLACEMODE) + ? OUString(CHAR_ZWSP) + : sw::mark::ExpandFieldmark(pMark); + aFieldResult.m_eType = FieldResult::FIELD; aFind->m_aAttrs.insert(aFieldResult); } } @@ -209,8 +218,18 @@ ModelToViewHelper::ModelToViewHelper(const SwTxtNode &rNode, sal_uInt16 eMode) { for (FieldResultSet::iterator j = i->m_aAttrs.begin(); j != i->m_aAttrs.end(); ++j) { - m_aRetText = m_aRetText.replaceAt( nOffset + j->m_nFieldPos, 1, j->m_sExpand ); - m_aMap.push_back( ConversionMapEntry( j->m_nFieldPos, nOffset + j->m_nFieldPos ) ); + sal_Int32 const viewPos(nOffset + j->m_nFieldPos); + m_aRetText = m_aRetText.replaceAt(viewPos, 1, j->m_sExpand); + m_aMap.push_back( ConversionMapEntry(j->m_nFieldPos, viewPos) ); + switch (j->m_eType) + { + case FieldResult::FIELD: + m_FieldPositions.push_back(viewPos); + break; + case FieldResult::FOOTNOTE: + m_FootnotePositions.push_back(viewPos); + break; + } nOffset += j->m_sExpand.getLength() - 1; } } diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index 417c3cf5c481..8929b0b23be7 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -1455,7 +1455,7 @@ SwRect SwTxtFrm::SmartTagScan( SwCntntNode* /*pActNode*/, sal_Int32 /*nActPos*/ if ( nBegin < nEnd ) { // Expand the string: - const ModelToViewHelper aConversionMap(*pNode); + const ModelToViewHelper aConversionMap(*pNode /*TODO - replace or expand fields for smart tags?*/); OUString aExpandText = aConversionMap.getViewText(); // Ownership ov ConversionMap is passed to SwXTextMarkup object! diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx index 80817cda5446..69760910cb96 100644 --- a/sw/source/core/unocore/unoflatpara.cxx +++ b/sw/source/core/unocore/unoflatpara.cxx @@ -92,6 +92,10 @@ uno::Any SAL_CALL SwXFlatParagraph::queryInterface( const uno::Type& rType ) thr { return uno::makeAny( uno::Reference < text::XFlatParagraph >(this) ); } + else if (rType == ::getCppuType((uno::Reference< beans::XPropertySet>*)0)) + { + return uno::makeAny( uno::Reference<beans::XPropertySet>(this) ); + } else return SwXTextMarkup::queryInterface( rType ); } @@ -111,6 +115,94 @@ const SwTxtNode* SwXFlatParagraph::getTxtNode() const return mpTxtNode; } +// XPropertySet +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXFlatParagraph::getPropertySetInfo() +throw (uno::RuntimeException, std::exception) +{ + throw uno::RuntimeException("SwXFlatParagraph::getPropertySetInfo(): " + "not implemented", 0/*static_cast< ::cppu::OWeakObject*>(this)*/); +} + +void SAL_CALL +SwXFlatParagraph::setPropertyValue(const OUString&, const uno::Any&) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException, std::exception) +{ + throw lang::IllegalArgumentException("no values can be set", + 0/*static_cast< ::cppu::OWeakObject*>(this)*/, 0); +} + +uno::Any SAL_CALL +SwXFlatParagraph::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException, std::exception) +{ + SolarMutexGuard g; + + if (rPropertyName == "FieldPositions") + { + uno::Sequence<sal_Int32> ret(maConversionMap.getFieldPositions().size()); + std::copy(maConversionMap.getFieldPositions().begin(), + maConversionMap.getFieldPositions().end(), ret.begin()); + return uno::makeAny(ret); + } + else if (rPropertyName == "FootnotePositions") + { + uno::Sequence<sal_Int32> ret(maConversionMap.getFootnotePositions().size()); + std::copy(maConversionMap.getFootnotePositions().begin(), + maConversionMap.getFootnotePositions().end(), ret.begin()); + return uno::makeAny(ret); + } + return uno::Any(); +} + +void SAL_CALL +SwXFlatParagraph::addPropertyChangeListener( + const OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException, std::exception) +{ + SAL_WARN("sw.uno", + "SwXFlatParagraph::addPropertyChangeListener(): not implemented"); +} + +void SAL_CALL +SwXFlatParagraph::removePropertyChangeListener( + const OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException, std::exception) +{ + SAL_WARN("sw.uno", + "SwXFlatParagraph::removePropertyChangeListener(): not implemented"); +} + +void SAL_CALL +SwXFlatParagraph::addVetoableChangeListener( + const OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException, std::exception) +{ + SAL_WARN("sw.uno", + "SwXFlatParagraph::addVetoableChangeListener(): not implemented"); +} + +void SAL_CALL +SwXFlatParagraph::removeVetoableChangeListener( + const OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException, std::exception) +{ + SAL_WARN("sw.uno", + "SwXFlatParagraph::removeVetoableChangeListener(): not implemented"); +} + + css::uno::Reference< css::container::XStringKeyMap > SAL_CALL SwXFlatParagraph::getMarkupInfoContainer() throw (css::uno::RuntimeException, std::exception) { return SwXTextMarkup::getMarkupInfoContainer(); |