aboutsummaryrefslogtreecommitdiff
path: root/editors/openoffice.org-3/files/patch-wrtrtf
blob: 7381dc61cd69974f96993f230aca1cb5df42cb7d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
--- ../svtools/source/svrtf/rtfout.cxx.orig	2000-10-16 18:13:46.000000000 +0900
+++ ../svtools/source/svrtf/rtfout.cxx	2003-09-23 12:41:00.000000000 +0900
@@ -124,8 +124,9 @@
 	default:
 		{
 			sal_Unicode cCh = c;
-			c = (BYTE)ByteString::ConvertFromUnicode( c, eDestEnc, FALSE );
-			if( !c )
+			rtl::OString buff( &c, 1, eDestEnc, RTL_UNICODETOTEXT_FLAGS_UNDEFINED_IGNORE|RTL_UNICODETOTEXT_FLAGS_INVALID_IGNORE );
+//			c = (BYTE)ByteString::ConvertFromUnicode( c, eDestEnc, FALSE );
+			if( !buff.getLength() )
 			{
 				// then write as unicode - character
 				if( 0xFF < cCh )
@@ -141,8 +142,8 @@
 				break;
 			}
 
-			if( !bWriteHelpFile )
-				switch( c )
+			if( !bWriteHelpFile && buff.getLength() == 1 )
+				switch( BYTE(buff[0]) )
 				{
 #ifdef MAC
 				case 0xa5:			pStr = sRTF_BULLET; break;
@@ -164,6 +165,9 @@
 			// MAC
 				}
 			if( !pStr )
+			    for (int i = 0; i < buff.getLength(); ++i)
+			    {
+				c = BYTE(buff[i]);
 				switch ( c )
 				{
 				case '\\':
@@ -186,6 +190,7 @@
 					}
 					break;
 				}
+			    }
 		}
 		break;
 	}
--- ../sw/source/filter/rtf/wrtrtf.cxx.orig	2003-04-18 00:00:28.000000000 +0900
+++ ../sw/source/filter/rtf/wrtrtf.cxx	2003-09-23 23:33:08.000000000 +0900
@@ -184,6 +184,12 @@
 #ifndef _CHARFMT_HXX
 #include <charfmt.hxx>
 #endif
+#ifndef _POOLFMT_HXX
+#include <poolfmt.hxx>
+#endif
+#ifndef _SWSTYLENAMEMAPPER_HXX
+#include <SwStyleNameMapper.hxx>
+#endif
 #ifndef _SECTION_HXX //autogen
 #include <section.hxx>
 #endif
@@ -215,7 +221,7 @@
 SV_IMPL_VARARR( RTFColorTbl, Color )
 
 
