Update to m13
[ooovba.git] / sw / source / ui / uno / unotxdoc.cxx
blobc22a03bb2c71b32528a79388daa4b9c6a0e27ec9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unotxdoc.cxx,v $
10 * $Revision: 1.134 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
34 #include <cmdid.h>
35 #include <swtypes.hxx>
36 #include <vcl/image.hxx>
37 #include <vcl/virdev.hxx>
38 #include <vcl/svapp.hxx>
39 #include <sfx2/viewfrm.hxx>
40 #ifndef _TOOLKIT_UNOHLP_HXX
41 #include <toolkit/helper/vclunohelper.hxx>
42 #endif
43 #include <wdocsh.hxx>
44 #include <wrtsh.hxx>
45 #include <view.hxx>
46 #include <pview.hxx>
47 #ifndef _SRCVIEW_HXX
48 #include <srcview.hxx>
49 #endif
50 #include <viewsh.hxx>
51 #include <pvprtdat.hxx>
52 #include <swprtopt.hxx>
53 #include <svtools/stritem.hxx>
54 #include <unotxdoc.hxx>
55 #include <svtools/numuno.hxx>
56 #include <unoobj.hxx>
57 #include <unosett.hxx>
58 #include <unocoll.hxx>
59 #include <unoredlines.hxx>
60 #include <unosrch.hxx>
61 #include <toolkit/awt/vclxdevice.hxx>
62 #include <sfx2/dispatch.hxx>
63 #include <sfx2/request.hxx>
64 #include <sfx2/objsh.hxx> // SfxObjectShellRef <-> SV_DECL_REF(SfxObjectShell)
65 #include <unoprnms.hxx>
66 #include <unostyle.hxx>
67 #include <unodraw.hxx>
68 #include <svtools/eitem.hxx>
69 #include <pagedesc.hxx>
70 #include <svtools/txtcmp.hxx>
71 #include <unocrsr.hxx>
72 #include <unofield.hxx>
73 #include <unoidx.hxx>
74 #include <unoflatpara.hxx>
75 #include <poolfmt.hxx>
76 #include <globdoc.hxx>
77 #include <viewopt.hxx>
78 #include <unochart.hxx>
79 #include <doc.hxx>
80 #include <charatr.hxx>
81 #include <svx/xmleohlp.hxx>
83 #include <com/sun/star/util/SearchOptions.hpp>
84 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
85 #include <com/sun/star/lang/DisposedException.hpp>
86 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
87 #ifndef _COM_SUN_STAR_BEANS_PropertyAttribute_HPP_
88 #include <com/sun/star/beans/PropertyAttribute.hpp>
89 #endif
90 #include <com/sun/star/document/RedlineDisplayType.hpp>
91 #include <svx/linkmgr.hxx>
92 #include <svx/unofill.hxx>
93 #include <svx/unolingu.hxx>
94 #include <sfx2/progress.hxx>
95 #include <swmodule.hxx>
96 #include <docstat.hxx>
97 #ifndef _MODOPT_HXX //
98 #include <modcfg.hxx>
99 #endif
100 #include <ndtxt.hxx>
101 #ifndef _UTLUI_HRC
102 #include <utlui.hrc>
103 #endif
104 #include <swcont.hxx>
105 #include <unodefaults.hxx>
106 #include <SwXDocumentSettings.hxx>
107 #include <SwXPrintPreviewSettings.hxx>
108 #include <doc.hxx>
109 #include <svx/forbiddencharacterstable.hxx>
110 #include <svtools/zforlist.hxx>
111 #include <drawdoc.hxx>
112 #include <SwStyleNameMapper.hxx>
113 #include <osl/file.hxx>
115 // --> FME 2004-06-08 #i12836# enhanced pdf export
116 #include <EnhancedPDFExportHelper.hxx>
117 // <--
118 #include <numrule.hxx>
120 ///////////////////////////Modified on Jun. 14th//////////////////////////
121 ///////////////////////for getDocumentLanguages///////////////////////////
122 //-->
123 #include <svx/langitem.hxx>
124 #include <doc.hxx>
125 #include <docary.hxx> //SwCharFmts
126 #include <i18npool/mslangid.hxx>
128 #include <format.hxx>
129 #include <charfmt.hxx> //SwCharFmt
130 #include <fmtcol.hxx> //SwTxtFmtColl
131 #include <unostyle.hxx> //SwAutoStyleFamily
132 #include <istyleaccess.hxx> // handling of automatic styles
134 #include <svtools/stylepool.hxx>
135 #include <swatrset.hxx>
137 //#include <com/sun/star/i18n/ScriptType.hpp>
138 #include <svtools/langtab.hxx>
139 #include <map>
140 #include <set>
142 #include <svx/eeitem.hxx>
143 #include <svx/editeng.hxx>
144 #include <svx/svdoutl.hxx>
145 #include <svtools/languageoptions.hxx>
146 #include <svx/svdview.hxx>
149 //<--
150 using namespace ::com::sun::star;
151 using namespace ::com::sun::star::text;
152 using namespace ::com::sun::star::i18n;
153 using namespace ::com::sun::star::uno;
154 using namespace ::com::sun::star::beans;
155 using namespace ::com::sun::star::lang;
156 using namespace ::com::sun::star::container;
157 using namespace ::com::sun::star::document;
158 using namespace ::com::sun::star::i18n;
159 using ::rtl::OUString;
160 using ::osl::FileBase;
162 /* -----------------------------17.01.01 15:43--------------------------------
164 ---------------------------------------------------------------------------*/
165 #define SW_CREATE_DASH_TABLE 0x01
166 #define SW_CREATE_GRADIENT_TABLE 0x02
167 #define SW_CREATE_HATCH_TABLE 0x03
168 #define SW_CREATE_BITMAP_TABLE 0x04
169 #define SW_CREATE_TRANSGRADIENT_TABLE 0x05
170 #define SW_CREATE_MARKER_TABLE 0x06
171 #define SW_CREATE_DRAW_DEFAULTS 0x07
173 #include <comphelper/processfactory.hxx>
175 /******************************************************************************
177 ******************************************************************************/
178 SwTxtFmtColl *lcl_GetParaStyle(const String& rCollName, SwDoc* pDoc)
180 SwTxtFmtColl* pColl = pDoc->FindTxtFmtCollByName( rCollName );
181 if( !pColl )
183 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rCollName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
184 if( USHRT_MAX != nId )
185 pColl = pDoc->GetTxtCollFromPool( nId );
187 return pColl;
189 void lcl_DisposeView( SfxViewFrame* pToClose, SwDocShell* pDocShell )
191 // check if the view frame still exists
192 SfxViewFrame* pFound = SfxViewFrame::GetFirst( pDocShell,
194 FALSE );
195 while(pFound)
197 if( pFound == pToClose)
199 pToClose->DoClose();
200 break;
202 pFound = SfxViewFrame::GetNext( *pFound,
203 pDocShell,
205 FALSE );
208 /* -----------------------------10.03.00 18:02--------------------------------
210 ---------------------------------------------------------------------------*/
211 const Sequence< sal_Int8 > & SwXTextDocument::getUnoTunnelId()
213 static Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
214 return aSeq;
216 /* -----------------------------10.03.00 18:04--------------------------------
218 ---------------------------------------------------------------------------*/
219 sal_Int64 SAL_CALL SwXTextDocument::getSomething( const Sequence< sal_Int8 >& rId )
220 throw(RuntimeException)
222 if( rId.getLength() == 16
223 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
224 rId.getConstArray(), 16 ) )
226 return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
228 if( rId.getLength() == 16
229 && 0 == rtl_compareMemory( SfxObjectShell::getUnoTunnelId().getConstArray(),
230 rId.getConstArray(), 16 ) )
232 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(pDocShell ));
235 sal_Int64 nRet = SfxBaseModel::getSomething( rId );
236 if ( nRet )
237 return nRet;
238 else
240 GetNumberFormatter();
241 Any aNumTunnel = xNumFmtAgg->queryAggregation(::getCppuType((Reference<XUnoTunnel>*)0));
242 Reference<XUnoTunnel> xNumTunnel;
243 aNumTunnel >>= xNumTunnel;
244 if(xNumTunnel.is())
245 return xNumTunnel->getSomething(rId);
248 return SfxBaseModel::getSomething( rId );
250 /* -----------------------------16.03.00 14:12--------------------------------
252 ---------------------------------------------------------------------------*/
253 Any SAL_CALL SwXTextDocument::queryInterface( const uno::Type& rType ) throw(RuntimeException)
255 Any aRet = SwXTextDocumentBaseClass::queryInterface(rType);
256 if(aRet.getValueType() == getVoidCppuType())
257 aRet = SfxBaseModel::queryInterface(rType);
258 if(aRet.getValueType() == getVoidCppuType() &&
259 rType == ::getCppuType((Reference<lang::XMultiServiceFactory>*)0))
261 Reference<lang::XMultiServiceFactory> xTmp = this;
262 aRet <<= xTmp;
264 if(aRet.getValueType() == getVoidCppuType())
266 GetNumberFormatter();
267 if(xNumFmtAgg.is())
268 aRet = xNumFmtAgg->queryAggregation(rType);
270 return aRet;
272 /* -----------------------------16.03.00 14:12--------------------------------
274 ---------------------------------------------------------------------------*/
275 void SAL_CALL SwXTextDocument::acquire()throw()
277 SfxBaseModel::acquire();
279 /* -----------------------------16.03.00 14:12--------------------------------
281 ---------------------------------------------------------------------------*/
282 void SAL_CALL SwXTextDocument::release()throw()
284 SfxBaseModel::release();
286 /* -----------------------------07.12.00 11:37--------------------------------
288 ---------------------------------------------------------------------------*/
289 Reference< XAdapter > SwXTextDocument::queryAdapter( ) throw(RuntimeException)
291 return SfxBaseModel::queryAdapter();
293 /* -----------------------------16.03.00 14:12--------------------------------
295 ---------------------------------------------------------------------------*/
296 Sequence< uno::Type > SAL_CALL SwXTextDocument::getTypes() throw(RuntimeException)
298 Sequence< uno::Type > aBaseTypes = SfxBaseModel::getTypes();
299 Sequence< uno::Type > aTextTypes = SwXTextDocumentBaseClass::getTypes();
301 Sequence< uno::Type > aNumTypes;
302 GetNumberFormatter();
303 if(xNumFmtAgg.is())
305 const uno::Type& rProvType = ::getCppuType((Reference <XTypeProvider>*)0);
306 Any aNumProv = xNumFmtAgg->queryAggregation(rProvType);
307 Reference<XTypeProvider> xNumProv;
308 if(aNumProv >>= xNumProv)
310 aNumTypes = xNumProv->getTypes();
313 long nIndex = aBaseTypes.getLength();
314 // don't forget the lang::XMultiServiceFactory
315 aBaseTypes.realloc(aBaseTypes.getLength() + aTextTypes.getLength() + aNumTypes.getLength() + 1);
316 uno::Type* pBaseTypes = aBaseTypes.getArray();
317 const uno::Type* pTextTypes = aTextTypes.getConstArray();
318 long nPos;
319 for(nPos = 0; nPos < aTextTypes.getLength(); nPos++)
321 pBaseTypes[nIndex++] = pTextTypes[nPos];
323 const uno::Type* pNumTypes = aNumTypes.getConstArray();
324 for(nPos = 0; nPos < aNumTypes.getLength(); nPos++)
326 pBaseTypes[nIndex++] = pNumTypes[nPos];
328 pBaseTypes[nIndex++] = ::getCppuType((Reference<lang::XMultiServiceFactory>*)0);
329 return aBaseTypes;
331 /*-- 18.12.98 11:52:59---------------------------------------------------
333 -----------------------------------------------------------------------*/
334 SwXTextDocument::SwXTextDocument(SwDocShell* pShell) :
335 SfxBaseModel(pShell),
337 aRefreshCont ( static_cast < XTextDocument* > ( this ) ),
339 aPropSet(aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TEXT_DOCUMENT)),
341 pDocShell(pShell),
343 bObjectValid(pShell != 0),
345 pDrawPage(0),
346 pxXDrawPage(0),
348 pxXNumberingRules(0),
349 pxXFootnotes(0),
350 pxXFootnoteSettings(0),
351 pxXEndnotes(0),
352 pxXEndnoteSettings(0),
353 pxXReferenceMarks(0),
354 pxXTextFieldTypes(0),
355 pxXTextFieldMasters(0),
356 pxXTextSections(0),
357 pxXBookmarks(0),
358 pxXTextTables(0),
359 pxXTextFrames(0),
360 pxXGraphicObjects(0),
361 pxXEmbeddedObjects(0),
362 pxXStyleFamilies(0),
363 pxXAutoStyles(0),
364 pxXChapterNumbering(0),
365 pxXDocumentIndexes(0),
367 pxXLineNumberingProperties(0),
368 pxLinkTargetSupplier(0),
369 pxXRedlines(0),
370 m_pHiddenViewFrame(0)
372 uno::Reference< document::XDocumentProperties > xWriterProps( ::comphelper::getProcessServiceFactory()->createInstance( DEFINE_CONST_UNICODE("com.sun.star.writer.DocumentProperties") ), uno::UNO_QUERY_THROW);
374 SfxBaseModel::setDocumentProperties( xWriterProps );
376 /*-- 18.12.98 11:53:00---------------------------------------------------
378 -----------------------------------------------------------------------*/
379 SwXTextDocument::~SwXTextDocument()
381 InitNewDoc();
382 if(xNumFmtAgg.is())
384 Reference< XInterface > x0;
385 xNumFmtAgg->setDelegator(x0);
386 xNumFmtAgg = 0;
391 /*-- 18.12.98 11:55:08---------------------------------------------------
393 -----------------------------------------------------------------------*/
394 /* -----------------18.12.98 12:49-------------------
396 * --------------------------------------------------*/
397 SwXDocumentPropertyHelper * SwXTextDocument::GetPropertyHelper ()
399 if(!xPropertyHelper.is())
401 pPropertyHelper = new SwXDocumentPropertyHelper(*pDocShell->GetDoc());
402 xPropertyHelper = (cppu::OWeakObject*)pPropertyHelper;
404 return pPropertyHelper;
406 void SwXTextDocument::GetNumberFormatter()
408 if(IsValid())
410 if(!xNumFmtAgg.is())
412 if ( pDocShell->GetDoc() )
414 SvNumberFormatsSupplierObj* pNumFmt = new SvNumberFormatsSupplierObj(
415 pDocShell->GetDoc()->GetNumberFormatter( sal_True ));
416 Reference< util::XNumberFormatsSupplier > xTmp = pNumFmt;
417 xNumFmtAgg = Reference< XAggregation >(xTmp, UNO_QUERY);
419 if(xNumFmtAgg.is())
420 xNumFmtAgg->setDelegator((cppu::OWeakObject*)(SwXTextDocumentBaseClass*)this);
422 else
424 const uno::Type& rTunnelType = ::getCppuType((Reference <XUnoTunnel>*)0);
425 Any aNumTunnel = xNumFmtAgg->queryAggregation(rTunnelType);
426 SvNumberFormatsSupplierObj* pNumFmt = 0;
427 Reference< XUnoTunnel > xNumTunnel;
428 if(aNumTunnel >>= xNumTunnel)
430 pNumFmt = reinterpret_cast<SvNumberFormatsSupplierObj*>(
431 xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
434 DBG_ASSERT(pNumFmt, "No number formatter available");
435 if(!pNumFmt->GetNumberFormatter())
436 pNumFmt->SetNumberFormatter(pDocShell->GetDoc()->GetNumberFormatter( sal_True ));
440 /*-- 18.12.98 11:55:11---------------------------------------------------
442 -----------------------------------------------------------------------*/
443 Reference< XText > SwXTextDocument::getText(void) throw( RuntimeException )
445 ::vos::OGuard aGuard(Application::GetSolarMutex());
446 if(!IsValid())
447 throw RuntimeException();
448 if(!xBodyText.is())
450 pBodyText = new SwXBodyText(pDocShell->GetDoc());
451 xBodyText = pBodyText;
453 return xBodyText;
455 /*-- 18.12.98 11:55:11---------------------------------------------------
457 -----------------------------------------------------------------------*/
458 void SwXTextDocument::reformat(void) throw( RuntimeException )
460 ::vos::OGuard aGuard(Application::GetSolarMutex());
461 if(!IsValid())
462 throw RuntimeException();
464 /*-- 18.12.98 11:55:16---------------------------------------------------
466 -----------------------------------------------------------------------*/
467 void SwXTextDocument::lockControllers(void) throw( RuntimeException )
469 ::vos::OGuard aGuard(Application::GetSolarMutex());
470 if(IsValid())
472 UnoActionContext* pContext = new UnoActionContext(pDocShell->GetDoc());
473 aActionArr.Insert(pContext, 0);
475 else
476 throw RuntimeException();
478 /*-- 18.12.98 11:55:16---------------------------------------------------
480 -----------------------------------------------------------------------*/
481 void SwXTextDocument::unlockControllers(void) throw( RuntimeException )
483 ::vos::OGuard aGuard(Application::GetSolarMutex());
484 if(aActionArr.Count())
486 UnoActionContext* pContext = aActionArr.GetObject(0);
487 aActionArr.Remove(0);
488 delete pContext;
490 else
491 throw RuntimeException();
493 /*-- 18.12.98 11:55:17---------------------------------------------------
495 -----------------------------------------------------------------------*/
496 sal_Bool SwXTextDocument::hasControllersLocked(void) throw( RuntimeException )
498 ::vos::OGuard aGuard(Application::GetSolarMutex());
499 return aActionArr.Count() > 0;
501 /*-- 18.12.98 13:12:23---------------------------------------------------
503 -----------------------------------------------------------------------*/
504 Reference< frame::XController > SwXTextDocument::getCurrentController(void) throw( RuntimeException )
506 return SfxBaseModel::getCurrentController();
508 /*-- 18.12.98 13:12:24---------------------------------------------------
510 -----------------------------------------------------------------------*/
511 void SwXTextDocument::setCurrentController(const Reference< frame::XController > & xController)
512 throw( NoSuchElementException, RuntimeException )
514 SfxBaseModel::setCurrentController(xController);
516 /* -----------------27.01.99 11:48-------------------
518 * --------------------------------------------------*/
519 Reference< XInterface > SwXTextDocument::getCurrentSelection() throw( RuntimeException )
521 ::vos::OGuard aGuard(Application::GetSolarMutex());
522 Reference< XInterface > xRef;
523 if(IsValid())
526 const TypeId aTypeId = TYPE(SwView);
527 SwView* pView = (SwView*)SfxViewShell::GetFirst(&aTypeId);
528 while(pView && pView->GetObjectShell() != pDocShell)
530 pView = (SwView*)SfxViewShell::GetNext(*pView, &aTypeId);
532 if(pView)
534 Any aRef = pView->GetUNOObject()->getSelection();
535 aRef >>= xRef;
538 return xRef;
541 /*-- 18.12.98 13:12:24---------------------------------------------------
543 -----------------------------------------------------------------------*/
544 sal_Bool SwXTextDocument::attachResource(const OUString& aURL, const Sequence< beans::PropertyValue >& aArgs)
545 throw( RuntimeException )
547 return SfxBaseModel::attachResource(aURL, aArgs);
549 /*-- 18.12.98 13:12:24---------------------------------------------------
551 -----------------------------------------------------------------------*/
552 OUString SwXTextDocument::getURL(void) throw( RuntimeException )
554 return SfxBaseModel::getURL();
556 /*-- 18.12.98 13:12:24---------------------------------------------------
558 -----------------------------------------------------------------------*/
559 Sequence< beans::PropertyValue > SwXTextDocument::getArgs(void) throw( RuntimeException )
561 return SfxBaseModel::getArgs();
563 /*-- 18.12.98 13:12:24---------------------------------------------------
565 -----------------------------------------------------------------------*/
566 void SwXTextDocument::connectController(const Reference< frame::XController > & xController) throw( RuntimeException )
568 SfxBaseModel::connectController(xController);
570 /*-- 18.12.98 13:12:25---------------------------------------------------
572 -----------------------------------------------------------------------*/
573 void SwXTextDocument::disconnectController(const Reference< frame::XController > & xController) throw( RuntimeException )
575 SfxBaseModel::disconnectController(xController);
577 /*-- 18.12.98 13:12:25---------------------------------------------------
579 -----------------------------------------------------------------------*/
580 void SwXTextDocument::dispose(void) throw( RuntimeException )
582 SfxBaseModel::dispose();
584 /*-- 10.05.2005 14:14:39---------------------------------------------------
586 -----------------------------------------------------------------------*/
587 void SwXTextDocument::close( sal_Bool bDeliverOwnership ) throw( util::CloseVetoException, RuntimeException )
589 if(IsValid() && m_pHiddenViewFrame)
590 lcl_DisposeView( m_pHiddenViewFrame, pDocShell);
591 SfxBaseModel::close(bDeliverOwnership);
593 /*-- 18.12.98 13:12:25---------------------------------------------------
595 -----------------------------------------------------------------------*/
596 void SwXTextDocument::addEventListener(const Reference< lang::XEventListener > & aListener) throw( RuntimeException )
598 SfxBaseModel::addEventListener(aListener);
600 /*-- 18.12.98 13:12:26---------------------------------------------------
602 -----------------------------------------------------------------------*/
603 void SwXTextDocument::removeEventListener(const Reference< lang::XEventListener > & aListener) throw( RuntimeException )
605 SfxBaseModel::removeEventListener(aListener);
608 /*-- 18.12.98 11:55:19---------------------------------------------------
610 -----------------------------------------------------------------------*/
611 Reference< XPropertySet > SwXTextDocument::getLineNumberingProperties(void)
612 throw( RuntimeException )
614 ::vos::OGuard aGuard(Application::GetSolarMutex());
615 if(IsValid())
617 if(!pxXLineNumberingProperties)
619 pxXLineNumberingProperties = new Reference<XPropertySet>;
620 (*pxXLineNumberingProperties) = new SwXLineNumberingProperties(pDocShell->GetDoc());
623 else
624 throw RuntimeException();
625 return *pxXLineNumberingProperties;
627 /*-- 18.12.98 11:55:20---------------------------------------------------
629 -----------------------------------------------------------------------*/
630 Reference< XIndexReplace > SwXTextDocument::getChapterNumberingRules(void)
631 throw( RuntimeException )
633 ::vos::OGuard aGuard(Application::GetSolarMutex());
634 if(!IsValid())
635 throw RuntimeException();
636 if(!pxXChapterNumbering)
638 pxXChapterNumbering = new Reference< XIndexReplace > ;
639 *pxXChapterNumbering = new SwXChapterNumbering(*pDocShell);
641 return *pxXChapterNumbering;
644 Reference< XIndexAccess > SwXTextDocument::getNumberingRules(void) throw( RuntimeException )
646 ::vos::OGuard aGuard(Application::GetSolarMutex());
647 if(!IsValid())
648 throw RuntimeException();
649 if(!pxXNumberingRules )
651 ((SwXTextDocument*)this)->pxXNumberingRules = new Reference< XIndexAccess > ;
652 *pxXNumberingRules = new SwXNumberingRulesCollection( pDocShell->GetDoc() );
654 return *pxXNumberingRules;
657 /*-- 18.12.98 11:55:21---------------------------------------------------
659 -----------------------------------------------------------------------*/
660 Reference< XIndexAccess > SwXTextDocument::getFootnotes(void) throw( RuntimeException )
662 ::vos::OGuard aGuard(Application::GetSolarMutex());
663 if(!IsValid())
664 throw RuntimeException();
665 if(!pxXFootnotes)
667 ((SwXTextDocument*)this)->pxXFootnotes = new Reference< XIndexAccess > ;
668 *pxXFootnotes = new SwXFootnotes(sal_False, pDocShell->GetDoc());
670 return *pxXFootnotes;
672 /*-- 18.12.98 11:55:21---------------------------------------------------
674 -----------------------------------------------------------------------*/
675 Reference< XPropertySet > SAL_CALL
676 SwXTextDocument::getFootnoteSettings(void) throw( RuntimeException )
678 ::vos::OGuard aGuard(Application::GetSolarMutex());
679 if(!IsValid())
680 throw RuntimeException();
681 if(!pxXFootnoteSettings)
683 ((SwXTextDocument*)this)->pxXFootnoteSettings = new Reference< XPropertySet > ;
684 *pxXFootnoteSettings = new SwXFootnoteProperties(pDocShell->GetDoc());
686 return *pxXFootnoteSettings;
688 /*-- 18.12.98 11:55:21---------------------------------------------------
690 -----------------------------------------------------------------------*/
691 Reference< XIndexAccess > SwXTextDocument::getEndnotes(void) throw( RuntimeException )
693 ::vos::OGuard aGuard(Application::GetSolarMutex());
694 if(!IsValid())
695 throw RuntimeException();
696 if(!pxXEndnotes)
698 ((SwXTextDocument*)this)->pxXEndnotes = new Reference< XIndexAccess > ;
699 *pxXEndnotes = new SwXFootnotes(sal_True, pDocShell->GetDoc());
701 return *pxXEndnotes;
703 /*-- 18.12.98 11:55:22---------------------------------------------------
705 -----------------------------------------------------------------------*/
706 Reference< XPropertySet > SwXTextDocument::getEndnoteSettings(void) throw( RuntimeException )
708 ::vos::OGuard aGuard(Application::GetSolarMutex());
709 if(!IsValid())
710 throw RuntimeException();
711 if(!pxXEndnoteSettings)
713 ((SwXTextDocument*)this)->pxXEndnoteSettings = new Reference< XPropertySet > ;
714 *pxXEndnoteSettings = new SwXEndnoteProperties(pDocShell->GetDoc());
716 return *pxXEndnoteSettings;
718 /*-- 18.12.98 11:55:22---------------------------------------------------
720 -----------------------------------------------------------------------*/
721 Reference< util::XReplaceDescriptor > SwXTextDocument::createReplaceDescriptor(void)
722 throw( RuntimeException )
724 ::vos::OGuard aGuard(Application::GetSolarMutex());
725 Reference< util::XReplaceDescriptor > xRet = new SwXTextSearch;
726 return xRet;
728 /* -----------------26.02.99 15:52-------------------
730 * --------------------------------------------------*/
731 SwUnoCrsr* SwXTextDocument::CreateCursorForSearch(Reference< XTextCursor > & xCrsr)
733 getText();
734 XText* pText = xBodyText.get();
735 SwXBodyText* pBText = (SwXBodyText*)pText;
736 xCrsr = pBText->CreateTextCursor(sal_True);
738 Reference<XUnoTunnel> xRangeTunnel( xCrsr, UNO_QUERY);
739 SwXTextCursor* pxUnoCrsr = 0;
740 if(xRangeTunnel.is())
742 pxUnoCrsr = reinterpret_cast<SwXTextCursor*>(xRangeTunnel->getSomething(
743 SwXTextCursor::getUnoTunnelId()));
746 SwUnoCrsr* pUnoCrsr = pxUnoCrsr->GetCrsr();
747 pUnoCrsr->SetRemainInSection(sal_False);
748 return pUnoCrsr;
751 /*-- 18.12.98 11:55:22---------------------------------------------------
753 -----------------------------------------------------------------------*/
754 sal_Int32 SwXTextDocument::replaceAll(const Reference< util::XSearchDescriptor > & xDesc)
755 throw( RuntimeException )
757 ::vos::OGuard aGuard(Application::GetSolarMutex());
758 Reference< XUnoTunnel > xDescTunnel(xDesc, UNO_QUERY);
759 if(!IsValid() || !xDescTunnel.is() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()))
760 throw RuntimeException();
762 Reference< XTextCursor > xCrsr;
763 SwUnoCrsr* pUnoCrsr = CreateCursorForSearch(xCrsr);
765 const SwXTextSearch* pSearch = reinterpret_cast<const SwXTextSearch*>(
766 xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()));
768 int eRanges(FND_IN_BODY|FND_IN_SELALL);
770 util::SearchOptions aSearchOpt;
771 pSearch->FillSearchOptions( aSearchOpt );
773 SwDocPositions eStart = pSearch->bBack ? DOCPOS_END : DOCPOS_START;
774 SwDocPositions eEnd = pSearch->bBack ? DOCPOS_START : DOCPOS_END;
776 // Suche soll ueberall stattfinden
777 pUnoCrsr->SetRemainInSection(sal_False);
778 sal_uInt32 nResult;
779 UnoActionContext aContext(pDocShell->GetDoc());
780 //try attribute search first
781 if(pSearch->HasSearchAttributes()||pSearch->HasReplaceAttributes())
783 SfxItemSet aSearch(pDocShell->GetDoc()->GetAttrPool(),
784 RES_CHRATR_BEGIN, RES_CHRATR_END-1,
785 RES_PARATR_BEGIN, RES_PARATR_END-1,
786 RES_FRMATR_BEGIN, RES_FRMATR_END-1,
788 SfxItemSet aReplace(pDocShell->GetDoc()->GetAttrPool(),
789 RES_CHRATR_BEGIN, RES_CHRATR_END-1,
790 RES_PARATR_BEGIN, RES_PARATR_END-1,
791 RES_FRMATR_BEGIN, RES_FRMATR_END-1,
793 pSearch->FillSearchItemSet(aSearch);
794 pSearch->FillReplaceItemSet(aReplace);
795 BOOL bCancel;
796 nResult = (sal_Int32)pUnoCrsr->Find( aSearch, !pSearch->bStyles,
797 eStart, eEnd, bCancel,
798 (FindRanges)eRanges,
799 pSearch->sSearchText.Len() ? &aSearchOpt : 0,
800 &aReplace );
802 else if(pSearch->bStyles)
804 SwTxtFmtColl *pSearchColl = lcl_GetParaStyle(pSearch->sSearchText, pUnoCrsr->GetDoc());
805 SwTxtFmtColl *pReplaceColl = lcl_GetParaStyle(pSearch->sReplaceText, pUnoCrsr->GetDoc());;
807 BOOL bCancel;
808 nResult = pUnoCrsr->Find( *pSearchColl,
809 eStart, eEnd, bCancel,
810 (FindRanges)eRanges, pReplaceColl );
813 else
815 //todo/mba: assuming that notes should be omitted
816 BOOL bSearchInNotes = FALSE;
817 BOOL bCancel;
818 nResult = pUnoCrsr->Find( aSearchOpt, bSearchInNotes,
819 eStart, eEnd, bCancel,
820 (FindRanges)eRanges,
821 sal_True );
823 return (sal_Int32)nResult;
826 /*-- 18.12.98 11:55:22---------------------------------------------------
828 -----------------------------------------------------------------------*/
829 Reference< util::XSearchDescriptor > SwXTextDocument::createSearchDescriptor(void)
830 throw( RuntimeException )
832 ::vos::OGuard aGuard(Application::GetSolarMutex());
833 Reference< util::XSearchDescriptor > xRet = new SwXTextSearch;
834 return xRet;
837 /* -----------------26.02.99 16:08-------------------
838 * wird fuer findAll/First/Next verwendet
839 * --------------------------------------------------*/
840 SwUnoCrsr* SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor > & xDesc,
841 Reference< XTextCursor > & xCrsr, sal_Bool bAll,
842 sal_Int32& nResult,
843 Reference< XInterface > xLastResult)
845 Reference< XUnoTunnel > xDescTunnel(xDesc, UNO_QUERY);
846 if(!IsValid() || !xDescTunnel.is() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()))
847 return 0;
849 SwUnoCrsr* pUnoCrsr = CreateCursorForSearch(xCrsr);
850 const SwXTextSearch* pSearch = reinterpret_cast<const SwXTextSearch*>(
851 xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()));
853 sal_Bool bParentInExtra = sal_False;
854 if(xLastResult.is())
856 Reference<XUnoTunnel> xCursorTunnel( xLastResult, UNO_QUERY);
857 OTextCursorHelper* pPosCrsr = 0;
858 if(xCursorTunnel.is())
860 pPosCrsr = reinterpret_cast<OTextCursorHelper*>(xCursorTunnel->getSomething(
861 OTextCursorHelper::getUnoTunnelId()));
863 SwPaM* pCrsr = pPosCrsr ? pPosCrsr->GetPaM() : 0;
864 if(pCrsr)
866 *pUnoCrsr->GetPoint() = *pCrsr->End();
867 pUnoCrsr->DeleteMark();
869 else
871 SwXTextRange* pRange = 0;
872 if(xCursorTunnel.is())
874 pRange = reinterpret_cast<SwXTextRange*>(xCursorTunnel->getSomething(
875 SwXTextRange::getUnoTunnelId()));
877 if(!pRange)
878 return 0;
879 pRange->GetPositions(*pUnoCrsr);
880 if(pUnoCrsr->HasMark())
882 if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark())
883 pUnoCrsr->Exchange();
884 pUnoCrsr->DeleteMark();
887 const SwNode* pRangeNode = pUnoCrsr->GetNode();
888 bParentInExtra = pRangeNode->FindFlyStartNode() ||
889 pRangeNode->FindFootnoteStartNode() ||
890 pRangeNode->FindHeaderStartNode() ||
891 pRangeNode->FindFooterStartNode() ;
894 util::SearchOptions aSearchOpt;
895 pSearch->FillSearchOptions( aSearchOpt );
898 * folgende Kombinationen sind erlaubt:
899 * - suche einen im Body: -> FND_IN_BODY
900 * - suche alle im Body: -> FND_IN_BODYONLY | FND_IN_SELALL
901 * - suche in Selectionen: einen / alle -> FND_IN_SEL [ | FND_IN_SELALL ]
902 * - suche im nicht Body: einen / alle -> FND_IN_OTHER [ | FND_IN_SELALL ]
903 * - suche ueberall alle: -> FND_IN_SELALL
905 int eRanges(FND_IN_BODY);
906 if(bParentInExtra)
907 eRanges = FND_IN_OTHER;
908 if(bAll) //immer - ueberall?
909 eRanges = FND_IN_SELALL;
910 SwDocPositions eStart = !bAll ? DOCPOS_CURR : pSearch->bBack ? DOCPOS_END : DOCPOS_START;
911 SwDocPositions eEnd = pSearch->bBack ? DOCPOS_START : DOCPOS_END;
913 nResult = 0;
914 sal_uInt16 nSearchProc = 0;
915 while(nSearchProc < 2)
917 //try attribute search first
918 if(pSearch->HasSearchAttributes())
920 SfxItemSet aSearch(pDocShell->GetDoc()->GetAttrPool(),
921 RES_CHRATR_BEGIN, RES_CHRATR_END-1,
922 RES_PARATR_BEGIN, RES_PARATR_END-1,
923 RES_FRMATR_BEGIN, RES_FRMATR_END-1,
924 RES_TXTATR_INETFMT, RES_TXTATR_INETFMT,
926 pSearch->FillSearchItemSet(aSearch);
927 BOOL bCancel;
928 nResult = (sal_Int32)pUnoCrsr->Find( aSearch, !pSearch->bStyles,
929 eStart, eEnd, bCancel,
930 (FindRanges)eRanges,
931 pSearch->sSearchText.Len() ? &aSearchOpt : 0,
932 0 );
934 else if(pSearch->bStyles)
936 SwTxtFmtColl *pSearchColl = lcl_GetParaStyle(pSearch->sSearchText, pUnoCrsr->GetDoc());
937 //pSearch->sReplaceText
938 SwTxtFmtColl *pReplaceColl = 0;
939 BOOL bCancel;
940 nResult = (sal_Int32)pUnoCrsr->Find( *pSearchColl,
941 eStart, eEnd, bCancel,
942 (FindRanges)eRanges, pReplaceColl );
944 else
946 //todo/mba: assuming that notes should be omitted
947 BOOL bSearchInNotes = FALSE;
948 BOOL bCancel;
949 nResult = (sal_Int32)pUnoCrsr->Find( aSearchOpt, bSearchInNotes,
950 eStart, eEnd, bCancel,
951 (FindRanges)eRanges,
952 /*int bReplace =*/sal_False );
954 nSearchProc++;
955 if(nResult || (eRanges&(FND_IN_SELALL|FND_IN_OTHER)))
956 break;
957 //second step - find in other
958 eRanges = FND_IN_OTHER;
960 return pUnoCrsr;
962 /*-- 18.12.98 11:55:23---------------------------------------------------
964 -----------------------------------------------------------------------*/
965 Reference< XIndexAccess >
966 SwXTextDocument::findAll(const Reference< util::XSearchDescriptor > & xDesc)
967 throw( RuntimeException )
969 ::vos::OGuard aGuard(Application::GetSolarMutex());
970 Reference< XInterface > xTmp;
971 sal_Int32 nResult = 0;
972 Reference< XTextCursor > xCrsr;
973 SwUnoCrsr* pResultCrsr = FindAny(xDesc, xCrsr, sal_True, nResult, xTmp);
974 if(!pResultCrsr)
975 throw RuntimeException();
976 Reference< XIndexAccess > xRet;
977 if(nResult)
978 xRet = new SwXTextRanges(pResultCrsr);
979 else
980 xRet = new SwXTextRanges();
981 delete pResultCrsr;
982 return xRet;
984 /*-- 18.12.98 11:55:23---------------------------------------------------
986 -----------------------------------------------------------------------*/
987 Reference< XInterface > SwXTextDocument::findFirst(const Reference< util::XSearchDescriptor > & xDesc)
988 throw( RuntimeException )
990 ::vos::OGuard aGuard(Application::GetSolarMutex());
991 Reference< XInterface > xTmp;
992 sal_Int32 nResult = 0;
993 Reference< XTextCursor > xCrsr;
994 SwUnoCrsr* pResultCrsr = FindAny(xDesc, xCrsr, sal_False, nResult, xTmp);
995 if(!pResultCrsr)
996 throw RuntimeException();
997 Reference< XInterface > xRet;
998 if(nResult)
1000 Reference< XTextRange > xTempRange = SwXTextRange::CreateTextRangeFromPosition(
1001 pDocShell->GetDoc(),
1002 *pResultCrsr->GetPoint(),
1003 pResultCrsr->GetMark());
1004 xRet = *new SwXTextCursor(xTempRange->getText(), pResultCrsr);
1005 delete pResultCrsr;
1007 return xRet;
1009 /*-- 18.12.98 11:55:24---------------------------------------------------
1011 -----------------------------------------------------------------------*/
1012 Reference< XInterface > SwXTextDocument::findNext(const Reference< XInterface > & xStartAt,
1013 const Reference< util::XSearchDescriptor > & xDesc)
1014 throw( RuntimeException )
1016 ::vos::OGuard aGuard(Application::GetSolarMutex());
1017 Reference< XInterface > xTmp;
1018 sal_Int32 nResult = 0;
1019 Reference< XTextCursor > xCrsr;
1020 if(!xStartAt.is())
1021 throw RuntimeException();
1022 SwUnoCrsr* pResultCrsr = FindAny(xDesc, xCrsr, sal_False, nResult, xStartAt);
1023 if(!pResultCrsr)
1024 throw RuntimeException();
1025 Reference< XInterface > xRet;
1026 if(nResult)
1028 Reference< XTextRange > xTempRange = SwXTextRange::CreateTextRangeFromPosition(
1029 pDocShell->GetDoc(),
1030 *pResultCrsr->GetPoint(),
1031 pResultCrsr->GetMark());
1033 xRet = *new SwXTextCursor(xTempRange->getText(), pResultCrsr);
1034 delete pResultCrsr;
1036 return xRet;
1038 /*-- 18.12.98 11:55:24---------------------------------------------------
1040 -----------------------------------------------------------------------*/
1041 Sequence< beans::PropertyValue > SwXTextDocument::getPagePrintSettings(void)
1042 throw( RuntimeException )
1044 ::vos::OGuard aGuard(Application::GetSolarMutex());
1045 Sequence< beans::PropertyValue > aSeq(9);
1046 if(IsValid())
1048 beans::PropertyValue* pArray = aSeq.getArray();
1049 SwPagePreViewPrtData aData;
1050 const SwPagePreViewPrtData* pData = pDocShell->GetDoc()->GetPreViewPrtData();
1051 if(pData)
1052 aData = *pData;
1053 Any aVal;
1054 aVal <<= (sal_Int16)aData.GetRow();
1055 pArray[0] = beans::PropertyValue(C2U("PageRows"), -1, aVal, PropertyState_DIRECT_VALUE);
1056 aVal <<= (sal_Int16)aData.GetCol();
1057 pArray[1] = beans::PropertyValue(C2U("PageColumns"), -1, aVal, PropertyState_DIRECT_VALUE);
1058 aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetLeftSpace());
1059 pArray[2] = beans::PropertyValue(C2U("LeftMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
1060 aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetRightSpace());
1061 pArray[3] = beans::PropertyValue(C2U("RightMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
1062 aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetTopSpace());
1063 pArray[4] = beans::PropertyValue(C2U("TopMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
1064 aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetBottomSpace());
1065 pArray[5] = beans::PropertyValue(C2U("BottomMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
1066 aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetHorzSpace());
1067 pArray[6] = beans::PropertyValue(C2U("HoriMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
1068 aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetVertSpace());
1069 pArray[7] = beans::PropertyValue(C2U("VertMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
1070 BOOL bTemp = aData.GetLandscape();
1071 aVal.setValue(&bTemp, ::getCppuBooleanType());
1072 pArray[8] = beans::PropertyValue(C2U("IsLandscape"), -1, aVal, PropertyState_DIRECT_VALUE);
1074 else
1075 throw RuntimeException();
1076 return aSeq;
1078 /* -----------------24.02.99 10:57-------------------
1080 * --------------------------------------------------*/
1081 sal_uInt32 lcl_Any_To_ULONG(const Any& rValue, sal_Bool& bException)
1083 bException = sal_False;
1084 TypeClass eType = rValue.getValueType().getTypeClass();
1086 sal_uInt32 nRet = 0;
1087 if( eType == TypeClass_UNSIGNED_LONG )
1088 rValue >>= nRet;
1089 else
1091 sal_Int32 nVal=0;
1092 bException = !(rValue >>= nVal);
1093 if( !bException )
1094 nRet = (sal_uInt32)nVal;
1097 return nRet;
1099 /*-- 09.06.2004 12:18:10---------------------------------------------------
1101 -----------------------------------------------------------------------*/
1102 String lcl_CreateOutlineString( USHORT nIndex,
1103 const SwOutlineNodes& rOutlineNodes, const SwNumRule* pOutlRule)
1105 String sEntry;
1106 const SwTxtNode * pTxtNd = rOutlineNodes[ nIndex ]->GetTxtNode();
1107 SwNumberTree::tNumberVector aNumVector = pTxtNd->GetNumberVector();
1108 if( pOutlRule && pTxtNd->GetNumRule())
1109 for( sal_Int8 nLevel = 0;
1110 nLevel <= pTxtNd->GetActualListLevel();
1111 nLevel++ )
1113 long nVal = aNumVector[nLevel];
1114 nVal ++;
1115 nVal -= pOutlRule->Get(nLevel).GetStart();
1116 sEntry += String::CreateFromInt32( nVal );
1117 sEntry += '.';
1119 sEntry += rOutlineNodes[ nIndex ]->
1120 GetTxtNode()->GetExpandTxt( 0, STRING_LEN, sal_False );
1121 return sEntry;
1123 /*-- 18.12.98 11:55:25---------------------------------------------------
1125 -----------------------------------------------------------------------*/
1126 void SwXTextDocument::setPagePrintSettings(const Sequence< beans::PropertyValue >& aSettings)
1127 throw( RuntimeException )
1129 ::vos::OGuard aGuard(Application::GetSolarMutex());
1130 if(IsValid())
1132 SwPagePreViewPrtData aData;
1133 //falls nur einige Properties kommen, dann die akt. Einstellungen benutzen
1134 const SwPagePreViewPrtData* pData = pDocShell->GetDoc()->GetPreViewPrtData();
1135 if(pData)
1136 aData = *pData;
1137 const beans::PropertyValue* pProperties = aSettings.getConstArray();
1138 int nCount = aSettings.getLength();
1139 for(int i = 0; i < nCount; i++)
1141 String sName = pProperties[i].Name;
1142 const Any& rVal = pProperties[i].Value;
1143 sal_Bool bException;
1144 sal_uInt32 nVal = lcl_Any_To_ULONG(rVal, bException);
1145 if( COMPARE_EQUAL == sName.CompareToAscii("PageRows" ) )
1147 if(!nVal || nVal > 0xff)
1148 throw RuntimeException();
1149 aData.SetRow((BYTE)nVal);
1151 else if(COMPARE_EQUAL == sName.CompareToAscii("PageColumns"))
1153 if(!nVal || nVal > 0xff)
1154 throw RuntimeException();
1155 aData.SetCol((BYTE)nVal);
1157 else if(COMPARE_EQUAL == sName.CompareToAscii("LeftMargin"))
1159 aData.SetLeftSpace(MM100_TO_TWIP_UNSIGNED(nVal));
1161 else if(COMPARE_EQUAL == sName.CompareToAscii("RightMargin"))
1163 aData.SetRightSpace(MM100_TO_TWIP_UNSIGNED(nVal));
1165 else if(COMPARE_EQUAL == sName.CompareToAscii("TopMargin"))
1167 aData.SetTopSpace(MM100_TO_TWIP_UNSIGNED(nVal));
1169 else if(COMPARE_EQUAL == sName.CompareToAscii("BottomMargin"))
1171 aData.SetBottomSpace(MM100_TO_TWIP_UNSIGNED(nVal));
1173 else if(COMPARE_EQUAL == sName.CompareToAscii("HoriMargin"))
1175 aData.SetHorzSpace(MM100_TO_TWIP_UNSIGNED(nVal));
1177 else if(COMPARE_EQUAL == sName.CompareToAscii("VertMargin"))
1179 aData.SetVertSpace(MM100_TO_TWIP_UNSIGNED(nVal));
1181 else if(COMPARE_EQUAL == sName.CompareToAscii("IsLandscape"))
1183 bException = (::getBooleanCppuType() != rVal.getValueType());
1184 aData.SetLandscape(*(sal_Bool*)rVal.getValue());
1186 else
1187 bException = sal_True;
1188 if(bException)
1189 throw RuntimeException();
1191 pDocShell->GetDoc()->SetPreViewPrtData(&aData);
1193 else
1194 throw RuntimeException();
1196 /*-- 18.12.98 11:55:25---------------------------------------------------
1198 -----------------------------------------------------------------------*/
1199 void SwXTextDocument::printPages(const Sequence< beans::PropertyValue >& xOptions)
1200 throw( IllegalArgumentException, RuntimeException )
1202 ::vos::OGuard aGuard(Application::GetSolarMutex());
1203 if(IsValid())
1205 SfxViewFrame* pFrame = SfxViewFrame::CreateViewFrame( *pDocShell, 7, sal_True );
1206 SfxRequest aReq(FN_PRINT_PAGEPREVIEW, SFX_CALLMODE_SYNCHRON,
1207 pDocShell->GetDoc()->GetAttrPool());
1208 aReq.AppendItem(SfxBoolItem(FN_PRINT_PAGEPREVIEW, sal_True));
1210 OUString sFileName( C2U(SW_PROP_NAME_STR(UNO_NAME_FILE_NAME)));
1211 OUString sCopyCount(C2U(SW_PROP_NAME_STR(UNO_NAME_COPY_COUNT)));
1212 OUString sCollate(C2U(SW_PROP_NAME_STR(UNO_NAME_COLLATE)));
1213 OUString sSort(C2U(SW_PROP_NAME_STR(UNO_NAME_SORT)));
1214 OUString sPages(C2U(SW_PROP_NAME_STR(UNO_NAME_PAGES)));
1216 for ( int n = 0; n < xOptions.getLength(); ++n )
1218 // get Property-Value from options
1219 const beans::PropertyValue &rProp = xOptions.getConstArray()[n];
1220 Any aValue( rProp.Value );
1222 // FileName-Property?
1223 if ( rProp.Name == sFileName )
1225 OUString sFileURL;
1226 if ( (rProp.Value >>= sFileURL ) )
1228 // Convert the File URL into a system dependant path, as the SalPrinter expects
1229 OUString sSystemPath;
1230 FileBase::getSystemPathFromFileURL ( sFileURL, sSystemPath );
1231 aReq.AppendItem(SfxStringItem( SID_FILE_NAME, sSystemPath ) );
1233 else if ( rProp.Value.getValueType() != ::getVoidCppuType() )
1234 throw IllegalArgumentException();
1237 // CopyCount-Property
1238 else if ( rProp.Name == sCopyCount )
1240 sal_Int32 nCopies = 0;
1241 aValue >>= nCopies;
1242 aReq.AppendItem(SfxInt16Item( SID_PRINT_COPIES, (sal_Int16)nCopies ) );
1245 // Collate-Property
1246 else if ( rProp.Name == sCollate )
1248 if ( rProp.Value.getValueType() == ::getBooleanCppuType())
1250 aReq.AppendItem(SfxBoolItem( SID_PRINT_COLLATE, *(sal_Bool*)rProp.Value.getValue() ) );
1251 else
1252 throw IllegalArgumentException();
1255 // Sort-Property
1256 else if ( rProp.Name == sSort )
1258 if ( rProp.Value.getValueType() == ::getBooleanCppuType() )
1259 aReq.AppendItem(SfxBoolItem( SID_PRINT_SORT, *(sal_Bool*)rProp.Value.getValue() ) );
1260 else
1261 throw IllegalArgumentException();
1264 // Pages-Property
1265 else if ( rProp.Name == sPages )
1267 OUString sTmp;
1268 if ( rProp.Value >>= sTmp )
1269 aReq.AppendItem( SfxStringItem( SID_PRINT_PAGES, sTmp ) );
1270 else
1271 throw IllegalArgumentException();
1276 pFrame->GetViewShell()->ExecuteSlot(aReq);
1277 // Frame schliessen
1278 pFrame->DoClose();
1281 else
1282 throw RuntimeException();
1284 /*-- 18.12.98 11:55:25---------------------------------------------------
1286 -----------------------------------------------------------------------*/
1287 Reference< XNameAccess > SwXTextDocument::getReferenceMarks(void)
1288 throw( RuntimeException )
1290 ::vos::OGuard aGuard(Application::GetSolarMutex());
1291 if(!IsValid())
1292 throw RuntimeException();
1293 if(!pxXReferenceMarks)
1295 ((SwXTextDocument*)this)->pxXReferenceMarks = new Reference< XNameAccess > ;
1296 *pxXReferenceMarks = new SwXReferenceMarks(pDocShell->GetDoc());
1298 return *pxXReferenceMarks;
1300 /* -----------------21.12.98 10:20-------------------
1302 * --------------------------------------------------*/
1303 Reference< XEnumerationAccess > SwXTextDocument::getTextFields(void) throw( RuntimeException )
1305 ::vos::OGuard aGuard(Application::GetSolarMutex());
1306 if(!IsValid())
1307 throw RuntimeException();
1308 if(!pxXTextFieldTypes)
1310 ((SwXTextDocument*)this)->pxXTextFieldTypes = new Reference< XEnumerationAccess > ;
1311 *pxXTextFieldTypes = new SwXTextFieldTypes(pDocShell->GetDoc());
1313 return *pxXTextFieldTypes;
1315 /*-- 21.12.98 10:21:12---------------------------------------------------
1317 -----------------------------------------------------------------------*/
1318 Reference< XNameAccess > SwXTextDocument::getTextFieldMasters(void)
1319 throw( RuntimeException )
1321 ::vos::OGuard aGuard(Application::GetSolarMutex());
1322 if(!IsValid())
1323 throw RuntimeException();
1324 if(!pxXTextFieldMasters)
1326 ((SwXTextDocument*)this)->pxXTextFieldMasters = new Reference< XNameAccess > ;
1327 *pxXTextFieldMasters = new SwXTextFieldMasters(pDocShell->GetDoc());
1329 return *pxXTextFieldMasters;
1331 /*-- 21.12.98 10:21:12---------------------------------------------------
1333 -----------------------------------------------------------------------*/
1334 Reference< XNameAccess > SwXTextDocument::getEmbeddedObjects(void) throw( RuntimeException )
1336 ::vos::OGuard aGuard(Application::GetSolarMutex());
1337 if(!IsValid())
1338 throw RuntimeException();
1339 if(!pxXEmbeddedObjects)
1341 ((SwXTextDocument*)this)->pxXEmbeddedObjects = new Reference< XNameAccess > ;
1342 *pxXEmbeddedObjects = new SwXTextEmbeddedObjects(pDocShell->GetDoc());
1344 return *pxXEmbeddedObjects;
1346 /*-- 21.12.98 10:21:13---------------------------------------------------
1348 -----------------------------------------------------------------------*/
1349 Reference< XNameAccess > SwXTextDocument::getBookmarks(void) throw( RuntimeException )
1351 ::vos::OGuard aGuard(Application::GetSolarMutex());
1352 if(!IsValid())
1353 throw RuntimeException();
1354 if(!pxXBookmarks)
1356 ((SwXTextDocument*)this)->pxXBookmarks = new Reference< XNameAccess > ;
1357 *pxXBookmarks = new SwXBookmarks(pDocShell->GetDoc());
1359 return *pxXBookmarks;
1361 /*-- 21.12.98 10:21:13---------------------------------------------------
1363 -----------------------------------------------------------------------*/
1364 Reference< XNameAccess > SwXTextDocument::getTextSections(void) throw( RuntimeException )
1366 ::vos::OGuard aGuard(Application::GetSolarMutex());
1367 if(!IsValid())
1368 throw RuntimeException();
1369 if(!pxXTextSections)
1371 ((SwXTextDocument*)this)->pxXTextSections = new Reference< XNameAccess > ;
1372 *pxXTextSections = new SwXTextSections(pDocShell->GetDoc());
1374 return *pxXTextSections;
1376 /*-- 21.12.98 10:21:13---------------------------------------------------
1378 -----------------------------------------------------------------------*/
1379 Reference< XNameAccess > SwXTextDocument::getTextTables(void) throw( RuntimeException )
1381 ::vos::OGuard aGuard(Application::GetSolarMutex());
1382 if(!IsValid())
1383 throw RuntimeException();
1384 if(!pxXTextTables)
1386 ((SwXTextDocument*)this)->pxXTextTables = new Reference< XNameAccess > ;
1387 *pxXTextTables = new SwXTextTables(pDocShell->GetDoc());
1389 return *pxXTextTables;
1391 /*-- 21.12.98 10:21:13---------------------------------------------------
1393 -----------------------------------------------------------------------*/
1394 Reference< XNameAccess > SwXTextDocument::getGraphicObjects(void) throw( RuntimeException )
1396 ::vos::OGuard aGuard(Application::GetSolarMutex());
1397 if(!IsValid())
1398 throw RuntimeException();
1399 if(!pxXGraphicObjects)
1401 ((SwXTextDocument*)this)->pxXGraphicObjects = new Reference< XNameAccess > ;
1402 *pxXGraphicObjects = new SwXTextGraphicObjects(pDocShell->GetDoc());
1404 return *pxXGraphicObjects;
1406 /*-- 21.12.98 10:21:14---------------------------------------------------
1408 -----------------------------------------------------------------------*/
1409 Reference< XNameAccess > SwXTextDocument::getTextFrames(void) throw( RuntimeException )
1411 ::vos::OGuard aGuard(Application::GetSolarMutex());
1412 if(!IsValid())
1413 throw RuntimeException();
1414 if(!pxXTextFrames)
1416 ((SwXTextDocument*)this)->pxXTextFrames = new Reference< XNameAccess > ;
1417 *pxXTextFrames = new SwXTextFrames(pDocShell->GetDoc());
1419 return *pxXTextFrames;
1421 /* -----------------21.12.98 10:56-------------------
1423 * --------------------------------------------------*/
1424 Reference< XNameAccess > SwXTextDocument::getStyleFamilies(void) throw( RuntimeException )
1426 ::vos::OGuard aGuard(Application::GetSolarMutex());
1427 if(!IsValid())
1428 throw RuntimeException();
1429 if(!pxXStyleFamilies)
1431 ((SwXTextDocument*)this)->pxXStyleFamilies = new Reference< XNameAccess > ;
1432 *pxXStyleFamilies = new SwXStyleFamilies(*pDocShell);
1434 return *pxXStyleFamilies;
1436 /*-- 19.05.06 10:15:22---------------------------------------------------
1438 -----------------------------------------------------------------------*/
1439 uno::Reference< style::XAutoStyles > SwXTextDocument::getAutoStyles( )
1440 throw (uno::RuntimeException)
1442 ::vos::OGuard aGuard(Application::GetSolarMutex());
1443 if(!IsValid())
1444 throw RuntimeException();
1445 if(!pxXAutoStyles)
1447 pxXAutoStyles = new Reference< style::XAutoStyles > ;
1448 *pxXAutoStyles = new SwXAutoStyles(*pDocShell);
1450 return *pxXAutoStyles;
1453 /*-- 22.01.99 10:18:03---------------------------------------------------
1455 -----------------------------------------------------------------------*/
1456 Reference< drawing::XDrawPage > SwXTextDocument::getDrawPage(void) throw( RuntimeException )
1458 ::vos::OGuard aGuard(Application::GetSolarMutex());
1459 if(!IsValid())
1460 throw RuntimeException();
1461 if(!pxXDrawPage)
1463 // simplified this creation, keeping original below as reference
1464 // for the case that it did something by purpose
1465 ((SwXTextDocument*)this)->pDrawPage = new SwXDrawPage(pDocShell->GetDoc());
1466 ((SwXTextDocument*)this)->pxXDrawPage = new Reference< drawing::XDrawPage >(pDrawPage);
1468 //((SwXTextDocument*)this)->pxXDrawPage = new Reference< drawing::XDrawPage > ;
1469 //((SwXTextDocument*)this)->pDrawPage = new SwXDrawPage(pDocShell->GetDoc());
1470 //Reference< drawing::XShapes > xTmp = pDrawPage;
1471 //*pxXDrawPage = Reference< drawing::XDrawPage>(xTmp, UNO_QUERY);
1473 return *pxXDrawPage;
1475 /* -----------------07.04.99 10:11-------------------
1477 * --------------------------------------------------*/
1478 SwXDrawPage* SwXTextDocument::GetDrawPage()
1480 if(!IsValid())
1481 return 0;
1482 if(!pDrawPage)
1483 getDrawPage();
1484 return pDrawPage;
1486 /*-- 18.12.98 11:55:26---------------------------------------------------
1488 -----------------------------------------------------------------------*/
1489 void SwXTextDocument::Invalidate()
1491 bObjectValid = sal_False;
1492 if(xNumFmtAgg.is())
1494 const uno::Type& rTunnelType = ::getCppuType((Reference <XUnoTunnel>*)0);
1495 Any aNumTunnel = xNumFmtAgg->queryAggregation(rTunnelType);
1496 SvNumberFormatsSupplierObj* pNumFmt = 0;
1497 Reference< XUnoTunnel > xNumTunnel;
1498 if(aNumTunnel >>= xNumTunnel)
1500 pNumFmt = reinterpret_cast<SvNumberFormatsSupplierObj*>(
1501 xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
1502 pNumFmt->SetNumberFormatter(0);
1504 DBG_ASSERT(pNumFmt, "No number formatter available");
1506 InitNewDoc();
1507 pDocShell = 0;
1508 aRefreshCont.Disposing();
1510 /* -----------------------------13.07.00 15:59--------------------------------
1512 ---------------------------------------------------------------------------*/
1513 void SwXTextDocument::Reactivate(SwDocShell* pNewDocShell)
1515 if(pDocShell && pDocShell != pNewDocShell)
1516 Invalidate();
1517 pDocShell = pNewDocShell;
1518 bObjectValid = TRUE;
1520 /*-- 18.12.98 11:55:26---------------------------------------------------
1522 -----------------------------------------------------------------------*/
1523 void SwXTextDocument::InitNewDoc()
1525 // zunaechst alle Collections invalidieren, dann Referenzen loeschen und Null setzen
1526 if(pxXTextTables)
1528 XNameAccess* pTbls = pxXTextTables->get();
1529 ((SwXTextTables*)pTbls)->Invalidate();
1530 delete pxXTextTables;
1531 pxXTextTables = 0;
1534 if(pxXTextFrames)
1536 XNameAccess* pFrms = pxXTextFrames->get();
1537 ((SwXTextFrames*)pFrms)->Invalidate();
1538 delete pxXTextFrames;
1539 pxXTextFrames = 0;
1542 if(pxXGraphicObjects)
1544 XNameAccess* pFrms = pxXGraphicObjects->get();
1545 ((SwXTextGraphicObjects*)pFrms)->Invalidate();
1546 delete pxXGraphicObjects;
1547 pxXGraphicObjects = 0;
1550 if(pxXEmbeddedObjects)
1552 XNameAccess* pOLE = pxXEmbeddedObjects->get();
1553 ((SwXTextEmbeddedObjects*)pOLE)->Invalidate();
1554 delete pxXEmbeddedObjects;
1555 pxXEmbeddedObjects = 0;
1558 if(xBodyText.is())
1560 xBodyText = 0;
1561 pBodyText = 0;
1564 if(xNumFmtAgg.is())
1566 const uno::Type& rTunnelType = ::getCppuType((Reference <XUnoTunnel>*)0);
1567 Any aNumTunnel = xNumFmtAgg->queryAggregation(rTunnelType);
1568 SvNumberFormatsSupplierObj* pNumFmt = 0;
1569 Reference< XUnoTunnel > xNumTunnel;
1570 if(aNumTunnel >>= xNumTunnel)
1572 pNumFmt = reinterpret_cast<SvNumberFormatsSupplierObj*>(
1573 xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
1576 DBG_ASSERT(pNumFmt, "No number formatter available");
1577 pNumFmt->SetNumberFormatter(0);
1580 if(pxXTextFieldTypes)
1582 XEnumerationAccess* pT = pxXTextFieldTypes->get();
1583 ((SwXTextFieldTypes*)pT)->Invalidate();
1584 delete pxXTextFieldTypes;
1585 pxXTextFieldTypes = 0;
1588 if(pxXTextFieldMasters)
1590 XNameAccess* pT = pxXTextFieldMasters->get();
1591 ((SwXTextFieldMasters*)pT)->Invalidate();
1592 delete pxXTextFieldMasters;
1593 pxXTextFieldMasters = 0;
1596 if(pxXTextSections)
1598 XNameAccess* pSect = pxXTextSections->get();
1599 ((SwXTextSections*)pSect)->Invalidate();
1600 delete pxXTextSections;
1601 pxXTextSections = 0;
1604 if(pxXDrawPage)
1606 // --> OD 2008-07-23 #i91798#, #i91895#
1607 // dispose XDrawPage here. We are the owner and know that it is no longer in a valid condition.
1608 uno::Reference<lang::XComponent> xComp( *pxXDrawPage, uno::UNO_QUERY );
1609 xComp->dispose();
1610 // <--
1611 pDrawPage->InvalidateSwDoc();
1612 delete pxXDrawPage;
1613 pxXDrawPage = 0;
1616 if ( pxXNumberingRules )
1618 XIndexAccess* pNum = pxXNumberingRules->get();
1619 ((SwXNumberingRulesCollection*)pNum)->Invalidate();
1620 delete pxXNumberingRules;
1621 pxXNumberingRules = 0;
1624 if(pxXFootnotes)
1626 XIndexAccess* pFtn = pxXFootnotes->get();
1627 ((SwXFootnotes*)pFtn)->Invalidate();
1628 delete pxXFootnotes;
1629 pxXFootnotes = 0;
1632 if(pxXEndnotes)
1634 XIndexAccess* pFtn = pxXEndnotes->get();
1635 ((SwXFootnotes*)pFtn)->Invalidate();
1636 delete pxXEndnotes;
1637 pxXEndnotes = 0;
1640 if(pxXDocumentIndexes)
1642 XIndexAccess* pIdxs = pxXDocumentIndexes->get();
1643 ((SwXDocumentIndexes*)pIdxs)->Invalidate();
1644 delete pxXDocumentIndexes;
1645 pxXDocumentIndexes = 0;
1648 if(pxXStyleFamilies)
1650 XNameAccess* pStyles = pxXStyleFamilies->get();
1651 ((SwXStyleFamilies*)pStyles)->Invalidate();
1652 delete pxXStyleFamilies;
1653 pxXStyleFamilies = 0;
1655 if(pxXAutoStyles)
1657 XNameAccess* pStyles = pxXAutoStyles->get();
1658 ((SwXAutoStyles*)pStyles)->Invalidate();
1659 delete pxXAutoStyles;
1660 pxXAutoStyles = 0;
1663 if(pxXBookmarks)
1665 XNameAccess* pBm = pxXBookmarks->get();
1666 ((SwXBookmarks*)pBm)->Invalidate();
1667 delete pxXBookmarks;
1668 pxXBookmarks = 0;
1671 if(pxXChapterNumbering)
1673 XIndexReplace* pCh = pxXChapterNumbering->get();
1674 ((SwXChapterNumbering*)pCh)->Invalidate();
1675 delete pxXChapterNumbering;
1676 pxXChapterNumbering = 0;
1679 if(pxXFootnoteSettings)
1681 XPropertySet* pFntSet = pxXFootnoteSettings->get();
1682 ((SwXFootnoteProperties*)pFntSet)->Invalidate();
1683 delete pxXFootnoteSettings;
1684 pxXFootnoteSettings = 0;
1687 if(pxXEndnoteSettings)
1689 XPropertySet* pEndSet = pxXEndnoteSettings->get();
1690 ((SwXEndnoteProperties*)pEndSet)->Invalidate();
1691 delete pxXEndnoteSettings;
1692 pxXEndnoteSettings = 0;
1695 if(pxXLineNumberingProperties)
1697 XPropertySet* pLine = pxXLineNumberingProperties->get();
1698 ((SwXLineNumberingProperties*)pLine)->Invalidate();
1699 delete pxXLineNumberingProperties;
1700 pxXLineNumberingProperties = 0;
1702 if(pxXReferenceMarks)
1704 XNameAccess* pMarks = pxXReferenceMarks->get();
1705 ((SwXReferenceMarks*)pMarks)->Invalidate();
1706 delete pxXReferenceMarks;
1707 pxXReferenceMarks = 0;
1709 if(pxLinkTargetSupplier)
1711 XNameAccess* pAccess = (*pxLinkTargetSupplier).get();
1712 ((SwXLinkTargetSupplier*)pAccess)->Invalidate();
1713 delete pxLinkTargetSupplier;
1714 pxLinkTargetSupplier = 0;
1716 if(pxXRedlines)
1718 XEnumerationAccess* pMarks = pxXRedlines->get();
1719 ((SwXRedlines*)pMarks)->Invalidate();
1720 delete pxXRedlines;
1721 pxXRedlines = 0;
1723 if(xPropertyHelper.is())
1725 pPropertyHelper->Invalidate();
1726 xPropertyHelper = 0;
1727 pPropertyHelper = 0;
1731 /*-- 11.03.99 11:51:40---------------------------------------------------
1733 -----------------------------------------------------------------------*/
1734 #define COM_SUN_STAR__DRAWING_LENGTH 13
1735 Reference< XInterface > SwXTextDocument::createInstance(const OUString& rServiceName)
1736 throw( Exception, RuntimeException )
1738 ::vos::OGuard aGuard(Application::GetSolarMutex());
1739 if(!IsValid())
1740 throw RuntimeException();
1741 Reference< XInterface > xRet;
1742 sal_uInt16 nType = SwXServiceProvider::GetProviderType(rServiceName);
1743 if(nType != SW_SERVICE_INVALID)
1745 xRet = SwXServiceProvider::MakeInstance(nType, pDocShell->GetDoc());
1747 else
1749 if( rServiceName.compareToAscii( "com.sun.star.", 13 ) == 0 )
1751 sal_Int32 nIndex = COM_SUN_STAR__DRAWING_LENGTH;
1752 OUString sCategory = rServiceName.getToken( 0, '.', nIndex );
1753 sal_Bool bShape = sCategory == C2U("drawing");
1754 if( bShape || sCategory == C2U("form"))
1756 if(bShape)
1758 short nTable = 0;
1759 if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.DashTable") ) )
1760 nTable = SW_CREATE_DASH_TABLE;
1761 else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GradientTable") ) )
1762 nTable = SW_CREATE_GRADIENT_TABLE;
1763 else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.HatchTable") ) )
1764 nTable = SW_CREATE_HATCH_TABLE;
1765 else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.BitmapTable") ) )
1766 nTable = SW_CREATE_BITMAP_TABLE;
1767 else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) )
1768 nTable = SW_CREATE_TRANSGRADIENT_TABLE;
1769 else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MarkerTable") ) )
1770 nTable = SW_CREATE_MARKER_TABLE;
1771 else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Defaults") ) )
1772 nTable = SW_CREATE_DRAW_DEFAULTS;
1773 if(nTable)
1775 xRet = GetPropertyHelper()->GetDrawTable(nTable);
1779 else if (sCategory == C2U ("document") )
1781 if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.Settings") ) )
1782 xRet = Reference < XInterface > ( *new SwXDocumentSettings ( this ) );
1783 if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ImportEmbeddedObjectResolver") ) )
1785 xRet = (::cppu::OWeakObject * )new SvXMLEmbeddedObjectHelper( *pDocShell, EMBEDDEDOBJECTHELPER_MODE_READ );
1788 else if (sCategory == C2U ("text") )
1790 if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.PrintPreviewSettings") ) )
1791 xRet = Reference < XInterface > ( *new SwXPrintPreviewSettings ( pDocShell->GetDoc() ) );
1792 else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.DocumentSettings") ) )
1793 xRet = Reference < XInterface > ( *new SwXDocumentSettings ( this ) );
1795 else if (sCategory == C2U ("chart2") )
1797 if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.data.DataProvider") ) )
1798 xRet = Reference < XInterface > ( dynamic_cast< chart2::data::XDataProvider * >(pDocShell->getIDocumentChartDataProviderAccess()->GetChartDataProvider()) );
1801 if(!xRet.is())
1803 //! we don't want to insert OLE2 Shapes (e.g. "com.sun.star.drawing.OLE2Shape", ...)
1804 //! like this (by creating them with the documents factory and
1805 //! adding the shapes to the draw page).
1806 //! For inserting OLE objects the proper way is to use
1807 //! "com.sun.star.text.TextEmbeddedObject"!
1808 if (rServiceName.lastIndexOf( C2U(".OLE2Shape") ) == rServiceName.getLength() - 10)
1809 throw ServiceNotRegisteredException(); // declare service to be not registered with this factory
1811 // --> OD 2006-02-22 #b6382898#
1812 // the XML import is allowed to create instances of com.sun.star.drawing.OLE2Shape.
1813 // Thus, a temporary service name is introduced to make this possible.
1814 OUString aTmpServiceName( rServiceName );
1815 if ( bShape &&
1816 rServiceName.compareToAscii( "com.sun.star.drawing.temporaryForXMLImportOLE2Shape" ) == 0 )
1818 aTmpServiceName = OUString::createFromAscii( "com.sun.star.drawing.OLE2Shape" );
1820 //hier den Draw - Service suchen
1821 Reference< XInterface > xTmp = SvxFmMSFactory::createInstance(aTmpServiceName);
1822 // <--
1823 if(bShape)
1825 nIndex = COM_SUN_STAR__DRAWING_LENGTH;
1826 if( 0 == rServiceName.reverseCompareToAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.drawing.GroupShape" ) ) ||
1827 0 == rServiceName.reverseCompareToAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.drawing.Shape3DSceneObject" ) ) )
1828 xRet = *new SwXGroupShape( xTmp );
1829 else
1830 xRet = *new SwXShape( xTmp );
1832 else
1833 xRet = xTmp;
1836 else
1837 throw ServiceNotRegisteredException();
1839 return xRet;
1841 /*-- 11.03.99 11:51:40---------------------------------------------------
1843 -----------------------------------------------------------------------*/
1844 Reference< XInterface > SwXTextDocument::createInstanceWithArguments(
1845 const OUString& ServiceSpecifier,
1846 const Sequence< Any >& /*Arguments*/)
1847 throw( Exception, RuntimeException )
1849 Reference< XInterface > xInt = createInstance(ServiceSpecifier);
1850 //die Any-Sequence dient zur Initialisierung von Objekten, die auf
1851 //Parameter zwingend angewiesen sind - bis jetzt haben wir das nicht
1852 return xInt;
1854 /*-- 11.03.99 11:51:41---------------------------------------------------
1856 -----------------------------------------------------------------------*/
1857 Sequence< OUString > SwXTextDocument::getAvailableServiceNames(void)
1858 throw( RuntimeException )
1860 static Sequence< OUString > aServices;
1861 if ( aServices.getLength() == 0 )
1863 Sequence< OUString > aRet = SvxFmMSFactory::getAvailableServiceNames();
1864 OUString* pRet = aRet.getArray();
1865 for ( sal_Int32 i = 0; i < aRet.getLength(); ++i )
1867 if ( pRet[i].compareToAscii( "com.sun.star.drawing.OLE2Shape" ) == 0 )
1869 pRet[i] = pRet[aRet.getLength() - 1];
1870 aRet.realloc( aRet.getLength() - 1 ); // <pRet> no longer valid.
1871 break;
1874 Sequence< OUString > aOwn = SwXServiceProvider::GetAllServiceNames();
1875 aServices = SvxFmMSFactory::concatServiceNames(aRet, aOwn);
1878 return aServices;
1880 /* -----------------18.03.99 11:36-------------------
1882 * --------------------------------------------------*/
1883 OUString SwXTextDocument::getImplementationName(void) throw( RuntimeException )
1885 return C2U("SwXTextDocument");
1887 /* -----------------20.01.04 10:14-------------------
1889 * --------------------------------------------------*/
1890 sal_Bool SwXTextDocument::supportsService(const OUString& rServiceName) throw( RuntimeException )
1892 if (
1893 (rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.document.OfficeDocument" ))) ||
1894 (rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.text.GenericTextDocument")))
1896 return sal_True;
1898 BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell));
1899 BOOL bGlobalDoc = (0 != PTR_CAST(SwGlobalDocShell, pDocShell));
1900 BOOL bTextDoc = (!bWebDoc && !bGlobalDoc);
1902 return (
1903 (bWebDoc && rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.WebDocument" ))) ||
1904 (bGlobalDoc && rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.GlobalDocument"))) ||
1905 (bTextDoc && rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextDocument" )))
1908 /* -----------------20.01.04 10:17-------------------
1910 * --------------------------------------------------*/
1911 Sequence< OUString > SwXTextDocument::getSupportedServiceNames(void) throw( RuntimeException )
1913 BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell));
1914 BOOL bGlobalDoc = (0 != PTR_CAST(SwGlobalDocShell, pDocShell));
1915 BOOL bTextDoc = (!bWebDoc && !bGlobalDoc);
1917 Sequence< OUString > aRet (3);
1918 OUString* pArray = aRet.getArray();
1920 pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.document.OfficeDocument" ) ) );
1921 pArray[1] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.text.GenericTextDocument" ) ) );
1923 if (bTextDoc)
1924 pArray[2] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.text.TextDocument" ) ) );
1925 else
1926 if (bWebDoc)
1927 pArray[2] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.text.WebDocument" ) ) );
1928 else
1929 if (bGlobalDoc)
1930 pArray[2] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.text.GlobalDocument" ) ) );
1932 return aRet;
1934 /* -----------------05.05.99 12:10-------------------
1936 * --------------------------------------------------*/
1937 Reference< XIndexAccess > SwXTextDocument::getDocumentIndexes(void) throw( RuntimeException )
1939 ::vos::OGuard aGuard(Application::GetSolarMutex());
1940 if(!IsValid())
1941 throw RuntimeException();
1942 if(!pxXDocumentIndexes)
1944 ((SwXTextDocument*)this)->pxXDocumentIndexes = new Reference< XIndexAccess > ;
1945 *pxXDocumentIndexes = new SwXDocumentIndexes(pDocShell->GetDoc());
1947 return *pxXDocumentIndexes;
1950 /*-- 10.05.99 13:58:58---------------------------------------------------
1952 -----------------------------------------------------------------------*/
1953 Reference< XPropertySetInfo > SwXTextDocument::getPropertySetInfo(void) throw( RuntimeException )
1955 static Reference< XPropertySetInfo > xRet = aPropSet.getPropertySetInfo();
1956 return xRet;
1958 /*-- 10.05.99 13:58:58---------------------------------------------------
1960 -----------------------------------------------------------------------*/
1961 void SwXTextDocument::setPropertyValue(const OUString& rPropertyName,
1962 const Any& aValue)
1963 throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException,
1964 WrappedTargetException, RuntimeException)
1966 ::vos::OGuard aGuard(Application::GetSolarMutex());
1967 if(!IsValid())
1968 throw RuntimeException();
1969 const SfxItemPropertyMap* pMap = SfxItemPropertyMap::GetByName(
1970 aPropSet.getPropertyMap(), rPropertyName);
1972 if(!pMap)
1973 throw UnknownPropertyException();
1974 if(pMap->nFlags & PropertyAttribute::READONLY)
1975 throw PropertyVetoException();
1976 switch(pMap->nWID)
1978 case WID_DOC_CHAR_COUNT :
1979 case WID_DOC_PARA_COUNT :
1980 case WID_DOC_WORD_COUNT :
1981 throw RuntimeException();
1982 case WID_DOC_WORD_SEPARATOR :
1984 OUString sDelim;
1985 aValue >>= sDelim;
1986 SW_MOD()->GetModuleConfig()->SetWordDelimiter(sDelim);
1988 break;
1989 case WID_DOC_CHANGES_RECORD:
1990 case WID_DOC_CHANGES_SHOW:
1992 sal_Bool bSet = *(sal_Bool*)aValue.getValue();
1993 sal_uInt16 eMode = pDocShell->GetDoc()->GetRedlineMode();
1994 if(WID_DOC_CHANGES_SHOW == pMap->nWID)
1996 eMode &= ~(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE);
1997 eMode |= nsRedlineMode_t::REDLINE_SHOW_INSERT;
1998 if( bSet )
1999 eMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE;
2001 else if(WID_DOC_CHANGES_RECORD == pMap->nWID)
2003 eMode = bSet ? eMode|nsRedlineMode_t::REDLINE_ON : eMode&~nsRedlineMode_t::REDLINE_ON;
2005 pDocShell->GetDoc()->SetRedlineMode( (RedlineMode_t)(eMode ));
2007 break;
2008 case WID_DOC_CHANGES_PASSWORD:
2010 Sequence <sal_Int8> aNew;
2011 if(aValue >>= aNew)
2013 SwDoc* pDoc = pDocShell->GetDoc();
2014 pDoc->SetRedlinePassword(aNew);
2015 if(aNew.getLength())
2017 sal_uInt16 eMode = pDoc->GetRedlineMode();
2018 eMode = eMode|nsRedlineMode_t::REDLINE_ON;
2019 pDoc->SetRedlineMode( (RedlineMode_t)(eMode ));
2023 break;
2024 case WID_DOC_AUTO_MARK_URL :
2026 OUString sURL;
2027 aValue >>= sURL;
2028 pDocShell->GetDoc()->SetTOIAutoMarkURL(sURL);
2030 break;
2031 case WID_DOC_HIDE_TIPS :
2032 SW_MOD()->GetModuleConfig()->SetHideFieldTips(*(sal_Bool*)aValue.getValue());
2033 break;
2034 case WID_DOC_REDLINE_DISPLAY:
2036 sal_Int16 eRedMode = pDocShell->GetDoc()->GetRedlineMode();
2037 eRedMode = eRedMode & (~nsRedlineMode_t::REDLINE_SHOW_MASK);
2038 sal_Int16 nSet = 0;
2039 aValue >>= nSet;
2040 switch(nSet)
2042 case RedlineDisplayType::NONE: break;
2043 case RedlineDisplayType::INSERTED: eRedMode |= nsRedlineMode_t::REDLINE_SHOW_INSERT; break;
2044 case RedlineDisplayType::REMOVED: eRedMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE; break;
2045 case RedlineDisplayType::
2046 INSERTED_AND_REMOVED: eRedMode |= nsRedlineMode_t::REDLINE_SHOW_INSERT|nsRedlineMode_t::REDLINE_SHOW_DELETE;
2047 break;
2048 default: throw IllegalArgumentException();
2050 pDocShell->GetDoc()->SetRedlineMode(eRedMode);
2052 break;
2053 case WID_DOC_TWO_DIGIT_YEAR:
2055 sal_Int16 nYear = 0;
2056 aValue >>= nYear;
2057 SfxRequest aRequest ( SID_ATTR_YEAR2000, SFX_CALLMODE_SLOT, pDocShell->GetDoc()->GetAttrPool());
2058 aRequest.AppendItem(SfxUInt16Item( SID_ATTR_YEAR2000, static_cast < sal_uInt16 > ( nYear ) ) );
2059 pDocShell->Execute ( aRequest );
2061 break;
2062 case WID_DOC_AUTOMATIC_CONTROL_FOCUS:
2064 SwDrawDocument * pDrawDoc;
2065 sal_Bool bAuto = *(sal_Bool*) aValue.getValue();
2067 if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * >( pDocShell->GetDoc()->GetDrawModel() ) ) )
2068 pDrawDoc->SetAutoControlFocus( bAuto );
2069 else if (bAuto)
2071 // if setting to true, and we don't have an
2072 // SdrModel, then we are changing the default and
2073 // must thus create an SdrModel, if we don't have an
2074 // SdrModel and we are leaving the default at false,
2075 // we don't need to make an SdrModel and can do nothing
2076 // --> OD 2005-08-08 #i52858# - method name changed
2077 pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetOrCreateDrawModel() );
2078 // <--
2079 pDrawDoc->SetAutoControlFocus ( bAuto );
2082 break;
2083 case WID_DOC_APPLY_FORM_DESIGN_MODE:
2085 SwDrawDocument * pDrawDoc;
2086 sal_Bool bMode = *(sal_Bool*)aValue.getValue();
2088 if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetDrawModel() ) ) )
2089 pDrawDoc->SetOpenInDesignMode( bMode );
2090 else if (!bMode)
2092 // if setting to false, and we don't have an
2093 // SdrModel, then we are changing the default and
2094 // must thus create an SdrModel, if we don't have an
2095 // SdrModel and we are leaving the default at true,
2096 // we don't need to make an SdrModel and can do
2097 // nothing
2098 // --> OD 2005-08-08 #i52858# - method name changed
2099 pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetOrCreateDrawModel() );
2100 // <--
2101 pDrawDoc->SetOpenInDesignMode ( bMode );
2104 break;
2105 // --> FME 2005-02-25 #i42634# New property to set the bInReading
2106 // flag at the document, used during binary import
2107 case WID_DOC_LOCK_UPDATES :
2109 SwDoc* pDoc = pDocShell->GetDoc();
2110 bool bBool (false);
2111 if( aValue >>= bBool )
2112 pDoc->SetInReading( bBool );
2114 break;
2115 // <--
2116 case WID_DOC_BUILDID:
2117 aValue >>= maBuildId;
2118 break;
2119 // --> OD 2006-03-21 #b6375613#
2120 case WID_APPLY_WORKAROUND_FOR_B6375613:
2122 bool bApplyWorkaroundForB6375613( false );
2123 aValue >>= bApplyWorkaroundForB6375613;
2124 pDocShell->GetDoc()->SetApplyWorkaroundForB6375613( bApplyWorkaroundForB6375613 );
2126 break;
2127 // <--
2129 default:
2131 const SfxPoolItem& rItem = pDocShell->GetDoc()->GetDefault(pMap->nWID);
2132 SfxPoolItem* pNewItem = rItem.Clone();
2133 pNewItem->PutValue(aValue, pMap->nMemberId);
2134 pDocShell->GetDoc()->SetDefault(*pNewItem);
2135 delete pNewItem;
2139 /*-- 10.05.99 13:58:59---------------------------------------------------
2141 -----------------------------------------------------------------------*/
2142 Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName)
2143 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
2145 ::vos::OGuard aGuard(Application::GetSolarMutex());
2146 if(!IsValid())
2147 throw RuntimeException();
2148 const SfxItemPropertyMap* pMap = SfxItemPropertyMap::GetByName(
2149 aPropSet.getPropertyMap(), rPropertyName);
2151 if(!pMap)
2152 throw UnknownPropertyException();
2153 Any aAny;
2154 switch(pMap->nWID)
2156 case WID_DOC_ISTEMPLATEID :
2157 aAny <<= pDocShell->IsTemplate();
2158 break;
2159 case WID_DOC_CHAR_COUNT :
2160 case WID_DOC_PARA_COUNT :
2161 case WID_DOC_WORD_COUNT :
2163 SwDocStat aStat(pDocShell->GetDoc()->GetDocStat());
2164 if(aStat.bModified)
2165 pDocShell->GetDoc()->UpdateDocStat( aStat );
2166 sal_Int32 nValue;
2167 switch(pMap->nWID)
2169 case WID_DOC_CHAR_COUNT :nValue = aStat.nChar;break;
2170 case WID_DOC_PARA_COUNT :nValue = aStat.nPara;break;
2171 case WID_DOC_WORD_COUNT :nValue = aStat.nWord;break;
2173 aAny <<= nValue;
2175 break;
2176 case WID_DOC_WORD_SEPARATOR :
2178 aAny <<= OUString(SW_MOD()->GetDocStatWordDelim());
2180 break;
2181 case WID_DOC_CHANGES_RECORD:
2182 case WID_DOC_CHANGES_SHOW:
2184 sal_uInt16 eMode = pDocShell->GetDoc()->GetRedlineMode();
2185 sal_Bool bSet = sal_False;
2186 if(WID_DOC_CHANGES_SHOW == pMap->nWID)
2188 sal_uInt16 nMask = nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE;
2189 bSet = (eMode & nMask) == nMask;
2191 else if(WID_DOC_CHANGES_RECORD == pMap->nWID)
2193 bSet = (eMode& nsRedlineMode_t::REDLINE_ON) != 0;
2195 aAny.setValue(&bSet, ::getBooleanCppuType());
2197 break;
2198 case WID_DOC_CHANGES_PASSWORD:
2200 SwDoc* pDoc = pDocShell->GetDoc();
2201 aAny <<= pDoc->GetRedlinePassword();
2203 break;
2204 case WID_DOC_AUTO_MARK_URL :
2205 aAny <<= OUString(pDocShell->GetDoc()->GetTOIAutoMarkURL());
2206 break;
2207 case WID_DOC_HIDE_TIPS :
2209 BOOL bTemp = SW_MOD()->GetModuleConfig()->IsHideFieldTips();
2210 aAny.setValue(&bTemp, ::getBooleanCppuType());
2212 break;
2213 case WID_DOC_REDLINE_DISPLAY:
2215 sal_Int16 eRedMode = pDocShell->GetDoc()->GetRedlineMode();
2216 eRedMode = eRedMode & nsRedlineMode_t::REDLINE_SHOW_MASK;
2217 sal_Int16 nRet = RedlineDisplayType::NONE;
2218 if(nsRedlineMode_t::REDLINE_SHOW_INSERT == eRedMode)
2219 nRet = RedlineDisplayType::INSERTED;
2220 else if(nsRedlineMode_t::REDLINE_SHOW_DELETE == eRedMode)
2221 nRet = RedlineDisplayType::REMOVED;
2222 else if(nsRedlineMode_t::REDLINE_SHOW_MASK == eRedMode)
2223 nRet = RedlineDisplayType::INSERTED_AND_REMOVED;
2224 aAny <<= nRet;
2226 break;
2227 case WID_DOC_FORBIDDEN_CHARS:
2229 GetPropertyHelper();
2230 Reference<XForbiddenCharacters> xRet(xPropertyHelper, UNO_QUERY);
2231 aAny <<= xRet;
2233 break;
2234 case WID_DOC_TWO_DIGIT_YEAR:
2236 aAny <<= static_cast < sal_Int16 > (pDocShell->GetDoc()->GetNumberFormatter ( TRUE )->GetYear2000());
2238 break;
2239 case WID_DOC_AUTOMATIC_CONTROL_FOCUS:
2241 SwDrawDocument * pDrawDoc;
2242 sal_Bool bAuto;
2243 if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetDrawModel() ) ) )
2244 bAuto = pDrawDoc->GetAutoControlFocus();
2245 else
2246 bAuto = sal_False;
2247 aAny.setValue(&bAuto, ::getBooleanCppuType());
2249 break;
2250 case WID_DOC_APPLY_FORM_DESIGN_MODE:
2252 SwDrawDocument * pDrawDoc;
2253 sal_Bool bMode;
2254 if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetDrawModel() ) ) )
2255 bMode = pDrawDoc->GetOpenInDesignMode();
2256 else
2257 bMode = sal_True;
2258 aAny.setValue(&bMode, ::getBooleanCppuType());
2260 break;
2261 case WID_DOC_BASIC_LIBRARIES:
2262 aAny <<= pDocShell->GetBasicContainer();
2263 break;
2264 case WID_DOC_DIALOG_LIBRARIES:
2265 aAny <<= pDocShell->GetDialogContainer();
2266 break;
2267 case WID_DOC_VBA_DOCOBJ:
2269 beans::PropertyValue aProp;
2270 aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ThisWordDoc") );
2271 aProp.Value <<= pDocShell->GetModel();
2272 aAny <<= aProp;
2274 break;
2275 case WID_DOC_RUNTIME_UID:
2276 aAny <<= getRuntimeUID();
2277 break;
2278 case WID_DOC_LOCK_UPDATES :
2279 aAny <<= static_cast<bool>( pDocShell->GetDoc()->IsInReading() );
2280 break;
2281 case WID_DOC_BUILDID:
2282 aAny <<= maBuildId;
2283 break;
2284 case WID_DOC_HAS_VALID_SIGNATURES:
2285 aAny <<= hasValidSignatures();
2286 break;
2287 // --> OD 2006-03-21 #b6375613#
2288 case WID_APPLY_WORKAROUND_FOR_B6375613:
2290 aAny <<= pDocShell->GetDoc()->ApplyWorkaroundForB6375613();
2292 break;
2293 // <--
2295 default:
2297 const SfxPoolItem& rItem = pDocShell->GetDoc()->GetDefault(pMap->nWID);
2298 rItem.QueryValue(aAny, pMap->nMemberId);
2301 return aAny;
2303 /*-- 10.05.99 13:58:59---------------------------------------------------
2305 -----------------------------------------------------------------------*/
2306 void SwXTextDocument::addPropertyChangeListener(const OUString& /*PropertyName*/,
2307 const Reference< XPropertyChangeListener > & /*aListener*/)
2308 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
2310 DBG_WARNING("not implemented");
2312 /*-- 10.05.99 13:58:59---------------------------------------------------
2314 -----------------------------------------------------------------------*/
2315 void SwXTextDocument::removePropertyChangeListener(const OUString& /*PropertyName*/,
2316 const Reference< XPropertyChangeListener > & /*aListener*/)
2317 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
2319 DBG_WARNING("not implemented");
2321 /*-- 10.05.99 13:59:00---------------------------------------------------
2323 -----------------------------------------------------------------------*/
2324 void SwXTextDocument::addVetoableChangeListener(const OUString& /*PropertyName*/,
2325 const Reference< XVetoableChangeListener > & /*aListener*/)
2326 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
2328 DBG_WARNING("not implemented");
2330 /*-- 10.05.99 13:59:00---------------------------------------------------
2332 -----------------------------------------------------------------------*/
2333 void SwXTextDocument::removeVetoableChangeListener(const OUString& /*PropertyName*/,
2334 const Reference< XVetoableChangeListener > & /*aListener*/)
2335 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
2337 DBG_WARNING("not implemented");
2339 /* -----------------25.10.99 10:42-------------------
2341 --------------------------------------------------*/
2342 Reference< XNameAccess > SwXTextDocument::getLinks(void) throw( RuntimeException )
2344 if(!pxLinkTargetSupplier)
2346 pxLinkTargetSupplier = new Reference< XNameAccess > ;
2347 (*pxLinkTargetSupplier) = new SwXLinkTargetSupplier(*(SwXTextDocument*)this);
2349 return (*pxLinkTargetSupplier);
2351 /* -----------------------------11.01.01 15:01--------------------------------
2353 ---------------------------------------------------------------------------*/
2354 Reference< XEnumerationAccess > SwXTextDocument::getRedlines( ) throw(RuntimeException)
2356 if(!pxXRedlines)
2358 pxXRedlines = new Reference< XEnumerationAccess > ;
2359 (*pxXRedlines) = new SwXRedlines(pDocShell->GetDoc());
2361 return *pxXRedlines;
2363 /*-- 21.02.00 08:41:06---------------------------------------------------
2365 -----------------------------------------------------------------------*/
2366 void SwXTextDocument::refresh(void) throw( RuntimeException )
2368 ::vos::OGuard aGuard(Application::GetSolarMutex());
2369 if(!IsValid())
2370 throw RuntimeException();
2371 SwWrtShell *pWrtShell = pDocShell->GetWrtShell();
2372 notifyRefreshListeners();
2373 if(pWrtShell)
2374 pWrtShell->CalcLayout();
2376 /*-- 21.02.00 08:41:06---------------------------------------------------
2378 -----------------------------------------------------------------------*/
2379 void SwXTextDocument::addRefreshListener(const Reference< util::XRefreshListener > & l)
2380 throw( RuntimeException )
2382 ::vos::OGuard aGuard(Application::GetSolarMutex());
2383 if ( !IsValid() )
2384 throw RuntimeException();
2385 aRefreshCont.AddListener ( reinterpret_cast < const Reference < lang::XEventListener > &> ( l ));
2387 /*-- 21.02.00 08:41:07---------------------------------------------------
2389 -----------------------------------------------------------------------*/
2390 void SwXTextDocument::removeRefreshListener(const Reference< util::XRefreshListener > & l)
2391 throw( RuntimeException )
2393 ::vos::OGuard aGuard(Application::GetSolarMutex());
2394 if ( !IsValid() || !aRefreshCont.RemoveListener ( reinterpret_cast < const Reference < lang::XEventListener > &> ( l ) ) )
2395 throw RuntimeException();
2397 /* -----------------------------26.02.01 12:22--------------------------------
2399 ---------------------------------------------------------------------------*/
2400 void SwXTextDocument::updateLinks( ) throw(RuntimeException)
2402 ::vos::OGuard aGuard(Application::GetSolarMutex());
2403 if(!IsValid())
2404 throw RuntimeException();
2405 SwDoc* pDoc = pDocShell->GetDoc();
2406 SvxLinkManager& rLnkMan = pDoc->GetLinkManager();
2407 if( rLnkMan.GetLinks().Count() )
2409 UnoActionContext aAction(pDoc);
2410 rLnkMan.UpdateAllLinks( FALSE, FALSE, TRUE );
2413 //XPropertyState
2414 PropertyState SAL_CALL SwXTextDocument::getPropertyState( const OUString& rPropertyName )
2415 throw (UnknownPropertyException, RuntimeException)
2417 ::vos::OGuard aGuard(Application::GetSolarMutex());
2418 PropertyState eRet = PropertyState_DIRECT_VALUE;
2419 if(!IsValid())
2420 throw RuntimeException();
2421 const SfxItemPropertyMap* pMap = SfxItemPropertyMap::GetByName(
2422 aPropSet.getPropertyMap(), rPropertyName);
2424 if(!pMap)
2425 throw UnknownPropertyException();
2426 Any aAny;
2427 switch(pMap->nWID)
2429 case 0:default:break;
2431 return eRet;
2433 Sequence< PropertyState > SAL_CALL SwXTextDocument::getPropertyStates( const Sequence< OUString >& rPropertyNames )
2434 throw (UnknownPropertyException, RuntimeException)
2436 const sal_Int32 nCount = rPropertyNames.getLength();
2437 const OUString * pNames = rPropertyNames.getConstArray();
2438 Sequence < PropertyState > aRet ( nCount );
2439 PropertyState *pState = aRet.getArray();
2441 for ( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++)
2442 pState[nIndex] = getPropertyState( pNames[nIndex] );
2444 return aRet;
2446 void SAL_CALL SwXTextDocument::setPropertyToDefault( const OUString& rPropertyName )
2447 throw (UnknownPropertyException, RuntimeException)
2449 ::vos::OGuard aGuard(Application::GetSolarMutex());
2450 if(!IsValid())
2451 throw RuntimeException();
2452 const SfxItemPropertyMap* pMap = SfxItemPropertyMap::GetByName(
2453 aPropSet.getPropertyMap(), rPropertyName);
2454 if(!pMap)
2455 throw UnknownPropertyException();
2456 switch(pMap->nWID)
2458 case 0:default:break;
2461 Any SAL_CALL SwXTextDocument::getPropertyDefault( const OUString& rPropertyName )
2462 throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
2464 ::vos::OGuard aGuard(Application::GetSolarMutex());
2465 if(!IsValid())
2466 throw RuntimeException();
2467 const SfxItemPropertyMap* pMap = SfxItemPropertyMap::GetByName(
2468 aPropSet.getPropertyMap(), rPropertyName);
2469 if(!pMap)
2470 throw UnknownPropertyException();
2471 Any aAny;
2472 switch(pMap->nWID)
2474 case 0:default:break;
2476 return aAny;
2478 /*-- 06.01.2004 15:08:34---------------------------------------------------
2479 The class SwViewOptionAdjust_Impl is used to adjust the SwViewOption of
2480 the current ViewShell so that fields are not printed as commands and
2481 hidden text and hidden characters are always invisible.
2482 After printing the view options are restored
2483 -----------------------------------------------------------------------*/
2484 class SwViewOptionAdjust_Impl
2486 bool m_bSwitchOff_IsFldName;
2487 bool m_bSwitchOff_PlaceHolderView;
2488 bool m_bSwitchOff_HiddenChar;
2489 bool m_bSwitchOff_HiddenParagraphs;
2490 bool m_bSwitchOff_IsShowHiddenField;
2492 SwViewOption* m_pViewOption;
2493 SwWrtShell& m_rShell;
2494 public:
2495 SwViewOptionAdjust_Impl(SwWrtShell& rSh);
2496 ~SwViewOptionAdjust_Impl();
2498 /*-- 06.01.2004 15:08:34---------------------------------------------------
2500 -----------------------------------------------------------------------*/
2501 SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl(SwWrtShell& rSh) :
2502 m_pViewOption(0),
2503 m_rShell(rSh)
2505 const SwViewOption* pCurrentViewOptions = m_rShell.GetViewOptions();
2506 m_bSwitchOff_IsFldName = pCurrentViewOptions->IsFldName() && m_rShell.IsAnyFieldInDoc();
2507 bool bApplyViewOptions = m_bSwitchOff_IsFldName;
2508 //switch off painting of placeholder fields
2509 m_bSwitchOff_PlaceHolderView = pCurrentViewOptions->IsShowPlaceHolderFields();
2510 //switch off display of hidden characters if on and hidden characters are in use
2511 m_bSwitchOff_HiddenChar = pCurrentViewOptions->IsShowHiddenChar() && m_rShell.GetDoc()->ContainsHiddenChars();
2512 //switch off display of hidden paragraphs if on and hidden paragraphs are in use
2513 m_bSwitchOff_HiddenParagraphs = pCurrentViewOptions->IsShowHiddenPara();
2514 if(m_bSwitchOff_HiddenParagraphs)
2516 const SwFieldType* pFldType = m_rShell.GetDoc()->GetSysFldType(RES_HIDDENPARAFLD);
2517 if(!pFldType || !pFldType->GetDepends())
2518 m_bSwitchOff_HiddenParagraphs = false;
2520 m_bSwitchOff_IsShowHiddenField = pCurrentViewOptions->IsShowHiddenField();
2521 if(m_bSwitchOff_IsShowHiddenField)
2523 const SwFieldType* pFldType = m_rShell.GetDoc()->GetSysFldType(RES_HIDDENTXTFLD);
2524 if( !pFldType || !pFldType->GetDepends())
2525 m_bSwitchOff_IsShowHiddenField = false;
2528 bApplyViewOptions |= m_bSwitchOff_PlaceHolderView;
2529 bApplyViewOptions |= m_bSwitchOff_HiddenChar;
2530 bApplyViewOptions |= m_bSwitchOff_HiddenParagraphs;
2531 bApplyViewOptions |= m_bSwitchOff_IsShowHiddenField;
2532 if(bApplyViewOptions)
2534 m_pViewOption = new SwViewOption(*m_rShell.GetViewOptions());
2535 if(m_bSwitchOff_IsFldName)
2536 m_pViewOption->SetFldName(FALSE);
2537 if(m_bSwitchOff_PlaceHolderView)
2538 m_pViewOption->SetShowPlaceHolderFields(FALSE);
2539 if(m_bSwitchOff_HiddenChar)
2540 m_pViewOption->SetShowHiddenChar(FALSE);
2541 if(m_bSwitchOff_HiddenParagraphs)
2542 m_pViewOption->SetShowHiddenPara(FALSE);
2543 if(m_bSwitchOff_IsShowHiddenField)
2544 m_pViewOption->SetShowHiddenField(FALSE);
2545 SW_MOD()->ApplyUsrPref(*m_pViewOption, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY );
2548 /*-- 06.01.2004 15:08:34---------------------------------------------------
2550 -----------------------------------------------------------------------*/
2551 SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl()
2553 if(m_pViewOption)
2555 if(m_bSwitchOff_IsFldName)
2556 m_pViewOption->SetFldName(TRUE);
2557 if(m_bSwitchOff_PlaceHolderView)
2558 m_pViewOption->SetShowPlaceHolderFields(TRUE);
2559 if(m_bSwitchOff_HiddenChar)
2560 m_pViewOption->SetShowHiddenChar(TRUE);
2561 if(m_bSwitchOff_HiddenParagraphs)
2562 m_pViewOption->SetShowHiddenPara(TRUE);
2563 if(m_bSwitchOff_IsShowHiddenField)
2564 m_pViewOption->SetShowHiddenField(TRUE);
2565 SW_MOD()->ApplyUsrPref(*m_pViewOption, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY );
2566 delete m_pViewOption;
2569 /* -----------------------------23.08.02 16:00--------------------------------
2571 ---------------------------------------------------------------------------*/
2573 * GetRenderDoc:
2574 * returns the document to be rendered, usually this will be the 'regular'
2575 * document but in case of PDF export of (multi-)selection it will
2576 * be a temporary document that gets created if not already done.
2577 * The rpView variable will be set (if not already done) to the used
2578 * SfxViewShell.
2581 SwDoc * SwXTextDocument::GetRenderDoc( SfxViewShell *&rpView, const uno::Any& rSelection )
2583 SwDoc *pDoc = 0;
2585 uno::Reference< frame::XModel > xModel;
2586 rSelection >>= xModel;
2587 if (xModel == pDocShell->GetModel())
2588 pDoc = pDocShell->GetDoc();
2589 else
2591 // used for PDF export of (multi-)selection
2592 if (rSelection.hasValue()) // is anything selected ?
2594 if (!rpView)
2595 rpView = GuessViewShell();
2596 DBG_ASSERT( rpView, "ViewShell missing" );
2597 // the view shell should be SwView for documents PDF export.
2598 // for the page preview no selection should be possible
2599 // (the export dialog does not allow for this option)
2600 const TypeId aSwViewTypeId = TYPE(SwView);
2601 if (rpView && rpView->IsA(aSwViewTypeId))
2603 SfxObjectShellRef xDocSh(((SwView*)rpView)->GetOrCreateTmpSelectionDoc());
2604 if (xDocSh.Is())
2606 pDoc = ((SwDocShell*)&xDocSh)->GetDoc();
2607 rpView = pDoc->GetDocShell()->GetView();
2610 else {
2611 DBG_ERROR( "unexpected ViewShell" );
2615 return pDoc;
2617 /* -----------------------------23.08.02 16:00--------------------------------
2619 ---------------------------------------------------------------------------*/
2620 sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
2621 const uno::Any& rSelection,
2622 const uno::Sequence< beans::PropertyValue >& /*rxOptions*/ )
2623 throw (IllegalArgumentException, RuntimeException)
2625 ::vos::OGuard aGuard(Application::GetSolarMutex());
2626 if(!IsValid())
2627 throw RuntimeException();
2628 SfxViewShell *pView = 0;
2629 SwDoc *pDoc = GetRenderDoc( pView, rSelection );
2630 if (!pDoc)
2631 throw RuntimeException();
2633 SwDocShell *pRenderDocShell = pDoc->GetDocShell();
2634 // #i38289
2635 if(pDoc->get(IDocumentSettingAccess::BROWSE_MODE))
2637 pRenderDocShell->ToggleBrowserMode(false,NULL);
2640 SwWrtShell *pWrtShell = pRenderDocShell->GetWrtShell();
2642 sal_Int32 nRet = 0;
2643 if( !pWrtShell )
2645 //create a hidden view to be able to export as PDF also in print preview
2646 m_pHiddenViewFrame = SfxViewFrame::CreateViewFrame( *pRenderDocShell, 2, TRUE );
2647 SwView* pSwView = (SwView*) m_pHiddenViewFrame->GetViewShell();
2648 pWrtShell = pSwView->GetWrtShellPtr();
2651 SwViewOptionAdjust_Impl aAdjust(*pWrtShell);
2652 pWrtShell->SetPDFExportOption( sal_True );
2653 // --> FME 2005-05-23 #122919# Force field update before PDF export:
2654 pWrtShell->ViewShell::UpdateFlds(TRUE);
2655 // <--
2656 pWrtShell->CalcLayout();
2657 pWrtShell->SetPDFExportOption( sal_False );
2658 nRet = pDoc->GetPageCount();
2660 return nRet;
2662 /* -----------------------------23.08.02 16:00--------------------------------
2664 ---------------------------------------------------------------------------*/
2665 uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
2666 sal_Int32 nRenderer,
2667 const uno::Any& rSelection,
2668 const uno::Sequence< beans::PropertyValue >& rxOptions )
2669 throw (IllegalArgumentException, RuntimeException)
2671 ::vos::OGuard aGuard(Application::GetSolarMutex());
2672 if(!IsValid())
2673 throw RuntimeException();
2674 SfxViewShell *pView = 0;
2675 SwDoc *pDoc = GetRenderDoc( pView, rSelection );
2676 if (!pDoc)
2677 throw RuntimeException();
2679 // due to #110067# (document page count changes sometimes during
2680 // PDF export/printing) we can not check for the upper bound properly.
2681 // Thus instead of throwing the exception we silently return.
2682 if (!(0 <= nRenderer /* && nRenderer < pDoc->GetPageCount()*/))
2683 throw IllegalArgumentException();
2684 if (nRenderer >= pDoc->GetPageCount())
2685 return uno::Sequence< beans::PropertyValue >();
2687 bool bSkipEmptyPages = false;
2688 for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty )
2690 if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "IsSkipEmptyPages" ) ) )
2691 rxOptions[ nProperty].Value >>= bSkipEmptyPages;
2694 Size aPgSize( pDoc->GetPageSize( sal_uInt16(nRenderer + 1), bSkipEmptyPages ) );
2696 awt::Size aPageSize( TWIP_TO_MM100( aPgSize.Width() ),
2697 TWIP_TO_MM100( aPgSize.Height() ));
2698 uno::Sequence< beans::PropertyValue > aRenderer(1);
2699 PropertyValue &rValue = aRenderer.getArray()[0];
2700 rValue.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) );
2701 rValue.Value <<= aPageSize;
2703 return aRenderer;
2705 /* -----------------------------28.10.02 16:00--------------------------------
2707 ---------------------------------------------------------------------------*/
2708 SfxViewShell * SwXTextDocument::GuessViewShell()
2710 // #130810# SfxViewShell::Current() / SfxViewShell::GetObjectShell()
2711 // must not be used (see comment from MBA)
2713 SfxViewShell *pView = 0;
2714 SwView *pSwView = 0;
2715 SwPagePreView *pSwPagePreView = 0;
2716 SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pDocShell, 0, sal_False );
2717 while (pFrame)
2719 pView = pFrame->GetViewShell();
2720 pSwView = dynamic_cast< SwView * >(pView);
2721 if (pSwView)
2722 break;
2723 if (!pSwPagePreView)
2724 pSwPagePreView = dynamic_cast< SwPagePreView * >(pView);
2725 pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell, 0, sal_False );
2728 return pSwView ? pSwView : dynamic_cast< SwView * >(pSwPagePreView);
2731 /* -----------------------------23.08.02 16:00--------------------------------
2733 ---------------------------------------------------------------------------*/
2734 void SAL_CALL SwXTextDocument::render(
2735 sal_Int32 nRenderer,
2736 const uno::Any& rSelection,
2737 const uno::Sequence< beans::PropertyValue >& rxOptions )
2738 throw (IllegalArgumentException, RuntimeException)
2740 ::vos::OGuard aGuard(Application::GetSolarMutex());
2741 if(!IsValid())
2742 throw RuntimeException();
2743 SfxViewShell *pView = GuessViewShell();
2744 SwDoc *pDoc = GetRenderDoc( pView, rSelection );
2745 if (!pDoc || !pView)
2746 throw RuntimeException();
2748 // due to #110067# (document page count changes sometimes during
2749 // PDF export/printing) we can not check for the upper bound properly.
2750 // Thus instead of throwing the exception we silently return.
2751 if (!(0 <= nRenderer /* && nRenderer < pDoc->GetPageCount()*/))
2752 throw IllegalArgumentException();
2753 if (nRenderer >= pDoc->GetPageCount())
2754 return;
2756 // the view shell should be SwView for documents PDF export
2757 // or SwPagePreView for PDF export of the page preview
2758 //!! (check for SwView first as in GuessViewShell) !!
2759 const TypeId aSwViewTypeId = TYPE(SwView);
2760 ViewShell* pVwSh = pView->IsA(aSwViewTypeId) ?
2761 ((SwView*)pView)->GetWrtShellPtr() :
2762 ((SwPagePreView*)pView)->GetViewShell();
2764 uno::Reference< awt::XDevice > xRenderDevice;
2765 bool bFirstPage = false;
2766 bool bLastPage = false;
2767 rtl::OUString aPages;
2768 bool bSkipEmptyPages = false;
2770 for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty )
2772 if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) )
2773 rxOptions[ nProperty].Value >>= xRenderDevice;
2774 else if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFirstPage" ) ) )
2775 rxOptions[ nProperty].Value >>= bFirstPage;
2776 else if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "IsLastPage" ) ) )
2777 rxOptions[ nProperty].Value >>= bLastPage;
2778 else if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ) )
2779 rxOptions[ nProperty].Value >>= aPages;
2780 else if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "IsSkipEmptyPages" ) ) )
2781 rxOptions[ nProperty].Value >>= bSkipEmptyPages;
2784 OutputDevice* pOut = 0;
2785 if (xRenderDevice.is())
2787 VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice );
2788 pOut = pDevice ? pDevice->GetOutputDevice() : 0;
2791 if(pVwSh && pOut)
2793 SwPrtOptions aOptions( C2U("PDF export") );
2795 const TypeId aSwWebDocShellTypeId = TYPE(SwWebDocShell);
2796 BOOL bWeb = pDocShell->IsA( aSwWebDocShellTypeId );
2797 SwView::MakeOptions( NULL, aOptions, NULL, NULL, bWeb, NULL, NULL );
2799 Range aPageRange( nRenderer+1, nRenderer+1 );
2800 MultiSelection aPage( aPageRange );
2801 aPage.SetTotalRange( Range( 0, RANGE_MAX ) );
2802 aPage.Select( aPageRange );
2803 aOptions.aMulti = aPage;
2805 //! Note: Since for PDF export of (multi-)selection a temporary
2806 //! document is created that contains only the selects parts,
2807 //! and thus that document is to printed in whole the,
2808 //! aOptions.bPrintSelection parameter will be false.
2809 aOptions.bPrintSelection = FALSE;
2811 SwViewOptionAdjust_Impl* pViewOptionAdjust = pView->IsA(aSwViewTypeId) ?
2812 new SwViewOptionAdjust_Impl(*((SwView*)pView)->GetWrtShellPtr()) : 0;
2815 pVwSh->SetPDFExportOption( sal_True );
2817 // --> FME 2004-06-08 #i12836# enhanced pdf export
2819 // First, we have to export hyperlinks, notes, and outline to pdf.
2820 // During this process, additional information required for tagging
2821 // the pdf file are collected, which are evaulated during painting.
2823 SwWrtShell* pWrtShell = pView->IsA(aSwViewTypeId) ?
2824 ((SwView*)pView)->GetWrtShellPtr() :
2827 if ( bFirstPage && pWrtShell )
2829 SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPages, bSkipEmptyPages, sal_False );
2831 // <--
2833 pVwSh->Prt( aOptions, 0, pOut );
2835 // --> FME 2004-10-08 #i35176#
2837 // After printing the last page, we take care for the links coming
2838 // from the EditEngine. The links are generated during the painting
2839 // process, but the destinations are still missing.
2841 if ( bLastPage && pWrtShell )
2843 SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPages, bSkipEmptyPages, sal_True );
2845 // <--
2847 pVwSh->SetPDFExportOption( sal_False );
2848 // #i96167# haggai: delete pViewOptionsAdjust here because it makes use
2849 // of the shell, which might get destroyed in lcl_DisposeView!
2850 delete pViewOptionAdjust;
2852 if( bLastPage && m_pHiddenViewFrame)
2854 lcl_DisposeView( m_pHiddenViewFrame, pDocShell );
2855 m_pHiddenViewFrame = 0;
2859 /* -----------------------------03.10.04 -------------------------------------
2861 ---------------------------------------------------------------------------*/
2862 // xforms::XFormsSupplier
2863 Reference<XNameContainer> SAL_CALL SwXTextDocument::getXForms()
2864 throw( RuntimeException )
2866 if ( !pDocShell )
2867 throw DisposedException( ::rtl::OUString(), static_cast< XTextDocument* >( this ) );
2868 SwDoc* pDoc = pDocShell->GetDoc();
2869 return pDoc->getXForms();
2872 /* -----------------------------25.09.07 -------------------------------------
2874 ---------------------------------------------------------------------------*/
2875 uno::Reference< text::XFlatParagraphIterator > SAL_CALL SwXTextDocument::getFlatParagraphIterator(::sal_Int32 nTextMarkupType, sal_Bool bAutomatic)
2876 throw ( uno::RuntimeException )
2878 return new SwXFlatParagraphIterator( *pDocShell->GetDoc(), nTextMarkupType, bAutomatic );
2881 /* -----------------------------20.06.00 09:54--------------------------------
2883 ---------------------------------------------------------------------------*/
2884 void * SAL_CALL SwXTextDocument::operator new( size_t t) throw()
2886 return SwXTextDocumentBaseClass::operator new(t);
2888 /* -----------------------------20.06.00 09:54--------------------------------
2890 ---------------------------------------------------------------------------*/
2891 void SAL_CALL SwXTextDocument::operator delete( void * p) throw()
2893 SwXTextDocumentBaseClass::operator delete(p);
2897 /*---------------------------------------------------
2898 retrieve languages already used in current document
2899 -----------------------------------------------------*/
2900 uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages(
2901 ::sal_Int16 nScriptTypes,
2902 ::sal_Int16 nMaxCount )
2903 throw (lang::IllegalArgumentException, uno::RuntimeException)
2905 ::vos::OGuard aGuard(Application::GetSolarMutex());
2908 // possible canonical values for nScriptTypes
2909 // any bit wise combination is allowed
2910 const sal_Int16 nLatin = 0x001;
2911 const sal_Int16 nAsian = 0x002;
2912 const sal_Int16 nComplex = 0x004;
2914 // script types for which to get the languages
2915 const bool bLatin = 0 != (nScriptTypes & nLatin);
2916 const bool bAsian = 0 != (nScriptTypes & nAsian);
2917 const bool bComplex = 0 != (nScriptTypes & nComplex);
2919 if (nScriptTypes < nLatin || nScriptTypes > (nLatin | nAsian | nComplex))
2920 throw IllegalArgumentException(::rtl::OUString::createFromAscii("nScriptTypes ranges from 1 to 7!"), Reference< XInterface >(), 1);
2921 if (!pDocShell)
2922 throw DisposedException();
2923 SwDoc* pDoc = pDocShell->GetDoc();
2925 // avoid duplicate values
2926 std::set< LanguageType > aAllLangs;
2928 //USER STYLES
2930 const SwCharFmts *pFmts = pDoc->GetCharFmts();
2931 for(USHORT i = 0; i < pFmts->Count(); ++i)
2933 const SwAttrSet &rAttrSet = (*pFmts)[i]->GetAttrSet();
2934 LanguageType nLang = LANGUAGE_DONTKNOW;
2935 if (bLatin)
2937 nLang = rAttrSet.GetLanguage( FALSE ).GetLanguage();
2938 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
2939 aAllLangs.insert( nLang );
2941 if (bAsian)
2943 nLang = rAttrSet.GetCJKLanguage( FALSE ).GetLanguage();
2944 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
2945 aAllLangs.insert( nLang );
2947 if (bComplex)
2949 nLang = rAttrSet.GetCTLLanguage( FALSE ).GetLanguage();
2950 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
2951 aAllLangs.insert( nLang );
2955 const SwTxtFmtColls *pColls = pDoc->GetTxtFmtColls();
2956 for (USHORT i = 0; i < pColls->Count(); ++i)
2958 const SwAttrSet &rAttrSet = (*pColls)[i]->GetAttrSet();
2959 LanguageType nLang = LANGUAGE_DONTKNOW;;
2960 if (bLatin)
2962 nLang = rAttrSet.GetLanguage( FALSE ).GetLanguage();
2963 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
2964 aAllLangs.insert( nLang );
2966 if (bAsian)
2968 nLang = rAttrSet.GetCJKLanguage( FALSE ).GetLanguage();
2969 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
2970 aAllLangs.insert( nLang );
2972 if (bComplex)
2974 nLang = rAttrSet.GetCTLLanguage( FALSE ).GetLanguage();
2975 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
2976 aAllLangs.insert( nLang );
2980 //AUTO STYLES
2981 const IStyleAccess::SwAutoStyleFamily aFam[2] =
2983 IStyleAccess::AUTO_STYLE_CHAR,
2984 IStyleAccess::AUTO_STYLE_PARA
2986 for (sal_uInt16 i = 0; i < 2; ++i)
2988 std::vector< SfxItemSet_Pointer_t > rStyles;
2989 pDoc->GetIStyleAccess().getAllStyles(rStyles, aFam[i]);
2990 while (!rStyles.empty())
2992 SfxItemSet_Pointer_t pStyle = rStyles.back();
2993 rStyles.pop_back();
2994 const SfxItemSet *pSet = dynamic_cast< const SfxItemSet * >(pStyle.get());
2996 LanguageType nLang = LANGUAGE_DONTKNOW;
2997 if (bLatin)
2999 nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_LANGUAGE, FALSE )).GetLanguage();
3000 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3001 aAllLangs.insert( nLang );
3003 if (bAsian)
3005 nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CJK_LANGUAGE, FALSE )).GetLanguage();
3006 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3007 aAllLangs.insert( nLang );
3009 if (bComplex)
3011 nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CTL_LANGUAGE, FALSE )).GetLanguage();
3012 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3013 aAllLangs.insert( nLang );
3018 //get languages from "drawobject"
3019 SwWrtShell *pWrtSh = pDocShell->GetWrtShell();
3020 SdrView *pSdrView = pWrtSh->GetDrawView();
3022 if( pSdrView )
3024 SdrOutliner* pOutliner = pSdrView->GetTextEditOutliner();
3025 if(pOutliner)
3027 EditEngine& rEditEng = (EditEngine&)pOutliner->GetEditEngine();
3028 ULONG nParCount = pOutliner->GetParagraphCount();
3029 for (ULONG nPar=0; nPar<nParCount; nPar++)
3031 //every paragraph
3032 SvUShorts aPortions;
3033 rEditEng.GetPortions( (USHORT)nPar, aPortions );
3035 for ( USHORT nPos = aPortions.Count(); nPos; )
3037 //every position
3038 --nPos;
3039 USHORT nEnd = aPortions.GetObject( nPos );
3040 USHORT nStart = nPos ? aPortions.GetObject( nPos - 1 ) : 0;
3041 ESelection aSelection( (USHORT)nPar, nStart, (USHORT)nPar, nEnd );
3042 SfxItemSet aAttr = rEditEng.GetAttribs( aSelection );
3044 LanguageType nLang = LANGUAGE_DONTKNOW;
3045 if (bLatin)
3047 nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE, FALSE )).GetLanguage();
3048 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3049 aAllLangs.insert( nLang );
3051 if (bAsian)
3053 nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE_CJK, FALSE )).GetLanguage();
3054 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3055 aAllLangs.insert( nLang );
3057 if (bComplex)
3059 nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE_CTL, FALSE )).GetLanguage();
3060 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3061 aAllLangs.insert( nLang );
3067 // less than nMaxCount languages
3068 if (nMaxCount > static_cast< sal_Int16 >( aAllLangs.size() ))
3069 nMaxCount = static_cast< sal_Int16 >( aAllLangs.size() );
3071 // build return value
3072 sal_Int32 nCount = 0;
3073 uno::Sequence< lang::Locale > aLanguages( nMaxCount );
3074 lang::Locale* pLanguage = aLanguages.getArray();
3075 if (nMaxCount > 0)
3077 const SvtLanguageTable aLangTab;
3078 for (std::set< LanguageType >::const_iterator it = aAllLangs.begin(); it != aAllLangs.end(); ++it)
3080 if (nCount >= nMaxCount)
3081 break;
3082 if (LANGUAGE_NONE != *it)
3084 MsLangId::convertLanguageToLocale( *it, pLanguage[nCount] );
3085 pLanguage[nCount].Language = aLangTab.GetString( *it );
3086 nCount += 1;
3091 return aLanguages;
3094 /* -----------------25.10.99 11:06-------------------
3096 --------------------------------------------------*/
3097 SwXLinkTargetSupplier::SwXLinkTargetSupplier(SwXTextDocument& rxDoc) :
3098 pxDoc(&rxDoc)
3100 sTables = String(SW_RES(STR_CONTENT_TYPE_TABLE));
3101 sFrames = String(SW_RES(STR_CONTENT_TYPE_FRAME));
3102 sGraphics = String(SW_RES(STR_CONTENT_TYPE_GRAPHIC));
3103 sOLEs = String(SW_RES(STR_CONTENT_TYPE_OLE));
3104 sSections = String(SW_RES(STR_CONTENT_TYPE_REGION));
3105 sOutlines = String(SW_RES(STR_CONTENT_TYPE_OUTLINE));
3106 sBookmarks = String(SW_RES(STR_CONTENT_TYPE_BOOKMARK));
3108 /* -----------------25.10.99 11:11-------------------
3110 --------------------------------------------------*/
3111 SwXLinkTargetSupplier::~SwXLinkTargetSupplier()
3115 /*-- 25.10.99 11:12:45---------------------------------------------------
3117 -----------------------------------------------------------------------*/
3118 Any SwXLinkTargetSupplier::getByName(const OUString& rName)
3119 throw( NoSuchElementException, WrappedTargetException, RuntimeException )
3121 Any aRet;
3122 if(!pxDoc)
3123 throw RuntimeException();
3124 String sToCompare(rName);
3125 String sSuffix('|');
3126 if(sToCompare == sTables)
3128 sSuffix += UniString::CreateFromAscii(pMarkToTable);
3130 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
3131 pxDoc->getTextTables(), sToCompare, sSuffix );
3132 Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
3133 aRet.setValue(&xRet, ::getCppuType((Reference<XPropertySet>*)0));
3135 else if(sToCompare == sFrames)
3137 sSuffix += UniString::CreateFromAscii(pMarkToFrame);
3138 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
3139 pxDoc->getTextFrames(), sToCompare, sSuffix );
3140 Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
3141 aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
3143 else if(sToCompare == sSections)
3145 sSuffix += UniString::CreateFromAscii(pMarkToRegion);
3146 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
3147 pxDoc->getTextSections(), sToCompare, sSuffix );
3148 Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
3149 aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
3151 /* else if(sToCompare == )
3153 sSuffix += UniString::CreateFromAscii(pMarkToText);
3154 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
3155 pxDoc->, sSuffix );
3156 Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
3157 aRet.setValue(&xRet, ::getCppuType((const XPropertySet*)0));
3159 else if(sToCompare == sGraphics)
3161 sSuffix += UniString::CreateFromAscii(pMarkToGraphic);
3162 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
3163 pxDoc->getGraphicObjects(), sToCompare, sSuffix );
3164 Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
3165 aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
3167 else if(sToCompare == sOLEs)
3169 sSuffix += UniString::CreateFromAscii(pMarkToOLE);
3170 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
3171 pxDoc->getEmbeddedObjects(), sToCompare, sSuffix );
3172 Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
3173 aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
3175 else if(sToCompare == sOutlines)
3177 sSuffix += UniString::CreateFromAscii(pMarkToOutline);
3178 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
3179 *pxDoc, sToCompare, sSuffix );
3180 Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
3181 aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
3183 else if(sToCompare == sBookmarks)
3185 sSuffix.Erase();
3186 Reference< XNameAccess > xBkms = new SwXLinkNameAccessWrapper(
3187 pxDoc->getBookmarks(), sToCompare, sSuffix );
3188 Reference< XPropertySet > xRet(xBkms, UNO_QUERY);
3189 aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
3191 else
3192 throw NoSuchElementException();
3193 return aRet;
3195 /*-- 25.10.99 11:12:46---------------------------------------------------
3197 -----------------------------------------------------------------------*/
3198 Sequence< OUString > SwXLinkTargetSupplier::getElementNames(void)
3199 throw( RuntimeException )
3201 Sequence< OUString > aRet(7);
3202 OUString* pNames = aRet.getArray();
3203 pNames[0] = sTables;
3204 pNames[1] = sFrames ;
3205 pNames[2] = sGraphics;
3206 pNames[3] = sOLEs ;
3207 pNames[4] = sSections;
3208 pNames[5] = sOutlines;
3209 pNames[6] = sBookmarks;
3210 return aRet;
3212 /*-- 25.10.99 11:12:46---------------------------------------------------
3214 -----------------------------------------------------------------------*/
3215 sal_Bool SwXLinkTargetSupplier::hasByName(const OUString& rName)
3216 throw( RuntimeException )
3218 String sToCompare(rName);
3219 if( sToCompare == sTables ||
3220 sToCompare == sFrames ||
3221 sToCompare == sGraphics||
3222 sToCompare == sOLEs ||
3223 sToCompare == sSections ||
3224 sToCompare == sOutlines ||
3225 sToCompare == sBookmarks )
3226 return sal_True;
3227 return sal_False;
3229 /*-- 25.10.99 11:12:47---------------------------------------------------
3231 -----------------------------------------------------------------------*/
3232 uno::Type SwXLinkTargetSupplier::getElementType(void)
3233 throw( RuntimeException )
3235 return ::getCppuType((Reference< XPropertySet>*)0);
3238 /*-- 25.10.99 11:12:47---------------------------------------------------
3240 -----------------------------------------------------------------------*/
3241 sal_Bool SwXLinkTargetSupplier::hasElements(void) throw( RuntimeException )
3243 return 0 != pxDoc;
3245 /*-- 25.10.99 11:12:47---------------------------------------------------
3247 -----------------------------------------------------------------------*/
3248 OUString SwXLinkTargetSupplier::getImplementationName(void) throw( RuntimeException )
3250 return C2U("SwXLinkTargetSupplier");
3252 /*-- 25.10.99 11:12:48---------------------------------------------------
3254 -----------------------------------------------------------------------*/
3255 sal_Bool SwXLinkTargetSupplier::supportsService(const OUString& rServiceName)
3256 throw( RuntimeException )
3258 return (rServiceName == C2U("com.sun.star.document.LinkTargets"));
3260 /*-- 25.10.99 11:12:48---------------------------------------------------
3262 -----------------------------------------------------------------------*/
3263 Sequence< OUString > SwXLinkTargetSupplier::getSupportedServiceNames(void)
3264 throw( RuntimeException )
3266 Sequence< OUString > aRet(1);
3267 OUString* pNames = aRet.getArray();
3268 pNames[0] = C2U("com.sun.star.document.LinkTargets");
3269 return aRet;
3272 /*-- 26.10.99 09:16:23---------------------------------------------------
3274 -----------------------------------------------------------------------*/
3275 SwXLinkNameAccessWrapper::SwXLinkNameAccessWrapper(
3276 Reference< XNameAccess > xAccess, const String& rLinkDisplayName, String sSuffix ) :
3277 xRealAccess(xAccess),
3278 aPropSet(aSwMapProvider.GetPropertyMap(PROPERTY_MAP_LINK_TARGET)),
3279 sLinkSuffix(sSuffix),
3280 sLinkDisplayName(rLinkDisplayName),
3281 pxDoc(0)
3284 /* -----------------26.10.99 14:17-------------------
3286 --------------------------------------------------*/
3287 SwXLinkNameAccessWrapper::SwXLinkNameAccessWrapper(SwXTextDocument& rxDoc,
3288 const String& rLinkDisplayName, String sSuffix) :
3289 aPropSet(aSwMapProvider.GetPropertyMap(PROPERTY_MAP_LINK_TARGET)),
3290 sLinkSuffix(sSuffix),
3291 sLinkDisplayName(rLinkDisplayName),
3292 xDoc(&rxDoc),
3293 pxDoc(&rxDoc)
3296 /*-- 26.10.99 09:16:23---------------------------------------------------
3298 -----------------------------------------------------------------------*/
3299 SwXLinkNameAccessWrapper::~SwXLinkNameAccessWrapper()
3302 /*-- 26.10.99 09:16:24---------------------------------------------------
3304 -----------------------------------------------------------------------*/
3305 Any SwXLinkNameAccessWrapper::getByName(const OUString& rName)
3306 throw( NoSuchElementException, WrappedTargetException, RuntimeException )
3308 Any aRet;
3309 sal_Bool bFound = sal_False;
3310 //cut link extension and call the real NameAccess
3311 String sParam = rName;
3312 String sSuffix(sLinkSuffix);
3313 if(sParam.Len() > sSuffix.Len() )
3315 String sCmp = sParam.Copy(sParam.Len() - sSuffix.Len(),
3316 sSuffix.Len());
3317 if(sCmp == sSuffix)
3319 if(pxDoc)
3321 sParam = sParam.Copy(0, sParam.Len() - sSuffix.Len());
3322 if(!pxDoc->GetDocShell())
3323 throw RuntimeException();
3324 SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
3325 sal_uInt16 nOutlineCount = pDoc->GetNodes().GetOutLineNds().Count();
3327 for (sal_uInt16 i = 0; i < nOutlineCount && !bFound; ++i)
3329 const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
3330 const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
3331 if(sParam ==
3332 lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule))
3334 Reference< XPropertySet > xOutline = new SwXOutlineTarget(sParam);
3335 aRet.setValue(&xOutline, ::getCppuType((Reference<XPropertySet>*)0));
3336 bFound = sal_True;
3340 else
3342 aRet = xRealAccess->getByName(sParam.Copy(0, sParam.Len() - sSuffix.Len()));
3343 Reference< XInterface > xInt;
3344 if(!(aRet >>= xInt))
3345 throw RuntimeException();
3346 Reference< XPropertySet > xProp(xInt, UNO_QUERY);
3347 aRet <<= xProp;
3348 bFound = sal_True;
3352 if(!bFound)
3353 throw NoSuchElementException();
3354 return aRet;
3356 /*-- 26.10.99 09:16:24---------------------------------------------------
3358 -----------------------------------------------------------------------*/
3359 Sequence< OUString > SwXLinkNameAccessWrapper::getElementNames(void)
3360 throw( RuntimeException )
3362 Sequence< OUString > aRet;
3363 if(pxDoc)
3365 if(!pxDoc->GetDocShell())
3366 throw RuntimeException();
3368 SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
3369 const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
3370 sal_uInt16 nOutlineCount = rOutlineNodes.Count();
3371 aRet.realloc(nOutlineCount);
3372 OUString* pResArr = aRet.getArray();
3373 String sSuffix('|');
3374 sSuffix += UniString::CreateFromAscii(pMarkToOutline);
3375 const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
3376 for (sal_uInt16 i = 0; i < nOutlineCount; ++i)
3378 String sEntry = lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule);
3379 sEntry += sSuffix;
3380 pResArr[i] = sEntry;
3383 else
3385 Sequence< OUString > aOrg = xRealAccess->getElementNames();
3386 const OUString* pOrgArr = aOrg.getConstArray();
3387 aRet.realloc(aOrg.getLength());
3388 OUString* pResArr = aRet.getArray();
3389 for(long i = 0; i < aOrg.getLength(); i++)
3391 pResArr[i] = pOrgArr[i] + sLinkSuffix;
3394 return aRet;
3396 /*-- 26.10.99 09:16:25---------------------------------------------------
3398 -----------------------------------------------------------------------*/
3399 sal_Bool SwXLinkNameAccessWrapper::hasByName(const OUString& rName)
3400 throw( RuntimeException )
3402 sal_Bool bRet = sal_False;
3403 String sParam(rName);
3404 if(sParam.Len() > sLinkSuffix.Len() )
3406 String sCmp = sParam.Copy(sParam.Len() - sLinkSuffix.Len(),
3407 sLinkSuffix.Len());
3408 if(sCmp == sLinkSuffix)
3410 sParam = sParam.Copy(0, sParam.Len() - sLinkSuffix.Len());
3411 if(pxDoc)
3413 if(!pxDoc->GetDocShell())
3414 throw RuntimeException();
3415 SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
3416 sal_uInt16 nOutlineCount = pDoc->GetNodes().GetOutLineNds().Count();
3418 for (sal_uInt16 i = 0; i < nOutlineCount && !bRet; ++i)
3420 const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
3421 const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
3422 if(sParam ==
3423 lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule))
3425 bRet = sal_True;
3429 else
3431 bRet = xRealAccess->hasByName(sParam);
3435 return bRet;
3437 /*-- 26.10.99 09:16:25---------------------------------------------------
3439 -----------------------------------------------------------------------*/
3440 uno::Type SwXLinkNameAccessWrapper::getElementType(void)
3441 throw( RuntimeException )
3443 return ::getCppuType((Reference<XPropertySet>*)0);
3445 /*-- 26.10.99 09:16:25---------------------------------------------------
3447 -----------------------------------------------------------------------*/
3448 sal_Bool SwXLinkNameAccessWrapper::hasElements(void) throw( RuntimeException )
3450 sal_Bool bRet = sal_False;
3451 if(pxDoc)
3453 DBG_ERROR("not implemented");
3455 else
3457 bRet = xRealAccess->hasElements();
3459 return bRet;
3461 /*-- 26.10.99 09:16:26---------------------------------------------------
3463 -----------------------------------------------------------------------*/
3464 Reference< XPropertySetInfo > SwXLinkNameAccessWrapper::getPropertySetInfo(void)
3465 throw( RuntimeException )
3467 static Reference< XPropertySetInfo > xRet = aPropSet.getPropertySetInfo();
3468 return xRet;
3470 /*-- 26.10.99 09:16:26---------------------------------------------------
3472 -----------------------------------------------------------------------*/
3473 void SwXLinkNameAccessWrapper::setPropertyValue(
3474 const OUString& , const Any& )
3475 throw( UnknownPropertyException,
3476 PropertyVetoException,
3477 IllegalArgumentException,
3478 WrappedTargetException,
3479 RuntimeException)
3481 throw UnknownPropertyException();
3483 /* -----------------------------08.12.99 11:10--------------------------------
3485 ---------------------------------------------------------------------------*/
3486 Any lcl_GetDisplayBitmap(String sLinkSuffix)
3488 Any aRet;
3489 if(sLinkSuffix.Len())
3490 sLinkSuffix.Erase(0, 1);
3491 sal_uInt16 nImgId = USHRT_MAX;
3493 if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToOutline))
3494 nImgId = CONTENT_TYPE_OUTLINE;
3495 else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToTable))
3496 nImgId = CONTENT_TYPE_TABLE;
3497 else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToFrame))
3498 nImgId = CONTENT_TYPE_FRAME;
3499 else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToGraphic))
3500 nImgId = CONTENT_TYPE_GRAPHIC;
3501 // else if(== sLinkSuffix)
3502 // nImgId = CONTENT_TYPE_BOOKMARK;
3503 else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToRegion))
3504 nImgId = CONTENT_TYPE_REGION;
3505 else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToOLE))
3506 nImgId = CONTENT_TYPE_OLE;
3507 else if(!sLinkSuffix.Len())
3508 nImgId = CONTENT_TYPE_BOOKMARK;
3509 if(USHRT_MAX != nImgId)
3511 nImgId += 20000;
3512 BOOL bHighContrast = Application::GetSettings().GetStyleSettings().GetWindowColor().IsDark();
3513 ImageList aEntryImages( SW_RES(bHighContrast ? IMG_NAVI_ENTRYBMPH : IMG_NAVI_ENTRYBMP) );
3514 const Image& rImage = aEntryImages.GetImage( nImgId );
3515 Bitmap aBitmap( rImage.GetBitmapEx().GetBitmap() );
3516 Reference<awt::XBitmap> xBmp = VCLUnoHelper::CreateBitmap( aBitmap );
3517 aRet.setValue( &xBmp, ::getCppuType((Reference<awt::XBitmap>*)0) );
3519 return aRet;
3521 /*-- 26.10.99 09:16:27---------------------------------------------------
3523 -----------------------------------------------------------------------*/
3524 Any SwXLinkNameAccessWrapper::getPropertyValue(const OUString& rPropertyName)
3525 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3527 Any aRet;
3528 if( rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_NAME)))
3530 aRet <<= OUString(sLinkDisplayName);
3532 else if( rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_BITMAP)))
3534 aRet = lcl_GetDisplayBitmap(sLinkSuffix);
3536 else
3537 throw UnknownPropertyException();
3538 return aRet;
3540 /*-- 26.10.99 09:16:27---------------------------------------------------
3542 -----------------------------------------------------------------------*/
3543 void SwXLinkNameAccessWrapper::addPropertyChangeListener(
3544 const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
3545 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3547 /*-- 26.10.99 09:16:28---------------------------------------------------
3549 -----------------------------------------------------------------------*/
3550 void SwXLinkNameAccessWrapper::removePropertyChangeListener(
3551 const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
3552 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3554 /*-- 26.10.99 09:16:28---------------------------------------------------
3556 -----------------------------------------------------------------------*/
3557 void SwXLinkNameAccessWrapper::addVetoableChangeListener(
3558 const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
3559 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3561 /*-- 26.10.99 09:16:29---------------------------------------------------
3563 -----------------------------------------------------------------------*/
3564 void SwXLinkNameAccessWrapper::removeVetoableChangeListener(
3565 const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
3566 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3568 /*-- 26.10.99 09:16:32---------------------------------------------------
3571 -----------------------------------------------------------------------*/
3572 Reference< XNameAccess > SwXLinkNameAccessWrapper::getLinks(void)
3573 throw( RuntimeException )
3575 return (SwXLinkNameAccessWrapper*)this;
3578 /*-- 26.10.99 09:21:48---------------------------------------------------
3580 -----------------------------------------------------------------------*/
3581 OUString SwXLinkNameAccessWrapper::getImplementationName(void) throw( RuntimeException )
3583 return C2U("SwXLinkNameAccessWrapper");
3585 /*-- 26.10.99 09:21:48---------------------------------------------------
3587 -----------------------------------------------------------------------*/
3588 sal_Bool SwXLinkNameAccessWrapper::supportsService(const OUString& rServiceName)
3589 throw( RuntimeException )
3591 return (rServiceName == C2U("com.sun.star.document.LinkTargets"));
3593 /*-- 26.10.99 09:21:48---------------------------------------------------
3595 -----------------------------------------------------------------------*/
3596 Sequence< OUString > SwXLinkNameAccessWrapper::getSupportedServiceNames(void)
3597 throw( RuntimeException )
3599 Sequence< OUString > aRet(1);
3600 OUString* pNames = aRet.getArray();
3601 pNames[0] = C2U("com.sun.star.document.LinkTargets");
3602 return aRet;
3604 /* -----------------26.10.99 15:50-------------------
3606 --------------------------------------------------*/
3607 SwXOutlineTarget::SwXOutlineTarget(const String& rOutlineText) :
3608 aPropSet(aSwMapProvider.GetPropertyMap(PROPERTY_MAP_LINK_TARGET)),
3609 sOutlineText(rOutlineText)
3612 /*-- 26.10.99 15:51:45---------------------------------------------------
3614 -----------------------------------------------------------------------*/
3615 SwXOutlineTarget::~SwXOutlineTarget()
3618 /*-- 26.10.99 15:51:46---------------------------------------------------
3620 -----------------------------------------------------------------------*/
3621 Reference< XPropertySetInfo > SwXOutlineTarget::getPropertySetInfo(void) throw( RuntimeException )
3623 static Reference< XPropertySetInfo > xRet = aPropSet.getPropertySetInfo();
3624 return xRet;
3626 /*-- 26.10.99 15:51:46---------------------------------------------------
3628 -----------------------------------------------------------------------*/
3629 void SwXOutlineTarget::setPropertyValue(
3630 const OUString& /*PropertyName*/, const Any& /*aValue*/)
3631 throw( UnknownPropertyException, PropertyVetoException,
3632 IllegalArgumentException, WrappedTargetException, RuntimeException)
3634 throw UnknownPropertyException();
3636 /*-- 26.10.99 15:51:46---------------------------------------------------
3638 -----------------------------------------------------------------------*/
3639 Any SwXOutlineTarget::getPropertyValue(const OUString& rPropertyName)
3640 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3642 Any aRet;
3643 if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_NAME)))
3644 aRet <<= OUString(sOutlineText);
3645 else
3646 throw UnknownPropertyException();
3647 return aRet;
3649 /*-- 26.10.99 15:51:46---------------------------------------------------
3651 -----------------------------------------------------------------------*/
3652 void SwXOutlineTarget::addPropertyChangeListener(
3653 const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
3654 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3657 /*-- 26.10.99 15:51:47---------------------------------------------------
3659 -----------------------------------------------------------------------*/
3660 void SwXOutlineTarget::removePropertyChangeListener(
3661 const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
3662 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3665 /*-- 26.10.99 15:51:47---------------------------------------------------
3667 -----------------------------------------------------------------------*/
3668 void SwXOutlineTarget::addVetoableChangeListener(
3669 const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
3670 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3673 /*-- 26.10.99 15:51:47---------------------------------------------------
3675 -----------------------------------------------------------------------*/
3676 void SwXOutlineTarget::removeVetoableChangeListener(
3677 const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
3678 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3681 /* -----------------03.05.99 12:28-------------------
3683 * --------------------------------------------------*/
3684 OUString SwXOutlineTarget::getImplementationName(void) throw( RuntimeException )
3686 return C2U("SwXOutlineTarget");
3688 /* -----------------03.05.99 12:28-------------------
3690 * --------------------------------------------------*/
3691 sal_Bool SwXOutlineTarget::supportsService(const OUString& ServiceName) throw( RuntimeException )
3693 return C2U("com.sun.star.document.LinkTarget") == ServiceName;
3695 /* -----------------03.05.99 12:28-------------------
3697 * --------------------------------------------------*/
3698 Sequence< OUString > SwXOutlineTarget::getSupportedServiceNames(void) throw( RuntimeException )
3700 Sequence < OUString > aRet(1);
3701 OUString* pArray = aRet.getArray();
3702 pArray[0] = C2U("com.sun.star.document.LinkTarget");
3704 return aRet;
3706 /* -----------------------------17.01.01 16:06--------------------------------
3708 ---------------------------------------------------------------------------*/
3709 SwXDocumentPropertyHelper::SwXDocumentPropertyHelper(SwDoc& rDoc) :
3710 SvxUnoForbiddenCharsTable ( rDoc.getForbiddenCharacterTable() )
3711 ,m_pDoc(&rDoc)
3714 /* -----------------------------17.01.01 16:06--------------------------------
3716 ---------------------------------------------------------------------------*/
3717 SwXDocumentPropertyHelper::~SwXDocumentPropertyHelper()
3720 /* -----------------------------17.01.01 16:06--------------------------------
3722 ---------------------------------------------------------------------------*/
3723 Reference<XInterface> SwXDocumentPropertyHelper::GetDrawTable(short nWhich)
3725 Reference<XInterface> xRet;
3726 if(m_pDoc)
3728 switch(nWhich)
3730 // --> OD 2005-08-08 #i52858#
3731 // assure that Draw model is created, if it doesn't exist.
3732 case SW_CREATE_DASH_TABLE :
3733 if(!xDashTable.is())
3734 xDashTable = SvxUnoDashTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
3735 xRet = xDashTable;
3736 break;
3737 case SW_CREATE_GRADIENT_TABLE :
3738 if(!xGradientTable.is())
3739 xGradientTable = SvxUnoGradientTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
3740 xRet = xGradientTable;
3741 break;
3742 case SW_CREATE_HATCH_TABLE :
3743 if(!xHatchTable.is())
3744 xHatchTable = SvxUnoHatchTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
3745 xRet = xHatchTable;
3746 break;
3747 case SW_CREATE_BITMAP_TABLE :
3748 if(!xBitmapTable.is())
3749 xBitmapTable = SvxUnoBitmapTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
3750 xRet = xBitmapTable;
3751 break;
3752 case SW_CREATE_TRANSGRADIENT_TABLE:
3753 if(!xTransGradientTable.is())
3754 xTransGradientTable = SvxUnoTransGradientTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
3755 xRet = xTransGradientTable;
3756 break;
3757 case SW_CREATE_MARKER_TABLE :
3758 if(!xMarkerTable.is())
3759 xMarkerTable = SvxUnoMarkerTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
3760 xRet = xMarkerTable;
3761 break;
3762 // <--
3763 case SW_CREATE_DRAW_DEFAULTS:
3764 if(!xDrawDefaults.is())
3765 xDrawDefaults = (cppu::OWeakObject*)new SwSvxUnoDrawPool(m_pDoc);
3766 xRet = xDrawDefaults;
3767 break;
3768 #ifdef DBG_UTIL
3769 default: DBG_ERROR("which table?");
3770 #endif
3773 return xRet;
3776 void SwXDocumentPropertyHelper::Invalidate()
3778 xDashTable = 0;
3779 xGradientTable = 0;
3780 xHatchTable = 0;
3781 xBitmapTable = 0;
3782 xTransGradientTable = 0;
3783 xMarkerTable = 0;
3784 xDrawDefaults = 0;
3785 m_pDoc = 0;
3786 SvxUnoForbiddenCharsTable::mxForbiddenChars.unbind();
3788 /* -----------------13.08.2003 12:43-----------------
3790 --------------------------------------------------*/
3791 void SwXDocumentPropertyHelper::onChange()
3793 if(m_pDoc)
3794 m_pDoc->SetModified();