diff options
-rw-r--r-- | officecfg/registry/schema/org/openoffice/Office/Common.xcs | 11 | ||||
-rw-r--r-- | officecfg/registry/schema/org/openoffice/Office/Writer.xcs | 22 | ||||
-rw-r--r-- | svx/inc/svx/svxacorr.hxx | 4 | ||||
-rw-r--r-- | svx/inc/svx/swafopt.hxx | 1 | ||||
-rw-r--r-- | svx/source/cui/autocdlg.cxx | 15 | ||||
-rw-r--r-- | svx/source/cui/autocdlg.hrc | 1 | ||||
-rw-r--r-- | svx/source/cui/autocdlg.hxx | 2 | ||||
-rw-r--r-- | svx/source/cui/autocdlg.src | 4 | ||||
-rw-r--r-- | svx/source/editeng/acorrcfg.cxx | 19 | ||||
-rw-r--r-- | svx/source/editeng/svxacorr.cxx | 54 |
10 files changed, 131 insertions, 2 deletions
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index e6218530561c..121a5fa478cd 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -1314,6 +1314,17 @@ Dymamic border coloring means that when the mouse is hovered over a control, and </info> <value>true</value> </prop> + <prop oor:name="AddNonBreakingSpace" oor:type="xs:boolean"> + <!-- OldPath: AutoCorrect/Options/All --> + <!-- OldLocation: Soffice.cfg --> + <!-- UIHints: Tools AutoCorrect/AutoFormat Options - Add non-breaking space --> + <info> + <author>cedricbosdo</author> + <desc>Adds a non-breaking space before the characters :;!? in french.</desc> + <label>Add non-breaking space</label> + </info> + <value>true</value> + </prop> <prop oor:name="RemoveDoubleSpaces" oor:type="xs:boolean"> <!-- OldPath: AutoCorrect/Options/All --> <!-- OldLocation: Soffice.cfg --> diff --git a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs index 1b21017e3f3c..d71af1791c55 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs @@ -4414,6 +4414,17 @@ </info> <value>true</value> </prop> + <prop oor:name="AddNonBreakingSpace" oor:type="xs:boolean"> + <!-- OldPath: Writer/AutoFormat/Options --> + <!-- OldLocation: Soffice.cfg --> + <!-- UIHints: Tools AutoCorrect/AutoFormat Options - Add non-breaking space --> + <info> + <author>cedricbosdo</author> + <desc>Adds a non-breaking space before the characters :!;? in french.</desc> + <label>Add non-breaking space</label> + </info> + <value>true</value> + </prop> <prop oor:name="DelEmptyParagraphs" oor:type="xs:boolean"> <!-- OldPath: Writer/AutoFormat/Options --> <!-- OldLocation: Soffice.cfg --> @@ -4590,6 +4601,17 @@ </info> <value>true</value> </prop> + <prop oor:name="AddNonBreakingSpace" oor:type="xs:boolean"> + <!-- OldPath: Writer/AutoFormat/Options --> + <!-- OldLocation: Soffice.cfg --> + <!-- UIHints: Tools AutoCorrect/AutoFormat Options - Add non-breaking space --> + <info> + <author>cedricbosdo</author> + <desc>Adds a non-breaking space before the characters :!;? in french.</desc> + <label>Add non-breaking space</label> + </info> + <value>true</value> + </prop> <prop oor:name="ChangeToBorders" oor:type="xs:boolean"> <!-- OldPath: Writer/AutoFormat/ByInput --> <!-- OldLocation: Soffice.cfg --> diff --git a/svx/inc/svx/svxacorr.hxx b/svx/inc/svx/svxacorr.hxx index ea4585b20af6..08da2ffabf0f 100644 --- a/svx/inc/svx/svxacorr.hxx +++ b/svx/inc/svx/svxacorr.hxx @@ -65,6 +65,7 @@ const long SaveWordCplSttLst= 0x00000200; // GrB. am SatzAnf. auto. aufnehmen const long SaveWordWrdSttLst= 0x00000400; // 2 GrB. am WortAnf. auto. aufnehmen const long IngnoreDoubleSpace= 0x00000800; // 2 Spaces ignorieren const long ChgSglQuotes = 0x00001000; // einfache Quotes ersetzen +const long AddNonBrkSpace = 0x00002000; // Add non breaking space before :;?! const long ChgWordLstLoad = 0x20000000; // Ersetzungsliste geladen const long CplSttLstLoad = 0x40000000; // Exceptionlist fuer CplStart geladen @@ -367,6 +368,9 @@ public: BOOL FnChgToEnEmDash( SvxAutoCorrDoc&, const String&, xub_StrLen nSttPos, xub_StrLen nEndPos, LanguageType eLang = LANGUAGE_SYSTEM ); + BOOL FnAddNonBrkSpace( SvxAutoCorrDoc&, const String&, + xub_StrLen nSttPos, xub_StrLen nEndPos, + LanguageType eLang = LANGUAGE_SYSTEM ); BOOL FnSetINetAttr( SvxAutoCorrDoc&, const String&, xub_StrLen nSttPos, xub_StrLen nEndPos, LanguageType eLang = LANGUAGE_SYSTEM ); diff --git a/svx/inc/svx/swafopt.hxx b/svx/inc/svx/swafopt.hxx index 86f569e46221..48f22d1a8db7 100644 --- a/svx/inc/svx/swafopt.hxx +++ b/svx/inc/svx/swafopt.hxx @@ -68,6 +68,7 @@ struct SVX_DLLPUBLIC SvxSwAutoFmtFlags BOOL bChgFracionSymbol : 1; BOOL bChgOrdinalNumber : 1; BOOL bChgToEnEmDash : 1; + BOOL bAddNonBrkSpace : 1; BOOL bChgWeightUnderl : 1; BOOL bSetINetAttr : 1; diff --git a/svx/source/cui/autocdlg.cxx b/svx/source/cui/autocdlg.cxx index 330459b224f1..07e8ddd2046f 100644 --- a/svx/source/cui/autocdlg.cxx +++ b/svx/source/cui/autocdlg.cxx @@ -233,6 +233,7 @@ OfaAutocorrOptionsPage::OfaAutocorrOptionsPage( Window* pParent, sNoDblSpaces (SVX_RES(STR_NO_DBL_SPACES )), sHalf (SVX_RES(ST_FRACTION )), sDash (SVX_RES(ST_DASH )), + sNonBrkSpace (SVX_RES(ST_NON_BREAK_SPACE )), sFirst (SVX_RES(ST_ORDINAL )) { FreeResource(); @@ -278,6 +279,7 @@ BOOL OfaAutocorrOptionsPage::FillItemSet( SfxItemSet& ) pAutoCorrect->SetAutoCorrFlag(ChgOrdinalNumber, aCheckLB.IsChecked(nPos++)); pAutoCorrect->SetAutoCorrFlag(ChgFractionSymbol, aCheckLB.IsChecked(nPos++)); pAutoCorrect->SetAutoCorrFlag(ChgToEnEmDash, aCheckLB.IsChecked(nPos++)); + pAutoCorrect->SetAutoCorrFlag(AddNonBrkSpace, aCheckLB.IsChecked(nPos++)); pAutoCorrect->SetAutoCorrFlag(IngnoreDoubleSpace, aCheckLB.IsChecked(nPos++)); BOOL bReturn = nFlags != pAutoCorrect->GetFlags(); @@ -319,6 +321,7 @@ void OfaAutocorrOptionsPage::Reset( const SfxItemSet& ) aCheckLB.InsertEntry(sFirst); aCheckLB.InsertEntry(sHalf); aCheckLB.InsertEntry(sDash); + aCheckLB.InsertEntry(sNonBrkSpace); aCheckLB.InsertEntry(sNoDblSpaces); USHORT nPos = 0; @@ -330,6 +333,7 @@ void OfaAutocorrOptionsPage::Reset( const SfxItemSet& ) aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & ChgOrdinalNumber) ); aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & ChgFractionSymbol) ); aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & ChgToEnEmDash) ); + aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & AddNonBrkSpace) ); aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & IngnoreDoubleSpace) ); aCheckLB.SetUpdateMode(TRUE); @@ -460,6 +464,7 @@ enum OfaAutoFmtOptions REPLACE_1ST, REPLACE_HALF, REPLACE_DASHES, + ADD_NON_BRK_SPACE, DEL_SPACES_AT_STT_END, DEL_SPACES_BETWEEN_LINES, IGNORE_DBLSPACE, @@ -495,6 +500,7 @@ OfaSwAutoFmtOptionsPage::OfaSwAutoFmtOptionsPage( Window* pParent, sFraction (SVX_RES( ST_FRACTION )), sDetectURL (SVX_RES( ST_DETECT_URL )), sDash (SVX_RES( ST_DASH )), + sNonBrkSpace (SVX_RES( ST_NON_BREAK_SPACE )), sOrdinal (SVX_RES( ST_ORDINAL )), sRightMargin (SVX_RES( ST_RIGHT_MARGIN )), sNum (SVX_RES( STR_NUM )), @@ -703,6 +709,12 @@ BOOL OfaSwAutoFmtOptionsPage::FillItemSet( SfxItemSet& ) pAutoCorrect->SetAutoCorrFlag(ChgToEnEmDash, aCheckLB.IsChecked(REPLACE_DASHES, CBCOL_SECOND)); + bCheck = aCheckLB.IsChecked(ADD_NON_BRK_SPACE, CBCOL_FIRST); + bModified |= pOpt->bAddNonBrkSpace != bCheck; + pOpt->bAddNonBrkSpace = bCheck; + pAutoCorrect->SetAutoCorrFlag(AddNonBrkSpace, + aCheckLB.IsChecked(ADD_NON_BRK_SPACE, CBCOL_SECOND)); + bCheck = aCheckLB.IsChecked(DEL_SPACES_AT_STT_END, CBCOL_FIRST); bModified |= pOpt->bAFmtDelSpacesAtSttEnd != bCheck; pOpt->bAFmtDelSpacesAtSttEnd = bCheck; @@ -759,6 +771,7 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet& ) aCheckLB.GetModel()->Insert(CreateEntry(sOrdinal, CBCOL_BOTH )); aCheckLB.GetModel()->Insert(CreateEntry(sFraction, CBCOL_BOTH )); aCheckLB.GetModel()->Insert(CreateEntry(sDash, CBCOL_BOTH )); + aCheckLB.GetModel()->Insert(CreateEntry(sNonBrkSpace, CBCOL_BOTH )); aCheckLB.GetModel()->Insert(CreateEntry(sDelSpaceAtSttEnd, CBCOL_BOTH )); aCheckLB.GetModel()->Insert(CreateEntry(sDelSpaceBetweenLines, CBCOL_BOTH )); @@ -790,6 +803,8 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet& ) aCheckLB.CheckEntryPos( REPLACE_HALF, CBCOL_SECOND, 0 != (nFlags & ChgFractionSymbol) ); aCheckLB.CheckEntryPos( REPLACE_DASHES, CBCOL_FIRST, pOpt->bChgToEnEmDash ); aCheckLB.CheckEntryPos( REPLACE_DASHES, CBCOL_SECOND, 0 != (nFlags & ChgToEnEmDash) ); + aCheckLB.CheckEntryPos( ADD_NON_BRK_SPACE, CBCOL_FIRST, 0 != (nFlags & AddNonBrkSpace) ); + aCheckLB.CheckEntryPos( ADD_NON_BRK_SPACE, CBCOL_SECOND, 0 != (nFlags & AddNonBrkSpace) ); aCheckLB.CheckEntryPos( DEL_SPACES_AT_STT_END, CBCOL_FIRST, pOpt->bAFmtDelSpacesAtSttEnd ); aCheckLB.CheckEntryPos( DEL_SPACES_AT_STT_END, CBCOL_SECOND, pOpt->bAFmtByInpDelSpacesAtSttEnd ); aCheckLB.CheckEntryPos( DEL_SPACES_BETWEEN_LINES, CBCOL_FIRST, pOpt->bAFmtDelSpacesBetweenLines ); diff --git a/svx/source/cui/autocdlg.hrc b/svx/source/cui/autocdlg.hrc index 6a698b4397d7..99a8683342a4 100644 --- a/svx/source/cui/autocdlg.hrc +++ b/svx/source/cui/autocdlg.hrc @@ -152,6 +152,7 @@ #define ST_DASH 208 #define FT_LANG 209 #define LB_LANG 210 +#define ST_NON_BREAK_SPACE 211 #define CB_SMARTTAGS 220 #define FT_SMARTTAGS 221 diff --git a/svx/source/cui/autocdlg.hxx b/svx/source/cui/autocdlg.hxx index dba6ce826cc3..712e0733cf22 100644 --- a/svx/source/cui/autocdlg.hxx +++ b/svx/source/cui/autocdlg.hxx @@ -118,6 +118,7 @@ private: String sNoDblSpaces; String sHalf; String sDash; + String sNonBrkSpace; String sFirst; public: @@ -160,6 +161,7 @@ class OfaSwAutoFmtOptionsPage : public SfxTabPage String sFraction; String sDetectURL; String sDash; + String sNonBrkSpace; String sOrdinal; String sRightMargin; String sNum; diff --git a/svx/source/cui/autocdlg.src b/svx/source/cui/autocdlg.src index a087bd7d59dc..ae78d573cefe 100644 --- a/svx/source/cui/autocdlg.src +++ b/svx/source/cui/autocdlg.src @@ -140,6 +140,10 @@ TabDialog RID_OFA_AUTOCORR_DLG String ST_DASH \ { \ Text [ en-US ] = "Replace dashes" ; \ + }; \ + String ST_NON_BREAK_SPACE \ + { \ + Text [ en-US ] = "Add non breaking space before : ; ? ! in french text" ; \ }; /**************************************************************************/ diff --git a/svx/source/editeng/acorrcfg.cxx b/svx/source/editeng/acorrcfg.cxx index 601e8497baa3..2284a0644923 100644 --- a/svx/source/editeng/acorrcfg.cxx +++ b/svx/source/editeng/acorrcfg.cxx @@ -128,8 +128,9 @@ Sequence<OUString> SvxBaseAutoCorrCfg::GetPropertyNames() "ReplaceDoubleQuote", // 14 "DoubleQuoteAtStart", // 15 "DoubleQuoteAtEnd" // 16 + "AddNonBreakingSpace" // 17 }; - const int nCount = 17; + const int nCount = 18; Sequence<OUString> aNames(nCount); OUString* pNames = aNames.getArray(); for(int i = 0; i < nCount; i++) @@ -229,6 +230,10 @@ void SvxBaseAutoCorrCfg::Load(sal_Bool bInit) rParent.pAutoCorrect->SetEndDoubleQuote( sal::static_int_cast< sal_Unicode >( nTemp ) ); break;//"DoubleQuoteAtEnd" + case 17: + if(*(sal_Bool*)pValues[nProp].getValue()) + nFlags |= AddNonBrkSpace; + break;//"AddNonBreakingSpace" } } } @@ -399,8 +404,10 @@ Sequence<OUString> SvxSwAutoCorrCfg::GetPropertyNames() "Format/ByInput/ApplyNumbering/SpecialCharacter/FontFamily", //45 "Format/ByInput/ApplyNumbering/SpecialCharacter/FontCharset", //46 "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch", //47 + "Format/Option/AddNonBreakingSpace", //48 + "Format/ByInput/AddNonBreakingSpace", //49 }; - const int nCount = 48; + const int nCount = 50; Sequence<OUString> aNames(nCount); OUString* pNames = aNames.getArray(); for(int i = 0; i < nCount; i++) @@ -552,6 +559,8 @@ void SvxSwAutoCorrCfg::Load(sal_Bool bInit) rSwFlags.aByInputBulletFont.SetPitch(FontPitch(nVal)); } break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch", + case 48 : rSwFlags.bAddNonBrkSpace = *(sal_Bool*)pValues[nProp].getValue( ); break;// "Format/Output/AddNonBreakingSpace", + case 49 : rSwFlags.bAddNonBrkSpace = *(sal_Bool*)pValues[nProp].getValue( ); break;// "Format/ByInput/AddNonBreakingSpace", } } } @@ -667,6 +676,12 @@ void SvxSwAutoCorrCfg::Commit() case 47 : pValues[nProp] <<= (sal_Int32)rSwFlags.aByInputBulletFont.GetPitch(); break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch", + case 48: + bVal = rSwFlags.bAddNonBrkSpace; pValues[nProp].setValue(&bVal, rType); + break; // "Format/Option/AddNonBreakingSpace", + case 49: + bVal = rSwFlags.bAddNonBrkSpace; pValues[nProp].setValue(&bVal, rType); + break; // "Format/ByInput/AddNonBreakingSpace", } } PutProperties(aNames, aValues); diff --git a/svx/source/editeng/svxacorr.cxx b/svx/source/editeng/svxacorr.cxx index 88e1543ab8c9..71e2f8425c7d 100644 --- a/svx/source/editeng/svxacorr.cxx +++ b/svx/source/editeng/svxacorr.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/io/XStream.hpp> +#include <com/sun/star/lang/Locale.hpp> #include <tools/urlobj.hxx> #include <tools/table.hxx> #include <i18npool/mslangid.hxx> @@ -97,6 +98,8 @@ #include <com/sun/star/ucb/NameClash.hpp> #include <xmloff/xmltoken.hxx> +#define CHAR_HARDBLANK ((sal_Unicode)0x00A0) + using namespace ::com::sun::star::ucb; using namespace ::com::sun::star::uno; using namespace ::com::sun::star; @@ -347,6 +350,7 @@ long SvxAutoCorrect::GetDefaultFlags() | ChgFractionSymbol | ChgOrdinalNumber | ChgToEnEmDash + | AddNonBrkSpace | ChgWeightUnderl | SetINetAttr | ChgQuotes @@ -692,6 +696,54 @@ BOOL SvxAutoCorrect::FnChgToEnEmDash( return bRet; } +BOOL SvxAutoCorrect::FnAddNonBrkSpace( + SvxAutoCorrDoc& rDoc, const String& rTxt, + xub_StrLen , xub_StrLen nEndPos, + LanguageType eLang ) +{ + bool bRet = false; + + CharClass& rCC = GetCharClass( eLang ); + const lang::Locale rLocale = rCC.getLocale( ); + + if ( rLocale.Language == OUString::createFromAscii( "fr" ) ) + { + OUString chars = OUString::createFromAscii( ":;!?" ); + if ( rLocale.Country == OUString::createFromAscii( "CA" ) ) + chars = OUString::createFromAscii( ":" ); + + sal_Unicode cChar = rTxt.GetChar( nEndPos ); + if ( chars.indexOf( sal_Unicode( cChar ) ) != -1 ) + { + // Check the previous char + sal_Unicode cPrevChar = rTxt.GetChar( nEndPos - 1 ); + if ( ( chars.indexOf( sal_Unicode( cPrevChar ) ) == -1 ) && cPrevChar != '\t' ) + { + // Remove any previous normal space + xub_StrLen nPos = nEndPos - 1; + while ( cPrevChar == ' ' || cPrevChar == CHAR_HARDBLANK ) + { + if ( nPos == 0 ) break; + nPos--; + cPrevChar = rTxt.GetChar( nPos ); + } + + if ( nPos != 0 ) + { + nPos++; + if ( nEndPos - nPos > 0 ) + rDoc.Delete( nPos, nEndPos ); + + // Add the non-breaking space at the end pos + rDoc.Insert( nPos, CHAR_HARDBLANK ); + bRet = true; + } + } + } + } + + return bRet; +} BOOL SvxAutoCorrect::FnSetINetAttr( SvxAutoCorrDoc& rDoc, const String& rTxt, xub_StrLen nSttPos, xub_StrLen nEndPos, @@ -1302,6 +1354,8 @@ ULONG SvxAutoCorrect::AutoCorrect( SvxAutoCorrDoc& rDoc, const String& rTxt, FnChgFractionSymbol( rDoc, rTxt, nCapLttrPos, nInsPos ) ) || ( IsAutoCorrFlag( nRet = ChgOrdinalNumber ) && FnChgOrdinalNumber( rDoc, rTxt, nCapLttrPos, nInsPos, eLang ) ) || + ( IsAutoCorrFlag( nRet = AddNonBrkSpace ) && + FnAddNonBrkSpace( rDoc, rTxt, nCapLttrPos, nInsPos - 1, eLang ) ) || ( IsAutoCorrFlag( nRet = SetINetAttr ) && ( ' ' == cChar || '\t' == cChar || 0x0a == cChar || !cChar ) && FnSetINetAttr( rDoc, rTxt, nCapLttrPos, nInsPos, eLang ) ) ) |