1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26
27 #include <swtypes.hxx>
28 #include <cmdid.h>
29 #include <hintids.hxx>
30 #include <svx/svxids.hrc>
31 #include <doc.hxx>
32 #include <docary.hxx>
33 #include <fmtcol.hxx>
34 #include <poolfmt.hxx>
35 #include <unocoll.hxx>
36 #include <unosett.hxx>
37 #include <fmtanchr.hxx>
38 #include <ndtxt.hxx>
39 #include <section.hxx>
40 #include <IMark.hxx>
41 #include <ftnidx.hxx>
42 #include <fmtftn.hxx>
43 #include <txtftn.hxx>
44 #include <fmtpdsc.hxx>
45 #include <pagedesc.hxx>
46 #include <vos/mutex.hxx>
47 #include <com/sun/star/text/XTextTableCursor.hpp>
48 #include <com/sun/star/text/XTextTablesSupplier.hpp>
49 #include <com/sun/star/text/TableColumnSeparator.hpp>
50 #include <com/sun/star/text/XTextTable.hpp>
51 #include <svl/PasswordHelper.hxx>
52 #include <svtools/unoimap.hxx>
53 #include <svtools/unoevent.hxx>
54 #include <unotbl.hxx>
55 #include <unostyle.hxx>
56 #include <unofield.hxx>
57 #include <unoidx.hxx>
58 #include <unoframe.hxx>
59 #include <unofootnote.hxx>
60 #include <vcl/svapp.hxx>
61 #include <fmtcntnt.hxx>
62 #include <authfld.hxx>
63 #include <SwXTextDefaults.hxx>
64 #include <unochart.hxx>
65 #include <comphelper/makesequence.hxx>
66 #include <comphelper/sequence.hxx>
67 #include <list>
68 #include <iterator>
69 #include <unosection.hxx>
70 #include <unoparagraph.hxx>
71 #include <unobookmark.hxx>
72 #include <unorefmark.hxx>
73 #include <unometa.hxx>
74 #include "docsh.hxx"
75 #include <switerator.hxx>
76
77 using ::rtl::OUString;
78 using namespace ::com::sun::star;
79 using namespace ::com::sun::star::document;
80 using namespace ::com::sun::star::uno;
81 using namespace ::com::sun::star::text;
82 using namespace ::com::sun::star::container;
83 using namespace ::com::sun::star::lang;
84
85 /******************************************************************************
86 *
87 ******************************************************************************/
88 struct ProvNamesId_Type
89 {
90 const char * pName;
91 sal_uInt16 nType;
92 };
93
94 // note: this thing is indexed as an array, so do not insert/remove entries!
95 const ProvNamesId_Type __FAR_DATA aProvNamesId[] =
96 {
97 { "com.sun.star.text.TextTable", SW_SERVICE_TYPE_TEXTTABLE },
98 { "com.sun.star.text.TextFrame", SW_SERVICE_TYPE_TEXTFRAME },
99 { "com.sun.star.text.GraphicObject", SW_SERVICE_TYPE_GRAPHIC },
100 { "com.sun.star.text.TextEmbeddedObject", SW_SERVICE_TYPE_OLE },
101 { "com.sun.star.text.Bookmark", SW_SERVICE_TYPE_BOOKMARK },
102 { "com.sun.star.text.Footnote", SW_SERVICE_TYPE_FOOTNOTE },
103 { "com.sun.star.text.Endnote", SW_SERVICE_TYPE_ENDNOTE },
104 { "com.sun.star.text.DocumentIndexMark", SW_SERVICE_TYPE_INDEXMARK },
105 { "com.sun.star.text.DocumentIndex", SW_SERVICE_TYPE_INDEX },
106 { "com.sun.star.text.ReferenceMark", SW_SERVICE_REFERENCE_MARK },
107 { "com.sun.star.style.CharacterStyle", SW_SERVICE_STYLE_CHARACTER_STYLE },
108 { "com.sun.star.style.ParagraphStyle", SW_SERVICE_STYLE_PARAGRAPH_STYLE },
109 { "com.sun.star.style.FrameStyle", SW_SERVICE_STYLE_FRAME_STYLE },
110 { "com.sun.star.style.PageStyle", SW_SERVICE_STYLE_PAGE_STYLE },
111 { "com.sun.star.style.NumberingStyle", SW_SERVICE_STYLE_NUMBERING_STYLE },
112 { "com.sun.star.text.ContentIndexMark", SW_SERVICE_CONTENT_INDEX_MARK },
113 { "com.sun.star.text.ContentIndex", SW_SERVICE_CONTENT_INDEX },
114 { "com.sun.star.text.UserIndexMark", SW_SERVICE_USER_INDEX_MARK },
115 { "com.sun.star.text.UserIndex", SW_SERVICE_USER_INDEX },
116 { "com.sun.star.text.TextSection", SW_SERVICE_TEXT_SECTION },
117 { "com.sun.star.text.TextField.DateTime", SW_SERVICE_FIELDTYPE_DATETIME },
118 { "com.sun.star.text.TextField.User", SW_SERVICE_FIELDTYPE_USER },
119 { "com.sun.star.text.TextField.SetExpression", SW_SERVICE_FIELDTYPE_SET_EXP },
120 { "com.sun.star.text.TextField.GetExpression", SW_SERVICE_FIELDTYPE_GET_EXP },
121 { "com.sun.star.text.TextField.FileName", SW_SERVICE_FIELDTYPE_FILE_NAME },
122 { "com.sun.star.text.TextField.PageNumber", SW_SERVICE_FIELDTYPE_PAGE_NUM },
123 { "com.sun.star.text.TextField.Author", SW_SERVICE_FIELDTYPE_AUTHOR },
124 { "com.sun.star.text.TextField.Chapter", SW_SERVICE_FIELDTYPE_CHAPTER },
125 { "", SW_SERVICE_FIELDTYPE_DUMMY_0 },
126 { "com.sun.star.text.TextField.GetReference", SW_SERVICE_FIELDTYPE_GET_REFERENCE },
127 { "com.sun.star.text.TextField.ConditionalText", SW_SERVICE_FIELDTYPE_CONDITIONED_TEXT },
128 { "com.sun.star.text.TextField.Annotation", SW_SERVICE_FIELDTYPE_ANNOTATION },
129 { "com.sun.star.text.TextField.Input", SW_SERVICE_FIELDTYPE_INPUT },
130 { "com.sun.star.text.TextField.Macro", SW_SERVICE_FIELDTYPE_MACRO },
131 { "com.sun.star.text.TextField.DDE", SW_SERVICE_FIELDTYPE_DDE },
132 { "com.sun.star.text.TextField.HiddenParagraph", SW_SERVICE_FIELDTYPE_HIDDEN_PARA },
133 { "" /*com.sun.star.text.TextField.DocumentInfo"*/, SW_SERVICE_FIELDTYPE_DOC_INFO },
134 { "com.sun.star.text.TextField.TemplateName", SW_SERVICE_FIELDTYPE_TEMPLATE_NAME },
135 { "com.sun.star.text.TextField.ExtendedUser", SW_SERVICE_FIELDTYPE_USER_EXT },
136 { "com.sun.star.text.TextField.ReferencePageSet", SW_SERVICE_FIELDTYPE_REF_PAGE_SET },
137 { "com.sun.star.text.TextField.ReferencePageGet", SW_SERVICE_FIELDTYPE_REF_PAGE_GET },
138 { "com.sun.star.text.TextField.JumpEdit", SW_SERVICE_FIELDTYPE_JUMP_EDIT },
139 { "com.sun.star.text.TextField.Script", SW_SERVICE_FIELDTYPE_SCRIPT },
140 { "com.sun.star.text.TextField.DatabaseNextSet", SW_SERVICE_FIELDTYPE_DATABASE_NEXT_SET },
141 { "com.sun.star.text.TextField.DatabaseNumberOfSet", SW_SERVICE_FIELDTYPE_DATABASE_NUM_SET },
142 { "com.sun.star.text.TextField.DatabaseSetNumber", SW_SERVICE_FIELDTYPE_DATABASE_SET_NUM },
143 { "com.sun.star.text.TextField.Database", SW_SERVICE_FIELDTYPE_DATABASE },
144 { "com.sun.star.text.TextField.DatabaseName", SW_SERVICE_FIELDTYPE_DATABASE_NAME },
145 { "com.sun.star.text.TextField.TableFormula", SW_SERVICE_FIELDTYPE_TABLE_FORMULA },
146 { "com.sun.star.text.TextField.PageCount", SW_SERVICE_FIELDTYPE_PAGE_COUNT },
147 { "com.sun.star.text.TextField.ParagraphCount", SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT },
148 { "com.sun.star.text.TextField.WordCount", SW_SERVICE_FIELDTYPE_WORD_COUNT },
149 { "com.sun.star.text.TextField.CharacterCount", SW_SERVICE_FIELDTYPE_CHARACTER_COUNT },
150 { "com.sun.star.text.TextField.TableCount", SW_SERVICE_FIELDTYPE_TABLE_COUNT },
151 { "com.sun.star.text.TextField.GraphicObjectCount", SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT },
152 { "com.sun.star.text.TextField.EmbeddedObjectCount", SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT },
153 { "com.sun.star.text.TextField.DocInfo.ChangeAuthor", SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR },
154 { "com.sun.star.text.TextField.DocInfo.ChangeDateTime", SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME },
155 { "com.sun.star.text.TextField.DocInfo.EditTime", SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME },
156 { "com.sun.star.text.TextField.DocInfo.Description", SW_SERVICE_FIELDTYPE_DOCINFO_DESCRIPTION },
157 { "com.sun.star.text.TextField.DocInfo.CreateAuthor", SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_AUTHOR },
158 { "com.sun.star.text.TextField.DocInfo.CreateDateTime", SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME },
159 { "", SW_SERVICE_FIELDTYPE_DUMMY_0 },
160 { "", SW_SERVICE_FIELDTYPE_DUMMY_1 },
161 { "", SW_SERVICE_FIELDTYPE_DUMMY_2 },
162 { "", SW_SERVICE_FIELDTYPE_DUMMY_3 },
163 { "com.sun.star.text.TextField.DocInfo.Custom", SW_SERVICE_FIELDTYPE_DOCINFO_CUSTOM },
164 { "com.sun.star.text.TextField.DocInfo.PrintAuthor", SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_AUTHOR },
165 { "com.sun.star.text.TextField.DocInfo.PrintDateTime", SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME },
166 { "com.sun.star.text.TextField.DocInfo.KeyWords", SW_SERVICE_FIELDTYPE_DOCINFO_KEY_WORDS },
167 { "com.sun.star.text.TextField.DocInfo.Subject", SW_SERVICE_FIELDTYPE_DOCINFO_SUBJECT },
168 { "com.sun.star.text.TextField.DocInfo.Title", SW_SERVICE_FIELDTYPE_DOCINFO_TITLE },
169 { "com.sun.star.text.TextField.DocInfo.Revision", SW_SERVICE_FIELDTYPE_DOCINFO_REVISION },
170 { "com.sun.star.text.TextField.Bibliography", SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY },
171 { "com.sun.star.text.TextField.CombinedCharacters", SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS },
172 { "com.sun.star.text.TextField.DropDown", SW_SERVICE_FIELDTYPE_DROPDOWN },
173 { "com.sun.star.text.textfield.MetadataField", SW_SERVICE_FIELDTYPE_METAFIELD },
174 { "", SW_SERVICE_FIELDTYPE_DUMMY_4 },
175 { "", SW_SERVICE_FIELDTYPE_DUMMY_5 },
176 { "", SW_SERVICE_FIELDTYPE_DUMMY_6 },
177 { "", SW_SERVICE_FIELDTYPE_DUMMY_7 },
178 { "com.sun.star.text.FieldMaster.User", SW_SERVICE_FIELDMASTER_USER },
179 { "com.sun.star.text.FieldMaster.DDE", SW_SERVICE_FIELDMASTER_DDE },
180 { "com.sun.star.text.FieldMaster.SetExpression", SW_SERVICE_FIELDMASTER_SET_EXP },
181 { "com.sun.star.text.FieldMaster.Database", SW_SERVICE_FIELDMASTER_DATABASE },
182 { "com.sun.star.text.FieldMaster.Bibliography", SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY },
183 { "", SW_SERVICE_FIELDMASTER_DUMMY2 },
184 { "", SW_SERVICE_FIELDMASTER_DUMMY3 },
185 { "", SW_SERVICE_FIELDMASTER_DUMMY4 },
186 { "", SW_SERVICE_FIELDMASTER_DUMMY5 },
187 { "com.sun.star.text.IllustrationsIndex", SW_SERVICE_INDEX_ILLUSTRATIONS },
188 { "com.sun.star.text.ObjectIndex", SW_SERVICE_INDEX_OBJECTS },
189 { "com.sun.star.text.TableIndex", SW_SERVICE_INDEX_TABLES },
190 { "com.sun.star.text.Bibliography", SW_SERVICE_INDEX_BIBLIOGRAPHY },
191 { "com.sun.star.text.Paragraph", SW_SERVICE_PARAGRAPH },
192 { "com.sun.star.text.TextField.InputUser", SW_SERVICE_FIELDTYPE_INPUT_USER },
193 { "com.sun.star.text.TextField.HiddenText", SW_SERVICE_FIELDTYPE_HIDDEN_TEXT },
194 { "com.sun.star.style.ConditionalParagraphStyle", SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE },
195 { "com.sun.star.text.NumberingRules", SW_SERVICE_NUMBERING_RULES },
196 { "com.sun.star.text.TextColumns", SW_SERVICE_TEXT_COLUMNS },
197 { "com.sun.star.text.IndexHeaderSection", SW_SERVICE_INDEX_HEADER_SECTION },
198 { "com.sun.star.text.Defaults", SW_SERVICE_DEFAULTS },
199 { "com.sun.star.image.ImageMapRectangleObject", SW_SERVICE_IMAP_RECTANGLE },
200 { "com.sun.star.image.ImageMapCircleObject", SW_SERVICE_IMAP_CIRCLE },
201 { "com.sun.star.image.ImageMapPolygonObject", SW_SERVICE_IMAP_POLYGON },
202 { "com.sun.star.text.TextGraphicObject", SW_SERVICE_TYPE_TEXT_GRAPHIC },
203 { "com.sun.star.chart2.data.DataProvider", SW_SERVICE_CHART2_DATA_PROVIDER },
204 { "com.sun.star.text.Fieldmark", SW_SERVICE_TYPE_FIELDMARK },
205 { "com.sun.star.text.FormFieldmark", SW_SERVICE_TYPE_FORMFIELDMARK },
206 { "com.sun.star.text.InContentMetadata", SW_SERVICE_TYPE_META },
207
208 // case-correct versions of the service names (see #i67811)
209 { CSS_TEXT_TEXTFIELD_DATE_TIME, SW_SERVICE_FIELDTYPE_DATETIME },
210 { CSS_TEXT_TEXTFIELD_USER, SW_SERVICE_FIELDTYPE_USER },
211 { CSS_TEXT_TEXTFIELD_SET_EXPRESSION, SW_SERVICE_FIELDTYPE_SET_EXP },
212 { CSS_TEXT_TEXTFIELD_GET_EXPRESSION, SW_SERVICE_FIELDTYPE_GET_EXP },
213 { CSS_TEXT_TEXTFIELD_FILE_NAME, SW_SERVICE_FIELDTYPE_FILE_NAME },
214 { CSS_TEXT_TEXTFIELD_PAGE_NUMBER, SW_SERVICE_FIELDTYPE_PAGE_NUM },
215 { CSS_TEXT_TEXTFIELD_AUTHOR, SW_SERVICE_FIELDTYPE_AUTHOR },
216 { CSS_TEXT_TEXTFIELD_CHAPTER, SW_SERVICE_FIELDTYPE_CHAPTER },
217 { CSS_TEXT_TEXTFIELD_GET_REFERENCE, SW_SERVICE_FIELDTYPE_GET_REFERENCE },
218 { CSS_TEXT_TEXTFIELD_CONDITIONAL_TEXT, SW_SERVICE_FIELDTYPE_CONDITIONED_TEXT },
219 { CSS_TEXT_TEXTFIELD_ANNOTATION, SW_SERVICE_FIELDTYPE_ANNOTATION },
220 { CSS_TEXT_TEXTFIELD_INPUT, SW_SERVICE_FIELDTYPE_INPUT },
221 { CSS_TEXT_TEXTFIELD_MACRO, SW_SERVICE_FIELDTYPE_MACRO },
222 { CSS_TEXT_TEXTFIELD_DDE, SW_SERVICE_FIELDTYPE_DDE },
223 { CSS_TEXT_TEXTFIELD_HIDDEN_PARAGRAPH, SW_SERVICE_FIELDTYPE_HIDDEN_PARA },
224 { CSS_TEXT_TEXTFIELD_TEMPLATE_NAME, SW_SERVICE_FIELDTYPE_TEMPLATE_NAME },
225 { CSS_TEXT_TEXTFIELD_EXTENDED_USER, SW_SERVICE_FIELDTYPE_USER_EXT },
226 { CSS_TEXT_TEXTFIELD_REFERENCE_PAGE_SET, SW_SERVICE_FIELDTYPE_REF_PAGE_SET },
227 { CSS_TEXT_TEXTFIELD_REFERENCE_PAGE_GET, SW_SERVICE_FIELDTYPE_REF_PAGE_GET },
228 { CSS_TEXT_TEXTFIELD_JUMP_EDIT, SW_SERVICE_FIELDTYPE_JUMP_EDIT },
229 { CSS_TEXT_TEXTFIELD_SCRIPT, SW_SERVICE_FIELDTYPE_SCRIPT },
230 { CSS_TEXT_TEXTFIELD_DATABASE_NEXT_SET, SW_SERVICE_FIELDTYPE_DATABASE_NEXT_SET },
231 { CSS_TEXT_TEXTFIELD_DATABASE_NUMBER_OF_SET, SW_SERVICE_FIELDTYPE_DATABASE_NUM_SET },
232 { CSS_TEXT_TEXTFIELD_DATABASE_SET_NUMBER, SW_SERVICE_FIELDTYPE_DATABASE_SET_NUM },
233 { CSS_TEXT_TEXTFIELD_DATABASE, SW_SERVICE_FIELDTYPE_DATABASE },
234 { CSS_TEXT_TEXTFIELD_DATABASE_NAME, SW_SERVICE_FIELDTYPE_DATABASE_NAME },
235 { CSS_TEXT_TEXTFIELD_TABLE_FORMULA, SW_SERVICE_FIELDTYPE_TABLE_FORMULA },
236 { CSS_TEXT_TEXTFIELD_PAGE_COUNT, SW_SERVICE_FIELDTYPE_PAGE_COUNT },
237 { CSS_TEXT_TEXTFIELD_PARAGRAPH_COUNT, SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT },
238 { CSS_TEXT_TEXTFIELD_WORD_COUNT, SW_SERVICE_FIELDTYPE_WORD_COUNT },
239 { CSS_TEXT_TEXTFIELD_CHARACTER_COUNT, SW_SERVICE_FIELDTYPE_CHARACTER_COUNT },
240 { CSS_TEXT_TEXTFIELD_TABLE_COUNT, SW_SERVICE_FIELDTYPE_TABLE_COUNT },
241 { CSS_TEXT_TEXTFIELD_GRAPHIC_OBJECT_COUNT, SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT },
242 { CSS_TEXT_TEXTFIELD_EMBEDDED_OBJECT_COUNT, SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT },
243 { CSS_TEXT_TEXTFIELD_DOCINFO_CHANGE_AUTHOR, SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR },
244 { CSS_TEXT_TEXTFIELD_DOCINFO_CHANGE_DATE_TIME, SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME },
245 { CSS_TEXT_TEXTFIELD_DOCINFO_EDIT_TIME, SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME },
246 { CSS_TEXT_TEXTFIELD_DOCINFO_DESCRIPTION, SW_SERVICE_FIELDTYPE_DOCINFO_DESCRIPTION },
247 { CSS_TEXT_TEXTFIELD_DOCINFO_CREATE_AUTHOR, SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_AUTHOR },
248 { CSS_TEXT_TEXTFIELD_DOCINFO_CREATE_DATE_TIME, SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME },
249 { CSS_TEXT_TEXTFIELD_DOCINFO_PRINT_AUTHOR, SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_AUTHOR },
250 { CSS_TEXT_TEXTFIELD_DOCINFO_PRINT_DATE_TIME, SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME },
251 { CSS_TEXT_TEXTFIELD_DOCINFO_KEY_WORDS, SW_SERVICE_FIELDTYPE_DOCINFO_KEY_WORDS },
252 { CSS_TEXT_TEXTFIELD_DOCINFO_SUBJECT, SW_SERVICE_FIELDTYPE_DOCINFO_SUBJECT },
253 { CSS_TEXT_TEXTFIELD_DOCINFO_TITLE, SW_SERVICE_FIELDTYPE_DOCINFO_TITLE },
254 { CSS_TEXT_TEXTFIELD_DOCINFO_REVISION, SW_SERVICE_FIELDTYPE_DOCINFO_REVISION },
255 { CSS_TEXT_TEXTFIELD_DOCINFO_CUSTOM, SW_SERVICE_FIELDTYPE_DOCINFO_CUSTOM },
256 { CSS_TEXT_TEXTFIELD_BIBLIOGRAPHY, SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY },
257 { CSS_TEXT_TEXTFIELD_COMBINED_CHARACTERS, SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS },
258 { CSS_TEXT_TEXTFIELD_DROP_DOWN, SW_SERVICE_FIELDTYPE_DROPDOWN },
259 { CSS_TEXT_TEXTFIELD_INPUT_USER, SW_SERVICE_FIELDTYPE_INPUT_USER },
260 { CSS_TEXT_TEXTFIELD_HIDDEN_TEXT, SW_SERVICE_FIELDTYPE_HIDDEN_TEXT },
261 { CSS_TEXT_FIELDMASTER_USER, SW_SERVICE_FIELDMASTER_USER },
262 { CSS_TEXT_FIELDMASTER_DDE, SW_SERVICE_FIELDMASTER_DDE },
263 { CSS_TEXT_FIELDMASTER_SET_EXPRESSION, SW_SERVICE_FIELDMASTER_SET_EXP },
264 { CSS_TEXT_FIELDMASTER_DATABASE, SW_SERVICE_FIELDMASTER_DATABASE },
265 { CSS_TEXT_FIELDMASTER_BIBLIOGRAPHY, SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY }
266 };
267
lcl_GetSupportedMacroItems()268 const SvEventDescription* lcl_GetSupportedMacroItems()
269 {
270 static const SvEventDescription aMacroDescriptionsImpl[] =
271 {
272 { SFX_EVENT_MOUSEOVER_OBJECT, "OnMouseOver" },
273 { SFX_EVENT_MOUSEOUT_OBJECT, "OnMouseOut" },
274 { 0, NULL }
275 };
276
277 return aMacroDescriptionsImpl;
278 }
279
280 /******************************************************************
281 * SwXServiceProvider
282 ******************************************************************/
GetProviderName(sal_uInt16 nObjectType)283 OUString SwXServiceProvider::GetProviderName(sal_uInt16 nObjectType)
284 {
285 vos::OGuard aGuard(Application::GetSolarMutex());
286 OUString sRet;
287 sal_uInt16 nEntries = sizeof(aProvNamesId) / sizeof(aProvNamesId[0]);
288 if(nObjectType < nEntries)
289 sRet = C2U(aProvNamesId[nObjectType].pName);
290 return sRet;
291 }
292
GetAllServiceNames()293 uno::Sequence<OUString> SwXServiceProvider::GetAllServiceNames()
294 {
295 sal_uInt16 nEntries = sizeof(aProvNamesId) / sizeof(aProvNamesId[0]);
296 uno::Sequence<OUString> aRet(nEntries);
297 OUString* pArray = aRet.getArray();
298 sal_uInt16 n = 0;
299 for(sal_uInt16 i = 0; i < nEntries; i++)
300 {
301 String sProv(C2U(aProvNamesId[i].pName));
302 if(sProv.Len())
303 {
304 pArray[n] = sProv;
305 n++;
306 }
307 }
308 aRet.realloc(n);
309 return aRet;
310
311 }
312
GetProviderType(const OUString & rServiceName)313 sal_uInt16 SwXServiceProvider::GetProviderType(const OUString& rServiceName)
314 {
315 sal_uInt16 nEntries = sizeof(aProvNamesId) / sizeof(aProvNamesId[0]);
316 for(sal_uInt16 i = 0; i < nEntries; i++ )
317 {
318 if( COMPARE_EQUAL == rServiceName.compareToAscii(aProvNamesId[i].pName))
319 return aProvNamesId[i].nType;
320 }
321 return SW_SERVICE_INVALID;
322 }
323
MakeInstance(sal_uInt16 nObjectType,SwDoc * pDoc)324 uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 nObjectType, SwDoc* pDoc)
325 {
326 vos::OGuard aGuard(Application::GetSolarMutex());
327 uno::Reference< uno::XInterface > xRet;
328 switch(nObjectType)
329 {
330 case SW_SERVICE_TYPE_TEXTTABLE:
331 {
332 SwXTextTable* pTextTable = new SwXTextTable();
333 xRet = (cppu::OWeakObject*)pTextTable;
334 }
335 break;
336 case SW_SERVICE_TYPE_TEXTFRAME:
337 {
338 SwXTextFrame* pTextFrame = new SwXTextFrame( pDoc );
339 xRet = (cppu::OWeakObject*)(SwXFrame*)pTextFrame;
340 }
341 break;
342 case SW_SERVICE_TYPE_GRAPHIC :
343 case SW_SERVICE_TYPE_TEXT_GRAPHIC /* #i47503# */ :
344 {
345 SwXTextGraphicObject* pGraphic = new SwXTextGraphicObject( pDoc );
346 xRet = (cppu::OWeakObject*)(SwXFrame*)pGraphic;
347
348 }
349 break;
350 case SW_SERVICE_TYPE_OLE :
351 {
352 SwXTextEmbeddedObject* pOle = new SwXTextEmbeddedObject( pDoc );
353 xRet = (cppu::OWeakObject*)(SwXFrame*)pOle;
354 }
355 break;
356 case SW_SERVICE_TYPE_BOOKMARK :
357 {
358 SwXBookmark* pBookmark = new SwXBookmark;
359 xRet = (cppu::OWeakObject*)pBookmark;
360 }
361 break;
362 case SW_SERVICE_TYPE_FIELDMARK :
363 {
364 SwXFieldmark* pFieldmark = new SwXFieldmark(false);
365 xRet = (cppu::OWeakObject*)pFieldmark;
366 }
367 break;
368 case SW_SERVICE_TYPE_FORMFIELDMARK :
369 {
370 SwXFieldmark* pFieldmark = new SwXFieldmark(true);
371 xRet = (cppu::OWeakObject*)pFieldmark;
372 }
373 break;
374 case SW_SERVICE_TYPE_FOOTNOTE :
375 xRet = (cppu::OWeakObject*)new SwXFootnote(sal_False);
376 break;
377 case SW_SERVICE_TYPE_ENDNOTE :
378 xRet = (cppu::OWeakObject*)new SwXFootnote(sal_True);
379 break;
380 case SW_SERVICE_CONTENT_INDEX_MARK :
381 case SW_SERVICE_USER_INDEX_MARK :
382 case SW_SERVICE_TYPE_INDEXMARK:
383 {
384 TOXTypes eType = TOX_INDEX;
385 if(SW_SERVICE_CONTENT_INDEX_MARK== nObjectType)
386 eType = TOX_CONTENT;
387 else if(SW_SERVICE_USER_INDEX_MARK == nObjectType)
388 eType = TOX_USER;
389 xRet = (cppu::OWeakObject*)new SwXDocumentIndexMark(eType);
390 }
391 break;
392 case SW_SERVICE_CONTENT_INDEX :
393 case SW_SERVICE_USER_INDEX :
394 case SW_SERVICE_TYPE_INDEX :
395 case SW_SERVICE_INDEX_ILLUSTRATIONS:
396 case SW_SERVICE_INDEX_OBJECTS :
397 case SW_SERVICE_INDEX_TABLES:
398 case SW_SERVICE_INDEX_BIBLIOGRAPHY :
399 {
400 TOXTypes eType = TOX_INDEX;
401 if(SW_SERVICE_CONTENT_INDEX == nObjectType)
402 eType = TOX_CONTENT;
403 else if(SW_SERVICE_USER_INDEX == nObjectType)
404 eType = TOX_USER;
405 else if(SW_SERVICE_INDEX_ILLUSTRATIONS == nObjectType)
406 {
407 eType = TOX_ILLUSTRATIONS;
408 }
409 else if(SW_SERVICE_INDEX_OBJECTS == nObjectType)
410 {
411 eType = TOX_OBJECTS;
412 }
413 else if(SW_SERVICE_INDEX_BIBLIOGRAPHY == nObjectType)
414 {
415 eType = TOX_AUTHORITIES;
416 }
417 else if(SW_SERVICE_INDEX_TABLES == nObjectType)
418 {
419 eType = TOX_TABLES;
420 }
421 xRet = (cppu::OWeakObject*)new SwXDocumentIndex(eType, *pDoc);
422 }
423 break;
424 case SW_SERVICE_INDEX_HEADER_SECTION :
425 case SW_SERVICE_TEXT_SECTION :
426 xRet = SwXTextSection::CreateXTextSection(0,
427 (SW_SERVICE_INDEX_HEADER_SECTION == nObjectType));
428
429 break;
430 case SW_SERVICE_REFERENCE_MARK :
431 xRet = (cppu::OWeakObject*)new SwXReferenceMark(0, 0);
432 break;
433 case SW_SERVICE_STYLE_CHARACTER_STYLE:
434 case SW_SERVICE_STYLE_PARAGRAPH_STYLE:
435 case SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE:
436 case SW_SERVICE_STYLE_FRAME_STYLE:
437 case SW_SERVICE_STYLE_PAGE_STYLE:
438 case SW_SERVICE_STYLE_NUMBERING_STYLE:
439 {
440 SfxStyleFamily eFamily = SFX_STYLE_FAMILY_CHAR;
441 switch(nObjectType)
442 {
443 case SW_SERVICE_STYLE_PARAGRAPH_STYLE:
444 case SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE:
445 eFamily = SFX_STYLE_FAMILY_PARA;
446 break;
447 case SW_SERVICE_STYLE_FRAME_STYLE:
448 eFamily = SFX_STYLE_FAMILY_FRAME;
449 break;
450 case SW_SERVICE_STYLE_PAGE_STYLE:
451 eFamily = SFX_STYLE_FAMILY_PAGE;
452 break;
453 case SW_SERVICE_STYLE_NUMBERING_STYLE:
454 eFamily = SFX_STYLE_FAMILY_PSEUDO;
455 break;
456 }
457 SwXStyle* pNewStyle = SFX_STYLE_FAMILY_PAGE == eFamily ?
458 new SwXPageStyle(pDoc->GetDocShell()) :
459 eFamily == SFX_STYLE_FAMILY_FRAME ?
460 new SwXFrameStyle ( pDoc ):
461 new SwXStyle( pDoc, eFamily, nObjectType == SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE);
462 xRet = (cppu::OWeakObject*)pNewStyle;
463 }
464 break;
465 // SW_SERVICE_DUMMY_5
466 // SW_SERVICE_DUMMY_6
467 // SW_SERVICE_DUMMY_7
468 // SW_SERVICE_DUMMY_8
469 // SW_SERVICE_DUMMY_9
470 case SW_SERVICE_FIELDTYPE_DATETIME:
471 case SW_SERVICE_FIELDTYPE_USER:
472 case SW_SERVICE_FIELDTYPE_SET_EXP:
473 case SW_SERVICE_FIELDTYPE_GET_EXP:
474 case SW_SERVICE_FIELDTYPE_FILE_NAME:
475 case SW_SERVICE_FIELDTYPE_PAGE_NUM:
476 case SW_SERVICE_FIELDTYPE_AUTHOR:
477 case SW_SERVICE_FIELDTYPE_CHAPTER:
478 case SW_SERVICE_FIELDTYPE_GET_REFERENCE:
479 case SW_SERVICE_FIELDTYPE_CONDITIONED_TEXT:
480 case SW_SERVICE_FIELDTYPE_INPUT:
481 case SW_SERVICE_FIELDTYPE_MACRO:
482 case SW_SERVICE_FIELDTYPE_DDE:
483 case SW_SERVICE_FIELDTYPE_HIDDEN_PARA:
484 case SW_SERVICE_FIELDTYPE_DOC_INFO:
485 case SW_SERVICE_FIELDTYPE_TEMPLATE_NAME:
486 case SW_SERVICE_FIELDTYPE_USER_EXT:
487 case SW_SERVICE_FIELDTYPE_REF_PAGE_SET:
488 case SW_SERVICE_FIELDTYPE_REF_PAGE_GET:
489 case SW_SERVICE_FIELDTYPE_JUMP_EDIT:
490 case SW_SERVICE_FIELDTYPE_SCRIPT:
491 case SW_SERVICE_FIELDTYPE_DATABASE_NEXT_SET:
492 case SW_SERVICE_FIELDTYPE_DATABASE_NUM_SET:
493 case SW_SERVICE_FIELDTYPE_DATABASE_SET_NUM:
494 case SW_SERVICE_FIELDTYPE_DATABASE:
495 case SW_SERVICE_FIELDTYPE_DATABASE_NAME:
496 case SW_SERVICE_FIELDTYPE_PAGE_COUNT :
497 case SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT :
498 case SW_SERVICE_FIELDTYPE_WORD_COUNT :
499 case SW_SERVICE_FIELDTYPE_CHARACTER_COUNT :
500 case SW_SERVICE_FIELDTYPE_TABLE_COUNT :
501 case SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT :
502 case SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT :
503 case SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR :
504 case SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME :
505 case SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME :
506 case SW_SERVICE_FIELDTYPE_DOCINFO_DESCRIPTION :
507 case SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_AUTHOR :
508 case SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME :
509 case SW_SERVICE_FIELDTYPE_DOCINFO_CUSTOM :
510 case SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_AUTHOR :
511 case SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME :
512 case SW_SERVICE_FIELDTYPE_DOCINFO_KEY_WORDS :
513 case SW_SERVICE_FIELDTYPE_DOCINFO_SUBJECT :
514 case SW_SERVICE_FIELDTYPE_DOCINFO_TITLE :
515 case SW_SERVICE_FIELDTYPE_DOCINFO_REVISION :
516 case SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY:
517 case SW_SERVICE_FIELDTYPE_INPUT_USER :
518 case SW_SERVICE_FIELDTYPE_HIDDEN_TEXT :
519 case SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS :
520 case SW_SERVICE_FIELDTYPE_DROPDOWN :
521 case SW_SERVICE_FIELDTYPE_TABLE_FORMULA:
522 xRet = (cppu::OWeakObject*)new SwXTextField(nObjectType);
523 break;
524 case SW_SERVICE_FIELDTYPE_ANNOTATION:
525 xRet = (cppu::OWeakObject*)new SwXTextField(nObjectType, pDoc);
526 break;
527 case SW_SERVICE_FIELDMASTER_USER:
528 case SW_SERVICE_FIELDMASTER_DDE:
529 case SW_SERVICE_FIELDMASTER_SET_EXP :
530 case SW_SERVICE_FIELDMASTER_DATABASE:
531 {
532 sal_uInt16 nResId = USHRT_MAX;
533 switch(nObjectType)
534 {
535 case SW_SERVICE_FIELDMASTER_USER: nResId = RES_USERFLD; break;
536 case SW_SERVICE_FIELDMASTER_DDE: nResId = RES_DDEFLD; break;
537 case SW_SERVICE_FIELDMASTER_SET_EXP : nResId = RES_SETEXPFLD; break;
538 case SW_SERVICE_FIELDMASTER_DATABASE: nResId = RES_DBFLD; break;
539 }
540 xRet = (cppu::OWeakObject*)new SwXFieldMaster(pDoc, nResId);
541 }
542 break;
543 case SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY:
544 {
545 SwFieldType* pType = pDoc->GetFldType(RES_AUTHORITY, aEmptyStr, sal_True);
546 if(!pType)
547 {
548 SwAuthorityFieldType aType(pDoc);
549 pType = pDoc->InsertFldType(aType);
550 }
551 else
552 {
553 SwXFieldMaster* pMaster = SwIterator<SwXFieldMaster,SwFieldType>::FirstElement( *pType );
554 if(pMaster)
555 xRet = (cppu::OWeakObject*)pMaster;
556 }
557 if(!xRet.is())
558 xRet = (cppu::OWeakObject*)new SwXFieldMaster(*pType, pDoc);
559 }
560 break;
561 case SW_SERVICE_PARAGRAPH :
562 xRet = (cppu::OWeakObject*)new SwXParagraph();
563 break;
564 case SW_SERVICE_NUMBERING_RULES :
565 xRet = (cppu::OWeakObject*)new SwXNumberingRules(*pDoc);
566 break;
567 case SW_SERVICE_TEXT_COLUMNS :
568 xRet = (cppu::OWeakObject*)new SwXTextColumns(0);
569 break;
570 case SW_SERVICE_DEFAULTS:
571 xRet = (cppu::OWeakObject*)new SwXTextDefaults( pDoc );
572 break;
573 case SW_SERVICE_IMAP_RECTANGLE :
574 xRet = SvUnoImageMapRectangleObject_createInstance( lcl_GetSupportedMacroItems() );
575 break;
576 case SW_SERVICE_IMAP_CIRCLE :
577 xRet = SvUnoImageMapCircleObject_createInstance( lcl_GetSupportedMacroItems() );
578 break;
579 case SW_SERVICE_IMAP_POLYGON :
580 xRet = SvUnoImageMapPolygonObject_createInstance( lcl_GetSupportedMacroItems() );
581 break;
582 case SW_SERVICE_CHART2_DATA_PROVIDER :
583 // #i64497# If a chart is in a temporary document during clipoard
584 // paste, there should be no data provider, so that own data is used
585 // This should not happen during copy/paste, as this will unlink
586 // charts using table data.
587 OSL_ASSERT( pDoc->GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED );
588 if( pDoc->GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
589 xRet = (cppu::OWeakObject*) pDoc->GetChartDataProvider( true /* create - if not yet available */ );
590 break;
591 case SW_SERVICE_TYPE_META:
592 xRet = static_cast< ::cppu::OWeakObject* >( new SwXMeta(pDoc) );
593 break;
594 case SW_SERVICE_FIELDTYPE_METAFIELD:
595 xRet = static_cast< ::cppu::OWeakObject* >(new SwXMetaField(pDoc));
596 break;
597 default:
598 throw uno::RuntimeException();
599 }
600 return xRet;
601 }
602 /******************************************************************
603 * SwXTextTables
604 ******************************************************************/
605 //SMART_UNO_IMPLEMENTATION( SwXTextTables, UsrObject );
606
SwXTextTables(SwDoc * pDc)607 SwXTextTables::SwXTextTables(SwDoc* pDc) :
608 SwUnoCollection(pDc)
609 {
610
611 }
612
~SwXTextTables()613 SwXTextTables::~SwXTextTables()
614 {
615
616 }
617
getCount(void)618 sal_Int32 SwXTextTables::getCount(void) throw( uno::RuntimeException )
619 {
620 vos::OGuard aGuard(Application::GetSolarMutex());
621 sal_Int32 nRet = 0;
622 if(IsValid())
623 nRet = GetDoc()->GetTblFrmFmtCount(sal_True);
624 return nRet;
625 }
626
getByIndex(sal_Int32 nIndex)627 uno::Any SAL_CALL SwXTextTables::getByIndex(sal_Int32 nIndex)
628 throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException )
629 {
630 vos::OGuard aGuard(Application::GetSolarMutex());
631 uno::Any aRet;
632 if(IsValid())
633 {
634 if(0 <= nIndex && GetDoc()->GetTblFrmFmtCount(sal_True) > nIndex)
635 {
636 SwFrmFmt& rFmt = GetDoc()->GetTblFrmFmt( static_cast< xub_StrLen >(nIndex), sal_True);
637 uno::Reference< XTextTable > xTbl = SwXTextTables::GetObject(rFmt);
638 aRet.setValue( &xTbl,
639 ::getCppuType((uno::Reference< XTextTable>*)0));
640 }
641 else
642 throw IndexOutOfBoundsException();
643 }
644 else
645 throw uno::RuntimeException();
646 return aRet;
647 }
648
getByName(const OUString & rItemName)649 uno::Any SwXTextTables::getByName(const OUString& rItemName)
650 throw( NoSuchElementException, WrappedTargetException, uno::RuntimeException )
651 {
652 vos::OGuard aGuard(Application::GetSolarMutex());
653 uno::Any aRet;
654 if(IsValid())
655 {
656 sal_uInt16 nCount = GetDoc()->GetTblFrmFmtCount(sal_True);
657 uno::Reference< XTextTable > xTbl;
658 for( sal_uInt16 i = 0; i < nCount; i++)
659 {
660 String aName(rItemName);
661 SwFrmFmt& rFmt = GetDoc()->GetTblFrmFmt(i, sal_True);
662 if(aName == rFmt.GetName())
663 {
664 xTbl = SwXTextTables::GetObject(rFmt);
665 aRet.setValue(&xTbl,
666 ::getCppuType(( uno::Reference< XTextTable >*)0));
667 break;
668 }
669 }
670 if(!xTbl.is())
671 throw NoSuchElementException();
672 }
673 else
674 throw uno::RuntimeException();
675 return aRet;
676 }
677
getElementNames(void)678 uno::Sequence< OUString > SwXTextTables::getElementNames(void)
679 throw( uno::RuntimeException )
680 {
681 vos::OGuard aGuard(Application::GetSolarMutex());
682 if(!IsValid())
683 throw uno::RuntimeException();
684 sal_uInt16 nCount = GetDoc()->GetTblFrmFmtCount(sal_True);
685 uno::Sequence<OUString> aSeq(nCount);
686 if(nCount)
687 {
688 OUString* pArray = aSeq.getArray();
689 for( sal_uInt16 i = 0; i < nCount; i++)
690 {
691 SwFrmFmt& rFmt = GetDoc()->GetTblFrmFmt(i, sal_True);
692
693 pArray[i] = OUString(rFmt.GetName());
694 }
695 }
696 return aSeq;
697 }
698
hasByName(const OUString & rName)699 sal_Bool SwXTextTables::hasByName(const OUString& rName)
700 throw( uno::RuntimeException )
701 {
702 vos::OGuard aGuard(Application::GetSolarMutex());
703 sal_Bool bRet= sal_False;
704 if(IsValid())
705 {
706 sal_uInt16 nCount = GetDoc()->GetTblFrmFmtCount(sal_True);
707 for( sal_uInt16 i = 0; i < nCount; i++)
708 {
709 String aName(rName);
710 SwFrmFmt& rFmt = GetDoc()->GetTblFrmFmt(i, sal_True);
711 if(aName == rFmt.GetName())
712 {
713 bRet = sal_True;
714 break;
715 }
716 }
717 }
718 else
719 throw uno::RuntimeException();
720 return bRet;
721 }
722
723 uno::Type SAL_CALL
getElementType()724 SwXTextTables::getElementType( )
725 throw(uno::RuntimeException)
726 {
727 return ::getCppuType((uno::Reference<XTextTable>*)0);
728 }
729
hasElements(void)730 sal_Bool SwXTextTables::hasElements(void) throw( uno::RuntimeException )
731 {
732 vos::OGuard aGuard(Application::GetSolarMutex());
733 if(!IsValid())
734 throw uno::RuntimeException();
735 return 0 != GetDoc()->GetTblFrmFmtCount(sal_True);
736 }
737
getImplementationName(void)738 OUString SwXTextTables::getImplementationName(void) throw( uno::RuntimeException )
739 {
740 return C2U("SwXTextTables");
741 }
742
supportsService(const OUString & rServiceName)743 sal_Bool SwXTextTables::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
744 {
745 return rServiceName == C2U("com.sun.star.text.TextTables");
746 }
747
getSupportedServiceNames(void)748 uno::Sequence< OUString > SwXTextTables::getSupportedServiceNames(void) throw( uno::RuntimeException )
749 {
750 uno::Sequence< OUString > aRet(1);
751 OUString* pArr = aRet.getArray();
752 pArr[0] = C2U("com.sun.star.text.TextTables");
753 return aRet;
754 }
755
GetObject(SwFrmFmt & rFmt)756 XTextTable* SwXTextTables::GetObject( SwFrmFmt& rFmt )
757 {
758 vos::OGuard aGuard(Application::GetSolarMutex());
759 SwXTextTable* pTbl = SwIterator<SwXTextTable,SwFmt>::FirstElement( rFmt );
760 if( !pTbl )
761 pTbl = new SwXTextTable(rFmt);
762 return pTbl ;
763 }
764
765
766 /******************************************************************
767 * SwXFrameEnumeration
768 ******************************************************************/
769 namespace
770 {
771 template<FlyCntType T> struct UnoFrameWrap_traits {};
772
773 template<>
774 struct UnoFrameWrap_traits<FLYCNTTYPE_FRM>
775 {
776 typedef SwXTextFrame core_frame_t;
777 typedef XTextFrame uno_frame_t;
filter__anondfd3df170111::UnoFrameWrap_traits778 static inline bool filter(const SwNode* const pNode) { return !pNode->IsNoTxtNode(); };
779 };
780
781 template<>
782 struct UnoFrameWrap_traits<FLYCNTTYPE_GRF>
783 {
784 typedef SwXTextGraphicObject core_frame_t;
785 typedef XTextContent uno_frame_t;
filter__anondfd3df170111::UnoFrameWrap_traits786 static inline bool filter(const SwNode* const pNode) { return pNode->IsGrfNode(); };
787 };
788
789 template<>
790 struct UnoFrameWrap_traits<FLYCNTTYPE_OLE>
791 {
792 typedef SwXTextEmbeddedObject core_frame_t;
793 typedef XEmbeddedObjectSupplier uno_frame_t;
filter__anondfd3df170111::UnoFrameWrap_traits794 static inline bool filter(const SwNode* const pNode) { return pNode->IsOLENode(); };
795 };
796
797 template<FlyCntType T>
lcl_UnoWrapFrame(SwFrmFmt * pFmt)798 static uno::Any lcl_UnoWrapFrame(SwFrmFmt* pFmt)
799 {
800 SwXFrame* pFrm = SwIterator<SwXFrame,SwFmt>::FirstElement( *pFmt );
801 if(!pFrm)
802 pFrm = new typename UnoFrameWrap_traits<T>::core_frame_t(*pFmt);
803 Reference< typename UnoFrameWrap_traits<T>::uno_frame_t > xFrm =
804 static_cast< typename UnoFrameWrap_traits<T>::core_frame_t* >(pFrm);
805 return uno::makeAny(xFrm);
806 }
807
808 // runtime adapter for lcl_UnoWrapFrame
lcl_UnoWrapFrame(SwFrmFmt * pFmt,FlyCntType eType)809 static uno::Any lcl_UnoWrapFrame(SwFrmFmt* pFmt, FlyCntType eType) throw(uno::RuntimeException())
810 {
811 switch(eType)
812 {
813 case FLYCNTTYPE_FRM:
814 return lcl_UnoWrapFrame<FLYCNTTYPE_FRM>(pFmt);
815 case FLYCNTTYPE_GRF:
816 return lcl_UnoWrapFrame<FLYCNTTYPE_GRF>(pFmt);
817 case FLYCNTTYPE_OLE:
818 return lcl_UnoWrapFrame<FLYCNTTYPE_OLE>(pFmt);
819 default:
820 throw uno::RuntimeException();
821 }
822 }
823
824 template<FlyCntType T>
825 class SwXFrameEnumeration
826 : public SwSimpleEnumeration_Base
827 {
828 private:
829 typedef ::std::list< Any > frmcontainer_t;
830 frmcontainer_t m_aFrames;
831 protected:
~SwXFrameEnumeration()832 virtual ~SwXFrameEnumeration() {};
833 public:
834 SwXFrameEnumeration(const SwDoc* const pDoc);
835
836 //XEnumeration
837 virtual sal_Bool SAL_CALL hasMoreElements(void) throw( RuntimeException );
838 virtual Any SAL_CALL nextElement(void) throw( NoSuchElementException, WrappedTargetException, RuntimeException );
839
840 //XServiceInfo
841 virtual OUString SAL_CALL getImplementationName(void) throw( RuntimeException );
842 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( RuntimeException );
843 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( RuntimeException );
844 };
845 }
846
847 template<FlyCntType T>
SwXFrameEnumeration(const SwDoc * const pDoc)848 SwXFrameEnumeration<T>::SwXFrameEnumeration(const SwDoc* const pDoc)
849 : m_aFrames()
850 {
851 vos::OGuard aGuard(Application::GetSolarMutex());
852 const SwSpzFrmFmts* const pFmts = pDoc->GetSpzFrmFmts();
853 if(!pFmts->Count())
854 return;
855 // --> OD 2009-09-10 #i104937#
856 // const SwFrmFmt* const pFmtsEnd = (*pFmts)[pFmts->Count()];
857 const sal_uInt16 nSize = pFmts->Count();
858 // <--
859 ::std::insert_iterator<frmcontainer_t> pInserter = ::std::insert_iterator<frmcontainer_t>(m_aFrames, m_aFrames.begin());
860 // --> OD 2009-09-10 #i104937#
861 SwFrmFmt* pFmt( 0 );
862 for( sal_uInt16 i = 0; i < nSize; ++i )
863 // for(SwFrmFmt* pFmt = (*pFmts)[0]; pFmt < pFmtsEnd; ++pFmt)
864 // <--
865 {
866 // --> OD 2009-09-10 #i104937#
867 pFmt = (*pFmts)[i];
868 // <--
869 if(pFmt->Which() != RES_FLYFRMFMT)
870 continue;
871 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
872 if(!pIdx || !pIdx->GetNodes().IsDocNodes())
873 continue;
874 const SwNode* pNd = pDoc->GetNodes()[ pIdx->GetIndex() + 1 ];
875 if(UnoFrameWrap_traits<T>::filter(pNd))
876 *pInserter++ = lcl_UnoWrapFrame<T>(pFmt);
877 }
878 }
879
880 template<FlyCntType T>
hasMoreElements(void)881 sal_Bool SwXFrameEnumeration<T>::hasMoreElements(void) throw( RuntimeException )
882 {
883 vos::OGuard aGuard(Application::GetSolarMutex());
884 return !m_aFrames.empty();
885 }
886
887 template<FlyCntType T>
nextElement(void)888 Any SwXFrameEnumeration<T>::nextElement(void) throw( NoSuchElementException, WrappedTargetException, RuntimeException )
889 {
890 vos::OGuard aGuard(Application::GetSolarMutex());
891 if(m_aFrames.empty())
892 throw NoSuchElementException();
893 Any aResult = *m_aFrames.begin();
894 m_aFrames.pop_front();
895 return aResult;
896 }
897
898 template<FlyCntType T>
getImplementationName(void)899 OUString SwXFrameEnumeration<T>::getImplementationName(void) throw( RuntimeException )
900 {
901 return C2U("SwXFrameEnumeration");
902 }
903
904 template<FlyCntType T>
supportsService(const OUString & ServiceName)905 sal_Bool SwXFrameEnumeration<T>::supportsService(const OUString& ServiceName) throw( RuntimeException )
906 {
907 return C2U("com.sun.star.container.XEnumeration") == ServiceName;
908 }
909
910 template<FlyCntType T>
getSupportedServiceNames(void)911 Sequence< OUString > SwXFrameEnumeration<T>::getSupportedServiceNames(void) throw( RuntimeException )
912 {
913 return ::comphelper::makeSequence(C2U("com.sun.star.container.XEnumeration"));
914 }
915
916 /******************************************************************
917 * SwXFrames
918 ******************************************************************/
getImplementationName(void)919 OUString SwXFrames::getImplementationName(void) throw( RuntimeException )
920 {
921 return C2U("SwXFrames");
922 }
923
supportsService(const OUString & rServiceName)924 sal_Bool SwXFrames::supportsService(const OUString& rServiceName) throw( RuntimeException )
925 {
926 return C2U("com.sun.star.text.TextFrames") == rServiceName;
927 }
928
getSupportedServiceNames(void)929 Sequence<OUString> SwXFrames::getSupportedServiceNames(void) throw( RuntimeException )
930 {
931 return ::comphelper::makeSequence(C2U("com.sun.star.text.TextFrames"));
932 }
933
SwXFrames(SwDoc * _pDoc,FlyCntType eSet)934 SwXFrames::SwXFrames(SwDoc* _pDoc, FlyCntType eSet) :
935 SwUnoCollection(_pDoc),
936 eType(eSet)
937 {}
938
~SwXFrames()939 SwXFrames::~SwXFrames()
940 {}
941
createEnumeration(void)942 uno::Reference<container::XEnumeration> SwXFrames::createEnumeration(void) throw(uno::RuntimeException)
943 {
944 vos::OGuard aGuard(Application::GetSolarMutex());
945 if(!IsValid())
946 throw uno::RuntimeException();
947 switch(eType)
948 {
949 case FLYCNTTYPE_FRM:
950 return uno::Reference< container::XEnumeration >(
951 new SwXFrameEnumeration<FLYCNTTYPE_FRM>(GetDoc()));
952 case FLYCNTTYPE_GRF:
953 return uno::Reference< container::XEnumeration >(
954 new SwXFrameEnumeration<FLYCNTTYPE_GRF>(GetDoc()));
955 case FLYCNTTYPE_OLE:
956 return uno::Reference< container::XEnumeration >(
957 new SwXFrameEnumeration<FLYCNTTYPE_OLE>(GetDoc()));
958 default:
959 throw uno::RuntimeException();
960 }
961 }
962
getCount(void)963 sal_Int32 SwXFrames::getCount(void) throw(uno::RuntimeException)
964 {
965 vos::OGuard aGuard(Application::GetSolarMutex());
966 if(!IsValid())
967 throw uno::RuntimeException();
968 return GetDoc()->GetFlyCount(eType);
969 }
970
getByIndex(sal_Int32 nIndex)971 uno::Any SwXFrames::getByIndex(sal_Int32 nIndex)
972 throw(IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException )
973 {
974 vos::OGuard aGuard(Application::GetSolarMutex());
975 if(!IsValid())
976 throw uno::RuntimeException();
977 if(nIndex < 0 || nIndex >= USHRT_MAX)
978 throw IndexOutOfBoundsException();
979 SwFrmFmt* pFmt = GetDoc()->GetFlyNum(static_cast<sal_uInt16>(nIndex), eType);
980 if(!pFmt)
981 throw IndexOutOfBoundsException();
982 return lcl_UnoWrapFrame(pFmt, eType);
983 }
984
getByName(const OUString & rName)985 uno::Any SwXFrames::getByName(const OUString& rName)
986 throw(NoSuchElementException, WrappedTargetException, uno::RuntimeException )
987 {
988 vos::OGuard aGuard(Application::GetSolarMutex());
989 if(!IsValid())
990 throw uno::RuntimeException();
991 const SwFrmFmt* pFmt;
992 switch(eType)
993 {
994 case FLYCNTTYPE_GRF:
995 pFmt = GetDoc()->FindFlyByName(rName, ND_GRFNODE);
996 break;
997 case FLYCNTTYPE_OLE:
998 pFmt = GetDoc()->FindFlyByName(rName, ND_OLENODE);
999 break;
1000 default:
1001 pFmt = GetDoc()->FindFlyByName(rName, ND_TEXTNODE);
1002 break;
1003 }
1004 if(!pFmt)
1005 throw NoSuchElementException();
1006 return lcl_UnoWrapFrame(const_cast<SwFrmFmt*>(pFmt), eType);
1007 }
1008
getElementNames(void)1009 uno::Sequence<OUString> SwXFrames::getElementNames(void) throw( uno::RuntimeException )
1010 {
1011 vos::OGuard aGuard(Application::GetSolarMutex());
1012 if(!IsValid())
1013 throw uno::RuntimeException();
1014 const Reference<XEnumeration> xEnum = createEnumeration();
1015 ::std::vector<OUString> vNames;
1016 while(xEnum->hasMoreElements())
1017 {
1018 Reference<container::XNamed> xNamed;
1019 xEnum->nextElement() >>= xNamed;
1020 if(xNamed.is())
1021 vNames.push_back(xNamed->getName());
1022 }
1023 return ::comphelper::containerToSequence(vNames);
1024 }
1025
hasByName(const OUString & rName)1026 sal_Bool SwXFrames::hasByName(const OUString& rName) throw( uno::RuntimeException )
1027 {
1028 vos::OGuard aGuard(Application::GetSolarMutex());
1029 if(!IsValid())
1030 throw uno::RuntimeException();
1031 switch(eType)
1032 {
1033 case FLYCNTTYPE_GRF:
1034 return GetDoc()->FindFlyByName(rName, ND_GRFNODE) != NULL;
1035 case FLYCNTTYPE_OLE:
1036 return GetDoc()->FindFlyByName(rName, ND_OLENODE) != NULL;
1037 default:
1038 return GetDoc()->FindFlyByName(rName, ND_TEXTNODE) != NULL;
1039 }
1040 }
1041
getElementType()1042 uno::Type SAL_CALL SwXFrames::getElementType() throw(uno::RuntimeException)
1043 {
1044 vos::OGuard aGuard(Application::GetSolarMutex());
1045 switch(eType)
1046 {
1047 case FLYCNTTYPE_FRM:
1048 return ::getCppuType((uno::Reference<XTextFrame>*)0);
1049 case FLYCNTTYPE_GRF:
1050 return ::getCppuType((uno::Reference<XTextContent>*)0);
1051 case FLYCNTTYPE_OLE:
1052 return ::getCppuType((uno::Reference<XEmbeddedObjectSupplier>*)0);
1053 default:
1054 return uno::Type();
1055 }
1056 }
1057
hasElements(void)1058 sal_Bool SwXFrames::hasElements(void) throw(uno::RuntimeException)
1059 {
1060 vos::OGuard aGuard(Application::GetSolarMutex());
1061 if(!IsValid())
1062 throw uno::RuntimeException();
1063 return GetDoc()->GetFlyCount(eType) > 0;
1064 }
1065
GetObject(SwFrmFmt & rFmt,FlyCntType eType)1066 SwXFrame* SwXFrames::GetObject(SwFrmFmt& rFmt, FlyCntType eType)
1067 {
1068 SwXFrame* pFrm = SwIterator<SwXFrame,SwFmt>::FirstElement( rFmt );
1069 if(pFrm) return pFrm;
1070 switch(eType)
1071 {
1072 case FLYCNTTYPE_FRM:
1073 return new SwXTextFrame(rFmt);
1074 case FLYCNTTYPE_GRF:
1075 return new SwXTextGraphicObject(rFmt);
1076 case FLYCNTTYPE_OLE:
1077 return new SwXTextEmbeddedObject(rFmt);
1078 default:
1079 return NULL;
1080 }
1081 }
1082
1083 /******************************************************************
1084 * SwXTextFrames
1085 ******************************************************************/
getImplementationName(void)1086 OUString SwXTextFrames::getImplementationName(void) throw( RuntimeException )
1087 {
1088 return C2U("SwXTextFrames");
1089 }
1090
supportsService(const OUString & rServiceName)1091 sal_Bool SwXTextFrames::supportsService(const OUString& rServiceName) throw( RuntimeException )
1092 {
1093 return C2U("com.sun.star.text.TextFrames") == rServiceName;
1094 }
1095
getSupportedServiceNames(void)1096 Sequence< OUString > SwXTextFrames::getSupportedServiceNames(void) throw( RuntimeException )
1097 {
1098 Sequence< OUString > aRet(1);
1099 OUString* pArray = aRet.getArray();
1100 pArray[0] = C2U("com.sun.star.text.TextFrames");
1101 return aRet;
1102 }
1103
SwXTextFrames(SwDoc * _pDoc)1104 SwXTextFrames::SwXTextFrames(SwDoc* _pDoc) :
1105 SwXFrames(_pDoc, FLYCNTTYPE_FRM)
1106 {
1107 }
1108
~SwXTextFrames()1109 SwXTextFrames::~SwXTextFrames()
1110 {
1111 }
1112
1113 /******************************************************************
1114 * SwXTextGraphicObjects
1115 ******************************************************************/
1116
getImplementationName(void)1117 OUString SwXTextGraphicObjects::getImplementationName(void) throw( RuntimeException )
1118 {
1119 return C2U("SwXTextGraphicObjects");
1120 }
1121
supportsService(const OUString & rServiceName)1122 sal_Bool SwXTextGraphicObjects::supportsService(const OUString& rServiceName) throw( RuntimeException )
1123 {
1124 return C2U("com.sun.star.text.TextGraphicObjects") == rServiceName;
1125 }
1126
getSupportedServiceNames(void)1127 Sequence< OUString > SwXTextGraphicObjects::getSupportedServiceNames(void) throw( RuntimeException )
1128 {
1129 Sequence< OUString > aRet(1);
1130 OUString* pArray = aRet.getArray();
1131 pArray[0] = C2U("com.sun.star.text.TextGraphicObjects");
1132 return aRet;
1133 }
1134
SwXTextGraphicObjects(SwDoc * _pDoc)1135 SwXTextGraphicObjects::SwXTextGraphicObjects(SwDoc* _pDoc) :
1136 SwXFrames(_pDoc, FLYCNTTYPE_GRF)
1137 {
1138 }
1139
~SwXTextGraphicObjects()1140 SwXTextGraphicObjects::~SwXTextGraphicObjects()
1141 {
1142 }
1143
1144 /******************************************************************
1145 * SwXTextEmbeddedObjects
1146 ******************************************************************/
getImplementationName(void)1147 OUString SwXTextEmbeddedObjects::getImplementationName(void) throw( RuntimeException )
1148 {
1149 return C2U("SwXTextEmbeddedObjects");
1150 }
1151
supportsService(const OUString & rServiceName)1152 sal_Bool SwXTextEmbeddedObjects::supportsService(const OUString& rServiceName) throw( RuntimeException )
1153 {
1154 return C2U("com.sun.star.text.TextEmbeddedObjects") == rServiceName;
1155 }
1156
getSupportedServiceNames(void)1157 Sequence< OUString > SwXTextEmbeddedObjects::getSupportedServiceNames(void) throw( RuntimeException )
1158 {
1159 Sequence< OUString > aRet(1);
1160 OUString* pArray = aRet.getArray();
1161 pArray[0] = C2U("com.sun.star.text.TextEmbeddedObjects");
1162 return aRet;
1163 }
1164
SwXTextEmbeddedObjects(SwDoc * _pDoc)1165 SwXTextEmbeddedObjects::SwXTextEmbeddedObjects(SwDoc* _pDoc) :
1166 SwXFrames(_pDoc, FLYCNTTYPE_OLE)
1167 {
1168 }
1169
~SwXTextEmbeddedObjects()1170 SwXTextEmbeddedObjects::~SwXTextEmbeddedObjects()
1171 {
1172 }
1173
1174 /******************************************************************
1175 *
1176 ******************************************************************/
1177 #define PASSWORD_STD_TIMEOUT 1000
getImplementationName(void)1178 OUString SwXTextSections::getImplementationName(void) throw( RuntimeException )
1179 {
1180 return C2U("SwXTextSections");
1181 }
1182
supportsService(const OUString & rServiceName)1183 sal_Bool SwXTextSections::supportsService(const OUString& rServiceName) throw( RuntimeException )
1184 {
1185 return C2U("com.sun.star.text.TextSections") == rServiceName;
1186 }
1187
getSupportedServiceNames(void)1188 Sequence< OUString > SwXTextSections::getSupportedServiceNames(void) throw( RuntimeException )
1189 {
1190 Sequence< OUString > aRet(1);
1191 OUString* pArray = aRet.getArray();
1192 pArray[0] = C2U("com.sun.star.text.TextSections");
1193 return aRet;
1194 }
1195
SwXTextSections(SwDoc * _pDoc)1196 SwXTextSections::SwXTextSections(SwDoc* _pDoc) :
1197 SwUnoCollection(_pDoc)
1198 {
1199 }
1200
~SwXTextSections()1201 SwXTextSections::~SwXTextSections()
1202 {
1203 }
1204
getCount(void)1205 sal_Int32 SwXTextSections::getCount(void) throw( uno::RuntimeException )
1206 {
1207 vos::OGuard aGuard(Application::GetSolarMutex());
1208 if(!IsValid())
1209 throw uno::RuntimeException();
1210 const SwSectionFmts& rSectFmts = GetDoc()->GetSections();
1211 sal_uInt16 nCount = rSectFmts.Count();
1212 for(sal_uInt16 i = nCount; i; i--)
1213 {
1214 if( !rSectFmts[i - 1]->IsInNodesArr())
1215 nCount--;
1216 }
1217 return nCount;
1218 }
1219
getByIndex(sal_Int32 nIndex)1220 uno::Any SwXTextSections::getByIndex(sal_Int32 nIndex)
1221 throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException )
1222 {
1223 vos::OGuard aGuard(Application::GetSolarMutex());
1224 uno::Reference< XTextSection > xRet;
1225 if(IsValid())
1226 {
1227 SwSectionFmts& rFmts = GetDoc()->GetSections();
1228
1229 const SwSectionFmts& rSectFmts = GetDoc()->GetSections();
1230 sal_uInt16 nCount = rSectFmts.Count();
1231 for(sal_uInt16 i = 0; i < nCount; i++)
1232 {
1233 if( !rSectFmts[i]->IsInNodesArr())
1234 nIndex ++;
1235 else if(nIndex == i)
1236 break;
1237 if(nIndex == i)
1238 break;
1239 }
1240 if(nIndex >= 0 && nIndex < rFmts.Count())
1241 {
1242 SwSectionFmt* pFmt = rFmts[(sal_uInt16)nIndex];
1243 xRet = GetObject(*pFmt);
1244 }
1245 else
1246 throw IndexOutOfBoundsException();
1247 }
1248 else
1249 throw uno::RuntimeException();
1250 return makeAny(xRet);
1251 }
1252
getByName(const OUString & Name)1253 uno::Any SwXTextSections::getByName(const OUString& Name)
1254 throw( NoSuchElementException, WrappedTargetException, uno::RuntimeException )
1255 {
1256 vos::OGuard aGuard(Application::GetSolarMutex());
1257 uno::Any aRet;
1258 if(IsValid())
1259 {
1260 String aName(Name);
1261 SwSectionFmts& rFmts = GetDoc()->GetSections();
1262 uno::Reference< XTextSection > xSect;
1263 for(sal_uInt16 i = 0; i < rFmts.Count(); i++)
1264 {
1265 SwSectionFmt* pFmt = rFmts[i];
1266 if (pFmt->IsInNodesArr()
1267 && (aName == pFmt->GetSection()->GetSectionName()))
1268 {
1269 xSect = GetObject(*pFmt);
1270 aRet.setValue(&xSect, ::getCppuType((uno::Reference<XTextSection>*)0));
1271 break;
1272 }
1273 }
1274 if(!xSect.is())
1275 throw NoSuchElementException();
1276 }
1277 else
1278 throw uno::RuntimeException();
1279 return aRet;
1280 }
1281
getElementNames(void)1282 uno::Sequence< OUString > SwXTextSections::getElementNames(void)
1283 throw( uno::RuntimeException )
1284 {
1285 vos::OGuard aGuard(Application::GetSolarMutex());
1286 if(!IsValid())
1287 throw uno::RuntimeException();
1288 sal_uInt16 nCount = GetDoc()->GetSections().Count();
1289 SwSectionFmts& rSectFmts = GetDoc()->GetSections();
1290 for(sal_uInt16 i = nCount; i; i--)
1291 {
1292 if( !rSectFmts[i - 1]->IsInNodesArr())
1293 nCount--;
1294 }
1295
1296 uno::Sequence<OUString> aSeq(nCount);
1297 if(nCount)
1298 {
1299 SwSectionFmts& rFmts = GetDoc()->GetSections();
1300 OUString* pArray = aSeq.getArray();
1301 sal_uInt16 nIndex = 0;
1302 for( sal_uInt16 i = 0; i < nCount; i++, nIndex++)
1303 {
1304 const SwSectionFmt* pFmt = rFmts[nIndex];
1305 while(!pFmt->IsInNodesArr())
1306 {
1307 pFmt = rFmts[++nIndex];
1308 }
1309 pArray[i] = pFmt->GetSection()->GetSectionName();
1310 }
1311 }
1312 return aSeq;
1313 }
1314
hasByName(const OUString & Name)1315 sal_Bool SwXTextSections::hasByName(const OUString& Name)
1316 throw( uno::RuntimeException )
1317 {
1318 vos::OGuard aGuard(Application::GetSolarMutex());
1319 sal_Bool bRet = sal_False;
1320 String aName(Name);
1321 if(IsValid())
1322 {
1323 SwSectionFmts& rFmts = GetDoc()->GetSections();
1324 for(sal_uInt16 i = 0; i < rFmts.Count(); i++)
1325 {
1326 const SwSectionFmt* pFmt = rFmts[i];
1327 if (aName == pFmt->GetSection()->GetSectionName())
1328 {
1329 bRet = sal_True;
1330 break;
1331 }
1332 }
1333 }
1334 else
1335 {
1336 //Sonderbehandlung der dbg_ - Methoden
1337 if( COMPARE_EQUAL != aName.CompareToAscii("dbg_", 4))
1338 throw uno::RuntimeException();
1339 }
1340 return bRet;
1341 }
1342
getElementType()1343 uno::Type SAL_CALL SwXTextSections::getElementType() throw(uno::RuntimeException)
1344 {
1345 return ::getCppuType((uno::Reference<XTextSection>*)0);
1346 }
1347
hasElements(void)1348 sal_Bool SwXTextSections::hasElements(void) throw( uno::RuntimeException )
1349 {
1350 vos::OGuard aGuard(Application::GetSolarMutex());
1351 sal_uInt16 nCount = 0;
1352 if(IsValid())
1353 {
1354 SwSectionFmts& rFmts = GetDoc()->GetSections();
1355 nCount = rFmts.Count();
1356 }
1357 else
1358 throw uno::RuntimeException();
1359 return nCount > 0;
1360 }
1361
GetObject(SwSectionFmt & rFmt)1362 uno::Reference< XTextSection > SwXTextSections::GetObject( SwSectionFmt& rFmt )
1363 {
1364 return SwXTextSection::CreateXTextSection(&rFmt);
1365 }
1366
getImplementationName(void)1367 OUString SwXBookmarks::getImplementationName(void) throw( RuntimeException )
1368 {
1369 return OUString::createFromAscii("SwXBookmarks");
1370 }
1371
supportsService(const OUString & rServiceName)1372 sal_Bool SwXBookmarks::supportsService(const OUString& rServiceName) throw( RuntimeException )
1373 {
1374 return OUString::createFromAscii("com.sun.star.text.Bookmarks") == rServiceName;
1375 }
1376
getSupportedServiceNames(void)1377 Sequence< OUString > SwXBookmarks::getSupportedServiceNames(void) throw( RuntimeException )
1378 {
1379 Sequence< OUString > aRet(1);
1380 aRet[0] = OUString::createFromAscii("com.sun.star.text.Bookmarks");
1381 return aRet;
1382 }
1383
SwXBookmarks(SwDoc * _pDoc)1384 SwXBookmarks::SwXBookmarks(SwDoc* _pDoc) :
1385 SwUnoCollection(_pDoc)
1386 { }
1387
~SwXBookmarks()1388 SwXBookmarks::~SwXBookmarks()
1389 { }
1390
getCount(void)1391 sal_Int32 SwXBookmarks::getCount(void)
1392 throw( uno::RuntimeException )
1393 {
1394 vos::OGuard aGuard(Application::GetSolarMutex());
1395 if(!IsValid())
1396 throw uno::RuntimeException();
1397 return GetDoc()->getIDocumentMarkAccess()->getBookmarksCount();
1398 }
1399
getByIndex(sal_Int32 nIndex)1400 uno::Any SwXBookmarks::getByIndex(sal_Int32 nIndex)
1401 throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException )
1402 {
1403 vos::OGuard aGuard(Application::GetSolarMutex());
1404 if(!IsValid())
1405 throw uno::RuntimeException();
1406 IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess();
1407 if(nIndex < 0 || nIndex >= pMarkAccess->getBookmarksCount())
1408 throw IndexOutOfBoundsException();
1409
1410 uno::Any aRet;
1411 ::sw::mark::IMark* pBkmk = pMarkAccess->getBookmarksBegin()[nIndex].get();
1412 const uno::Reference< text::XTextContent > xRef =
1413 SwXBookmark::CreateXBookmark(*GetDoc(), *pBkmk);
1414 aRet <<= xRef;
1415 return aRet;
1416 }
1417
getByName(const rtl::OUString & rName)1418 uno::Any SwXBookmarks::getByName(const rtl::OUString& rName)
1419 throw( NoSuchElementException, WrappedTargetException, uno::RuntimeException )
1420 {
1421 vos::OGuard aGuard(Application::GetSolarMutex());
1422 if(!IsValid())
1423 throw uno::RuntimeException();
1424
1425 IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess();
1426 IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->findBookmark(rName);
1427 if(ppBkmk == pMarkAccess->getBookmarksEnd())
1428 throw NoSuchElementException();
1429
1430 uno::Any aRet;
1431 const uno::Reference< text::XTextContent > xRef =
1432 SwXBookmark::CreateXBookmark(*GetDoc(), *(ppBkmk->get()));
1433 aRet <<= xRef;
1434 return aRet;
1435 }
1436
getElementNames(void)1437 uno::Sequence< OUString > SwXBookmarks::getElementNames(void)
1438 throw( uno::RuntimeException )
1439 {
1440 vos::OGuard aGuard(Application::GetSolarMutex());
1441 if(!IsValid())
1442 throw uno::RuntimeException();
1443
1444 IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess();
1445 uno::Sequence<OUString> aSeq(pMarkAccess->getBookmarksCount());
1446 sal_Int32 nCnt = 0;
1447 for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getBookmarksBegin();
1448 ppMark != pMarkAccess->getBookmarksEnd();)
1449 aSeq[nCnt++] = (*ppMark++)->GetName();
1450 return aSeq;
1451 }
1452
hasByName(const OUString & rName)1453 sal_Bool SwXBookmarks::hasByName(const OUString& rName)
1454 throw( uno::RuntimeException )
1455 {
1456 vos::OGuard aGuard(Application::GetSolarMutex());
1457 if(!IsValid())
1458 throw uno::RuntimeException();
1459
1460 IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess();
1461 return pMarkAccess->findBookmark(rName) != pMarkAccess->getBookmarksEnd();
1462 }
1463
getElementType()1464 uno::Type SAL_CALL SwXBookmarks::getElementType()
1465 throw(uno::RuntimeException)
1466 {
1467 return ::getCppuType((uno::Reference<XTextContent>*)0);
1468 }
1469
hasElements(void)1470 sal_Bool SwXBookmarks::hasElements(void)
1471 throw( uno::RuntimeException )
1472 {
1473 vos::OGuard aGuard(Application::GetSolarMutex());
1474 if(!IsValid())
1475 throw uno::RuntimeException();
1476 return GetDoc()->getIDocumentMarkAccess()->getBookmarksCount() != 0;
1477 }
1478
1479 /******************************************************************
1480 *
1481 ******************************************************************/
1482
SwXNumberingRulesCollection(SwDoc * _pDoc)1483 SwXNumberingRulesCollection::SwXNumberingRulesCollection( SwDoc* _pDoc ) :
1484 SwUnoCollection(_pDoc)
1485 {
1486 }
1487
~SwXNumberingRulesCollection()1488 SwXNumberingRulesCollection::~SwXNumberingRulesCollection()
1489 {
1490 }
1491
getCount(void)1492 sal_Int32 SwXNumberingRulesCollection::getCount(void) throw( uno::RuntimeException )
1493 {
1494 vos::OGuard aGuard(Application::GetSolarMutex());
1495 if(!IsValid())
1496 throw uno::RuntimeException();
1497 return GetDoc()->GetNumRuleTbl().Count();
1498 }
1499
getByIndex(sal_Int32 nIndex)1500 uno::Any SwXNumberingRulesCollection::getByIndex(sal_Int32 nIndex)
1501 throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException )
1502 {
1503 vos::OGuard aGuard(Application::GetSolarMutex());
1504 uno::Any aRet;
1505 if(IsValid())
1506 {
1507 uno::Reference< XIndexReplace > xRef;
1508 if ( nIndex < GetDoc()->GetNumRuleTbl().Count() )
1509 {
1510 xRef = new SwXNumberingRules( *GetDoc()->GetNumRuleTbl()[ static_cast< sal_uInt16 >(nIndex) ] );
1511 aRet.setValue(&xRef, ::getCppuType((uno::Reference<XIndexReplace>*)0));
1512 }
1513
1514 if(!xRef.is())
1515 throw IndexOutOfBoundsException();
1516 }
1517 else
1518 throw uno::RuntimeException();
1519 return aRet;
1520 }
1521
getElementType()1522 uno::Type SAL_CALL SwXNumberingRulesCollection::getElementType() throw(uno::RuntimeException)
1523 {
1524 return ::getCppuType((uno::Reference<XIndexReplace>*)0);
1525 }
1526
hasElements(void)1527 sal_Bool SwXNumberingRulesCollection::hasElements(void) throw( uno::RuntimeException )
1528 {
1529 vos::OGuard aGuard(Application::GetSolarMutex());
1530 if(!IsValid())
1531 throw uno::RuntimeException();
1532 return GetDoc()->GetNumRuleTbl().Count() > 0;
1533 }
1534
getImplementationName(void)1535 OUString SwXFootnotes::getImplementationName(void) throw( RuntimeException )
1536 {
1537 return C2U("SwXFootnotes");
1538 }
1539
supportsService(const OUString & rServiceName)1540 sal_Bool SwXFootnotes::supportsService(const OUString& rServiceName) throw( RuntimeException )
1541 {
1542 return C2U("com.sun.star.text.Footnotes") == rServiceName;
1543 }
1544
getSupportedServiceNames(void)1545 Sequence< OUString > SwXFootnotes::getSupportedServiceNames(void) throw( RuntimeException )
1546 {
1547 Sequence< OUString > aRet(1);
1548 OUString* pArray = aRet.getArray();
1549 pArray[0] = C2U("com.sun.star.text.Footnotes");
1550 return aRet;
1551 }
1552
SwXFootnotes(sal_Bool bEnd,SwDoc * _pDoc)1553 SwXFootnotes::SwXFootnotes(sal_Bool bEnd, SwDoc* _pDoc)
1554 : SwUnoCollection(_pDoc)
1555 , m_bEndnote(bEnd)
1556 {
1557 }
1558
~SwXFootnotes()1559 SwXFootnotes::~SwXFootnotes()
1560 {
1561 }
1562
getCount(void)1563 sal_Int32 SwXFootnotes::getCount(void) throw( uno::RuntimeException )
1564 {
1565 vos::OGuard aGuard(Application::GetSolarMutex());
1566 if(!IsValid())
1567 throw uno::RuntimeException();
1568 sal_Int32 nCount = 0;
1569 sal_uInt16 n, nFtnCnt = GetDoc()->GetFtnIdxs().Count();
1570 SwTxtFtn* pTxtFtn;
1571 for( n = 0; n < nFtnCnt; ++n )
1572 {
1573 pTxtFtn = GetDoc()->GetFtnIdxs()[ n ];
1574 const SwFmtFtn& rFtn = pTxtFtn->GetFtn();
1575 if ( rFtn.IsEndNote() != m_bEndnote )
1576 continue;
1577 nCount++;
1578 }
1579 return nCount;
1580 }
1581
getByIndex(sal_Int32 nIndex)1582 uno::Any SwXFootnotes::getByIndex(sal_Int32 nIndex)
1583 throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException )
1584 {
1585 vos::OGuard aGuard(Application::GetSolarMutex());
1586 uno::Any aRet;
1587 sal_Int32 nCount = 0;
1588 if(IsValid())
1589 {
1590 sal_uInt16 n, nFtnCnt = GetDoc()->GetFtnIdxs().Count();
1591 SwTxtFtn* pTxtFtn;
1592 uno::Reference< XFootnote > xRef;
1593 for( n = 0; n < nFtnCnt; ++n )
1594 {
1595 pTxtFtn = GetDoc()->GetFtnIdxs()[ n ];
1596 const SwFmtFtn& rFtn = pTxtFtn->GetFtn();
1597 if ( rFtn.IsEndNote() != m_bEndnote )
1598 continue;
1599
1600 if(nCount == nIndex)
1601 {
1602 xRef = SwXFootnote::CreateXFootnote(*GetDoc(), rFtn);
1603 aRet <<= xRef;
1604 break;
1605 }
1606 nCount++;
1607 }
1608 if(!xRef.is())
1609 throw IndexOutOfBoundsException();
1610 }
1611 else
1612 throw uno::RuntimeException();
1613 return aRet;
1614 }
1615
getElementType()1616 uno::Type SAL_CALL SwXFootnotes::getElementType() throw(uno::RuntimeException)
1617 {
1618 return ::getCppuType((uno::Reference<XFootnote>*)0);
1619 }
1620
hasElements(void)1621 sal_Bool SwXFootnotes::hasElements(void) throw( uno::RuntimeException )
1622 {
1623 vos::OGuard aGuard(Application::GetSolarMutex());
1624 if(!IsValid())
1625 throw uno::RuntimeException();
1626 return GetDoc()->GetFtnIdxs().Count() > 0;
1627 }
1628
GetObject(SwDoc & rDoc,const SwFmtFtn & rFmt)1629 Reference<XFootnote> SwXFootnotes::GetObject( SwDoc& rDoc, const SwFmtFtn& rFmt )
1630 {
1631 return SwXFootnote::CreateXFootnote(rDoc, rFmt);
1632 }
1633
1634 /******************************************************************
1635 *
1636 ******************************************************************/
1637
getImplementationName(void)1638 OUString SwXReferenceMarks::getImplementationName(void) throw( RuntimeException )
1639 {
1640 return C2U("SwXReferenceMarks");
1641 }
1642
supportsService(const OUString & rServiceName)1643 sal_Bool SwXReferenceMarks::supportsService(const OUString& rServiceName) throw( RuntimeException )
1644 {
1645 return C2U("com.sun.star.text.ReferenceMarks") == rServiceName;
1646 }
1647
getSupportedServiceNames(void)1648 Sequence< OUString > SwXReferenceMarks::getSupportedServiceNames(void) throw( RuntimeException )
1649 {
1650 Sequence< OUString > aRet(1);
1651 OUString* pArray = aRet.getArray();
1652 pArray[0] = C2U("com.sun.star.text.ReferenceMarks");
1653 return aRet;
1654 }
1655
SwXReferenceMarks(SwDoc * _pDoc)1656 SwXReferenceMarks::SwXReferenceMarks(SwDoc* _pDoc) :
1657 SwUnoCollection(_pDoc)
1658 {
1659 }
1660
~SwXReferenceMarks()1661 SwXReferenceMarks::~SwXReferenceMarks()
1662 {
1663 }
1664
getCount(void)1665 sal_Int32 SwXReferenceMarks::getCount(void) throw( uno::RuntimeException )
1666 {
1667 vos::OGuard aGuard(Application::GetSolarMutex());
1668 if(!IsValid())
1669 throw uno::RuntimeException();
1670 return GetDoc()->GetRefMarks();
1671 }
1672
getByIndex(sal_Int32 nIndex)1673 uno::Any SwXReferenceMarks::getByIndex(sal_Int32 nIndex)
1674 throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException )
1675 {
1676 vos::OGuard aGuard(Application::GetSolarMutex());
1677 uno::Any aRet;
1678 if(!IsValid())
1679 throw uno::RuntimeException();
1680 uno::Reference< XTextContent > xRef;
1681 if(0 <= nIndex && nIndex < USHRT_MAX)
1682 {
1683 const SwFmtRefMark* pMark = GetDoc()->GetRefMark( (sal_uInt16) nIndex );
1684 if(pMark)
1685 {
1686 xRef = SwXReferenceMarks::GetObject( GetDoc(), pMark );
1687 aRet.setValue(&xRef, ::getCppuType((uno::Reference<XTextContent>*)0));
1688 }
1689 }
1690 if(!xRef.is())
1691 throw IndexOutOfBoundsException();
1692 return aRet;
1693 }
1694
getByName(const OUString & rName)1695 uno::Any SwXReferenceMarks::getByName(const OUString& rName)
1696 throw( NoSuchElementException, WrappedTargetException, uno::RuntimeException )
1697 {
1698 vos::OGuard aGuard(Application::GetSolarMutex());
1699 uno::Any aRet;
1700 if(IsValid())
1701 {
1702 const SwFmtRefMark* pMark = GetDoc()->GetRefMark(rName);
1703 if(pMark)
1704 {
1705 uno::Reference< XTextContent > xRef = SwXReferenceMarks::GetObject( GetDoc(), pMark );
1706 aRet.setValue(&xRef, ::getCppuType((uno::Reference<XTextContent>*)0));
1707 }
1708 else
1709 throw NoSuchElementException();
1710 }
1711 else
1712 throw uno::RuntimeException();
1713 return aRet;
1714 }
1715
getElementNames(void)1716 uno::Sequence< OUString > SwXReferenceMarks::getElementNames(void) throw( uno::RuntimeException )
1717 {
1718 vos::OGuard aGuard(Application::GetSolarMutex());
1719 uno::Sequence<OUString> aRet;
1720 if(IsValid())
1721 {
1722 SvStringsDtor aStrings;
1723 sal_uInt16 nCount = GetDoc()->GetRefMarks( &aStrings );
1724 aRet.realloc(nCount);
1725 OUString* pNames = aRet.getArray();
1726 for(sal_uInt16 i = 0; i < nCount; i++)
1727 pNames[i] = *aStrings.GetObject(i);
1728 }
1729 else
1730 throw uno::RuntimeException();
1731 return aRet;
1732 }
1733
hasByName(const OUString & rName)1734 sal_Bool SwXReferenceMarks::hasByName(const OUString& rName) throw( uno::RuntimeException )
1735 {
1736 vos::OGuard aGuard(Application::GetSolarMutex());
1737 if(!IsValid())
1738 throw uno::RuntimeException();
1739 return 0 != GetDoc()->GetRefMark( rName);
1740 }
1741
getElementType()1742 uno::Type SAL_CALL SwXReferenceMarks::getElementType() throw(uno::RuntimeException)
1743 {
1744 return ::getCppuType((uno::Reference<XTextContent>*)0);
1745 }
1746
hasElements(void)1747 sal_Bool SwXReferenceMarks::hasElements(void) throw( uno::RuntimeException )
1748 {
1749 vos::OGuard aGuard(Application::GetSolarMutex());
1750 if(!IsValid())
1751 throw uno::RuntimeException();
1752 return 0 != GetDoc()->GetRefMarks();
1753 }
1754
GetObject(SwDoc * pDoc,const SwFmtRefMark * pMark)1755 SwXReferenceMark* SwXReferenceMarks::GetObject( SwDoc* pDoc, const SwFmtRefMark* pMark )
1756 {
1757 vos::OGuard aGuard(Application::GetSolarMutex());
1758
1759 return SwXReferenceMark::CreateXReferenceMark(*pDoc, *pMark);
1760 }
1761
1762 /******************************************************************
1763 *
1764 ******************************************************************/
1765
Invalidate()1766 void SwUnoCollection::Invalidate()
1767 {
1768 bObjectValid = sal_False;
1769 pDoc = 0;
1770 }
1771
1772