[Libreoffice-commits] core.git: 5 commits - linguistic/source sw/inc sw/qa sw/source

Michael Stahl mstahl at redhat.com
Tue Apr 8 03:15:59 PDT 2014


 linguistic/source/gciterator.cxx             |   26 ++++-
 sw/inc/modeltoviewhelper.hxx                 |   12 ++
 sw/inc/swscanner.hxx                         |    2 
 sw/qa/core/uwriter.cxx                       |  120 ++++++++++++++++++++++++---
 sw/source/core/inc/unoflatpara.hxx           |   71 +++++++++++++--
 sw/source/core/inc/unotextmarkup.hxx         |    3 
 sw/source/core/ole/ndole.cxx                 |    1 
 sw/source/core/txtnode/modeltoviewhelper.cxx |   33 +++++--
 sw/source/core/txtnode/txtedt.cxx            |   14 +--
 sw/source/core/unocore/unoflatpara.cxx       |   97 +++++++++++++++++----
 sw/source/core/unocore/unotextmarkup.cxx     |    6 -
 11 files changed, 316 insertions(+), 69 deletions(-)

New commits:
commit 44569082041d921e8eeb954efac082a02fa7a5a9
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Apr 7 23:43:33 2014 +0200

    SwXFlatParagraph: use ::cppu::ImplInheritanceHelper
    
    ... instead of manually overriding XInterface/XTypeInfo methods.
    Requires replacing a non-const reference parameter by a pointer in
    base class ctor.
    
    Change-Id: I5847524752cc0bdb595f6ce675a856479f3f8507

diff --git a/sw/source/core/inc/unoflatpara.hxx b/sw/source/core/inc/unoflatpara.hxx
index ceeff51..9d8b2a5 100644
--- a/sw/source/core/inc/unoflatpara.hxx
+++ b/sw/source/core/inc/unoflatpara.hxx
@@ -48,26 +48,20 @@ class SwDoc;
  * SwXFlatParagraph
  ******************************************************************************/
 
