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