Update ooo320-m1
[ooovba.git] / applied_patches / 0415-cws-cbosdo01.diff
blob5c9301dfc60a18bc936e20614dd899f81247140e
1 diff --git svx/inc/svx/svxacorr.hxx svx/inc/svx/svxacorr.hxx
2 index 6771086..d414aed 100644
3 --- svx/inc/svx/svxacorr.hxx
4 +++ svx/inc/svx/svxacorr.hxx
5 @@ -67,6 +67,7 @@ const long SaveWordWrdSttLst= 0x00000400; // 2 GrB. am WortAnf. auto. aufnehmen
6 const long IngnoreDoubleSpace= 0x00000800; // 2 Spaces ignorieren
7 const long ChgSglQuotes = 0x00001000; // einfache Quotes ersetzen
8 const long CorrectCapsLock = 0x00002000; // Correct accidental use of cAPS LOCK key
9 +const long AddNonBrkSpace = 0x00004000; // Add non breaking space before :;?!
11 const long ChgWordLstLoad = 0x20000000; // Ersetzungsliste geladen
12 const long CplSttLstLoad = 0x40000000; // Exceptionlist fuer CplStart geladen
13 @@ -369,6 +370,9 @@ public:
14 BOOL FnChgToEnEmDash( SvxAutoCorrDoc&, const String&,
15 xub_StrLen nSttPos, xub_StrLen nEndPos,
16 LanguageType eLang = LANGUAGE_SYSTEM );
17 + BOOL FnAddNonBrkSpace( SvxAutoCorrDoc&, const String&,
18 + xub_StrLen nSttPos, xub_StrLen nEndPos,
19 + LanguageType eLang = LANGUAGE_SYSTEM );
20 BOOL FnSetINetAttr( SvxAutoCorrDoc&, const String&,
21 xub_StrLen nSttPos, xub_StrLen nEndPos,
22 LanguageType eLang = LANGUAGE_SYSTEM );
23 diff --git svx/inc/svx/swafopt.hxx svx/inc/svx/swafopt.hxx
24 index 18ae7e0..eb557ea 100644
25 --- svx/inc/svx/swafopt.hxx
26 +++ svx/inc/svx/swafopt.hxx
27 @@ -68,6 +68,7 @@ struct SVX_DLLPUBLIC SvxSwAutoFmtFlags
28 BOOL bChgFracionSymbol : 1;
29 BOOL bChgOrdinalNumber : 1;
30 BOOL bChgToEnEmDash : 1;
31 + BOOL bAddNonBrkSpace : 1;
32 BOOL bChgWeightUnderl : 1;
33 BOOL bSetINetAttr : 1;
35 diff --git svx/source/cui/autocdlg.cxx svx/source/cui/autocdlg.cxx
36 index f4c0a21..a517c98 100644
37 --- svx/source/cui/autocdlg.cxx
38 +++ svx/source/cui/autocdlg.cxx
39 @@ -233,6 +233,7 @@ OfaAutocorrOptionsPage::OfaAutocorrOptionsPage( Window* pParent,
40 sNoDblSpaces (SVX_RES(STR_NO_DBL_SPACES )),
41 sHalf (SVX_RES(ST_FRACTION )),
42 sDash (SVX_RES(ST_DASH )),
43 + sNonBrkSpace (SVX_RES(ST_NON_BREAK_SPACE )),
44 sFirst (SVX_RES(ST_ORDINAL )),
45 sAccidentalCaps (SVX_RES(ST_CORRECT_ACCIDENTAL_CAPS_LOCK))
47 @@ -279,6 +280,7 @@ BOOL OfaAutocorrOptionsPage::FillItemSet( SfxItemSet& )
48 pAutoCorrect->SetAutoCorrFlag(ChgOrdinalNumber, aCheckLB.IsChecked(nPos++));
49 pAutoCorrect->SetAutoCorrFlag(ChgFractionSymbol, aCheckLB.IsChecked(nPos++));
50 pAutoCorrect->SetAutoCorrFlag(ChgToEnEmDash, aCheckLB.IsChecked(nPos++));
51 + pAutoCorrect->SetAutoCorrFlag(AddNonBrkSpace, aCheckLB.IsChecked(nPos++));
52 pAutoCorrect->SetAutoCorrFlag(IngnoreDoubleSpace, aCheckLB.IsChecked(nPos++));
53 pAutoCorrect->SetAutoCorrFlag(CorrectCapsLock, aCheckLB.IsChecked(nPos++));
55 @@ -321,6 +323,7 @@ void OfaAutocorrOptionsPage::Reset( const SfxItemSet& )
56 aCheckLB.InsertEntry(sFirst);
57 aCheckLB.InsertEntry(sHalf);
58 aCheckLB.InsertEntry(sDash);
59 + aCheckLB.InsertEntry(sNonBrkSpace);
60 aCheckLB.InsertEntry(sNoDblSpaces);
61 aCheckLB.InsertEntry(sAccidentalCaps);
63 @@ -333,6 +336,7 @@ void OfaAutocorrOptionsPage::Reset( const SfxItemSet& )
64 aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & ChgOrdinalNumber) );
65 aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & ChgFractionSymbol) );
66 aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & ChgToEnEmDash) );
67 + aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & AddNonBrkSpace) );
68 aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & IngnoreDoubleSpace) );
69 aCheckLB.CheckEntryPos( nPos++, 0 != (nFlags & CorrectCapsLock) );
71 @@ -464,6 +468,7 @@ enum OfaAutoFmtOptions
72 REPLACE_1ST,
73 REPLACE_HALF,
74 REPLACE_DASHES,
75 + ADD_NON_BRK_SPACE,
76 DEL_SPACES_AT_STT_END,
77 DEL_SPACES_BETWEEN_LINES,
78 IGNORE_DBLSPACE,
79 @@ -501,6 +506,7 @@ OfaSwAutoFmtOptionsPage::OfaSwAutoFmtOptionsPage( Window* pParent,
80 sFraction (SVX_RES( ST_FRACTION )),
81 sDetectURL (SVX_RES( ST_DETECT_URL )),
82 sDash (SVX_RES( ST_DASH )),
83 + sNonBrkSpace (SVX_RES( ST_NON_BREAK_SPACE )),
84 sOrdinal (SVX_RES( ST_ORDINAL )),
85 sRightMargin (SVX_RES( ST_RIGHT_MARGIN )),
86 sNum (SVX_RES( STR_NUM )),
87 @@ -711,6 +717,12 @@ BOOL OfaSwAutoFmtOptionsPage::FillItemSet( SfxItemSet& )
88 pOpt->bChgToEnEmDash = bCheck;
89 pAutoCorrect->SetAutoCorrFlag(ChgToEnEmDash,
90 aCheckLB.IsChecked(REPLACE_DASHES, CBCOL_SECOND));
92 + bCheck = aCheckLB.IsChecked(ADD_NON_BRK_SPACE, CBCOL_FIRST);
93 + bModified |= pOpt->bAddNonBrkSpace != bCheck;
94 + pOpt->bAddNonBrkSpace = bCheck;
95 + pAutoCorrect->SetAutoCorrFlag(AddNonBrkSpace,
96 + aCheckLB.IsChecked(ADD_NON_BRK_SPACE, CBCOL_SECOND));
98 bCheck = aCheckLB.IsChecked(DEL_SPACES_AT_STT_END, CBCOL_FIRST);
99 bModified |= pOpt->bAFmtDelSpacesAtSttEnd != bCheck;
100 @@ -768,6 +780,7 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet& )
101 aCheckLB.GetModel()->Insert(CreateEntry(sOrdinal, CBCOL_BOTH ));
102 aCheckLB.GetModel()->Insert(CreateEntry(sFraction, CBCOL_BOTH ));
103 aCheckLB.GetModel()->Insert(CreateEntry(sDash, CBCOL_BOTH ));
104 + aCheckLB.GetModel()->Insert(CreateEntry(sNonBrkSpace, CBCOL_BOTH ));
105 aCheckLB.GetModel()->Insert(CreateEntry(sDelSpaceAtSttEnd, CBCOL_BOTH ));
106 aCheckLB.GetModel()->Insert(CreateEntry(sDelSpaceBetweenLines, CBCOL_BOTH ));
108 @@ -801,6 +814,8 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet& )
109 aCheckLB.CheckEntryPos( REPLACE_HALF, CBCOL_SECOND, 0 != (nFlags & ChgFractionSymbol) );
110 aCheckLB.CheckEntryPos( REPLACE_DASHES, CBCOL_FIRST, pOpt->bChgToEnEmDash );
111 aCheckLB.CheckEntryPos( REPLACE_DASHES, CBCOL_SECOND, 0 != (nFlags & ChgToEnEmDash) );
112 + aCheckLB.CheckEntryPos( ADD_NON_BRK_SPACE, CBCOL_FIRST, 0 != (nFlags & AddNonBrkSpace) );
113 + aCheckLB.CheckEntryPos( ADD_NON_BRK_SPACE, CBCOL_SECOND, 0 != (nFlags & AddNonBrkSpace) );
114 aCheckLB.CheckEntryPos( DEL_SPACES_AT_STT_END, CBCOL_FIRST, pOpt->bAFmtDelSpacesAtSttEnd );
115 aCheckLB.CheckEntryPos( DEL_SPACES_AT_STT_END, CBCOL_SECOND, pOpt->bAFmtByInpDelSpacesAtSttEnd );
116 aCheckLB.CheckEntryPos( DEL_SPACES_BETWEEN_LINES, CBCOL_FIRST, pOpt->bAFmtDelSpacesBetweenLines );
117 diff --git svx/source/cui/autocdlg.hrc svx/source/cui/autocdlg.hrc
118 index 38b3507..7aef1e4 100644
119 --- svx/source/cui/autocdlg.hrc
120 +++ svx/source/cui/autocdlg.hrc
121 @@ -153,6 +153,7 @@
122 #define FT_LANG 209
123 #define LB_LANG 210
124 #define ST_CORRECT_ACCIDENTAL_CAPS_LOCK 211
125 +#define ST_NON_BREAK_SPACE 212
127 #define CB_SMARTTAGS 220
128 #define FT_SMARTTAGS 221
129 diff --git svx/source/cui/autocdlg.hxx svx/source/cui/autocdlg.hxx
130 index ea5ee11..e3d1d3f 100644
131 --- svx/source/cui/autocdlg.hxx
132 +++ svx/source/cui/autocdlg.hxx
133 @@ -118,6 +118,7 @@ private:
134 String sNoDblSpaces;
135 String sHalf;
136 String sDash;
137 + String sNonBrkSpace;
138 String sFirst;
139 String sAccidentalCaps;
141 @@ -162,6 +163,7 @@ class OfaSwAutoFmtOptionsPage : public SfxTabPage
142 String sFraction;
143 String sDetectURL;
144 String sDash;
145 + String sNonBrkSpace;
146 String sOrdinal;
147 String sRightMargin;
148 String sNum;
149 diff --git svx/source/cui/autocdlg.src svx/source/cui/autocdlg.src
150 index 099f63a..47f6c62 100644
151 --- svx/source/cui/autocdlg.src
152 +++ svx/source/cui/autocdlg.src
153 @@ -144,6 +144,10 @@ TabDialog RID_OFA_AUTOCORR_DLG
154 String ST_CORRECT_ACCIDENTAL_CAPS_LOCK \
156 Text [ en-US ] = "Correct accidental use of cAPS LOCK key" ; \
157 + }; \
158 + String ST_NON_BREAK_SPACE \
159 + { \
160 + Text [ en-US ] = "Add non breaking space before : ; ? ! in french text" ; \
163 /**************************************************************************/
164 diff --git svx/source/editeng/acorrcfg.cxx svx/source/editeng/acorrcfg.cxx
165 index 95ecf61..9a794c2 100644
166 --- svx/source/editeng/acorrcfg.cxx
167 +++ svx/source/editeng/acorrcfg.cxx
168 @@ -128,9 +128,10 @@ Sequence<OUString> SvxBaseAutoCorrCfg::GetPropertyNames()
169 "ReplaceDoubleQuote", // 14
170 "DoubleQuoteAtStart", // 15
171 "DoubleQuoteAtEnd", // 16
172 - "CorrectAccidentalCapsLock" // 17
173 + "CorrectAccidentalCapsLock", // 17
174 + "AddNonBreakingSpace" // 18
176 - const int nCount = 18;
177 + const int nCount = 19;
178 Sequence<OUString> aNames(nCount);
179 OUString* pNames = aNames.getArray();
180 for(int i = 0; i < nCount; i++)
181 @@ -234,6 +235,10 @@ void SvxBaseAutoCorrCfg::Load(sal_Bool bInit)
182 if(*(sal_Bool*)pValues[nProp].getValue())
183 nFlags |= CorrectCapsLock;
184 break;//"CorrectAccidentalCapsLock"
185 + case 18:
186 + if(*(sal_Bool*)pValues[nProp].getValue())
187 + nFlags |= AddNonBrkSpace;
188 + break;//"AddNonBreakingSpace"
192 @@ -408,8 +413,10 @@ Sequence<OUString> SvxSwAutoCorrCfg::GetPropertyNames()
193 "Format/ByInput/ApplyNumbering/SpecialCharacter/FontFamily", //45
194 "Format/ByInput/ApplyNumbering/SpecialCharacter/FontCharset", //46
195 "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch", //47
196 + "Format/Option/AddNonBreakSpace", //48
197 + "Format/ByInput/AddNonBreakSpace", //49
199 - const int nCount = 48;
200 + const int nCount = 50;
201 Sequence<OUString> aNames(nCount);
202 OUString* pNames = aNames.getArray();
203 for(int i = 0; i < nCount; i++)
204 @@ -561,6 +568,8 @@ void SvxSwAutoCorrCfg::Load(sal_Bool bInit)
205 rSwFlags.aByInputBulletFont.SetPitch(FontPitch(nVal));
207 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch",
208 + case 48 : rSwFlags.bAddNonBrkSpace = *(sal_Bool*)pValues[nProp].getValue( ); break;// "Format/Output/AddNonBreakingSpace",
209 + case 49 : rSwFlags.bAddNonBrkSpace = *(sal_Bool*)pValues[nProp].getValue( ); break;// "Format/ByInput/AddNonBreakingSpace",
213 @@ -676,6 +685,12 @@ void SvxSwAutoCorrCfg::Commit()
214 case 47 :
215 pValues[nProp] <<= (sal_Int32)rSwFlags.aByInputBulletFont.GetPitch();
216 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch",
217 + case 48:
218 + bVal = rSwFlags.bAddNonBrkSpace; pValues[nProp].setValue(&bVal, rType);
219 + break; // "Format/Option/AddNonBreakingSpace",
220 + case 49:
221 + bVal = rSwFlags.bAddNonBrkSpace; pValues[nProp].setValue(&bVal, rType);
222 + break; // "Format/ByInput/AddNonBreakingSpace",
225 PutProperties(aNames, aValues);
226 diff --git svx/source/editeng/svxacorr.cxx svx/source/editeng/svxacorr.cxx
227 index a6e7401..fd7b093 100644
228 --- svx/source/editeng/svxacorr.cxx
229 +++ svx/source/editeng/svxacorr.cxx
230 @@ -33,6 +33,7 @@
233 #include <com/sun/star/io/XStream.hpp>
234 +#include <com/sun/star/lang/Locale.hpp>
235 #include <tools/urlobj.hxx>
236 #include <tools/table.hxx>
237 #include <i18npool/mslangid.hxx>
238 @@ -98,6 +99,8 @@
239 #include <com/sun/star/ucb/NameClash.hpp>
240 #include <xmloff/xmltoken.hxx>
242 +#define CHAR_HARDBLANK ((sal_Unicode)0x00A0)
244 using namespace ::com::sun::star::ucb;
245 using namespace ::com::sun::star::uno;
246 using namespace ::com::sun::star;
247 @@ -348,6 +351,7 @@ long SvxAutoCorrect::GetDefaultFlags()
248 | ChgFractionSymbol
249 | ChgOrdinalNumber
250 | ChgToEnEmDash
251 + | AddNonBrkSpace
252 | ChgWeightUnderl
253 | SetINetAttr
254 | ChgQuotes
255 @@ -694,6 +698,50 @@ BOOL SvxAutoCorrect::FnChgToEnEmDash(
256 return bRet;
259 +BOOL SvxAutoCorrect::FnAddNonBrkSpace(
260 + SvxAutoCorrDoc& rDoc, const String& rTxt,
261 + xub_StrLen , xub_StrLen nEndPos,
262 + LanguageType eLang )
264 + bool bRet = false;
266 + CharClass& rCC = GetCharClass( eLang );
267 + const lang::Locale rLocale = rCC.getLocale( );
269 + if ( rLocale.Language == OUString::createFromAscii( "fr" ) )
271 + sal_Unicode cChar = rTxt.GetChar( nEndPos );
272 + if ( cChar == ':' || cChar == ';' || cChar == '!' || cChar == '?' )
274 + // Check the previous char
275 + sal_Unicode cPrevChar = rTxt.GetChar( nEndPos - 1 );
276 + if ( cPrevChar != ':' && cPrevChar != ';' && cPrevChar != '!' && cPrevChar != '?' )
277 + {
278 + // Remove any previous normal space
279 + xub_StrLen nPos = nEndPos - 1;
280 + while ( cPrevChar == ' ' || cPrevChar == CHAR_HARDBLANK )
282 + if ( nPos == 0 ) break;
283 + nPos--;
284 + cPrevChar = rTxt.GetChar( nPos );
287 + if ( nPos != 0 )
289 + nPos++;
290 + if ( nEndPos - nPos > 0 )
291 + rDoc.Delete( nPos, nEndPos );
293 + // Add the non-breaking space at the end pos
294 + rDoc.Insert( nPos, CHAR_HARDBLANK );
295 + bRet = true;
301 + return bRet;
304 BOOL SvxAutoCorrect::FnSetINetAttr( SvxAutoCorrDoc& rDoc, const String& rTxt,
305 xub_StrLen nSttPos, xub_StrLen nEndPos,
306 @@ -1347,6 +1395,8 @@ ULONG SvxAutoCorrect::AutoCorrect( SvxAutoCorrDoc& rDoc, const String& rTxt,
307 FnChgFractionSymbol( rDoc, rTxt, nCapLttrPos, nInsPos ) ) ||
308 ( IsAutoCorrFlag( nRet = ChgOrdinalNumber ) &&
309 FnChgOrdinalNumber( rDoc, rTxt, nCapLttrPos, nInsPos, eLang ) ) ||
310 + ( IsAutoCorrFlag( nRet = AddNonBrkSpace ) &&
311 + FnAddNonBrkSpace( rDoc, rTxt, nCapLttrPos, nInsPos - 1, eLang ) ) ||
312 ( IsAutoCorrFlag( nRet = SetINetAttr ) &&
313 ( ' ' == cChar || '\t' == cChar || 0x0a == cChar || !cChar ) &&
314 FnSetINetAttr( rDoc, rTxt, nCapLttrPos, nInsPos, eLang ) ) )
315 diff --git sw/inc/comcore.hrc sw/inc/comcore.hrc
316 index 8260814..9122841 100644
317 --- sw/inc/comcore.hrc
318 +++ sw/inc/comcore.hrc
319 @@ -115,8 +115,9 @@
320 #define STR_AUTOFMTREDL_SET_TMPL_HEADLINE 18
321 #define STR_AUTOFMTREDL_SET_NUMBULET 19
322 #define STR_AUTOFMTREDL_DEL_MORELINES 20
323 +#define STR_AUTOFMTREDL_NON_BREAK_SPACE 21
324 // !!!!!!!!!!!!!!!!!!!!!!!!!! das Ende immer richtig setzen !!!!!!!!!!!!
325 -#define STR_AUTOFMTREDL_END 21
326 +#define STR_AUTOFMTREDL_END 22
329 #endif
330 diff --git sw/source/core/edit/autofmt.cxx sw/source/core/edit/autofmt.cxx
331 index 9622075..f4499b2 100644
332 --- sw/source/core/edit/autofmt.cxx
333 +++ sw/source/core/edit/autofmt.cxx
334 @@ -319,6 +319,7 @@ void SwAutoFormat::_SetRedlineTxt( USHORT nActionId )
335 case STR_AUTOFMTREDL_FRACTION:
336 case STR_AUTOFMTREDL_DASH:
337 case STR_AUTOFMTREDL_ORDINAL:
338 + case STR_AUTOFMTREDL_NON_BREAK_SPACE:
339 nSeqNo = ++nRedlAutoFmtSeqId;
340 break;
342 @@ -1885,7 +1886,7 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos )
343 !aFlags.bCptlSttSntnc && !aFlags.bCptlSttWrd &&
344 !aFlags.bChgFracionSymbol && !aFlags.bChgOrdinalNumber &&
345 !aFlags.bChgToEnEmDash && !aFlags.bSetINetAttr &&
346 - !aFlags.bChgWeightUnderl) )
347 + !aFlags.bChgWeightUnderl && !aFlags.bAddNonBrkSpace) )
348 return;
350 const String* pTxt = &pAktTxtNd->GetTxt();
351 @@ -1894,7 +1895,8 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos )
353 BOOL bGetLanguage = aFlags.bChgOrdinalNumber ||
354 aFlags.bChgToEnEmDash || aFlags.bSetINetAttr ||
355 - aFlags.bCptlSttWrd || aFlags.bCptlSttSntnc;
356 + aFlags.bCptlSttWrd || aFlags.bCptlSttSntnc ||
357 + aFlags.bAddNonBrkSpace;
360 aDelPam.DeleteMark();
361 @@ -2123,6 +2125,9 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos )
362 ( aFlags.bChgToEnEmDash &&
363 SetRedlineTxt( STR_AUTOFMTREDL_DASH ) &&
364 pATst->FnChgToEnEmDash( aACorrDoc, *pTxt, nSttPos, nPos, eLang ) ) ||
365 + ( aFlags.bAddNonBrkSpace &&
366 + SetRedlineTxt( STR_AUTOFMTREDL_NON_BREAK_SPACE ) &&
367 + pATst->FnAddNonBrkSpace( aACorrDoc, *pTxt, nSttPos, nPos, eLang ) ) ||
368 ( aFlags.bSetINetAttr &&
369 ( nPos == pTxt->Len() || IsSpace( pTxt->GetChar( nPos )) ) &&
370 SetRedlineTxt( STR_AUTOFMTREDL_DETECT_URL ) &&
371 diff --git sw/source/ui/utlui/utlui.src sw/source/ui/utlui/utlui.src
372 index 7a45772..3aad027 100644
373 --- sw/source/ui/utlui/utlui.src
374 +++ sw/source/ui/utlui/utlui.src
375 @@ -122,6 +122,10 @@ Resource RID_SHELLRES_AUTOFMTSTRS
377 Text [ en-US ] = "Combine paragraphs";
379 + String STR_AUTOFMTREDL_NON_BREAK_SPACE +1
381 + Text [ en-US ] = "Add non breaking space";
382 + };