-class SwXFlatParagraph:
-    public ::cppu::WeakImplHelper3
-    <
-        css::beans::XPropertySet,
-        css::text::XFlatParagraph,
-        css::lang::XUnoTunnel
-    >,
-    public SwXTextMarkup
+typedef ::cppu::ImplInheritanceHelper3
+<   SwXTextMarkup
+,   css::beans::XPropertySet
+,   css::text::XFlatParagraph
+,   css::lang::XUnoTunnel
+> SwXFlatParagraph_Base;
+
+class SwXFlatParagraph
+    :   public SwXFlatParagraph_Base
 {
 public:
     SwXFlatParagraph( SwTxtNode& rTxtNode, const OUString& aExpandText, const ModelToViewHelper& rConversionMap );
     virtual ~SwXFlatParagraph();
 
-    virtual     ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-    virtual void SAL_CALL acquire(  ) throw() SAL_OVERRIDE;
-    virtual void SAL_CALL release(  ) throw() SAL_OVERRIDE;
-
-    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
diff --git a/sw/source/core/inc/unotextmarkup.hxx b/sw/source/core/inc/unotextmarkup.hxx
index 59b1c36..2b22a95 100644
--- a/sw/source/core/inc/unotextmarkup.hxx
+++ b/sw/source/core/inc/unotextmarkup.hxx
@@ -51,7 +51,8 @@ class SwXTextMarkup:
     public SwClient
 {
 public:
-    SwXTextMarkup( SwTxtNode& rTxtNode, const ModelToViewHelper& rConversionMap );
+    SwXTextMarkup(SwTxtNode *const rTxtNode,
+            const ModelToViewHelper& rConversionMap);
     virtual ~SwXTextMarkup();
 
     // ::com::sun::star::text::XTextMarkup:
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index 8929b0b..5292369 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -1459,8 +1459,8 @@ SwRect SwTxtFrm::SmartTagScan( SwCntntNode* /*pActNode*/, sal_Int32 /*nActPos*/
         OUString aExpandText = aConversionMap.getViewText();
 
         // Ownership ov ConversionMap is passed to SwXTextMarkup object!
-        com::sun::star::uno::Reference< com::sun::star::text::XTextMarkup > xTextMarkup =
-             new SwXTextMarkup( *pNode, aConversionMap );
+        uno::Reference<text::XTextMarkup> const xTextMarkup =
+             new SwXTextMarkup(pNode, aConversionMap);
 
         com::sun::star::uno::Reference< ::com::sun::star::frame::XController > xController = pNode->GetDoc()->GetDocShell()->GetController();
 
diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx
index 6976091..f495655 100644
--- a/sw/source/core/unocore/unoflatpara.cxx
+++ b/sw/source/core/unocore/unoflatpara.cxx
@@ -63,9 +63,9 @@ CreateFlatParagraphIterator(SwDoc & rDoc, sal_Int32 const nTextMarkupType,
  * SwXFlatParagraph
  ******************************************************************************/
 
-SwXFlatParagraph::SwXFlatParagraph( SwTxtNode& rTxtNode, const OUString& aExpandText, const ModelToViewHelper& rMap ) :
-    SwXTextMarkup( rTxtNode, rMap ),
-    maExpandText( aExpandText )
+SwXFlatParagraph::SwXFlatParagraph( SwTxtNode& rTxtNode, const OUString& aExpandText, const ModelToViewHelper& rMap )
+    : SwXFlatParagraph_Base(& rTxtNode, rMap)
+    , maExpandText(aExpandText)
 {
 }
 
@@ -73,43 +73,6 @@ SwXFlatParagraph::~SwXFlatParagraph()
 {
 }
 
-uno::Sequence< uno::Type > SwXFlatParagraph::getTypes(  ) throw(uno::RuntimeException, std::exception)
-{
-    uno::Sequence< uno::Type > aTypes = SwXTextMarkup::getTypes();
-    aTypes.realloc( aTypes.getLength() + 1 );
-    aTypes[aTypes.getLength()-1] = ::getCppuType((uno::Reference< text::XFlatParagraph >*)0);
-    return aTypes;
-}
-
-uno::Sequence< sal_Int8 > SwXFlatParagraph::getImplementationId(  ) throw(uno::RuntimeException, std::exception)
-{
-    return css::uno::Sequence<sal_Int8>();
-}
-
-uno::Any SAL_CALL SwXFlatParagraph::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception)
-{
-    if ( rType == ::getCppuType((uno::Reference< text::XFlatParagraph >*)0) )
-    {
-        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 );
-}
-
-void SAL_CALL SwXFlatParagraph::acquire() throw()
-{
-    SwXTextMarkup::acquire();
-}
-
-void SAL_CALL SwXFlatParagraph::release() throw()
-{
-    SwXTextMarkup::release();
-}
-
 const SwTxtNode* SwXFlatParagraph::getTxtNode() const
 {
     return mpTxtNode;
@@ -121,7 +84,7 @@ SwXFlatParagraph::getPropertySetInfo()
 throw (uno::RuntimeException, std::exception)
 {
     throw uno::RuntimeException("SwXFlatParagraph::getPropertySetInfo(): "
-            "not implemented", 0/*static_cast< ::cppu::OWeakObject*>(this)*/);
+            "not implemented", static_cast< ::cppu::OWeakObject*>(this));
 }
 
 void SAL_CALL
@@ -131,7 +94,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
         uno::RuntimeException, std::exception)
 {
     throw lang::IllegalArgumentException("no values can be set",
-            0/*static_cast< ::cppu::OWeakObject*>(this)*/, 0);
+            static_cast< ::cppu::OWeakObject*>(this), 0);
 }
 
 uno::Any SAL_CALL
diff --git a/sw/source/core/unocore/unotextmarkup.cxx b/sw/source/core/unocore/unotextmarkup.cxx
index de9a987..5df731f 100644
--- a/sw/source/core/unocore/unotextmarkup.cxx
+++ b/sw/source/core/unocore/unotextmarkup.cxx
@@ -43,8 +43,10 @@ using namespace ::com::sun::star;
 /*
  * SwXTextMarkup
  */
-SwXTextMarkup::SwXTextMarkup( SwTxtNode& rTxtNode, const ModelToViewHelper& rMap )
-    : mpTxtNode( &rTxtNode ), maConversionMap( rMap )
+SwXTextMarkup::SwXTextMarkup(
+        SwTxtNode *const pTxtNode, const ModelToViewHelper& rMap)
+    : mpTxtNode(pTxtNode)
+    , maConversionMap(rMap)
 {
     // FME 2007-07-16 #i79641# SwXTextMarkup is allowed to be removed ...
     SetIsAllowedToBeRemovedInModifyCall(true);
commit d477ff4a81ecba8a77ead5ff1a33d3e3ceed622e
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Apr 7 23:22:22 2014 +0200

    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

diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx
index 73c010b..6f01230 100644
--- a/linguistic/source/gciterator.cxx
+++ b/linguistic/source/gciterator.cxx
@@ -489,6 +489,20 @@ uno::Reference< linguistic2::XProofreader > GrammarCheckingIterator::GetGrammarC
     return xRes;
 }
 
+static uno::Sequence<beans::PropertyValue>
+lcl_makeProperties(uno::Reference<text::XFlatParagraph> const& xFlatPara)
+{
+    uno::Sequence<beans::PropertyValue> ret(2);
+    uno::Reference<beans::XPropertySet> const xProps(
+            xFlatPara, uno::UNO_QUERY_THROW);
+    ret[0] = beans::PropertyValue("FieldPositions", -1,
+        xProps->getPropertyValue("FieldPositions"),
+        beans::PropertyState_DIRECT_VALUE);
+    ret[1] = beans::PropertyValue("FootnotePositions", -1,
+        xProps->getPropertyValue("FootnotePositions"),
+        beans::PropertyState_DIRECT_VALUE);
+    return ret;
+}
 
 void GrammarCheckingIterator::DequeueAndCheck()
 {
@@ -548,8 +562,10 @@ void GrammarCheckingIterator::DequeueAndCheck()
                     if (xGC.is())
                     {
                         aGuard.clear();
-                        uno::Sequence< beans::PropertyValue > aEmptyProps;
-                        aRes = xGC->doProofreading( aCurDocId, aCurTxt, aCurLocale, nStartPos, nSuggestedEnd, aEmptyProps );
+                        uno::Sequence<beans::PropertyValue> const aProps(
+                                lcl_makeProperties(xFlatPara));
+                        aRes = xGC->doProofreading( aCurDocId, aCurTxt,
+                                aCurLocale, nStartPos, nSuggestedEnd, aProps );
 
                         //!! work-around to prevent looping if the grammar checker
                         //!! failed to properly identify the sentence end
@@ -696,8 +712,10 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
             sal_Int32 nEndPos = -1;
             if (xGC.is())
             {
-                uno::Sequence< beans::PropertyValue > aEmptyProps;
-                aTmpRes = xGC->doProofreading( aDocId, rText, aCurLocale, nStartPos, nSuggestedEndOfSentencePos, aEmptyProps );
+                uno::Sequence<beans::PropertyValue> const aProps(
+                        lcl_makeProperties(xFlatPara));
+                aTmpRes = xGC->doProofreading( aDocId, rText,
+                    aCurLocale, nStartPos, nSuggestedEndOfSentencePos, aProps );
 
                 //!! work-around to prevent looping if the grammar checker
                 //!! failed to properly identify the sentence end
diff --git a/sw/inc/modeltoviewhelper.hxx b/sw/inc/modeltoviewhelper.hxx
index 82ec6da..018b67c 100644
--- a/sw/inc/modeltoviewhelper.hxx
+++ b/sw/inc/modeltoviewhelper.hxx
@@ -66,6 +66,8 @@ class SwTxtNode;
 #define EXPANDFOOTNOTE 0x0002
 #define HIDEINVISIBLE  0x0004
 #define HIDEREDLINED   0x0008
+/// do not expand to content, but replace with ZWSP
+#define REPLACEMODE    0x0010
 
 class ModelToViewHelper
 {
@@ -77,8 +79,12 @@ class ModelToViewHelper
     */
     typedef std::pair< sal_Int32 , sal_Int32 > ConversionMapEntry;
     typedef std::vector< ConversionMapEntry > ConversionMap;
+    typedef std::vector<sal_Int32> Positions;
 
     ConversionMap m_aMap;
+    /// store positions of fields and footnotes for grammar checkers
+    Positions m_FieldPositions;
+    Positions m_FootnotePositions;
 
     OUString m_aRetText;
 
@@ -99,7 +105,9 @@ public:
         ModelPosition() : mnPos(0), mnSubPos(0), mbIsField(false) {}
     };
 
-    ModelToViewHelper(const SwTxtNode &rNode, sal_uInt16 eMode = EXPANDFIELDS | EXPANDFOOTNOTE);
+    ModelToViewHelper(const SwTxtNode &rNode,
+            // defaults are appropriate for spell/grammar checking
+            sal_uInt16 eMode = EXPANDFIELDS | EXPANDFOOTNOTE | REPLACEMODE);
     ModelToViewHelper() //pass through filter, view == model
     {
     }
@@ -135,6 +143,8 @@ public:
     ModelPosition ConvertToModelPosition( sal_Int32 nViewPos ) const;
 
     OUString getViewText() const { return m_aRetText; }
+    Positions const& getFieldPositions() const { return m_FieldPositions; }
+    Positions const& getFootnotePositions() const { return m_FootnotePositions;}
 };
 
 #endif
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index 535813f..3d5b010 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -269,6 +269,22 @@ void SwDocTest::testModelToViewHelper()
             CPPUNIT_ASSERT_EQUAL(
                 OUString("AAAAA BBBBB foo CCCCC foo DDDDD"), sViewText);
         }
+        {
+            ModelToViewHelper aModelToViewHelper(*pTxtNode,
+                    EXPANDFIELDS | EXPANDFOOTNOTE | REPLACEMODE);
+            OUString sViewText = aModelToViewHelper.getViewText();
+            CPPUNIT_ASSERT_EQUAL(
+                OUString("AAAAA BBBBB " + OUString(CHAR_ZWSP) + " CCCCC " + OUString(CHAR_ZWSP) + " DDDDD"),
+                sViewText);
+            CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2),
+                aModelToViewHelper.getFootnotePositions().size());
+            CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(12),
+                aModelToViewHelper.getFootnotePositions()[0]);
+            CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(20),
+                aModelToViewHelper.getFootnotePositions()[1]);
+            CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0),
+                aModelToViewHelper.getFieldPositions().size());
+        }
 
         {
             ModelToViewHelper aModelToViewHelper(*pTxtNode, EXPANDFIELDS);
@@ -276,6 +292,23 @@ void SwDocTest::testModelToViewHelper()
             CPPUNIT_ASSERT_EQUAL(
                 OUString("AAAAA BBBBB  CCCCC  DDDDD"), sViewText);
         }
