[PATCH] Fix for fdo#32786: 'Capitalise Every Word' function

Samuel Mehrbrodt s.mehrbrodt at googlemail.com
Wed Jun 8 03:16:24 PDT 2011


This fix is based on http://hg.services.openoffice.org/OOO340/rev/de0464b37fb3
Also replaced remaining tabs with spaces
---
 sc/source/core/data/documen8.cxx |  326 +++++++++++++++++---------------------
 1 files changed, 145 insertions(+), 181 deletions(-)

diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index c8e5fda..f08445a 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -62,6 +62,8 @@
 #include <vcl/virdev.hxx>
 #include <vcl/msgbox.hxx>
 
+#include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
+
 #include "inputopt.hxx"
 #include "global.hxx"
 #include "table.hxx"
@@ -87,7 +89,7 @@
 #include "chartlis.hxx"
 #include "chartlock.hxx"
 #include "refupdat.hxx"
-#include "validat.hxx"		// fuer HasMacroCalls
+#include "validat.hxx"   // fuer HasMacroCalls
 #include "markdata.hxx"
 #include "scmod.hxx"
 #include "printopt.hxx"
@@ -100,11 +102,11 @@
 #include "docuno.hxx"
 #include "scresid.hxx"
 
-#define GET_SCALEVALUE(set,id) 	((const SfxUInt16Item&)(set.Get( id ))).GetValue()
+#define GET_SCALEVALUE(set,id) ((const SfxUInt16Item&)(set.Get( id ))).GetValue()
 
-//	states for online spelling in the visible range (0 is set initially)
-#define VSPL_START	0
-#define VSPL_DONE	1
+//states for online spelling in the visible range (0 is set initially)
+#define VSPL_START 0
+#define VSPL_DONE 1
 
 
 // STATIC DATA -----------------------------------------------------------
