[Libreoffice-commits] .: 6 commits - lotuswordpro/qa sfx2/inc sfx2/source solenv/bin svtools/source sw/inc sw/qa sw/source unotest/inc unotest/source unusedcode.easy
Caolán McNamara
caolan at kemper.freedesktop.org
Thu Jul 26 08:39:06 PDT 2012
lotuswordpro/qa/cppunit/data/fail/CVE-2012-1770-1.lwp |binary
sfx2/inc/sfx2/docfile.hxx | 9 ---
sfx2/source/doc/docfile.cxx | 29 ------------
solenv/bin/make_installer.pl | 2
svtools/source/misc/embedhlp.cxx | 25 +++++++---
sw/inc/modeltoviewhelper.hxx | 33 +++++++-------
sw/inc/ndtxt.hxx | 3 -
sw/inc/swscanner.hxx | 4 -
sw/inc/unoflatpara.hxx | 2
sw/inc/unotextmarkup.hxx | 7 +--
sw/qa/core/swdoc-test.cxx | 2
sw/source/core/doc/docedt.cxx | 22 ++++-----
sw/source/core/edit/edlingu.cxx | 19 +++-----
sw/source/core/text/porlay.cxx | 2
sw/source/core/txtnode/modeltoviewhelper.cxx | 21 ++-------
sw/source/core/txtnode/ndtxt.cxx | 28 +++---------
sw/source/core/txtnode/txtedt.cxx | 41 ++++++++----------
sw/source/core/unocore/unoflatpara.cxx | 25 ++++------
sw/source/core/unocore/unotextmarkup.cxx | 29 ++++++------
unotest/inc/unotest/filters-test.hxx | 5 +-
unotest/source/cpp/filters-test.cxx | 15 ++++--
unusedcode.easy | 15 ------
22 files changed, 138 insertions(+), 200 deletions(-)
New commits:
commit 97e3a9a3a62e52821f5f3389931d109a9070ec40
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Jul 26 16:36:47 2012 +0100
callcatcher: update used code post-stlification
Change-Id: Ife742cfbb5295fafe36ba608744a3b3e356cc061
diff --git a/sfx2/inc/sfx2/docfile.hxx b/sfx2/inc/sfx2/docfile.hxx
index 044ae4b..563fd0f 100644
--- a/sfx2/inc/sfx2/docfile.hxx
+++ b/sfx2/inc/sfx2/docfile.hxx
@@ -100,13 +100,7 @@ public:
SfxMedium( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
const String& rBaseURL,
- const SfxItemSet* pSet=0,
- sal_Bool bRoot = sal_False );
- SfxMedium( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
- const String& rBaseURL,
- const String& rTypeName,
- const SfxItemSet* pSet=0,
- sal_Bool bRoot = sal_False );
+ const SfxItemSet* pSet=0 );
SfxMedium( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs );
~SfxMedium();
@@ -158,7 +152,6 @@ public:
void CloseInStream();
sal_Bool CloseOutStream();
- sal_Bool IsRoot() const;
void CloseStorage();
StreamMode GetOpenMode() const;
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index b0e0640..9924243 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -260,7 +260,6 @@ public:
bool m_bGotDateTime:1;
bool m_bRemoveBackup:1;
bool m_bOriginallyReadOnly:1;
- bool m_bRoot:1;
bool m_bTriedStorage:1;
bool m_bRemote:1;
bool m_bInputStreamIsReadOnly:1;
@@ -334,7 +333,6 @@ SfxMedium_Impl::SfxMedium_Impl( SfxMedium* pAntiImplP ) :
m_bGotDateTime( false ),
m_bRemoveBackup( false ),
m_bOriginallyReadOnly(false),
- m_bRoot(false),
m_bTriedStorage(false),
m_bRemote(false),
m_bInputStreamIsReadOnly(false),
@@ -1436,11 +1434,6 @@ void SfxMedium::CloseZipStorage_Impl()
}
}
-sal_Bool SfxMedium::IsRoot() const
-{
- return pImp->m_bRoot;
-}
-
void SfxMedium::CloseStorage()
{
if ( pImp->xStorage.is() )
@@ -2904,11 +2897,9 @@ SfxMedium::SfxMedium( const ::com::sun::star::uno::Sequence< ::com::sun::star::b
//------------------------------------------------------------------
-SfxMedium::SfxMedium( const uno::Reference < embed::XStorage >& rStor, const String& rBaseURL, const SfxItemSet* p, sal_Bool bRootP ) :
+SfxMedium::SfxMedium( const uno::Reference < embed::XStorage >& rStor, const String& rBaseURL, const SfxItemSet* p ) :
pImp(new SfxMedium_Impl(this))
{
- pImp->m_bRoot = bRootP;
-
String aType = SfxFilter::GetTypeFromStorage( rStor );
pImp->m_pFilter = SFX_APP()->GetFilterMatcher().GetFilter4EA( aType );
DBG_ASSERT( pImp->m_pFilter, "No Filter for storage found!" );
@@ -2923,24 +2914,6 @@ SfxMedium::SfxMedium( const uno::Reference < embed::XStorage >& rStor, const Str
GetItemSet()->Put( *p );
}
-SfxMedium::SfxMedium( const uno::Reference < embed::XStorage >& rStor, const String& rBaseURL, const String& rTypeName, const SfxItemSet* p, sal_Bool bRootP ) :
- pImp(new SfxMedium_Impl(this))
-{
- pImp->m_bRoot = bRootP;
-
- pImp->m_pFilter = SFX_APP()->GetFilterMatcher().GetFilter4EA( rTypeName );
- DBG_ASSERT( pImp->m_pFilter, "No Filter for storage found!" );
-
- Init_Impl();
- pImp->xStorage = rStor;
- pImp->bDisposeStorage = false;
-
- // always take BaseURL first, could be overwritten by ItemSet
- GetItemSet()->Put( SfxStringItem( SID_DOC_BASEURL, rBaseURL ) );
- if ( p )
- GetItemSet()->Put( *p );
-}
-
//------------------------------------------------------------------
SfxMedium::~SfxMedium()
diff --git a/unusedcode.easy b/unusedcode.easy
index 87728a5..6935075 100755
--- a/unusedcode.easy
+++ b/unusedcode.easy
@@ -40,7 +40,7 @@ ScVbaFormat<ooo::vba::excel::XStyle>::setNumberFormat(com::sun::star::lang::Loca
ScXMLExport::HasDrawPages(com::sun::star::uno::Reference<com::sun::star::sheet::XSpreadsheetDocument>&)
ScXMLImport::GetVisibleSheet()
SecurityEnvironment_NssImpl::getImplementation(com::sun::star::uno::Reference<com::sun::star::uno::XInterface>)
-SfxMedium::SfxMedium(com::sun::star::uno::Reference<com::sun::star::embed::XStorage> const&, String const&, String const&, SfxItemSet const*, unsigned char)
+SmRtfExport::HandleUnaryOperation(SmUnHorNode const*, int)
SotStorage::GetProperty(String const&, String const&, com::sun::star::uno::Any&)
SpinButton::SpinButton(Window*, ResId const&)
SrchAttrItemList::Replace(SearchAttrItem const&, unsigned short)
@@ -54,7 +54,6 @@ String::String(unsigned short const*, unsigned short)
SvPtrarr::Replace(void* const&, unsigned short)
SvPtrarr::Replace(void* const*, unsigned short, unsigned short)
SvPtrarr::_ForEach(unsigned short, unsigned short, unsigned char (*)(void* const&, void*), void*)
-SvStringsISortDtor::Insert(String* const*, unsigned short)
SvXMLAutoStylePoolNamesP_Impl::GetPos(rtl::OUString const*) const
SvXMLAutoStylePoolNamesP_Impl::Remove(rtl::OUString*)
SvXMLAutoStylePoolParentsP_Impl::GetPos(SvXMLAutoStylePoolParentP_Impl const*) const
@@ -77,9 +76,6 @@ SwBlockNames::Insert(SwBlockName const**, unsigned short)
SwBlockNames::Insert(SwBlockNames const*, unsigned short, unsigned short)
SwBlockNames::Remove(SwBlockName const*&, unsigned short)
SwBlockNames::Remove(unsigned short, unsigned short)
-SwOutlineNodes::Insert(SwNode* const&, unsigned short&)
-SwOutlineNodes::Insert(SwNode* const*, unsigned short)
-SwOutlineNodes::Insert(SwOutlineNodes const*, unsigned short, unsigned short)
SwRects::Replace(SwRect const&, unsigned short)
SwRects::Replace(SwRect const*, unsigned short, unsigned short)
SwRects::_ForEach(unsigned short, unsigned short, unsigned char (*)(SwRect const&, void*), void*)
@@ -90,15 +86,6 @@ SwSortElements::Insert(SwSortElement* const*, unsigned short)
SwSortElements::Insert(SwSortElements const*, unsigned short, unsigned short)
SwSortElements::Remove(SwSortElement* const&, unsigned short)
SwSortElements::Remove(unsigned short, unsigned short)
-SwSortTableLines::DeleteAndDestroy(unsigned short, unsigned short)
-SwSortTableLines::Insert(SwTableLine* const&)
-SwSortTableLines::Insert(SwTableLine* const&, unsigned short&)
-SwSortTableLines::Insert(SwTableLine* const*, unsigned short)
-SwSortTableLines::Remove(SwTableLine* const&, unsigned short)
-SwSortTableLines::Remove(unsigned short, unsigned short)
-SwTableSortBoxes::DeleteAndDestroy(unsigned short, unsigned short)
-SwTableSortBoxes::Insert(SwTableBox* const&, unsigned short&)
-SwTableSortBoxes::Insert(SwTableBox* const*, unsigned short)
SwXMLTableColumnsSortByWidth_Impl::GetPos(SwXMLTableColumn_Impl const*) const
SwXMLTableColumnsSortByWidth_Impl::Remove(SwXMLTableColumn_Impl*)
SwpHtEnd::Insert(SwTxtAttr const*&, unsigned short&)
commit 3c2c2eb46ec70c82ec63ab7cf8096db4cb4fd8a2
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Jul 26 16:35:43 2012 +0100
discard broken embedded object previews
Change-Id: I4f632545d383c4887342aa2959987d4ac3638eb4
diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx
index 6325a76..135ad30 100644
--- a/svtools/source/misc/embedhlp.cxx
+++ b/svtools/source/misc/embedhlp.cxx
@@ -560,16 +560,25 @@ SvStream* EmbeddedObjectRef::GetGraphicStream( sal_Bool bUpdate ) const
{
const sal_Int32 nConstBufferSize = 32000;
SvStream *pStream = new SvMemoryStream( 32000, 32000 );
- sal_Int32 nRead=0;
- uno::Sequence < sal_Int8 > aSequence ( nConstBufferSize );
- do
+ try
+ {
+ sal_Int32 nRead=0;
+ uno::Sequence < sal_Int8 > aSequence ( nConstBufferSize );
+ do
+ {
+ nRead = xStream->readBytes ( aSequence, nConstBufferSize );
+ pStream->Write( aSequence.getConstArray(), nRead );
+ }
+ while ( nRead == nConstBufferSize );
+ pStream->Seek(0);
+ return pStream;
+ }
+ catch (const uno::Exception& ex)
{
- nRead = xStream->readBytes ( aSequence, nConstBufferSize );
- pStream->Write( aSequence.getConstArray(), nRead );
+ SAL_WARN("svtools", "discarding broken embedded object preview: " << ex.Message);
+ delete pStream;
+ xStream.clear();
}
- while ( nRead == nConstBufferSize );
- pStream->Seek(0);
- return pStream;
}
}
commit 69bb7c732d9b4b80c211b031ff40c500b4b02a40
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Jul 26 14:38:22 2012 +0100
regression test for CVE-2012-1770
Change-Id: I2c51a128437913c3bb0bc7a59774ff117603dc82
diff --git a/lotuswordpro/qa/cppunit/data/fail/CVE-2012-1770-1.lwp b/lotuswordpro/qa/cppunit/data/fail/CVE-2012-1770-1.lwp
new file mode 100644
index 0000000..fb4a7e8
Binary files /dev/null and b/lotuswordpro/qa/cppunit/data/fail/CVE-2012-1770-1.lwp differ
commit 23826a28f421d82898cf52a894f6e11ca6ae1fc0
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Jul 26 14:26:10 2012 +0100
use EDB as well as CVE as encrypted prefixes
Change-Id: I3cb1e4d736ca1627cb0716a9c17ff11b5a837264
diff --git a/unotest/inc/unotest/filters-test.hxx b/unotest/inc/unotest/filters-test.hxx
index ab44d81..73cfbe3 100644
--- a/unotest/inc/unotest/filters-test.hxx
+++ b/unotest/inc/unotest/filters-test.hxx
@@ -40,8 +40,9 @@ enum filterStatus
};
/*
- * NOTE, any files beginning with CVE- will be assumed to be encrypted using
- * arcfour with key 0x435645, this is to silence panicky virus/malware-checkers
+ * NOTE, any files beginning with CVE- or EDB- will be assumed to be encrypted
+ * using arcfour with key 0x435645, this is to silence panicky
+ * virus/malware-checkers
*
* e.g. m[de]crypt --bare -a arcfour -o hex -k 435645 -s 3
*/
diff --git a/unotest/source/cpp/filters-test.cxx b/unotest/source/cpp/filters-test.cxx
index 989dd33..f92ce79 100644
--- a/unotest/source/cpp/filters-test.cxx
+++ b/unotest/source/cpp/filters-test.cxx
@@ -87,7 +87,7 @@ void FiltersTest::recursiveScan(const rtl::OUString &rFilter, const rtl::OUStrin
else
{
rtl::OUString sTmpFile;
- bool bCVE = false;
+ bool bEncrypted = false;
sal_Int32 nLastSlash = sURL.lastIndexOf('/');
@@ -97,14 +97,19 @@ void FiltersTest::recursiveScan(const rtl::OUString &rFilter, const rtl::OUStrin
if (sURL.getStr()[nLastSlash+1] == '.')
continue;
- if (sURL.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("CVE"), nLastSlash+1))
- bCVE = true;
+ if (
+ (sURL.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("CVE"), nLastSlash+1)) ||
+ (sURL.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("EDB"), nLastSlash+1))
+ )
+ {
+ bEncrypted = true;
+ }
}
rtl::OString aRes(rtl::OUStringToOString(sURL,
osl_getThreadTextEncoding()));
- if (bCVE)
+ if (bEncrypted)
{
CPPUNIT_ASSERT(osl::FileBase::E_None == osl::FileBase::createTempFile(NULL, NULL, &sTmpFile));
decode(sURL, sTmpFile);
@@ -118,7 +123,7 @@ void FiltersTest::recursiveScan(const rtl::OUString &rFilter, const rtl::OUStrin
bool bRes = load(rFilter, sURL, rUserData);
sal_uInt32 nEndTime = osl_getGlobalTimer();
- if (bCVE)
+ if (bEncrypted)
CPPUNIT_ASSERT(osl::FileBase::E_None == osl::File::remove(sTmpFile));
fprintf(stderr, "%s,%" SAL_PRIuUINT32"\n",
commit 2584a460b5e560fce8719879414311b16b2c63d9
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Jul 26 11:44:28 2012 +0100
just remove logging dir without moaning
Change-Id: I66435c5da113711ecc01d85124dab88411232ee5
diff --git a/solenv/bin/make_installer.pl b/solenv/bin/make_installer.pl
index 914c791..ea77d9f 100644
--- a/solenv/bin/make_installer.pl
+++ b/solenv/bin/make_installer.pl
@@ -248,7 +248,7 @@ installer::control::set_addsystemintegration($allvariableshashref);
########################################################
my $oldloggingdir = $loggingdir;
-installer::systemactions::remove_empty_directory($oldloggingdir);
+installer::systemactions::remove_complete_directory($oldloggingdir);
$loggingdir = installer::systemactions::create_directories("logging", "");
$loggingdir = $loggingdir . $installer::globals::separator;
$installer::globals::exitlog = $loggingdir;
commit 331e4d03a70900bc390b376f4073d0efd868b919
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Jul 20 16:11:08 2012 +0100
refactor ModelToViewHelper, should have unchanged results
Change-Id: Ib57f0d6f9491d12ffacada5ec0ae8bc68874c25b
diff --git a/sw/inc/modeltoviewhelper.hxx b/sw/inc/modeltoviewhelper.hxx
index a1ee88e..c7a80c5 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 83b3e2f..39565cf 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 3c05995..f657f23 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 b728dcd..310ff80 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 d918b8d..de7aa15 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;
};
diff --git a/sw/qa/core/swdoc-test.cxx b/sw/qa/core/swdoc-test.cxx
index ae49266..e47b7d1 100644
--- a/sw/qa/core/swdoc-test.cxx
+++ b/sw/qa/core/swdoc-test.cxx
@@ -238,7 +238,7 @@ void SwDocTest::testSwScanner()
{
SwScanner aScanner(*pTxtNode,
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Hello World")),
- 0, 0, i18n::WordType::DICTIONARY_WORD, 0,
+ 0, ModelToViewHelper(), i18n::WordType::DICTIONARY_WORD, 0,
RTL_CONSTASCII_LENGTH("Hello World"));
bool bFirstOk = aScanner.NextWord();
diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index d33c9dc..11517ca 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -1824,7 +1824,7 @@ bool SwDoc::DeleteRange( SwPaM & rPam )
void lcl_syncGrammarError( SwTxtNode &rTxtNode, linguistic2::ProofreadingResult& rResult,
- xub_StrLen /*nBeginGrammarCheck*/, const ModelToViewHelper::ConversionMap* pConversionMap )
+ xub_StrLen /*nBeginGrammarCheck*/, const ModelToViewHelper &rConversionMap )
{
if( rTxtNode.IsGrammarCheckDirty() )
return;
@@ -1836,8 +1836,8 @@ void lcl_syncGrammarError( SwTxtNode &rTxtNode, linguistic2::ProofreadingResult&
for( i = 0; i < rResult.aErrors.getLength(); ++i )
{
const linguistic2::SingleProofreadingError &rError = rResult.aErrors[i];
- xub_StrLen nStart = (xub_StrLen)ModelToViewHelper::ConvertToModelPosition( pConversionMap, rError.nErrorStart ).mnPos;
- xub_StrLen nEnd = (xub_StrLen)ModelToViewHelper::ConvertToModelPosition( pConversionMap, rError.nErrorStart + rError.nErrorLength ).mnPos;
+ xub_StrLen nStart = (xub_StrLen)rConversionMap.ConvertToModelPosition( rError.nErrorStart ).mnPos;
+ xub_StrLen nEnd = (xub_StrLen)rConversionMap.ConvertToModelPosition( rError.nErrorStart + rError.nErrorLength ).mnPos;
if( i != j )
pArray[j] = pArray[i];
if( pWrong->LookForEntry( nStart, nEnd ) )
@@ -1955,22 +1955,22 @@ uno::Any SwDoc::Spell( SwPaM& rPaM,
String aText( ((SwTxtNode*)pNd)->GetTxt().Copy( nBeginGrammarCheck, nEndGrammarCheck - nBeginGrammarCheck ) );
uno::Reference< lang::XComponent > xDoc( ((SwDocShell*)GetDocShell())->GetBaseModel(), uno::UNO_QUERY );
// Expand the string:
- rtl::OUString aExpandText;
- const ModelToViewHelper::ConversionMap* pConversionMap =
- ((SwTxtNode*)pNd)->BuildConversionMap( aExpandText );
+ const ModelToViewHelper aConversionMap(*(SwTxtNode*)pNd);
+ rtl::OUString aExpandText = aConversionMap.getViewText();
+
// get XFlatParagraph to use...
- uno::Reference< text::XFlatParagraph > xFlatPara = new SwXFlatParagraph( *((SwTxtNode*)pNd), aExpandText, pConversionMap );
+ uno::Reference< text::XFlatParagraph > xFlatPara = new SwXFlatParagraph( *((SwTxtNode*)pNd), aExpandText, aConversionMap );
// get error position of cursor in XFlatParagraph
linguistic2::ProofreadingResult aResult;
sal_Int32 nGrammarErrors;
do
{
- ModelToViewHelper::ConvertToViewPosition( pConversionMap, nBeginGrammarCheck );
+ aConversionMap.ConvertToViewPosition( nBeginGrammarCheck );
aResult = xGCIterator->checkSentenceAtPosition(
xDoc, xFlatPara, aExpandText, lang::Locale(), nBeginGrammarCheck, -1, -1 );
- lcl_syncGrammarError( *((SwTxtNode*)pNd), aResult, nBeginGrammarCheck, pConversionMap );
+ lcl_syncGrammarError( *((SwTxtNode*)pNd), aResult, nBeginGrammarCheck, aConversionMap );
// get suggestions to use for the specific error position
nGrammarErrors = aResult.aErrors.getLength();
@@ -1992,8 +1992,8 @@ uno::Any SwDoc::Spell( SwPaM& rPaM,
pEndPos->nNode = nCurrNd;
pSpellArgs->pStartNode = ((SwTxtNode*)pNd);
pSpellArgs->pEndNode = ((SwTxtNode*)pNd);
- pSpellArgs->pStartIdx->Assign(((SwTxtNode*)pNd), (xub_StrLen)ModelToViewHelper::ConvertToModelPosition( pConversionMap, rError.nErrorStart ).mnPos );
- pSpellArgs->pEndIdx->Assign(((SwTxtNode*)pNd), (xub_StrLen)ModelToViewHelper::ConvertToModelPosition( pConversionMap, rError.nErrorStart + rError.nErrorLength ).mnPos );
+ pSpellArgs->pStartIdx->Assign(((SwTxtNode*)pNd), (xub_StrLen)aConversionMap.ConvertToModelPosition( rError.nErrorStart ).mnPos );
+ pSpellArgs->pEndIdx->Assign(((SwTxtNode*)pNd), (xub_StrLen)aConversionMap.ConvertToModelPosition( rError.nErrorStart + rError.nErrorLength ).mnPos );
nCurrNd = nEndNd;
}
}
diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx
index ffe27d3..c002d56 100644
--- a/sw/source/core/edit/edlingu.cxx
+++ b/sw/source/core/edit/edlingu.cxx
@@ -1131,17 +1131,16 @@ bool SwEditShell::GetGrammarCorrection(
uno::Reference< lang::XComponent > xDoc( pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY );
// Expand the string:
- rtl::OUString aExpandText;
- const ModelToViewHelper::ConversionMap* pConversionMap =
- pNode->BuildConversionMap( aExpandText );
+ const ModelToViewHelper aConversionMap(*pNode);
+ rtl::OUString aExpandText = aConversionMap.getViewText();
// get XFlatParagraph to use...
- uno::Reference< text::XFlatParagraph > xFlatPara = new SwXFlatParagraph( *pNode, aExpandText, pConversionMap );
+ uno::Reference< text::XFlatParagraph > xFlatPara = new SwXFlatParagraph( *pNode, aExpandText, aConversionMap );
// get error position of cursor in XFlatParagraph
- rErrorPosInText = ModelToViewHelper::ConvertToViewPosition( pConversionMap, nBegin );
+ rErrorPosInText = aConversionMap.ConvertToViewPosition( nBegin );
- sal_Int32 nStartOfSentence = ModelToViewHelper::ConvertToViewPosition( pConversionMap, pWrong->getSentenceStart( nBegin ) );
- sal_Int32 nEndOfSentence = ModelToViewHelper::ConvertToViewPosition( pConversionMap, pWrong->getSentenceEnd( nBegin ) );
+ sal_Int32 nStartOfSentence = aConversionMap.ConvertToViewPosition( pWrong->getSentenceStart( nBegin ) );
+ sal_Int32 nEndOfSentence = aConversionMap.ConvertToViewPosition( pWrong->getSentenceEnd( nBegin ) );
if( nEndOfSentence == STRING_LEN )
{
nEndOfSentence = aExpandText.getLength();
@@ -1601,9 +1600,9 @@ bool SwSpellIter::SpellSentence(::svx::SpellPortions& rPortions, bool bIsGrammar
pMySh->GoEndSentence();
if( bGrammarErrorFound )
{
- rtl::OUString aExpandText;
- const ModelToViewHelper::ConversionMap* pConversionMap = ((SwTxtNode*)pCrsr->GetNode())->BuildConversionMap( aExpandText );
- xub_StrLen nSentenceEnd = (xub_StrLen)ModelToViewHelper::ConvertToViewPosition( pConversionMap, aGrammarResult.nBehindEndOfSentencePosition );
+ const ModelToViewHelper aConversionMap(*(SwTxtNode*)pCrsr->GetNode());
+ rtl::OUString aExpandText = aConversionMap.getViewText();
+ xub_StrLen nSentenceEnd = (xub_StrLen)aConversionMap.ConvertToViewPosition( aGrammarResult.nBehindEndOfSentencePosition );
// remove trailing space
if( aExpandText[nSentenceEnd - 1] == ' ' )
--nSentenceEnd;
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 9ab7bbe..c464d24 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -989,7 +989,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL )
// we search for connecting opportunities (kashida)
else if ( bAdjustBlock && i18n::ScriptType::COMPLEX == nScript )
{
- SwScanner aScanner( rNode, rNode.GetTxt(), 0, 0,
+ SwScanner aScanner( rNode, rNode.GetTxt(), 0, ModelToViewHelper(),
i18n::WordType::DICTIONARY_WORD,
nLastKashida, nChg );
diff --git a/sw/source/core/txtnode/modeltoviewhelper.cxx b/sw/source/core/txtnode/modeltoviewhelper.cxx
index 7f33324..861583d 100644
--- a/sw/source/core/txtnode/modeltoviewhelper.cxx
+++ b/sw/source/core/txtnode/modeltoviewhelper.cxx
@@ -19,21 +19,15 @@
#include <modeltoviewhelper.hxx>
-namespace ModelToViewHelper
-{
-
/** Converts a model position into a view position
*/
-sal_uInt32 ConvertToViewPosition( const ConversionMap* pMap, sal_uInt32 nModelPos )
+sal_uInt32 ModelToViewHelper::ConvertToViewPosition( sal_uInt32 nModelPos ) const
{
sal_uInt32 nRet = nModelPos;
- if ( !pMap )
- return nRet;
-
// Search for entry after nPos:
ConversionMap::const_iterator aIter;
- for ( aIter = pMap->begin(); aIter != pMap->end(); ++aIter )
+ for ( aIter = m_aMap.begin(); aIter != m_aMap.end(); ++aIter )
{
if ( (*aIter).first >= nModelPos )
{
@@ -52,17 +46,14 @@ sal_uInt32 ConvertToViewPosition( const ConversionMap* pMap, sal_uInt32 nModelPo
/** Converts a view position into a model position
*/
-ModelPosition ConvertToModelPosition( const ConversionMap* pMap, sal_uInt32 nViewPos )
+ModelToViewHelper::ModelPosition ModelToViewHelper::ConvertToModelPosition( sal_uInt32 nViewPos ) const
{
ModelPosition aRet;
aRet.mnPos = nViewPos;
- if ( !pMap )
- return aRet;
-
// Search for entry after nPos:
ConversionMap::const_iterator aIter;
- for ( aIter = pMap->begin(); aIter != pMap->end(); ++aIter )
+ for ( aIter = m_aMap.begin(); aIter != m_aMap.end(); ++aIter )
{
if ( (*aIter).second > nViewPos )
{
@@ -70,7 +61,7 @@ ModelPosition ConvertToModelPosition( const ConversionMap* pMap, sal_uInt32 nVie
const sal_uInt32 nPosExpand = (*aIter).second;
// If nViewPos is in front of first field, we are finished.
- if ( aIter == pMap->begin() )
+ if ( aIter == m_aMap.begin() )
break;
--aIter;
@@ -107,6 +98,4 @@ ModelPosition ConvertToModelPosition( const ConversionMap* pMap, sal_uInt32 nVie
return aRet;
}
-} // namespace ModelToViewStringConverter end
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index b966480..3a26191 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -3092,14 +3092,12 @@ sal_Bool SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx,
return sal_True;
}
-const ModelToViewHelper::ConversionMap*
- SwTxtNode::BuildConversionMap( rtl::OUString& rRetText ) const
+ModelToViewHelper::ModelToViewHelper(const SwTxtNode &rNode)
{
- const rtl::OUString& rNodeText = GetTxt();
- rRetText = rNodeText;
- ModelToViewHelper::ConversionMap* pConversionMap = 0;
+ const rtl::OUString& rNodeText = rNode.GetTxt();
+ m_aRetText = rNodeText;
- const SwpHints* pSwpHints2 = GetpSwpHints();
+ const SwpHints* pSwpHints2 = rNode.GetpSwpHints();
xub_StrLen nPos = 0;
for ( sal_uInt16 i = 0; pSwpHints2 && i < pSwpHints2->Count(); ++i )
@@ -3121,7 +3119,7 @@ const ModelToViewHelper::ConversionMap*
{
bReplace = true;
const SwFmtFtn& rFtn = static_cast<SwTxtFtn const*>(pAttr)->GetFtn();
- const SwDoc *pDoc = GetDoc();
+ const SwDoc *pDoc = rNode.GetDoc();
aExpand = rFtn.GetViewNumStr(*pDoc);
nFieldPos = *pAttr->GetStart();
}
@@ -3137,22 +3135,14 @@ const ModelToViewHelper::ConversionMap*
if (bReplace)
{
- rRetText = rRetText.replaceAt( nPos + nFieldPos, 1, aExpand );
- if ( !pConversionMap )
- pConversionMap = new ModelToViewHelper::ConversionMap;
- pConversionMap->push_back(
- ModelToViewHelper::ConversionMapEntry(
- nFieldPos, nPos + nFieldPos ) );
+ m_aRetText = m_aRetText.replaceAt( nPos + nFieldPos, 1, aExpand );
+ m_aMap.push_back( ConversionMapEntry( nFieldPos, nPos + nFieldPos ) );
nPos += ( aExpand.getLength() - 1 );
}
}
- if ( pConversionMap && pConversionMap->size() )
- pConversionMap->push_back(
- ModelToViewHelper::ConversionMapEntry(
- rNodeText.getLength()+1, rRetText.getLength()+1 ) );
-
- return pConversionMap;
+ if ( !m_aMap.empty() )
+ m_aMap.push_back( ConversionMapEntry( rNodeText.getLength()+1, m_aRetText.getLength()+1 ) );
}
XubString SwTxtNode::GetRedlineTxt( xub_StrLen nIdx, xub_StrLen nLen,
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index 9f18fc7..0e4e447 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -660,9 +660,9 @@ XubString SwTxtNode::GetCurWord( xub_StrLen nPos ) const
}
SwScanner::SwScanner( const SwTxtNode& rNd, const rtl::OUString& rTxt,
- const LanguageType* pLang, const ModelToViewHelper::ConversionMap* pConvMap,
+ const LanguageType* pLang, const ModelToViewHelper& rConvMap,
sal_uInt16 nType, sal_Int32 nStart, sal_Int32 nEnde, sal_Bool bClp )
- : rNode( rNd ), aText( rTxt), pLanguage( pLang ), pConversionMap( pConvMap ), nLen( 0 ), nWordType( nType ), bClip( bClp )
+ : rNode( rNd ), aText( rTxt), pLanguage( pLang ), rConversionMap( rConvMap ), nLen( 0 ), nWordType( nType ), bClip( bClp )
{
OSL_ENSURE( !aText.isEmpty(), "SwScanner: EmptyString" );
nStartPos = nBegin = nStart;
@@ -674,7 +674,7 @@ SwScanner::SwScanner( const SwTxtNode& rNd, const rtl::OUString& rTxt,
}
else
{
- ModelToViewHelper::ModelPosition aModelBeginPos = ModelToViewHelper::ConvertToModelPosition( pConversionMap, nBegin );
+ ModelToViewHelper::ModelPosition aModelBeginPos = rConversionMap.ConvertToModelPosition( nBegin );
const sal_Int32 nModelBeginPos = aModelBeginPos.mnPos;
aCurrLang = rNd.GetLang( nModelBeginPos );
}
@@ -736,7 +736,7 @@ sal_Bool SwScanner::NextWord()
if ( !pLanguage )
{
const sal_uInt16 nNextScriptType = pBreakIt->GetBreakIter()->getScriptType( aText, nBegin );
- ModelToViewHelper::ModelPosition aModelBeginPos = ModelToViewHelper::ConvertToModelPosition( pConversionMap, nBegin );
+ ModelToViewHelper::ModelPosition aModelBeginPos = rConversionMap.ConvertToModelPosition( nBegin );
const sal_Int32 nBeginModelPos = aModelBeginPos.mnPos;
aCurrLang = rNode.GetLang( nBeginModelPos, 1, nNextScriptType );
}
@@ -915,7 +915,7 @@ sal_uInt16 SwTxtNode::Spell(SwSpellArgs* pArgs)
// In case 2. we pass the wrong list to the scanned, because only
// the words in the wrong list have to be checked
- SwScanner aScanner( *this, m_Text, 0, 0,
+ SwScanner aScanner( *this, m_Text, 0, ModelToViewHelper(),
WordType::DICTIONARY_WORD,
nBegin, nEnd );
while( !pArgs->xSpellAlt.is() && aScanner.NextWord() )
@@ -1223,7 +1223,7 @@ SwRect SwTxtFrm::_AutoSpell( const SwCntntNode* pActNode, const SwViewOption& rV
uno::Reference< XSpellChecker1 > xSpell( ::GetSpellChecker() );
SwDoc* pDoc = pNode->GetDoc();
- SwScanner aScanner( *pNode, pNode->GetTxt(), 0, 0,
+ SwScanner aScanner( *pNode, pNode->GetTxt(), 0, ModelToViewHelper(),
WordType::DICTIONARY_WORD, nBegin, nEnd);
while( aScanner.NextWord() )
@@ -1373,13 +1373,12 @@ SwRect SwTxtFrm::SmartTagScan( SwCntntNode* /*pActNode*/, xub_StrLen /*nActPos*/
if ( nBegin < nEnd )
{
// Expand the string:
- rtl::OUString aExpandText;
- const ModelToViewHelper::ConversionMap* pConversionMap =
- pNode->BuildConversionMap( aExpandText );
+ const ModelToViewHelper aConversionMap(*pNode);
+ rtl::OUString aExpandText = aConversionMap.getViewText();
// Ownership ov ConversionMap is passed to SwXTextMarkup object!
Reference< com::sun::star::text::XTextMarkup > xTextMarkup =
- new SwXTextMarkup( *pNode, pConversionMap );
+ new SwXTextMarkup( *pNode, aConversionMap );
Reference< ::com::sun::star::frame::XController > xController = pNode->GetDoc()->GetDocShell()->GetController();
@@ -1395,8 +1394,8 @@ SwRect SwTxtFrm::SmartTagScan( SwCntntNode* /*pActNode*/, xub_StrLen /*nActPos*/
const com::sun::star::lang::Locale aLocale = pBreakIt->GetLocale( nLang );
nLangEnd = Min( nEnd, aIter.GetChgPos() );
- const sal_uInt32 nExpandBegin = ModelToViewHelper::ConvertToViewPosition( pConversionMap, nLangBegin );
- const sal_uInt32 nExpandEnd = ModelToViewHelper::ConvertToViewPosition( pConversionMap, nLangEnd );
+ const sal_uInt32 nExpandBegin = aConversionMap.ConvertToViewPosition( nLangBegin );
+ const sal_uInt32 nExpandEnd = aConversionMap.ConvertToViewPosition( nLangEnd );
rSmartTagMgr.Recognize( aExpandText, xTextMarkup, xController, aLocale, nExpandBegin, nExpandEnd - nExpandBegin );
@@ -1458,7 +1457,7 @@ void SwTxtFrm::CollectAutoCmplWrds( SwCntntNode* pActNode, xub_StrLen nActPos )
if( nBegin < nEnd )
{
sal_uInt16 nCnt = 200;
- SwScanner aScanner( *pNode, pNode->GetTxt(), 0, 0,
+ SwScanner aScanner( *pNode, pNode->GetTxt(), 0, ModelToViewHelper(),
WordType::DICTIONARY_WORD, nBegin, nEnd );
while( aScanner.NextWord() )
{
@@ -1861,13 +1860,13 @@ void SwTxtNode::CountWords( SwDocStat& rStat,
return;
}
- // expand text into pConversionMap for scanner
- rtl::OUString aExpandText;
- const ModelToViewHelper::ConversionMap* pConversionMap = BuildConversionMap( aExpandText );
+ // expand text into aConversionMap for scanner
+ const ModelToViewHelper aConversionMap(*this);
+ rtl::OUString aExpandText = aConversionMap.getViewText();
// map start and end points onto the ConversionMap
- const sal_uInt32 nExpandBegin = ModelToViewHelper::ConvertToViewPosition( pConversionMap, nStt );
- const sal_uInt32 nExpandEnd = ModelToViewHelper::ConvertToViewPosition( pConversionMap, nEnd );
+ const sal_uInt32 nExpandBegin = aConversionMap.ConvertToViewPosition( nStt );
+ const sal_uInt32 nExpandEnd = aConversionMap.ConvertToViewPosition( nEnd );
if ( aExpandText.isEmpty() )
{
@@ -1894,7 +1893,7 @@ void SwTxtNode::CountWords( SwDocStat& rStat,
if( pBreakIt->GetBreakIter().is() )
{
// zero is NULL for pLanguage -----------v last param = true for clipping
- SwScanner aScanner( *this, aExpandText, 0, pConversionMap, i18n::WordType::WORD_COUNT,
+ SwScanner aScanner( *this, aExpandText, 0, aConversionMap, i18n::WordType::WORD_COUNT,
nExpandBegin, nExpandEnd, true );
// used to filter out scanner returning almost empty strings (len=1; unichar=0x0001)
@@ -1931,7 +1930,7 @@ void SwTxtNode::CountWords( SwDocStat& rStat,
{
LanguageType aLanguage = GetLang( 0 );
- SwScanner aScanner( *this, aNumString, &aLanguage, 0,
+ SwScanner aScanner( *this, aNumString, &aLanguage, ModelToViewHelper(),
i18n::WordType::WORD_COUNT, 0, nNumStringLen, true );
while ( aScanner.NextWord() )
@@ -1953,8 +1952,6 @@ void SwTxtNode::CountWords( SwDocStat& rStat,
}
}
- delete pConversionMap;
-
// If counting the whole para then update cached values and mark clean
if ( isCountAll )
{
diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx
index c590560..1652f9c 100644
--- a/sw/source/core/unocore/unoflatpara.cxx
+++ b/sw/source/core/unocore/unoflatpara.cxx
@@ -59,8 +59,8 @@ using namespace ::com::sun::star;
* SwXFlatParagraph
******************************************************************************/
-SwXFlatParagraph::SwXFlatParagraph( SwTxtNode& rTxtNode, rtl::OUString aExpandText, const ModelToViewHelper::ConversionMap* pMap ) :
- SwXTextMarkup( rTxtNode, pMap ),
+SwXFlatParagraph::SwXFlatParagraph( SwTxtNode& rTxtNode, rtl::OUString aExpandText, const ModelToViewHelper& rMap ) :
+ SwXTextMarkup( rTxtNode, rMap ),
maExpandText( aExpandText )
{
}
@@ -416,11 +416,10 @@ uno::Reference< text::XFlatParagraph > SwXFlatParagraphIterator::getNextPara()
if ( pRet )
{
// Expand the string:
- rtl::OUString aExpandText;
- const ModelToViewHelper::ConversionMap* pConversionMap =
- pRet->BuildConversionMap( aExpandText );
+ const ModelToViewHelper aConversionMap(*pRet);
+ rtl::OUString aExpandText = aConversionMap.getViewText();
- xRet = new SwXFlatParagraph( *pRet, aExpandText, pConversionMap );
+ xRet = new SwXFlatParagraph( *pRet, aExpandText, aConversionMap );
// keep hard references...
m_aFlatParaList.insert( xRet );
}
@@ -469,11 +468,10 @@ uno::Reference< text::XFlatParagraph > SwXFlatParagraphIterator::getParaAfter(co
if ( pNextTxtNode )
{
// Expand the string:
- rtl::OUString aExpandText;
- const ModelToViewHelper::ConversionMap* pConversionMap =
- pNextTxtNode->BuildConversionMap( aExpandText );
+ const ModelToViewHelper aConversionMap(*pNextTxtNode);
+ rtl::OUString aExpandText = aConversionMap.getViewText();
- xRet = new SwXFlatParagraph( *pNextTxtNode, aExpandText, pConversionMap );
+ xRet = new SwXFlatParagraph( *pNextTxtNode, aExpandText, aConversionMap );
// keep hard references...
m_aFlatParaList.insert( xRet );
}
@@ -516,11 +514,10 @@ uno::Reference< text::XFlatParagraph > SwXFlatParagraphIterator::getParaBefore(c
if ( pPrevTxtNode )
{
// Expand the string:
- rtl::OUString aExpandText;
- const ModelToViewHelper::ConversionMap* pConversionMap =
- pPrevTxtNode->BuildConversionMap( aExpandText );
+ const ModelToViewHelper aConversionMap(*pPrevTxtNode);
+ rtl::OUString aExpandText = aConversionMap.getViewText();
- xRet = new SwXFlatParagraph( *pPrevTxtNode, aExpandText, pConversionMap );
+ xRet = new SwXFlatParagraph( *pPrevTxtNode, aExpandText, aConversionMap );
// keep hard references...
m_aFlatParaList.insert( xRet );
}
diff --git a/sw/source/core/unocore/unotextmarkup.cxx b/sw/source/core/unocore/unotextmarkup.cxx
index 80d410e..a7cddad 100644
--- a/sw/source/core/unocore/unotextmarkup.cxx
+++ b/sw/source/core/unocore/unotextmarkup.cxx
@@ -44,8 +44,8 @@ using namespace ::com::sun::star;
/*
* SwXTextMarkup
*/
-SwXTextMarkup::SwXTextMarkup( SwTxtNode& rTxtNode, const ModelToViewHelper::ConversionMap* pMap )
- : mpTxtNode( &rTxtNode ), mpConversionMap( pMap )
+SwXTextMarkup::SwXTextMarkup( SwTxtNode& rTxtNode, const ModelToViewHelper& rMap )
+ : mpTxtNode( &rTxtNode ), maConversionMap( rMap )
{
// FME 2007-07-16 #i79641# SwXTextMarkup is allowed to be removed ...
SetIsAllowedToBeRemovedInModifyCall(true);
@@ -54,7 +54,6 @@ SwXTextMarkup::SwXTextMarkup( SwTxtNode& rTxtNode, const ModelToViewHelper::Conv
SwXTextMarkup::~SwXTextMarkup()
{
- delete mpConversionMap;
}
uno::Reference< container::XStringKeyMap > SAL_CALL SwXTextMarkup::getMarkupInfoContainer() throw (uno::RuntimeException)
@@ -133,9 +132,9 @@ void SAL_CALL SwXTextMarkup::commitTextMarkup(
const ModelToViewHelper::ModelPosition aStartPos =
- ModelToViewHelper::ConvertToModelPosition( mpConversionMap, nStart );
+ maConversionMap.ConvertToModelPosition( nStart );
const ModelToViewHelper::ModelPosition aEndPos =
- ModelToViewHelper::ConvertToModelPosition( mpConversionMap, nStart + nLength - 1);
+ maConversionMap.ConvertToModelPosition( nStart + nLength - 1);
const bool bStartInField = aStartPos.mbIsField;
const bool bEndInField = aEndPos.mbIsField;
@@ -181,8 +180,8 @@ void SAL_CALL SwXTextMarkup::commitTextMarkup(
pSubList = new SwGrammarMarkUp();
pWList->InsertSubList( nFieldPosModel, 1, nInsertPos, pSubList );
}
- const sal_uInt32 nTmpStart = ModelToViewHelper::ConvertToViewPosition( mpConversionMap, aStartPos.mnPos );
- const sal_uInt32 nTmpLen = ModelToViewHelper::ConvertToViewPosition( mpConversionMap, aStartPos.mnPos + 1 )
+ const sal_uInt32 nTmpStart = maConversionMap.ConvertToViewPosition( aStartPos.mnPos );
+ const sal_uInt32 nTmpLen = maConversionMap.ConvertToViewPosition( aStartPos.mnPos + 1 )
- nTmpStart - aStartPos.mnSubPos;
if( nTmpLen > 0 )
{
@@ -233,7 +232,7 @@ void SAL_CALL SwXTextMarkup::commitTextMarkup(
void lcl_commitGrammarMarkUp(
- const ModelToViewHelper::ConversionMap* pConversionMap,
+ const ModelToViewHelper& rConversionMap,
SwGrammarMarkUp* pWList,
::sal_Int32 nType,
const ::rtl::OUString & rIdentifier,
@@ -243,9 +242,9 @@ void lcl_commitGrammarMarkUp(
{
OSL_ENSURE( nType == text::TextMarkupType::PROOFREADING || nType == text::TextMarkupType::SENTENCE, "Wrong mark-up type" );
const ModelToViewHelper::ModelPosition aStartPos =
- ModelToViewHelper::ConvertToModelPosition( pConversionMap, nStart );
+ rConversionMap.ConvertToModelPosition( nStart );
const ModelToViewHelper::ModelPosition aEndPos =
- ModelToViewHelper::ConvertToModelPosition( pConversionMap, nStart + nLength - 1);
+ rConversionMap.ConvertToModelPosition( nStart + nLength - 1);
const bool bStartInField = aStartPos.mbIsField;
const bool bEndInField = aEndPos.mbIsField;
@@ -288,8 +287,8 @@ void lcl_commitGrammarMarkUp(
pSubList = new SwGrammarMarkUp();
pWList->InsertSubList( nFieldPosModel, 1, nInsertPos, pSubList );
}
- const sal_uInt32 nTmpStart = ModelToViewHelper::ConvertToViewPosition( pConversionMap, aStartPos.mnPos );
- const sal_uInt32 nTmpLen = ModelToViewHelper::ConvertToViewPosition( pConversionMap, aStartPos.mnPos + 1 )
+ const sal_uInt32 nTmpStart = rConversionMap.ConvertToViewPosition( aStartPos.mnPos );
+ const sal_uInt32 nTmpLen = rConversionMap.ConvertToViewPosition( aStartPos.mnPos + 1 )
- nTmpStart - aStartPos.mnSubPos;
if( nTmpLen > 0 )
pSubList->Insert( rIdentifier, xMarkupInfoContainer,
@@ -391,7 +390,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
if( pWList->GetBeginInv() < STRING_LEN )
{
const ModelToViewHelper::ModelPosition aSentenceEnd =
- ModelToViewHelper::ConvertToModelPosition( mpConversionMap,
+ maConversionMap.ConvertToModelPosition(
pMarkups[nSentenceMarkUpIndex].nOffset + pMarkups[nSentenceMarkUpIndex].nLength );
bAcceptGrammarError = (xub_StrLen)aSentenceEnd.mnPos > pWList->GetBeginInv();
pWList->ClearGrammarList( (xub_StrLen)aSentenceEnd.mnPos );
@@ -402,7 +401,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
for( i = 0; i < nLen; ++i )
{
const text::TextMarkupDescriptor &rDesc = pMarkups[i];
- lcl_commitGrammarMarkUp( mpConversionMap, pWList, rDesc.nType,
+ lcl_commitGrammarMarkUp( maConversionMap, pWList, rDesc.nType,
rDesc.aIdentifier, rDesc.nOffset, rDesc.nLength, rDesc.xMarkupInfoContainer );
}
}
@@ -411,7 +410,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
bRepaint = false;
i = nSentenceMarkUpIndex;
const text::TextMarkupDescriptor &rDesc = pMarkups[i];
- lcl_commitGrammarMarkUp( mpConversionMap, pWList, rDesc.nType,
+ lcl_commitGrammarMarkUp( maConversionMap, pWList, rDesc.nType,
rDesc.aIdentifier, rDesc.nOffset, rDesc.nLength, rDesc.xMarkupInfoContainer );
}
More information about the Libreoffice-commits
mailing list