+        {
+            ModelToViewHelper aModelToViewHelper(*pTxtNode,
+                EXPANDFIELDS | REPLACEMODE);
+            OUString sViewText = aModelToViewHelper.getViewText();
+            CPPUNIT_ASSERT_EQUAL(OUString("AAAAA BBBBB  CCCCC  DDDDD"),
+                sViewText);
+            // ??? is it a problem that we get the positions without
+            // EXPANDFOOTNOTE when it's completely removed?
+            CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2),
+                aModelToViewHelper.getFootnotePositions().size());
+            CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(12),
+                aModelToViewHelper.getFootnotePositions()[0]);
+            CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(19),
+                aModelToViewHelper.getFootnotePositions()[1]);
+            CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0),
+                aModelToViewHelper.getFieldPositions().size());
+        }
 
         {
             ModelToViewHelper aModelToViewHelper(*pTxtNode, HIDEINVISIBLE);
@@ -298,6 +331,20 @@ void SwDocTest::testModelToViewHelper()
             OUString sViewText = aModelToViewHelper.getViewText();
             CPPUNIT_ASSERT_EQUAL(OUString("AAAAA CCCCC foo DDDDD"), sViewText);
         }
+        {
+            ModelToViewHelper aModelToViewHelper(*pTxtNode,
+                EXPANDFIELDS | HIDEINVISIBLE | EXPANDFOOTNOTE | REPLACEMODE);
+            OUString sViewText = aModelToViewHelper.getViewText();
+            CPPUNIT_ASSERT_EQUAL(
+                OUString("AAAAA CCCCC " + OUString(CHAR_ZWSP) + " DDDDD"),
+                sViewText);
+            CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1),
+                aModelToViewHelper.getFootnotePositions().size());
+            CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(12),
+                aModelToViewHelper.getFootnotePositions()[0]);
+            CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0),
+                aModelToViewHelper.getFieldPositions().size());
+        }
 
         {
             ModelToViewHelper aModelToViewHelper(*pTxtNode, EXPANDFIELDS | HIDEREDLINED | EXPANDFOOTNOTE);
@@ -305,6 +352,22 @@ void SwDocTest::testModelToViewHelper()
             CPPUNIT_ASSERT_EQUAL(
                 OUString("AAAABB foo CCCCC foo DDDDD"), sViewText);
         }