@@ -164,9 +166,9 @@ void ScDocument::SetPrinter( SfxPrinter* pNewPrinter )
 {
     if ( pNewPrinter == pPrinter )
     {
-        //	#i6706# SetPrinter is called with the same printer again if
-        //	the JobSetup has changed. In that case just call UpdateDrawPrinter
-        //	(SetRefDevice for drawing layer) because of changed text sizes.
+        //#i6706# SetPrinter is called with the same printer again if
+        //the JobSetup has changed. In that case just call UpdateDrawPrinter
+        //(SetRefDevice for drawing layer) because of changed text sizes.
         UpdateDrawPrinter();
     }
     else
@@ -241,10 +243,10 @@ void ScDocument::ModifyStyleSheet( SfxStyleSheetBase& rStyleSheet,
     {
         case SFX_STYLE_FAMILY_PAGE:
             {
-                const sal_uInt16 nOldScale		  = GET_SCALEVALUE(rSet,ATTR_PAGE_SCALE);
+                const sal_uInt16 nOldScale = GET_SCALEVALUE(rSet,ATTR_PAGE_SCALE);
                 const sal_uInt16 nOldScaleToPages = GET_SCALEVALUE(rSet,ATTR_PAGE_SCALETOPAGES);
                 rSet.Put( rChanges );
-                const sal_uInt16 nNewScale		  = GET_SCALEVALUE(rSet,ATTR_PAGE_SCALE);
+                const sal_uInt16 nNewScale = GET_SCALEVALUE(rSet,ATTR_PAGE_SCALE);
                 const sal_uInt16 nNewScaleToPages = GET_SCALEVALUE(rSet,ATTR_PAGE_SCALETOPAGES);
 
                 if ( (nOldScale != nNewScale) || (nOldScaleToPages != nNewScaleToPages) )
@@ -286,9 +288,9 @@ void ScDocument::ModifyStyleSheet( SfxStyleSheetBase& rStyleSheet,
                 }
 
                 // Bedeutung der Items in rChanges:
-                //	Item gesetzt	- Aenderung uebernehmen
-                //	Dontcare		- Default setzen
-                //	Default			- keine Aenderung
+                // Item gesetzt - Aenderung uebernehmen
+                // Dontcare - Default setzen
+                // Default - keine Aenderung
                 // ("keine Aenderung" geht nicht mit PutExtended, darum Schleife)
                 for (sal_uInt16 nWhich = ATTR_PATTERN_START; nWhich <= ATTR_PATTERN_END; nWhich++)
                 {
@@ -336,7 +338,7 @@ void ScDocument::InvalidateTextWidth( const String& rStyleName )
 
 void ScDocument::InvalidateTextWidth( SCTAB nTab )
 {
-    ScAddress aAdrFrom( 0,	  0,        nTab );
+    ScAddress aAdrFrom( 0, 0, nTab );
     ScAddress aAdrTo  ( MAXCOL, MAXROW, nTab );
     InvalidateTextWidth( &aAdrFrom, &aAdrTo, false );
 }
@@ -345,7 +347,7 @@ void ScDocument::InvalidateTextWidth( SCTAB nTab )
 
 sal_Bool ScDocument::IsPageStyleInUse( const String& rStrPageStyle, SCTAB* pInTab )
 {
-    sal_Bool		 bInUse = false;
+    sal_Bool bInUse = false;
     const SCTAB nCount = GetTableCount();
     SCTAB i;
 
@@ -447,28 +449,28 @@ void ScDocument::InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress
 
 //------------------------------------------------------------------------
 
-#define CALCMAX					1000	// Berechnungen
-#define ABORT_EVENTS			(INPUT_ANY & ~INPUT_TIMER & ~INPUT_OTHER)
+#define CALCMAX 1000 // Berechnungen
+#define ABORT_EVENTS (INPUT_ANY & ~INPUT_TIMER & ~INPUT_OTHER)
 
-sal_Bool ScDocument::IdleCalcTextWidth()			// sal_True = demnaechst wieder versuchen
+sal_Bool ScDocument::IdleCalcTextWidth() // sal_True = demnaechst wieder versuchen
 {
     // #i75610# if a printer hasn't been set or created yet, don't create one for this
     if ( bIdleDisabled || IsInLinkUpdate() || GetPrinter(false) == NULL )
         return false;
     bIdleDisabled = sal_True;
 
-    const sal_uLong			nStart	 = Time::GetSystemTicks();
-    OutputDevice*		pDev	 = NULL;
-    MapMode				aOldMap;
-    ScStyleSheet*		pStyle	 = NULL;
-    ScColumnIterator*	pColIter = NULL;
-    ScTable*			pTable	 = NULL;
-    ScColumn*			pColumn	 = NULL;
-    ScBaseCell*			pCell	 = NULL;
-    SCTAB				nTab  	 = aCurTextWidthCalcPos.Tab();
-    SCROW				nRow   	 = aCurTextWidthCalcPos.Row();
-    SCsCOL				nCol  	 = aCurTextWidthCalcPos.Col();
-    sal_Bool				bNeedMore= false;
+    const sal_uLong nStart = Time::GetSystemTicks();
+    OutputDevice* pDev = NULL;
+    MapMode aOldMap;
+    ScStyleSheet* pStyle = NULL;
+    ScColumnIterator* pColIter = NULL;
+    ScTable* pTable = NULL;
+    ScColumn* pColumn = NULL;
+    ScBaseCell* pCell = NULL;
+    SCTAB nTab = aCurTextWidthCalcPos.Tab();
+    SCROW nRow = aCurTextWidthCalcPos.Row();
+    SCsCOL nCol = aCurTextWidthCalcPos.Col();
+    sal_Bool bNeedMore= false;
 
     if ( !ValidRow(nRow) )
         nRow = 0, nCol--;
@@ -477,9 +479,9 @@ sal_Bool ScDocument::IdleCalcTextWidth()			// sal_True = demnaechst wieder versu
     if ( !ValidTab(nTab) || !pTab[nTab] )
         nTab = 0;
 
-    //	SearchMask/Family muss gemerkt werden,
-    //	damit z.B. der Organizer nicht durcheinanderkommt, wenn zwischendurch eine
-    //	Query-Box aufgemacht wird !!!
+    //SearchMask/Family muss gemerkt werden,
+    //damit z.B. der Organizer nicht durcheinanderkommt, wenn zwischendurch eine
+    //Query-Box aufgemacht wird !!!
 
     ScStyleSheetPool* pStylePool = xPoolHelper->GetStylePool();
     sal_uInt16 nOldMask = pStylePool->GetSearchMask();
@@ -499,16 +501,16 @@ sal_Bool ScDocument::IdleCalcTextWidth()			// sal_True = demnaechst wieder versu
         sal_uInt16 nZoom = 0;
         sal_uInt16 nCount = 0;
 
-        nZoom	 = GET_SCALEVALUE(pStyle->GetItemSet(),ATTR_PAGE_SCALE);
+        nZoom = GET_SCALEVALUE(pStyle->GetItemSet(),ATTR_PAGE_SCALE);
         Fraction aZoomFract( nZoom, 100 );
-        pColumn  = &pTable->aCol[nCol];
+        pColumn = &pTable->aCol[nCol];
         pColIter = new ScColumnIterator( pColumn, nRow, MAXROW );
 
         while ( (nZoom > 0) && (nCount < CALCMAX) && (nRestart < 2) )
         {
             if ( pColIter->Next( nRow, pCell ) )
             {
-                if ( TEXTWIDTH_DIRTY ==	pCell->GetTextWidth() )
+                if ( TEXTWIDTH_DIRTY == pCell->GetTextWidth() )
                 {
                     double nPPTX = 0.0;
                     double nPPTY = 0.0;
@@ -516,7 +518,7 @@ sal_Bool ScDocument::IdleCalcTextWidth()			// sal_True = demnaechst wieder versu
                     {
                         pDev = GetPrinter();
                         aOldMap = pDev->GetMapMode();
-                        pDev->SetMapMode( MAP_PIXEL );	// wichtig fuer GetNeededSize
+                        pDev->SetMapMode( MAP_PIXEL );    // wichtig fuer GetNeededSize
 
                         Point aPix1000 = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP );
                         nPPTX = aPix1000.X() / 1000.0;
@@ -532,7 +534,7 @@ sal_Bool ScDocument::IdleCalcTextWidth()			// sal_True = demnaechst wieder versu
                     sal_uInt16 nNewWidth = (sal_uInt16)GetNeededSize( nCol, nRow, nTab,
                                                               pDev, nPPTX, nPPTY,
                                                               aZoomFract,aZoomFract, sal_True,
-                                                              sal_True );	// bTotalSize
+                                                              sal_True );    // bTotalSize
 
                     pCell->SetTextWidth( nNewWidth );
 
@@ -632,7 +634,7 @@ sal_Bool ScDocument::IdleCalcTextWidth()			// sal_True = demnaechst wieder versu
 class ScSpellStatus
 {
 public:
-    sal_Bool	bModified;
+    sal_Bool    bModified;
 
     ScSpellStatus() : bModified(false) {};
 
@@ -648,38 +650,38 @@ IMPL_LINK( ScSpellStatus, EventHdl, EditStatus *, pStatus )
     return 0;
 }
 
-//	SPELL_MAXCELLS muss mindestens 256 sein, solange am Iterator keine
-//	Start-Spalte gesetzt werden kann
+// SPELL_MAXCELLS muss mindestens 256 sein, solange am Iterator keine
+// Start-Spalte gesetzt werden kann
 
-//!	SPELL_MAXTEST fuer Timer und Idle unterschiedlich ???
+// !SPELL_MAXTEST fuer Timer und Idle unterschiedlich ???
 
-//	SPELL_MAXTEST now divided between visible and rest of document
+// SPELL_MAXTEST now divided between visible and rest of document
 
-#define SPELL_MAXTEST_VIS	1
-#define SPELL_MAXTEST_ALL	3
-#define SPELL_MAXCELLS		256
+#define SPELL_MAXTEST_VIS    1
+#define SPELL_MAXTEST_ALL    3
+#define SPELL_MAXCELLS       256
 
 sal_Bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpellPos,
                                      sal_uInt16 nMaxTest )
 {
-    ScEditEngineDefaulter* pEngine = NULL;				//! am Dokument speichern
+    ScEditEngineDefaulter* pEngine = NULL;                //! am Dokument speichern
     SfxItemSet* pDefaults = NULL;
     ScSpellStatus aStatus;
 
-    sal_uInt16 nCellCount = 0;			// Zellen insgesamt
-    sal_uInt16 nTestCount = 0;			// Aufrufe Spelling
-    sal_Bool bChanged = false;			// Aenderungen?
+    sal_uInt16 nCellCount = 0;            // Zellen insgesamt
+    sal_uInt16 nTestCount = 0;            // Aufrufe Spelling
+    sal_Bool bChanged = false;            // Aenderungen?
 
-    SCCOL nCol = rSpellRange.aStart.Col();		// iterator always starts on the left edge
+    SCCOL nCol = rSpellRange.aStart.Col();// iterator always starts on the left edge
     SCROW nRow = rSpellPos.Row();
     SCTAB nTab = rSpellPos.Tab();
-    if ( !pTab[nTab] )							// sheet deleted?
+    if ( !pTab[nTab] )                    // sheet deleted?
     {
         nTab = rSpellRange.aStart.Tab();
         nRow = rSpellRange.aStart.Row();
         if ( !pTab[nTab] )
         {
-            //	may happen for visible range
+            // may happen for visible range
             return false;
         }
     }
@@ -687,7 +689,7 @@ sal_Bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress&
                                     rSpellRange.aStart.Col(), nRow,
                                     rSpellRange.aEnd.Col(), rSpellRange.aEnd.Row() );
     ScBaseCell* pCell = aIter.GetNext( nCol, nRow );
-    //	skip everything left of rSpellPos:
+    //skip everything left of rSpellPos:
     while ( pCell && nRow == rSpellPos.Row() && nCol < rSpellPos.Col() )
         pCell = aIter.GetNext( nCol, nRow );
 
@@ -702,13 +704,13 @@ sal_Bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress&
         {
             if (!pEngine)
             {
-                //	ScTabEditEngine is needed
-                //	because MapMode must be set for some old documents
+                // ScTabEditEngine is needed
+                // because MapMode must be set for some old documents
                 pEngine = new ScTabEditEngine( this );
                 pEngine->SetControlWord( pEngine->GetControlWord() |
                             ( EE_CNTRL_ONLINESPELLING | EE_CNTRL_ALLOWBIGOBJS ) );
                 pEngine->SetStatusEventHdl( LINK( &aStatus, ScSpellStatus, EventHdl ) );
-                //	Delimiters hier wie in inputhdl.cxx !!!
+                //    Delimiters hier wie in inputhdl.cxx !!!
                 pEngine->SetWordDelimiters(
                             ScEditUtil::ModifyDelimiters( pEngine->GetWordDelimiters() ) );
                 pDefaults = new SfxItemSet( pEngine->GetEmptyItemSet() );
@@ -720,7 +722,7 @@ sal_Bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress&
 
             const ScPatternAttr* pPattern = GetPattern( nCol, nRow, nTab );
             pPattern->FillEditItemSet( pDefaults );
-            pEngine->SetDefaults( pDefaults, false );				//! noetig ?
+            pEngine->SetDefaults( pDefaults, false );                //! noetig ?
 
             sal_uInt16 nCellLang = ((const SvxLanguageItem&)
                                     pPattern->GetItem(ATTR_FONT_LANGUAGE)).GetValue();
@@ -739,9 +741,9 @@ sal_Bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress&
 
             aStatus.bModified = false;
             pEngine->CompleteOnlineSpelling();
-            if ( aStatus.bModified )				// Fehler dazu oder weggekommen?
+            if ( aStatus.bModified )                // Fehler dazu oder weggekommen?
             {
-                sal_Bool bNeedEdit = sal_True;						//	Test auf einfachen Text
+                sal_Bool bNeedEdit = sal_True;                        //    Test auf einfachen Text
                 if ( !pEngine->HasOnlineSpellErrors() )
                 {
                     ScEditAttrTester aTester( pEngine );
@@ -759,14 +761,14 @@ sal_Bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress&
                             this, pEngine->GetEditTextObjectPool() ) );
                     delete pNewData;
                 }
-                else					// einfacher String
+                else                    // einfacher String
                     PutCell( nCol, nRow, nTab, new ScStringCell( pEngine->GetText() ) );
 
-                //	Paint
+                //    Paint
                 if (pShell)
                 {
-                    //	Seitenvorschau ist davon nicht betroffen
-                    //	(sollte jedenfalls nicht)
+                    //    Seitenvorschau ist davon nicht betroffen
+                    //    (sollte jedenfalls nicht)
                     ScPaintHint aHint( ScRange( nCol, nRow, nTab ), PAINT_GRID );
                     aHint.SetPrintFlag( false );
                     pShell->Broadcast( aHint );
@@ -775,17 +777,17 @@ sal_Bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress&
                 bChanged = sal_True;
             }
 
-            if ( ++nTestCount >= nMaxTest )				// checked enough text?
+            if ( ++nTestCount >= nMaxTest )                // checked enough text?
                 break;
         }
 
-        if ( ++nCellCount >= SPELL_MAXCELLS )			// seen enough cells?
+        if ( ++nCellCount >= SPELL_MAXCELLS )            // seen enough cells?
             break;
     }
 
     if ( pCell )
     {
-        ++nCol;											// continue after last cell
+        ++nCol;                                            // continue after last cell
         if ( nCol > rSpellRange.aEnd.Col() )
         {
             nCol = rSpellRange.aStart.Col();
@@ -795,7 +797,7 @@ sal_Bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress&
         }
     }
 
-    if (!pCell)			// end of range reached -> next sheet
+    if (!pCell)            // end of range reached -> next sheet
     {
         ++nTab;
         if ( nTab > rSpellRange.aEnd.Tab() || !pTab[nTab] )
@@ -803,12 +805,12 @@ sal_Bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress&
         nCol = rSpellRange.aStart.Col();
         nRow = rSpellRange.aStart.Row();
 
-        nVisSpellState = VSPL_DONE;		//! only if this is for the visible range
+        nVisSpellState = VSPL_DONE;        //! only if this is for the visible range
     }
     rSpellPos.Set( nCol, nRow, nTab );
 
     delete pDefaults;
-    delete pEngine;			// bevor aStatus out of scope geht
+    delete pEngine;            // bevor aStatus out of scope geht
 
     return bChanged;
 }
@@ -824,23 +826,23 @@ sal_Bool ScDocument::ContinueOnlineSpelling()
     sal_Bool bOldInserting = IsInsertingFromOtherDoc();
     SetInsertingFromOtherDoc( sal_True );
 
-    //!	use one EditEngine for both calls
+    //!    use one EditEngine for both calls
 
-    //	first check visible range
+    //    first check visible range
     sal_Bool bResult = OnlineSpellInRange( aVisSpellRange, aVisSpellPos, SPELL_MAXTEST_VIS );
 
-    //	during first pass through visible range, always continue
+    //    during first pass through visible range, always continue
     if ( nVisSpellState == VSPL_START )
         bResult = sal_True;
 
     if (bResult)
     {
-        //	if errors found, continue there
+        //    if errors found, continue there
         OnlineSpellInRange( aVisSpellRange, aVisSpellPos, SPELL_MAXTEST_ALL );
     }
     else
     {
-        //	if nothing found there, continue with rest of document
+        //    if nothing found there, continue with rest of document
         ScRange aTotalRange( 0,0,0, MAXCOL,MAXROW,MAXTAB );
         bResult = OnlineSpellInRange( aTotalRange, aOnlineSpellPos, SPELL_MAXTEST_ALL );
     }
@@ -855,7 +857,7 @@ void ScDocument::SetOnlineSpellPos( const ScAddress& rPos )
 {
     aOnlineSpellPos = rPos;
 
-    //	skip visible area for aOnlineSpellPos
+    //    skip visible area for aOnlineSpellPos
     if ( aVisSpellRange.In( aOnlineSpellPos ) )
         aOnlineSpellPos = aVisSpellRange.aEnd;
 }
@@ -865,7 +867,7 @@ sal_Bool ScDocument::SetVisibleSpellRange( const ScRange& rNewRange )
     sal_Bool bChange = ( aVisSpellRange != rNewRange );
     if (bChange)
     {
-        //	continue spelling through visible range when scrolling down
+        //    continue spelling through visible range when scrolling down
         sal_Bool bContDown = ( nVisSpellState == VSPL_START && rNewRange.In( aVisSpellPos ) &&
                             rNewRange.aStart.Row() >  aVisSpellRange.aStart.Row() &&
                             rNewRange.aStart.Col() == aVisSpellRange.aStart.Col() &&
@@ -879,7 +881,7 @@ sal_Bool ScDocument::SetVisibleSpellRange( const ScRange& rNewRange )
             nVisSpellState = VSPL_START;
         }
 
-        //	skip visible area for aOnlineSpellPos
+        //    skip visible area for aOnlineSpellPos
         if ( aVisSpellRange.In( aOnlineSpellPos ) )
             aOnlineSpellPos = aVisSpellRange.aEnd;
     }
@@ -888,7 +890,7 @@ sal_Bool ScDocument::SetVisibleSpellRange( const ScRange& rNewRange )
 
 void ScDocument::RemoveAutoSpellObj()
 {
-    //	alle Spelling-Informationen entfernen
+    //    alle Spelling-Informationen entfernen
 
     for (SCTAB nTab=0; nTab<=MAXTAB && pTab[nTab]; nTab++)
         pTab[nTab]->RemoveAutoSpellObj();
@@ -906,7 +908,7 @@ void ScDocument::RepaintRange( const ScRange& rRange )
 
 //------------------------------------------------------------------------
 
-sal_Bool ScDocument::IdleCheckLinks()			// sal_True = demnaechst wieder versuchen
+sal_Bool ScDocument::IdleCheckLinks()            // sal_True = demnaechst wieder versuchen
 {
     sal_Bool bAnyLeft = false;
 
@@ -935,13 +937,13 @@ sal_Bool ScDocument::IdleCheckLinks()			// sal_True = demnaechst wieder versuche
 
 void ScDocument::SaveDdeLinks(SvStream& rStream) const
 {
-    //	bei 4.0-Export alle mit Modus != DEFAULT weglassen
+    //    bei 4.0-Export alle mit Modus != DEFAULT weglassen
     sal_Bool bExport40 = ( rStream.GetVersion() <= SOFFICE_FILEFORMAT_40 );
 
     const ::sfx2::SvBaseLinks& rLinks = GetLinkManager()->GetLinks();
     sal_uInt16 nCount = rLinks.Count();
 
-    //	erstmal zaehlen...
+    //    erstmal zaehlen...
 
     sal_uInt16 nDdeCount = 0;
     sal_uInt16 i;
@@ -953,12 +955,12 @@ void ScDocument::SaveDdeLinks(SvStream& rStream) const
                 ++nDdeCount;
     }
 
-    //	Header
+    //    Header
 
     ScMultipleWriteHeader aHdr( rStream );
     rStream << nDdeCount;
 
-    //	Links speichern
+    //    Links speichern
 
     for (i=0; i<nCount; i++)
     {
@@ -989,7 +991,7 @@ void ScDocument::LoadDdeLinks(SvStream& rStream)
 
 bool ScDocument::HasDdeLinks() const
 {
-    if (GetLinkManager())			// Clipboard z.B. hat keinen LinkManager
+    if (GetLinkManager())            // Clipboard z.B. hat keinen LinkManager
     {
         const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
         sal_uInt16 nCount = rLinks.Count();
@@ -1003,7 +1005,7 @@ bool ScDocument::HasDdeLinks() const
 
 void ScDocument::SetInLinkUpdate(sal_Bool bSet)
 {
-    //	called from TableLink and AreaLink
+    //    called from TableLink and AreaLink
 
     OSL_ENSURE( bInLinkUpdate != bSet, "SetInLinkUpdate twice" );
     bInLinkUpdate = bSet;
@@ -1114,9 +1116,9 @@ void ScDocument::UpdateDdeLinks()
 
 sal_Bool ScDocument::UpdateDdeLink( const String& rAppl, const String& rTopic, const String& rItem )
 {
-    //	fuer refresh() per StarOne Api
-    //	ResetValue() fuer einzelnen Link nicht noetig
-    //!	wenn's mal alles asynchron wird, aber auch hier
+    //    fuer refresh() per StarOne Api
+    //    ResetValue() fuer einzelnen Link nicht noetig
+    //!    wenn's mal alles asynchron wird, aber auch hier
 
     sal_Bool bFound = false;
     if (GetLinkManager())
@@ -1153,14 +1155,14 @@ void ScDocument::DisconnectDdeLinks()
         {
             ::sfx2::SvBaseLink* pBase = *rLinks[i];
             if (pBase->ISA(ScDdeLink))
-                pBase->Disconnect();			// bleibt im LinkManager eingetragen
+                pBase->Disconnect();            // bleibt im LinkManager eingetragen
         }
     }
 }
 
 void ScDocument::CopyDdeLinks( ScDocument* pDestDoc ) const
 {
-    if (bIsClip)		// aus Stream erzeugen
+    if (bIsClip)        // aus Stream erzeugen
     {
         if (pClipData)
         {
@@ -1336,7 +1338,7 @@ bool ScDocument::SetDdeLinkResultMatrix( sal_uInt16 nDdePos, ScMatrixRef pResult
 
 bool ScDocument::HasAreaLinks() const
 {
-    if (GetLinkManager())			// Clipboard z.B. hat keinen LinkManager
+    if (GetLinkManager())            // Clipboard z.B. hat keinen LinkManager
     {
         const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
         sal_uInt16 nCount = rLinks.Count();
@@ -1463,12 +1465,12 @@ void ScDocument::KeyInput( const KeyEvent& )
         apTemporaryChartLock->StartOrContinueLocking();
 }
 
-//	----------------------------------------------------------------------------
+//    ----------------------------------------------------------------------------
 
 sal_Bool ScDocument::CheckMacroWarn()
 {
-    //	The check for macro configuration, macro warning and disabling is now handled
-    //	in SfxObjectShell::AdjustMacroMode, called by SfxObjectShell::CallBasic.
+    //    The check for macro configuration, macro warning and disabling is now handled
+    //    in SfxObjectShell::AdjustMacroMode, called by SfxObjectShell::CallBasic.
 
     return sal_True;
 }
@@ -1477,17 +1479,17 @@ sal_Bool ScDocument::CheckMacroWarn()
 
 SfxBindings* ScDocument::GetViewBindings()
 {
-    //	used to invalidate slots after changes to this document
+    //    used to invalidate slots after changes to this document
 
     if ( !pShell )
-        return NULL;		// no ObjShell -> no view
+        return NULL;        // no ObjShell -> no view
 
-    //	first check current view
+    //    first check current view
     SfxViewFrame* pViewFrame = SfxViewFrame::Current();
-    if ( pViewFrame && pViewFrame->GetObjectShell() != pShell )		// wrong document?
+    if ( pViewFrame && pViewFrame->GetObjectShell() != pShell )        // wrong document?
         pViewFrame = NULL;
 
-    //	otherwise use first view for this doc
+    //    otherwise use first view for this doc
     if ( !pViewFrame )
         pViewFrame = SfxViewFrame::GetFirst( pShell );
 
@@ -1499,57 +1501,6 @@ SfxBindings* ScDocument::GetViewBindings()
 
 //------------------------------------------------------------------------
 
-void lcl_TransliterateEditEngine( ScEditEngineDefaulter& rEngine,
-                                utl::TransliterationWrapper& rTranslitarationWrapper,
-                                sal_Bool bConsiderLanguage, ScDocument* pDoc )
-{
-    //!	should use TransliterateText method of EditEngine instead, when available!
-
-    sal_uInt16 nLanguage = LANGUAGE_SYSTEM;
-
-    sal_uInt16 nParCount = rEngine.GetParagraphCount();
-    for (sal_uInt16 nPar=0; nPar<nParCount; nPar++)
-    {
-        SvUShorts aPortions;
-        rEngine.GetPortions( (sal_uInt16)nPar, aPortions );
-
-        for ( sal_uInt16 nPos = aPortions.Count(); nPos; )
-        {
-            --nPos;
-            sal_uInt16 nEnd = aPortions.GetObject( nPos );
-            sal_uInt16 nStart = nPos ? aPortions.GetObject( nPos - 1 ) : 0;
-
-            ESelection aSel( nPar, nStart, nPar, nEnd );
-            String aOldStr = rEngine.GetText( aSel );
-            SfxItemSet aAttr = rEngine.GetAttribs( aSel );
-
-            if ( aAttr.GetItemState( EE_FEATURE_FIELD ) != SFX_ITEM_ON )	// fields are not touched
-            {
-                if ( bConsiderLanguage )
-                {
-                    sal_uInt8 nScript = pDoc->GetStringScriptType( aOldStr );
-                    sal_uInt16 nWhich = ( nScript == SCRIPTTYPE_ASIAN ) ? EE_CHAR_LANGUAGE_CJK :
-                                    ( ( nScript == SCRIPTTYPE_COMPLEX ) ? EE_CHAR_LANGUAGE_CTL :
-                                                                            EE_CHAR_LANGUAGE );
-                    nLanguage = ((const SvxLanguageItem&)aAttr.Get(nWhich)).GetValue();
-                }
-
-                com::sun::star::uno::Sequence<sal_Int32> aOffsets;
-                String aNewStr = rTranslitarationWrapper.transliterate( aOldStr, nLanguage, 0, aOldStr.Len(), &aOffsets );
-
-                if ( aNewStr != aOldStr )
-                {
-                    // replace string, keep attributes
-
-                    rEngine.QuickInsertText( aNewStr, aSel );
-                    aSel.nEndPos = aSel.nStartPos + aNewStr.Len();
-                    rEngine.QuickSetAttribs( aAttr, aSel );
-                }
-            }
-        }
-    }
-}
-
 void ScDocument::TransliterateText( const ScMarkData& rMultiMark, sal_Int32 nType )
 {
     OSL_ENSURE( rMultiMark.IsMultiMarked(), "TransliterateText: no selection" );
@@ -1558,7 +1509,7 @@ void ScDocument::TransliterateText( const ScMarkData& rMultiMark, sal_Int32 nTyp
     sal_Bool bConsiderLanguage = aTranslitarationWrapper.needLanguageForTheMode();
     sal_uInt16 nLanguage = LANGUAGE_SYSTEM;
 
-    ScEditEngineDefaulter* pEngine = NULL;		// not using pEditEngine member because of defaults
+    ScEditEngineDefaulter* pEngine = NULL;        // not using pEditEngine member because of defaults
 
     SCTAB nCount = GetTableCount();
     for (SCTAB nTab = 0; nTab < nCount; nTab++)
@@ -1575,29 +1526,12 @@ void ScDocument::TransliterateText( const ScMarkData& rMultiMark, sal_Int32 nTyp
             {
                 const ScBaseCell* pCell = GetCell( ScAddress( nCol, nRow, nTab ) );
                 CellType eType = pCell ? pCell->GetCellType() : CELLTYPE_NONE;
-
-                if ( eType == CELLTYPE_STRING )
-                {
-                    String aOldStr;
-                    ((const ScStringCell*)pCell)->GetString(aOldStr);
-                    xub_StrLen nOldLen = aOldStr.Len();
-
-                    if ( bConsiderLanguage )
-                    {
-                        sal_uInt8 nScript = GetStringScriptType( aOldStr );		//! cell script type?
-                        sal_uInt16 nWhich = ( nScript == SCRIPTTYPE_ASIAN ) ? ATTR_CJK_FONT_LANGUAGE :
-                                        ( ( nScript == SCRIPTTYPE_COMPLEX ) ? ATTR_CTL_FONT_LANGUAGE :
-                                                                                ATTR_FONT_LANGUAGE );
-                        nLanguage = ((const SvxLanguageItem*)GetAttr( nCol, nRow, nTab, nWhich ))->GetValue();
-                    }
-
-                    com::sun::star::uno::Sequence<sal_Int32> aOffsets;
-                    String aNewStr = aTranslitarationWrapper.transliterate( aOldStr, nLanguage, 0, nOldLen, &aOffsets );
-
-                    if ( aNewStr != aOldStr )
-                        PutCell( nCol, nRow, nTab, new ScStringCell( aNewStr ) );
-                }
-                else if ( eType == CELLTYPE_EDIT )
+                // fdo#32786 TITLE_CASE/SENTENCE_CASE need the extra handling in EditEngine (loop over words/sentences).
+                // Still use TransliterationWrapper directly for text cells with other transliteration types,
+                // for performance reasons.
+                if ( eType == CELLTYPE_EDIT ||
+                     ( eType == CELLTYPE_STRING && ( nType == com::sun::star::i18n::TransliterationModulesExtra::SENTENCE_CASE ||
+                                                     nType == com::sun::star::i18n::TransliterationModulesExtra::TITLE_CASE ) ) )
                 {
                     if (!pEngine)
                         pEngine = new ScFieldEditEngine( GetEnginePool(), GetEditPool() );
@@ -1608,12 +1542,22 @@ void ScDocument::TransliterateText( const ScMarkData& rMultiMark, sal_Int32 nTyp
                     pPattern->FillEditItemSet( pDefaults );
                     pEngine->SetDefaults( pDefaults, sal_True );
 
-                    const EditTextObject* pData = ((const ScEditCell*)pCell)->GetData();
-                    pEngine->SetText( *pData );
-
+                    if ( eType == CELLTYPE_STRING )
+                        pEngine->SetText( static_cast<const ScStringCell*>(pCell)->GetString() );
+                    else
+                    {
+                        const EditTextObject* pData = static_cast<const ScEditCell*>(pCell)->GetData();
+                        pEngine->SetText( *pData );
+                    }
                     pEngine->ClearModifyFlag();
 
-                    lcl_TransliterateEditEngine( *pEngine, aTranslitarationWrapper, bConsiderLanguage, this );
+                    sal_uInt16 nLastPar = pEngine->GetParagraphCount();
+                    if (nLastPar)
+                        --nLastPar;
+                    xub_StrLen nTxtLen = pEngine->GetTextLen(nLastPar);
+                    ESelection aSelAll( 0, 0, nLastPar, nTxtLen );
+
+                    pEngine->TransliterateText( aSelAll, nType );
 
                     if ( pEngine->IsModified() )
                     {
@@ -1637,11 +1581,31 @@ void ScDocument::TransliterateText( const ScMarkData& rMultiMark, sal_Int32 nTyp
                     }
                 }
 
+                else if ( eType == CELLTYPE_STRING )
+                {
+                    String aOldStr;
+                    ((const ScStringCell*)pCell)->GetString(aOldStr);
+                    xub_StrLen nOldLen = aOldStr.Len();
+
+                    if ( bConsiderLanguage )
+                    {
+                        sal_uInt8 nScript = GetStringScriptType( aOldStr );        //! cell script type?
+                        sal_uInt16 nWhich = ( nScript == SCRIPTTYPE_ASIAN ) ? ATTR_CJK_FONT_LANGUAGE :
+                                        ( ( nScript == SCRIPTTYPE_COMPLEX ) ? ATTR_CTL_FONT_LANGUAGE :
+                                                                                ATTR_FONT_LANGUAGE );
+                        nLanguage = ((const SvxLanguageItem*)GetAttr( nCol, nRow, nTab, nWhich ))->GetValue();
+                    }
+
+                    com::sun::star::uno::Sequence<sal_Int32> aOffsets;
+                    String aNewStr = aTranslitarationWrapper.transliterate( aOldStr, nLanguage, 0, nOldLen, &aOffsets );
+
+                    if ( aNewStr != aOldStr )
+                        PutCell( nCol, nRow, nTab, new ScStringCell( aNewStr ) );
+                }
                 bFound = GetNextMarkedCell( nCol, nRow, nTab, rMultiMark );
             }
         }
-
     delete pEngine;
 }
 
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
-- 
1.7.4.4


--=-YwQ/BrwhPuroFQAizByb--



More information about the LibreOffice mailing list