summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2007-06-27 11:39:58 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2007-06-27 11:39:58 +0000
commit90d948d549d43c632f03190dd2e0755cf11638fd (patch)
treeac491dc56c401bd47582c44d1cff6c33a1909a1c /starmath
parent541e9b50a5ff2e4d9209f3ed509f1d7159afb17b (diff)
INTEGRATION: CWS tl37 (1.86.32); FILE MERGED
2007/06/04 13:19:44 tl 1.86.32.2: RESYNC: (1.86-1.88); FILE MERGED 2007/02/08 07:49:25 tl 1.86.32.1: #i72498# replace bad chars that keep document from being saved
Diffstat (limited to 'starmath')
-rw-r--r--starmath/source/document.cxx43
1 files changed, 39 insertions, 4 deletions
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx
index 3f9024682c85..2a64d177f8ae 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: document.cxx,v $
*
- * $Revision: 1.89 $
+ * $Revision: 1.90 $
*
- * last change: $Author: hr $ $Date: 2007-06-26 16:03:31 $
+ * last change: $Author: hr $ $Date: 2007-06-27 12:39:58 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -366,6 +366,7 @@ void SmDocShell::Parse()
if (pTree)
delete pTree;
+ ReplaceBadChars();
pTree = aInterpreter.Parse(aText);
nModifyCount++;
SetFormulaArranged( FALSE );
@@ -966,7 +967,7 @@ BOOL SmDocShell::Save()
if ( SfxObjectShell::Save() )
{
- if( !pTree )
+ if (!pTree)
Parse();
if( pTree && !IsFormulaArranged() )
ArrangeFormula();
@@ -980,6 +981,40 @@ BOOL SmDocShell::Save()
return FALSE;
}
+/*
+ * replace bad characters that can not be saved. (#i74144)
+ * */
+sal_Bool SmDocShell::ReplaceBadChars()
+{
+ sal_Bool bReplace = sal_False;
+ if (pEditEngine)
+ {
+ String aEngTxt( pEditEngine->GetText( LINEEND_LF ) );
+ const sal_Unicode *pEngTxt = aEngTxt.GetBuffer();
+ xub_StrLen nLen = aEngTxt.Len();
+ for (xub_StrLen i = 0; i < nLen && !bReplace; ++i)
+ {
+ const sal_Unicode c = *pEngTxt++;
+ if (c < ' ' && c != '\r' && c != '\n' && c != '\t')
+ bReplace = sal_True;
+ }
+ if (bReplace)
+ {
+ sal_Unicode *pChgTxt = aEngTxt.GetBufferAccess();
+ for (xub_StrLen i = 0; i < nLen; ++i)
+ {
+ sal_Unicode &rc = *pChgTxt++;
+ if (rc < ' ' && rc != '\r' && rc != '\n' && rc != '\t')
+ rc = ' ';
+ }
+ aEngTxt.ReleaseBufferAccess( nLen );
+
+ aText = aEngTxt;
+ }
+ }
+ return bReplace;
+}
+
void SmDocShell::UpdateText()
{
@@ -1005,7 +1040,7 @@ BOOL SmDocShell::SaveAs( SfxMedium& rMedium )
if ( SfxObjectShell::SaveAs( rMedium ) )
{
- if( !pTree )
+ if (!pTree)
Parse();
if( pTree && !IsFormulaArranged() )
ArrangeFormula();