+        {
+            ModelToViewHelper aModelToViewHelper(*pTxtNode,
+                EXPANDFIELDS | HIDEREDLINED | EXPANDFOOTNOTE | REPLACEMODE);
+            OUString sViewText = aModelToViewHelper.getViewText();
+            CPPUNIT_ASSERT_EQUAL(
+               OUString("AAAABB " + OUString(CHAR_ZWSP) + " CCCCC " + OUString(CHAR_ZWSP) + " DDDDD"),
+               sViewText);
+            CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2),
+                aModelToViewHelper.getFootnotePositions().size());
+            CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(7),
+                aModelToViewHelper.getFootnotePositions()[0]);
+            CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(15),
+                aModelToViewHelper.getFootnotePositions()[1]);
+            CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0),
+                aModelToViewHelper.getFieldPositions().size());
+        }
 
         {
             ModelToViewHelper aModelToViewHelper(*pTxtNode, HIDEINVISIBLE | HIDEREDLINED);
@@ -321,6 +384,19 @@ void SwDocTest::testModelToViewHelper()
             OUString sViewText = aModelToViewHelper.getViewText();
             CPPUNIT_ASSERT_EQUAL(OUString("AAAACCCCC foo DDDDD"), sViewText);
         }
+        {
+            ModelToViewHelper aModelToViewHelper(*pTxtNode,
+                EXPANDFIELDS | HIDEINVISIBLE | HIDEREDLINED | EXPANDFOOTNOTE | REPLACEMODE);
+            OUString sViewText = aModelToViewHelper.getViewText();
+            CPPUNIT_ASSERT_EQUAL(sViewText,
+                OUString("AAAACCCCC " + OUString(CHAR_ZWSP) + " DDDDD"));
+            CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1),
+                aModelToViewHelper.getFootnotePositions().size());
+            CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(10),
+                aModelToViewHelper.getFootnotePositions()[0]);
+            CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0),
+                aModelToViewHelper.getFieldPositions().size());
+        }
 
         m_pDoc->AppendTxtNode(*aPaM.GetPoint());
         m_pDoc->InsertString(aPaM, OUString("AAAAA"));
