Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <osl/mutex.hxx>
31 : : #include <vcl/image.hxx>
32 : : #include <vcl/virdev.hxx>
33 : : #include <vcl/svapp.hxx>
34 : : #include <vcl/print.hxx>
35 : : #include <sfx2/viewfrm.hxx>
36 : : #include <sfx2/sfxbasecontroller.hxx>
37 : : #include <sfx2/docfile.hxx>
38 : : #include <toolkit/helper/vclunohelper.hxx>
39 : : #include <toolkit/awt/vclxdevice.hxx>
40 : : #include <cmdid.h>
41 : : #include <swtypes.hxx>
42 : : #include <wdocsh.hxx>
43 : : #include <wrtsh.hxx>
44 : : #include <pview.hxx>
45 : : #include <viewsh.hxx>
46 : : #include <pvprtdat.hxx>
47 : : #include <printdata.hxx>
48 : : #include <svl/stritem.hxx>
49 : : #include <unotxdoc.hxx>
50 : : #include <svl/numuno.hxx>
51 : : #include <fldbas.hxx>
52 : : #include <unotextbodyhf.hxx>
53 : : #include <unotextrange.hxx>
54 : : #include <unotextcursor.hxx>
55 : : #include <unosett.hxx>
56 : : #include <unocoll.hxx>
57 : : #include <unoredlines.hxx>
58 : : #include <unosrch.hxx>
59 : : #include <sfx2/dispatch.hxx>
60 : : #include <sfx2/request.hxx>
61 : : #include <sfx2/objsh.hxx> // SfxObjectShellRef <-> SV_DECL_REF(SfxObjectShell)
62 : : #include <unoprnms.hxx>
63 : : #include <unostyle.hxx>
64 : : #include <unodraw.hxx>
65 : : #include <svl/eitem.hxx>
66 : : #include <pagedesc.hxx>
67 : : #include <svtools/txtcmp.hxx>
68 : : #include <unocrsr.hxx>
69 : : #include <unofield.hxx>
70 : : #include <unoidx.hxx>
71 : : #include <unoflatpara.hxx>
72 : : #include <unotxvw.hxx>
73 : : #include <poolfmt.hxx>
74 : : #include <globdoc.hxx>
75 : : #include <viewopt.hxx>
76 : : #include <unochart.hxx>
77 : : #include <charatr.hxx>
78 : : #include <svx/xmleohlp.hxx>
79 : : #include <globals.hrc>
80 : : #include <unomid.h>
81 : : #include <unotools/printwarningoptions.hxx>
82 : : #include <com/sun/star/util/SearchOptions.hpp>
83 : : #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
84 : : #include <com/sun/star/lang/DisposedException.hpp>
85 : : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
86 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
87 : : #include <com/sun/star/beans/XFastPropertySet.hpp>
88 : : #include <com/sun/star/document/RedlineDisplayType.hpp>
89 : : #include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
90 : : #include <com/sun/star/frame/XController.hpp>
91 : : #include <com/sun/star/frame/XFrame.hpp>
92 : : #include <com/sun/star/script/XInvocation.hpp>
93 : : #include <sfx2/linkmgr.hxx>
94 : : #include <svx/unofill.hxx>
95 : : #include <editeng/unolingu.hxx>
96 : : #include <sfx2/progress.hxx>
97 : : #include <swmodule.hxx>
98 : : #include <docstat.hxx>
99 : : #include <modcfg.hxx>
100 : : #include <ndtxt.hxx>
101 : : #include <utlui.hrc>
102 : : #include <swcont.hxx>
103 : : #include <unodefaults.hxx>
104 : : #include <SwXDocumentSettings.hxx>
105 : : #include <doc.hxx>
106 : : #include <editeng/forbiddencharacterstable.hxx>
107 : : #include <svl/zforlist.hxx>
108 : : #include <drawdoc.hxx>
109 : : #include <SwStyleNameMapper.hxx>
110 : : #include <osl/file.hxx>
111 : : #include <comphelper/storagehelper.hxx>
112 : :
113 : : // #i12836# enhanced pdf export
114 : : #include <EnhancedPDFExportHelper.hxx>
115 : : #include <numrule.hxx>
116 : :
117 : : #include <editeng/langitem.hxx>
118 : : #include <docary.hxx> //SwCharFmts
119 : : #include <i18npool/mslangid.hxx>
120 : :
121 : : #include <format.hxx>
122 : : #include <charfmt.hxx> //SwCharFmt
123 : : #include <fmtcol.hxx> //SwTxtFmtColl
124 : : #include <unostyle.hxx> //SwAutoStyleFamily
125 : : #include <istyleaccess.hxx> // handling of automatic styles
126 : :
127 : : #include <svl/stylepool.hxx>
128 : : #include <swatrset.hxx>
129 : : #include <view.hxx>
130 : : #include <srcview.hxx>
131 : :
132 : : #include <svtools/langtab.hxx>
133 : : #include <map>
134 : : #include <set>
135 : : #include <vector>
136 : :
137 : : #include <editeng/eeitem.hxx>
138 : : #include <editeng/editeng.hxx>
139 : : #include <svx/svdoutl.hxx>
140 : : #include <svl/languageoptions.hxx>
141 : : #include <svx/svdview.hxx>
142 : : #include <comphelper/processfactory.hxx>
143 : : #include <comphelper/servicehelper.hxx>
144 : :
145 : : using namespace ::com::sun::star;
146 : : using namespace ::com::sun::star::text;
147 : : using namespace ::com::sun::star::i18n;
148 : : using namespace ::com::sun::star::uno;
149 : : using namespace ::com::sun::star::beans;
150 : : using namespace ::com::sun::star::lang;
151 : : using namespace ::com::sun::star::container;
152 : : using namespace ::com::sun::star::document;
153 : : using namespace ::com::sun::star::i18n;
154 : : using ::rtl::OUString;
155 : : using ::osl::FileBase;
156 : :
157 : : #define SW_CREATE_DASH_TABLE 0x01
158 : : #define SW_CREATE_GRADIENT_TABLE 0x02
159 : : #define SW_CREATE_HATCH_TABLE 0x03
160 : : #define SW_CREATE_BITMAP_TABLE 0x04
161 : : #define SW_CREATE_TRANSGRADIENT_TABLE 0x05
162 : : #define SW_CREATE_MARKER_TABLE 0x06
163 : : #define SW_CREATE_DRAW_DEFAULTS 0x07
164 : :
165 : : extern bool lcl_GetPostIts( IDocumentFieldsAccess* pIDFA, _SetGetExpFlds * pSrtLst );
166 : :
167 : 0 : SwPrintUIOptions * lcl_GetPrintUIOptions(
168 : : SwDocShell * pDocShell,
169 : : const SfxViewShell * pView )
170 : : {
171 [ # # ]: 0 : if (!pDocShell)
172 : 0 : return NULL;
173 : :
174 [ # # ][ # # ]: 0 : const sal_Bool bWebDoc = NULL != dynamic_cast< const SwWebDocShell * >(pDocShell);
175 [ # # ][ # # ]: 0 : const bool bSwSrcView = NULL != dynamic_cast< const SwSrcView * >(pView);
176 [ # # ]: 0 : const SwView * pSwView = dynamic_cast< const SwView * >(pView);
177 [ # # ][ # # ]: 0 : const bool bHasSelection = pSwView ? pSwView->HasSelection( sal_False ) : false; // check for any selection, not just text selection
178 [ # # ]: 0 : const bool bHasPostIts = lcl_GetPostIts( pDocShell->GetDoc(), 0 );
179 : :
180 : : // get default values to use in dialog from documents SwPrintData
181 : 0 : const SwPrintData &rPrintData = pDocShell->GetDoc()->getPrintData();
182 : :
183 : : // Get current page number
184 : 0 : sal_uInt16 nCurrentPage = 1;
185 : 0 : SwWrtShell* pSh = pDocShell->GetWrtShell();
186 [ # # ]: 0 : if (pSh)
187 : : {
188 : 0 : SwPaM* pShellCrsr = pSh->GetCrsr();
189 : 0 : nCurrentPage = pShellCrsr->GetPageNum(sal_True, 0);
190 : : }
191 [ # # ]: 0 : else if (!bSwSrcView)
192 : : {
193 [ # # ]: 0 : const SwPagePreView* pPreView = dynamic_cast< const SwPagePreView* >(pView);
194 : : OSL_ENSURE(pPreView, "Unexpected type of the view shell");
195 [ # # ]: 0 : if (pPreView)
196 : 0 : nCurrentPage = pPreView->GetSelectedPage();
197 : : }
198 [ # # ]: 0 : return new SwPrintUIOptions( nCurrentPage, bWebDoc, bSwSrcView, bHasSelection, bHasPostIts, rPrintData );
199 : : }
200 : :
201 : 0 : SwTxtFmtColl *lcl_GetParaStyle(const String& rCollName, SwDoc* pDoc)
202 : : {
203 : 0 : SwTxtFmtColl* pColl = pDoc->FindTxtFmtCollByName( rCollName );
204 [ # # ]: 0 : if( !pColl )
205 : : {
206 : 0 : sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rCollName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
207 [ # # ]: 0 : if( USHRT_MAX != nId )
208 : 0 : pColl = pDoc->GetTxtCollFromPool( nId );
209 : : }
210 : 0 : return pColl;
211 : : }
212 : :
213 : 0 : void lcl_DisposeView( SfxViewFrame* pToClose, SwDocShell* pDocShell )
214 : : {
215 : : // check if the view frame still exists
216 : : SfxViewFrame* pFound = SfxViewFrame::GetFirst( pDocShell,
217 : 0 : sal_False );
218 [ # # ]: 0 : while(pFound)
219 : : {
220 [ # # ]: 0 : if( pFound == pToClose)
221 : : {
222 : 0 : pToClose->DoClose();
223 : 0 : break;
224 : : }
225 : : pFound = SfxViewFrame::GetNext( *pFound,
226 : : pDocShell,
227 : 0 : sal_False );
228 : : }
229 : 0 : }
230 : :
231 : : namespace
232 : : {
233 : : class theSwXTextDocumentUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextDocumentUnoTunnelId > {};
234 : : }
235 : :
236 : 60433 : const Sequence< sal_Int8 > & SwXTextDocument::getUnoTunnelId()
237 : : {
238 : 60433 : return theSwXTextDocumentUnoTunnelId::get().getSeq();
239 : : }
240 : :
241 : 59966 : sal_Int64 SAL_CALL SwXTextDocument::getSomething( const Sequence< sal_Int8 >& rId )
242 : : throw(RuntimeException)
243 : : {
244 [ + - + + ]: 119932 : if( rId.getLength() == 16
[ + + ]
245 : 59966 : && 0 == memcmp( getUnoTunnelId().getConstArray(),
246 : 59966 : rId.getConstArray(), 16 ) )
247 : : {
248 : 467 : return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
249 : : }
250 [ + - - + ]: 118998 : if( rId.getLength() == 16
[ - + ]
251 : 59499 : && 0 == memcmp( SfxObjectShell::getUnoTunnelId().getConstArray(),
252 : 59499 : rId.getConstArray(), 16 ) )
253 : : {
254 : 0 : return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(pDocShell ));
255 : : }
256 : :
257 : 59499 : sal_Int64 nRet = SfxBaseModel::getSomething( rId );
258 [ + + ]: 59499 : if ( nRet )
259 : 59299 : return nRet;
260 : : else
261 : : {
262 [ + - ]: 200 : GetNumberFormatter();
263 [ + - ][ + - ]: 200 : Any aNumTunnel = xNumFmtAgg->queryAggregation(::getCppuType((Reference<XUnoTunnel>*)0));
[ + - ]
264 : 200 : Reference<XUnoTunnel> xNumTunnel;
265 [ + - ]: 200 : aNumTunnel >>= xNumTunnel;
266 [ + - ]: 200 : if(xNumTunnel.is())
267 [ + - ][ + - ]: 200 : return xNumTunnel->getSomething(rId);
[ + - ][ - + ]
268 : : }
269 : :
270 : 59966 : return SfxBaseModel::getSomething( rId );
271 : : }
272 : :
273 : 639761 : Any SAL_CALL SwXTextDocument::queryInterface( const uno::Type& rType ) throw(RuntimeException)
274 : : {
275 : 639761 : Any aRet = SwXTextDocumentBaseClass::queryInterface(rType);
276 [ + + ]: 639761 : if ( !aRet.hasValue() )
277 [ + - ]: 374676 : aRet = SfxBaseModel::queryInterface(rType);
278 [ + + + + ]: 711873 : if ( !aRet.hasValue() &&
[ + + ]
279 [ + - ]: 72112 : rType == ::getCppuType((Reference<lang::XMultiServiceFactory>*)0))
280 : : {
281 [ + - ]: 5897 : Reference<lang::XMultiServiceFactory> xTmp = this;
282 [ + - ]: 5897 : aRet <<= xTmp;
283 : : }
284 : :
285 [ + + + - : 875681 : if ( !aRet.hasValue()
+ + + + +
+ + + +
+ ][ + + ]
286 [ + - ]: 66215 : && rType != ::getCppuType((Reference< com::sun::star::document::XDocumentEventBroadcaster>*)0)
287 [ + - ]: 66215 : && rType != ::getCppuType((Reference< com::sun::star::frame::XController>*)0)
288 [ + - ]: 43558 : && rType != ::getCppuType((Reference< com::sun::star::frame::XFrame>*)0)
289 [ + - ]: 20901 : && rType != ::getCppuType((Reference< com::sun::star::script::XInvocation>*)0)
290 [ + - ]: 19548 : && rType != ::getCppuType((Reference< com::sun::star::beans::XFastPropertySet>*)0)
291 [ + - ]: 19483 : && rType != ::getCppuType((Reference< com::sun::star::awt::XWindow>*)0))
292 : : {
293 [ + - ]: 1216 : GetNumberFormatter();
294 [ + - ]: 1216 : if(xNumFmtAgg.is())
295 [ + - ][ + - ]: 1216 : aRet = xNumFmtAgg->queryAggregation(rType);
296 : : }
297 : 639761 : return aRet;
298 : : }
299 : :
300 : 1834884 : void SAL_CALL SwXTextDocument::acquire()throw()
301 : : {
302 : 1834884 : SfxBaseModel::acquire();
303 : 1834884 : }
304 : :
305 : 1834208 : void SAL_CALL SwXTextDocument::release()throw()
306 : : {
307 : 1834208 : SfxBaseModel::release();
308 : 1834208 : }
309 : :
310 : 14806 : Reference< XAdapter > SwXTextDocument::queryAdapter( ) throw(RuntimeException)
311 : : {
312 : 14806 : return SfxBaseModel::queryAdapter();
313 : : }
314 : :
315 : 1335 : Sequence< uno::Type > SAL_CALL SwXTextDocument::getTypes() throw(RuntimeException)
316 : : {
317 [ + - ]: 1335 : Sequence< uno::Type > aBaseTypes = SfxBaseModel::getTypes();
318 [ + - ]: 1335 : Sequence< uno::Type > aTextTypes = SwXTextDocumentBaseClass::getTypes();
319 : :
320 [ + - ]: 1335 : Sequence< uno::Type > aNumTypes;
321 [ + - ]: 1335 : GetNumberFormatter();
322 [ + - ]: 1335 : if(xNumFmtAgg.is())
323 : : {
324 [ + - ]: 1335 : const uno::Type& rProvType = ::getCppuType((Reference <XTypeProvider>*)0);
325 [ + - ][ + - ]: 1335 : Any aNumProv = xNumFmtAgg->queryAggregation(rProvType);
326 : 1335 : Reference<XTypeProvider> xNumProv;
327 [ + - ][ + - ]: 1335 : if(aNumProv >>= xNumProv)
328 : : {
329 [ + - ][ + - ]: 1335 : aNumTypes = xNumProv->getTypes();
[ + - ][ + - ]
330 : 1335 : }
331 : : }
332 : 1335 : long nIndex = aBaseTypes.getLength();
333 : : // don't forget the lang::XMultiServiceFactory
334 [ + - ]: 1335 : aBaseTypes.realloc(aBaseTypes.getLength() + aTextTypes.getLength() + aNumTypes.getLength() + 1);
335 [ + - ]: 1335 : uno::Type* pBaseTypes = aBaseTypes.getArray();
336 : 1335 : const uno::Type* pTextTypes = aTextTypes.getConstArray();
337 : : long nPos;
338 [ + + ]: 46725 : for(nPos = 0; nPos < aTextTypes.getLength(); nPos++)
339 : : {
340 : 45390 : pBaseTypes[nIndex++] = pTextTypes[nPos];
341 : : }
342 : 1335 : const uno::Type* pNumTypes = aNumTypes.getConstArray();
343 [ + + ]: 8010 : for(nPos = 0; nPos < aNumTypes.getLength(); nPos++)
344 : : {
345 : 6675 : pBaseTypes[nIndex++] = pNumTypes[nPos];
346 : : }
347 [ + - ]: 1335 : pBaseTypes[nIndex++] = ::getCppuType((Reference<lang::XMultiServiceFactory>*)0);
348 [ + - ][ + - ]: 1335 : return aBaseTypes;
349 : : }
350 : :
351 : 1553 : SwXTextDocument::SwXTextDocument(SwDocShell* pShell) :
352 : : SfxBaseModel(pShell),
353 : :
354 : : aRefreshCont ( static_cast < XTextDocument* > ( this ) ),
355 : :
356 [ + - ]: 1553 : pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_DOCUMENT)),
357 : :
358 : : pDocShell(pShell),
359 : :
360 : : bObjectValid(pShell != 0),
361 : :
362 : : pDrawPage(0),
363 : : pxXDrawPage(0),
364 : :
365 : : pxXNumberingRules(0),
366 : : pxXFootnotes(0),
367 : : pxXFootnoteSettings(0),
368 : : pxXEndnotes(0),
369 : : pxXEndnoteSettings(0),
370 : : pxXReferenceMarks(0),
371 : : pxXTextFieldTypes(0),
372 : : pxXTextFieldMasters(0),
373 : : pxXTextSections(0),
374 : : pxXBookmarks(0),
375 : : pxXTextTables(0),
376 : : pxXTextFrames(0),
377 : : pxXGraphicObjects(0),
378 : : pxXEmbeddedObjects(0),
379 : : pxXStyleFamilies(0),
380 : : pxXAutoStyles(0),
381 : : pxXChapterNumbering(0),
382 : : pxXDocumentIndexes(0),
383 : :
384 : : pxXLineNumberingProperties(0),
385 : : pxLinkTargetSupplier(0),
386 : : pxXRedlines(0),
387 : : m_pHiddenViewFrame(0),
388 : : m_pPrintUIOptions( NULL ),
389 [ + - ][ + - ]: 3106 : m_pRenderData( NULL )
[ + - ]
390 : : {
391 : 1553 : }
392 : :
393 [ + - ][ + - ]: 1162 : SwXTextDocument::~SwXTextDocument()
394 : : {
395 [ + - ]: 1162 : InitNewDoc();
396 [ + + ]: 1162 : if(xNumFmtAgg.is())
397 : : {
398 : 1024 : Reference< XInterface > x0;
399 [ + - ][ + - ]: 1024 : xNumFmtAgg->setDelegator(x0);
400 [ + - ]: 1024 : xNumFmtAgg = 0;
401 : : }
402 [ - + ][ # # ]: 1162 : delete m_pPrintUIOptions;
403 [ - + ][ # # ]: 1162 : delete m_pRenderData;
404 [ - + ]: 2324 : }
405 : :
406 : 242 : SwXDocumentPropertyHelper * SwXTextDocument::GetPropertyHelper ()
407 : : {
408 [ + + ]: 242 : if(!xPropertyHelper.is())
409 : : {
410 [ + - ]: 80 : pPropertyHelper = new SwXDocumentPropertyHelper(*pDocShell->GetDoc());
411 : 80 : xPropertyHelper = (cppu::OWeakObject*)pPropertyHelper;
412 : : }
413 : 242 : return pPropertyHelper;
414 : : }
415 : :
416 : 2751 : void SwXTextDocument::GetNumberFormatter()
417 : : {
418 [ + - ]: 2751 : if(IsValid())
419 : : {
420 [ + + ]: 2751 : if(!xNumFmtAgg.is())
421 : : {
422 [ + - ]: 1318 : if ( pDocShell->GetDoc() )
423 : : {
424 : : SvNumberFormatsSupplierObj* pNumFmt = new SvNumberFormatsSupplierObj(
425 [ + - ][ + - ]: 1318 : pDocShell->GetDoc()->GetNumberFormatter( sal_True ));
426 [ + - ][ + - ]: 1318 : Reference< util::XNumberFormatsSupplier > xTmp = pNumFmt;
427 [ + - ][ + - ]: 1318 : xNumFmtAgg = Reference< XAggregation >(xTmp, UNO_QUERY);
428 : : }
429 [ + - ]: 1318 : if(xNumFmtAgg.is())
430 [ + - ]: 1318 : xNumFmtAgg->setDelegator((cppu::OWeakObject*)(SwXTextDocumentBaseClass*)this);
431 : : }
432 : : else
433 : : {
434 [ + - ]: 1433 : const uno::Type& rTunnelType = ::getCppuType((Reference <XUnoTunnel>*)0);
435 [ + - ][ + - ]: 1433 : Any aNumTunnel = xNumFmtAgg->queryAggregation(rTunnelType);
436 : 1433 : SvNumberFormatsSupplierObj* pNumFmt = 0;
437 : 1433 : Reference< XUnoTunnel > xNumTunnel;
438 [ + - ][ + - ]: 1433 : if(aNumTunnel >>= xNumTunnel)
439 : : {
440 : : pNumFmt = reinterpret_cast<SvNumberFormatsSupplierObj*>(
441 [ + - ][ + - ]: 1433 : xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
[ + - ]
442 : :
443 : : }
444 : : OSL_ENSURE(pNumFmt, "No number formatter available");
445 [ + - ][ - + ]: 1433 : if(!pNumFmt->GetNumberFormatter())
446 [ # # ][ # # ]: 1433 : pNumFmt->SetNumberFormatter(pDocShell->GetDoc()->GetNumberFormatter( sal_True ));
447 : : }
448 : : }
449 : 2751 : }
450 : :
451 : 14275 : Reference< XText > SwXTextDocument::getText(void) throw( RuntimeException )
452 : : {
453 [ + - ]: 14275 : SolarMutexGuard aGuard;
454 [ - + ]: 14275 : if(!IsValid())
455 [ # # ]: 0 : throw RuntimeException();
456 [ + + ]: 14275 : if(!xBodyText.is())
457 : : {
458 [ + - ]: 889 : pBodyText = new SwXBodyText(pDocShell->GetDoc());
459 [ + - ][ + - ]: 889 : xBodyText = pBodyText;
460 : : }
461 [ + - ]: 14275 : return xBodyText;
462 : : }
463 : :
464 : 2 : void SwXTextDocument::reformat(void) throw( RuntimeException )
465 : : {
466 [ + - ]: 2 : SolarMutexGuard aGuard;
467 [ - + ]: 2 : if(!IsValid())
468 [ # # ][ + - ]: 2 : throw RuntimeException();
469 : 2 : }
470 : :
471 : 116 : void SwXTextDocument::lockControllers(void) throw( RuntimeException )
472 : : {
473 [ + - ]: 116 : SolarMutexGuard aGuard;
474 [ + - ]: 116 : if(IsValid())
475 : : {
476 [ + - ][ + - ]: 116 : UnoActionContext* pContext = new UnoActionContext(pDocShell->GetDoc());
477 [ + - ]: 116 : aActionArr.push_front(pContext);
478 : : }
479 : : else
480 [ + - ][ # # ]: 116 : throw RuntimeException();
481 : 116 : }
482 : :
483 : 116 : void SwXTextDocument::unlockControllers(void) throw( RuntimeException )
484 : : {
485 [ + - ]: 116 : SolarMutexGuard aGuard;
486 [ + - ]: 116 : if(!aActionArr.empty())
487 : : {
488 [ + - ]: 116 : UnoActionContext* pContext = aActionArr.front();
489 [ + - ]: 116 : aActionArr.pop_front();
490 [ + - ][ + - ]: 116 : delete pContext;
491 : : }
492 : : else
493 [ # # ][ + - ]: 116 : throw RuntimeException();
494 : 116 : }
495 : :
496 : 102 : sal_Bool SwXTextDocument::hasControllersLocked(void) throw( RuntimeException )
497 : : {
498 [ + - ]: 102 : SolarMutexGuard aGuard;
499 [ + - ]: 102 : return !aActionArr.empty();
500 : : }
501 : :
502 : 1875 : Reference< frame::XController > SwXTextDocument::getCurrentController(void) throw( RuntimeException )
503 : : {
504 : 1875 : return SfxBaseModel::getCurrentController();
505 : : }
506 : :
507 : 2624 : void SwXTextDocument::setCurrentController(const Reference< frame::XController > & xController)
508 : : throw( NoSuchElementException, RuntimeException )
509 : : {
510 : 2624 : SfxBaseModel::setCurrentController(xController);
511 : 2624 : }
512 : :
513 : 2 : Reference< XInterface > SwXTextDocument::getCurrentSelection() throw( RuntimeException )
514 : : {
515 [ + - ]: 2 : SolarMutexGuard aGuard;
516 : 2 : Reference< XInterface > xRef;
517 [ + - ]: 2 : if(IsValid())
518 : : {
519 : :
520 [ + - ]: 2 : const TypeId aTypeId = TYPE(SwView);
521 [ + - ]: 2 : SwView* pView = (SwView*)SfxViewShell::GetFirst(&aTypeId);
522 [ + - ][ + - ]: 2 : while(pView && pView->GetObjectShell() != pDocShell)
[ - + ][ - + ]
523 : : {
524 [ # # ]: 0 : pView = (SwView*)SfxViewShell::GetNext(*pView, &aTypeId);
525 : : }
526 [ + - ]: 2 : if(pView)
527 : : {
528 [ + - ][ + - ]: 2 : Any aRef = pView->GetUNOObject()->getSelection();
529 [ + - ]: 2 : aRef >>= xRef;
530 : : }
531 : : }
532 [ + - ]: 2 : return xRef;
533 : : }
534 : :
535 : 2438 : sal_Bool SwXTextDocument::attachResource(const OUString& aURL, const Sequence< beans::PropertyValue >& aArgs)
536 : : throw( RuntimeException )
537 : : {
538 : 2438 : return SfxBaseModel::attachResource(aURL, aArgs);
539 : : }
540 : :
541 : 5586 : OUString SwXTextDocument::getURL(void) throw( RuntimeException )
542 : : {
543 : 5586 : return SfxBaseModel::getURL();
544 : : }
545 : :
546 : 5802 : Sequence< beans::PropertyValue > SwXTextDocument::getArgs(void) throw( RuntimeException )
547 : : {
548 : 5802 : return SfxBaseModel::getArgs();
549 : : }
550 : :
551 : 1322 : void SwXTextDocument::connectController(const Reference< frame::XController > & xController) throw( RuntimeException )
552 : : {
553 : 1322 : SfxBaseModel::connectController(xController);
554 : 1322 : }
555 : :
556 : 1233 : void SwXTextDocument::disconnectController(const Reference< frame::XController > & xController) throw( RuntimeException )
557 : : {
558 : 1233 : SfxBaseModel::disconnectController(xController);
559 : 1233 : }
560 : :
561 : 1890 : void SwXTextDocument::dispose(void) throw( RuntimeException )
562 : : {
563 : 1890 : SfxBaseModel::dispose();
564 : 1890 : }
565 : :
566 : 2692 : void SwXTextDocument::close( sal_Bool bDeliverOwnership ) throw( util::CloseVetoException, RuntimeException )
567 : : {
568 [ + - ]: 2692 : SolarMutexGuard aGuard;
569 [ + + ][ - + ]: 2692 : if(IsValid() && m_pHiddenViewFrame)
[ - + ]
570 [ # # ]: 0 : lcl_DisposeView( m_pHiddenViewFrame, pDocShell);
571 [ + - ][ + - ]: 2692 : SfxBaseModel::close(bDeliverOwnership);
572 : 2692 : }
573 : :
574 : 1953 : void SwXTextDocument::addEventListener(const Reference< lang::XEventListener > & aListener) throw( RuntimeException )
575 : : {
576 : 1953 : SfxBaseModel::addEventListener(aListener);
577 : 1953 : }
578 : :
579 : 336 : void SwXTextDocument::removeEventListener(const Reference< lang::XEventListener > & aListener) throw( RuntimeException )
580 : : {
581 : 336 : SfxBaseModel::removeEventListener(aListener);
582 : 336 : }
583 : :
584 : 84 : Reference< XPropertySet > SwXTextDocument::getLineNumberingProperties(void)
585 : : throw( RuntimeException )
586 : : {
587 [ + - ]: 84 : SolarMutexGuard aGuard;
588 [ + - ]: 84 : if(IsValid())
589 : : {
590 [ + + ]: 84 : if(!pxXLineNumberingProperties)
591 : : {
592 : 73 : pxXLineNumberingProperties = new Reference<XPropertySet>;
593 [ + - ][ + - ]: 73 : (*pxXLineNumberingProperties) = new SwXLineNumberingProperties(pDocShell->GetDoc());
[ + - ]
594 : : }
595 : : }
596 : : else
597 [ # # ]: 0 : throw RuntimeException();
598 [ + - ]: 84 : return *pxXLineNumberingProperties;
599 : : }
600 : :
601 : 307 : Reference< XIndexReplace > SwXTextDocument::getChapterNumberingRules(void)
602 : : throw( RuntimeException )
603 : : {
604 [ + - ]: 307 : SolarMutexGuard aGuard;
605 [ - + ]: 307 : if(!IsValid())
606 [ # # ]: 0 : throw RuntimeException();
607 [ + + ]: 307 : if(!pxXChapterNumbering)
608 : : {
609 : 80 : pxXChapterNumbering = new Reference< XIndexReplace > ;
610 [ + - ][ + - ]: 80 : *pxXChapterNumbering = new SwXChapterNumbering(*pDocShell);
[ + - ]
611 : : }
612 [ + - ]: 307 : return *pxXChapterNumbering;
613 : : }
614 : :
615 : 24 : Reference< XIndexAccess > SwXTextDocument::getNumberingRules(void) throw( RuntimeException )
616 : : {
617 [ + - ]: 24 : SolarMutexGuard aGuard;
618 [ - + ]: 24 : if(!IsValid())
619 [ # # ]: 0 : throw RuntimeException();
620 [ + + ]: 24 : if(!pxXNumberingRules )
621 : : {
622 : 22 : ((SwXTextDocument*)this)->pxXNumberingRules = new Reference< XIndexAccess > ;
623 [ + - ][ + - ]: 22 : *pxXNumberingRules = new SwXNumberingRulesCollection( pDocShell->GetDoc() );
[ + - ]
624 : : }
625 [ + - ]: 24 : return *pxXNumberingRules;
626 : : }
627 : :
628 : 10 : Reference< XIndexAccess > SwXTextDocument::getFootnotes(void) throw( RuntimeException )
629 : : {
630 [ + - ]: 10 : SolarMutexGuard aGuard;
631 [ - + ]: 10 : if(!IsValid())
632 [ # # ]: 0 : throw RuntimeException();
633 [ + - ]: 10 : if(!pxXFootnotes)
634 : : {
635 : 10 : ((SwXTextDocument*)this)->pxXFootnotes = new Reference< XIndexAccess > ;
636 [ + - ][ + - ]: 10 : *pxXFootnotes = new SwXFootnotes(sal_False, pDocShell->GetDoc());
[ + - ]
637 : : }
638 [ + - ]: 10 : return *pxXFootnotes;
639 : : }
640 : :
641 : : Reference< XPropertySet > SAL_CALL
642 : 468 : SwXTextDocument::getFootnoteSettings(void) throw( RuntimeException )
643 : : {
644 [ + - ]: 468 : SolarMutexGuard aGuard;
645 [ - + ]: 468 : if(!IsValid())
646 [ # # ]: 0 : throw RuntimeException();
647 [ + + ]: 468 : if(!pxXFootnoteSettings)
648 : : {
649 : 157 : ((SwXTextDocument*)this)->pxXFootnoteSettings = new Reference< XPropertySet > ;
650 [ + - ][ + - ]: 157 : *pxXFootnoteSettings = new SwXFootnoteProperties(pDocShell->GetDoc());
[ + - ]
651 : : }
652 [ + - ]: 468 : return *pxXFootnoteSettings;
653 : : }
654 : :
655 : 2 : Reference< XIndexAccess > SwXTextDocument::getEndnotes(void) throw( RuntimeException )
656 : : {
657 [ + - ]: 2 : SolarMutexGuard aGuard;
658 [ - + ]: 2 : if(!IsValid())
659 [ # # ]: 0 : throw RuntimeException();
660 [ + - ]: 2 : if(!pxXEndnotes)
661 : : {
662 : 2 : ((SwXTextDocument*)this)->pxXEndnotes = new Reference< XIndexAccess > ;
663 [ + - ][ + - ]: 2 : *pxXEndnotes = new SwXFootnotes(sal_True, pDocShell->GetDoc());
[ + - ]
664 : : }
665 [ + - ]: 2 : return *pxXEndnotes;
666 : : }
667 : :
668 : 338 : Reference< XPropertySet > SwXTextDocument::getEndnoteSettings(void) throw( RuntimeException )
669 : : {
670 [ + - ]: 338 : SolarMutexGuard aGuard;
671 [ - + ]: 338 : if(!IsValid())
672 [ # # ]: 0 : throw RuntimeException();
673 [ + + ]: 338 : if(!pxXEndnoteSettings)
674 : : {
675 : 153 : ((SwXTextDocument*)this)->pxXEndnoteSettings = new Reference< XPropertySet > ;
676 [ + - ][ + - ]: 153 : *pxXEndnoteSettings = new SwXEndnoteProperties(pDocShell->GetDoc());
[ + - ]
677 : : }
678 [ + - ]: 338 : return *pxXEndnoteSettings;
679 : : }
680 : :
681 : 2 : Reference< util::XReplaceDescriptor > SwXTextDocument::createReplaceDescriptor(void)
682 : : throw( RuntimeException )
683 : : {
684 [ + - ]: 2 : SolarMutexGuard aGuard;
685 [ + - ][ + - ]: 2 : Reference< util::XReplaceDescriptor > xRet = new SwXTextSearch;
[ + - ]
686 [ + - ]: 2 : return xRet;
687 : : }
688 : :
689 : 16 : SwUnoCrsr* SwXTextDocument::CreateCursorForSearch(Reference< XTextCursor > & xCrsr)
690 : : {
691 : 16 : getText();
692 : 16 : XText *const pText = xBodyText.get();
693 [ + - ]: 16 : SwXBodyText* pBText = (SwXBodyText*)pText;
694 : 16 : SwXTextCursor *const pXTextCursor = pBText->CreateTextCursor(true);
695 [ + - ]: 16 : xCrsr.set( static_cast<text::XWordCursor*>(pXTextCursor) );
696 : :
697 : 16 : SwUnoCrsr *const pUnoCrsr = pXTextCursor->GetCursor();
698 : 16 : pUnoCrsr->SetRemainInSection(sal_False);
699 : 16 : return pUnoCrsr;
700 : : }
701 : :
702 : 4 : sal_Int32 SwXTextDocument::replaceAll(const Reference< util::XSearchDescriptor > & xDesc)
703 : : throw( RuntimeException )
704 : : {
705 [ + - ]: 4 : SolarMutexGuard aGuard;
706 [ + - ]: 4 : Reference< XUnoTunnel > xDescTunnel(xDesc, UNO_QUERY);
707 [ + - ][ + - ]: 4 : if(!IsValid() || !xDescTunnel.is() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()))
[ + - ][ + - ]
[ + - ][ - + ]
[ - + ]
708 [ # # ]: 0 : throw RuntimeException();
709 : :
710 : 4 : Reference< XTextCursor > xCrsr;
711 [ + - ]: 4 : SwUnoCrsr* pUnoCrsr = CreateCursorForSearch(xCrsr);
712 : :
713 : : const SwXTextSearch* pSearch = reinterpret_cast<const SwXTextSearch*>(
714 [ + - ][ + - ]: 4 : xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()));
[ + - ]
715 : :
716 : 4 : int eRanges(FND_IN_BODY|FND_IN_SELALL);
717 : :
718 : 4 : util::SearchOptions aSearchOpt;
719 [ + - ]: 4 : pSearch->FillSearchOptions( aSearchOpt );
720 : :
721 [ - + ]: 4 : SwDocPositions eStart = pSearch->bBack ? DOCPOS_END : DOCPOS_START;
722 [ - + ]: 4 : SwDocPositions eEnd = pSearch->bBack ? DOCPOS_START : DOCPOS_END;
723 : :
724 : : // Suche soll ueberall stattfinden
725 : 4 : pUnoCrsr->SetRemainInSection(sal_False);
726 : : sal_uInt32 nResult;
727 [ + - ]: 4 : UnoActionContext aContext(pDocShell->GetDoc());
728 : : //try attribute search first
729 [ + - ][ + - ]: 4 : if(pSearch->HasSearchAttributes()||pSearch->HasReplaceAttributes())
[ + - ][ - + ]
[ - + ]
730 : : {
731 : 0 : SfxItemSet aSearch(pDocShell->GetDoc()->GetAttrPool(),
732 : : RES_CHRATR_BEGIN, RES_CHRATR_END-1,
733 : : RES_PARATR_BEGIN, RES_PARATR_END-1,
734 : : RES_FRMATR_BEGIN, RES_FRMATR_END-1,
735 [ # # ]: 0 : 0);
736 : 0 : SfxItemSet aReplace(pDocShell->GetDoc()->GetAttrPool(),
737 : : RES_CHRATR_BEGIN, RES_CHRATR_END-1,
738 : : RES_PARATR_BEGIN, RES_PARATR_END-1,
739 : : RES_FRMATR_BEGIN, RES_FRMATR_END-1,
740 [ # # ]: 0 : 0);
741 [ # # ]: 0 : pSearch->FillSearchItemSet(aSearch);
742 [ # # ]: 0 : pSearch->FillReplaceItemSet(aReplace);
743 : : sal_Bool bCancel;
744 : : nResult = (sal_Int32)pUnoCrsr->Find( aSearch, !pSearch->bStyles,
745 : : eStart, eEnd, bCancel,
746 : : (FindRanges)eRanges,
747 : 0 : pSearch->sSearchText.Len() ? &aSearchOpt : 0,
748 [ # # ][ # # ]: 0 : &aReplace );
[ # # ][ # # ]
749 : : }
750 [ - + ]: 4 : else if(pSearch->bStyles)
751 : : {
752 [ # # ]: 0 : SwTxtFmtColl *pSearchColl = lcl_GetParaStyle(pSearch->sSearchText, pUnoCrsr->GetDoc());
753 [ # # ]: 0 : SwTxtFmtColl *pReplaceColl = lcl_GetParaStyle(pSearch->sReplaceText, pUnoCrsr->GetDoc());
754 : :
755 : : sal_Bool bCancel;
756 : : nResult = pUnoCrsr->Find( *pSearchColl,
757 : : eStart, eEnd, bCancel,
758 [ # # ]: 0 : (FindRanges)eRanges, pReplaceColl );
759 : :
760 : : }
761 : : else
762 : : {
763 : : //todo/mba: assuming that notes should be omitted
764 : 4 : sal_Bool bSearchInNotes = sal_False;
765 : : sal_Bool bCancel;
766 : : nResult = pUnoCrsr->Find( aSearchOpt, bSearchInNotes,
767 : : eStart, eEnd, bCancel,
768 : : (FindRanges)eRanges,
769 [ + - ]: 4 : sal_True );
770 : : }
771 [ + - ][ + - ]: 4 : return (sal_Int32)nResult;
772 : :
773 : : }
774 : :
775 : 8 : Reference< util::XSearchDescriptor > SwXTextDocument::createSearchDescriptor(void)
776 : : throw( RuntimeException )
777 : : {
778 [ + - ]: 8 : SolarMutexGuard aGuard;
779 [ + - ][ + - ]: 8 : Reference< util::XSearchDescriptor > xRet = new SwXTextSearch;
[ + - ]
780 [ + - ]: 8 : return xRet;
781 : :
782 : : }
783 : :
784 : : /* --------------------------------------------------
785 : : * wird fuer findAll/First/Next verwendet
786 : : * --------------------------------------------------*/
787 : 12 : SwUnoCrsr* SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor > & xDesc,
788 : : Reference< XTextCursor > & xCrsr, sal_Bool bAll,
789 : : sal_Int32& nResult,
790 : : Reference< XInterface > xLastResult)
791 : : {
792 [ + - ]: 12 : Reference< XUnoTunnel > xDescTunnel(xDesc, UNO_QUERY);
793 [ + - ][ + - ]: 12 : if(!IsValid() || !xDescTunnel.is() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()))
[ + - ][ + - ]
[ + - ][ - + ]
[ - + ]
794 : 0 : return 0;
795 : :
796 [ + - ]: 12 : SwUnoCrsr* pUnoCrsr = CreateCursorForSearch(xCrsr);
797 : : const SwXTextSearch* pSearch = reinterpret_cast<const SwXTextSearch*>(
798 [ + - ][ + - ]: 12 : xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()));
[ + - ]
799 : :
800 : 12 : sal_Bool bParentInExtra = sal_False;
801 [ + + ]: 12 : if(xLastResult.is())
802 : : {
803 [ + - ]: 2 : Reference<XUnoTunnel> xCursorTunnel( xLastResult, UNO_QUERY);
804 : 2 : OTextCursorHelper* pPosCrsr = 0;
805 [ + - ]: 2 : if(xCursorTunnel.is())
806 : : {
807 [ + - ]: 2 : pPosCrsr = reinterpret_cast<OTextCursorHelper*>(xCursorTunnel->getSomething(
808 [ + - ][ + - ]: 2 : OTextCursorHelper::getUnoTunnelId()));
809 : : }
810 [ + - ][ + - ]: 2 : SwPaM* pCrsr = pPosCrsr ? pPosCrsr->GetPaM() : 0;
811 [ + - ]: 2 : if(pCrsr)
812 : : {
813 [ + - ][ + - ]: 2 : *pUnoCrsr->GetPoint() = *pCrsr->End();
814 [ + - ]: 2 : pUnoCrsr->DeleteMark();
815 : : }
816 : : else
817 : : {
818 : 0 : SwXTextRange* pRange = 0;
819 [ # # ]: 0 : if(xCursorTunnel.is())
820 : : {
821 [ # # ]: 0 : pRange = reinterpret_cast<SwXTextRange*>(xCursorTunnel->getSomething(
822 [ # # ][ # # ]: 0 : SwXTextRange::getUnoTunnelId()));
823 : : }
824 [ # # ]: 0 : if(!pRange)
825 : 0 : return 0;
826 [ # # ]: 0 : pRange->GetPositions(*pUnoCrsr);
827 [ # # ]: 0 : if(pUnoCrsr->HasMark())
828 : : {
829 [ # # ][ # # ]: 0 : if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark())
830 : 0 : pUnoCrsr->Exchange();
831 [ # # ]: 0 : pUnoCrsr->DeleteMark();
832 : : }
833 : : }
834 : 2 : const SwNode* pRangeNode = pUnoCrsr->GetNode();
835 [ + - ]: 2 : bParentInExtra = pRangeNode->FindFlyStartNode() ||
836 [ + - ]: 2 : pRangeNode->FindFootnoteStartNode() ||
837 [ + - ]: 2 : pRangeNode->FindHeaderStartNode() ||
838 [ + - ][ + - ]: 6 : pRangeNode->FindFooterStartNode() ;
[ + - ][ + - ]
[ - + ][ + - ]
839 : : }
840 : :
841 : 12 : util::SearchOptions aSearchOpt;
842 [ + - ]: 12 : pSearch->FillSearchOptions( aSearchOpt );
843 : :
844 : : /*
845 : : * folgende Kombinationen sind erlaubt:
846 : : * - suche einen im Body: -> FND_IN_BODY
847 : : * - suche alle im Body: -> FND_IN_BODYONLY | FND_IN_SELALL
848 : : * - suche in Selectionen: einen / alle -> FND_IN_SEL [ | FND_IN_SELALL ]
849 : : * - suche im nicht Body: einen / alle -> FND_IN_OTHER [ | FND_IN_SELALL ]
850 : : * - suche ueberall alle: -> FND_IN_SELALL
851 : : */
852 : 12 : int eRanges(FND_IN_BODY);
853 [ - + ]: 12 : if(bParentInExtra)
854 : 0 : eRanges = FND_IN_OTHER;
855 [ + + ]: 12 : if(bAll) //immer - ueberall?
856 : 4 : eRanges = FND_IN_SELALL;
857 [ + + ][ - + ]: 12 : SwDocPositions eStart = !bAll ? DOCPOS_CURR : pSearch->bBack ? DOCPOS_END : DOCPOS_START;
858 [ - + ]: 12 : SwDocPositions eEnd = pSearch->bBack ? DOCPOS_START : DOCPOS_END;
859 : :
860 : 12 : nResult = 0;
861 : 12 : sal_uInt16 nSearchProc = 0;
862 [ + - ]: 14 : while(nSearchProc < 2)
863 : : {
864 : : //try attribute search first
865 [ + - ][ - + ]: 14 : if(pSearch->HasSearchAttributes())
866 : : {
867 : 0 : SfxItemSet aSearch(pDocShell->GetDoc()->GetAttrPool(),
868 : : RES_CHRATR_BEGIN, RES_CHRATR_END-1,
869 : : RES_PARATR_BEGIN, RES_PARATR_END-1,
870 : : RES_FRMATR_BEGIN, RES_FRMATR_END-1,
871 : : RES_TXTATR_INETFMT, RES_TXTATR_CHARFMT,
872 [ # # ]: 0 : 0);
873 [ # # ]: 0 : pSearch->FillSearchItemSet(aSearch);
874 : : sal_Bool bCancel;
875 : : nResult = (sal_Int32)pUnoCrsr->Find( aSearch, !pSearch->bStyles,
876 : : eStart, eEnd, bCancel,
877 : : (FindRanges)eRanges,
878 : 0 : pSearch->sSearchText.Len() ? &aSearchOpt : 0,
879 [ # # ][ # # ]: 0 : 0 );
[ # # ]
880 : : }
881 [ - + ]: 14 : else if(pSearch->bStyles)
882 : : {
883 [ # # ]: 0 : SwTxtFmtColl *pSearchColl = lcl_GetParaStyle(pSearch->sSearchText, pUnoCrsr->GetDoc());
884 : : //pSearch->sReplaceText
885 : 0 : SwTxtFmtColl *pReplaceColl = 0;
886 : : sal_Bool bCancel;
887 : : nResult = (sal_Int32)pUnoCrsr->Find( *pSearchColl,
888 : : eStart, eEnd, bCancel,
889 [ # # ]: 0 : (FindRanges)eRanges, pReplaceColl );
890 : : }
891 : : else
892 : : {
893 : : //todo/mba: assuming that notes should be omitted
894 : 14 : sal_Bool bSearchInNotes = sal_False;
895 : : sal_Bool bCancel;
896 : : nResult = (sal_Int32)pUnoCrsr->Find( aSearchOpt, bSearchInNotes,
897 : : eStart, eEnd, bCancel,
898 : : (FindRanges)eRanges,
899 [ + - ]: 14 : /*int bReplace =*/sal_False );
900 : : }
901 : 14 : nSearchProc++;
902 [ + + ][ + + ]: 14 : if(nResult || (eRanges&(FND_IN_SELALL|FND_IN_OTHER)))
903 : 12 : break;
904 : : //second step - find in other
905 : 2 : eRanges = FND_IN_OTHER;
906 : : }
907 : 12 : return pUnoCrsr;
908 : : }
909 : :
910 : : Reference< XIndexAccess >
911 : 4 : SwXTextDocument::findAll(const Reference< util::XSearchDescriptor > & xDesc)
912 : : throw( RuntimeException )
913 : : {
914 [ + - ]: 4 : SolarMutexGuard aGuard;
915 : 4 : Reference< XInterface > xTmp;
916 : 4 : sal_Int32 nResult = 0;
917 : 4 : Reference< XTextCursor > xCrsr;
918 [ + - ]: 4 : SwUnoCrsr* pResultCrsr = FindAny(xDesc, xCrsr, sal_True, nResult, xTmp);
919 [ - + ]: 4 : if(!pResultCrsr)
920 [ # # ]: 0 : throw RuntimeException();
921 : 4 : Reference< XIndexAccess > xRet;
922 [ + - ][ + - ]: 4 : xRet = new SwXTextRanges( (nResult) ? pResultCrsr : 0 );
[ + - ][ # # ]
[ + - ][ + - ]
[ + - ][ + - ]
923 [ + - ][ + - ]: 4 : delete pResultCrsr;
924 [ + - ]: 4 : return xRet;
925 : : }
926 : :
927 : 6 : Reference< XInterface > SwXTextDocument::findFirst(const Reference< util::XSearchDescriptor > & xDesc)
928 : : throw( RuntimeException )
929 : : {
930 [ + - ]: 6 : SolarMutexGuard aGuard;
931 : 6 : Reference< XInterface > xTmp;
932 : 6 : sal_Int32 nResult = 0;
933 : 6 : Reference< XTextCursor > xCrsr;
934 [ + - ]: 6 : SwUnoCrsr* pResultCrsr = FindAny(xDesc, xCrsr, sal_False, nResult, xTmp);
935 [ - + ]: 6 : if(!pResultCrsr)
936 [ # # ]: 0 : throw RuntimeException();
937 : 6 : Reference< XInterface > xRet;
938 [ + + ]: 6 : if(nResult)
939 : : {
940 : : const uno::Reference< text::XText > xParent =
941 : 4 : ::sw::CreateParentXText(*pDocShell->GetDoc(),
942 [ + - ]: 8 : *pResultCrsr->GetPoint());
943 [ + - ][ + - ]: 4 : xRet = *new SwXTextCursor(xParent, *pResultCrsr);
[ + - ]
944 [ + - ][ + - ]: 4 : delete pResultCrsr;
945 : : }
946 [ + - ]: 6 : return xRet;
947 : : }
948 : :
949 : 2 : Reference< XInterface > SwXTextDocument::findNext(const Reference< XInterface > & xStartAt,
950 : : const Reference< util::XSearchDescriptor > & xDesc)
951 : : throw( RuntimeException )
952 : : {
953 [ + - ]: 2 : SolarMutexGuard aGuard;
954 : 2 : Reference< XInterface > xTmp;
955 : 2 : sal_Int32 nResult = 0;
956 : 2 : Reference< XTextCursor > xCrsr;
957 [ - + ]: 2 : if(!xStartAt.is())
958 [ # # ]: 0 : throw RuntimeException();
959 [ + - ]: 2 : SwUnoCrsr* pResultCrsr = FindAny(xDesc, xCrsr, sal_False, nResult, xStartAt);
960 [ - + ]: 2 : if(!pResultCrsr)
961 [ # # ]: 0 : throw RuntimeException();
962 : 2 : Reference< XInterface > xRet;
963 [ + - ]: 2 : if(nResult)
964 : : {
965 : : const uno::Reference< text::XText > xParent =
966 : 2 : ::sw::CreateParentXText(*pDocShell->GetDoc(),
967 [ + - ]: 4 : *pResultCrsr->GetPoint());
968 : :
969 [ + - ][ + - ]: 2 : xRet = *new SwXTextCursor(xParent, *pResultCrsr);
[ + - ]
970 [ + - ][ + - ]: 2 : delete pResultCrsr;
971 : : }
972 [ + - ]: 2 : return xRet;
973 : : }
974 : :
975 : 0 : Sequence< beans::PropertyValue > SwXTextDocument::getPagePrintSettings(void)
976 : : throw( RuntimeException )
977 : : {
978 [ # # ]: 0 : SolarMutexGuard aGuard;
979 [ # # ]: 0 : Sequence< beans::PropertyValue > aSeq(9);
980 [ # # ]: 0 : if(IsValid())
981 : : {
982 [ # # ]: 0 : beans::PropertyValue* pArray = aSeq.getArray();
983 : 0 : SwPagePreViewPrtData aData;
984 : 0 : const SwPagePreViewPrtData* pData = pDocShell->GetDoc()->GetPreViewPrtData();
985 [ # # ]: 0 : if(pData)
986 : 0 : aData = *pData;
987 : 0 : Any aVal;
988 [ # # ]: 0 : aVal <<= (sal_Int16)aData.GetRow();
989 [ # # ]: 0 : pArray[0] = beans::PropertyValue(C2U("PageRows"), -1, aVal, PropertyState_DIRECT_VALUE);
990 [ # # ]: 0 : aVal <<= (sal_Int16)aData.GetCol();
991 [ # # ]: 0 : pArray[1] = beans::PropertyValue(C2U("PageColumns"), -1, aVal, PropertyState_DIRECT_VALUE);
992 [ # # ]: 0 : aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetLeftSpace());
993 [ # # ]: 0 : pArray[2] = beans::PropertyValue(C2U("LeftMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
994 [ # # ]: 0 : aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetRightSpace());
995 [ # # ]: 0 : pArray[3] = beans::PropertyValue(C2U("RightMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
996 [ # # ]: 0 : aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetTopSpace());
997 [ # # ]: 0 : pArray[4] = beans::PropertyValue(C2U("TopMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
998 [ # # ]: 0 : aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetBottomSpace());
999 [ # # ]: 0 : pArray[5] = beans::PropertyValue(C2U("BottomMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
1000 [ # # ]: 0 : aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetHorzSpace());
1001 [ # # ]: 0 : pArray[6] = beans::PropertyValue(C2U("HoriMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
1002 [ # # ]: 0 : aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetVertSpace());
1003 [ # # ]: 0 : pArray[7] = beans::PropertyValue(C2U("VertMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
1004 : 0 : sal_Bool bTemp = aData.GetLandscape();
1005 [ # # ]: 0 : aVal.setValue(&bTemp, ::getCppuBooleanType());
1006 [ # # ]: 0 : pArray[8] = beans::PropertyValue(C2U("IsLandscape"), -1, aVal, PropertyState_DIRECT_VALUE);
1007 : : }
1008 : : else
1009 [ # # ]: 0 : throw RuntimeException();
1010 [ # # ]: 0 : return aSeq;
1011 : : }
1012 : :
1013 : 0 : sal_uInt32 lcl_Any_To_ULONG(const Any& rValue, sal_Bool& bException)
1014 : : {
1015 : 0 : bException = sal_False;
1016 : 0 : TypeClass eType = rValue.getValueType().getTypeClass();
1017 : :
1018 : 0 : sal_uInt32 nRet = 0;
1019 [ # # ]: 0 : if( eType == TypeClass_UNSIGNED_LONG )
1020 : 0 : rValue >>= nRet;
1021 : : else
1022 : : {
1023 : 0 : sal_Int32 nVal=0;
1024 : 0 : bException = !(rValue >>= nVal);
1025 [ # # ]: 0 : if( !bException )
1026 : 0 : nRet = (sal_uInt32)nVal;
1027 : : }
1028 : :
1029 : 0 : return nRet;
1030 : : }
1031 : :
1032 : 0 : String lcl_CreateOutlineString( sal_uInt16 nIndex,
1033 : : const SwOutlineNodes& rOutlineNodes, const SwNumRule* pOutlRule)
1034 : : {
1035 [ # # ]: 0 : String sEntry;
1036 [ # # ]: 0 : const SwTxtNode * pTxtNd = rOutlineNodes[ nIndex ]->GetTxtNode();
1037 [ # # ]: 0 : SwNumberTree::tNumberVector aNumVector = pTxtNd->GetNumberVector();
1038 [ # # ][ # # ]: 0 : if( pOutlRule && pTxtNd->GetNumRule())
[ # # ][ # # ]
1039 [ # # ]: 0 : for( sal_Int8 nLevel = 0;
1040 [ # # ]: 0 : nLevel <= pTxtNd->GetActualListLevel();
1041 : : nLevel++ )
1042 : : {
1043 [ # # ]: 0 : long nVal = aNumVector[nLevel];
1044 : 0 : nVal ++;
1045 [ # # ]: 0 : nVal -= pOutlRule->Get(nLevel).GetStart();
1046 [ # # ][ # # ]: 0 : sEntry += String::CreateFromInt32( nVal );
[ # # ]
1047 [ # # ]: 0 : sEntry += '.';
1048 : : }
1049 [ # # ]: 0 : sEntry += rOutlineNodes[ nIndex ]->
1050 [ # # ][ # # ]: 0 : GetTxtNode()->GetExpandTxt( 0, STRING_LEN, sal_False );
[ # # ]
1051 : 0 : return sEntry;
1052 : : }
1053 : :
1054 : 0 : void SwXTextDocument::setPagePrintSettings(const Sequence< beans::PropertyValue >& aSettings)
1055 : : throw( RuntimeException )
1056 : : {
1057 [ # # ]: 0 : SolarMutexGuard aGuard;
1058 [ # # ]: 0 : if(IsValid())
1059 : : {
1060 : 0 : SwPagePreViewPrtData aData;
1061 : : //falls nur einige Properties kommen, dann die akt. Einstellungen benutzen
1062 : 0 : const SwPagePreViewPrtData* pData = pDocShell->GetDoc()->GetPreViewPrtData();
1063 [ # # ]: 0 : if(pData)
1064 : 0 : aData = *pData;
1065 : 0 : const beans::PropertyValue* pProperties = aSettings.getConstArray();
1066 : 0 : int nCount = aSettings.getLength();
1067 [ # # ]: 0 : for(int i = 0; i < nCount; i++)
1068 : : {
1069 [ # # ]: 0 : String sName = pProperties[i].Name;
1070 : 0 : const Any& rVal = pProperties[i].Value;
1071 : : sal_Bool bException;
1072 : 0 : sal_uInt32 nVal = lcl_Any_To_ULONG(rVal, bException);
1073 [ # # ][ # # ]: 0 : if( COMPARE_EQUAL == sName.CompareToAscii("PageRows" ) )
1074 : : {
1075 [ # # ][ # # ]: 0 : if(!nVal || nVal > 0xff)
1076 [ # # ]: 0 : throw RuntimeException();
1077 : 0 : aData.SetRow((sal_uInt8)nVal);
1078 : : }
1079 [ # # ][ # # ]: 0 : else if(COMPARE_EQUAL == sName.CompareToAscii("PageColumns"))
1080 : : {
1081 [ # # ][ # # ]: 0 : if(!nVal || nVal > 0xff)
1082 [ # # ]: 0 : throw RuntimeException();
1083 : 0 : aData.SetCol((sal_uInt8)nVal);
1084 : : }
1085 [ # # ][ # # ]: 0 : else if(COMPARE_EQUAL == sName.CompareToAscii("LeftMargin"))
1086 : : {
1087 : 0 : aData.SetLeftSpace(MM100_TO_TWIP_UNSIGNED(nVal));
1088 : : }
1089 [ # # ][ # # ]: 0 : else if(COMPARE_EQUAL == sName.CompareToAscii("RightMargin"))
1090 : : {
1091 : 0 : aData.SetRightSpace(MM100_TO_TWIP_UNSIGNED(nVal));
1092 : : }
1093 [ # # ][ # # ]: 0 : else if(COMPARE_EQUAL == sName.CompareToAscii("TopMargin"))
1094 : : {
1095 : 0 : aData.SetTopSpace(MM100_TO_TWIP_UNSIGNED(nVal));
1096 : : }
1097 [ # # ][ # # ]: 0 : else if(COMPARE_EQUAL == sName.CompareToAscii("BottomMargin"))
1098 : : {
1099 : 0 : aData.SetBottomSpace(MM100_TO_TWIP_UNSIGNED(nVal));
1100 : : }
1101 [ # # ][ # # ]: 0 : else if(COMPARE_EQUAL == sName.CompareToAscii("HoriMargin"))
1102 : : {
1103 : 0 : aData.SetHorzSpace(MM100_TO_TWIP_UNSIGNED(nVal));
1104 : : }
1105 [ # # ][ # # ]: 0 : else if(COMPARE_EQUAL == sName.CompareToAscii("VertMargin"))
1106 : : {
1107 : 0 : aData.SetVertSpace(MM100_TO_TWIP_UNSIGNED(nVal));
1108 : : }
1109 [ # # ][ # # ]: 0 : else if(COMPARE_EQUAL == sName.CompareToAscii("IsLandscape"))
1110 : : {
1111 [ # # ]: 0 : bException = (::getBooleanCppuType() != rVal.getValueType());
1112 : 0 : aData.SetLandscape(*(sal_Bool*)rVal.getValue());
1113 : : }
1114 : : else
1115 : 0 : bException = sal_True;
1116 [ # # ]: 0 : if(bException)
1117 [ # # ]: 0 : throw RuntimeException();
1118 [ # # ]: 0 : }
1119 [ # # ]: 0 : pDocShell->GetDoc()->SetPreViewPrtData(&aData);
1120 : : }
1121 : : else
1122 [ # # ][ # # ]: 0 : throw RuntimeException();
1123 : 0 : }
1124 : :
1125 : 0 : void SwXTextDocument::printPages(const Sequence< beans::PropertyValue >& xOptions)
1126 : : throw( IllegalArgumentException, RuntimeException )
1127 : : {
1128 [ # # ]: 0 : SolarMutexGuard aGuard;
1129 [ # # ]: 0 : if(IsValid())
1130 : : {
1131 [ # # ]: 0 : SfxViewFrame* pFrame = SfxViewFrame::LoadHiddenDocument( *pDocShell, 7 );
1132 : : SfxRequest aReq(FN_PRINT_PAGEPREVIEW, SFX_CALLMODE_SYNCHRON,
1133 [ # # ]: 0 : pDocShell->GetDoc()->GetAttrPool());
1134 [ # # ][ # # ]: 0 : aReq.AppendItem(SfxBoolItem(FN_PRINT_PAGEPREVIEW, sal_True));
[ # # ]
1135 : :
1136 [ # # ]: 0 : OUString sFileName(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_FILE_NAME)));
1137 [ # # ]: 0 : OUString sCopyCount(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_COPY_COUNT)));
1138 [ # # ]: 0 : OUString sCollate(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_COLLATE)));
1139 [ # # ]: 0 : OUString sSort(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_SORT)));
1140 [ # # ]: 0 : OUString sPages(OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_PAGES)));
1141 : :
1142 [ # # ]: 0 : for ( int n = 0; n < xOptions.getLength(); ++n )
1143 : : {
1144 : : // get Property-Value from options
1145 : 0 : const beans::PropertyValue &rProp = xOptions.getConstArray()[n];
1146 : 0 : Any aValue( rProp.Value );
1147 : :
1148 : : // FileName-Property?
1149 [ # # ]: 0 : if ( rProp.Name == sFileName )
1150 : : {
1151 : 0 : OUString sFileURL;
1152 [ # # ]: 0 : if ( (rProp.Value >>= sFileURL ) )
1153 : : {
1154 : : // Convert the File URL into a system dependant path, as the SalPrinter expects
1155 : 0 : OUString sSystemPath;
1156 [ # # ]: 0 : FileBase::getSystemPathFromFileURL ( sFileURL, sSystemPath );
1157 [ # # ][ # # ]: 0 : aReq.AppendItem(SfxStringItem( SID_FILE_NAME, sSystemPath ) );
[ # # ][ # # ]
[ # # ]
1158 : : }
1159 [ # # ][ # # ]: 0 : else if ( rProp.Value.getValueType() != ::getVoidCppuType() )
1160 [ # # ]: 0 : throw IllegalArgumentException();
1161 : : }
1162 : :
1163 : : // CopyCount-Property
1164 [ # # ]: 0 : else if ( rProp.Name == sCopyCount )
1165 : : {
1166 : 0 : sal_Int32 nCopies = 0;
1167 : 0 : aValue >>= nCopies;
1168 [ # # ][ # # ]: 0 : aReq.AppendItem(SfxInt16Item( SID_PRINT_COPIES, (sal_Int16)nCopies ) );
[ # # ]
1169 : : }
1170 : :
1171 : : // Collate-Property
1172 [ # # ]: 0 : else if ( rProp.Name == sCollate )
1173 : : {
1174 [ # # ][ # # ]: 0 : if ( rProp.Value.getValueType() == ::getBooleanCppuType())
1175 : :
1176 [ # # ][ # # ]: 0 : aReq.AppendItem(SfxBoolItem( SID_PRINT_COLLATE, *(sal_Bool*)rProp.Value.getValue() ) );
[ # # ]
1177 : : else
1178 [ # # ]: 0 : throw IllegalArgumentException();
1179 : : }
1180 : :
1181 : : // Sort-Property
1182 [ # # ]: 0 : else if ( rProp.Name == sSort )
1183 : : {
1184 [ # # ][ # # ]: 0 : if ( rProp.Value.getValueType() == ::getBooleanCppuType() )
1185 [ # # ][ # # ]: 0 : aReq.AppendItem(SfxBoolItem( SID_PRINT_SORT, *(sal_Bool*)rProp.Value.getValue() ) );
[ # # ]
1186 : : else
1187 [ # # ]: 0 : throw IllegalArgumentException();
1188 : : }
1189 : :
1190 : : // Pages-Property
1191 [ # # ]: 0 : else if ( rProp.Name == sPages )
1192 : : {
1193 : 0 : OUString sTmp;
1194 [ # # ]: 0 : if ( rProp.Value >>= sTmp )
1195 [ # # ][ # # ]: 0 : aReq.AppendItem( SfxStringItem( SID_PRINT_PAGES, sTmp ) );
[ # # ][ # # ]
[ # # ]
1196 : : else
1197 [ # # ]: 0 : throw IllegalArgumentException();
1198 : : }
1199 : 0 : }
1200 : :
1201 : :
1202 [ # # ][ # # ]: 0 : pFrame->GetViewShell()->ExecuteSlot(aReq);
1203 : : // Frame schliessen
1204 [ # # ][ # # ]: 0 : pFrame->DoClose();
1205 : :
1206 : : }
1207 : : else
1208 [ # # ][ # # ]: 0 : throw RuntimeException();
1209 : 0 : }
1210 : :
1211 : 4 : Reference< XNameAccess > SwXTextDocument::getReferenceMarks(void)
1212 : : throw( RuntimeException )
1213 : : {
1214 [ + - ]: 4 : SolarMutexGuard aGuard;
1215 [ - + ]: 4 : if(!IsValid())
1216 [ # # ]: 0 : throw RuntimeException();
1217 [ + - ]: 4 : if(!pxXReferenceMarks)
1218 : : {
1219 : 4 : ((SwXTextDocument*)this)->pxXReferenceMarks = new Reference< XNameAccess > ;
1220 [ + - ][ + - ]: 4 : *pxXReferenceMarks = new SwXReferenceMarks(pDocShell->GetDoc());
[ + - ]
1221 : : }
1222 [ + - ]: 4 : return *pxXReferenceMarks;
1223 : : }
1224 : :
1225 : 563 : Reference< XEnumerationAccess > SwXTextDocument::getTextFields(void) throw( RuntimeException )
1226 : : {
1227 [ + - ]: 563 : SolarMutexGuard aGuard;
1228 [ - + ]: 563 : if(!IsValid())
1229 [ # # ]: 0 : throw RuntimeException();
1230 [ + + ]: 563 : if(!pxXTextFieldTypes)
1231 : : {
1232 : 508 : ((SwXTextDocument*)this)->pxXTextFieldTypes = new Reference< XEnumerationAccess > ;
1233 [ + - ][ + - ]: 508 : *pxXTextFieldTypes = new SwXTextFieldTypes(pDocShell->GetDoc());
[ + - ]
1234 : : }
1235 [ + - ]: 563 : return *pxXTextFieldTypes;
1236 : : }
1237 : :
1238 : 362 : Reference< XNameAccess > SwXTextDocument::getTextFieldMasters(void)
1239 : : throw( RuntimeException )
1240 : : {
1241 [ + - ]: 362 : SolarMutexGuard aGuard;
1242 [ - + ]: 362 : if(!IsValid())
1243 [ # # ]: 0 : throw RuntimeException();
1244 [ + + ]: 362 : if(!pxXTextFieldMasters)
1245 : : {
1246 : 80 : ((SwXTextDocument*)this)->pxXTextFieldMasters = new Reference< XNameAccess > ;
1247 [ + - ][ + - ]: 80 : *pxXTextFieldMasters = new SwXTextFieldMasters(pDocShell->GetDoc());
[ + - ]
1248 : : }
1249 [ + - ]: 362 : return *pxXTextFieldMasters;
1250 : : }
1251 : :
1252 : 304 : Reference< XNameAccess > SwXTextDocument::getEmbeddedObjects(void) throw( RuntimeException )
1253 : : {
1254 [ + - ]: 304 : SolarMutexGuard aGuard;
1255 [ - + ]: 304 : if(!IsValid())
1256 [ # # ]: 0 : throw RuntimeException();
1257 [ + + ]: 304 : if(!pxXEmbeddedObjects)
1258 : : {
1259 : 81 : ((SwXTextDocument*)this)->pxXEmbeddedObjects = new Reference< XNameAccess > ;
1260 [ + - ][ + - ]: 81 : *pxXEmbeddedObjects = new SwXTextEmbeddedObjects(pDocShell->GetDoc());
[ + - ]
1261 : : }
1262 [ + - ]: 304 : return *pxXEmbeddedObjects;
1263 : : }
1264 : :
1265 : 28 : Reference< XNameAccess > SwXTextDocument::getBookmarks(void) throw( RuntimeException )
1266 : : {
1267 [ + - ]: 28 : SolarMutexGuard aGuard;
1268 [ - + ]: 28 : if(!IsValid())
1269 [ # # ]: 0 : throw RuntimeException();
1270 [ + + ]: 28 : if(!pxXBookmarks)
1271 : : {
1272 : 16 : ((SwXTextDocument*)this)->pxXBookmarks = new Reference< XNameAccess > ;
1273 [ + - ][ + - ]: 16 : *pxXBookmarks = new SwXBookmarks(pDocShell->GetDoc());
[ + - ]
1274 : : }
1275 [ + - ]: 28 : return *pxXBookmarks;
1276 : : }
1277 : :
1278 : 43 : Reference< XNameAccess > SwXTextDocument::getTextSections(void) throw( RuntimeException )
1279 : : {
1280 [ + - ]: 43 : SolarMutexGuard aGuard;
1281 [ - + ]: 43 : if(!IsValid())
1282 [ # # ]: 0 : throw RuntimeException();
1283 [ + + ]: 43 : if(!pxXTextSections)
1284 : : {
1285 : 37 : ((SwXTextDocument*)this)->pxXTextSections = new Reference< XNameAccess > ;
1286 [ + - ][ + - ]: 37 : *pxXTextSections = new SwXTextSections(pDocShell->GetDoc());
[ + - ]
1287 : : }
1288 [ + - ]: 43 : return *pxXTextSections;
1289 : : }
1290 : :
1291 : 127 : Reference< XNameAccess > SwXTextDocument::getTextTables(void) throw( RuntimeException )
1292 : : {
1293 [ + - ]: 127 : SolarMutexGuard aGuard;
1294 [ - + ]: 127 : if(!IsValid())
1295 [ # # ]: 0 : throw RuntimeException();
1296 [ + + ]: 127 : if(!pxXTextTables)
1297 : : {
1298 : 87 : ((SwXTextDocument*)this)->pxXTextTables = new Reference< XNameAccess > ;
1299 [ + - ][ + - ]: 87 : *pxXTextTables = new SwXTextTables(pDocShell->GetDoc());
[ + - ]
1300 : : }
1301 [ + - ]: 127 : return *pxXTextTables;
1302 : : }
1303 : :
1304 : 305 : Reference< XNameAccess > SwXTextDocument::getGraphicObjects(void) throw( RuntimeException )
1305 : : {
1306 [ + - ]: 305 : SolarMutexGuard aGuard;
1307 [ - + ]: 305 : if(!IsValid())
1308 [ # # ]: 0 : throw RuntimeException();
1309 [ + + ]: 305 : if(!pxXGraphicObjects)
1310 : : {
1311 : 82 : ((SwXTextDocument*)this)->pxXGraphicObjects = new Reference< XNameAccess > ;
1312 [ + - ][ + - ]: 82 : *pxXGraphicObjects = new SwXTextGraphicObjects(pDocShell->GetDoc());
[ + - ]
1313 : : }
1314 [ + - ]: 305 : return *pxXGraphicObjects;
1315 : : }
1316 : :
1317 : 330 : Reference< XNameAccess > SwXTextDocument::getTextFrames(void) throw( RuntimeException )
1318 : : {
1319 [ + - ]: 330 : SolarMutexGuard aGuard;
1320 [ - + ]: 330 : if(!IsValid())
1321 [ # # ]: 0 : throw RuntimeException();
1322 [ + + ]: 330 : if(!pxXTextFrames)
1323 : : {
1324 : 103 : ((SwXTextDocument*)this)->pxXTextFrames = new Reference< XNameAccess > ;
1325 [ + - ][ + - ]: 103 : *pxXTextFrames = new SwXTextFrames(pDocShell->GetDoc());
[ + - ]
1326 : : }
1327 [ + - ]: 330 : return *pxXTextFrames;
1328 : : }
1329 : :
1330 : 3486 : Reference< XNameAccess > SwXTextDocument::getStyleFamilies(void) throw( RuntimeException )
1331 : : {
1332 [ + - ]: 3486 : SolarMutexGuard aGuard;
1333 [ - + ]: 3486 : if(!IsValid())
1334 [ # # ]: 0 : throw RuntimeException();
1335 [ + + ]: 3486 : if(!pxXStyleFamilies)
1336 : : {
1337 : 1278 : ((SwXTextDocument*)this)->pxXStyleFamilies = new Reference< XNameAccess > ;
1338 [ + - ][ + - ]: 1278 : *pxXStyleFamilies = new SwXStyleFamilies(*pDocShell);
[ + - ]
1339 : : }
1340 [ + - ]: 3486 : return *pxXStyleFamilies;
1341 : : }
1342 : :
1343 : 68 : uno::Reference< style::XAutoStyles > SwXTextDocument::getAutoStyles( )
1344 : : throw (uno::RuntimeException)
1345 : : {
1346 [ + - ]: 68 : SolarMutexGuard aGuard;
1347 [ - + ]: 68 : if(!IsValid())
1348 [ # # ]: 0 : throw RuntimeException();
1349 [ + + ]: 68 : if(!pxXAutoStyles)
1350 : : {
1351 : 48 : pxXAutoStyles = new Reference< style::XAutoStyles > ;
1352 [ + - ][ + - ]: 48 : *pxXAutoStyles = new SwXAutoStyles(*pDocShell);
[ + - ]
1353 : : }
1354 [ + - ]: 68 : return *pxXAutoStyles;
1355 : :
1356 : : }
1357 : :
1358 : 2907 : Reference< drawing::XDrawPage > SwXTextDocument::getDrawPage(void) throw( RuntimeException )
1359 : : {
1360 [ + - ]: 2907 : SolarMutexGuard aGuard;
1361 [ - + ]: 2907 : if(!IsValid())
1362 [ # # ]: 0 : throw RuntimeException();
1363 [ + + ]: 2907 : if(!pxXDrawPage)
1364 : : {
1365 [ + - ]: 1302 : ((SwXTextDocument*)this)->pDrawPage = new SwXDrawPage(pDocShell->GetDoc());
1366 [ + - ][ + - ]: 1302 : ((SwXTextDocument*)this)->pxXDrawPage = new Reference< drawing::XDrawPage >(pDrawPage);
1367 : : // Create a Reference to trigger the complete initialization of the
1368 : : // object. Otherwise in some corner cases it would get initialized
1369 : : // at ::InitNewDoc -> which would get called during
1370 : : // close() or dispose() -> n#681746
1371 [ + - ]: 1302 : uno::Reference<lang::XComponent> xComp( *pxXDrawPage, uno::UNO_QUERY );
1372 : : }
1373 [ + - ]: 2907 : return *pxXDrawPage;
1374 : : }
1375 : :
1376 : 0 : SwXDrawPage* SwXTextDocument::GetDrawPage()
1377 : : {
1378 [ # # ]: 0 : if(!IsValid())
1379 : 0 : return 0;
1380 [ # # ]: 0 : if(!pDrawPage)
1381 : 0 : getDrawPage();
1382 : 0 : return pDrawPage;
1383 : : }
1384 : :
1385 : 1457 : void SwXTextDocument::Invalidate()
1386 : : {
1387 : 1457 : bObjectValid = sal_False;
1388 [ + + ]: 1457 : if(xNumFmtAgg.is())
1389 : : {
1390 [ + - ]: 1231 : const uno::Type& rTunnelType = ::getCppuType((Reference <XUnoTunnel>*)0);
1391 [ + - ][ + - ]: 1231 : Any aNumTunnel = xNumFmtAgg->queryAggregation(rTunnelType);
1392 : 1231 : SvNumberFormatsSupplierObj* pNumFmt = 0;
1393 : 1231 : Reference< XUnoTunnel > xNumTunnel;
1394 [ + - ][ + - ]: 1231 : if(aNumTunnel >>= xNumTunnel)
1395 : : {
1396 : : pNumFmt = reinterpret_cast<SvNumberFormatsSupplierObj*>(
1397 [ + - ][ + - ]: 1231 : xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
[ + - ]
1398 [ + - ]: 1231 : pNumFmt->SetNumberFormatter(0);
1399 : : }
1400 : 1231 : OSL_ENSURE(pNumFmt, "No number formatter available");
1401 : : }
1402 : 1457 : InitNewDoc();
1403 : 1457 : pDocShell = 0;
1404 : 1457 : aRefreshCont.Disposing();
1405 : 1457 : }
1406 : :
1407 : 1569 : void SwXTextDocument::Reactivate(SwDocShell* pNewDocShell)
1408 : : {
1409 [ + + ][ - + ]: 1569 : if(pDocShell && pDocShell != pNewDocShell)
1410 : 0 : Invalidate();
1411 : 1569 : pDocShell = pNewDocShell;
1412 : 1569 : bObjectValid = sal_True;
1413 : 1569 : }
1414 : :
1415 : 2619 : void SwXTextDocument::InitNewDoc()
1416 : : {
1417 : : // zunaechst alle Collections invalidieren, dann Referenzen loeschen und Null setzen
1418 [ + + ]: 2619 : if(pxXTextTables)
1419 : : {
1420 : 87 : XNameAccess* pTbls = pxXTextTables->get();
1421 [ + - ][ + - ]: 87 : ((SwXTextTables*)pTbls)->Invalidate();
[ + - ]
1422 [ + - ]: 87 : delete pxXTextTables;
1423 : 87 : pxXTextTables = 0;
1424 : : }
1425 : :
1426 [ + + ]: 2619 : if(pxXTextFrames)
1427 : : {
1428 : 91 : XNameAccess* pFrms = pxXTextFrames->get();
1429 [ + - ][ + - ]: 91 : ((SwXTextFrames*)pFrms)->Invalidate();
[ + - ]
1430 [ + - ]: 91 : delete pxXTextFrames;
1431 : 91 : pxXTextFrames = 0;
1432 : : }
1433 : :
1434 [ + + ]: 2619 : if(pxXGraphicObjects)
1435 : : {
1436 : 70 : XNameAccess* pFrms = pxXGraphicObjects->get();
1437 [ + - ][ + - ]: 70 : ((SwXTextGraphicObjects*)pFrms)->Invalidate();
[ + - ]
1438 [ + - ]: 70 : delete pxXGraphicObjects;
1439 : 70 : pxXGraphicObjects = 0;
1440 : : }
1441 : :
1442 [ + + ]: 2619 : if(pxXEmbeddedObjects)
1443 : : {
1444 : 69 : XNameAccess* pOLE = pxXEmbeddedObjects->get();
1445 [ + - ][ + - ]: 69 : ((SwXTextEmbeddedObjects*)pOLE)->Invalidate();
[ + - ]
1446 [ + - ]: 69 : delete pxXEmbeddedObjects;
1447 : 69 : pxXEmbeddedObjects = 0;
1448 : : }
1449 : :
1450 [ + + ]: 2619 : if(xBodyText.is())
1451 : : {
1452 : 805 : xBodyText = 0;
1453 : 805 : pBodyText = 0;
1454 : : }
1455 : :
1456 [ + + ]: 2619 : if(xNumFmtAgg.is())
1457 : : {
1458 [ + - ]: 2255 : const uno::Type& rTunnelType = ::getCppuType((Reference <XUnoTunnel>*)0);
1459 [ + - ][ + - ]: 2255 : Any aNumTunnel = xNumFmtAgg->queryAggregation(rTunnelType);
1460 : 2255 : SvNumberFormatsSupplierObj* pNumFmt = 0;
1461 : 2255 : Reference< XUnoTunnel > xNumTunnel;
1462 [ + - ][ + - ]: 2255 : if(aNumTunnel >>= xNumTunnel)
1463 : : {
1464 : : pNumFmt = reinterpret_cast<SvNumberFormatsSupplierObj*>(
1465 [ + - ][ + - ]: 2255 : xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
[ + - ]
1466 : :
1467 : : }
1468 : : OSL_ENSURE(pNumFmt, "No number formatter available");
1469 [ + - ]: 2255 : pNumFmt->SetNumberFormatter(0);
1470 : : }
1471 : :
1472 [ + + ]: 2619 : if(pxXTextFieldTypes)
1473 : : {
1474 : 436 : XEnumerationAccess* pT = pxXTextFieldTypes->get();
1475 [ + - ][ + - ]: 436 : ((SwXTextFieldTypes*)pT)->Invalidate();
[ + - ]
1476 [ + - ]: 436 : delete pxXTextFieldTypes;
1477 : 436 : pxXTextFieldTypes = 0;
1478 : : }
1479 : :
1480 [ + + ]: 2619 : if(pxXTextFieldMasters)
1481 : : {
1482 : 68 : XNameAccess* pT = pxXTextFieldMasters->get();
1483 [ + - ][ + - ]: 68 : ((SwXTextFieldMasters*)pT)->Invalidate();
[ + - ]
1484 [ + - ]: 68 : delete pxXTextFieldMasters;
1485 : 68 : pxXTextFieldMasters = 0;
1486 : : }
1487 : :
1488 [ + + ]: 2619 : if(pxXTextSections)
1489 : : {
1490 : 37 : XNameAccess* pSect = pxXTextSections->get();
1491 [ + - ][ + - ]: 37 : ((SwXTextSections*)pSect)->Invalidate();
[ + - ]
1492 [ + - ]: 37 : delete pxXTextSections;
1493 : 37 : pxXTextSections = 0;
1494 : : }
1495 : :
1496 [ + + ]: 2619 : if(pxXDrawPage)
1497 : : {
1498 : : // #i91798#, #i91895#
1499 : : // dispose XDrawPage here. We are the owner and know that it is no longer in a valid condition.
1500 [ + - ]: 1215 : uno::Reference<lang::XComponent> xComp( *pxXDrawPage, uno::UNO_QUERY );
1501 [ + - ][ + - ]: 1215 : xComp->dispose();
1502 [ + - ]: 1215 : pDrawPage->InvalidateSwDoc();
1503 [ + - ]: 1215 : delete pxXDrawPage;
1504 : 1215 : pxXDrawPage = 0;
1505 : : }
1506 : :
1507 [ + + ]: 2619 : if ( pxXNumberingRules )
1508 : : {
1509 : 22 : XIndexAccess* pNum = pxXNumberingRules->get();
1510 [ + - ][ + - ]: 22 : ((SwXNumberingRulesCollection*)pNum)->Invalidate();
[ + - ]
1511 [ + - ]: 22 : delete pxXNumberingRules;
1512 : 22 : pxXNumberingRules = 0;
1513 : : }
1514 : :
1515 [ + + ]: 2619 : if(pxXFootnotes)
1516 : : {
1517 : 10 : XIndexAccess* pFtn = pxXFootnotes->get();
1518 [ + - ][ + - ]: 10 : ((SwXFootnotes*)pFtn)->Invalidate();
[ + - ]
1519 [ + - ]: 10 : delete pxXFootnotes;
1520 : 10 : pxXFootnotes = 0;
1521 : : }
1522 : :
1523 [ + + ]: 2619 : if(pxXEndnotes)
1524 : : {
1525 : 2 : XIndexAccess* pFtn = pxXEndnotes->get();
1526 [ + - ][ + - ]: 2 : ((SwXFootnotes*)pFtn)->Invalidate();
[ + - ]
1527 [ + - ]: 2 : delete pxXEndnotes;
1528 : 2 : pxXEndnotes = 0;
1529 : : }
1530 : :
1531 [ + + ]: 2619 : if(pxXDocumentIndexes)
1532 : : {
1533 : 409 : XIndexAccess* pIdxs = pxXDocumentIndexes->get();
1534 [ + - ][ + - ]: 409 : ((SwXDocumentIndexes*)pIdxs)->Invalidate();
[ + - ]
1535 [ + - ]: 409 : delete pxXDocumentIndexes;
1536 : 409 : pxXDocumentIndexes = 0;
1537 : : }
1538 : :
1539 [ + + ]: 2619 : if(pxXStyleFamilies)
1540 : : {
1541 : 1194 : XNameAccess* pStyles = pxXStyleFamilies->get();
1542 [ + - ][ + - ]: 1194 : ((SwXStyleFamilies*)pStyles)->Invalidate();
[ + - ]
1543 [ + - ]: 1194 : delete pxXStyleFamilies;
1544 : 1194 : pxXStyleFamilies = 0;
1545 : : }
1546 [ + + ]: 2619 : if(pxXAutoStyles)
1547 : : {
1548 : 36 : XNameAccess* pStyles = pxXAutoStyles->get();
1549 [ + - ][ + - ]: 36 : ((SwXAutoStyles*)pStyles)->Invalidate();
[ + - ]
1550 [ + - ]: 36 : delete pxXAutoStyles;
1551 : 36 : pxXAutoStyles = 0;
1552 : : }
1553 : :
1554 [ + + ]: 2619 : if(pxXBookmarks)
1555 : : {
1556 : 16 : XNameAccess* pBm = pxXBookmarks->get();
1557 [ + - ][ + - ]: 16 : ((SwXBookmarks*)pBm)->Invalidate();
[ + - ]
1558 [ + - ]: 16 : delete pxXBookmarks;
1559 : 16 : pxXBookmarks = 0;
1560 : : }
1561 : :
1562 [ + + ]: 2619 : if(pxXChapterNumbering)
1563 : : {
1564 : 68 : XIndexReplace* pCh = pxXChapterNumbering->get();
1565 [ + - ]: 68 : ((SwXChapterNumbering*)pCh)->Invalidate();
1566 [ + - ]: 68 : delete pxXChapterNumbering;
1567 : 68 : pxXChapterNumbering = 0;
1568 : : }
1569 : :
1570 [ + + ]: 2619 : if(pxXFootnoteSettings)
1571 : : {
1572 : 145 : XPropertySet* pFntSet = pxXFootnoteSettings->get();
1573 [ + - ]: 145 : ((SwXFootnoteProperties*)pFntSet)->Invalidate();
1574 [ + - ]: 145 : delete pxXFootnoteSettings;
1575 : 145 : pxXFootnoteSettings = 0;
1576 : : }
1577 : :
1578 [ + + ]: 2619 : if(pxXEndnoteSettings)
1579 : : {
1580 : 141 : XPropertySet* pEndSet = pxXEndnoteSettings->get();
1581 [ + - ]: 141 : ((SwXEndnoteProperties*)pEndSet)->Invalidate();
1582 [ + - ]: 141 : delete pxXEndnoteSettings;
1583 : 141 : pxXEndnoteSettings = 0;
1584 : : }
1585 : :
1586 [ + + ]: 2619 : if(pxXLineNumberingProperties)
1587 : : {
1588 : 61 : XPropertySet* pLine = pxXLineNumberingProperties->get();
1589 [ + - ]: 61 : ((SwXLineNumberingProperties*)pLine)->Invalidate();
1590 [ + - ]: 61 : delete pxXLineNumberingProperties;
1591 : 61 : pxXLineNumberingProperties = 0;
1592 : : }
1593 [ + + ]: 2619 : if(pxXReferenceMarks)
1594 : : {
1595 : 4 : XNameAccess* pMarks = pxXReferenceMarks->get();
1596 [ + - ][ + - ]: 4 : ((SwXReferenceMarks*)pMarks)->Invalidate();
[ + - ]
1597 [ + - ]: 4 : delete pxXReferenceMarks;
1598 : 4 : pxXReferenceMarks = 0;
1599 : : }
1600 [ - + ]: 2619 : if(pxLinkTargetSupplier)
1601 : : {
1602 : 0 : XNameAccess* pAccess = (*pxLinkTargetSupplier).get();
1603 [ # # ]: 0 : ((SwXLinkTargetSupplier*)pAccess)->Invalidate();
1604 [ # # ]: 0 : delete pxLinkTargetSupplier;
1605 : 0 : pxLinkTargetSupplier = 0;
1606 : : }
1607 [ + + ]: 2619 : if(pxXRedlines)
1608 : : {
1609 : 19 : XEnumerationAccess* pMarks = pxXRedlines->get();
1610 [ + - ][ + - ]: 19 : ((SwXRedlines*)pMarks)->Invalidate();
[ + - ]
1611 [ + - ]: 19 : delete pxXRedlines;
1612 : 19 : pxXRedlines = 0;
1613 : : }
1614 [ + + ]: 2619 : if(xPropertyHelper.is())
1615 : : {
1616 : 68 : pPropertyHelper->Invalidate();
1617 : 68 : xPropertyHelper = 0;
1618 : 68 : pPropertyHelper = 0;
1619 : : }
1620 : 2619 : }
1621 : :
1622 : : #define COM_SUN_STAR__DRAWING_LENGTH 13
1623 : 9740 : Reference< XInterface > SwXTextDocument::createInstance(const OUString& rServiceName)
1624 : : throw( Exception, RuntimeException )
1625 : : {
1626 [ + - ]: 9740 : SolarMutexGuard aGuard;
1627 [ - + ]: 9740 : if(!IsValid())
1628 [ # # ]: 0 : throw RuntimeException();
1629 : 9740 : Reference< XInterface > xRet;
1630 [ + - ]: 9740 : sal_uInt16 nType = SwXServiceProvider::GetProviderType(rServiceName);
1631 [ + + ]: 9740 : if(nType != SW_SERVICE_INVALID)
1632 : : {
1633 [ + - ][ + - ]: 7550 : xRet = SwXServiceProvider::MakeInstance(nType, pDocShell->GetDoc());
1634 : : }
1635 : : else
1636 : : {
1637 [ + - ]: 2190 : if( rServiceName.compareToAscii( "com.sun.star.", 13 ) == 0 )
1638 : : {
1639 : 2190 : sal_Int32 nIndex = COM_SUN_STAR__DRAWING_LENGTH;
1640 : 2190 : OUString sCategory = rServiceName.getToken( 0, '.', nIndex );
1641 [ + - ]: 2190 : sal_Bool bShape = sCategory == C2U("drawing");
1642 [ + - ][ + + ]: 2190 : if( bShape || sCategory == C2U("form"))
[ + + ]
[ + + # # ]
[ + + ]
1643 : : {
1644 [ + + ]: 1279 : if(bShape)
1645 : : {
1646 : 820 : short nTable = 0;
1647 [ + + ]: 820 : if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.DashTable") ) )
1648 : 21 : nTable = SW_CREATE_DASH_TABLE;
1649 [ + + ]: 799 : else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GradientTable") ) )
1650 : 21 : nTable = SW_CREATE_GRADIENT_TABLE;
1651 [ + + ]: 778 : else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.HatchTable") ) )
1652 : 24 : nTable = SW_CREATE_HATCH_TABLE;
1653 [ + + ]: 754 : else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.BitmapTable") ) )
1654 : 21 : nTable = SW_CREATE_BITMAP_TABLE;
1655 [ + + ]: 733 : else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) )
1656 : 21 : nTable = SW_CREATE_TRANSGRADIENT_TABLE;
1657 [ + + ]: 712 : else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MarkerTable") ) )
1658 : 27 : nTable = SW_CREATE_MARKER_TABLE;
1659 [ + + ]: 685 : else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Defaults") ) )
1660 : 84 : nTable = SW_CREATE_DRAW_DEFAULTS;
1661 [ + + ]: 820 : if(nTable)
1662 : : {
1663 [ + - ][ + - ]: 219 : xRet = GetPropertyHelper()->GetDrawTable(nTable);
[ + - ]
1664 : : }
1665 : : }
1666 : : }
1667 [ + - ][ + + ]: 911 : else if (sCategory == C2U ("document") )
1668 : : {
1669 [ + + ]: 811 : if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.Settings") ) )
1670 [ + - ][ + - ]: 746 : xRet = Reference < XInterface > ( *new SwXDocumentSettings ( this ) );
[ + - ]
1671 [ - + ]: 811 : if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ImportEmbeddedObjectResolver") ) )
1672 : : {
1673 [ # # ][ # # ]: 0 : xRet = (::cppu::OWeakObject * )new SvXMLEmbeddedObjectHelper( *pDocShell, EMBEDDEDOBJECTHELPER_MODE_READ );
1674 : : }
1675 : : }
1676 [ + - ][ + + ]: 100 : else if (sCategory == C2U ("text") )
1677 : : {
1678 [ + - ]: 2 : if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.DocumentSettings") ) )
1679 [ + - ][ + - ]: 2 : xRet = Reference < XInterface > ( *new SwXDocumentSettings ( this ) );
[ + - ]
1680 : : }
1681 [ + - ][ - + ]: 98 : else if (sCategory == C2U ("chart2") )
1682 : : {
1683 [ # # ]: 0 : if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.data.DataProvider") ) )
1684 [ # # ][ # # ]: 0 : xRet = Reference < XInterface > ( dynamic_cast< chart2::data::XDataProvider * >(pDocShell->getIDocumentChartDataProviderAccess()->GetChartDataProvider()) );
[ # # ][ # # ]
[ # # ]
1685 : : }
1686 : :
1687 [ + + ]: 2190 : if(!xRet.is())
1688 : : {
1689 : : //! we don't want to insert OLE2 Shapes (e.g. "com.sun.star.drawing.OLE2Shape", ...)
1690 : : //! like this (by creating them with the documents factory and
1691 : : //! adding the shapes to the draw page).
1692 : : //! For inserting OLE objects the proper way is to use
1693 : : //! "com.sun.star.text.TextEmbeddedObject"!
1694 [ + - ][ - + ]: 1223 : if (rServiceName.lastIndexOf( C2U(".OLE2Shape") ) == rServiceName.getLength() - 10)
1695 [ # # ]: 0 : throw ServiceNotRegisteredException(); // declare service to be not registered with this factory
1696 : :
1697 : : //
1698 : : // the XML import is allowed to create instances of com.sun.star.drawing.OLE2Shape.
1699 : : // Thus, a temporary service name is introduced to make this possible.
1700 : 1223 : OUString aTmpServiceName( rServiceName );
1701 [ - + ]: 1824 : if ( bShape &&
[ + + - + ]
1702 : 601 : rServiceName.compareToAscii( "com.sun.star.drawing.temporaryForXMLImportOLE2Shape" ) == 0 )
1703 : : {
1704 [ # # ]: 0 : aTmpServiceName = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.OLE2Shape"));
1705 : : }
1706 : : //hier den Draw - Service suchen
1707 [ + + ]: 1223 : Reference< XInterface > xTmp = SvxFmMSFactory::createInstance(aTmpServiceName);
1708 [ + + ]: 1060 : if(bShape)
1709 : : {
1710 : 601 : nIndex = COM_SUN_STAR__DRAWING_LENGTH;
1711 [ + + - + ]: 1193 : if( 0 == rServiceName.reverseCompareToAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.drawing.GroupShape" ) ) ||
[ + + ]
1712 : 592 : 0 == rServiceName.reverseCompareToAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.drawing.Shape3DSceneObject" ) ) )
1713 [ + - ][ + - ]: 9 : xRet = *new SwXGroupShape( xTmp );
[ + - ]
1714 : : else
1715 [ + - ][ + - ]: 592 : xRet = *new SwXShape( xTmp );
[ + - ]
1716 : : }
1717 : : else
1718 [ + - ]: 1223 : xRet = xTmp;
1719 : 2190 : }
1720 : : }
1721 : : else
1722 [ # # ]: 0 : throw ServiceNotRegisteredException();
1723 : : }
1724 [ + - ]: 9740 : return xRet;
1725 : : }
1726 : :
1727 : 0 : Reference< XInterface > SwXTextDocument::createInstanceWithArguments(
1728 : : const OUString& ServiceSpecifier,
1729 : : const Sequence< Any >& /*Arguments*/)
1730 : : throw( Exception, RuntimeException )
1731 : : {
1732 : 0 : Reference< XInterface > xInt = createInstance(ServiceSpecifier);
1733 : : //die Any-Sequence dient zur Initialisierung von Objekten, die auf
1734 : : //Parameter zwingend angewiesen sind - bis jetzt haben wir das nicht
1735 : 0 : return xInt;
1736 : : }
1737 : :
1738 : 46 : Sequence< OUString > SwXTextDocument::getAvailableServiceNames(void)
1739 : : throw( RuntimeException )
1740 : : {
1741 [ + + ][ + - ]: 46 : static Sequence< OUString > aServices;
[ + - ][ # # ]
1742 [ + + ]: 46 : if ( aServices.getLength() == 0 )
1743 : : {
1744 [ + - ]: 15 : Sequence< OUString > aRet = SvxFmMSFactory::getAvailableServiceNames();
1745 [ + - ]: 15 : OUString* pRet = aRet.getArray();
1746 [ + - ]: 420 : for ( sal_Int32 i = 0; i < aRet.getLength(); ++i )
1747 : : {
1748 [ + + ]: 420 : if ( pRet[i].compareToAscii( "com.sun.star.drawing.OLE2Shape" ) == 0 )
1749 : : {
1750 : 15 : pRet[i] = pRet[aRet.getLength() - 1];
1751 [ + - ]: 15 : aRet.realloc( aRet.getLength() - 1 ); // <pRet> no longer valid.
1752 : 15 : break;
1753 : : }
1754 : : }
1755 [ + - ]: 15 : Sequence< OUString > aOwn = SwXServiceProvider::GetAllServiceNames();
1756 [ + - ][ + - ]: 15 : aServices = SvxFmMSFactory::concatServiceNames(aRet, aOwn);
[ + - ][ + - ]
1757 : : }
1758 : :
1759 : 46 : return aServices;
1760 : : }
1761 : :
1762 : 0 : OUString SwXTextDocument::getImplementationName(void) throw( RuntimeException )
1763 : : {
1764 : 0 : return C2U("SwXTextDocument");
1765 : : }
1766 : :
1767 : 1758 : sal_Bool SwXTextDocument::supportsService(const OUString& rServiceName) throw( RuntimeException )
1768 : : {
1769 [ + + ][ + + ]: 1758 : if ( rServiceName == "com.sun.star.document.OfficeDocument" || rServiceName == "com.sun.star.text.GenericTextDocument" )
[ + + ]
1770 : 848 : return sal_True;
1771 : :
1772 [ + - ][ + + ]: 910 : sal_Bool bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell));
[ + - ]
1773 [ + - ][ - + ]: 910 : sal_Bool bGlobalDoc = (0 != PTR_CAST(SwGlobalDocShell, pDocShell));
[ # # ]
1774 [ + + ][ + - ]: 910 : sal_Bool bTextDoc = (!bWebDoc && !bGlobalDoc);
1775 : :
1776 : 8 : return ( (bWebDoc && rServiceName == "com.sun.star.text.WebDocument")
1777 : 0 : || (bGlobalDoc && rServiceName == "com.sun.star.text.GlobalDocument")
1778 [ + + + - ]: 1766 : || (bTextDoc && rServiceName == "com.sun.star.text.TextDocument") );
[ - + # # ]
[ + + ][ + + ]
1779 : : }
1780 : :
1781 : 1416 : Sequence< OUString > SwXTextDocument::getSupportedServiceNames(void) throw( RuntimeException )
1782 : : {
1783 [ + - ][ + + ]: 1416 : sal_Bool bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell));
[ + - ]
1784 [ + - ][ - + ]: 1416 : sal_Bool bGlobalDoc = (0 != PTR_CAST(SwGlobalDocShell, pDocShell));
[ # # ]
1785 [ + + ][ + - ]: 1416 : sal_Bool bTextDoc = (!bWebDoc && !bGlobalDoc);
1786 : :
1787 : 1416 : Sequence< OUString > aRet (3);
1788 [ + - ]: 1416 : OUString* pArray = aRet.getArray();
1789 : :
1790 [ + - ]: 1416 : pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.document.OfficeDocument" ) ) );
1791 [ + - ]: 1416 : pArray[1] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.text.GenericTextDocument" ) ) );
1792 : :
1793 [ + + ]: 1416 : if (bTextDoc)
1794 [ + - ]: 1412 : pArray[2] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.text.TextDocument" ) ) );
1795 : : else
1796 [ + - ]: 4 : if (bWebDoc)
1797 [ + - ]: 4 : pArray[2] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.text.WebDocument" ) ) );
1798 : : else
1799 [ # # ]: 0 : if (bGlobalDoc)
1800 [ # # ]: 0 : pArray[2] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.text.GlobalDocument" ) ) );
1801 : :
1802 : 1416 : return aRet;
1803 : : }
1804 : :
1805 : 511 : Reference< XIndexAccess > SwXTextDocument::getDocumentIndexes(void) throw( RuntimeException )
1806 : : {
1807 [ + - ]: 511 : SolarMutexGuard aGuard;
1808 [ - + ]: 511 : if(!IsValid())
1809 [ # # ]: 0 : throw RuntimeException();
1810 [ + + ]: 511 : if(!pxXDocumentIndexes)
1811 : : {
1812 : 481 : ((SwXTextDocument*)this)->pxXDocumentIndexes = new Reference< XIndexAccess > ;
1813 [ + - ][ + - ]: 481 : *pxXDocumentIndexes = new SwXDocumentIndexes(pDocShell->GetDoc());
[ + - ]
1814 : : }
1815 [ + - ]: 511 : return *pxXDocumentIndexes;
1816 : : }
1817 : :
1818 : 1590 : Reference< XPropertySetInfo > SwXTextDocument::getPropertySetInfo(void) throw( RuntimeException )
1819 : : {
1820 [ + + ][ + - ]: 1590 : static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
[ + - ][ # # ]
1821 : 1590 : return xRet;
1822 : : }
1823 : :
1824 : 1732 : void SwXTextDocument::setPropertyValue(const OUString& rPropertyName,
1825 : : const Any& aValue)
1826 : : throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException,
1827 : : WrappedTargetException, RuntimeException)
1828 : : {
1829 [ + - ]: 1732 : SolarMutexGuard aGuard;
1830 [ + + ]: 1732 : if(!IsValid())
1831 [ + - ]: 2 : throw RuntimeException();
1832 [ + - ]: 1730 : const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName);
1833 : :
1834 [ - + ]: 1730 : if(!pEntry)
1835 [ # # ]: 0 : throw UnknownPropertyException();
1836 [ + + ]: 1730 : if(pEntry->nFlags & PropertyAttribute::READONLY)
1837 [ + - ]: 8 : throw PropertyVetoException();
1838 [ - + + + : 1722 : switch(pEntry->nWID)
+ + + + +
+ + + +
+ ]
1839 : : {
1840 : : case WID_DOC_CHAR_COUNT :
1841 : : case WID_DOC_PARA_COUNT :
1842 : : case WID_DOC_WORD_COUNT :
1843 [ # # ]: 0 : throw RuntimeException();
1844 : : case WID_DOC_WORD_SEPARATOR :
1845 : : {
1846 : 10 : OUString sDelim;
1847 : 10 : aValue >>= sDelim;
1848 [ + - ][ + - ]: 10 : SW_MOD()->GetModuleConfig()->SetWordDelimiter(sDelim);
[ + - ][ + - ]
1849 : : }
1850 : 10 : break;
1851 : : case WID_DOC_CHANGES_RECORD:
1852 : : case WID_DOC_CHANGES_SHOW:
1853 : : {
1854 : 493 : sal_Bool bSet = *(sal_Bool*)aValue.getValue();
1855 [ + - ]: 493 : sal_uInt16 eMode = pDocShell->GetDoc()->GetRedlineMode();
1856 [ + + ]: 493 : if(WID_DOC_CHANGES_SHOW == pEntry->nWID)
1857 : : {
1858 : 8 : eMode &= ~(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE);
1859 : 8 : eMode |= nsRedlineMode_t::REDLINE_SHOW_INSERT;
1860 [ + - ]: 8 : if( bSet )
1861 : 8 : eMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE;
1862 : : }
1863 [ + - ]: 485 : else if(WID_DOC_CHANGES_RECORD == pEntry->nWID)
1864 : : {
1865 [ + + ]: 485 : eMode = bSet ? eMode|nsRedlineMode_t::REDLINE_ON : eMode&~nsRedlineMode_t::REDLINE_ON;
1866 : : }
1867 [ + - ]: 493 : pDocShell->GetDoc()->SetRedlineMode( (RedlineMode_t)(eMode ));
1868 : : }
1869 : 493 : break;
1870 : : case WID_DOC_CHANGES_PASSWORD:
1871 : : {
1872 [ + - ]: 8 : Sequence <sal_Int8> aNew;
1873 [ + - ][ + - ]: 8 : if(aValue >>= aNew)
1874 : : {
1875 : 8 : SwDoc* pDoc = pDocShell->GetDoc();
1876 [ + - ]: 8 : pDoc->SetRedlinePassword(aNew);
1877 [ - + ]: 8 : if(aNew.getLength())
1878 : : {
1879 [ # # ]: 0 : sal_uInt16 eMode = pDoc->GetRedlineMode();
1880 : 0 : eMode = eMode|nsRedlineMode_t::REDLINE_ON;
1881 [ # # ]: 0 : pDoc->SetRedlineMode( (RedlineMode_t)(eMode ));
1882 : : }
1883 [ + - ]: 8 : }
1884 : : }
1885 : 8 : break;
1886 : : case WID_DOC_AUTO_MARK_URL :
1887 : : {
1888 : 2 : OUString sURL;
1889 : 2 : aValue >>= sURL;
1890 [ + - ][ + - ]: 2 : pDocShell->GetDoc()->SetTOIAutoMarkURL(sURL);
[ + - ]
1891 : : }
1892 : 2 : break;
1893 : : case WID_DOC_HIDE_TIPS :
1894 [ + - ]: 8 : SW_MOD()->GetModuleConfig()->SetHideFieldTips(*(sal_Bool*)aValue.getValue());
1895 : 8 : break;
1896 : : case WID_DOC_REDLINE_DISPLAY:
1897 : : {
1898 [ + - ]: 8 : sal_Int16 eRedMode = pDocShell->GetDoc()->GetRedlineMode();
1899 : 8 : eRedMode = eRedMode & (~nsRedlineMode_t::REDLINE_SHOW_MASK);
1900 : 8 : sal_Int16 nSet = 0;
1901 : 8 : aValue >>= nSet;
1902 [ - - + - : 8 : switch(nSet)
- ]
1903 : : {
1904 : 0 : case RedlineDisplayType::NONE: break;
1905 : 0 : case RedlineDisplayType::INSERTED: eRedMode |= nsRedlineMode_t::REDLINE_SHOW_INSERT; break;
1906 : 8 : case RedlineDisplayType::REMOVED: eRedMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE; break;
1907 : : case RedlineDisplayType::
1908 : 0 : INSERTED_AND_REMOVED: eRedMode |= nsRedlineMode_t::REDLINE_SHOW_INSERT|nsRedlineMode_t::REDLINE_SHOW_DELETE;
1909 : 0 : break;
1910 [ # # ]: 0 : default: throw IllegalArgumentException();
1911 : : }
1912 [ + - ]: 8 : pDocShell->GetDoc()->SetRedlineMode(eRedMode);
1913 : : }
1914 : 8 : break;
1915 : : case WID_DOC_TWO_DIGIT_YEAR:
1916 : : {
1917 : 10 : sal_Int16 nYear = 0;
1918 : 10 : aValue >>= nYear;
1919 [ + - ]: 10 : SfxRequest aRequest ( SID_ATTR_YEAR2000, SFX_CALLMODE_SLOT, pDocShell->GetDoc()->GetAttrPool());
1920 [ + - ][ + - ]: 10 : aRequest.AppendItem(SfxUInt16Item( SID_ATTR_YEAR2000, static_cast < sal_uInt16 > ( nYear ) ) );
[ + - ]
1921 [ + - ][ + - ]: 10 : pDocShell->Execute ( aRequest );
1922 : : }
1923 : 10 : break;
1924 : : case WID_DOC_AUTOMATIC_CONTROL_FOCUS:
1925 : : {
1926 : : SwDrawDocument * pDrawDoc;
1927 : 23 : sal_Bool bAuto = *(sal_Bool*) aValue.getValue();
1928 : :
1929 [ - + ][ + - ]: 23 : if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * >( pDocShell->GetDoc()->GetDrawModel() ) ) )
[ + - ]
1930 [ + - ]: 23 : pDrawDoc->SetAutoControlFocus( bAuto );
1931 [ # # ]: 0 : else if (bAuto)
1932 : : {
1933 : : // if setting to true, and we don't have an
1934 : : // SdrModel, then we are changing the default and
1935 : : // must thus create an SdrModel, if we don't have an
1936 : : // SdrModel and we are leaving the default at false,
1937 : : // we don't need to make an SdrModel and can do nothing
1938 : : // #i52858# - method name changed
1939 [ # # ][ # # ]: 0 : pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetOrCreateDrawModel() );
1940 [ # # ]: 0 : pDrawDoc->SetAutoControlFocus ( bAuto );
1941 : : }
1942 : : }
1943 : 23 : break;
1944 : : case WID_DOC_APPLY_FORM_DESIGN_MODE:
1945 : : {
1946 : : SwDrawDocument * pDrawDoc;
1947 : 125 : sal_Bool bMode = *(sal_Bool*)aValue.getValue();
1948 : :
1949 [ + + ][ + + ]: 125 : if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetDrawModel() ) ) )
[ + - ]
1950 [ + - ]: 23 : pDrawDoc->SetOpenInDesignMode( bMode );
1951 [ + - ]: 102 : else if (!bMode)
1952 : : {
1953 : : // if setting to false, and we don't have an
1954 : : // SdrModel, then we are changing the default and
1955 : : // must thus create an SdrModel, if we don't have an
1956 : : // SdrModel and we are leaving the default at true,
1957 : : // we don't need to make an SdrModel and can do
1958 : : // nothing
1959 : : // #i52858# - method name changed
1960 [ + - ][ - + ]: 102 : pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetOrCreateDrawModel() );
1961 [ + - ]: 102 : pDrawDoc->SetOpenInDesignMode ( bMode );
1962 : : }
1963 : : }
1964 : 125 : break;
1965 : : // #i42634# New property to set the bInReading
1966 : : // flag at the document, used during binary import
1967 : : case WID_DOC_LOCK_UPDATES :
1968 : : {
1969 : 954 : SwDoc* pDoc = pDocShell->GetDoc();
1970 : 954 : bool bBool (false);
1971 [ + - ]: 954 : if( aValue >>= bBool )
1972 : 954 : pDoc->SetInReading( bBool );
1973 : : }
1974 : 954 : break;
1975 : : case WID_DOC_BUILDID:
1976 : 71 : aValue >>= maBuildId;
1977 : 71 : break;
1978 : : //
1979 : : case WID_APPLY_WORKAROUND_FOR_B6375613:
1980 : : {
1981 : 8 : bool bApplyWorkaroundForB6375613( false );
1982 : 8 : aValue >>= bApplyWorkaroundForB6375613;
1983 [ + - ]: 8 : pDocShell->GetDoc()->SetApplyWorkaroundForB6375613( bApplyWorkaroundForB6375613 );
1984 : : }
1985 : 8 : break;
1986 : :
1987 : : default:
1988 : : {
1989 [ + - ]: 2 : const SfxPoolItem& rItem = pDocShell->GetDoc()->GetDefault(pEntry->nWID);
1990 [ + - ]: 2 : SfxPoolItem* pNewItem = rItem.Clone();
1991 [ + - ]: 2 : pNewItem->PutValue(aValue, pEntry->nMemberId);
1992 [ + - ]: 2 : pDocShell->GetDoc()->SetDefault(*pNewItem);
1993 [ + - ][ + - ]: 2 : delete pNewItem;
1994 : : }
1995 [ + - ]: 1732 : }
1996 : 1722 : }
1997 : :
1998 : 3547 : Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName)
1999 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
2000 : : {
2001 [ + - ]: 3547 : SolarMutexGuard aGuard;
2002 [ - + ]: 3547 : if(!IsValid())
2003 [ # # ]: 0 : throw RuntimeException();
2004 [ + - ]: 3547 : const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName);
2005 : :
2006 [ + + ]: 3547 : if(!pEntry)
2007 [ + - ]: 2497 : throw UnknownPropertyException();
2008 : 1050 : Any aAny;
2009 [ - + + + : 1050 : switch(pEntry->nWID)
+ + + + +
+ + + + -
- + + + -
+ + ]
2010 : : {
2011 : : case WID_DOC_ISTEMPLATEID :
2012 [ # # ]: 0 : aAny <<= pDocShell->IsTemplate();
2013 : 0 : break;
2014 : : case WID_DOC_CHAR_COUNT :
2015 : : case WID_DOC_PARA_COUNT :
2016 : : case WID_DOC_WORD_COUNT :
2017 : : {
2018 [ + - ]: 12 : const SwDocStat& rStat(pDocShell->GetDoc()->GetUpdatedDocStat());
2019 : : sal_Int32 nValue;
2020 [ + + + - ]: 12 : switch(pEntry->nWID)
2021 : : {
2022 : 4 : case WID_DOC_CHAR_COUNT :nValue = rStat.nChar;break;
2023 : 4 : case WID_DOC_PARA_COUNT :nValue = rStat.nPara;break;
2024 : 4 : case WID_DOC_WORD_COUNT :nValue = rStat.nWord;break;
2025 : : }
2026 [ + - ]: 12 : aAny <<= nValue;
2027 : : }
2028 : 12 : break;
2029 : : case WID_DOC_WORD_SEPARATOR :
2030 : : {
2031 [ + - ][ + - ]: 24 : aAny <<= OUString(SW_MOD()->GetDocStatWordDelim());
[ + - ][ + - ]
2032 : : }
2033 : 24 : break;
2034 : : case WID_DOC_CHANGES_RECORD:
2035 : : case WID_DOC_CHANGES_SHOW:
2036 : : {
2037 [ + - ]: 69 : sal_uInt16 eMode = pDocShell->GetDoc()->GetRedlineMode();
2038 : 69 : sal_Bool bSet = sal_False;
2039 [ + + ]: 69 : if(WID_DOC_CHANGES_SHOW == pEntry->nWID)
2040 : : {
2041 : 22 : sal_uInt16 nMask = nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE;
2042 : 22 : bSet = (eMode & nMask) == nMask;
2043 : : }
2044 [ + - ]: 47 : else if(WID_DOC_CHANGES_RECORD == pEntry->nWID)
2045 : : {
2046 : 47 : bSet = (eMode& nsRedlineMode_t::REDLINE_ON) != 0;
2047 : : }
2048 [ + - ]: 69 : aAny.setValue(&bSet, ::getBooleanCppuType());
2049 : : }
2050 : 69 : break;
2051 : : case WID_DOC_CHANGES_PASSWORD:
2052 : : {
2053 : 22 : SwDoc* pDoc = pDocShell->GetDoc();
2054 [ + - ][ + - ]: 22 : aAny <<= pDoc->GetRedlinePassword();
2055 : : }
2056 : 22 : break;
2057 : : case WID_DOC_AUTO_MARK_URL :
2058 [ + - ][ + - ]: 25 : aAny <<= OUString(pDocShell->GetDoc()->GetTOIAutoMarkURL());
2059 : 25 : break;
2060 : : case WID_DOC_HIDE_TIPS :
2061 : : {
2062 [ + - ]: 20 : sal_Bool bTemp = SW_MOD()->GetModuleConfig()->IsHideFieldTips();
2063 [ + - ]: 20 : aAny.setValue(&bTemp, ::getBooleanCppuType());
2064 : : }
2065 : 20 : break;
2066 : : case WID_DOC_REDLINE_DISPLAY:
2067 : : {
2068 [ + - ]: 20 : sal_Int16 eRedMode = pDocShell->GetDoc()->GetRedlineMode();
2069 : 20 : eRedMode = eRedMode & nsRedlineMode_t::REDLINE_SHOW_MASK;
2070 : 20 : sal_Int16 nRet = RedlineDisplayType::NONE;
2071 [ - + ]: 20 : if(nsRedlineMode_t::REDLINE_SHOW_INSERT == eRedMode)
2072 : 0 : nRet = RedlineDisplayType::INSERTED;
2073 [ + + ]: 20 : else if(nsRedlineMode_t::REDLINE_SHOW_DELETE == eRedMode)
2074 : 8 : nRet = RedlineDisplayType::REMOVED;
2075 [ + - ]: 12 : else if(nsRedlineMode_t::REDLINE_SHOW_MASK == eRedMode)
2076 : 12 : nRet = RedlineDisplayType::INSERTED_AND_REMOVED;
2077 [ + - ]: 20 : aAny <<= nRet;
2078 : : }
2079 : 20 : break;
2080 : : case WID_DOC_FORBIDDEN_CHARS:
2081 : : {
2082 [ + - ]: 4 : GetPropertyHelper();
2083 [ + - ]: 4 : Reference<XForbiddenCharacters> xRet(xPropertyHelper, UNO_QUERY);
2084 [ + - ]: 4 : aAny <<= xRet;
2085 : : }
2086 : 4 : break;
2087 : : case WID_DOC_TWO_DIGIT_YEAR:
2088 : : {
2089 [ + - ][ + - ]: 45 : aAny <<= static_cast < sal_Int16 > (pDocShell->GetDoc()->GetNumberFormatter ( sal_True )->GetYear2000());
[ + - ]
2090 : : }
2091 : 45 : break;
2092 : : case WID_DOC_AUTOMATIC_CONTROL_FOCUS:
2093 : : {
2094 : : SwDrawDocument * pDrawDoc;
2095 : : sal_Bool bAuto;
2096 [ + - ][ - + ]: 24 : if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetDrawModel() ) ) )
[ + - ]
2097 : 24 : bAuto = pDrawDoc->GetAutoControlFocus();
2098 : : else
2099 : 0 : bAuto = sal_False;
2100 [ + - ]: 24 : aAny.setValue(&bAuto, ::getBooleanCppuType());
2101 : : }
2102 : 24 : break;
2103 : : case WID_DOC_APPLY_FORM_DESIGN_MODE:
2104 : : {
2105 : : SwDrawDocument * pDrawDoc;
2106 : : sal_Bool bMode;
2107 [ + - ][ - + ]: 24 : if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetDrawModel() ) ) )
[ + - ]
2108 : 24 : bMode = pDrawDoc->GetOpenInDesignMode();
2109 : : else
2110 : 0 : bMode = sal_True;
2111 [ + - ]: 24 : aAny.setValue(&bMode, ::getBooleanCppuType());
2112 : : }
2113 : 24 : break;
2114 : : case WID_DOC_BASIC_LIBRARIES:
2115 [ + - ][ + - ]: 102 : aAny <<= pDocShell->GetBasicContainer();
2116 : 102 : break;
2117 : : case WID_DOC_DIALOG_LIBRARIES:
2118 [ # # ][ # # ]: 0 : aAny <<= pDocShell->GetDialogContainer();
2119 : 0 : break;
2120 : : case WID_DOC_VBA_DOCOBJ:
2121 : : {
2122 : 0 : beans::PropertyValue aProp;
2123 [ # # ]: 0 : aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ThisWordDoc") );
2124 [ # # ][ # # ]: 0 : aProp.Value <<= pDocShell->GetModel();
2125 [ # # ]: 0 : aAny <<= aProp;
2126 : : }
2127 : 0 : break;
2128 : : case WID_DOC_RUNTIME_UID:
2129 [ + - ][ + - ]: 595 : aAny <<= getRuntimeUID();
2130 : 595 : break;
2131 : : case WID_DOC_LOCK_UPDATES :
2132 [ + - ]: 20 : aAny <<= static_cast<bool>( pDocShell->GetDoc()->IsInReading() );
2133 : 20 : break;
2134 : : case WID_DOC_BUILDID:
2135 [ + - ]: 20 : aAny <<= maBuildId;
2136 : 20 : break;
2137 : : case WID_DOC_HAS_VALID_SIGNATURES:
2138 [ # # ][ # # ]: 0 : aAny <<= hasValidSignatures();
2139 : 0 : break;
2140 : : //
2141 : : case WID_APPLY_WORKAROUND_FOR_B6375613:
2142 : : {
2143 [ + - ]: 20 : aAny <<= pDocShell->GetDoc()->ApplyWorkaroundForB6375613();
2144 : : }
2145 : 20 : break;
2146 : :
2147 : : default:
2148 : : {
2149 [ + - ]: 4 : const SfxPoolItem& rItem = pDocShell->GetDoc()->GetDefault(pEntry->nWID);
2150 [ + - ]: 4 : rItem.QueryValue(aAny, pEntry->nMemberId);
2151 : : }
2152 : : }
2153 [ + - ]: 3547 : return aAny;
2154 : : }
2155 : :
2156 : 0 : void SwXTextDocument::addPropertyChangeListener(const OUString& /*PropertyName*/,
2157 : : const Reference< XPropertyChangeListener > & /*aListener*/)
2158 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
2159 : : {
2160 : : OSL_FAIL("not implemented");
2161 : 0 : }
2162 : :
2163 : 0 : void SwXTextDocument::removePropertyChangeListener(const OUString& /*PropertyName*/,
2164 : : const Reference< XPropertyChangeListener > & /*aListener*/)
2165 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
2166 : : {
2167 : : OSL_FAIL("not implemented");
2168 : 0 : }
2169 : :
2170 : 0 : void SwXTextDocument::addVetoableChangeListener(const OUString& /*PropertyName*/,
2171 : : const Reference< XVetoableChangeListener > & /*aListener*/)
2172 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
2173 : : {
2174 : : OSL_FAIL("not implemented");
2175 : 0 : }
2176 : :
2177 : 0 : void SwXTextDocument::removeVetoableChangeListener(const OUString& /*PropertyName*/,
2178 : : const Reference< XVetoableChangeListener > & /*aListener*/)
2179 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
2180 : : {
2181 : : OSL_FAIL("not implemented");
2182 : 0 : }
2183 : :
2184 : 0 : Reference< XNameAccess > SwXTextDocument::getLinks(void) throw( RuntimeException )
2185 : : {
2186 [ # # ]: 0 : if(!pxLinkTargetSupplier)
2187 : : {
2188 : 0 : pxLinkTargetSupplier = new Reference< XNameAccess > ;
2189 [ # # ][ # # ]: 0 : (*pxLinkTargetSupplier) = new SwXLinkTargetSupplier(*(SwXTextDocument*)this);
2190 : : }
2191 : 0 : return (*pxLinkTargetSupplier);
2192 : : }
2193 : :
2194 : 42 : Reference< XEnumerationAccess > SwXTextDocument::getRedlines( ) throw(RuntimeException)
2195 : : {
2196 [ + + ]: 42 : if(!pxXRedlines)
2197 : : {
2198 : 19 : pxXRedlines = new Reference< XEnumerationAccess > ;
2199 [ + - ][ + - ]: 19 : (*pxXRedlines) = new SwXRedlines(pDocShell->GetDoc());
2200 : : }
2201 : 42 : return *pxXRedlines;
2202 : : }
2203 : :
2204 : 4 : void SwXTextDocument::refresh(void) throw( RuntimeException )
2205 : : {
2206 [ + - ]: 4 : SolarMutexGuard aGuard;
2207 [ - + ]: 4 : if(!IsValid())
2208 [ # # ]: 0 : throw RuntimeException();
2209 : 4 : ViewShell *pViewShell = pDocShell->GetWrtShell();
2210 [ + - ]: 4 : notifyRefreshListeners();
2211 [ + - ]: 4 : if(pViewShell)
2212 [ + - ][ + - ]: 4 : pViewShell->CalcLayout();
2213 : 4 : }
2214 : :
2215 : 2 : void SwXTextDocument::addRefreshListener(const Reference< util::XRefreshListener > & l)
2216 : : throw( RuntimeException )
2217 : : {
2218 [ + - ]: 2 : SolarMutexGuard aGuard;
2219 [ - + ]: 2 : if ( !IsValid() )
2220 [ # # ]: 0 : throw RuntimeException();
2221 [ + - ][ + - ]: 2 : aRefreshCont.AddListener ( reinterpret_cast < const Reference < lang::XEventListener > &> ( l ));
2222 : 2 : }
2223 : :
2224 : 2 : void SwXTextDocument::removeRefreshListener(const Reference< util::XRefreshListener > & l)
2225 : : throw( RuntimeException )
2226 : : {
2227 [ + - ]: 2 : SolarMutexGuard aGuard;
2228 [ + - ][ + - ]: 2 : if ( !IsValid() || !aRefreshCont.RemoveListener ( reinterpret_cast < const Reference < lang::XEventListener > &> ( l ) ) )
[ - + ][ - + ]
2229 [ # # ][ + - ]: 2 : throw RuntimeException();
2230 : 2 : }
2231 : :
2232 : 0 : void SwXTextDocument::updateLinks( ) throw(RuntimeException)
2233 : : {
2234 [ # # ]: 0 : SolarMutexGuard aGuard;
2235 [ # # ]: 0 : if(!IsValid())
2236 [ # # ]: 0 : throw RuntimeException();
2237 : 0 : SwDoc* pDoc = pDocShell->GetDoc();
2238 [ # # ]: 0 : sfx2::LinkManager& rLnkMan = pDoc->GetLinkManager();
2239 [ # # ]: 0 : if( !rLnkMan.GetLinks().empty() )
2240 : : {
2241 [ # # ]: 0 : UnoActionContext aAction(pDoc);
2242 [ # # ][ # # ]: 0 : rLnkMan.UpdateAllLinks( sal_False, sal_False, sal_True );
2243 [ # # ]: 0 : }
2244 : 0 : }
2245 : :
2246 : : //XPropertyState
2247 : 0 : PropertyState SAL_CALL SwXTextDocument::getPropertyState( const OUString& rPropertyName )
2248 : : throw (UnknownPropertyException, RuntimeException)
2249 : : {
2250 [ # # ]: 0 : SolarMutexGuard aGuard;
2251 : 0 : PropertyState eRet = PropertyState_DIRECT_VALUE;
2252 [ # # ]: 0 : if(!IsValid())
2253 [ # # ]: 0 : throw RuntimeException();
2254 [ # # ]: 0 : const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName);
2255 : :
2256 [ # # ]: 0 : if(!pEntry)
2257 [ # # ]: 0 : throw UnknownPropertyException();
2258 : 0 : Any aAny;
2259 : 0 : switch(pEntry->nWID)
2260 : : {
2261 : 0 : case 0:default:break;
2262 : : }
2263 [ # # ]: 0 : return eRet;
2264 : : }
2265 : :
2266 : 0 : Sequence< PropertyState > SAL_CALL SwXTextDocument::getPropertyStates( const Sequence< OUString >& rPropertyNames )
2267 : : throw (UnknownPropertyException, RuntimeException)
2268 : : {
2269 : 0 : const sal_Int32 nCount = rPropertyNames.getLength();
2270 : 0 : const OUString * pNames = rPropertyNames.getConstArray();
2271 : 0 : Sequence < PropertyState > aRet ( nCount );
2272 [ # # ]: 0 : PropertyState *pState = aRet.getArray();
2273 : :
2274 [ # # ]: 0 : for ( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++)
2275 [ # # ]: 0 : pState[nIndex] = getPropertyState( pNames[nIndex] );
2276 : :
2277 : 0 : return aRet;
2278 : : }
2279 : :
2280 : 0 : void SAL_CALL SwXTextDocument::setPropertyToDefault( const OUString& rPropertyName )
2281 : : throw (UnknownPropertyException, RuntimeException)
2282 : : {
2283 [ # # ]: 0 : SolarMutexGuard aGuard;
2284 [ # # ]: 0 : if(!IsValid())
2285 [ # # ]: 0 : throw RuntimeException();
2286 [ # # ]: 0 : const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName);
2287 [ # # ]: 0 : if(!pEntry)
2288 [ # # ]: 0 : throw UnknownPropertyException();
2289 : 0 : switch(pEntry->nWID)
2290 : : {
2291 : 0 : case 0:default:break;
2292 [ # # ]: 0 : }
2293 : 0 : }
2294 : :
2295 : 0 : Any SAL_CALL SwXTextDocument::getPropertyDefault( const OUString& rPropertyName )
2296 : : throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
2297 : : {
2298 [ # # ]: 0 : SolarMutexGuard aGuard;
2299 [ # # ]: 0 : if(!IsValid())
2300 [ # # ]: 0 : throw RuntimeException();
2301 [ # # ]: 0 : const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName);
2302 [ # # ]: 0 : if(!pEntry)
2303 [ # # ]: 0 : throw UnknownPropertyException();
2304 : 0 : Any aAny;
2305 : 0 : switch(pEntry->nWID)
2306 : : {
2307 : 0 : case 0:default:break;
2308 : : }
2309 [ # # ]: 0 : return aAny;
2310 : : }
2311 : :
2312 : 0 : static OutputDevice * lcl_GetOutputDevice( const SwPrintUIOptions &rPrintUIOptions )
2313 : : {
2314 : 0 : OutputDevice *pOut = 0;
2315 : :
2316 [ # # ][ # # ]: 0 : uno::Any aAny( rPrintUIOptions.getValue( C2U( "RenderDevice" ) ));
2317 : 0 : uno::Reference< awt::XDevice > xRenderDevice;
2318 [ # # ]: 0 : aAny >>= xRenderDevice;
2319 [ # # ]: 0 : if (xRenderDevice.is())
2320 : : {
2321 : 0 : VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice );
2322 [ # # ]: 0 : pOut = pDevice ? pDevice->GetOutputDevice() : 0;
2323 : : }
2324 : :
2325 : 0 : return pOut;
2326 : : }
2327 : :
2328 : 0 : static bool lcl_SeqHasProperty(
2329 : : const uno::Sequence< beans::PropertyValue >& rOptions,
2330 : : const sal_Char *pPropName )
2331 : : {
2332 : 0 : bool bRes = false;
2333 : 0 : const sal_Int32 nLen = rOptions.getLength();
2334 : 0 : const beans::PropertyValue *pProps = rOptions.getConstArray();
2335 [ # # ][ # # ]: 0 : for (sal_Int32 i = 0; i < nLen && !bRes; ++i)
[ # # ]
2336 : : {
2337 [ # # ]: 0 : if (pProps[i].Name.equalsAscii( pPropName ))
2338 : 0 : bRes = true;
2339 : : }
2340 : 0 : return bRes;
2341 : : }
2342 : :
2343 : 0 : SfxViewShell * SwXTextDocument::GetRenderView(
2344 : : bool &rbIsSwSrcView,
2345 : : const uno::Sequence< beans::PropertyValue >& rOptions,
2346 : : bool bIsPDFExport )
2347 : : {
2348 : : // get view shell to use
2349 : 0 : SfxViewShell *pView = 0;
2350 [ # # ]: 0 : if (bIsPDFExport)
2351 [ # # ]: 0 : pView = GuessViewShell( rbIsSwSrcView );
2352 : : else
2353 : : {
2354 : 0 : uno::Any aTmp;
2355 : 0 : const sal_Int32 nLen = rOptions.getLength();
2356 : 0 : const beans::PropertyValue *pProps = rOptions.getConstArray();
2357 [ # # ]: 0 : for (sal_Int32 i = 0; i < nLen; ++i)
2358 : : {
2359 [ # # ]: 0 : if ( pProps[i].Name == "View" )
2360 : : {
2361 : 0 : aTmp = pProps[i].Value;
2362 : 0 : break;
2363 : : }
2364 : : }
2365 : :
2366 : 0 : uno::Reference< frame::XController > xController;
2367 [ # # ][ # # ]: 0 : if (aTmp >>= xController)
2368 : : {
2369 : : OSL_ENSURE( xController.is(), "controller is empty!" );
2370 [ # # ]: 0 : pView = GuessViewShell( rbIsSwSrcView, xController );
2371 : 0 : }
2372 : : }
2373 : 0 : return pView;
2374 : : }
2375 : :
2376 : : /*
2377 : : * GetRenderDoc:
2378 : : * returns the document to be rendered, usually this will be the 'regular'
2379 : : * document but in case of PDF export of (multi-)selection it will
2380 : : * be a temporary document that gets created if not already done.
2381 : : * The rpView variable will be set (if not already done) to the used
2382 : : * SfxViewShell.
2383 : : */
2384 : 0 : SwDoc * SwXTextDocument::GetRenderDoc(
2385 : : SfxViewShell *&rpView,
2386 : : const uno::Any& rSelection,
2387 : : bool bIsPDFExport )
2388 : : {
2389 : 0 : SwDoc *pDoc = 0;
2390 : :
2391 : 0 : uno::Reference< frame::XModel > xModel;
2392 [ # # ]: 0 : rSelection >>= xModel;
2393 [ # # ][ # # ]: 0 : if (xModel == pDocShell->GetModel())
[ # # ]
2394 : 0 : pDoc = pDocShell->GetDoc();
2395 : : else
2396 : : {
2397 : : OSL_ENSURE( !xModel.is(), "unexpected model found" );
2398 : :
2399 [ # # ]: 0 : if (rSelection.hasValue()) // is anything selected ?
2400 : : {
2401 : : // this part should only be called when a temporary document needs to be created,
2402 : : // for example for PDF export or printing of (multi-)selection only.
2403 : :
2404 : 0 : bool bIsSwSrcView = false;
2405 [ # # ]: 0 : if (!rpView)
2406 : : {
2407 : : (void) bIsPDFExport;
2408 : : // aside from maybe PDF export the view should always have been provided!
2409 : : OSL_ENSURE( bIsPDFExport, "view is missing, guessing one..." );
2410 : :
2411 [ # # ]: 0 : rpView = GuessViewShell( bIsSwSrcView );
2412 : : }
2413 : : OSL_ENSURE( rpView, "ViewShell missing" );
2414 : : // the view shell should be SwView for documents PDF export.
2415 : : // for the page preview no selection should be possible
2416 : : // (the export dialog does not allow for this option)
2417 [ # # ]: 0 : const TypeId aSwViewTypeId = TYPE(SwView);
2418 [ # # ][ # # ]: 0 : if (rpView && rpView->IsA(aSwViewTypeId))
[ # # ][ # # ]
2419 : : {
2420 [ # # ]: 0 : if (!m_pRenderData)
2421 : : {
2422 : : OSL_FAIL("GetRenderDoc: no renderdata");
2423 : 0 : return 0;
2424 : : }
2425 : 0 : SwView *const pSwView(static_cast<SwView *>(rpView));
2426 [ # # ][ # # ]: 0 : SfxObjectShellLock xDocSh(m_pRenderData->GetTempDocShell());
2427 [ # # ]: 0 : if (!xDocSh.Is())
2428 : : {
2429 [ # # ][ # # ]: 0 : xDocSh = pSwView->CreateTmpSelectionDoc();
[ # # ]
2430 [ # # ]: 0 : m_pRenderData->SetTempDocShell(xDocSh);
2431 : : }
2432 [ # # ]: 0 : if (xDocSh.Is())
2433 : : {
2434 : 0 : pDoc = ((SwDocShell*)&xDocSh)->GetDoc();
2435 : 0 : rpView = pDoc->GetDocShell()->GetView();
2436 [ # # ]: 0 : }
2437 : : }
2438 : : else
2439 : : {
2440 : : OSL_FAIL("unexpected ViewShell" );
2441 : : }
2442 : : }
2443 : : }
2444 : 0 : return pDoc;
2445 : : }
2446 : :
2447 : 0 : static void lcl_SavePrintUIOptionsToDocumentPrintData(
2448 : : SwDoc &rDoc,
2449 : : const SwPrintUIOptions &rPrintUIOptions,
2450 : : bool bIsPDFEXport )
2451 : : {
2452 [ # # ]: 0 : SwPrintData aDocPrintData( rDoc.getPrintData() );
2453 : :
2454 [ # # ][ # # ]: 0 : aDocPrintData.SetPrintGraphic( rPrintUIOptions.IsPrintGraphics() );
2455 [ # # ][ # # ]: 0 : aDocPrintData.SetPrintTable( rPrintUIOptions.IsPrintTables() );
2456 [ # # ][ # # ]: 0 : aDocPrintData.SetPrintDraw( rPrintUIOptions.IsPrintDrawings() );
2457 [ # # ][ # # ]: 0 : aDocPrintData.SetPrintControl( rPrintUIOptions.IsPrintFormControls() );
2458 [ # # ][ # # ]: 0 : aDocPrintData.SetPrintLeftPage( rPrintUIOptions.IsPrintLeftPages() );
2459 [ # # ][ # # ]: 0 : aDocPrintData.SetPrintRightPage( rPrintUIOptions.IsPrintRightPages() );
2460 [ # # ]: 0 : aDocPrintData.SetPrintReverse( rPrintUIOptions.IsPrintReverse() );
2461 [ # # ][ # # ]: 0 : aDocPrintData.SetPaperFromSetup( rPrintUIOptions.IsPaperFromSetup() );
2462 [ # # ][ # # ]: 0 : aDocPrintData.SetPrintEmptyPages( rPrintUIOptions.IsPrintEmptyPages( bIsPDFEXport ) );
2463 [ # # ][ # # ]: 0 : aDocPrintData.SetPrintPostIts( rPrintUIOptions.GetPrintPostItsType() );
2464 [ # # ][ # # ]: 0 : aDocPrintData.SetPrintProspect( rPrintUIOptions.IsPrintProspect() );
2465 [ # # ][ # # ]: 0 : aDocPrintData.SetPrintProspect_RTL( rPrintUIOptions.IsPrintProspectRTL() );
2466 [ # # ][ # # ]: 0 : aDocPrintData.SetPrintPageBackground( rPrintUIOptions.IsPrintPageBackground() );
2467 [ # # ][ # # ]: 0 : aDocPrintData.SetPrintBlackFont( rPrintUIOptions.IsPrintWithBlackTextColor() );
2468 : : // aDocPrintData.SetPrintSingleJobs( b ); handled by File/Print dialog itself
2469 : : // arDocPrintData.SetFaxName( s ); n/a in File/Print dialog
2470 [ # # ][ # # ]: 0 : aDocPrintData.SetPrintHiddenText( rPrintUIOptions.IsPrintHiddenText() );
2471 [ # # ][ # # ]: 0 : aDocPrintData.SetPrintTextPlaceholder( rPrintUIOptions.IsPrintTextPlaceholders() );
2472 : :
2473 [ # # ]: 0 : rDoc.setPrintData( aDocPrintData );
2474 : 0 : }
2475 : :
2476 : 0 : sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
2477 : : const uno::Any& rSelection,
2478 : : const uno::Sequence< beans::PropertyValue >& rxOptions )
2479 : : throw (IllegalArgumentException, RuntimeException)
2480 : : {
2481 [ # # ]: 0 : SolarMutexGuard aGuard;
2482 [ # # ]: 0 : if(!IsValid())
2483 : : {
2484 : : throw DisposedException( ::rtl::OUString(),
2485 [ # # ][ # # ]: 0 : static_cast< XTextDocument* >(this) );
2486 : : }
2487 : :
2488 [ # # ]: 0 : const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" );
2489 : 0 : bool bIsSwSrcView = false;
2490 [ # # ]: 0 : SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport );
2491 : :
2492 [ # # ][ # # ]: 0 : if (!bIsSwSrcView && !m_pRenderData)
2493 [ # # ][ # # ]: 0 : m_pRenderData = new SwRenderData;
2494 [ # # ]: 0 : if (!m_pPrintUIOptions)
2495 [ # # ]: 0 : m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView );
2496 [ # # ]: 0 : bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions );
2497 : :
2498 [ # # ]: 0 : SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport );
2499 : : OSL_ENSURE( pDoc && pView, "doc or view shell missing!" );
2500 [ # # ][ # # ]: 0 : if (!pDoc || !pView)
2501 : 0 : return 0;
2502 : :
2503 : : // save current UI options from the print dialog for the next call to that dialog
2504 [ # # ]: 0 : lcl_SavePrintUIOptionsToDocumentPrintData( *pDoc, *m_pPrintUIOptions, bIsPDFExport );
2505 : :
2506 : 0 : sal_Int32 nRet = 0;
2507 [ # # ]: 0 : if (bIsSwSrcView)
2508 : : {
2509 [ # # ]: 0 : SwSrcView *pSwSrcView = dynamic_cast< SwSrcView * >(pView);
2510 [ # # ]: 0 : OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions );
2511 [ # # ]: 0 : nRet = pSwSrcView->PrintSource( pOutDev, 1 /* dummy */, true /* get page count only */ );
2512 : : }
2513 : : else
2514 : : {
2515 : 0 : SwDocShell *pRenderDocShell = pDoc->GetDocShell();
2516 : :
2517 : : // TODO/mba: we really need a generic way to get the ViewShell!
2518 : 0 : ViewShell* pViewShell = 0;
2519 [ # # ][ # # ]: 0 : SwView* pSwView = PTR_CAST(SwView, pView);
[ # # ][ # # ]
2520 [ # # ]: 0 : if ( pSwView )
2521 : : {
2522 : 0 : pViewShell = pSwView->GetWrtShellPtr();
2523 : : }
2524 : : else
2525 : : {
2526 [ # # ][ # # ]: 0 : if ( bIsPDFExport && bFormat )
2527 : : {
2528 : : //create a hidden view to be able to export as PDF also in print preview
2529 : : //pView and pSwView are not changed intentionally!
2530 [ # # ]: 0 : m_pHiddenViewFrame = SfxViewFrame::LoadHiddenDocument( *pRenderDocShell, 2 );
2531 [ # # ]: 0 : pViewShell = ((SwView*)m_pHiddenViewFrame->GetViewShell())->GetWrtShellPtr();
2532 : : }
2533 : : else
2534 : 0 : pViewShell = ((SwPagePreView*)pView)->GetViewShell();
2535 : : }
2536 : :
2537 [ # # ][ # # ]: 0 : if (!pViewShell || !pViewShell->GetLayout())
[ # # ][ # # ]
2538 : 0 : return 0;
2539 : :
2540 [ # # ]: 0 : if (bFormat)
2541 : : {
2542 : : // #i38289
2543 [ # # ]: 0 : if( pViewShell->GetViewOptions()->getBrowseMode() )
2544 : : {
2545 [ # # ]: 0 : SwViewOption aOpt( *pViewShell->GetViewOptions() );
2546 : 0 : aOpt.setBrowseMode( false );
2547 [ # # ]: 0 : pViewShell->ApplyViewOptions( aOpt );
2548 [ # # ][ # # ]: 0 : pSwView->RecheckBrowseMode();
2549 : : }
2550 : :
2551 : : // reformating the document for printing will show the changes in the view
2552 : : // which is likely to produce many unwanted and not nice to view actions.
2553 : : // We don't want that! Thus we disable updating of the view.
2554 [ # # ]: 0 : pViewShell->StartAction();
2555 : :
2556 [ # # ]: 0 : if (pSwView)
2557 : : {
2558 [ # # ][ # # ]: 0 : if (m_pRenderData && m_pRenderData->NeedNewViewOptionAdjust( *pViewShell ) )
[ # # ][ # # ]
2559 [ # # ]: 0 : m_pRenderData->ViewOptionAdjustStop();
2560 [ # # ][ # # ]: 0 : if (m_pRenderData && !m_pRenderData->IsViewOptionAdjust())
[ # # ][ # # ]
2561 : : {
2562 : : m_pRenderData->ViewOptionAdjustStart(
2563 [ # # ]: 0 : *pViewShell, *pViewShell->GetViewOptions() );
2564 : : }
2565 : : }
2566 : :
2567 : : m_pRenderData->MakeSwPrtOptions( pRenderDocShell,
2568 [ # # ]: 0 : m_pPrintUIOptions, bIsPDFExport );
2569 : :
2570 [ # # ]: 0 : if (pSwView)
2571 : : {
2572 : : // PDF export should not make use of the SwPrtOptions
2573 : : const SwPrintData *pPrtOptions = (bIsPDFExport)
2574 [ # # ][ # # ]: 0 : ? NULL : m_pRenderData->GetSwPrtOptions();
2575 [ # # ]: 0 : m_pRenderData->ViewOptionAdjust( pPrtOptions );
2576 : : }
2577 : :
2578 : : // since printing now also use the API for PDF export this option
2579 : : // should be set for printing as well ...
2580 [ # # ]: 0 : pViewShell->SetPDFExportOption( sal_True );
2581 [ # # ]: 0 : bool bOrigStatus = pRenderDocShell->IsEnableSetModified();
2582 : : // check configuration: shall update of printing information in DocInfo set the document to "modified"?
2583 : 0 : bool bStateChanged = false;
2584 [ # # ][ # # ]: 0 : if ( bOrigStatus && !SvtPrintWarningOptions().IsModifyDocumentOnPrintingAllowed() )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
2585 : : {
2586 [ # # ]: 0 : pRenderDocShell->EnableSetModified( sal_False );
2587 : 0 : bStateChanged = true;
2588 : : }
2589 : :
2590 : : // #122919# Force field update before PDF export
2591 [ # # ]: 0 : pViewShell->ViewShell::UpdateFlds(sal_True);
2592 [ # # ]: 0 : if( bStateChanged )
2593 [ # # ]: 0 : pRenderDocShell->EnableSetModified( sal_True );
2594 : :
2595 : : // there is some redundancy between those two function calls, but right now
2596 : : // there is no time to sort this out.
2597 : : //TODO: check what exatly needs to be done and make just one function for that
2598 [ # # ]: 0 : pViewShell->CalcLayout();
2599 [ # # ][ # # ]: 0 : pViewShell->CalcPagesForPrint( pViewShell->GetPageCount() );
2600 : :
2601 [ # # ]: 0 : pViewShell->SetPDFExportOption( sal_False );
2602 : :
2603 : : // enable view again
2604 [ # # ]: 0 : pViewShell->EndAction();
2605 : : }
2606 : :
2607 [ # # ]: 0 : const sal_Int32 nPageCount = pViewShell->GetPageCount();
2608 : :
2609 : : //
2610 : : // get number of pages to be rendered
2611 : : //
2612 [ # # ]: 0 : const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false );
2613 [ # # ]: 0 : if (bPrintProspect)
2614 : : {
2615 [ # # ][ # # ]: 0 : pDoc->CalculatePagePairsForProspectPrinting( *pViewShell->GetLayout(), *m_pRenderData, *m_pPrintUIOptions, nPageCount );
2616 : 0 : nRet = m_pRenderData->GetPagePairsForProspectPrinting().size();
2617 : : }
2618 : : else
2619 : : {
2620 [ # # ]: 0 : const sal_Int16 nPostItMode = (sal_Int16) m_pPrintUIOptions->getIntValue( "PrintAnnotationMode", 0 );
2621 [ # # ]: 0 : if (nPostItMode != POSTITS_NONE)
2622 : : {
2623 [ # # ]: 0 : OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions );
2624 [ # # ]: 0 : m_pRenderData->CreatePostItData( pDoc, pViewShell->GetViewOptions(), pOutDev );
2625 : : }
2626 : :
2627 : : // get set of valid document pages (according to the current settings)
2628 : : // and their start frames
2629 [ # # ][ # # ]: 0 : pDoc->CalculatePagesForPrinting( *pViewShell->GetLayout(), *m_pRenderData, *m_pPrintUIOptions, bIsPDFExport, nPageCount );
2630 : :
2631 [ # # ]: 0 : if (nPostItMode != POSTITS_NONE)
2632 : : {
2633 : : pDoc->UpdatePagesForPrintingWithPostItData( *m_pRenderData,
2634 [ # # ]: 0 : *m_pPrintUIOptions, bIsPDFExport, nPageCount );
2635 : : }
2636 : :
2637 : 0 : nRet = m_pRenderData->GetPagesToPrint().size();
2638 : : }
2639 : : }
2640 : : OSL_ENSURE( nRet >= 0, "negative number of pages???" );
2641 : :
2642 [ # # ]: 0 : return nRet;
2643 : : }
2644 : :
2645 : 0 : uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
2646 : : sal_Int32 nRenderer,
2647 : : const uno::Any& rSelection,
2648 : : const uno::Sequence< beans::PropertyValue >& rxOptions )
2649 : : throw (IllegalArgumentException, RuntimeException)
2650 : : {
2651 [ # # ]: 0 : SolarMutexGuard aGuard;
2652 [ # # ]: 0 : if(!IsValid())
2653 : : {
2654 : : throw DisposedException( ::rtl::OUString(),
2655 [ # # ][ # # ]: 0 : static_cast< XTextDocument* >(this) );
2656 : : }
2657 : :
2658 [ # # ]: 0 : const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" );
2659 : 0 : bool bIsSwSrcView = false;
2660 [ # # ]: 0 : SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport );
2661 : :
2662 : : // m_pRenderData should NOT be created here!
2663 : : // That should only be done in getRendererCount. If this function is called before
2664 : : // getRendererCount was called then the caller will probably just retrieve the extra UI options
2665 : : // and is not interested in getting valid information about the other data that would
2666 : : // otherwise be provided here!
2667 : : // if( ! m_pRenderData )
2668 : : // m_pRenderData = new SwRenderData;
2669 [ # # ]: 0 : if (!m_pPrintUIOptions)
2670 [ # # ]: 0 : m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView );
2671 [ # # ]: 0 : m_pPrintUIOptions->processProperties( rxOptions );
2672 [ # # ]: 0 : const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false );
2673 [ # # ]: 0 : const bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport );
2674 [ # # ]: 0 : const bool bPrintPaperFromSetup = m_pPrintUIOptions->getBoolValue( "PrintPaperFromSetup", false );
2675 : :
2676 [ # # ]: 0 : SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport );
2677 : : OSL_ENSURE( pDoc && pView, "doc or view shell missing!" );
2678 [ # # ][ # # ]: 0 : if (!pDoc || !pView)
2679 [ # # ]: 0 : return uno::Sequence< beans::PropertyValue >();
2680 : :
2681 : : // due to #110067# (document page count changes sometimes during
2682 : : // PDF export/printing) we can not check for the upper bound properly.
2683 : : // Thus instead of throwing the exception we silently return.
2684 [ # # ]: 0 : if (0 > nRenderer)
2685 [ # # ]: 0 : throw IllegalArgumentException();
2686 : :
2687 : : // TODO/mba: we really need a generic way to get the ViewShell!
2688 : 0 : ViewShell* pVwSh = 0;
2689 [ # # ][ # # ]: 0 : SwView* pSwView = PTR_CAST(SwView, pView);
[ # # ][ # # ]
2690 [ # # ]: 0 : if ( pSwView )
2691 : 0 : pVwSh = pSwView->GetWrtShellPtr();
2692 : : else
2693 : 0 : pVwSh = ((SwPagePreView*)pView)->GetViewShell();
2694 : :
2695 : 0 : sal_Int32 nMaxRenderer = 0;
2696 [ # # ][ # # ]: 0 : if (!bIsSwSrcView && m_pRenderData)
2697 : : {
2698 : : OSL_ENSURE( m_pRenderData, "m_pRenderData missing!!" );
2699 : : nMaxRenderer = bPrintProspect?
2700 : 0 : m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 :
2701 [ # # ]: 0 : m_pRenderData->GetPagesToPrint().size() - 1;
2702 : : }
2703 : : // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print
2704 : : // we obmit checking of the upper bound in this case.
2705 [ # # ][ # # ]: 0 : if (!bIsSwSrcView && m_pRenderData && nRenderer > nMaxRenderer)
[ # # ]
2706 [ # # ]: 0 : return uno::Sequence< beans::PropertyValue >();
2707 : :
2708 [ # # ]: 0 : uno::Sequence< beans::PropertyValue > aRenderer;
2709 [ # # ]: 0 : if (m_pRenderData)
2710 : : {
2711 : : // #i114210#
2712 : : // determine the correct page number from the renderer index
2713 : : // --> OD 2010-10-01 #i114875
2714 : : // consider brochure print
2715 : : const sal_uInt16 nPage = bPrintProspect
2716 : : ? nRenderer + 1
2717 [ # # ][ # # ]: 0 : : m_pRenderData->GetPagesToPrint()[ nRenderer ];
2718 : :
2719 : : // get paper tray to use ...
2720 : 0 : sal_Int32 nPrinterPaperTray = -1;
2721 [ # # ]: 0 : if (! bPrintPaperFromSetup)
2722 : : {
2723 : : // ... from individual page style (see the page tab in Format/Page dialog)
2724 : 0 : const std::map< sal_Int32, sal_Int32 > &rPaperTrays = m_pRenderData->GetPrinterPaperTrays();
2725 [ # # ]: 0 : std::map< sal_Int32, sal_Int32 >::const_iterator aIt( rPaperTrays.find( nPage ) );
2726 [ # # ][ # # ]: 0 : if (aIt != rPaperTrays.end())
2727 [ # # ]: 0 : nPrinterPaperTray = aIt->second;
2728 : : }
2729 : :
2730 : 0 : awt::Size aPageSize;
2731 : 0 : awt::Size aPreferredPageSize;
2732 : 0 : Size aTmpSize;
2733 [ # # ][ # # ]: 0 : if (bIsSwSrcView || bPrintProspect)
2734 : : {
2735 : : // for printing of HTML source code and prospect printing we should use
2736 : : // the printers paper size since
2737 : : // a) HTML source view has no page size
2738 : : // b) prospect printing has a different page size from the documents page
2739 : : // since two document pages will get rendered on one printer page
2740 : :
2741 : : // since PageIncludesNonprintableArea will be set to true we can return the
2742 : : // printers paper size here.
2743 : : // Sometimes 'getRenderer' is only called to get "ExtraPrintUIOptions", in this
2744 : : // case we won't get an OutputDevice here, but then the caller also has no need
2745 : : // for the correct PageSisze right now...
2746 [ # # ][ # # ]: 0 : Printer *pPrinter = dynamic_cast< Printer * >(lcl_GetOutputDevice( *m_pPrintUIOptions ));
2747 [ # # ]: 0 : if (pPrinter)
2748 : : {
2749 : : // HTML source view and prospect adapt to the printer's paper size
2750 [ # # ]: 0 : aTmpSize = pPrinter->GetPaperSize();
2751 : : aTmpSize = pPrinter->LogicToLogic( aTmpSize,
2752 [ # # ][ # # ]: 0 : pPrinter->GetMapMode(), MapMode( MAP_100TH_MM ));
[ # # ]
2753 : 0 : aPageSize = awt::Size( aTmpSize.Width(), aTmpSize.Height() );
2754 : : #if 0
2755 : : // #i115048# it seems users didn't like getting double the formatted page size
2756 : : // revert to "old" behavior scaling to the current paper size of the printer
2757 : : if (bPrintProspect)
2758 : : {
2759 : : // we just state what output size we would need
2760 : : // which may cause vcl to set that page size on the printer
2761 : : // (if available and not overriden by the user)
2762 : : aTmpSize = pVwSh->GetPageSize( nPage, bIsSkipEmptyPages );
2763 : : aPreferredPageSize = awt::Size ( TWIP_TO_MM100( 2 * aTmpSize.Width() ),
2764 : : TWIP_TO_MM100( aTmpSize.Height() ));
2765 : : }
2766 : : #else
2767 [ # # ]: 0 : if( bPrintProspect )
2768 : : {
2769 : : // just switch to an appropriate portrait/landscape format
2770 : : // FIXME: brochure printing with landscape pages puts the
2771 : : // pages next to each other, so landscape is currently always
2772 : : // the better choice
2773 [ # # ]: 0 : if( aPageSize.Width < aPageSize.Height )
2774 : : {
2775 : 0 : aPreferredPageSize.Width = aPageSize.Height;
2776 : 0 : aPreferredPageSize.Height = aPageSize.Width;
2777 : : }
2778 : : }
2779 : : #endif
2780 : 0 : }
2781 : : }
2782 : : else
2783 : : {
2784 [ # # ]: 0 : aTmpSize = pVwSh->GetPageSize( nPage, bIsSkipEmptyPages );
2785 : 0 : aPageSize = awt::Size ( TWIP_TO_MM100( aTmpSize.Width() ),
2786 [ # # ][ # # ]: 0 : TWIP_TO_MM100( aTmpSize.Height() ));
2787 : : }
2788 : :
2789 : 0 : sal_Int32 nLen = 2;
2790 [ # # ]: 0 : aRenderer.realloc(2);
2791 [ # # ][ # # ]: 0 : aRenderer[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) );
2792 [ # # ][ # # ]: 0 : aRenderer[0].Value <<= aPageSize;
2793 [ # # ][ # # ]: 0 : aRenderer[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageIncludesNonprintableArea" ) );
2794 [ # # ][ # # ]: 0 : aRenderer[1].Value <<= sal_True;
2795 [ # # ][ # # ]: 0 : if (aPreferredPageSize.Width && aPreferredPageSize.Height)
2796 : : {
2797 : 0 : ++nLen;
2798 [ # # ]: 0 : aRenderer.realloc( nLen );
2799 [ # # ][ # # ]: 0 : aRenderer[ nLen - 1 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PreferredPageSize" ) );
2800 [ # # ][ # # ]: 0 : aRenderer[ nLen - 1 ].Value <<= aPreferredPageSize;
2801 : : }
2802 [ # # ]: 0 : if (nPrinterPaperTray >= 0)
2803 : : {
2804 : 0 : ++nLen;
2805 [ # # ]: 0 : aRenderer.realloc( nLen );
2806 [ # # ][ # # ]: 0 : aRenderer[ nLen - 1 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PrinterPaperTray" ) );
2807 [ # # ][ # # ]: 0 : aRenderer[ nLen - 1 ].Value <<= nPrinterPaperTray;
2808 : : }
2809 : : }
2810 : :
2811 [ # # ]: 0 : m_pPrintUIOptions->appendPrintUIOptions( aRenderer );
2812 : :
2813 [ # # ][ # # ]: 0 : return aRenderer;
[ # # ]
2814 : : }
2815 : :
2816 : 0 : SfxViewShell * SwXTextDocument::GuessViewShell(
2817 : : /* out */ bool &rbIsSwSrcView,
2818 : : const uno::Reference< css::frame::XController > xController )
2819 : : {
2820 : : // #130810# SfxViewShell::Current() / SfxViewShell::GetObjectShell()
2821 : : // must not be used (see comment from MBA)
2822 : : //
2823 : 0 : SfxViewShell *pView = 0;
2824 : 0 : SwView *pSwView = 0;
2825 : 0 : SwPagePreView *pSwPagePreView = 0;
2826 : 0 : SwSrcView *pSwSrcView = 0;
2827 : 0 : SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pDocShell, sal_False );
2828 : :
2829 : : // look for the view shell with the same controller in use,
2830 : : // otherwise look for a suitable view, preferably a SwView,
2831 : : // if that one is not found use a SwPagePreView if found.
2832 [ # # ]: 0 : while (pFrame)
2833 : : {
2834 : 0 : pView = pFrame->GetViewShell();
2835 [ # # ]: 0 : pSwView = dynamic_cast< SwView * >(pView);
2836 [ # # ]: 0 : pSwSrcView = dynamic_cast< SwSrcView * >(pView);
2837 [ # # ]: 0 : if (!pSwPagePreView)
2838 [ # # ]: 0 : pSwPagePreView = dynamic_cast< SwPagePreView * >(pView);
2839 [ # # ]: 0 : if (xController.is())
2840 : : {
2841 [ # # ][ # # ]: 0 : if (pView && pView->GetController() == xController)
[ # # ][ # # ]
[ # # ]
[ # # # # ]
2842 : 0 : break;
2843 : : }
2844 [ # # ][ # # ]: 0 : else if (pSwView || pSwSrcView)
2845 : 0 : break;
2846 : 0 : pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell, sal_False );
2847 : : }
2848 : :
2849 : : OSL_ENSURE( pSwView || pSwPagePreView || pSwSrcView, "failed to get view shell" );
2850 [ # # ]: 0 : if (pView)
2851 : 0 : rbIsSwSrcView = pSwSrcView != 0;
2852 : 0 : return pView;
2853 : : }
2854 : :
2855 : 0 : void SAL_CALL SwXTextDocument::render(
2856 : : sal_Int32 nRenderer,
2857 : : const uno::Any& rSelection,
2858 : : const uno::Sequence< beans::PropertyValue >& rxOptions )
2859 : : throw (IllegalArgumentException, RuntimeException)
2860 : : {
2861 [ # # ]: 0 : SolarMutexGuard aGuard;
2862 [ # # ]: 0 : if(!IsValid())
2863 : : {
2864 : : throw DisposedException( ::rtl::OUString(),
2865 [ # # ][ # # ]: 0 : static_cast< XTextDocument* >(this) );
2866 : : }
2867 : :
2868 : : // due to #110067# (document page count changes sometimes during
2869 : : // PDF export/printing) we can not check for the upper bound properly.
2870 : : // Thus instead of throwing the exception we silently return.
2871 [ # # ]: 0 : if (0 > nRenderer)
2872 [ # # ]: 0 : throw IllegalArgumentException();
2873 : :
2874 [ # # ]: 0 : const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" );
2875 : 0 : bool bIsSwSrcView = false;
2876 [ # # ]: 0 : SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport );
2877 : :
2878 : : OSL_ENSURE( m_pRenderData, "data should have been created already in getRendererCount..." );
2879 : : OSL_ENSURE( m_pPrintUIOptions, "data should have been created already in getRendererCount..." );
2880 [ # # ][ # # ]: 0 : if (!bIsSwSrcView && !m_pRenderData)
2881 [ # # ][ # # ]: 0 : m_pRenderData = new SwRenderData;
2882 [ # # ]: 0 : if (!m_pPrintUIOptions)
2883 [ # # ]: 0 : m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView );
2884 [ # # ]: 0 : m_pPrintUIOptions->processProperties( rxOptions );
2885 [ # # ]: 0 : const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false );
2886 [ # # ]: 0 : const bool bLastPage = m_pPrintUIOptions->getBoolValue( "IsLastPage", sal_False );
2887 : :
2888 [ # # ]: 0 : SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport );
2889 : : OSL_ENSURE( pDoc && pView, "doc or view shell missing!" );
2890 [ # # ][ # # ]: 0 : if (pDoc && pView)
2891 : : {
2892 : 0 : sal_Int32 nMaxRenderer = 0;
2893 [ # # ]: 0 : if (!bIsSwSrcView)
2894 : : {
2895 : : OSL_ENSURE( m_pRenderData, "m_pRenderData missing!!" );
2896 : : nMaxRenderer = bPrintProspect?
2897 : 0 : m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 :
2898 [ # # ]: 0 : m_pRenderData->GetPagesToPrint().size() - 1;
2899 : : }
2900 : : // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print
2901 : : // we obmit checking of the upper bound in this case.
2902 [ # # ][ # # ]: 0 : if (bIsSwSrcView || nRenderer <= nMaxRenderer)
2903 : : {
2904 [ # # ]: 0 : if (bIsSwSrcView)
2905 : : {
2906 [ # # ]: 0 : SwSrcView *pSwSrcView = dynamic_cast< SwSrcView * >(pView);
2907 [ # # ]: 0 : OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions );
2908 [ # # ]: 0 : pSwSrcView->PrintSource( pOutDev, nRenderer + 1, false );
2909 : : }
2910 : : else
2911 : : {
2912 : : // the view shell should be SwView for documents PDF export
2913 : : // or SwPagePreView for PDF export of the page preview
2914 : : //!! (check for SwView first as in GuessViewShell) !!
2915 : : OSL_ENSURE( pView, "!! view missing !!" );
2916 [ # # ]: 0 : const TypeId aSwViewTypeId = TYPE(SwView);
2917 : 0 : ViewShell* pVwSh = 0;
2918 [ # # ]: 0 : if (pView)
2919 : : {
2920 : : // TODO/mba: we really need a generic way to get the ViewShell!
2921 [ # # ][ # # ]: 0 : SwView* pSwView = PTR_CAST(SwView, pView);
[ # # ][ # # ]
2922 [ # # ]: 0 : if ( pSwView )
2923 : 0 : pVwSh = pSwView->GetWrtShellPtr();
2924 : : else
2925 : 0 : pVwSh = ((SwPagePreView*)pView)->GetViewShell();
2926 : : }
2927 : :
2928 : : // get output device to use
2929 [ # # ]: 0 : OutputDevice * pOut = lcl_GetOutputDevice( *m_pPrintUIOptions );
2930 : :
2931 [ # # ][ # # ]: 0 : if(pVwSh && pOut && m_pRenderData->HasSwPrtOptions())
[ # # ][ # # ]
[ # # ]
2932 : : {
2933 [ # # ]: 0 : const rtl::OUString aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() );
2934 [ # # ]: 0 : const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage", sal_False );
2935 [ # # ]: 0 : bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport );
2936 : :
2937 : : OSL_ENSURE(( pView->IsA(aSwViewTypeId) && m_pRenderData->IsViewOptionAdjust())
2938 : : || (!pView->IsA(aSwViewTypeId) && !m_pRenderData->IsViewOptionAdjust()),
2939 : : "SwView / SwViewOptionAdjust_Impl availability mismatch" );
2940 : :
2941 : : // since printing now also use the API for PDF export this option
2942 : : // should be set for printing as well ...
2943 [ # # ]: 0 : pVwSh->SetPDFExportOption( sal_True );
2944 : :
2945 : : // #i12836# enhanced pdf export
2946 : : //
2947 : : // First, we have to export hyperlinks, notes, and outline to pdf.
2948 : : // During this process, additional information required for tagging
2949 : : // the pdf file are collected, which are evaulated during painting.
2950 : : //
2951 [ # # ]: 0 : SwWrtShell* pWrtShell = pView->IsA(aSwViewTypeId) ?
2952 : 0 : ((SwView*)pView)->GetWrtShellPtr() :
2953 [ # # ]: 0 : 0;
2954 : :
2955 [ # # ][ # # ]: 0 : if (bIsPDFExport && bFirstPage && pWrtShell)
[ # # ]
2956 : : {
2957 [ # # ][ # # ]: 0 : SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_False );
2958 : : }
2959 : :
2960 : : SwPrintData const& rSwPrtOptions =
2961 [ # # ]: 0 : *m_pRenderData->GetSwPrtOptions();
2962 [ # # ]: 0 : if (bPrintProspect)
2963 [ # # ]: 0 : pVwSh->PrintProspect( pOut, rSwPrtOptions, nRenderer );
2964 : : else // normal printing and PDF export
2965 [ # # ]: 0 : pVwSh->PrintOrPDFExport( pOut, rSwPrtOptions, nRenderer );
2966 : :
2967 : : // #i35176#
2968 : : //
2969 : : // After printing the last page, we take care for the links coming
2970 : : // from the EditEngine. The links are generated during the painting
2971 : : // process, but the destinations are still missing.
2972 : : //
2973 [ # # ][ # # ]: 0 : if (bIsPDFExport && bLastPage && pWrtShell)
[ # # ]
2974 : : {
2975 [ # # ][ # # ]: 0 : SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_True );
2976 : : }
2977 : :
2978 [ # # ]: 0 : pVwSh->SetPDFExportOption( sal_False );
2979 : :
2980 : : // last page to be rendered? (not necessarily the last page of the document)
2981 : : // -> do clean-up of data
2982 [ # # ]: 0 : if (bLastPage)
2983 : : {
2984 : : // #i96167# haggai: delete ViewOptionsAdjust here because it makes use
2985 : : // of the shell, which might get destroyed in lcl_DisposeView!
2986 [ # # ][ # # ]: 0 : if (m_pRenderData && m_pRenderData->IsViewOptionAdjust())
[ # # ][ # # ]
2987 [ # # ]: 0 : m_pRenderData->ViewOptionAdjustStop();
2988 : :
2989 [ # # ][ # # ]: 0 : if (m_pRenderData && m_pRenderData->HasPostItData())
[ # # ][ # # ]
2990 [ # # ]: 0 : m_pRenderData->DeletePostItData();
2991 [ # # ]: 0 : if (m_pHiddenViewFrame)
2992 : : {
2993 [ # # ]: 0 : lcl_DisposeView( m_pHiddenViewFrame, pDocShell );
2994 : 0 : m_pHiddenViewFrame = 0;
2995 : :
2996 : : // prevent crash described in #i108805
2997 : 0 : SwDocShell *pRenderDocShell = pDoc->GetDocShell();
2998 [ # # ]: 0 : SfxItemSet *pSet = pRenderDocShell->GetMedium()->GetItemSet();
2999 [ # # ][ # # ]: 0 : pSet->Put( SfxBoolItem( SID_HIDDEN, sal_False ) );
[ # # ]
3000 : :
3001 : : }
3002 : 0 : }
3003 : : }
3004 : : }
3005 : : }
3006 : : }
3007 [ # # ]: 0 : if( bLastPage )
3008 : : {
3009 [ # # ][ # # ]: 0 : delete m_pRenderData; m_pRenderData = NULL;
3010 [ # # ][ # # ]: 0 : delete m_pPrintUIOptions; m_pPrintUIOptions = NULL;
3011 [ # # ]: 0 : }
3012 : 0 : }
3013 : :
3014 : : // xforms::XFormsSupplier
3015 : 40 : Reference<XNameContainer> SAL_CALL SwXTextDocument::getXForms()
3016 : : throw( RuntimeException )
3017 : : {
3018 [ + - ]: 40 : SolarMutexGuard aGuard;
3019 [ - + ]: 40 : if ( !pDocShell )
3020 [ # # ][ # # ]: 0 : throw DisposedException( ::rtl::OUString(), static_cast< XTextDocument* >( this ) );
3021 : 40 : SwDoc* pDoc = pDocShell->GetDoc();
3022 [ + - ][ + - ]: 40 : return pDoc->getXForms();
3023 : : }
3024 : :
3025 : 3755 : uno::Reference< text::XFlatParagraphIterator > SAL_CALL SwXTextDocument::getFlatParagraphIterator(::sal_Int32 nTextMarkupType, sal_Bool bAutomatic)
3026 : : throw ( uno::RuntimeException )
3027 : : {
3028 [ + - ]: 3755 : SolarMutexGuard aGuard;
3029 [ + - ][ + - ]: 3755 : return new SwXFlatParagraphIterator( *pDocShell->GetDoc(), nTextMarkupType, bAutomatic );
[ + - ][ + - ]
3030 : : }
3031 : :
3032 : 0 : uno::Reference< util::XCloneable > SwXTextDocument::createClone( ) throw (uno::RuntimeException)
3033 : : {
3034 [ # # ]: 0 : SolarMutexGuard aGuard;
3035 [ # # ]: 0 : if(!IsValid())
3036 [ # # ]: 0 : throw RuntimeException();
3037 : :
3038 : : // create a new document - hidden - copy the storage and return it
3039 : : // SfxObjectShellRef is used here, since the model should control object lifetime after creation
3040 : : // and thus SfxObjectShellLock is not allowed here
3041 : : // the model holds reference to the shell, so the shell will not destructed at the end of method
3042 [ # # ]: 0 : SfxObjectShellRef pShell = pDocShell->GetDoc()->CreateCopy(false);
3043 [ # # ]: 0 : uno::Reference< frame::XModel > xNewModel = pShell->GetModel();
3044 [ # # ]: 0 : uno::Reference< embed::XStorage > xNewStorage = ::comphelper::OStorageHelper::GetTemporaryStorage( );
3045 [ # # ]: 0 : uno::Sequence< beans::PropertyValue > aTempMediaDescriptor;
3046 [ # # ]: 0 : storeToStorage( xNewStorage, aTempMediaDescriptor );
3047 [ # # ]: 0 : uno::Reference< document::XStorageBasedDocument > xStorageDoc( xNewModel, uno::UNO_QUERY );
3048 [ # # ][ # # ]: 0 : xStorageDoc->loadFromStorage( xNewStorage, aTempMediaDescriptor );
3049 [ # # ][ # # ]: 0 : return uno::Reference< util::XCloneable >( xNewModel, UNO_QUERY );
[ # # ][ # # ]
3050 : : }
3051 : :
3052 : 1553 : void * SAL_CALL SwXTextDocument::operator new( size_t t) throw()
3053 : : {
3054 : 1553 : return SwXTextDocumentBaseClass::operator new(t);
3055 : : }
3056 : :
3057 : 1162 : void SAL_CALL SwXTextDocument::operator delete( void * p) throw()
3058 : : {
3059 : 1162 : SwXTextDocumentBaseClass::operator delete(p);
3060 : 1162 : }
3061 : :
3062 : : /*---------------------------------------------------
3063 : : retrieve languages already used in current document
3064 : : -----------------------------------------------------*/
3065 : 0 : uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages(
3066 : : ::sal_Int16 nScriptTypes,
3067 : : ::sal_Int16 nMaxCount )
3068 : : throw (lang::IllegalArgumentException, uno::RuntimeException)
3069 : : {
3070 [ # # ]: 0 : SolarMutexGuard aGuard;
3071 : :
3072 : :
3073 : : // possible canonical values for nScriptTypes
3074 : : // any bit wise combination is allowed
3075 : 0 : const sal_Int16 nLatin = 0x001;
3076 : 0 : const sal_Int16 nAsian = 0x002;
3077 : 0 : const sal_Int16 nComplex = 0x004;
3078 : :
3079 : : // script types for which to get the languages
3080 : 0 : const bool bLatin = 0 != (nScriptTypes & nLatin);
3081 : 0 : const bool bAsian = 0 != (nScriptTypes & nAsian);
3082 : 0 : const bool bComplex = 0 != (nScriptTypes & nComplex);
3083 : :
3084 [ # # ][ # # ]: 0 : if (nScriptTypes < nLatin || nScriptTypes > (nLatin | nAsian | nComplex))
3085 [ # # ][ # # ]: 0 : throw IllegalArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nScriptTypes ranges from 1 to 7!")), Reference< XInterface >(), 1);
3086 [ # # ]: 0 : if (!pDocShell)
3087 [ # # ]: 0 : throw DisposedException();
3088 : 0 : SwDoc* pDoc = pDocShell->GetDoc();
3089 : :
3090 : : // avoid duplicate values
3091 [ # # ]: 0 : std::set< LanguageType > aAllLangs;
3092 : :
3093 : : //USER STYLES
3094 : :
3095 : 0 : const SwCharFmts *pFmts = pDoc->GetCharFmts();
3096 [ # # ]: 0 : for(sal_uInt16 i = 0; i < pFmts->size(); ++i)
3097 : : {
3098 : 0 : const SwAttrSet &rAttrSet = (*pFmts)[i]->GetAttrSet();
3099 : 0 : LanguageType nLang = LANGUAGE_DONTKNOW;
3100 [ # # ]: 0 : if (bLatin)
3101 : : {
3102 [ # # ]: 0 : nLang = rAttrSet.GetLanguage( sal_False ).GetLanguage();
3103 [ # # ][ # # ]: 0 : if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3104 [ # # ]: 0 : aAllLangs.insert( nLang );
3105 : : }
3106 [ # # ]: 0 : if (bAsian)
3107 : : {
3108 [ # # ]: 0 : nLang = rAttrSet.GetCJKLanguage( sal_False ).GetLanguage();
3109 [ # # ][ # # ]: 0 : if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3110 [ # # ]: 0 : aAllLangs.insert( nLang );
3111 : : }
3112 [ # # ]: 0 : if (bComplex)
3113 : : {
3114 [ # # ]: 0 : nLang = rAttrSet.GetCTLLanguage( sal_False ).GetLanguage();
3115 [ # # ][ # # ]: 0 : if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3116 [ # # ]: 0 : aAllLangs.insert( nLang );
3117 : : }
3118 : : }
3119 : :
3120 : 0 : const SwTxtFmtColls *pColls = pDoc->GetTxtFmtColls();
3121 [ # # ]: 0 : for (sal_uInt16 i = 0; i < pColls->size(); ++i)
3122 : : {
3123 [ # # ]: 0 : const SwAttrSet &rAttrSet = (*pColls)[i]->GetAttrSet();
3124 : 0 : LanguageType nLang = LANGUAGE_DONTKNOW;
3125 [ # # ]: 0 : if (bLatin)
3126 : : {
3127 [ # # ]: 0 : nLang = rAttrSet.GetLanguage( sal_False ).GetLanguage();
3128 [ # # ][ # # ]: 0 : if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3129 [ # # ]: 0 : aAllLangs.insert( nLang );
3130 : : }
3131 [ # # ]: 0 : if (bAsian)
3132 : : {
3133 [ # # ]: 0 : nLang = rAttrSet.GetCJKLanguage( sal_False ).GetLanguage();
3134 [ # # ][ # # ]: 0 : if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3135 [ # # ]: 0 : aAllLangs.insert( nLang );
3136 : : }
3137 [ # # ]: 0 : if (bComplex)
3138 : : {
3139 [ # # ]: 0 : nLang = rAttrSet.GetCTLLanguage( sal_False ).GetLanguage();
3140 [ # # ][ # # ]: 0 : if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3141 [ # # ]: 0 : aAllLangs.insert( nLang );
3142 : : }
3143 : : }
3144 : :
3145 : : //AUTO STYLES
3146 : : const IStyleAccess::SwAutoStyleFamily aFam[2] =
3147 : : {
3148 : : IStyleAccess::AUTO_STYLE_CHAR,
3149 : : IStyleAccess::AUTO_STYLE_PARA
3150 : 0 : };
3151 [ # # ]: 0 : for (sal_uInt16 i = 0; i < 2; ++i)
3152 : : {
3153 [ # # ]: 0 : std::vector< SfxItemSet_Pointer_t > rStyles;
3154 [ # # ]: 0 : pDoc->GetIStyleAccess().getAllStyles(rStyles, aFam[i]);
3155 [ # # ]: 0 : while (!rStyles.empty())
3156 : : {
3157 [ # # ][ # # ]: 0 : SfxItemSet_Pointer_t pStyle = rStyles.back();
3158 [ # # ]: 0 : rStyles.pop_back();
3159 : 0 : const SfxItemSet *pSet = dynamic_cast< const SfxItemSet * >(pStyle.get());
3160 : :
3161 : 0 : LanguageType nLang = LANGUAGE_DONTKNOW;
3162 [ # # ]: 0 : if (bLatin)
3163 : : {
3164 [ # # ][ # # ]: 0 : nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_LANGUAGE, sal_False )).GetLanguage();
3165 [ # # ][ # # ]: 0 : if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3166 [ # # ]: 0 : aAllLangs.insert( nLang );
3167 : : }
3168 [ # # ]: 0 : if (bAsian)
3169 : : {
3170 [ # # ][ # # ]: 0 : nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CJK_LANGUAGE, sal_False )).GetLanguage();
3171 [ # # ][ # # ]: 0 : if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3172 [ # # ]: 0 : aAllLangs.insert( nLang );
3173 : : }
3174 [ # # ]: 0 : if (bComplex)
3175 : : {
3176 [ # # ][ # # ]: 0 : nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CTL_LANGUAGE, sal_False )).GetLanguage();
3177 [ # # ][ # # ]: 0 : if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3178 [ # # ]: 0 : aAllLangs.insert( nLang );
3179 : : }
3180 [ # # ]: 0 : }
3181 : 0 : }
3182 : :
3183 : : //TODO/mba: it's a strange concept that a view is needed to retrieve core data
3184 : 0 : SwWrtShell *pWrtSh = pDocShell->GetWrtShell();
3185 [ # # ]: 0 : SdrView *pSdrView = pWrtSh->GetDrawView();
3186 : :
3187 [ # # ]: 0 : if( pSdrView )
3188 : : {
3189 : 0 : SdrOutliner* pOutliner = pSdrView->GetTextEditOutliner();
3190 [ # # ]: 0 : if(pOutliner)
3191 : : {
3192 : 0 : EditEngine& rEditEng = (EditEngine&)pOutliner->GetEditEngine();
3193 [ # # ]: 0 : sal_uLong nParCount = pOutliner->GetParagraphCount();
3194 [ # # ]: 0 : for (sal_uLong nPar=0; nPar<nParCount; nPar++)
3195 : : {
3196 : : //every paragraph
3197 [ # # ]: 0 : std::vector<sal_uInt16> aPortions;
3198 [ # # ]: 0 : rEditEng.GetPortions( (sal_uInt16)nPar, aPortions );
3199 : :
3200 [ # # ]: 0 : for ( size_t nPos = aPortions.size(); nPos; )
3201 : : {
3202 : : //every position
3203 : 0 : --nPos;
3204 [ # # ]: 0 : sal_uInt16 nEnd = aPortions[ nPos ];
3205 [ # # ][ # # ]: 0 : sal_uInt16 nStart = nPos ? aPortions[ nPos - 1 ] : 0;
3206 : 0 : ESelection aSelection( (sal_uInt16)nPar, nStart, (sal_uInt16)nPar, nEnd );
3207 [ # # ]: 0 : SfxItemSet aAttr = rEditEng.GetAttribs( aSelection );
3208 : :
3209 : 0 : LanguageType nLang = LANGUAGE_DONTKNOW;
3210 [ # # ]: 0 : if (bLatin)
3211 : : {
3212 [ # # ][ # # ]: 0 : nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE, sal_False )).GetLanguage();
3213 [ # # ][ # # ]: 0 : if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3214 [ # # ]: 0 : aAllLangs.insert( nLang );
3215 : : }
3216 [ # # ]: 0 : if (bAsian)
3217 : : {
3218 [ # # ][ # # ]: 0 : nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE_CJK, sal_False )).GetLanguage();
3219 [ # # ][ # # ]: 0 : if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3220 [ # # ]: 0 : aAllLangs.insert( nLang );
3221 : : }
3222 [ # # ]: 0 : if (bComplex)
3223 : : {
3224 [ # # ][ # # ]: 0 : nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE_CTL, sal_False )).GetLanguage();
3225 [ # # ][ # # ]: 0 : if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3226 [ # # ]: 0 : aAllLangs.insert( nLang );
3227 : : }
3228 [ # # ]: 0 : }
3229 : 0 : }
3230 : : }
3231 : : }
3232 : : // less than nMaxCount languages
3233 [ # # ]: 0 : if (nMaxCount > static_cast< sal_Int16 >( aAllLangs.size() ))
3234 : 0 : nMaxCount = static_cast< sal_Int16 >( aAllLangs.size() );
3235 : :
3236 : : // build return value
3237 [ # # ]: 0 : uno::Sequence< lang::Locale > aLanguages( nMaxCount );
3238 [ # # ]: 0 : lang::Locale* pLanguage = aLanguages.getArray();
3239 [ # # ]: 0 : if (nMaxCount > 0)
3240 : : {
3241 : 0 : sal_Int32 nCount = 0;
3242 [ # # ]: 0 : const SvtLanguageTable aLangTab;
3243 [ # # ][ # # ]: 0 : for (std::set< LanguageType >::const_iterator it = aAllLangs.begin(); it != aAllLangs.end(); ++it)
[ # # ]
3244 : : {
3245 [ # # ]: 0 : if (nCount >= nMaxCount)
3246 : 0 : break;
3247 [ # # ][ # # ]: 0 : if (LANGUAGE_NONE != *it)
3248 : : {
3249 [ # # ][ # # ]: 0 : MsLangId::convertLanguageToLocale( *it, pLanguage[nCount] );
3250 [ # # ][ # # ]: 0 : pLanguage[nCount].Language = aLangTab.GetString( *it );
3251 : 0 : nCount += 1;
3252 : : }
3253 [ # # ]: 0 : }
3254 : : }
3255 : :
3256 [ # # ]: 0 : return aLanguages;
3257 : : }
3258 : :
3259 : 0 : SwXLinkTargetSupplier::SwXLinkTargetSupplier(SwXTextDocument& rxDoc) :
3260 [ # # ][ # # ]: 0 : pxDoc(&rxDoc)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
3261 : : {
3262 [ # # ][ # # ]: 0 : sTables = String(SW_RES(STR_CONTENT_TYPE_TABLE));
[ # # ]
3263 [ # # ][ # # ]: 0 : sFrames = String(SW_RES(STR_CONTENT_TYPE_FRAME));
[ # # ]
3264 [ # # ][ # # ]: 0 : sGraphics = String(SW_RES(STR_CONTENT_TYPE_GRAPHIC));
[ # # ]
3265 [ # # ][ # # ]: 0 : sOLEs = String(SW_RES(STR_CONTENT_TYPE_OLE));
[ # # ]
3266 [ # # ][ # # ]: 0 : sSections = String(SW_RES(STR_CONTENT_TYPE_REGION));
[ # # ]
3267 [ # # ][ # # ]: 0 : sOutlines = String(SW_RES(STR_CONTENT_TYPE_OUTLINE));
[ # # ]
3268 [ # # ][ # # ]: 0 : sBookmarks = String(SW_RES(STR_CONTENT_TYPE_BOOKMARK));
[ # # ]
3269 : 0 : }
3270 : :
3271 [ # # ][ # # ]: 0 : SwXLinkTargetSupplier::~SwXLinkTargetSupplier()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
3272 : : {
3273 [ # # ]: 0 : }
3274 : :
3275 : 0 : Any SwXLinkTargetSupplier::getByName(const OUString& rName)
3276 : : throw( NoSuchElementException, WrappedTargetException, RuntimeException )
3277 : : {
3278 : 0 : Any aRet;
3279 [ # # ]: 0 : if(!pxDoc)
3280 [ # # ]: 0 : throw RuntimeException();
3281 [ # # ]: 0 : String sToCompare(rName);
3282 [ # # ]: 0 : String sSuffix = rtl::OUString('|');
3283 [ # # ][ # # ]: 0 : if(sToCompare == sTables)
3284 : : {
3285 [ # # ]: 0 : sSuffix += rtl::OUString::createFromAscii(pMarkToTable);
3286 : :
3287 : : Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
3288 [ # # ][ # # ]: 0 : pxDoc->getTextTables(), sToCompare, sSuffix );
[ # # ][ # # ]
[ # # ][ # # ]
3289 [ # # ]: 0 : Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
3290 [ # # ]: 0 : aRet.setValue(&xRet, ::getCppuType((Reference<XPropertySet>*)0));
3291 : : }
3292 [ # # ][ # # ]: 0 : else if(sToCompare == sFrames)
3293 : : {
3294 [ # # ]: 0 : sSuffix += rtl::OUString::createFromAscii(pMarkToFrame);
3295 : : Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
3296 [ # # ][ # # ]: 0 : pxDoc->getTextFrames(), sToCompare, sSuffix );
[ # # ][ # # ]
[ # # ][ # # ]
3297 [ # # ]: 0 : Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
3298 [ # # ]: 0 : aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
3299 : : }
3300 [ # # ][ # # ]: 0 : else if(sToCompare == sSections)
3301 : : {
3302 [ # # ]: 0 : sSuffix += rtl::OUString::createFromAscii(pMarkToRegion);
3303 : : Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
3304 [ # # ][ # # ]: 0 : pxDoc->getTextSections(), sToCompare, sSuffix );
[ # # ][ # # ]
[ # # ][ # # ]
3305 [ # # ]: 0 : Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
3306 [ # # ]: 0 : aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
3307 : : }
3308 [ # # ][ # # ]: 0 : else if(sToCompare == sGraphics)
3309 : : {
3310 [ # # ]: 0 : sSuffix += rtl::OUString::createFromAscii(pMarkToGraphic);
3311 : : Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
3312 [ # # ][ # # ]: 0 : pxDoc->getGraphicObjects(), sToCompare, sSuffix );
[ # # ][ # # ]
[ # # ][ # # ]
3313 [ # # ]: 0 : Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
3314 [ # # ]: 0 : aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
3315 : : }
3316 [ # # ][ # # ]: 0 : else if(sToCompare == sOLEs)
3317 : : {
3318 [ # # ]: 0 : sSuffix += rtl::OUString::createFromAscii(pMarkToOLE);
3319 : : Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
3320 [ # # ][ # # ]: 0 : pxDoc->getEmbeddedObjects(), sToCompare, sSuffix );
[ # # ][ # # ]
[ # # ][ # # ]
3321 [ # # ]: 0 : Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
3322 [ # # ]: 0 : aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
3323 : : }
3324 [ # # ][ # # ]: 0 : else if(sToCompare == sOutlines)
3325 : : {
3326 [ # # ]: 0 : sSuffix += rtl::OUString::createFromAscii(pMarkToOutline);
3327 : : Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
3328 [ # # ][ # # ]: 0 : *pxDoc, sToCompare, sSuffix );
[ # # ][ # # ]
[ # # ]
3329 [ # # ]: 0 : Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
3330 [ # # ]: 0 : aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
3331 : : }
3332 [ # # ][ # # ]: 0 : else if(sToCompare == sBookmarks)
3333 : : {
3334 [ # # ]: 0 : sSuffix.Erase();
3335 : : Reference< XNameAccess > xBkms = new SwXLinkNameAccessWrapper(
3336 [ # # ][ # # ]: 0 : pxDoc->getBookmarks(), sToCompare, sSuffix );
[ # # ][ # # ]
[ # # ][ # # ]
3337 [ # # ]: 0 : Reference< XPropertySet > xRet(xBkms, UNO_QUERY);
3338 [ # # ]: 0 : aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
3339 : : }
3340 : : else
3341 [ # # ]: 0 : throw NoSuchElementException();
3342 [ # # ][ # # ]: 0 : return aRet;
3343 : : }
3344 : :
3345 : 0 : Sequence< OUString > SwXLinkTargetSupplier::getElementNames(void)
3346 : : throw( RuntimeException )
3347 : : {
3348 : 0 : Sequence< OUString > aRet(7);
3349 [ # # ]: 0 : OUString* pNames = aRet.getArray();
3350 [ # # ]: 0 : pNames[0] = sTables;
3351 [ # # ]: 0 : pNames[1] = sFrames ;
3352 [ # # ]: 0 : pNames[2] = sGraphics;
3353 [ # # ]: 0 : pNames[3] = sOLEs ;
3354 [ # # ]: 0 : pNames[4] = sSections;
3355 [ # # ]: 0 : pNames[5] = sOutlines;
3356 [ # # ]: 0 : pNames[6] = sBookmarks;
3357 : 0 : return aRet;
3358 : : }
3359 : :
3360 : 0 : sal_Bool SwXLinkTargetSupplier::hasByName(const OUString& rName)
3361 : : throw( RuntimeException )
3362 : : {
3363 [ # # ]: 0 : String sToCompare(rName);
3364 [ # # ][ # # ]: 0 : if( sToCompare == sTables ||
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
3365 [ # # ]: 0 : sToCompare == sFrames ||
3366 [ # # ]: 0 : sToCompare == sGraphics||
3367 [ # # ]: 0 : sToCompare == sOLEs ||
3368 [ # # ]: 0 : sToCompare == sSections ||
3369 [ # # ]: 0 : sToCompare == sOutlines ||
3370 [ # # ]: 0 : sToCompare == sBookmarks )
3371 : 0 : return sal_True;
3372 [ # # ]: 0 : return sal_False;
3373 : : }
3374 : :
3375 : 0 : uno::Type SwXLinkTargetSupplier::getElementType(void)
3376 : : throw( RuntimeException )
3377 : : {
3378 : 0 : return ::getCppuType((Reference< XPropertySet>*)0);
3379 : :
3380 : : }
3381 : :
3382 : 0 : sal_Bool SwXLinkTargetSupplier::hasElements(void) throw( RuntimeException )
3383 : : {
3384 : 0 : return 0 != pxDoc;
3385 : : }
3386 : :
3387 : 0 : OUString SwXLinkTargetSupplier::getImplementationName(void) throw( RuntimeException )
3388 : : {
3389 : 0 : return C2U("SwXLinkTargetSupplier");
3390 : : }
3391 : :
3392 : 0 : sal_Bool SwXLinkTargetSupplier::supportsService(const OUString& rServiceName)
3393 : : throw( RuntimeException )
3394 : : {
3395 : 0 : return (rServiceName == C2U("com.sun.star.document.LinkTargets"));
3396 : : }
3397 : :
3398 : 0 : Sequence< OUString > SwXLinkTargetSupplier::getSupportedServiceNames(void)
3399 : : throw( RuntimeException )
3400 : : {
3401 : 0 : Sequence< OUString > aRet(1);
3402 [ # # ]: 0 : OUString* pNames = aRet.getArray();
3403 [ # # ]: 0 : pNames[0] = C2U("com.sun.star.document.LinkTargets");
3404 : 0 : return aRet;
3405 : : }
3406 : :
3407 : 0 : SwXLinkNameAccessWrapper::SwXLinkNameAccessWrapper(
3408 : : Reference< XNameAccess > xAccess, const String& rLinkDisplayName, String sSuffix ) :
3409 : : xRealAccess(xAccess),
3410 [ # # ]: 0 : pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
3411 : : sLinkSuffix(sSuffix),
3412 : : sLinkDisplayName(rLinkDisplayName),
3413 [ # # ][ # # ]: 0 : pxDoc(0)
3414 : : {
3415 : 0 : }
3416 : :
3417 : 0 : SwXLinkNameAccessWrapper::SwXLinkNameAccessWrapper(SwXTextDocument& rxDoc,
3418 : : const String& rLinkDisplayName, String sSuffix) :
3419 [ # # ]: 0 : pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
3420 : : sLinkSuffix(sSuffix),
3421 : : sLinkDisplayName(rLinkDisplayName),
3422 : : xDoc(&rxDoc),
3423 [ # # ][ # # ]: 0 : pxDoc(&rxDoc)
[ # # ]
3424 : : {
3425 : 0 : }
3426 : :
3427 [ # # ][ # # ]: 0 : SwXLinkNameAccessWrapper::~SwXLinkNameAccessWrapper()
3428 : : {
3429 [ # # ]: 0 : }
3430 : :
3431 : 0 : Any SwXLinkNameAccessWrapper::getByName(const OUString& rName)
3432 : : throw( NoSuchElementException, WrappedTargetException, RuntimeException )
3433 : : {
3434 : 0 : Any aRet;
3435 : 0 : sal_Bool bFound = sal_False;
3436 : : //cut link extension and call the real NameAccess
3437 [ # # ]: 0 : String sParam = rName;
3438 [ # # ]: 0 : String sSuffix(sLinkSuffix);
3439 [ # # ]: 0 : if(sParam.Len() > sSuffix.Len() )
3440 : : {
3441 : 0 : String sCmp = sParam.Copy(sParam.Len() - sSuffix.Len(),
3442 [ # # ]: 0 : sSuffix.Len());
3443 [ # # ][ # # ]: 0 : if(sCmp == sSuffix)
3444 : : {
3445 [ # # ]: 0 : if(pxDoc)
3446 : : {
3447 [ # # ][ # # ]: 0 : sParam = sParam.Copy(0, sParam.Len() - sSuffix.Len());
[ # # ]
3448 [ # # ]: 0 : if(!pxDoc->GetDocShell())
3449 [ # # ]: 0 : throw RuntimeException();
3450 : 0 : SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
3451 [ # # ][ # # ]: 0 : sal_uInt16 nOutlineCount = pDoc->GetNodes().GetOutLineNds().size();
3452 : :
3453 [ # # ][ # # ]: 0 : for (sal_uInt16 i = 0; i < nOutlineCount && !bFound; ++i)
[ # # ]
3454 : : {
3455 [ # # ][ # # ]: 0 : const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
3456 : 0 : const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
3457 [ # # ]: 0 : if(sParam ==
3458 [ # # ][ # # ]: 0 : lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule))
[ # # ]
3459 : : {
3460 [ # # ][ # # ]: 0 : Reference< XPropertySet > xOutline = new SwXOutlineTarget(sParam);
[ # # ]
3461 [ # # ]: 0 : aRet.setValue(&xOutline, ::getCppuType((Reference<XPropertySet>*)0));
3462 : 0 : bFound = sal_True;
3463 : : }
3464 : : }
3465 : : }
3466 : : else
3467 : : {
3468 [ # # ][ # # ]: 0 : aRet = xRealAccess->getByName(sParam.Copy(0, sParam.Len() - sSuffix.Len()));
[ # # ][ # # ]
[ # # ]
3469 : 0 : Reference< XInterface > xInt;
3470 [ # # ][ # # ]: 0 : if(!(aRet >>= xInt))
3471 [ # # ]: 0 : throw RuntimeException();
3472 [ # # ]: 0 : Reference< XPropertySet > xProp(xInt, UNO_QUERY);
3473 [ # # ]: 0 : aRet <<= xProp;
3474 : 0 : bFound = sal_True;
3475 : : }
3476 [ # # ]: 0 : }
3477 : : }
3478 [ # # ]: 0 : if(!bFound)
3479 [ # # ]: 0 : throw NoSuchElementException();
3480 [ # # ][ # # ]: 0 : return aRet;
3481 : : }
3482 : :
3483 : 0 : Sequence< OUString > SwXLinkNameAccessWrapper::getElementNames(void)
3484 : : throw( RuntimeException )
3485 : : {
3486 : 0 : Sequence< OUString > aRet;
3487 [ # # ]: 0 : if(pxDoc)
3488 : : {
3489 [ # # ]: 0 : if(!pxDoc->GetDocShell())
3490 [ # # ]: 0 : throw RuntimeException();
3491 : :
3492 : 0 : SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
3493 [ # # ][ # # ]: 0 : const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
3494 : 0 : sal_uInt16 nOutlineCount = rOutlineNodes.size();
3495 [ # # ]: 0 : aRet.realloc(nOutlineCount);
3496 [ # # ]: 0 : OUString* pResArr = aRet.getArray();
3497 [ # # ]: 0 : String sSuffix = rtl::OUString('|');
3498 [ # # ]: 0 : sSuffix += rtl::OUString::createFromAscii(pMarkToOutline);
3499 : 0 : const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
3500 [ # # ]: 0 : for (sal_uInt16 i = 0; i < nOutlineCount; ++i)
3501 : : {
3502 [ # # ]: 0 : String sEntry = lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule);
3503 [ # # ]: 0 : sEntry += sSuffix;
3504 [ # # ]: 0 : pResArr[i] = sEntry;
3505 [ # # ][ # # ]: 0 : }
3506 : : }
3507 : : else
3508 : : {
3509 [ # # ][ # # ]: 0 : Sequence< OUString > aOrg = xRealAccess->getElementNames();
3510 : 0 : const OUString* pOrgArr = aOrg.getConstArray();
3511 [ # # ]: 0 : aRet.realloc(aOrg.getLength());
3512 [ # # ]: 0 : OUString* pResArr = aRet.getArray();
3513 [ # # ]: 0 : for(long i = 0; i < aOrg.getLength(); i++)
3514 : : {
3515 [ # # ]: 0 : pResArr[i] = pOrgArr[i] + sLinkSuffix;
3516 [ # # ]: 0 : }
3517 : : }
3518 : 0 : return aRet;
3519 : : }
3520 : :
3521 : 0 : sal_Bool SwXLinkNameAccessWrapper::hasByName(const OUString& rName)
3522 : : throw( RuntimeException )
3523 : : {
3524 : 0 : sal_Bool bRet = sal_False;
3525 [ # # ]: 0 : String sParam(rName);
3526 [ # # ]: 0 : if(sParam.Len() > sLinkSuffix.Len() )
3527 : : {
3528 : 0 : String sCmp = sParam.Copy(sParam.Len() - sLinkSuffix.Len(),
3529 [ # # ]: 0 : sLinkSuffix.Len());
3530 [ # # ][ # # ]: 0 : if(sCmp == sLinkSuffix)
3531 : : {
3532 [ # # ][ # # ]: 0 : sParam = sParam.Copy(0, sParam.Len() - sLinkSuffix.Len());
[ # # ]
3533 [ # # ]: 0 : if(pxDoc)
3534 : : {
3535 [ # # ]: 0 : if(!pxDoc->GetDocShell())
3536 [ # # ]: 0 : throw RuntimeException();
3537 : 0 : SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
3538 [ # # ][ # # ]: 0 : sal_uInt16 nOutlineCount = pDoc->GetNodes().GetOutLineNds().size();
3539 : :
3540 [ # # ][ # # ]: 0 : for (sal_uInt16 i = 0; i < nOutlineCount && !bRet; ++i)
[ # # ]
3541 : : {
3542 [ # # ][ # # ]: 0 : const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
3543 : 0 : const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
3544 [ # # ]: 0 : if(sParam ==
3545 [ # # ][ # # ]: 0 : lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule))
[ # # ]
3546 : : {
3547 : 0 : bRet = sal_True;
3548 : : }
3549 : : }
3550 : : }
3551 : : else
3552 : : {
3553 [ # # ][ # # ]: 0 : bRet = xRealAccess->hasByName(sParam);
[ # # ]
3554 : : }
3555 [ # # ]: 0 : }
3556 : : }
3557 [ # # ]: 0 : return bRet;
3558 : : }
3559 : :
3560 : 0 : uno::Type SwXLinkNameAccessWrapper::getElementType(void)
3561 : : throw( RuntimeException )
3562 : : {
3563 : 0 : return ::getCppuType((Reference<XPropertySet>*)0);
3564 : : }
3565 : :
3566 : 0 : sal_Bool SwXLinkNameAccessWrapper::hasElements(void) throw( RuntimeException )
3567 : : {
3568 : 0 : sal_Bool bRet = sal_False;
3569 [ # # ]: 0 : if(pxDoc)
3570 : : {
3571 : : OSL_FAIL("not implemented");
3572 : : }
3573 : : else
3574 : : {
3575 : 0 : bRet = xRealAccess->hasElements();
3576 : : }
3577 : 0 : return bRet;
3578 : : }
3579 : :
3580 : 0 : Reference< XPropertySetInfo > SwXLinkNameAccessWrapper::getPropertySetInfo(void)
3581 : : throw( RuntimeException )
3582 : : {
3583 [ # # ][ # # ]: 0 : static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
[ # # ][ # # ]
3584 : 0 : return xRet;
3585 : : }
3586 : :
3587 : 0 : void SwXLinkNameAccessWrapper::setPropertyValue(
3588 : : const OUString& , const Any& )
3589 : : throw( UnknownPropertyException,
3590 : : PropertyVetoException,
3591 : : IllegalArgumentException,
3592 : : WrappedTargetException,
3593 : : RuntimeException)
3594 : : {
3595 [ # # ]: 0 : throw UnknownPropertyException();
3596 : : }
3597 : :
3598 : 0 : Any lcl_GetDisplayBitmap(String sLinkSuffix)
3599 : : {
3600 : 0 : Any aRet;
3601 [ # # ]: 0 : if(sLinkSuffix.Len())
3602 [ # # ]: 0 : sLinkSuffix.Erase(0, 1);
3603 : 0 : sal_uInt16 nImgId = USHRT_MAX;
3604 : :
3605 [ # # ][ # # ]: 0 : if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToOutline))
3606 : 0 : nImgId = CONTENT_TYPE_OUTLINE;
3607 [ # # ][ # # ]: 0 : else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToTable))
3608 : 0 : nImgId = CONTENT_TYPE_TABLE;
3609 [ # # ][ # # ]: 0 : else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToFrame))
3610 : 0 : nImgId = CONTENT_TYPE_FRAME;
3611 [ # # ][ # # ]: 0 : else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToGraphic))
3612 : 0 : nImgId = CONTENT_TYPE_GRAPHIC;
3613 [ # # ][ # # ]: 0 : else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToRegion))
3614 : 0 : nImgId = CONTENT_TYPE_REGION;
3615 [ # # ][ # # ]: 0 : else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToOLE))
3616 : 0 : nImgId = CONTENT_TYPE_OLE;
3617 [ # # ]: 0 : else if(!sLinkSuffix.Len())
3618 : 0 : nImgId = CONTENT_TYPE_BOOKMARK;
3619 [ # # ]: 0 : if(USHRT_MAX != nImgId)
3620 : : {
3621 : 0 : nImgId += 20000;
3622 [ # # ]: 0 : ImageList aEntryImages( SW_RES(IMG_NAVI_ENTRYBMP) );
3623 [ # # ]: 0 : const Image& rImage = aEntryImages.GetImage( nImgId );
3624 [ # # ][ # # ]: 0 : Bitmap aBitmap( rImage.GetBitmapEx().GetBitmap() );
[ # # ]
3625 [ # # ][ # # ]: 0 : Reference<awt::XBitmap> xBmp = VCLUnoHelper::CreateBitmap( aBitmap );
[ # # ]
3626 [ # # ][ # # ]: 0 : aRet.setValue( &xBmp, ::getCppuType((Reference<awt::XBitmap>*)0) );
[ # # ][ # # ]
3627 : : }
3628 : 0 : return aRet;
3629 : : }
3630 : :
3631 : 0 : Any SwXLinkNameAccessWrapper::getPropertyValue(const OUString& rPropertyName)
3632 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3633 : : {
3634 : 0 : Any aRet;
3635 [ # # ][ # # ]: 0 : if( rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_NAME)))
[ # # ]
3636 : : {
3637 [ # # ][ # # ]: 0 : aRet <<= OUString(sLinkDisplayName);
3638 : : }
3639 [ # # ][ # # ]: 0 : else if( rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_BITMAP)))
[ # # ]
3640 : : {
3641 [ # # ][ # # ]: 0 : aRet = lcl_GetDisplayBitmap(sLinkSuffix);
[ # # ]
3642 : : }
3643 : : else
3644 [ # # ]: 0 : throw UnknownPropertyException();
3645 : 0 : return aRet;
3646 : : }
3647 : :
3648 : 0 : void SwXLinkNameAccessWrapper::addPropertyChangeListener(
3649 : : const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
3650 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3651 : 0 : {}
3652 : :
3653 : 0 : void SwXLinkNameAccessWrapper::removePropertyChangeListener(
3654 : : const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
3655 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3656 : 0 : {}
3657 : :
3658 : 0 : void SwXLinkNameAccessWrapper::addVetoableChangeListener(
3659 : : const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
3660 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3661 : 0 : {}
3662 : :
3663 : 0 : void SwXLinkNameAccessWrapper::removeVetoableChangeListener(
3664 : : const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
3665 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3666 : 0 : {}
3667 : :
3668 : 0 : Reference< XNameAccess > SwXLinkNameAccessWrapper::getLinks(void)
3669 : : throw( RuntimeException )
3670 : : {
3671 : 0 : return (SwXLinkNameAccessWrapper*)this;
3672 : : }
3673 : :
3674 : 0 : OUString SwXLinkNameAccessWrapper::getImplementationName(void) throw( RuntimeException )
3675 : : {
3676 : 0 : return C2U("SwXLinkNameAccessWrapper");
3677 : : }
3678 : :
3679 : 0 : sal_Bool SwXLinkNameAccessWrapper::supportsService(const OUString& rServiceName)
3680 : : throw( RuntimeException )
3681 : : {
3682 : 0 : return (rServiceName == C2U("com.sun.star.document.LinkTargets"));
3683 : : }
3684 : :
3685 : 0 : Sequence< OUString > SwXLinkNameAccessWrapper::getSupportedServiceNames(void)
3686 : : throw( RuntimeException )
3687 : : {
3688 : 0 : Sequence< OUString > aRet(1);
3689 [ # # ]: 0 : OUString* pNames = aRet.getArray();
3690 [ # # ]: 0 : pNames[0] = C2U("com.sun.star.document.LinkTargets");
3691 : 0 : return aRet;
3692 : : }
3693 : :
3694 : 0 : SwXOutlineTarget::SwXOutlineTarget(const String& rOutlineText) :
3695 [ # # ]: 0 : pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
3696 [ # # ]: 0 : sOutlineText(rOutlineText)
3697 : : {
3698 : 0 : }
3699 : :
3700 [ # # ]: 0 : SwXOutlineTarget::~SwXOutlineTarget()
3701 : : {
3702 [ # # ]: 0 : }
3703 : :
3704 : 0 : Reference< XPropertySetInfo > SwXOutlineTarget::getPropertySetInfo(void) throw( RuntimeException )
3705 : : {
3706 [ # # ][ # # ]: 0 : static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
[ # # ][ # # ]
3707 : 0 : return xRet;
3708 : : }
3709 : :
3710 : 0 : void SwXOutlineTarget::setPropertyValue(
3711 : : const OUString& /*PropertyName*/, const Any& /*aValue*/)
3712 : : throw( UnknownPropertyException, PropertyVetoException,
3713 : : IllegalArgumentException, WrappedTargetException, RuntimeException)
3714 : : {
3715 [ # # ]: 0 : throw UnknownPropertyException();
3716 : : }
3717 : :
3718 : 0 : Any SwXOutlineTarget::getPropertyValue(const OUString& rPropertyName)
3719 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3720 : : {
3721 : 0 : Any aRet;
3722 [ # # ][ # # ]: 0 : if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_NAME)))
[ # # ]
3723 [ # # ][ # # ]: 0 : aRet <<= OUString(sOutlineText);
3724 : : else
3725 [ # # ]: 0 : throw UnknownPropertyException();
3726 : 0 : return aRet;
3727 : : }
3728 : :
3729 : 0 : void SwXOutlineTarget::addPropertyChangeListener(
3730 : : const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
3731 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3732 : : {
3733 : 0 : }
3734 : :
3735 : 0 : void SwXOutlineTarget::removePropertyChangeListener(
3736 : : const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
3737 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3738 : : {
3739 : 0 : }
3740 : :
3741 : 0 : void SwXOutlineTarget::addVetoableChangeListener(
3742 : : const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
3743 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3744 : : {
3745 : 0 : }
3746 : :
3747 : 0 : void SwXOutlineTarget::removeVetoableChangeListener(
3748 : : const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
3749 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3750 : : {
3751 : 0 : }
3752 : :
3753 : 0 : OUString SwXOutlineTarget::getImplementationName(void) throw( RuntimeException )
3754 : : {
3755 : 0 : return C2U("SwXOutlineTarget");
3756 : : }
3757 : :
3758 : 0 : sal_Bool SwXOutlineTarget::supportsService(const OUString& ServiceName) throw( RuntimeException )
3759 : : {
3760 : 0 : return C2U("com.sun.star.document.LinkTarget") == ServiceName;
3761 : : }
3762 : :
3763 : 0 : Sequence< OUString > SwXOutlineTarget::getSupportedServiceNames(void) throw( RuntimeException )
3764 : : {
3765 : 0 : Sequence < OUString > aRet(1);
3766 [ # # ]: 0 : OUString* pArray = aRet.getArray();
3767 [ # # ]: 0 : pArray[0] = C2U("com.sun.star.document.LinkTarget");
3768 : :
3769 : 0 : return aRet;
3770 : : }
3771 : :
3772 : 80 : SwXDocumentPropertyHelper::SwXDocumentPropertyHelper(SwDoc& rDoc) :
3773 : 80 : SvxUnoForbiddenCharsTable ( rDoc.getForbiddenCharacterTable() )
3774 [ + - ]: 80 : ,m_pDoc(&rDoc)
3775 : : {
3776 : 80 : }
3777 : :
3778 : 68 : SwXDocumentPropertyHelper::~SwXDocumentPropertyHelper()
3779 : : {
3780 [ - + ]: 136 : }
3781 : :
3782 : 219 : Reference<XInterface> SwXDocumentPropertyHelper::GetDrawTable(short nWhich)
3783 : : {
3784 : 219 : Reference<XInterface> xRet;
3785 [ + - ]: 219 : if(m_pDoc)
3786 : : {
3787 [ + + + + : 219 : switch(nWhich)
+ + + - ]
3788 : : {
3789 : : // #i52858#
3790 : : // assure that Draw model is created, if it doesn't exist.
3791 : : case SW_CREATE_DASH_TABLE :
3792 [ + + ]: 21 : if(!xDashTable.is())
3793 [ + - ][ + - ]: 19 : xDashTable = SvxUnoDashTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
[ + - ]
3794 [ + - ]: 21 : xRet = xDashTable;
3795 : 21 : break;
3796 : : case SW_CREATE_GRADIENT_TABLE :
3797 [ + + ]: 21 : if(!xGradientTable.is())
3798 [ + - ][ + - ]: 19 : xGradientTable = SvxUnoGradientTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
[ + - ]
3799 [ + - ]: 21 : xRet = xGradientTable;
3800 : 21 : break;
3801 : : case SW_CREATE_HATCH_TABLE :
3802 [ + + ]: 24 : if(!xHatchTable.is())
3803 [ + - ][ + - ]: 22 : xHatchTable = SvxUnoHatchTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
[ + - ]
3804 [ + - ]: 24 : xRet = xHatchTable;
3805 : 24 : break;
3806 : : case SW_CREATE_BITMAP_TABLE :
3807 [ + + ]: 21 : if(!xBitmapTable.is())
3808 [ + - ][ + - ]: 19 : xBitmapTable = SvxUnoBitmapTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
[ + - ]
3809 [ + - ]: 21 : xRet = xBitmapTable;
3810 : 21 : break;
3811 : : case SW_CREATE_TRANSGRADIENT_TABLE:
3812 [ + + ]: 21 : if(!xTransGradientTable.is())
3813 [ + - ][ + - ]: 19 : xTransGradientTable = SvxUnoTransGradientTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
[ + - ]
3814 [ + - ]: 21 : xRet = xTransGradientTable;
3815 : 21 : break;
3816 : : case SW_CREATE_MARKER_TABLE :
3817 [ + + ]: 27 : if(!xMarkerTable.is())
3818 [ + - ][ + - ]: 25 : xMarkerTable = SvxUnoMarkerTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
[ + - ]
3819 [ + - ]: 27 : xRet = xMarkerTable;
3820 : 27 : break;
3821 : : case SW_CREATE_DRAW_DEFAULTS:
3822 [ + + ]: 84 : if(!xDrawDefaults.is())
3823 [ + - ]: 73 : xDrawDefaults = (cppu::OWeakObject*)new SwSvxUnoDrawPool(m_pDoc);
3824 [ + - ]: 84 : xRet = xDrawDefaults;
3825 : 219 : break;
3826 : : #if OSL_DEBUG_LEVEL > 0
3827 : : default: OSL_FAIL("which table?");
3828 : : #endif
3829 : : }
3830 : : }
3831 : 219 : return xRet;
3832 : : }
3833 : :
3834 : 68 : void SwXDocumentPropertyHelper::Invalidate()
3835 : : {
3836 : 68 : xDashTable = 0;
3837 : 68 : xGradientTable = 0;
3838 : 68 : xHatchTable = 0;
3839 : 68 : xBitmapTable = 0;
3840 : 68 : xTransGradientTable = 0;
3841 : 68 : xMarkerTable = 0;
3842 : 68 : xDrawDefaults = 0;
3843 : 68 : m_pDoc = 0;
3844 : 68 : SvxUnoForbiddenCharsTable::mxForbiddenChars.clear();
3845 : 68 : }
3846 : :
3847 : 0 : void SwXDocumentPropertyHelper::onChange()
3848 : : {
3849 [ # # ]: 0 : if(m_pDoc)
3850 : 0 : m_pDoc->SetModified();
3851 : 0 : }
3852 : :
3853 : 0 : SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl(
3854 : : ViewShell& rSh, const SwViewOption &rViewOptions)
3855 : : : m_rShell( rSh )
3856 : 0 : , m_aOldViewOptions( rViewOptions )
3857 : : {
3858 : 0 : }
3859 : :
3860 : 0 : SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl()
3861 : : {
3862 [ # # ]: 0 : m_rShell.ApplyViewOptions( m_aOldViewOptions );
3863 : 0 : }
3864 : :
3865 : : void
3866 : 0 : SwViewOptionAdjust_Impl::AdjustViewOptions(SwPrintData const*const pPrtOptions)
3867 : : {
3868 : : // to avoid unnecessary reformatting the view options related to the content
3869 : : // below should only change if necessary, that is if respective content is present
3870 [ # # ]: 0 : const bool bContainsHiddenChars = m_rShell.GetDoc()->ContainsHiddenChars();
3871 [ # # ]: 0 : const SwFieldType* pFldType = m_rShell.GetDoc()->GetSysFldType( RES_HIDDENTXTFLD );
3872 [ # # ][ # # ]: 0 : const bool bContainsHiddenFields = pFldType && pFldType->GetDepends();
3873 [ # # ]: 0 : pFldType = m_rShell.GetDoc()->GetSysFldType( RES_HIDDENPARAFLD );
3874 [ # # ][ # # ]: 0 : const bool bContainsHiddenParagraphs = pFldType && pFldType->GetDepends();
3875 [ # # ]: 0 : pFldType = m_rShell.GetDoc()->GetSysFldType( RES_JUMPEDITFLD );
3876 [ # # ][ # # ]: 0 : const bool bContainsPlaceHolders = pFldType && pFldType->GetDepends();
3877 [ # # ]: 0 : const bool bContainsFields = m_rShell.IsAnyFieldInDoc();
3878 : :
3879 [ # # ]: 0 : SwViewOption aRenderViewOptions( m_aOldViewOptions );
3880 : :
3881 : : // disable anything in the view that should not be printed (or exported to PDF) by default
3882 : : // (see also dialog "Tools/Options - StarOffice Writer - Formatting Aids"
3883 : : // in section "Display of ...")
3884 : 0 : aRenderViewOptions.SetParagraph( sal_False ); // paragraph end
3885 : 0 : aRenderViewOptions.SetSoftHyph( sal_False ); // aka custom hyphens
3886 : 0 : aRenderViewOptions.SetBlank( sal_False ); // spaces
3887 : 0 : aRenderViewOptions.SetHardBlank( sal_False ); // non-breaking spaces
3888 : 0 : aRenderViewOptions.SetTab( sal_False ); // tabs
3889 : 0 : aRenderViewOptions.SetLineBreak( sal_False ); // breaks (type 1)
3890 : 0 : aRenderViewOptions.SetPageBreak( sal_False ); // breaks (type 2)
3891 : 0 : aRenderViewOptions.SetColumnBreak( sal_False ); // breaks (type 3)
3892 [ # # ]: 0 : sal_Bool bVal = pPrtOptions? pPrtOptions->bPrintHiddenText : sal_False;
3893 [ # # ]: 0 : if (bContainsHiddenChars)
3894 : 0 : aRenderViewOptions.SetShowHiddenChar( bVal ); // hidden text
3895 [ # # ]: 0 : if (bContainsHiddenFields)
3896 : 0 : aRenderViewOptions.SetShowHiddenField( bVal );
3897 [ # # ]: 0 : if (bContainsHiddenParagraphs)
3898 : 0 : aRenderViewOptions.SetShowHiddenPara( bVal );
3899 : :
3900 [ # # ]: 0 : if (bContainsPlaceHolders)
3901 : : {
3902 : : // should always be printed in PDF export!
3903 [ # # ]: 0 : bVal = pPrtOptions ? pPrtOptions->bPrintTextPlaceholder : sal_True;
3904 : 0 : aRenderViewOptions.SetShowPlaceHolderFields( bVal );
3905 : : }
3906 : :
3907 [ # # ]: 0 : if (bContainsFields)
3908 : 0 : aRenderViewOptions.SetFldName( sal_False );
3909 : :
3910 : : // we need to set this flag in order to get to see the visible effect of
3911 : : // some of the above settings (needed for correct rendering)
3912 : 0 : aRenderViewOptions.SetViewMetaChars( sal_True );
3913 : :
3914 [ # # ][ # # ]: 0 : if (m_aOldViewOptions != aRenderViewOptions) // check if reformatting is necessary
3915 : : {
3916 : 0 : aRenderViewOptions.SetPrinting( pPrtOptions != NULL );
3917 [ # # ]: 0 : m_rShell.ApplyViewOptions( aRenderViewOptions );
3918 [ # # ]: 0 : }
3919 : 0 : }
3920 : :
3921 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|