summaryrefslogtreecommitdiff
path: root/sw/inc
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-07-20 16:11:08 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-07-26 16:38:05 +0100
commit331e4d03a70900bc390b376f4073d0efd868b919 (patch)
treef4bd121485872447062e30001758670d9700aa85 /sw/inc
parente5e85f2987a27db7efb2b24039b5c1ddf3f5d90e (diff)
refactor ModelToViewHelper, should have unchanged results
Change-Id: Ib57f0d6f9491d12ffacada5ec0ae8bc68874c25b
Diffstat (limited to 'sw/inc')
-rw-r--r--sw/inc/modeltoviewhelper.hxx33
-rw-r--r--sw/inc/ndtxt.hxx3
-rw-r--r--sw/inc/swscanner.hxx4
-rw-r--r--sw/inc/unoflatpara.hxx2
-rw-r--r--sw/inc/unotextmarkup.hxx7
5 files changed, 24 insertions, 25 deletions
diff --git a/sw/inc/modeltoviewhelper.hxx b/sw/inc/modeltoviewhelper.hxx
index a1ee88e3965a..c7a80c5b4278 100644
--- a/sw/inc/modeltoviewhelper.hxx
+++ b/sw/inc/modeltoviewhelper.hxx
@@ -20,10 +20,12 @@
#ifndef _MODELTOVIEWHELPER_HXX
#define _MODELTOVIEWHELPER_HXX
+#include <rtl/ustring.hxx>
#include <sal/types.h>
-
#include <vector>
+class SwTxtNode;
+
/** Some helpers for converting model strings to view strings.
A paragraph string does not have its fields expanded, i.e., they are
@@ -33,7 +35,7 @@
helper functions are provided to convert model positions to view positions
and vice versa.
*/
-namespace ModelToViewHelper
+class ModelToViewHelper
{
/** For each field in the model string, there is an entry in the conversion
map. The first value of the ConversionMapEntry points to the field
@@ -44,6 +46,12 @@ namespace ModelToViewHelper
typedef std::pair< sal_uInt32 , sal_uInt32 > ConversionMapEntry;
typedef std::vector< ConversionMapEntry > ConversionMap;
+ ConversionMap m_aMap;
+
+ rtl::OUString m_aRetText;
+
+public:
+
/** This struct defines a position in the model string.
The 'main' position is given by mnPos. If there's a field located at
@@ -59,12 +67,10 @@ namespace ModelToViewHelper
ModelPosition() : mnPos(0), mnSubPos(0), mbIsField(false) {}
};
- /** Converts a model position into a view position
+ ModelToViewHelper(const SwTxtNode &rNode);
+ ModelToViewHelper() {} //pass through filter, view == model
- @param pMap
- pMap is the conversion map required for the calculation. If pMap is
- 0, no conversion takes place, i.e., it is assumed that the model
- string is identical to the view string.
+ /** Converts a model position into a view position
@param nPos
nPos denotes a position in the model string which should be
@@ -77,15 +83,10 @@ namespace ModelToViewHelper
nPos is behind the last entry in the conversion map) nPos will
be returned.
*/
- sal_uInt32 ConvertToViewPosition( const ConversionMap* pMap, sal_uInt32 nModelPos );
+ sal_uInt32 ConvertToViewPosition( sal_uInt32 nModelPos ) const;
/** Converts a view position into a model position
- @param pMap
- pMap is the conversion map required for the calculation. If pMap is
- 0, no conversion takes place, i.e., it is assumed that the model
- string is identical to the view string.
-
@param nPos
nPos denotes a position in the view string which should be
converted.
@@ -97,8 +98,10 @@ namespace ModelToViewHelper
model position with mnPos = nPos and mnIsField = false will be
returned.
*/
- ModelPosition ConvertToModelPosition( const ConversionMap* pMap, sal_uInt32 nViewPos );
-}
+ ModelPosition ConvertToModelPosition( sal_uInt32 nViewPos ) const;
+
+ rtl::OUString getViewText() const { return m_aRetText; }
+};
#endif
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index 83b3e2f35a4a..39565cf4a6fd 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -699,9 +699,6 @@ public:
sal_Bool bWithNum = sal_False, sal_Bool bWithFtn = sal_True,
sal_Bool bReplaceTabsWithSpaces = sal_False ) const;
- const ModelToViewHelper::ConversionMap*
- BuildConversionMap( rtl::OUString& rExpandText ) const;
-
XubString GetRedlineTxt( xub_StrLen nIdx = 0,
xub_StrLen nLen = STRING_LEN,
sal_Bool bExpandFlds = sal_False,
diff --git a/sw/inc/swscanner.hxx b/sw/inc/swscanner.hxx
index 3c059950ddb4..f657f238c2ca 100644
--- a/sw/inc/swscanner.hxx
+++ b/sw/inc/swscanner.hxx
@@ -45,7 +45,7 @@ class SwScanner
const SwTxtNode& rNode;
const rtl::OUString aText;
const LanguageType* pLanguage;
- const ModelToViewHelper::ConversionMap* pConversionMap;
+ const ModelToViewHelper& rConversionMap;
sal_Int32 nStartPos;
sal_Int32 nEndPos;
sal_Int32 nBegin;
@@ -57,7 +57,7 @@ class SwScanner
public:
SwScanner( const SwTxtNode& rNd, const rtl::OUString& rTxt,
const LanguageType* pLang,
- const ModelToViewHelper::ConversionMap* pConvMap,
+ const ModelToViewHelper& rConvMap,
sal_uInt16 nWordType,
sal_Int32 nStart, sal_Int32 nEnde, sal_Bool bClip = sal_False );
diff --git a/sw/inc/unoflatpara.hxx b/sw/inc/unoflatpara.hxx
index b728dcdd32e3..310ff80cd7af 100644
--- a/sw/inc/unoflatpara.hxx
+++ b/sw/inc/unoflatpara.hxx
@@ -52,7 +52,7 @@ class SwXFlatParagraph:
public SwXTextMarkup
{
public:
- SwXFlatParagraph( SwTxtNode& rTxtNode, rtl::OUString aExpandText, const ModelToViewHelper::ConversionMap* pConversionMap );
+ SwXFlatParagraph( SwTxtNode& rTxtNode, rtl::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);
diff --git a/sw/inc/unotextmarkup.hxx b/sw/inc/unotextmarkup.hxx
index d918b8d6cb13..de7aa158399c 100644
--- a/sw/inc/unotextmarkup.hxx
+++ b/sw/inc/unotextmarkup.hxx
@@ -47,7 +47,7 @@ class SwXTextMarkup:
public SwClient
{
public:
- SwXTextMarkup( SwTxtNode& rTxtNode, const ModelToViewHelper::ConversionMap* pConversionMap );
+ SwXTextMarkup( SwTxtNode& rTxtNode, const ModelToViewHelper& rConversionMap );
virtual ~SwXTextMarkup();
// ::com::sun::star::text::XTextMarkup:
@@ -63,11 +63,10 @@ private:
protected:
//SwClient
- virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
+ virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
SwTxtNode* mpTxtNode;
- const ModelToViewHelper::ConversionMap* mpConversionMap;
-
+ const ModelToViewHelper maConversionMap;
};