@@ -341,6 +417,20 @@ void SwDocTest::testModelToViewHelper()
             OUString sViewText = aModelToViewHelper.getViewText();
             CPPUNIT_ASSERT_EQUAL(OUString("AAAAABBBBBCCCCC"), sViewText);
         }
+        {
+            ModelToViewHelper aModelToViewHelper(*pTxtNode,
+                EXPANDFIELDS | EXPANDFOOTNOTE | REPLACEMODE);
+            OUString sViewText = aModelToViewHelper.getViewText();
+            CPPUNIT_ASSERT_EQUAL(
+                OUString("AAAAA" + OUString(CHAR_ZWSP) + "CCCCC"),
+                sViewText);
+            CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0),
+                aModelToViewHelper.getFootnotePositions().size());
+            CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1),
+                aModelToViewHelper.getFieldPositions().size());
+            CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(5),
+                aModelToViewHelper.getFieldPositions()[0]);
+        }
     }
 }
 
diff --git a/sw/source/core/inc/unoflatpara.hxx b/sw/source/core/inc/unoflatpara.hxx
index af4db77..ceeff51 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 2a338ad..085d3c5 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 417c3cf..8929b0b 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 80817cda..6976091 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();
commit bda01cf116c324e4082c7cffb156dc2d5fee9d3d
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Apr 7 22:11:05 2014 +0200

    convert testModelToViewHelper to CPPUNIT_ASSERT_EQUALS
    
    Change-Id: I27cd49adeb5b7bcf1e793b230bf0b41e46527702

diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index b6d8dee..535813f 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -260,43 +260,50 @@ void SwDocTest::testModelToViewHelper()
             ModelToViewHelper aModelToViewHelper(*pTxtNode, PASSTHROUGH);
             OUString sViewText = aModelToViewHelper.getViewText();
             OUString sModelText = pTxtNode->GetTxt();