-SwRTFWriter::SwRTFWriter( const String& rFltName )
+SwRTFWriter::SwRTFWriter( const String& rFltName ) : eCurrentCharSet(DEF_ENCODING)
 {
 	// schreibe Win-RTF-HelpFileFmt
 	bWriteHelpFmt = 'W' == rFltName.GetChar( 0 );
@@ -893,14 +899,14 @@
 		//				as alternative name. Because WinWord can't match each
 		//				font to a UniCode font. So the CJK texts are shown as
 		//				empty rectangles ;-(.
-		RTFOutFuncs::Out_String( rWrt.Strm(), sFntNm, DEF_ENCODING,
+		RTFOutFuncs::Out_String( rWrt.Strm(), sFntNm, eChrSet,
 							 	rWrt.bWriteHelpFmt );
 		OutComment( rWrt, sRTF_FALT) << ' ';
-		RTFOutFuncs::Out_String( rWrt.Strm(), sAltNm, DEF_ENCODING,
+		RTFOutFuncs::Out_String( rWrt.Strm(), sAltNm, eChrSet,
 									rWrt.bWriteHelpFmt ) << '}';
 	}
 	else
-		RTFOutFuncs::Out_String( rWrt.Strm(), sFntNm, DEF_ENCODING,
+		RTFOutFuncs::Out_String( rWrt.Strm(), sFntNm, eChrSet,
 							 	rWrt.bWriteHelpFmt );
 	rWrt.Strm() << ";}";
 }
@@ -932,6 +938,139 @@
 
 
 
+//Takashi Ono for CJK
+const rtl::OUString SwRTFWriter::XlateFmtName( const rtl::OUString &rName, SwGetPoolIdFromName eFlags )
+{
+#define RES_NONE RES_POOLCOLL_DOC_END
+
+	static const RES_POOL_COLLFMT_TYPE aArr[]={
+		RES_POOLCOLL_STANDARD, RES_POOLCOLL_HEADLINE1, RES_POOLCOLL_HEADLINE2,
+		RES_POOLCOLL_HEADLINE3, RES_POOLCOLL_HEADLINE4, RES_POOLCOLL_HEADLINE5,
+		RES_POOLCOLL_HEADLINE6, RES_POOLCOLL_HEADLINE7, RES_POOLCOLL_HEADLINE8,
+		RES_POOLCOLL_HEADLINE9,
+
+		RES_POOLCOLL_TOX_IDX1, RES_POOLCOLL_TOX_IDX2, RES_POOLCOLL_TOX_IDX3,
+		RES_NONE, RES_NONE, RES_NONE, RES_NONE, RES_NONE, RES_NONE,
+		RES_POOLCOLL_TOX_CNTNT1,
+
+		RES_POOLCOLL_TOX_CNTNT2, RES_POOLCOLL_TOX_CNTNT3, RES_POOLCOLL_TOX_CNTNT4,
+		RES_POOLCOLL_TOX_CNTNT5, RES_POOLCOLL_TOX_CNTNT6, RES_POOLCOLL_TOX_CNTNT7,
+		RES_POOLCOLL_TOX_CNTNT8, RES_POOLCOLL_TOX_CNTNT9,
+		RES_POOLCOLL_TEXT_IDENT, RES_POOLCOLL_FOOTNOTE,
+
+		RES_NONE, RES_POOLCOLL_HEADER, RES_POOLCOLL_FOOTER, RES_POOLCOLL_TOX_IDXH,
+		RES_POOLCOLL_LABEL, RES_POOLCOLL_TOX_ILLUSH, RES_POOLCOLL_JAKETADRESS, RES_POOLCOLL_SENDADRESS,
+		RES_NONE, RES_NONE,
+
+		RES_NONE, RES_NONE, RES_NONE, RES_POOLCOLL_ENDNOTE, RES_POOLCOLL_TOX_AUTHORITIESH, RES_NONE, RES_NONE,
+		RES_POOLCOLL_BUL_LEVEL1, RES_POOLCOLL_BUL_LEVEL1, RES_POOLCOLL_NUM_LEVEL1,
+
+		RES_POOLCOLL_BUL_LEVEL2, RES_POOLCOLL_BUL_LEVEL3, RES_POOLCOLL_BUL_LEVEL4, RES_POOLCOLL_BUL_LEVEL5,
+		RES_POOLCOLL_BUL_LEVEL2, RES_POOLCOLL_BUL_LEVEL3, RES_POOLCOLL_BUL_LEVEL4, RES_POOLCOLL_BUL_LEVEL5,
+		RES_POOLCOLL_NUM_LEVEL2, RES_POOLCOLL_NUM_LEVEL3, RES_POOLCOLL_NUM_LEVEL4, RES_POOLCOLL_NUM_LEVEL5,
+
+		RES_POOLCOLL_DOC_TITEL, RES_NONE, RES_POOLCOLL_SIGNATURE, RES_NONE,
+		RES_POOLCOLL_TEXT, RES_POOLCOLL_TEXT_MOVE, RES_NONE, RES_NONE,
+
+		RES_NONE, RES_NONE, RES_NONE, RES_NONE, RES_POOLCOLL_DOC_SUBTITEL };
+	static const sal_Char *stiName[] = {
+		"Normal",
+		"heading 1",
+		"heading 2",
+		"heading 3",
+		"heading 4",
+		"heading 5",
+		"heading 6",
+		"heading 7",
+		"heading 8",
+		"heading 9",
+		"index 1",
+		"index 2",
+		"index 3",
+		"index 4",
+		"index 5",
+		"index 6",
+		"index 7",
+		"index 8",
+		"index 9",
+		"toc 1",
+		"toc 2",
+		"toc 3",
+		"toc 4",
+		"toc 5",
+		"toc 6",
+		"toc 7",
+		"toc 8",
+		"toc 9",
+		"Normal Indent",
+		"footnote text",
+		"annotation text",
+		"header",
+		"footer",
+		"index heading",
+		"caption",
+		"table of figures",
+		"envelope address",
+		"envelope return",
+		"footnote reference",
+		"annotation reference",
+		"line number",
+		"page number",
+		"endnote reference",
+		"endnote text",
+		"table of authorities",
+		"macro",
+		"toa heading",
+		"List",
+		"List Bullet",
+		"List Number",
+		"List 2",
+		"List 3",
+		"List 4",
+		"List 5",
+		"List Bullet 2",
+		"List Bullet 3",
+		"List Bullet 4",
+		"List Bullet 5",
+		"List Number 2",
+		"List Number 3",
+		"List Number 4",
+		"List Number 5",
+		"Title",
+		"Closing",
+		"Signature",
+		"Default Paragraph Font",
+		"Body Text",
+		"Body Text Indent",
+		"List Continue",
+		"List Continue 2",
+		"List Continue 3",
+		"List Continue 4",
+		"List Continue 5",
+		"Message Header",
+		"Subtitle",
+	};
+
+
+	ASSERT( ( sizeof( aArr ) / sizeof( RES_POOL_COLLFMT_TYPE ) == 75 ),
+			"Style-UEbersetzungstabelle hat falsche Groesse" );
+	ASSERT( ( sizeof( stiName ) / sizeof( *stiName ) == 75 ),
+			"Style-UEbersetzungstabelle hat falsche Groesse" );
+
+	sal_uInt16 idcol = ::SwStyleNameMapper::GetPoolIdFromUIName( rName, eFlags );
+ 
+	for (int i = 0; i < sizeof( aArr ) / sizeof( *aArr ); i++)
+	{
+		if ( idcol == aArr[i] )
+		{
+			return rtl::OUString::createFromAscii(stiName[i]);
+		}
+	}
+	return ::SwStyleNameMapper::GetProgName( idcol, String() );
+}
+
+
+
 void SwRTFWriter::OutRTFStyleTab()
 {
 	// das 0-Style ist das Default, wird nie ausgegeben !!
@@ -988,7 +1127,7 @@
 		}
 
 		Strm() << ' ';
-		RTFOutFuncs::Out_String( Strm(), pColl->GetName(), DEF_ENCODING,
+		RTFOutFuncs::Out_String( Strm(), XlateFmtName( pColl->GetName(), GET_POOLID_TXTCOLL ), DEF_ENCODING,
 						bWriteHelpFmt ) << ";}" << SwRTFWriter::sNewLine;
 	}
 
@@ -1015,8 +1154,8 @@
 				}
 
 		Strm() << ' ';
-		RTFOutFuncs::Out_String( Strm(), pFmt->GetName(), DEF_ENCODING,
-					bWriteHelpFmt ) << ";}" << SwRTFWriter::sNewLine;
+		RTFOutFuncs::Out_String( Strm(), XlateFmtName( pFmt->GetName(), GET_POOLID_CHRFMT ), DEF_ENCODING,
+						bWriteHelpFmt ) << ";}" << SwRTFWriter::sNewLine;
 	}
 
 	Strm() << '}';