-            CPPUNIT_ASSERT(sViewText == sModelText);
+            CPPUNIT_ASSERT_EQUAL(sModelText, sViewText);
         }
 
         {
             ModelToViewHelper aModelToViewHelper(*pTxtNode, EXPANDFIELDS | EXPANDFOOTNOTE);
             OUString sViewText = aModelToViewHelper.getViewText();
-            CPPUNIT_ASSERT(sViewText == "AAAAA BBBBB foo CCCCC foo DDDDD");
+            CPPUNIT_ASSERT_EQUAL(
+                OUString("AAAAA BBBBB foo CCCCC foo DDDDD"), sViewText);
         }
 
         {
             ModelToViewHelper aModelToViewHelper(*pTxtNode, EXPANDFIELDS);
             OUString sViewText = aModelToViewHelper.getViewText();
-            CPPUNIT_ASSERT(sViewText == "AAAAA BBBBB  CCCCC  DDDDD");
+            CPPUNIT_ASSERT_EQUAL(
+                OUString("AAAAA BBBBB  CCCCC  DDDDD"), sViewText);
         }
 
         {
             ModelToViewHelper aModelToViewHelper(*pTxtNode, HIDEINVISIBLE);
             OUString sViewText = aModelToViewHelper.getViewText();
-            CPPUNIT_ASSERT(sViewText == "AAAAA CCCCC " + OUString(CH_TXTATR_BREAKWORD) + " DDDDD");
+            CPPUNIT_ASSERT_EQUAL(
+                OUString("AAAAA CCCCC " + OUString(CH_TXTATR_BREAKWORD) + " DDDDD"),
+                sViewText);
         }
 
         {
             ModelToViewHelper aModelToViewHelper(*pTxtNode, HIDEREDLINED);
             OUString sViewText = aModelToViewHelper.getViewText();
-            CPPUNIT_ASSERT(sViewText == "AAAABB " + OUString(CH_TXTATR_BREAKWORD) + " CCCCC " + OUString(CH_TXTATR_BREAKWORD) + " DDDDD");
+            CPPUNIT_ASSERT_EQUAL(
+                OUString("AAAABB " + OUString(CH_TXTATR_BREAKWORD) + " CCCCC " + OUString(CH_TXTATR_BREAKWORD) + " DDDDD"),
+                sViewText);
         }
 
         {
             ModelToViewHelper aModelToViewHelper(*pTxtNode, EXPANDFIELDS | HIDEINVISIBLE | EXPANDFOOTNOTE);
             OUString sViewText = aModelToViewHelper.getViewText();
-            CPPUNIT_ASSERT(sViewText == "AAAAA CCCCC foo DDDDD");
+            CPPUNIT_ASSERT_EQUAL(OUString("AAAAA CCCCC foo DDDDD"), sViewText);
         }
 
         {
             ModelToViewHelper aModelToViewHelper(*pTxtNode, EXPANDFIELDS | HIDEREDLINED | EXPANDFOOTNOTE);
             OUString sViewText = aModelToViewHelper.getViewText();
-            CPPUNIT_ASSERT(sViewText == "AAAABB foo CCCCC foo DDDDD");
+            CPPUNIT_ASSERT_EQUAL(
+                OUString("AAAABB foo CCCCC foo DDDDD"), sViewText);
         }
 
         {
@@ -306,13 +313,13 @@ void SwDocTest::testModelToViewHelper()
             aBuffer.append("AAAACCCCC ");
             aBuffer.append(CH_TXTATR_BREAKWORD);
             aBuffer.append(" DDDDD");
-            CPPUNIT_ASSERT(sViewText == aBuffer.makeStringAndClear());
+            CPPUNIT_ASSERT_EQUAL(aBuffer.makeStringAndClear(), sViewText);
         }
 
         {
             ModelToViewHelper aModelToViewHelper(*pTxtNode, EXPANDFIELDS | HIDEINVISIBLE | HIDEREDLINED | EXPANDFOOTNOTE);
             OUString sViewText = aModelToViewHelper.getViewText();
-            CPPUNIT_ASSERT(sViewText == "AAAACCCCC foo DDDDD");
+            CPPUNIT_ASSERT_EQUAL(OUString("AAAACCCCC foo DDDDD"), sViewText);
         }
 
         m_pDoc->AppendTxtNode(*aPaM.GetPoint());