@@ -1217,8 +1356,8 @@
 				break;
 		Strm() << sRTF_PGDSCNXT;
 		OutULong( i ) << ' ';
-		RTFOutFuncs::Out_String( Strm(), rPageDesc.GetName(),
-								DEF_ENCODING, bWriteHelpFmt ) << ";}";
+		RTFOutFuncs::Out_String( Strm(), XlateFmtName( rPageDesc.GetName(), GET_POOLID_PAGEDESC ), DEF_ENCODING,
+						bWriteHelpFmt ) << ";}";
 	}
 	Strm() << '}' << SwRTFWriter::sNewLine;
 	bOutPageDesc = bOutPageDescTbl = FALSE;
--- ../sw/source/filter/rtf/wrtrtf.hxx.orig	2002-07-31 19:18:50.000000000 +0900
+++ ../sw/source/filter/rtf/wrtrtf.hxx	2003-09-23 23:37:50.000000000 +0900
@@ -117,6 +117,7 @@
 	USHORT nAktFlyPos;				// Index auf das naechste "FlyFrmFmt"
 	void OutRTFColorTab();
 	void OutRTFFontTab();
+	const rtl::OUString XlateFmtName( const rtl::OUString &rName, SwGetPoolIdFromName eFlags );
 	void OutRTFStyleTab();
 	void OutRTFListTab();
 