@@ -327,13 +334,12 @@ void SwDocTest::testModelToViewHelper()
         (*pFieldmark->GetParameters())[ODF_FORMDROPDOWN_RESULT] = uno::makeAny(sal_Int32(0));
         m_pDoc->InsertString(aPaM, OUString("CCCCC"));
         pTxtNode = aPaM.GetNode()->GetTxtNode();
-        CPPUNIT_ASSERT(pTxtNode->GetTxt().getLength() == 11);
+        CPPUNIT_ASSERT_EQUAL(11, pTxtNode->GetTxt().getLength());
 
         {
             ModelToViewHelper aModelToViewHelper(*pTxtNode, EXPANDFIELDS | EXPANDFOOTNOTE);
             OUString sViewText = aModelToViewHelper.getViewText();
-            fprintf(stderr, "string is %s\n", OUStringToOString(sViewText, RTL_TEXTENCODING_UTF8).getStr());
-            CPPUNIT_ASSERT(sViewText == "AAAAABBBBBCCCCC");
+            CPPUNIT_ASSERT_EQUAL(OUString("AAAAABBBBBCCCCC"), sViewText);
         }
     }
 }
commit 6c59177ba3a4f005c79f086b28cafd63332bf3de
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Apr 7 17:34:55 2014 +0200

    rename misleading SwScanner::rConversionMap
    
    Change-Id: I6f93eae5377c95ec47348b01b3414855b05a525e

diff --git a/sw/inc/swscanner.hxx b/sw/inc/swscanner.hxx
index e9f4c46..49ce2e2 100644
--- a/sw/inc/swscanner.hxx
+++ b/sw/inc/swscanner.hxx
@@ -38,7 +38,7 @@ class SwScanner
     const OUString aPreDashReplacementText;
     OUString aText;
     const LanguageType* pLanguage;
-    const ModelToViewHelper rConversionMap;
+    const ModelToViewHelper m_ModelToView;
     sal_Int32 nStartPos;
     sal_Int32 nEndPos;
     sal_Int32 nBegin;
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index 3c8adbe..417c3cf 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -705,7 +705,7 @@ SwScanner::SwScanner( const SwTxtNode& rNd, const OUString& rTxt,
     : rNode( rNd )
     , aPreDashReplacementText(rTxt)
     , pLanguage( pLang )
-    , rConversionMap( rConvMap )
+    , m_ModelToView( rConvMap )
     , nLen( 0 )
     , nOverriddenDashCount( 0 )
     , nWordType( nType )
@@ -746,7 +746,8 @@ SwScanner::SwScanner( const SwTxtNode& rNd, const OUString& rTxt,
     }
     else
     {
-        ModelToViewHelper::ModelPosition aModelBeginPos = rConversionMap.ConvertToModelPosition( nBegin );
+        ModelToViewHelper::ModelPosition aModelBeginPos =
+            m_ModelToView.ConvertToModelPosition( nBegin );
         aCurrLang = rNd.GetLang( aModelBeginPos.mnPos );
     }
 }
@@ -807,7 +808,8 @@ sal_Bool SwScanner::NextWord()
                 if ( !pLanguage )
                 {
                     const sal_uInt16 nNextScriptType = g_pBreakIt->GetBreakIter()->getScriptType( aText, nBegin );
-                    ModelToViewHelper::ModelPosition aModelBeginPos = rConversionMap.ConvertToModelPosition( nBegin );
+                    ModelToViewHelper::ModelPosition aModelBeginPos =
+                        m_ModelToView.ConvertToModelPosition( nBegin );
                     aCurrLang = rNode.GetLang( aModelBeginPos.mnPos, 1, nNextScriptType );
                 }
 
commit e89caa7db17676e6f5889fa9ac3ef3592ef2e9b4
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Apr 7 10:41:23 2014 +0200

    remove useless comment
    
    Change-Id: Icdd19fe060735a3efcebbbf5efd97841afa59dad

diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx
index 8208613..84144f2 100644
--- a/sw/source/core/ole/ndole.cxx
+++ b/sw/source/core/ole/ndole.cxx
@@ -357,7 +357,6 @@ bool SwOLENode::SavePersistentData()
             }
 
             pCnt->RemoveEmbeddedObject( aOLEObj.aName, false, bKeepObjectToTempStorage );
-            // modify end
 
             // TODO/LATER: aOLEObj.aName has no meaning here, since the undo container contains the object
             // by different name, in future it might makes sence that the name is transported here.


More information about the Libreoffice-commits mailing list