@@ -136,6 +137,8 @@
 	USHORT nBkmkTabPos;				// akt. Position in der Bookmark-Tabelle
 	USHORT nCurScript;				    // actual scripttype
 
+	rtl_TextEncoding eCurrentCharSet;
+
 #if defined(MAC) || defined(UNX)
 	static const sal_Char sNewLine;					// nur \012 oder \015
 #else
--- ../sw/source/filter/rtf/rtfatr.cxx.orig	2003-05-19 21:24:46.000000000 +0900
+++ ../sw/source/filter/rtf/rtfatr.cxx	2003-09-23 23:45:52.000000000 +0900
@@ -1319,7 +1319,7 @@
 				sURL = aTmp.GetFull();
 			}
 */			rWrt.Strm()	<< '\"';
-			RTFOutFuncs::Out_String( rWrt.Strm(), sURL, DEF_ENCODING,
+			RTFOutFuncs::Out_String( rWrt.Strm(), sURL, rRTFWrt.eCurrentCharSet,
 									rRTFWrt.bWriteHelpFmt ) << "\" ";
 			sURL = aTmp.GetMark();
 		}
@@ -1328,7 +1328,7 @@
 		{
 			rWrt.Strm() << "\\\\l \"";
 			sURL.Erase( 0, 1 );
-			RTFOutFuncs::Out_String( rWrt.Strm(), sURL, DEF_ENCODING,
+			RTFOutFuncs::Out_String( rWrt.Strm(), sURL, rRTFWrt.eCurrentCharSet,
 									rRTFWrt.bWriteHelpFmt ) << "\" ";
 		}
 
@@ -1609,7 +1609,7 @@
 
 		if( nStrPos != nEnde )
 			RTFOutFuncs::Out_Char( rWrt.Strm(), rStr.GetChar( nStrPos ),
-									DEF_ENCODING, rRTFWrt.bWriteHelpFmt );
+									rRTFWrt.eCurrentCharSet, rRTFWrt.bWriteHelpFmt );
     }
 
 	// noch eine schliesende Klammer da ??
@@ -2188,6 +2188,7 @@
 		const sal_Char* pCmd = bAssoc ? sRTF_AF : sRTF_F;
 		rWrt.Strm() << pCmd;
 		rWrt.OutULong(rRTFWrt.GetId(rFont));
+		rRTFWrt.eCurrentCharSet = rFont.GetCharSet();
 	}
 	return rWrt;
 }