update dev300-m58
[ooovba.git] / sw / source / ui / uno / unotxdoc.cxx
blob7143f4d92c24303203cbb9d6bdd405f7a1c0e61e
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 #include <toolkit/helper/vclunohelper.hxx>
41 #include <wdocsh.hxx>
42 #include <wrtsh.hxx>
43 #include <view.hxx>
44 #include <pview.hxx>
45 #include <srcview.hxx>
46 #include <viewsh.hxx>
47 #include <pvprtdat.hxx>
48 #include <swprtopt.hxx>
49 #include <svtools/stritem.hxx>
50 #include <unotxdoc.hxx>
51 #include <svtools/numuno.hxx>
52 #include <unoobj.hxx>
53 #include <unosett.hxx>
54 #include <unocoll.hxx>
55 #include <unoredlines.hxx>
56 #include <unosrch.hxx>
57 #include <toolkit/awt/vclxdevice.hxx>
58 #include <sfx2/dispatch.hxx>
59 #include <sfx2/request.hxx>
60 #include <sfx2/objsh.hxx> // SfxObjectShellRef <-> SV_DECL_REF(SfxObjectShell)
61 #include <unoprnms.hxx>
62 #include <unostyle.hxx>
63 #include <unodraw.hxx>
64 #include <svtools/eitem.hxx>
65 #include <pagedesc.hxx>
66 #include <svtools/txtcmp.hxx>
67 #include <unocrsr.hxx>
68 #include <unofield.hxx>
69 #include <unoidx.hxx>
70 #include <unoflatpara.hxx>
71 #include <poolfmt.hxx>
72 #include <globdoc.hxx>
73 #include <viewopt.hxx>
74 #include <unochart.hxx>
75 #include <doc.hxx>
76 #include <charatr.hxx>
77 #include <svx/xmleohlp.hxx>
79 #include <com/sun/star/util/SearchOptions.hpp>
80 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
81 #include <com/sun/star/lang/DisposedException.hpp>
82 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
83 #include <com/sun/star/beans/PropertyAttribute.hpp>
84 #include <com/sun/star/beans/XFastPropertySet.hpp>
85 #include <com/sun/star/document/RedlineDisplayType.hpp>
86 #include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
87 #include <com/sun/star/frame/XController.hpp>
88 #include <com/sun/star/frame/XFrame.hpp>
89 #include <com/sun/star/script/XInvocation.hpp>
90 #include <com/sun/star/reflection/XIdlClassProvider.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 #include <modcfg.hxx>
98 #include <ndtxt.hxx>
99 #include <utlui.hrc>
100 #include <swcont.hxx>
101 #include <unodefaults.hxx>
102 #include <SwXDocumentSettings.hxx>
103 #include <SwXPrintPreviewSettings.hxx>
104 #include <doc.hxx>
105 #include <svx/forbiddencharacterstable.hxx>
106 #include <svtools/zforlist.hxx>
107 #include <drawdoc.hxx>
108 #include <SwStyleNameMapper.hxx>
109 #include <osl/file.hxx>
111 // --> FME 2004-06-08 #i12836# enhanced pdf export
112 #include <EnhancedPDFExportHelper.hxx>
113 // <--
114 #include <numrule.hxx>
116 ///////////////////////////Modified on Jun. 14th//////////////////////////
117 ///////////////////////for getDocumentLanguages///////////////////////////
118 //-->
119 #include <svx/langitem.hxx>
120 #include <doc.hxx>
121 #include <docary.hxx> //SwCharFmts
122 #include <i18npool/mslangid.hxx>
124 #include <format.hxx>
125 #include <charfmt.hxx> //SwCharFmt
126 #include <fmtcol.hxx> //SwTxtFmtColl
127 #include <unostyle.hxx> //SwAutoStyleFamily
128 #include <istyleaccess.hxx> // handling of automatic styles
130 #include <svtools/stylepool.hxx>
131 #include <swatrset.hxx>
133 //#include <com/sun/star/i18n/ScriptType.hpp>
134 #include <svtools/langtab.hxx>
135 #include <map>
136 #include <set>
138 #include <svx/eeitem.hxx>
139 #include <svx/editeng.hxx>
140 #include <svx/svdoutl.hxx>
141 #include <svtools/languageoptions.hxx>
142 #include <svx/svdview.hxx>
145 //<--
146 using namespace ::com::sun::star;
147 using namespace ::com::sun::star::text;
148 using namespace ::com::sun::star::i18n;
149 using namespace ::com::sun::star::uno;
150 using namespace ::com::sun::star::beans;
151 using namespace ::com::sun::star::lang;
152 using namespace ::com::sun::star::container;
153 using namespace ::com::sun::star::document;
154 using namespace ::com::sun::star::i18n;
155 using ::rtl::OUString;
156 using ::osl::FileBase;
158 /* -----------------------------17.01.01 15:43--------------------------------
160 ---------------------------------------------------------------------------*/
161 #define SW_CREATE_DASH_TABLE 0x01
162 #define SW_CREATE_GRADIENT_TABLE 0x02
163 #define SW_CREATE_HATCH_TABLE 0x03
164 #define SW_CREATE_BITMAP_TABLE 0x04
165 #define SW_CREATE_TRANSGRADIENT_TABLE 0x05
166 #define SW_CREATE_MARKER_TABLE 0x06
167 #define SW_CREATE_DRAW_DEFAULTS 0x07
169 #include <comphelper/processfactory.hxx>
171 /******************************************************************************
173 ******************************************************************************/
174 SwTxtFmtColl *lcl_GetParaStyle(const String& rCollName, SwDoc* pDoc)
176 SwTxtFmtColl* pColl = pDoc->FindTxtFmtCollByName( rCollName );
177 if( !pColl )
179 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rCollName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
180 if( USHRT_MAX != nId )
181 pColl = pDoc->GetTxtCollFromPool( nId );
183 return pColl;
185 void lcl_DisposeView( SfxViewFrame* pToClose, SwDocShell* pDocShell )
187 // check if the view frame still exists
188 SfxViewFrame* pFound = SfxViewFrame::GetFirst( pDocShell,
190 FALSE );
191 while(pFound)
193 if( pFound == pToClose)
195 pToClose->DoClose();
196 break;
198 pFound = SfxViewFrame::GetNext( *pFound,
199 pDocShell,
201 FALSE );
204 /* -----------------------------10.03.00 18:02--------------------------------
206 ---------------------------------------------------------------------------*/
207 const Sequence< sal_Int8 > & SwXTextDocument::getUnoTunnelId()
209 static Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
210 return aSeq;
212 /* -----------------------------10.03.00 18:04--------------------------------
214 ---------------------------------------------------------------------------*/
215 sal_Int64 SAL_CALL SwXTextDocument::getSomething( const Sequence< sal_Int8 >& rId )
216 throw(RuntimeException)
218 if( rId.getLength() == 16
219 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
220 rId.getConstArray(), 16 ) )
222 return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
224 if( rId.getLength() == 16
225 && 0 == rtl_compareMemory( SfxObjectShell::getUnoTunnelId().getConstArray(),
226 rId.getConstArray(), 16 ) )
228 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(pDocShell ));
231 sal_Int64 nRet = SfxBaseModel::getSomething( rId );
232 if ( nRet )
233 return nRet;
234 else
236 GetNumberFormatter();
237 Any aNumTunnel = xNumFmtAgg->queryAggregation(::getCppuType((Reference<XUnoTunnel>*)0));
238 Reference<XUnoTunnel> xNumTunnel;
239 aNumTunnel >>= xNumTunnel;
240 if(xNumTunnel.is())
241 return xNumTunnel->getSomething(rId);
244 return SfxBaseModel::getSomething( rId );
246 /* -----------------------------16.03.00 14:12--------------------------------
248 ---------------------------------------------------------------------------*/
249 Any SAL_CALL SwXTextDocument::queryInterface( const uno::Type& rType ) throw(RuntimeException)
251 Any aRet = SwXTextDocumentBaseClass::queryInterface(rType);
252 if ( !aRet.hasValue() )
253 aRet = SfxBaseModel::queryInterface(rType);
254 if ( !aRet.hasValue() &&
255 rType == ::getCppuType((Reference<lang::XMultiServiceFactory>*)0))
257 Reference<lang::XMultiServiceFactory> xTmp = this;
258 aRet <<= xTmp;
261 if ( !aRet.hasValue()
262 && rType != ::getCppuType((Reference< com::sun::star::document::XDocumentEventBroadcaster>*)0)
263 && rType != ::getCppuType((Reference< com::sun::star::frame::XController>*)0)
264 && rType != ::getCppuType((Reference< com::sun::star::frame::XFrame>*)0)
265 && rType != ::getCppuType((Reference< com::sun::star::script::XInvocation>*)0)
266 && rType != ::getCppuType((Reference< com::sun::star::reflection::XIdlClassProvider>*)0)
267 && rType != ::getCppuType((Reference< com::sun::star::beans::XFastPropertySet>*)0)
268 && rType != ::getCppuType((Reference< com::sun::star::awt::XWindow>*)0))
270 GetNumberFormatter();
271 if(xNumFmtAgg.is())
272 aRet = xNumFmtAgg->queryAggregation(rType);
274 return aRet;
276 /* -----------------------------16.03.00 14:12--------------------------------
278 ---------------------------------------------------------------------------*/
279 void SAL_CALL SwXTextDocument::acquire()throw()
281 SfxBaseModel::acquire();
283 /* -----------------------------16.03.00 14:12--------------------------------
285 ---------------------------------------------------------------------------*/
286 void SAL_CALL SwXTextDocument::release()throw()
288 SfxBaseModel::release();
290 /* -----------------------------07.12.00 11:37--------------------------------
292 ---------------------------------------------------------------------------*/
293 Reference< XAdapter > SwXTextDocument::queryAdapter( ) throw(RuntimeException)
295 return SfxBaseModel::queryAdapter();
297 /* -----------------------------16.03.00 14:12--------------------------------
299 ---------------------------------------------------------------------------*/
300 Sequence< uno::Type > SAL_CALL SwXTextDocument::getTypes() throw(RuntimeException)
302 Sequence< uno::Type > aBaseTypes = SfxBaseModel::getTypes();
303 Sequence< uno::Type > aTextTypes = SwXTextDocumentBaseClass::getTypes();
305 Sequence< uno::Type > aNumTypes;
306 GetNumberFormatter();
307 if(xNumFmtAgg.is())
309 const uno::Type& rProvType = ::getCppuType((Reference <XTypeProvider>*)0);
310 Any aNumProv = xNumFmtAgg->queryAggregation(rProvType);
311 Reference<XTypeProvider> xNumProv;
312 if(aNumProv >>= xNumProv)
314 aNumTypes = xNumProv->getTypes();
317 long nIndex = aBaseTypes.getLength();
318 // don't forget the lang::XMultiServiceFactory
319 aBaseTypes.realloc(aBaseTypes.getLength() + aTextTypes.getLength() + aNumTypes.getLength() + 1);
320 uno::Type* pBaseTypes = aBaseTypes.getArray();
321 const uno::Type* pTextTypes = aTextTypes.getConstArray();
322 long nPos;
323 for(nPos = 0; nPos < aTextTypes.getLength(); nPos++)
325 pBaseTypes[nIndex++] = pTextTypes[nPos];
327 const uno::Type* pNumTypes = aNumTypes.getConstArray();
328 for(nPos = 0; nPos < aNumTypes.getLength(); nPos++)
330 pBaseTypes[nIndex++] = pNumTypes[nPos];
332 pBaseTypes[nIndex++] = ::getCppuType((Reference<lang::XMultiServiceFactory>*)0);
333 return aBaseTypes;
335 /*-- 18.12.98 11:52:59---------------------------------------------------
337 -----------------------------------------------------------------------*/
338 SwXTextDocument::SwXTextDocument(SwDocShell* pShell) :
339 SfxBaseModel(pShell),
341 aRefreshCont ( static_cast < XTextDocument* > ( this ) ),
343 pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_DOCUMENT)),
345 pDocShell(pShell),
347 bObjectValid(pShell != 0),
349 pDrawPage(0),
350 pxXDrawPage(0),
352 pxXNumberingRules(0),
353 pxXFootnotes(0),
354 pxXFootnoteSettings(0),
355 pxXEndnotes(0),
356 pxXEndnoteSettings(0),
357 pxXReferenceMarks(0),
358 pxXTextFieldTypes(0),
359 pxXTextFieldMasters(0),
360 pxXTextSections(0),
361 pxXBookmarks(0),
362 pxXTextTables(0),
363 pxXTextFrames(0),
364 pxXGraphicObjects(0),
365 pxXEmbeddedObjects(0),
366 pxXStyleFamilies(0),
367 pxXAutoStyles(0),
368 pxXChapterNumbering(0),
369 pxXDocumentIndexes(0),
371 pxXLineNumberingProperties(0),
372 pxLinkTargetSupplier(0),
373 pxXRedlines(0),
374 m_pHiddenViewFrame(0)
376 uno::Reference< document::XDocumentProperties > xWriterProps( ::comphelper::getProcessServiceFactory()->createInstance( DEFINE_CONST_UNICODE("com.sun.star.writer.DocumentProperties") ), uno::UNO_QUERY_THROW);
378 SfxBaseModel::setDocumentProperties( xWriterProps );
380 /*-- 18.12.98 11:53:00---------------------------------------------------
382 -----------------------------------------------------------------------*/
383 SwXTextDocument::~SwXTextDocument()
385 InitNewDoc();
386 if(xNumFmtAgg.is())
388 Reference< XInterface > x0;
389 xNumFmtAgg->setDelegator(x0);
390 xNumFmtAgg = 0;
395 /*-- 18.12.98 11:55:08---------------------------------------------------
397 -----------------------------------------------------------------------*/
398 /* -----------------18.12.98 12:49-------------------
400 * --------------------------------------------------*/
401 SwXDocumentPropertyHelper * SwXTextDocument::GetPropertyHelper ()
403 if(!xPropertyHelper.is())
405 pPropertyHelper = new SwXDocumentPropertyHelper(*pDocShell->GetDoc());
406 xPropertyHelper = (cppu::OWeakObject*)pPropertyHelper;
408 return pPropertyHelper;
410 void SwXTextDocument::GetNumberFormatter()
412 if(IsValid())
414 if(!xNumFmtAgg.is())
416 if ( pDocShell->GetDoc() )
418 SvNumberFormatsSupplierObj* pNumFmt = new SvNumberFormatsSupplierObj(
419 pDocShell->GetDoc()->GetNumberFormatter( sal_True ));
420 Reference< util::XNumberFormatsSupplier > xTmp = pNumFmt;
421 xNumFmtAgg = Reference< XAggregation >(xTmp, UNO_QUERY);
423 if(xNumFmtAgg.is())
424 xNumFmtAgg->setDelegator((cppu::OWeakObject*)(SwXTextDocumentBaseClass*)this);
426 else
428 const uno::Type& rTunnelType = ::getCppuType((Reference <XUnoTunnel>*)0);
429 Any aNumTunnel = xNumFmtAgg->queryAggregation(rTunnelType);
430 SvNumberFormatsSupplierObj* pNumFmt = 0;
431 Reference< XUnoTunnel > xNumTunnel;
432 if(aNumTunnel >>= xNumTunnel)
434 pNumFmt = reinterpret_cast<SvNumberFormatsSupplierObj*>(
435 xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
438 DBG_ASSERT(pNumFmt, "No number formatter available");
439 if(!pNumFmt->GetNumberFormatter())
440 pNumFmt->SetNumberFormatter(pDocShell->GetDoc()->GetNumberFormatter( sal_True ));
444 /*-- 18.12.98 11:55:11---------------------------------------------------
446 -----------------------------------------------------------------------*/
447 Reference< XText > SwXTextDocument::getText(void) throw( RuntimeException )
449 ::vos::OGuard aGuard(Application::GetSolarMutex());
450 if(!IsValid())
451 throw RuntimeException();
452 if(!xBodyText.is())
454 pBodyText = new SwXBodyText(pDocShell->GetDoc());
455 xBodyText = pBodyText;
457 return xBodyText;
459 /*-- 18.12.98 11:55:11---------------------------------------------------
461 -----------------------------------------------------------------------*/
462 void SwXTextDocument::reformat(void) throw( RuntimeException )
464 ::vos::OGuard aGuard(Application::GetSolarMutex());
465 if(!IsValid())
466 throw RuntimeException();
468 /*-- 18.12.98 11:55:16---------------------------------------------------
470 -----------------------------------------------------------------------*/
471 void SwXTextDocument::lockControllers(void) throw( RuntimeException )
473 ::vos::OGuard aGuard(Application::GetSolarMutex());
474 if(IsValid())
476 UnoActionContext* pContext = new UnoActionContext(pDocShell->GetDoc());
477 aActionArr.Insert(pContext, 0);
479 else
480 throw RuntimeException();
482 /*-- 18.12.98 11:55:16---------------------------------------------------
484 -----------------------------------------------------------------------*/
485 void SwXTextDocument::unlockControllers(void) throw( RuntimeException )
487 ::vos::OGuard aGuard(Application::GetSolarMutex());
488 if(aActionArr.Count())
490 UnoActionContext* pContext = aActionArr.GetObject(0);
491 aActionArr.Remove(0);
492 delete pContext;
494 else
495 throw RuntimeException();
497 /*-- 18.12.98 11:55:17---------------------------------------------------
499 -----------------------------------------------------------------------*/
500 sal_Bool SwXTextDocument::hasControllersLocked(void) throw( RuntimeException )
502 ::vos::OGuard aGuard(Application::GetSolarMutex());
503 return aActionArr.Count() > 0;
505 /*-- 18.12.98 13:12:23---------------------------------------------------
507 -----------------------------------------------------------------------*/
508 Reference< frame::XController > SwXTextDocument::getCurrentController(void) throw( RuntimeException )
510 return SfxBaseModel::getCurrentController();
512 /*-- 18.12.98 13:12:24---------------------------------------------------
514 -----------------------------------------------------------------------*/
515 void SwXTextDocument::setCurrentController(const Reference< frame::XController > & xController)
516 throw( NoSuchElementException, RuntimeException )
518 SfxBaseModel::setCurrentController(xController);
520 /* -----------------27.01.99 11:48-------------------
522 * --------------------------------------------------*/
523 Reference< XInterface > SwXTextDocument::getCurrentSelection() throw( RuntimeException )
525 ::vos::OGuard aGuard(Application::GetSolarMutex());
526 Reference< XInterface > xRef;
527 if(IsValid())
530 const TypeId aTypeId = TYPE(SwView);
531 SwView* pView = (SwView*)SfxViewShell::GetFirst(&aTypeId);
532 while(pView && pView->GetObjectShell() != pDocShell)
534 pView = (SwView*)SfxViewShell::GetNext(*pView, &aTypeId);
536 if(pView)
538 Any aRef = pView->GetUNOObject()->getSelection();
539 aRef >>= xRef;
542 return xRef;
545 /*-- 18.12.98 13:12:24---------------------------------------------------
547 -----------------------------------------------------------------------*/
548 sal_Bool SwXTextDocument::attachResource(const OUString& aURL, const Sequence< beans::PropertyValue >& aArgs)
549 throw( RuntimeException )
551 return SfxBaseModel::attachResource(aURL, aArgs);
553 /*-- 18.12.98 13:12:24---------------------------------------------------
555 -----------------------------------------------------------------------*/
556 OUString SwXTextDocument::getURL(void) throw( RuntimeException )
558 return SfxBaseModel::getURL();
560 /*-- 18.12.98 13:12:24---------------------------------------------------
562 -----------------------------------------------------------------------*/
563 Sequence< beans::PropertyValue > SwXTextDocument::getArgs(void) throw( RuntimeException )
565 return SfxBaseModel::getArgs();
567 /*-- 18.12.98 13:12:24---------------------------------------------------
569 -----------------------------------------------------------------------*/
570 void SwXTextDocument::connectController(const Reference< frame::XController > & xController) throw( RuntimeException )
572 SfxBaseModel::connectController(xController);
574 /*-- 18.12.98 13:12:25---------------------------------------------------
576 -----------------------------------------------------------------------*/
577 void SwXTextDocument::disconnectController(const Reference< frame::XController > & xController) throw( RuntimeException )
579 SfxBaseModel::disconnectController(xController);
581 /*-- 18.12.98 13:12:25---------------------------------------------------
583 -----------------------------------------------------------------------*/
584 void SwXTextDocument::dispose(void) throw( RuntimeException )
586 SfxBaseModel::dispose();
588 /*-- 10.05.2005 14:14:39---------------------------------------------------
590 -----------------------------------------------------------------------*/
591 void SwXTextDocument::close( sal_Bool bDeliverOwnership ) throw( util::CloseVetoException, RuntimeException )
593 if(IsValid() && m_pHiddenViewFrame)
594 lcl_DisposeView( m_pHiddenViewFrame, pDocShell);
595 SfxBaseModel::close(bDeliverOwnership);
597 /*-- 18.12.98 13:12:25---------------------------------------------------
599 -----------------------------------------------------------------------*/
600 void SwXTextDocument::addEventListener(const Reference< lang::XEventListener > & aListener) throw( RuntimeException )
602 SfxBaseModel::addEventListener(aListener);
604 /*-- 18.12.98 13:12:26---------------------------------------------------
606 -----------------------------------------------------------------------*/
607 void SwXTextDocument::removeEventListener(const Reference< lang::XEventListener > & aListener) throw( RuntimeException )
609 SfxBaseModel::removeEventListener(aListener);
612 /*-- 18.12.98 11:55:19---------------------------------------------------
614 -----------------------------------------------------------------------*/
615 Reference< XPropertySet > SwXTextDocument::getLineNumberingProperties(void)
616 throw( RuntimeException )
618 ::vos::OGuard aGuard(Application::GetSolarMutex());
619 if(IsValid())
621 if(!pxXLineNumberingProperties)
623 pxXLineNumberingProperties = new Reference<XPropertySet>;
624 (*pxXLineNumberingProperties) = new SwXLineNumberingProperties(pDocShell->GetDoc());
627 else
628 throw RuntimeException();
629 return *pxXLineNumberingProperties;
631 /*-- 18.12.98 11:55:20---------------------------------------------------
633 -----------------------------------------------------------------------*/
634 Reference< XIndexReplace > SwXTextDocument::getChapterNumberingRules(void)
635 throw( RuntimeException )
637 ::vos::OGuard aGuard(Application::GetSolarMutex());
638 if(!IsValid())
639 throw RuntimeException();
640 if(!pxXChapterNumbering)
642 pxXChapterNumbering = new Reference< XIndexReplace > ;
643 *pxXChapterNumbering = new SwXChapterNumbering(*pDocShell);
645 return *pxXChapterNumbering;
648 Reference< XIndexAccess > SwXTextDocument::getNumberingRules(void) throw( RuntimeException )
650 ::vos::OGuard aGuard(Application::GetSolarMutex());
651 if(!IsValid())
652 throw RuntimeException();
653 if(!pxXNumberingRules )
655 ((SwXTextDocument*)this)->pxXNumberingRules = new Reference< XIndexAccess > ;
656 *pxXNumberingRules = new SwXNumberingRulesCollection( pDocShell->GetDoc() );
658 return *pxXNumberingRules;
661 /*-- 18.12.98 11:55:21---------------------------------------------------
663 -----------------------------------------------------------------------*/
664 Reference< XIndexAccess > SwXTextDocument::getFootnotes(void) throw( RuntimeException )
666 ::vos::OGuard aGuard(Application::GetSolarMutex());
667 if(!IsValid())
668 throw RuntimeException();
669 if(!pxXFootnotes)
671 ((SwXTextDocument*)this)->pxXFootnotes = new Reference< XIndexAccess > ;
672 *pxXFootnotes = new SwXFootnotes(sal_False, pDocShell->GetDoc());
674 return *pxXFootnotes;
676 /*-- 18.12.98 11:55:21---------------------------------------------------
678 -----------------------------------------------------------------------*/
679 Reference< XPropertySet > SAL_CALL
680 SwXTextDocument::getFootnoteSettings(void) throw( RuntimeException )
682 ::vos::OGuard aGuard(Application::GetSolarMutex());
683 if(!IsValid())
684 throw RuntimeException();
685 if(!pxXFootnoteSettings)
687 ((SwXTextDocument*)this)->pxXFootnoteSettings = new Reference< XPropertySet > ;
688 *pxXFootnoteSettings = new SwXFootnoteProperties(pDocShell->GetDoc());
690 return *pxXFootnoteSettings;
692 /*-- 18.12.98 11:55:21---------------------------------------------------
694 -----------------------------------------------------------------------*/
695 Reference< XIndexAccess > SwXTextDocument::getEndnotes(void) throw( RuntimeException )
697 ::vos::OGuard aGuard(Application::GetSolarMutex());
698 if(!IsValid())
699 throw RuntimeException();
700 if(!pxXEndnotes)
702 ((SwXTextDocument*)this)->pxXEndnotes = new Reference< XIndexAccess > ;
703 *pxXEndnotes = new SwXFootnotes(sal_True, pDocShell->GetDoc());
705 return *pxXEndnotes;
707 /*-- 18.12.98 11:55:22---------------------------------------------------
709 -----------------------------------------------------------------------*/
710 Reference< XPropertySet > SwXTextDocument::getEndnoteSettings(void) throw( RuntimeException )
712 ::vos::OGuard aGuard(Application::GetSolarMutex());
713 if(!IsValid())
714 throw RuntimeException();
715 if(!pxXEndnoteSettings)
717 ((SwXTextDocument*)this)->pxXEndnoteSettings = new Reference< XPropertySet > ;
718 *pxXEndnoteSettings = new SwXEndnoteProperties(pDocShell->GetDoc());
720 return *pxXEndnoteSettings;
722 /*-- 18.12.98 11:55:22---------------------------------------------------
724 -----------------------------------------------------------------------*/
725 Reference< util::XReplaceDescriptor > SwXTextDocument::createReplaceDescriptor(void)
726 throw( RuntimeException )
728 ::vos::OGuard aGuard(Application::GetSolarMutex());
729 Reference< util::XReplaceDescriptor > xRet = new SwXTextSearch;
730 return xRet;
732 /* -----------------26.02.99 15:52-------------------
734 * --------------------------------------------------*/
735 SwUnoCrsr* SwXTextDocument::CreateCursorForSearch(Reference< XTextCursor > & xCrsr)
737 getText();
738 XText* pText = xBodyText.get();
739 SwXBodyText* pBText = (SwXBodyText*)pText;
740 xCrsr = pBText->CreateTextCursor(sal_True);
742 Reference<XUnoTunnel> xRangeTunnel( xCrsr, UNO_QUERY);
743 SwXTextCursor* pxUnoCrsr = 0;
744 if(xRangeTunnel.is())
746 pxUnoCrsr = reinterpret_cast<SwXTextCursor*>(xRangeTunnel->getSomething(
747 SwXTextCursor::getUnoTunnelId()));
750 SwUnoCrsr* pUnoCrsr = pxUnoCrsr->GetCrsr();
751 pUnoCrsr->SetRemainInSection(sal_False);
752 return pUnoCrsr;
755 /*-- 18.12.98 11:55:22---------------------------------------------------
757 -----------------------------------------------------------------------*/
758 sal_Int32 SwXTextDocument::replaceAll(const Reference< util::XSearchDescriptor > & xDesc)
759 throw( RuntimeException )
761 ::vos::OGuard aGuard(Application::GetSolarMutex());
762 Reference< XUnoTunnel > xDescTunnel(xDesc, UNO_QUERY);
763 if(!IsValid() || !xDescTunnel.is() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()))
764 throw RuntimeException();
766 Reference< XTextCursor > xCrsr;
767 SwUnoCrsr* pUnoCrsr = CreateCursorForSearch(xCrsr);
769 const SwXTextSearch* pSearch = reinterpret_cast<const SwXTextSearch*>(
770 xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()));
772 int eRanges(FND_IN_BODY|FND_IN_SELALL);
774 util::SearchOptions aSearchOpt;
775 pSearch->FillSearchOptions( aSearchOpt );
777 SwDocPositions eStart = pSearch->bBack ? DOCPOS_END : DOCPOS_START;
778 SwDocPositions eEnd = pSearch->bBack ? DOCPOS_START : DOCPOS_END;
780 // Suche soll ueberall stattfinden
781 pUnoCrsr->SetRemainInSection(sal_False);
782 sal_uInt32 nResult;
783 UnoActionContext aContext(pDocShell->GetDoc());
784 //try attribute search first
785 if(pSearch->HasSearchAttributes()||pSearch->HasReplaceAttributes())
787 SfxItemSet aSearch(pDocShell->GetDoc()->GetAttrPool(),
788 RES_CHRATR_BEGIN, RES_CHRATR_END-1,
789 RES_PARATR_BEGIN, RES_PARATR_END-1,
790 RES_FRMATR_BEGIN, RES_FRMATR_END-1,
792 SfxItemSet aReplace(pDocShell->GetDoc()->GetAttrPool(),
793 RES_CHRATR_BEGIN, RES_CHRATR_END-1,
794 RES_PARATR_BEGIN, RES_PARATR_END-1,
795 RES_FRMATR_BEGIN, RES_FRMATR_END-1,
797 pSearch->FillSearchItemSet(aSearch);
798 pSearch->FillReplaceItemSet(aReplace);
799 BOOL bCancel;
800 nResult = (sal_Int32)pUnoCrsr->Find( aSearch, !pSearch->bStyles,
801 eStart, eEnd, bCancel,
802 (FindRanges)eRanges,
803 pSearch->sSearchText.Len() ? &aSearchOpt : 0,
804 &aReplace );
806 else if(pSearch->bStyles)
808 SwTxtFmtColl *pSearchColl = lcl_GetParaStyle(pSearch->sSearchText, pUnoCrsr->GetDoc());
809 SwTxtFmtColl *pReplaceColl = lcl_GetParaStyle(pSearch->sReplaceText, pUnoCrsr->GetDoc());;
811 BOOL bCancel;
812 nResult = pUnoCrsr->Find( *pSearchColl,
813 eStart, eEnd, bCancel,
814 (FindRanges)eRanges, pReplaceColl );
817 else
819 //todo/mba: assuming that notes should be omitted
820 BOOL bSearchInNotes = FALSE;
821 BOOL bCancel;
822 nResult = pUnoCrsr->Find( aSearchOpt, bSearchInNotes,
823 eStart, eEnd, bCancel,
824 (FindRanges)eRanges,
825 sal_True );
827 return (sal_Int32)nResult;
830 /*-- 18.12.98 11:55:22---------------------------------------------------
832 -----------------------------------------------------------------------*/
833 Reference< util::XSearchDescriptor > SwXTextDocument::createSearchDescriptor(void)
834 throw( RuntimeException )
836 ::vos::OGuard aGuard(Application::GetSolarMutex());
837 Reference< util::XSearchDescriptor > xRet = new SwXTextSearch;
838 return xRet;
841 /* -----------------26.02.99 16:08-------------------
842 * wird fuer findAll/First/Next verwendet
843 * --------------------------------------------------*/
844 SwUnoCrsr* SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor > & xDesc,
845 Reference< XTextCursor > & xCrsr, sal_Bool bAll,
846 sal_Int32& nResult,
847 Reference< XInterface > xLastResult)
849 Reference< XUnoTunnel > xDescTunnel(xDesc, UNO_QUERY);
850 if(!IsValid() || !xDescTunnel.is() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()))
851 return 0;
853 SwUnoCrsr* pUnoCrsr = CreateCursorForSearch(xCrsr);
854 const SwXTextSearch* pSearch = reinterpret_cast<const SwXTextSearch*>(
855 xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()));
857 sal_Bool bParentInExtra = sal_False;
858 if(xLastResult.is())
860 Reference<XUnoTunnel> xCursorTunnel( xLastResult, UNO_QUERY);
861 OTextCursorHelper* pPosCrsr = 0;
862 if(xCursorTunnel.is())
864 pPosCrsr = reinterpret_cast<OTextCursorHelper*>(xCursorTunnel->getSomething(
865 OTextCursorHelper::getUnoTunnelId()));
867 SwPaM* pCrsr = pPosCrsr ? pPosCrsr->GetPaM() : 0;
868 if(pCrsr)
870 *pUnoCrsr->GetPoint() = *pCrsr->End();
871 pUnoCrsr->DeleteMark();
873 else
875 SwXTextRange* pRange = 0;
876 if(xCursorTunnel.is())
878 pRange = reinterpret_cast<SwXTextRange*>(xCursorTunnel->getSomething(
879 SwXTextRange::getUnoTunnelId()));
881 if(!pRange)
882 return 0;
883 pRange->GetPositions(*pUnoCrsr);
884 if(pUnoCrsr->HasMark())
886 if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark())
887 pUnoCrsr->Exchange();
888 pUnoCrsr->DeleteMark();
891 const SwNode* pRangeNode = pUnoCrsr->GetNode();
892 bParentInExtra = pRangeNode->FindFlyStartNode() ||
893 pRangeNode->FindFootnoteStartNode() ||
894 pRangeNode->FindHeaderStartNode() ||
895 pRangeNode->FindFooterStartNode() ;
898 util::SearchOptions aSearchOpt;
899 pSearch->FillSearchOptions( aSearchOpt );
902 * folgende Kombinationen sind erlaubt:
903 * - suche einen im Body: -> FND_IN_BODY
904 * - suche alle im Body: -> FND_IN_BODYONLY | FND_IN_SELALL
905 * - suche in Selectionen: einen / alle -> FND_IN_SEL [ | FND_IN_SELALL ]
906 * - suche im nicht Body: einen / alle -> FND_IN_OTHER [ | FND_IN_SELALL ]
907 * - suche ueberall alle: -> FND_IN_SELALL
909 int eRanges(FND_IN_BODY);
910 if(bParentInExtra)
911 eRanges = FND_IN_OTHER;
912 if(bAll) //immer - ueberall?
913 eRanges = FND_IN_SELALL;
914 SwDocPositions eStart = !bAll ? DOCPOS_CURR : pSearch->bBack ? DOCPOS_END : DOCPOS_START;
915 SwDocPositions eEnd = pSearch->bBack ? DOCPOS_START : DOCPOS_END;
917 nResult = 0;
918 sal_uInt16 nSearchProc = 0;
919 while(nSearchProc < 2)
921 //try attribute search first
922 if(pSearch->HasSearchAttributes())
924 SfxItemSet aSearch(pDocShell->GetDoc()->GetAttrPool(),
925 RES_CHRATR_BEGIN, RES_CHRATR_END-1,
926 RES_PARATR_BEGIN, RES_PARATR_END-1,
927 RES_FRMATR_BEGIN, RES_FRMATR_END-1,
928 RES_TXTATR_INETFMT, RES_TXTATR_INETFMT,
930 pSearch->FillSearchItemSet(aSearch);
931 BOOL bCancel;
932 nResult = (sal_Int32)pUnoCrsr->Find( aSearch, !pSearch->bStyles,
933 eStart, eEnd, bCancel,
934 (FindRanges)eRanges,
935 pSearch->sSearchText.Len() ? &aSearchOpt : 0,
936 0 );
938 else if(pSearch->bStyles)
940 SwTxtFmtColl *pSearchColl = lcl_GetParaStyle(pSearch->sSearchText, pUnoCrsr->GetDoc());
941 //pSearch->sReplaceText
942 SwTxtFmtColl *pReplaceColl = 0;
943 BOOL bCancel;
944 nResult = (sal_Int32)pUnoCrsr->Find( *pSearchColl,
945 eStart, eEnd, bCancel,
946 (FindRanges)eRanges, pReplaceColl );
948 else
950 //todo/mba: assuming that notes should be omitted
951 BOOL bSearchInNotes = FALSE;
952 BOOL bCancel;
953 nResult = (sal_Int32)pUnoCrsr->Find( aSearchOpt, bSearchInNotes,
954 eStart, eEnd, bCancel,
955 (FindRanges)eRanges,
956 /*int bReplace =*/sal_False );
958 nSearchProc++;
959 if(nResult || (eRanges&(FND_IN_SELALL|FND_IN_OTHER)))
960 break;
961 //second step - find in other
962 eRanges = FND_IN_OTHER;
964 return pUnoCrsr;
966 /*-- 18.12.98 11:55:23---------------------------------------------------
968 -----------------------------------------------------------------------*/
969 Reference< XIndexAccess >
970 SwXTextDocument::findAll(const Reference< util::XSearchDescriptor > & xDesc)
971 throw( RuntimeException )
973 ::vos::OGuard aGuard(Application::GetSolarMutex());
974 Reference< XInterface > xTmp;
975 sal_Int32 nResult = 0;
976 Reference< XTextCursor > xCrsr;
977 SwUnoCrsr* pResultCrsr = FindAny(xDesc, xCrsr, sal_True, nResult, xTmp);
978 if(!pResultCrsr)
979 throw RuntimeException();
980 Reference< XIndexAccess > xRet;
981 if(nResult)
982 xRet = new SwXTextRanges(pResultCrsr);
983 else
984 xRet = new SwXTextRanges();
985 delete pResultCrsr;
986 return xRet;
988 /*-- 18.12.98 11:55:23---------------------------------------------------
990 -----------------------------------------------------------------------*/
991 Reference< XInterface > SwXTextDocument::findFirst(const Reference< util::XSearchDescriptor > & xDesc)
992 throw( RuntimeException )
994 ::vos::OGuard aGuard(Application::GetSolarMutex());
995 Reference< XInterface > xTmp;
996 sal_Int32 nResult = 0;
997 Reference< XTextCursor > xCrsr;
998 SwUnoCrsr* pResultCrsr = FindAny(xDesc, xCrsr, sal_False, nResult, xTmp);
999 if(!pResultCrsr)
1000 throw RuntimeException();
1001 Reference< XInterface > xRet;
1002 if(nResult)
1004 Reference< XTextRange > xTempRange = SwXTextRange::CreateTextRangeFromPosition(
1005 pDocShell->GetDoc(),
1006 *pResultCrsr->GetPoint(),
1007 pResultCrsr->GetMark());
1008 xRet = *new SwXTextCursor(xTempRange->getText(), pResultCrsr);
1009 delete pResultCrsr;
1011 return xRet;
1013 /*-- 18.12.98 11:55:24---------------------------------------------------
1015 -----------------------------------------------------------------------*/
1016 Reference< XInterface > SwXTextDocument::findNext(const Reference< XInterface > & xStartAt,
1017 const Reference< util::XSearchDescriptor > & xDesc)
1018 throw( RuntimeException )
1020 ::vos::OGuard aGuard(Application::GetSolarMutex());
1021 Reference< XInterface > xTmp;
1022 sal_Int32 nResult = 0;
1023 Reference< XTextCursor > xCrsr;
1024 if(!xStartAt.is())
1025 throw RuntimeException();
1026 SwUnoCrsr* pResultCrsr = FindAny(xDesc, xCrsr, sal_False, nResult, xStartAt);
1027 if(!pResultCrsr)
1028 throw RuntimeException();
1029 Reference< XInterface > xRet;
1030 if(nResult)
1032 Reference< XTextRange > xTempRange = SwXTextRange::CreateTextRangeFromPosition(
1033 pDocShell->GetDoc(),
1034 *pResultCrsr->GetPoint(),
1035 pResultCrsr->GetMark());
1037 xRet = *new SwXTextCursor(xTempRange->getText(), pResultCrsr);
1038 delete pResultCrsr;
1040 return xRet;
1042 /*-- 18.12.98 11:55:24---------------------------------------------------
1044 -----------------------------------------------------------------------*/
1045 Sequence< beans::PropertyValue > SwXTextDocument::getPagePrintSettings(void)
1046 throw( RuntimeException )
1048 ::vos::OGuard aGuard(Application::GetSolarMutex());
1049 Sequence< beans::PropertyValue > aSeq(9);
1050 if(IsValid())
1052 beans::PropertyValue* pArray = aSeq.getArray();
1053 SwPagePreViewPrtData aData;
1054 const SwPagePreViewPrtData* pData = pDocShell->GetDoc()->GetPreViewPrtData();
1055 if(pData)
1056 aData = *pData;
1057 Any aVal;
1058 aVal <<= (sal_Int16)aData.GetRow();
1059 pArray[0] = beans::PropertyValue(C2U("PageRows"), -1, aVal, PropertyState_DIRECT_VALUE);
1060 aVal <<= (sal_Int16)aData.GetCol();
1061 pArray[1] = beans::PropertyValue(C2U("PageColumns"), -1, aVal, PropertyState_DIRECT_VALUE);
1062 aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetLeftSpace());
1063 pArray[2] = beans::PropertyValue(C2U("LeftMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
1064 aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetRightSpace());
1065 pArray[3] = beans::PropertyValue(C2U("RightMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
1066 aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetTopSpace());
1067 pArray[4] = beans::PropertyValue(C2U("TopMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
1068 aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetBottomSpace());
1069 pArray[5] = beans::PropertyValue(C2U("BottomMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
1070 aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetHorzSpace());
1071 pArray[6] = beans::PropertyValue(C2U("HoriMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
1072 aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetVertSpace());
1073 pArray[7] = beans::PropertyValue(C2U("VertMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
1074 BOOL bTemp = aData.GetLandscape();
1075 aVal.setValue(&bTemp, ::getCppuBooleanType());
1076 pArray[8] = beans::PropertyValue(C2U("IsLandscape"), -1, aVal, PropertyState_DIRECT_VALUE);
1078 else
1079 throw RuntimeException();
1080 return aSeq;
1082 /* -----------------24.02.99 10:57-------------------
1084 * --------------------------------------------------*/
1085 sal_uInt32 lcl_Any_To_ULONG(const Any& rValue, sal_Bool& bException)
1087 bException = sal_False;
1088 TypeClass eType = rValue.getValueType().getTypeClass();
1090 sal_uInt32 nRet = 0;
1091 if( eType == TypeClass_UNSIGNED_LONG )
1092 rValue >>= nRet;
1093 else
1095 sal_Int32 nVal=0;
1096 bException = !(rValue >>= nVal);
1097 if( !bException )
1098 nRet = (sal_uInt32)nVal;
1101 return nRet;
1103 /*-- 09.06.2004 12:18:10---------------------------------------------------
1105 -----------------------------------------------------------------------*/
1106 String lcl_CreateOutlineString( USHORT nIndex,
1107 const SwOutlineNodes& rOutlineNodes, const SwNumRule* pOutlRule)
1109 String sEntry;
1110 const SwTxtNode * pTxtNd = rOutlineNodes[ nIndex ]->GetTxtNode();
1111 SwNumberTree::tNumberVector aNumVector = pTxtNd->GetNumberVector();
1112 if( pOutlRule && pTxtNd->GetNumRule())
1113 for( sal_Int8 nLevel = 0;
1114 nLevel <= pTxtNd->GetActualListLevel();
1115 nLevel++ )
1117 long nVal = aNumVector[nLevel];
1118 nVal ++;
1119 nVal -= pOutlRule->Get(nLevel).GetStart();
1120 sEntry += String::CreateFromInt32( nVal );
1121 sEntry += '.';
1123 sEntry += rOutlineNodes[ nIndex ]->
1124 GetTxtNode()->GetExpandTxt( 0, STRING_LEN, sal_False );
1125 return sEntry;
1127 /*-- 18.12.98 11:55:25---------------------------------------------------
1129 -----------------------------------------------------------------------*/
1130 void SwXTextDocument::setPagePrintSettings(const Sequence< beans::PropertyValue >& aSettings)
1131 throw( RuntimeException )
1133 ::vos::OGuard aGuard(Application::GetSolarMutex());
1134 if(IsValid())
1136 SwPagePreViewPrtData aData;
1137 //falls nur einige Properties kommen, dann die akt. Einstellungen benutzen
1138 const SwPagePreViewPrtData* pData = pDocShell->GetDoc()->GetPreViewPrtData();
1139 if(pData)
1140 aData = *pData;
1141 const beans::PropertyValue* pProperties = aSettings.getConstArray();
1142 int nCount = aSettings.getLength();
1143 for(int i = 0; i < nCount; i++)
1145 String sName = pProperties[i].Name;
1146 const Any& rVal = pProperties[i].Value;
1147 sal_Bool bException;
1148 sal_uInt32 nVal = lcl_Any_To_ULONG(rVal, bException);
1149 if( COMPARE_EQUAL == sName.CompareToAscii("PageRows" ) )
1151 if(!nVal || nVal > 0xff)
1152 throw RuntimeException();
1153 aData.SetRow((BYTE)nVal);
1155 else if(COMPARE_EQUAL == sName.CompareToAscii("PageColumns"))
1157 if(!nVal || nVal > 0xff)
1158 throw RuntimeException();
1159 aData.SetCol((BYTE)nVal);
1161 else if(COMPARE_EQUAL == sName.CompareToAscii("LeftMargin"))
1163 aData.SetLeftSpace(MM100_TO_TWIP_UNSIGNED(nVal));
1165 else if(COMPARE_EQUAL == sName.CompareToAscii("RightMargin"))
1167 aData.SetRightSpace(MM100_TO_TWIP_UNSIGNED(nVal));
1169 else if(COMPARE_EQUAL == sName.CompareToAscii("TopMargin"))
1171 aData.SetTopSpace(MM100_TO_TWIP_UNSIGNED(nVal));
1173 else if(COMPARE_EQUAL == sName.CompareToAscii("BottomMargin"))
1175 aData.SetBottomSpace(MM100_TO_TWIP_UNSIGNED(nVal));
1177 else if(COMPARE_EQUAL == sName.CompareToAscii("HoriMargin"))
1179 aData.SetHorzSpace(MM100_TO_TWIP_UNSIGNED(nVal));
1181 else if(COMPARE_EQUAL == sName.CompareToAscii("VertMargin"))
1183 aData.SetVertSpace(MM100_TO_TWIP_UNSIGNED(nVal));
1185 else if(COMPARE_EQUAL == sName.CompareToAscii("IsLandscape"))
1187 bException = (::getBooleanCppuType() != rVal.getValueType());
1188 aData.SetLandscape(*(sal_Bool*)rVal.getValue());
1190 else
1191 bException = sal_True;
1192 if(bException)
1193 throw RuntimeException();
1195 pDocShell->GetDoc()->SetPreViewPrtData(&aData);
1197 else
1198 throw RuntimeException();
1200 /*-- 18.12.98 11:55:25---------------------------------------------------
1202 -----------------------------------------------------------------------*/
1203 void SwXTextDocument::printPages(const Sequence< beans::PropertyValue >& xOptions)
1204 throw( IllegalArgumentException, RuntimeException )
1206 ::vos::OGuard aGuard(Application::GetSolarMutex());
1207 if(IsValid())
1209 SfxViewFrame* pFrame = SfxViewFrame::CreateViewFrame( *pDocShell, 7, sal_True );
1210 SfxRequest aReq(FN_PRINT_PAGEPREVIEW, SFX_CALLMODE_SYNCHRON,
1211 pDocShell->GetDoc()->GetAttrPool());
1212 aReq.AppendItem(SfxBoolItem(FN_PRINT_PAGEPREVIEW, sal_True));
1214 OUString sFileName( C2U(SW_PROP_NAME_STR(UNO_NAME_FILE_NAME)));
1215 OUString sCopyCount(C2U(SW_PROP_NAME_STR(UNO_NAME_COPY_COUNT)));
1216 OUString sCollate(C2U(SW_PROP_NAME_STR(UNO_NAME_COLLATE)));
1217 OUString sSort(C2U(SW_PROP_NAME_STR(UNO_NAME_SORT)));
1218 OUString sPages(C2U(SW_PROP_NAME_STR(UNO_NAME_PAGES)));
1220 for ( int n = 0; n < xOptions.getLength(); ++n )
1222 // get Property-Value from options
1223 const beans::PropertyValue &rProp = xOptions.getConstArray()[n];
1224 Any aValue( rProp.Value );
1226 // FileName-Property?
1227 if ( rProp.Name == sFileName )
1229 OUString sFileURL;
1230 if ( (rProp.Value >>= sFileURL ) )
1232 // Convert the File URL into a system dependant path, as the SalPrinter expects
1233 OUString sSystemPath;
1234 FileBase::getSystemPathFromFileURL ( sFileURL, sSystemPath );
1235 aReq.AppendItem(SfxStringItem( SID_FILE_NAME, sSystemPath ) );
1237 else if ( rProp.Value.getValueType() != ::getVoidCppuType() )
1238 throw IllegalArgumentException();
1241 // CopyCount-Property
1242 else if ( rProp.Name == sCopyCount )
1244 sal_Int32 nCopies = 0;
1245 aValue >>= nCopies;
1246 aReq.AppendItem(SfxInt16Item( SID_PRINT_COPIES, (sal_Int16)nCopies ) );
1249 // Collate-Property
1250 else if ( rProp.Name == sCollate )
1252 if ( rProp.Value.getValueType() == ::getBooleanCppuType())
1254 aReq.AppendItem(SfxBoolItem( SID_PRINT_COLLATE, *(sal_Bool*)rProp.Value.getValue() ) );
1255 else
1256 throw IllegalArgumentException();
1259 // Sort-Property
1260 else if ( rProp.Name == sSort )
1262 if ( rProp.Value.getValueType() == ::getBooleanCppuType() )
1263 aReq.AppendItem(SfxBoolItem( SID_PRINT_SORT, *(sal_Bool*)rProp.Value.getValue() ) );
1264 else
1265 throw IllegalArgumentException();
1268 // Pages-Property
1269 else if ( rProp.Name == sPages )
1271 OUString sTmp;
1272 if ( rProp.Value >>= sTmp )
1273 aReq.AppendItem( SfxStringItem( SID_PRINT_PAGES, sTmp ) );
1274 else
1275 throw IllegalArgumentException();
1280 pFrame->GetViewShell()->ExecuteSlot(aReq);
1281 // Frame schliessen
1282 pFrame->DoClose();
1285 else
1286 throw RuntimeException();
1288 /*-- 18.12.98 11:55:25---------------------------------------------------
1290 -----------------------------------------------------------------------*/
1291 Reference< XNameAccess > SwXTextDocument::getReferenceMarks(void)
1292 throw( RuntimeException )
1294 ::vos::OGuard aGuard(Application::GetSolarMutex());
1295 if(!IsValid())
1296 throw RuntimeException();
1297 if(!pxXReferenceMarks)
1299 ((SwXTextDocument*)this)->pxXReferenceMarks = new Reference< XNameAccess > ;
1300 *pxXReferenceMarks = new SwXReferenceMarks(pDocShell->GetDoc());
1302 return *pxXReferenceMarks;
1304 /* -----------------21.12.98 10:20-------------------
1306 * --------------------------------------------------*/
1307 Reference< XEnumerationAccess > SwXTextDocument::getTextFields(void) throw( RuntimeException )
1309 ::vos::OGuard aGuard(Application::GetSolarMutex());
1310 if(!IsValid())
1311 throw RuntimeException();
1312 if(!pxXTextFieldTypes)
1314 ((SwXTextDocument*)this)->pxXTextFieldTypes = new Reference< XEnumerationAccess > ;
1315 *pxXTextFieldTypes = new SwXTextFieldTypes(pDocShell->GetDoc());
1317 return *pxXTextFieldTypes;
1319 /*-- 21.12.98 10:21:12---------------------------------------------------
1321 -----------------------------------------------------------------------*/
1322 Reference< XNameAccess > SwXTextDocument::getTextFieldMasters(void)
1323 throw( RuntimeException )
1325 ::vos::OGuard aGuard(Application::GetSolarMutex());
1326 if(!IsValid())
1327 throw RuntimeException();
1328 if(!pxXTextFieldMasters)
1330 ((SwXTextDocument*)this)->pxXTextFieldMasters = new Reference< XNameAccess > ;
1331 *pxXTextFieldMasters = new SwXTextFieldMasters(pDocShell->GetDoc());
1333 return *pxXTextFieldMasters;
1335 /*-- 21.12.98 10:21:12---------------------------------------------------
1337 -----------------------------------------------------------------------*/
1338 Reference< XNameAccess > SwXTextDocument::getEmbeddedObjects(void) throw( RuntimeException )
1340 ::vos::OGuard aGuard(Application::GetSolarMutex());
1341 if(!IsValid())
1342 throw RuntimeException();
1343 if(!pxXEmbeddedObjects)
1345 ((SwXTextDocument*)this)->pxXEmbeddedObjects = new Reference< XNameAccess > ;
1346 *pxXEmbeddedObjects = new SwXTextEmbeddedObjects(pDocShell->GetDoc());
1348 return *pxXEmbeddedObjects;
1350 /*-- 21.12.98 10:21:13---------------------------------------------------
1352 -----------------------------------------------------------------------*/
1353 Reference< XNameAccess > SwXTextDocument::getBookmarks(void) throw( RuntimeException )
1355 ::vos::OGuard aGuard(Application::GetSolarMutex());
1356 if(!IsValid())
1357 throw RuntimeException();
1358 if(!pxXBookmarks)
1360 ((SwXTextDocument*)this)->pxXBookmarks = new Reference< XNameAccess > ;
1361 *pxXBookmarks = new SwXBookmarks(pDocShell->GetDoc());
1363 return *pxXBookmarks;
1365 /*-- 21.12.98 10:21:13---------------------------------------------------
1367 -----------------------------------------------------------------------*/
1368 Reference< XNameAccess > SwXTextDocument::getTextSections(void) throw( RuntimeException )
1370 ::vos::OGuard aGuard(Application::GetSolarMutex());
1371 if(!IsValid())
1372 throw RuntimeException();
1373 if(!pxXTextSections)
1375 ((SwXTextDocument*)this)->pxXTextSections = new Reference< XNameAccess > ;
1376 *pxXTextSections = new SwXTextSections(pDocShell->GetDoc());
1378 return *pxXTextSections;
1380 /*-- 21.12.98 10:21:13---------------------------------------------------
1382 -----------------------------------------------------------------------*/
1383 Reference< XNameAccess > SwXTextDocument::getTextTables(void) throw( RuntimeException )
1385 ::vos::OGuard aGuard(Application::GetSolarMutex());
1386 if(!IsValid())
1387 throw RuntimeException();
1388 if(!pxXTextTables)
1390 ((SwXTextDocument*)this)->pxXTextTables = new Reference< XNameAccess > ;
1391 *pxXTextTables = new SwXTextTables(pDocShell->GetDoc());
1393 return *pxXTextTables;
1395 /*-- 21.12.98 10:21:13---------------------------------------------------
1397 -----------------------------------------------------------------------*/
1398 Reference< XNameAccess > SwXTextDocument::getGraphicObjects(void) throw( RuntimeException )
1400 ::vos::OGuard aGuard(Application::GetSolarMutex());
1401 if(!IsValid())
1402 throw RuntimeException();
1403 if(!pxXGraphicObjects)
1405 ((SwXTextDocument*)this)->pxXGraphicObjects = new Reference< XNameAccess > ;
1406 *pxXGraphicObjects = new SwXTextGraphicObjects(pDocShell->GetDoc());
1408 return *pxXGraphicObjects;
1410 /*-- 21.12.98 10:21:14---------------------------------------------------
1412 -----------------------------------------------------------------------*/
1413 Reference< XNameAccess > SwXTextDocument::getTextFrames(void) throw( RuntimeException )
1415 ::vos::OGuard aGuard(Application::GetSolarMutex());
1416 if(!IsValid())
1417 throw RuntimeException();
1418 if(!pxXTextFrames)
1420 ((SwXTextDocument*)this)->pxXTextFrames = new Reference< XNameAccess > ;
1421 *pxXTextFrames = new SwXTextFrames(pDocShell->GetDoc());
1423 return *pxXTextFrames;
1425 /* -----------------21.12.98 10:56-------------------
1427 * --------------------------------------------------*/
1428 Reference< XNameAccess > SwXTextDocument::getStyleFamilies(void) throw( RuntimeException )
1430 ::vos::OGuard aGuard(Application::GetSolarMutex());
1431 if(!IsValid())
1432 throw RuntimeException();
1433 if(!pxXStyleFamilies)
1435 ((SwXTextDocument*)this)->pxXStyleFamilies = new Reference< XNameAccess > ;
1436 *pxXStyleFamilies = new SwXStyleFamilies(*pDocShell);
1438 return *pxXStyleFamilies;
1440 /*-- 19.05.06 10:15:22---------------------------------------------------
1442 -----------------------------------------------------------------------*/
1443 uno::Reference< style::XAutoStyles > SwXTextDocument::getAutoStyles( )
1444 throw (uno::RuntimeException)
1446 ::vos::OGuard aGuard(Application::GetSolarMutex());
1447 if(!IsValid())
1448 throw RuntimeException();
1449 if(!pxXAutoStyles)
1451 pxXAutoStyles = new Reference< style::XAutoStyles > ;
1452 *pxXAutoStyles = new SwXAutoStyles(*pDocShell);
1454 return *pxXAutoStyles;
1457 /*-- 22.01.99 10:18:03---------------------------------------------------
1459 -----------------------------------------------------------------------*/
1460 Reference< drawing::XDrawPage > SwXTextDocument::getDrawPage(void) throw( RuntimeException )
1462 ::vos::OGuard aGuard(Application::GetSolarMutex());
1463 if(!IsValid())
1464 throw RuntimeException();
1465 if(!pxXDrawPage)
1467 // simplified this creation, keeping original below as reference
1468 // for the case that it did something by purpose
1469 ((SwXTextDocument*)this)->pDrawPage = new SwXDrawPage(pDocShell->GetDoc());
1470 ((SwXTextDocument*)this)->pxXDrawPage = new Reference< drawing::XDrawPage >(pDrawPage);
1472 //((SwXTextDocument*)this)->pxXDrawPage = new Reference< drawing::XDrawPage > ;
1473 //((SwXTextDocument*)this)->pDrawPage = new SwXDrawPage(pDocShell->GetDoc());
1474 //Reference< drawing::XShapes > xTmp = pDrawPage;
1475 //*pxXDrawPage = Reference< drawing::XDrawPage>(xTmp, UNO_QUERY);
1477 return *pxXDrawPage;
1479 /* -----------------07.04.99 10:11-------------------
1481 * --------------------------------------------------*/
1482 SwXDrawPage* SwXTextDocument::GetDrawPage()
1484 if(!IsValid())
1485 return 0;
1486 if(!pDrawPage)
1487 getDrawPage();
1488 return pDrawPage;
1490 /*-- 18.12.98 11:55:26---------------------------------------------------
1492 -----------------------------------------------------------------------*/
1493 void SwXTextDocument::Invalidate()
1495 bObjectValid = sal_False;
1496 if(xNumFmtAgg.is())
1498 const uno::Type& rTunnelType = ::getCppuType((Reference <XUnoTunnel>*)0);
1499 Any aNumTunnel = xNumFmtAgg->queryAggregation(rTunnelType);
1500 SvNumberFormatsSupplierObj* pNumFmt = 0;
1501 Reference< XUnoTunnel > xNumTunnel;
1502 if(aNumTunnel >>= xNumTunnel)
1504 pNumFmt = reinterpret_cast<SvNumberFormatsSupplierObj*>(
1505 xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
1506 pNumFmt->SetNumberFormatter(0);
1508 DBG_ASSERT(pNumFmt, "No number formatter available");
1510 InitNewDoc();
1511 pDocShell = 0;
1512 aRefreshCont.Disposing();
1514 /* -----------------------------13.07.00 15:59--------------------------------
1516 ---------------------------------------------------------------------------*/
1517 void SwXTextDocument::Reactivate(SwDocShell* pNewDocShell)
1519 if(pDocShell && pDocShell != pNewDocShell)
1520 Invalidate();
1521 pDocShell = pNewDocShell;
1522 bObjectValid = TRUE;
1524 /*-- 18.12.98 11:55:26---------------------------------------------------
1526 -----------------------------------------------------------------------*/
1527 void SwXTextDocument::InitNewDoc()
1529 // zunaechst alle Collections invalidieren, dann Referenzen loeschen und Null setzen
1530 if(pxXTextTables)
1532 XNameAccess* pTbls = pxXTextTables->get();
1533 ((SwXTextTables*)pTbls)->Invalidate();
1534 delete pxXTextTables;
1535 pxXTextTables = 0;
1538 if(pxXTextFrames)
1540 XNameAccess* pFrms = pxXTextFrames->get();
1541 ((SwXTextFrames*)pFrms)->Invalidate();
1542 delete pxXTextFrames;
1543 pxXTextFrames = 0;
1546 if(pxXGraphicObjects)
1548 XNameAccess* pFrms = pxXGraphicObjects->get();
1549 ((SwXTextGraphicObjects*)pFrms)->Invalidate();
1550 delete pxXGraphicObjects;
1551 pxXGraphicObjects = 0;
1554 if(pxXEmbeddedObjects)
1556 XNameAccess* pOLE = pxXEmbeddedObjects->get();
1557 ((SwXTextEmbeddedObjects*)pOLE)->Invalidate();
1558 delete pxXEmbeddedObjects;
1559 pxXEmbeddedObjects = 0;
1562 if(xBodyText.is())
1564 xBodyText = 0;
1565 pBodyText = 0;
1568 if(xNumFmtAgg.is())
1570 const uno::Type& rTunnelType = ::getCppuType((Reference <XUnoTunnel>*)0);
1571 Any aNumTunnel = xNumFmtAgg->queryAggregation(rTunnelType);
1572 SvNumberFormatsSupplierObj* pNumFmt = 0;
1573 Reference< XUnoTunnel > xNumTunnel;
1574 if(aNumTunnel >>= xNumTunnel)
1576 pNumFmt = reinterpret_cast<SvNumberFormatsSupplierObj*>(
1577 xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
1580 DBG_ASSERT(pNumFmt, "No number formatter available");
1581 pNumFmt->SetNumberFormatter(0);
1584 if(pxXTextFieldTypes)
1586 XEnumerationAccess* pT = pxXTextFieldTypes->get();
1587 ((SwXTextFieldTypes*)pT)->Invalidate();
1588 delete pxXTextFieldTypes;
1589 pxXTextFieldTypes = 0;
1592 if(pxXTextFieldMasters)
1594 XNameAccess* pT = pxXTextFieldMasters->get();
1595 ((SwXTextFieldMasters*)pT)->Invalidate();
1596 delete pxXTextFieldMasters;
1597 pxXTextFieldMasters = 0;
1600 if(pxXTextSections)
1602 XNameAccess* pSect = pxXTextSections->get();
1603 ((SwXTextSections*)pSect)->Invalidate();
1604 delete pxXTextSections;
1605 pxXTextSections = 0;
1608 if(pxXDrawPage)
1610 // --> OD 2008-07-23 #i91798#, #i91895#
1611 // dispose XDrawPage here. We are the owner and know that it is no longer in a valid condition.
1612 uno::Reference<lang::XComponent> xComp( *pxXDrawPage, uno::UNO_QUERY );
1613 xComp->dispose();
1614 // <--
1615 pDrawPage->InvalidateSwDoc();
1616 delete pxXDrawPage;
1617 pxXDrawPage = 0;
1620 if ( pxXNumberingRules )
1622 XIndexAccess* pNum = pxXNumberingRules->get();
1623 ((SwXNumberingRulesCollection*)pNum)->Invalidate();
1624 delete pxXNumberingRules;
1625 pxXNumberingRules = 0;
1628 if(pxXFootnotes)
1630 XIndexAccess* pFtn = pxXFootnotes->get();
1631 ((SwXFootnotes*)pFtn)->Invalidate();
1632 delete pxXFootnotes;
1633 pxXFootnotes = 0;
1636 if(pxXEndnotes)
1638 XIndexAccess* pFtn = pxXEndnotes->get();
1639 ((SwXFootnotes*)pFtn)->Invalidate();
1640 delete pxXEndnotes;
1641 pxXEndnotes = 0;
1644 if(pxXDocumentIndexes)
1646 XIndexAccess* pIdxs = pxXDocumentIndexes->get();
1647 ((SwXDocumentIndexes*)pIdxs)->Invalidate();
1648 delete pxXDocumentIndexes;
1649 pxXDocumentIndexes = 0;
1652 if(pxXStyleFamilies)
1654 XNameAccess* pStyles = pxXStyleFamilies->get();
1655 ((SwXStyleFamilies*)pStyles)->Invalidate();
1656 delete pxXStyleFamilies;
1657 pxXStyleFamilies = 0;
1659 if(pxXAutoStyles)
1661 XNameAccess* pStyles = pxXAutoStyles->get();
1662 ((SwXAutoStyles*)pStyles)->Invalidate();
1663 delete pxXAutoStyles;
1664 pxXAutoStyles = 0;
1667 if(pxXBookmarks)
1669 XNameAccess* pBm = pxXBookmarks->get();
1670 ((SwXBookmarks*)pBm)->Invalidate();
1671 delete pxXBookmarks;
1672 pxXBookmarks = 0;
1675 if(pxXChapterNumbering)
1677 XIndexReplace* pCh = pxXChapterNumbering->get();
1678 ((SwXChapterNumbering*)pCh)->Invalidate();
1679 delete pxXChapterNumbering;
1680 pxXChapterNumbering = 0;
1683 if(pxXFootnoteSettings)
1685 XPropertySet* pFntSet = pxXFootnoteSettings->get();
1686 ((SwXFootnoteProperties*)pFntSet)->Invalidate();
1687 delete pxXFootnoteSettings;
1688 pxXFootnoteSettings = 0;
1691 if(pxXEndnoteSettings)
1693 XPropertySet* pEndSet = pxXEndnoteSettings->get();
1694 ((SwXEndnoteProperties*)pEndSet)->Invalidate();
1695 delete pxXEndnoteSettings;
1696 pxXEndnoteSettings = 0;
1699 if(pxXLineNumberingProperties)
1701 XPropertySet* pLine = pxXLineNumberingProperties->get();
1702 ((SwXLineNumberingProperties*)pLine)->Invalidate();
1703 delete pxXLineNumberingProperties;
1704 pxXLineNumberingProperties = 0;
1706 if(pxXReferenceMarks)
1708 XNameAccess* pMarks = pxXReferenceMarks->get();
1709 ((SwXReferenceMarks*)pMarks)->Invalidate();
1710 delete pxXReferenceMarks;
1711 pxXReferenceMarks = 0;
1713 if(pxLinkTargetSupplier)
1715 XNameAccess* pAccess = (*pxLinkTargetSupplier).get();
1716 ((SwXLinkTargetSupplier*)pAccess)->Invalidate();
1717 delete pxLinkTargetSupplier;
1718 pxLinkTargetSupplier = 0;
1720 if(pxXRedlines)
1722 XEnumerationAccess* pMarks = pxXRedlines->get();
1723 ((SwXRedlines*)pMarks)->Invalidate();
1724 delete pxXRedlines;
1725 pxXRedlines = 0;
1727 if(xPropertyHelper.is())
1729 pPropertyHelper->Invalidate();
1730 xPropertyHelper = 0;
1731 pPropertyHelper = 0;
1735 /*-- 11.03.99 11:51:40---------------------------------------------------
1737 -----------------------------------------------------------------------*/
1738 #define COM_SUN_STAR__DRAWING_LENGTH 13
1739 Reference< XInterface > SwXTextDocument::createInstance(const OUString& rServiceName)
1740 throw( Exception, RuntimeException )
1742 ::vos::OGuard aGuard(Application::GetSolarMutex());
1743 if(!IsValid())
1744 throw RuntimeException();
1745 Reference< XInterface > xRet;
1746 sal_uInt16 nType = SwXServiceProvider::GetProviderType(rServiceName);
1747 if(nType != SW_SERVICE_INVALID)
1749 xRet = SwXServiceProvider::MakeInstance(nType, pDocShell->GetDoc());
1751 else
1753 if( rServiceName.compareToAscii( "com.sun.star.", 13 ) == 0 )
1755 sal_Int32 nIndex = COM_SUN_STAR__DRAWING_LENGTH;
1756 OUString sCategory = rServiceName.getToken( 0, '.', nIndex );
1757 sal_Bool bShape = sCategory == C2U("drawing");
1758 if( bShape || sCategory == C2U("form"))
1760 if(bShape)
1762 short nTable = 0;
1763 if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.DashTable") ) )
1764 nTable = SW_CREATE_DASH_TABLE;
1765 else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GradientTable") ) )
1766 nTable = SW_CREATE_GRADIENT_TABLE;
1767 else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.HatchTable") ) )
1768 nTable = SW_CREATE_HATCH_TABLE;
1769 else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.BitmapTable") ) )
1770 nTable = SW_CREATE_BITMAP_TABLE;
1771 else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) )
1772 nTable = SW_CREATE_TRANSGRADIENT_TABLE;
1773 else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MarkerTable") ) )
1774 nTable = SW_CREATE_MARKER_TABLE;
1775 else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Defaults") ) )
1776 nTable = SW_CREATE_DRAW_DEFAULTS;
1777 if(nTable)
1779 xRet = GetPropertyHelper()->GetDrawTable(nTable);
1783 else if (sCategory == C2U ("document") )
1785 if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.Settings") ) )
1786 xRet = Reference < XInterface > ( *new SwXDocumentSettings ( this ) );
1787 if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ImportEmbeddedObjectResolver") ) )
1789 xRet = (::cppu::OWeakObject * )new SvXMLEmbeddedObjectHelper( *pDocShell, EMBEDDEDOBJECTHELPER_MODE_READ );
1792 else if (sCategory == C2U ("text") )
1794 if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.PrintPreviewSettings") ) )
1795 xRet = Reference < XInterface > ( *new SwXPrintPreviewSettings ( pDocShell->GetDoc() ) );
1796 else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.DocumentSettings") ) )
1797 xRet = Reference < XInterface > ( *new SwXDocumentSettings ( this ) );
1799 else if (sCategory == C2U ("chart2") )
1801 if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.data.DataProvider") ) )
1802 xRet = Reference < XInterface > ( dynamic_cast< chart2::data::XDataProvider * >(pDocShell->getIDocumentChartDataProviderAccess()->GetChartDataProvider()) );
1805 if(!xRet.is())
1807 //! we don't want to insert OLE2 Shapes (e.g. "com.sun.star.drawing.OLE2Shape", ...)
1808 //! like this (by creating them with the documents factory and
1809 //! adding the shapes to the draw page).
1810 //! For inserting OLE objects the proper way is to use
1811 //! "com.sun.star.text.TextEmbeddedObject"!
1812 if (rServiceName.lastIndexOf( C2U(".OLE2Shape") ) == rServiceName.getLength() - 10)
1813 throw ServiceNotRegisteredException(); // declare service to be not registered with this factory
1815 // --> OD 2006-02-22 #b6382898#
1816 // the XML import is allowed to create instances of com.sun.star.drawing.OLE2Shape.
1817 // Thus, a temporary service name is introduced to make this possible.
1818 OUString aTmpServiceName( rServiceName );
1819 if ( bShape &&
1820 rServiceName.compareToAscii( "com.sun.star.drawing.temporaryForXMLImportOLE2Shape" ) == 0 )
1822 aTmpServiceName = OUString::createFromAscii( "com.sun.star.drawing.OLE2Shape" );
1824 //hier den Draw - Service suchen
1825 Reference< XInterface > xTmp = SvxFmMSFactory::createInstance(aTmpServiceName);
1826 // <--
1827 if(bShape)
1829 nIndex = COM_SUN_STAR__DRAWING_LENGTH;
1830 if( 0 == rServiceName.reverseCompareToAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.drawing.GroupShape" ) ) ||
1831 0 == rServiceName.reverseCompareToAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.drawing.Shape3DSceneObject" ) ) )
1832 xRet = *new SwXGroupShape( xTmp );
1833 else
1834 xRet = *new SwXShape( xTmp );
1836 else
1837 xRet = xTmp;
1840 else
1841 throw ServiceNotRegisteredException();
1843 return xRet;
1845 /*-- 11.03.99 11:51:40---------------------------------------------------
1847 -----------------------------------------------------------------------*/
1848 Reference< XInterface > SwXTextDocument::createInstanceWithArguments(
1849 const OUString& ServiceSpecifier,
1850 const Sequence< Any >& /*Arguments*/)
1851 throw( Exception, RuntimeException )
1853 Reference< XInterface > xInt = createInstance(ServiceSpecifier);
1854 //die Any-Sequence dient zur Initialisierung von Objekten, die auf
1855 //Parameter zwingend angewiesen sind - bis jetzt haben wir das nicht
1856 return xInt;
1858 /*-- 11.03.99 11:51:41---------------------------------------------------
1860 -----------------------------------------------------------------------*/
1861 Sequence< OUString > SwXTextDocument::getAvailableServiceNames(void)
1862 throw( RuntimeException )
1864 static Sequence< OUString > aServices;
1865 if ( aServices.getLength() == 0 )
1867 Sequence< OUString > aRet = SvxFmMSFactory::getAvailableServiceNames();
1868 OUString* pRet = aRet.getArray();
1869 for ( sal_Int32 i = 0; i < aRet.getLength(); ++i )
1871 if ( pRet[i].compareToAscii( "com.sun.star.drawing.OLE2Shape" ) == 0 )
1873 pRet[i] = pRet[aRet.getLength() - 1];
1874 aRet.realloc( aRet.getLength() - 1 ); // <pRet> no longer valid.
1875 break;
1878 Sequence< OUString > aOwn = SwXServiceProvider::GetAllServiceNames();
1879 aServices = SvxFmMSFactory::concatServiceNames(aRet, aOwn);
1882 return aServices;
1884 /* -----------------18.03.99 11:36-------------------
1886 * --------------------------------------------------*/
1887 OUString SwXTextDocument::getImplementationName(void) throw( RuntimeException )
1889 return C2U("SwXTextDocument");
1891 /* -----------------20.01.04 10:14-------------------
1893 * --------------------------------------------------*/
1894 sal_Bool SwXTextDocument::supportsService(const OUString& rServiceName) throw( RuntimeException )
1896 if (
1897 (rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.document.OfficeDocument" ))) ||
1898 (rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.text.GenericTextDocument")))
1900 return sal_True;
1902 BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell));
1903 BOOL bGlobalDoc = (0 != PTR_CAST(SwGlobalDocShell, pDocShell));
1904 BOOL bTextDoc = (!bWebDoc && !bGlobalDoc);
1906 return (
1907 (bWebDoc && rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.WebDocument" ))) ||
1908 (bGlobalDoc && rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.GlobalDocument"))) ||
1909 (bTextDoc && rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextDocument" )))
1912 /* -----------------20.01.04 10:17-------------------
1914 * --------------------------------------------------*/
1915 Sequence< OUString > SwXTextDocument::getSupportedServiceNames(void) throw( RuntimeException )
1917 BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell));
1918 BOOL bGlobalDoc = (0 != PTR_CAST(SwGlobalDocShell, pDocShell));
1919 BOOL bTextDoc = (!bWebDoc && !bGlobalDoc);
1921 Sequence< OUString > aRet (3);
1922 OUString* pArray = aRet.getArray();
1924 pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.document.OfficeDocument" ) ) );
1925 pArray[1] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.text.GenericTextDocument" ) ) );
1927 if (bTextDoc)
1928 pArray[2] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.text.TextDocument" ) ) );
1929 else
1930 if (bWebDoc)
1931 pArray[2] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.text.WebDocument" ) ) );
1932 else
1933 if (bGlobalDoc)
1934 pArray[2] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.text.GlobalDocument" ) ) );
1936 return aRet;
1938 /* -----------------05.05.99 12:10-------------------
1940 * --------------------------------------------------*/
1941 Reference< XIndexAccess > SwXTextDocument::getDocumentIndexes(void) throw( RuntimeException )
1943 ::vos::OGuard aGuard(Application::GetSolarMutex());
1944 if(!IsValid())
1945 throw RuntimeException();
1946 if(!pxXDocumentIndexes)
1948 ((SwXTextDocument*)this)->pxXDocumentIndexes = new Reference< XIndexAccess > ;
1949 *pxXDocumentIndexes = new SwXDocumentIndexes(pDocShell->GetDoc());
1951 return *pxXDocumentIndexes;
1954 /*-- 10.05.99 13:58:58---------------------------------------------------
1956 -----------------------------------------------------------------------*/
1957 Reference< XPropertySetInfo > SwXTextDocument::getPropertySetInfo(void) throw( RuntimeException )
1959 static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
1960 return xRet;
1962 /*-- 10.05.99 13:58:58---------------------------------------------------
1964 -----------------------------------------------------------------------*/
1965 void SwXTextDocument::setPropertyValue(const OUString& rPropertyName,
1966 const Any& aValue)
1967 throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException,
1968 WrappedTargetException, RuntimeException)
1970 ::vos::OGuard aGuard(Application::GetSolarMutex());
1971 if(!IsValid())
1972 throw RuntimeException();
1973 const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap()->getByName( rPropertyName);
1975 if(!pEntry)
1976 throw UnknownPropertyException();
1977 if(pEntry->nFlags & PropertyAttribute::READONLY)
1978 throw PropertyVetoException();
1979 switch(pEntry->nWID)
1981 case WID_DOC_CHAR_COUNT :
1982 case WID_DOC_PARA_COUNT :
1983 case WID_DOC_WORD_COUNT :
1984 throw RuntimeException();
1985 case WID_DOC_WORD_SEPARATOR :
1987 OUString sDelim;
1988 aValue >>= sDelim;
1989 SW_MOD()->GetModuleConfig()->SetWordDelimiter(sDelim);
1991 break;
1992 case WID_DOC_CHANGES_RECORD:
1993 case WID_DOC_CHANGES_SHOW:
1995 sal_Bool bSet = *(sal_Bool*)aValue.getValue();
1996 sal_uInt16 eMode = pDocShell->GetDoc()->GetRedlineMode();
1997 if(WID_DOC_CHANGES_SHOW == pEntry->nWID)
1999 eMode &= ~(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE);
2000 eMode |= nsRedlineMode_t::REDLINE_SHOW_INSERT;
2001 if( bSet )
2002 eMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE;
2004 else if(WID_DOC_CHANGES_RECORD == pEntry->nWID)
2006 eMode = bSet ? eMode|nsRedlineMode_t::REDLINE_ON : eMode&~nsRedlineMode_t::REDLINE_ON;
2008 pDocShell->GetDoc()->SetRedlineMode( (RedlineMode_t)(eMode ));
2010 break;
2011 case WID_DOC_CHANGES_PASSWORD:
2013 Sequence <sal_Int8> aNew;
2014 if(aValue >>= aNew)
2016 SwDoc* pDoc = pDocShell->GetDoc();
2017 pDoc->SetRedlinePassword(aNew);
2018 if(aNew.getLength())
2020 sal_uInt16 eMode = pDoc->GetRedlineMode();
2021 eMode = eMode|nsRedlineMode_t::REDLINE_ON;
2022 pDoc->SetRedlineMode( (RedlineMode_t)(eMode ));
2026 break;
2027 case WID_DOC_AUTO_MARK_URL :
2029 OUString sURL;
2030 aValue >>= sURL;
2031 pDocShell->GetDoc()->SetTOIAutoMarkURL(sURL);
2033 break;
2034 case WID_DOC_HIDE_TIPS :
2035 SW_MOD()->GetModuleConfig()->SetHideFieldTips(*(sal_Bool*)aValue.getValue());
2036 break;
2037 case WID_DOC_REDLINE_DISPLAY:
2039 sal_Int16 eRedMode = pDocShell->GetDoc()->GetRedlineMode();
2040 eRedMode = eRedMode & (~nsRedlineMode_t::REDLINE_SHOW_MASK);
2041 sal_Int16 nSet = 0;
2042 aValue >>= nSet;
2043 switch(nSet)
2045 case RedlineDisplayType::NONE: break;
2046 case RedlineDisplayType::INSERTED: eRedMode |= nsRedlineMode_t::REDLINE_SHOW_INSERT; break;
2047 case RedlineDisplayType::REMOVED: eRedMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE; break;
2048 case RedlineDisplayType::
2049 INSERTED_AND_REMOVED: eRedMode |= nsRedlineMode_t::REDLINE_SHOW_INSERT|nsRedlineMode_t::REDLINE_SHOW_DELETE;
2050 break;
2051 default: throw IllegalArgumentException();
2053 pDocShell->GetDoc()->SetRedlineMode(eRedMode);
2055 break;
2056 case WID_DOC_TWO_DIGIT_YEAR:
2058 sal_Int16 nYear = 0;
2059 aValue >>= nYear;
2060 SfxRequest aRequest ( SID_ATTR_YEAR2000, SFX_CALLMODE_SLOT, pDocShell->GetDoc()->GetAttrPool());
2061 aRequest.AppendItem(SfxUInt16Item( SID_ATTR_YEAR2000, static_cast < sal_uInt16 > ( nYear ) ) );
2062 pDocShell->Execute ( aRequest );
2064 break;
2065 case WID_DOC_AUTOMATIC_CONTROL_FOCUS:
2067 SwDrawDocument * pDrawDoc;
2068 sal_Bool bAuto = *(sal_Bool*) aValue.getValue();
2070 if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * >( pDocShell->GetDoc()->GetDrawModel() ) ) )
2071 pDrawDoc->SetAutoControlFocus( bAuto );
2072 else if (bAuto)
2074 // if setting to true, and we don't have an
2075 // SdrModel, then we are changing the default and
2076 // must thus create an SdrModel, if we don't have an
2077 // SdrModel and we are leaving the default at false,
2078 // we don't need to make an SdrModel and can do nothing
2079 // --> OD 2005-08-08 #i52858# - method name changed
2080 pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetOrCreateDrawModel() );
2081 // <--
2082 pDrawDoc->SetAutoControlFocus ( bAuto );
2085 break;
2086 case WID_DOC_APPLY_FORM_DESIGN_MODE:
2088 SwDrawDocument * pDrawDoc;
2089 sal_Bool bMode = *(sal_Bool*)aValue.getValue();
2091 if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetDrawModel() ) ) )
2092 pDrawDoc->SetOpenInDesignMode( bMode );
2093 else if (!bMode)
2095 // if setting to false, and we don't have an
2096 // SdrModel, then we are changing the default and
2097 // must thus create an SdrModel, if we don't have an
2098 // SdrModel and we are leaving the default at true,
2099 // we don't need to make an SdrModel and can do
2100 // nothing
2101 // --> OD 2005-08-08 #i52858# - method name changed
2102 pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetOrCreateDrawModel() );
2103 // <--
2104 pDrawDoc->SetOpenInDesignMode ( bMode );
2107 break;
2108 // --> FME 2005-02-25 #i42634# New property to set the bInReading
2109 // flag at the document, used during binary import
2110 case WID_DOC_LOCK_UPDATES :
2112 SwDoc* pDoc = pDocShell->GetDoc();
2113 bool bBool (false);
2114 if( aValue >>= bBool )
2115 pDoc->SetInReading( bBool );
2117 break;
2118 // <--
2119 case WID_DOC_BUILDID:
2120 aValue >>= maBuildId;
2121 break;
2122 // --> OD 2006-03-21 #b6375613#
2123 case WID_APPLY_WORKAROUND_FOR_B6375613:
2125 bool bApplyWorkaroundForB6375613( false );
2126 aValue >>= bApplyWorkaroundForB6375613;
2127 pDocShell->GetDoc()->SetApplyWorkaroundForB6375613( bApplyWorkaroundForB6375613 );
2129 break;
2130 // <--
2132 default:
2134 const SfxPoolItem& rItem = pDocShell->GetDoc()->GetDefault(pEntry->nWID);
2135 SfxPoolItem* pNewItem = rItem.Clone();
2136 pNewItem->PutValue(aValue, pEntry->nMemberId);
2137 pDocShell->GetDoc()->SetDefault(*pNewItem);
2138 delete pNewItem;
2142 /*-- 10.05.99 13:58:59---------------------------------------------------
2144 -----------------------------------------------------------------------*/
2145 Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName)
2146 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
2148 ::vos::OGuard aGuard(Application::GetSolarMutex());
2149 if(!IsValid())
2150 throw RuntimeException();
2151 const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap()->getByName( rPropertyName);
2153 if(!pEntry)
2154 throw UnknownPropertyException();
2155 Any aAny;
2156 switch(pEntry->nWID)
2158 case WID_DOC_ISTEMPLATEID :
2159 aAny <<= pDocShell->IsTemplate();
2160 break;
2161 case WID_DOC_CHAR_COUNT :
2162 case WID_DOC_PARA_COUNT :
2163 case WID_DOC_WORD_COUNT :
2165 SwDocStat aStat(pDocShell->GetDoc()->GetDocStat());
2166 if(aStat.bModified)
2167 pDocShell->GetDoc()->UpdateDocStat( aStat );
2168 sal_Int32 nValue;
2169 switch(pEntry->nWID)
2171 case WID_DOC_CHAR_COUNT :nValue = aStat.nChar;break;
2172 case WID_DOC_PARA_COUNT :nValue = aStat.nPara;break;
2173 case WID_DOC_WORD_COUNT :nValue = aStat.nWord;break;
2175 aAny <<= nValue;
2177 break;
2178 case WID_DOC_WORD_SEPARATOR :
2180 aAny <<= OUString(SW_MOD()->GetDocStatWordDelim());
2182 break;
2183 case WID_DOC_CHANGES_RECORD:
2184 case WID_DOC_CHANGES_SHOW:
2186 sal_uInt16 eMode = pDocShell->GetDoc()->GetRedlineMode();
2187 sal_Bool bSet = sal_False;
2188 if(WID_DOC_CHANGES_SHOW == pEntry->nWID)
2190 sal_uInt16 nMask = nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE;
2191 bSet = (eMode & nMask) == nMask;
2193 else if(WID_DOC_CHANGES_RECORD == pEntry->nWID)
2195 bSet = (eMode& nsRedlineMode_t::REDLINE_ON) != 0;
2197 aAny.setValue(&bSet, ::getBooleanCppuType());
2199 break;
2200 case WID_DOC_CHANGES_PASSWORD:
2202 SwDoc* pDoc = pDocShell->GetDoc();
2203 aAny <<= pDoc->GetRedlinePassword();
2205 break;
2206 case WID_DOC_AUTO_MARK_URL :
2207 aAny <<= OUString(pDocShell->GetDoc()->GetTOIAutoMarkURL());
2208 break;
2209 case WID_DOC_HIDE_TIPS :
2211 BOOL bTemp = SW_MOD()->GetModuleConfig()->IsHideFieldTips();
2212 aAny.setValue(&bTemp, ::getBooleanCppuType());
2214 break;
2215 case WID_DOC_REDLINE_DISPLAY:
2217 sal_Int16 eRedMode = pDocShell->GetDoc()->GetRedlineMode();
2218 eRedMode = eRedMode & nsRedlineMode_t::REDLINE_SHOW_MASK;
2219 sal_Int16 nRet = RedlineDisplayType::NONE;
2220 if(nsRedlineMode_t::REDLINE_SHOW_INSERT == eRedMode)
2221 nRet = RedlineDisplayType::INSERTED;
2222 else if(nsRedlineMode_t::REDLINE_SHOW_DELETE == eRedMode)
2223 nRet = RedlineDisplayType::REMOVED;
2224 else if(nsRedlineMode_t::REDLINE_SHOW_MASK == eRedMode)
2225 nRet = RedlineDisplayType::INSERTED_AND_REMOVED;
2226 aAny <<= nRet;
2228 break;
2229 case WID_DOC_FORBIDDEN_CHARS:
2231 GetPropertyHelper();
2232 Reference<XForbiddenCharacters> xRet(xPropertyHelper, UNO_QUERY);
2233 aAny <<= xRet;
2235 break;
2236 case WID_DOC_TWO_DIGIT_YEAR:
2238 aAny <<= static_cast < sal_Int16 > (pDocShell->GetDoc()->GetNumberFormatter ( TRUE )->GetYear2000());
2240 break;
2241 case WID_DOC_AUTOMATIC_CONTROL_FOCUS:
2243 SwDrawDocument * pDrawDoc;
2244 sal_Bool bAuto;
2245 if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetDrawModel() ) ) )
2246 bAuto = pDrawDoc->GetAutoControlFocus();
2247 else
2248 bAuto = sal_False;
2249 aAny.setValue(&bAuto, ::getBooleanCppuType());
2251 break;
2252 case WID_DOC_APPLY_FORM_DESIGN_MODE:
2254 SwDrawDocument * pDrawDoc;
2255 sal_Bool bMode;
2256 if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetDrawModel() ) ) )
2257 bMode = pDrawDoc->GetOpenInDesignMode();
2258 else
2259 bMode = sal_True;
2260 aAny.setValue(&bMode, ::getBooleanCppuType());
2262 break;
2263 case WID_DOC_BASIC_LIBRARIES:
2264 aAny <<= pDocShell->GetBasicContainer();
2265 break;
2266 case WID_DOC_DIALOG_LIBRARIES:
2267 aAny <<= pDocShell->GetDialogContainer();
2268 break;
2269 case WID_DOC_VBA_DOCOBJ:
2271 beans::PropertyValue aProp;
2272 aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ThisWordDoc") );
2273 aProp.Value <<= pDocShell->GetModel();
2274 aAny <<= aProp;
2276 break;
2277 case WID_DOC_RUNTIME_UID:
2278 aAny <<= getRuntimeUID();
2279 break;
2280 case WID_DOC_LOCK_UPDATES :
2281 aAny <<= static_cast<bool>( pDocShell->GetDoc()->IsInReading() );
2282 break;
2283 case WID_DOC_BUILDID:
2284 aAny <<= maBuildId;
2285 break;
2286 case WID_DOC_HAS_VALID_SIGNATURES:
2287 aAny <<= hasValidSignatures();
2288 break;
2289 // --> OD 2006-03-21 #b6375613#
2290 case WID_APPLY_WORKAROUND_FOR_B6375613:
2292 aAny <<= pDocShell->GetDoc()->ApplyWorkaroundForB6375613();
2294 break;
2295 // <--
2297 default:
2299 const SfxPoolItem& rItem = pDocShell->GetDoc()->GetDefault(pEntry->nWID);
2300 rItem.QueryValue(aAny, pEntry->nMemberId);
2303 return aAny;
2305 /*-- 10.05.99 13:58:59---------------------------------------------------
2307 -----------------------------------------------------------------------*/
2308 void SwXTextDocument::addPropertyChangeListener(const OUString& /*PropertyName*/,
2309 const Reference< XPropertyChangeListener > & /*aListener*/)
2310 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
2312 DBG_WARNING("not implemented");
2314 /*-- 10.05.99 13:58:59---------------------------------------------------
2316 -----------------------------------------------------------------------*/
2317 void SwXTextDocument::removePropertyChangeListener(const OUString& /*PropertyName*/,
2318 const Reference< XPropertyChangeListener > & /*aListener*/)
2319 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
2321 DBG_WARNING("not implemented");
2323 /*-- 10.05.99 13:59:00---------------------------------------------------
2325 -----------------------------------------------------------------------*/
2326 void SwXTextDocument::addVetoableChangeListener(const OUString& /*PropertyName*/,
2327 const Reference< XVetoableChangeListener > & /*aListener*/)
2328 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
2330 DBG_WARNING("not implemented");
2332 /*-- 10.05.99 13:59:00---------------------------------------------------
2334 -----------------------------------------------------------------------*/
2335 void SwXTextDocument::removeVetoableChangeListener(const OUString& /*PropertyName*/,
2336 const Reference< XVetoableChangeListener > & /*aListener*/)
2337 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
2339 DBG_WARNING("not implemented");
2341 /* -----------------25.10.99 10:42-------------------
2343 --------------------------------------------------*/
2344 Reference< XNameAccess > SwXTextDocument::getLinks(void) throw( RuntimeException )
2346 if(!pxLinkTargetSupplier)
2348 pxLinkTargetSupplier = new Reference< XNameAccess > ;
2349 (*pxLinkTargetSupplier) = new SwXLinkTargetSupplier(*(SwXTextDocument*)this);
2351 return (*pxLinkTargetSupplier);
2353 /* -----------------------------11.01.01 15:01--------------------------------
2355 ---------------------------------------------------------------------------*/
2356 Reference< XEnumerationAccess > SwXTextDocument::getRedlines( ) throw(RuntimeException)
2358 if(!pxXRedlines)
2360 pxXRedlines = new Reference< XEnumerationAccess > ;
2361 (*pxXRedlines) = new SwXRedlines(pDocShell->GetDoc());
2363 return *pxXRedlines;
2365 /*-- 21.02.00 08:41:06---------------------------------------------------
2367 -----------------------------------------------------------------------*/
2368 void SwXTextDocument::refresh(void) throw( RuntimeException )
2370 ::vos::OGuard aGuard(Application::GetSolarMutex());
2371 if(!IsValid())
2372 throw RuntimeException();
2373 SwWrtShell *pWrtShell = pDocShell->GetWrtShell();
2374 notifyRefreshListeners();
2375 if(pWrtShell)
2376 pWrtShell->CalcLayout();
2378 /*-- 21.02.00 08:41:06---------------------------------------------------
2380 -----------------------------------------------------------------------*/
2381 void SwXTextDocument::addRefreshListener(const Reference< util::XRefreshListener > & l)
2382 throw( RuntimeException )
2384 ::vos::OGuard aGuard(Application::GetSolarMutex());
2385 if ( !IsValid() )
2386 throw RuntimeException();
2387 aRefreshCont.AddListener ( reinterpret_cast < const Reference < lang::XEventListener > &> ( l ));
2389 /*-- 21.02.00 08:41:07---------------------------------------------------
2391 -----------------------------------------------------------------------*/
2392 void SwXTextDocument::removeRefreshListener(const Reference< util::XRefreshListener > & l)
2393 throw( RuntimeException )
2395 ::vos::OGuard aGuard(Application::GetSolarMutex());
2396 if ( !IsValid() || !aRefreshCont.RemoveListener ( reinterpret_cast < const Reference < lang::XEventListener > &> ( l ) ) )
2397 throw RuntimeException();
2399 /* -----------------------------26.02.01 12:22--------------------------------
2401 ---------------------------------------------------------------------------*/
2402 void SwXTextDocument::updateLinks( ) throw(RuntimeException)
2404 ::vos::OGuard aGuard(Application::GetSolarMutex());
2405 if(!IsValid())
2406 throw RuntimeException();
2407 SwDoc* pDoc = pDocShell->GetDoc();
2408 SvxLinkManager& rLnkMan = pDoc->GetLinkManager();
2409 if( rLnkMan.GetLinks().Count() )
2411 UnoActionContext aAction(pDoc);
2412 rLnkMan.UpdateAllLinks( FALSE, FALSE, TRUE );
2415 //XPropertyState
2416 PropertyState SAL_CALL SwXTextDocument::getPropertyState( const OUString& rPropertyName )
2417 throw (UnknownPropertyException, RuntimeException)
2419 ::vos::OGuard aGuard(Application::GetSolarMutex());
2420 PropertyState eRet = PropertyState_DIRECT_VALUE;
2421 if(!IsValid())
2422 throw RuntimeException();
2423 const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap()->getByName( rPropertyName);
2425 if(!pEntry)
2426 throw UnknownPropertyException();
2427 Any aAny;
2428 switch(pEntry->nWID)
2430 case 0:default:break;
2432 return eRet;
2434 Sequence< PropertyState > SAL_CALL SwXTextDocument::getPropertyStates( const Sequence< OUString >& rPropertyNames )
2435 throw (UnknownPropertyException, RuntimeException)
2437 const sal_Int32 nCount = rPropertyNames.getLength();
2438 const OUString * pNames = rPropertyNames.getConstArray();
2439 Sequence < PropertyState > aRet ( nCount );
2440 PropertyState *pState = aRet.getArray();
2442 for ( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++)
2443 pState[nIndex] = getPropertyState( pNames[nIndex] );
2445 return aRet;
2447 void SAL_CALL SwXTextDocument::setPropertyToDefault( const OUString& rPropertyName )
2448 throw (UnknownPropertyException, RuntimeException)
2450 ::vos::OGuard aGuard(Application::GetSolarMutex());
2451 if(!IsValid())
2452 throw RuntimeException();
2453 const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap()->getByName( rPropertyName);
2454 if(!pEntry)
2455 throw UnknownPropertyException();
2456 switch(pEntry->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 SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap()->getByName( rPropertyName);
2468 if(!pEntry)
2469 throw UnknownPropertyException();
2470 Any aAny;
2471 switch(pEntry->nWID)
2473 case 0:default:break;
2475 return aAny;
2477 /*-- 06.01.2004 15:08:34---------------------------------------------------
2478 The class SwViewOptionAdjust_Impl is used to adjust the SwViewOption of
2479 the current ViewShell so that fields are not printed as commands and
2480 hidden text and hidden characters are always invisible.
2481 After printing the view options are restored
2482 -----------------------------------------------------------------------*/
2483 class SwViewOptionAdjust_Impl
2485 bool m_bSwitchOff_IsFldName;
2486 bool m_bSwitchOff_PlaceHolderView;
2487 bool m_bSwitchOff_HiddenChar;
2488 bool m_bSwitchOff_HiddenParagraphs;
2489 bool m_bSwitchOff_IsShowHiddenField;
2491 SwViewOption* m_pViewOption;
2492 SwWrtShell& m_rShell;
2493 public:
2494 SwViewOptionAdjust_Impl(SwWrtShell& rSh);
2495 ~SwViewOptionAdjust_Impl();
2497 /*-- 06.01.2004 15:08:34---------------------------------------------------
2499 -----------------------------------------------------------------------*/
2500 SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl(SwWrtShell& rSh) :
2501 m_pViewOption(0),
2502 m_rShell(rSh)
2504 const SwViewOption* pCurrentViewOptions = m_rShell.GetViewOptions();
2505 m_bSwitchOff_IsFldName = pCurrentViewOptions->IsFldName() && m_rShell.IsAnyFieldInDoc();
2506 bool bApplyViewOptions = m_bSwitchOff_IsFldName;
2507 //switch off painting of placeholder fields
2508 m_bSwitchOff_PlaceHolderView = pCurrentViewOptions->IsShowPlaceHolderFields();
2509 //switch off display of hidden characters if on and hidden characters are in use
2510 m_bSwitchOff_HiddenChar = pCurrentViewOptions->IsShowHiddenChar() && m_rShell.GetDoc()->ContainsHiddenChars();
2511 //switch off display of hidden paragraphs if on and hidden paragraphs are in use
2512 m_bSwitchOff_HiddenParagraphs = pCurrentViewOptions->IsShowHiddenPara();
2513 if(m_bSwitchOff_HiddenParagraphs)
2515 const SwFieldType* pFldType = m_rShell.GetDoc()->GetSysFldType(RES_HIDDENPARAFLD);
2516 if(!pFldType || !pFldType->GetDepends())
2517 m_bSwitchOff_HiddenParagraphs = false;
2519 m_bSwitchOff_IsShowHiddenField = pCurrentViewOptions->IsShowHiddenField();
2520 if(m_bSwitchOff_IsShowHiddenField)
2522 const SwFieldType* pFldType = m_rShell.GetDoc()->GetSysFldType(RES_HIDDENTXTFLD);
2523 if( !pFldType || !pFldType->GetDepends())
2524 m_bSwitchOff_IsShowHiddenField = false;
2527 bApplyViewOptions |= m_bSwitchOff_PlaceHolderView;
2528 bApplyViewOptions |= m_bSwitchOff_HiddenChar;
2529 bApplyViewOptions |= m_bSwitchOff_HiddenParagraphs;
2530 bApplyViewOptions |= m_bSwitchOff_IsShowHiddenField;
2531 if(bApplyViewOptions)
2533 m_pViewOption = new SwViewOption(*m_rShell.GetViewOptions());
2534 if(m_bSwitchOff_IsFldName)
2535 m_pViewOption->SetFldName(FALSE);
2536 if(m_bSwitchOff_PlaceHolderView)
2537 m_pViewOption->SetShowPlaceHolderFields(FALSE);
2538 if(m_bSwitchOff_HiddenChar)
2539 m_pViewOption->SetShowHiddenChar(FALSE);
2540 if(m_bSwitchOff_HiddenParagraphs)
2541 m_pViewOption->SetShowHiddenPara(FALSE);
2542 if(m_bSwitchOff_IsShowHiddenField)
2543 m_pViewOption->SetShowHiddenField(FALSE);
2544 SW_MOD()->ApplyUsrPref(*m_pViewOption, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY );
2547 /*-- 06.01.2004 15:08:34---------------------------------------------------
2549 -----------------------------------------------------------------------*/
2550 SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl()
2552 if(m_pViewOption)
2554 if(m_bSwitchOff_IsFldName)
2555 m_pViewOption->SetFldName(TRUE);
2556 if(m_bSwitchOff_PlaceHolderView)
2557 m_pViewOption->SetShowPlaceHolderFields(TRUE);
2558 if(m_bSwitchOff_HiddenChar)
2559 m_pViewOption->SetShowHiddenChar(TRUE);
2560 if(m_bSwitchOff_HiddenParagraphs)
2561 m_pViewOption->SetShowHiddenPara(TRUE);
2562 if(m_bSwitchOff_IsShowHiddenField)
2563 m_pViewOption->SetShowHiddenField(TRUE);
2564 SW_MOD()->ApplyUsrPref(*m_pViewOption, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY );
2565 delete m_pViewOption;
2568 /* -----------------------------23.08.02 16:00--------------------------------
2570 ---------------------------------------------------------------------------*/
2572 * GetRenderDoc:
2573 * returns the document to be rendered, usually this will be the 'regular'
2574 * document but in case of PDF export of (multi-)selection it will
2575 * be a temporary document that gets created if not already done.
2576 * The rpView variable will be set (if not already done) to the used
2577 * SfxViewShell.
2580 SwDoc * SwXTextDocument::GetRenderDoc( SfxViewShell *&rpView, const uno::Any& rSelection )
2582 SwDoc *pDoc = 0;
2584 uno::Reference< frame::XModel > xModel;
2585 rSelection >>= xModel;
2586 if (xModel == pDocShell->GetModel())
2587 pDoc = pDocShell->GetDoc();
2588 else
2590 // used for PDF export of (multi-)selection
2591 if (rSelection.hasValue()) // is anything selected ?
2593 if (!rpView)
2594 rpView = GuessViewShell();
2595 DBG_ASSERT( rpView, "ViewShell missing" );
2596 // the view shell should be SwView for documents PDF export.
2597 // for the page preview no selection should be possible
2598 // (the export dialog does not allow for this option)
2599 const TypeId aSwViewTypeId = TYPE(SwView);
2600 if (rpView && rpView->IsA(aSwViewTypeId))
2602 SfxObjectShellRef xDocSh(((SwView*)rpView)->GetOrCreateTmpSelectionDoc());
2603 if (xDocSh.Is())
2605 pDoc = ((SwDocShell*)&xDocSh)->GetDoc();
2606 rpView = pDoc->GetDocShell()->GetView();
2609 else {
2610 DBG_ERROR( "unexpected ViewShell" );
2614 return pDoc;
2616 /* -----------------------------23.08.02 16:00--------------------------------
2618 ---------------------------------------------------------------------------*/
2619 sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
2620 const uno::Any& rSelection,
2621 const uno::Sequence< beans::PropertyValue >& /*rxOptions*/ )
2622 throw (IllegalArgumentException, RuntimeException)
2624 ::vos::OGuard aGuard(Application::GetSolarMutex());
2625 if(!IsValid())
2626 throw RuntimeException();
2627 SfxViewShell *pView = 0;
2628 SwDoc *pDoc = GetRenderDoc( pView, rSelection );
2629 if (!pDoc)
2630 throw RuntimeException();
2632 SwDocShell *pRenderDocShell = pDoc->GetDocShell();
2633 // #i38289
2634 if(pDoc->get(IDocumentSettingAccess::BROWSE_MODE))
2636 pRenderDocShell->ToggleBrowserMode(false,NULL);
2639 SwWrtShell *pWrtShell = pRenderDocShell->GetWrtShell();
2641 sal_Int32 nRet = 0;
2642 if( !pWrtShell )
2644 //create a hidden view to be able to export as PDF also in print preview
2645 m_pHiddenViewFrame = SfxViewFrame::CreateViewFrame( *pRenderDocShell, 2, TRUE );
2646 SwView* pSwView = (SwView*) m_pHiddenViewFrame->GetViewShell();
2647 pWrtShell = pSwView->GetWrtShellPtr();
2650 SwViewOptionAdjust_Impl aAdjust(*pWrtShell);
2651 pWrtShell->SetPDFExportOption( sal_True );
2652 // --> FME 2005-05-23 #122919# Force field update before PDF export:
2653 pWrtShell->ViewShell::UpdateFlds(TRUE);
2654 // <--
2655 pWrtShell->CalcLayout();
2656 pWrtShell->SetPDFExportOption( sal_False );
2657 nRet = pDoc->GetPageCount();
2659 return nRet;
2661 /* -----------------------------23.08.02 16:00--------------------------------
2663 ---------------------------------------------------------------------------*/
2664 uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
2665 sal_Int32 nRenderer,
2666 const uno::Any& rSelection,
2667 const uno::Sequence< beans::PropertyValue >& rxOptions )
2668 throw (IllegalArgumentException, RuntimeException)
2670 ::vos::OGuard aGuard(Application::GetSolarMutex());
2671 if(!IsValid())
2672 throw RuntimeException();
2673 SfxViewShell *pView = 0;
2674 SwDoc *pDoc = GetRenderDoc( pView, rSelection );
2675 if (!pDoc)
2676 throw RuntimeException();
2678 // due to #110067# (document page count changes sometimes during
2679 // PDF export/printing) we can not check for the upper bound properly.
2680 // Thus instead of throwing the exception we silently return.
2681 if (!(0 <= nRenderer /* && nRenderer < pDoc->GetPageCount()*/))
2682 throw IllegalArgumentException();
2683 if (nRenderer >= pDoc->GetPageCount())
2684 return uno::Sequence< beans::PropertyValue >();
2686 bool bSkipEmptyPages = false;
2687 for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty )
2689 if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "IsSkipEmptyPages" ) ) )
2690 rxOptions[ nProperty].Value >>= bSkipEmptyPages;
2693 Size aPgSize( pDoc->GetPageSize( sal_uInt16(nRenderer + 1), bSkipEmptyPages ) );
2695 awt::Size aPageSize( TWIP_TO_MM100( aPgSize.Width() ),
2696 TWIP_TO_MM100( aPgSize.Height() ));
2697 uno::Sequence< beans::PropertyValue > aRenderer(1);
2698 PropertyValue &rValue = aRenderer.getArray()[0];
2699 rValue.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) );
2700 rValue.Value <<= aPageSize;
2702 return aRenderer;
2704 /* -----------------------------28.10.02 16:00--------------------------------
2706 ---------------------------------------------------------------------------*/
2707 SfxViewShell * SwXTextDocument::GuessViewShell()
2709 // #130810# SfxViewShell::Current() / SfxViewShell::GetObjectShell()
2710 // must not be used (see comment from MBA)
2712 SfxViewShell *pView = 0;
2713 SwView *pSwView = 0;
2714 SwPagePreView *pSwPagePreView = 0;
2715 SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pDocShell, 0, sal_False );
2716 while (pFrame)
2718 pView = pFrame->GetViewShell();
2719 pSwView = dynamic_cast< SwView * >(pView);
2720 if (pSwView)
2721 break;
2722 if (!pSwPagePreView)
2723 pSwPagePreView = dynamic_cast< SwPagePreView * >(pView);
2724 pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell, 0, sal_False );
2727 return pSwView ? pSwView : dynamic_cast< SwView * >(pSwPagePreView);
2730 /* -----------------------------23.08.02 16:00--------------------------------
2732 ---------------------------------------------------------------------------*/
2733 void SAL_CALL SwXTextDocument::render(
2734 sal_Int32 nRenderer,
2735 const uno::Any& rSelection,
2736 const uno::Sequence< beans::PropertyValue >& rxOptions )
2737 throw (IllegalArgumentException, RuntimeException)
2739 ::vos::OGuard aGuard(Application::GetSolarMutex());
2740 if(!IsValid())
2741 throw RuntimeException();
2742 SfxViewShell *pView = GuessViewShell();
2743 SwDoc *pDoc = GetRenderDoc( pView, rSelection );
2744 if (!pDoc || !pView)
2745 throw RuntimeException();
2747 // due to #110067# (document page count changes sometimes during
2748 // PDF export/printing) we can not check for the upper bound properly.
2749 // Thus instead of throwing the exception we silently return.
2750 if (!(0 <= nRenderer /* && nRenderer < pDoc->GetPageCount()*/))
2751 throw IllegalArgumentException();
2752 if (nRenderer >= pDoc->GetPageCount())
2753 return;
2755 // the view shell should be SwView for documents PDF export
2756 // or SwPagePreView for PDF export of the page preview
2757 //!! (check for SwView first as in GuessViewShell) !!
2758 const TypeId aSwViewTypeId = TYPE(SwView);
2759 ViewShell* pVwSh = pView->IsA(aSwViewTypeId) ?
2760 ((SwView*)pView)->GetWrtShellPtr() :
2761 ((SwPagePreView*)pView)->GetViewShell();
2763 uno::Reference< awt::XDevice > xRenderDevice;
2764 bool bFirstPage = false;
2765 bool bLastPage = false;
2766 rtl::OUString aPages;
2767 bool bSkipEmptyPages = false;
2769 for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty )
2771 if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) )
2772 rxOptions[ nProperty].Value >>= xRenderDevice;
2773 else if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFirstPage" ) ) )
2774 rxOptions[ nProperty].Value >>= bFirstPage;
2775 else if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "IsLastPage" ) ) )
2776 rxOptions[ nProperty].Value >>= bLastPage;
2777 else if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ) )
2778 rxOptions[ nProperty].Value >>= aPages;
2779 else if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "IsSkipEmptyPages" ) ) )
2780 rxOptions[ nProperty].Value >>= bSkipEmptyPages;
2783 OutputDevice* pOut = 0;
2784 if (xRenderDevice.is())
2786 VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice );
2787 pOut = pDevice ? pDevice->GetOutputDevice() : 0;
2790 if(pVwSh && pOut)
2792 SwPrtOptions aOptions( C2U("PDF export") );
2794 const TypeId aSwWebDocShellTypeId = TYPE(SwWebDocShell);
2795 BOOL bWeb = pDocShell->IsA( aSwWebDocShellTypeId );
2796 SwView::MakeOptions( NULL, aOptions, NULL, NULL, bWeb, NULL, NULL );
2798 Range aPageRange( nRenderer+1, nRenderer+1 );
2799 MultiSelection aPage( aPageRange );
2800 aPage.SetTotalRange( Range( 0, RANGE_MAX ) );
2801 aPage.Select( aPageRange );
2802 aOptions.aMulti = aPage;
2804 //! Note: Since for PDF export of (multi-)selection a temporary
2805 //! document is created that contains only the selects parts,
2806 //! and thus that document is to printed in whole the,
2807 //! aOptions.bPrintSelection parameter will be false.
2808 aOptions.bPrintSelection = FALSE;
2810 SwViewOptionAdjust_Impl* pViewOptionAdjust = pView->IsA(aSwViewTypeId) ?
2811 new SwViewOptionAdjust_Impl(*((SwView*)pView)->GetWrtShellPtr()) : 0;
2814 pVwSh->SetPDFExportOption( sal_True );
2816 // --> FME 2004-06-08 #i12836# enhanced pdf export
2818 // First, we have to export hyperlinks, notes, and outline to pdf.
2819 // During this process, additional information required for tagging
2820 // the pdf file are collected, which are evaulated during painting.
2822 SwWrtShell* pWrtShell = pView->IsA(aSwViewTypeId) ?
2823 ((SwView*)pView)->GetWrtShellPtr() :
2826 if ( bFirstPage && pWrtShell )
2828 SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPages, bSkipEmptyPages, sal_False );
2830 // <--
2832 pVwSh->Prt( aOptions, 0, pOut );
2834 // --> FME 2004-10-08 #i35176#
2836 // After printing the last page, we take care for the links coming
2837 // from the EditEngine. The links are generated during the painting
2838 // process, but the destinations are still missing.
2840 if ( bLastPage && pWrtShell )
2842 SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPages, bSkipEmptyPages, sal_True );
2844 // <--
2846 pVwSh->SetPDFExportOption( sal_False );
2847 // #i96167# haggai: delete pViewOptionsAdjust here because it makes use
2848 // of the shell, which might get destroyed in lcl_DisposeView!
2849 delete pViewOptionAdjust;
2851 if( bLastPage && m_pHiddenViewFrame)
2853 lcl_DisposeView( m_pHiddenViewFrame, pDocShell );
2854 m_pHiddenViewFrame = 0;
2858 /* -----------------------------03.10.04 -------------------------------------
2860 ---------------------------------------------------------------------------*/
2861 // xforms::XFormsSupplier
2862 Reference<XNameContainer> SAL_CALL SwXTextDocument::getXForms()
2863 throw( RuntimeException )
2865 if ( !pDocShell )
2866 throw DisposedException( ::rtl::OUString(), static_cast< XTextDocument* >( this ) );
2867 SwDoc* pDoc = pDocShell->GetDoc();
2868 return pDoc->getXForms();
2871 /* -----------------------------25.09.07 -------------------------------------
2873 ---------------------------------------------------------------------------*/
2874 uno::Reference< text::XFlatParagraphIterator > SAL_CALL SwXTextDocument::getFlatParagraphIterator(::sal_Int32 nTextMarkupType, sal_Bool bAutomatic)
2875 throw ( uno::RuntimeException )
2877 return new SwXFlatParagraphIterator( *pDocShell->GetDoc(), nTextMarkupType, bAutomatic );
2879 /*-- 07.05.2009 09:21:12---------------------------------------------------
2881 -----------------------------------------------------------------------*/
2882 uno::Reference< util::XCloneable > SwXTextDocument::createClone( ) throw (uno::RuntimeException)
2884 ::vos::OGuard aGuard(Application::GetSolarMutex());
2885 if(!IsValid())
2886 throw RuntimeException();
2887 //create a new document - hidden - copy the storage and return it
2888 SwDoc* pCopyDoc = pDocShell->GetDoc()->CreateCopy();
2889 SfxObjectShell* pShell = new SwDocShell( pCopyDoc, SFX_CREATE_MODE_STANDARD );
2890 pShell->DoInitNew();
2892 uno::Reference< embed::XStorage > xSourceStorage = getDocumentStorage();
2893 uno::Reference< frame::XModel > xNewModel = pShell->GetModel();
2894 //copy this storage
2895 uno::Reference< document::XStorageBasedDocument > xStorageDoc( xNewModel, uno::UNO_QUERY );
2896 uno::Reference< embed::XStorage > xNewStorage = xStorageDoc->getDocumentStorage();
2897 xSourceStorage->copyToStorage( xNewStorage );
2898 return uno::Reference< util::XCloneable >( xNewModel, UNO_QUERY );
2900 /* -----------------------------20.06.00 09:54--------------------------------
2902 ---------------------------------------------------------------------------*/
2903 void * SAL_CALL SwXTextDocument::operator new( size_t t) throw()
2905 return SwXTextDocumentBaseClass::operator new(t);
2907 /* -----------------------------20.06.00 09:54--------------------------------
2909 ---------------------------------------------------------------------------*/
2910 void SAL_CALL SwXTextDocument::operator delete( void * p) throw()
2912 SwXTextDocumentBaseClass::operator delete(p);
2916 /*---------------------------------------------------
2917 retrieve languages already used in current document
2918 -----------------------------------------------------*/
2919 uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages(
2920 ::sal_Int16 nScriptTypes,
2921 ::sal_Int16 nMaxCount )
2922 throw (lang::IllegalArgumentException, uno::RuntimeException)
2924 ::vos::OGuard aGuard(Application::GetSolarMutex());
2927 // possible canonical values for nScriptTypes
2928 // any bit wise combination is allowed
2929 const sal_Int16 nLatin = 0x001;
2930 const sal_Int16 nAsian = 0x002;
2931 const sal_Int16 nComplex = 0x004;
2933 // script types for which to get the languages
2934 const bool bLatin = 0 != (nScriptTypes & nLatin);
2935 const bool bAsian = 0 != (nScriptTypes & nAsian);
2936 const bool bComplex = 0 != (nScriptTypes & nComplex);
2938 if (nScriptTypes < nLatin || nScriptTypes > (nLatin | nAsian | nComplex))
2939 throw IllegalArgumentException(::rtl::OUString::createFromAscii("nScriptTypes ranges from 1 to 7!"), Reference< XInterface >(), 1);
2940 if (!pDocShell)
2941 throw DisposedException();
2942 SwDoc* pDoc = pDocShell->GetDoc();
2944 // avoid duplicate values
2945 std::set< LanguageType > aAllLangs;
2947 //USER STYLES
2949 const SwCharFmts *pFmts = pDoc->GetCharFmts();
2950 for(USHORT i = 0; i < pFmts->Count(); ++i)
2952 const SwAttrSet &rAttrSet = (*pFmts)[i]->GetAttrSet();
2953 LanguageType nLang = LANGUAGE_DONTKNOW;
2954 if (bLatin)
2956 nLang = rAttrSet.GetLanguage( FALSE ).GetLanguage();
2957 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
2958 aAllLangs.insert( nLang );
2960 if (bAsian)
2962 nLang = rAttrSet.GetCJKLanguage( FALSE ).GetLanguage();
2963 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
2964 aAllLangs.insert( nLang );
2966 if (bComplex)
2968 nLang = rAttrSet.GetCTLLanguage( FALSE ).GetLanguage();
2969 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
2970 aAllLangs.insert( nLang );
2974 const SwTxtFmtColls *pColls = pDoc->GetTxtFmtColls();
2975 for (USHORT i = 0; i < pColls->Count(); ++i)
2977 const SwAttrSet &rAttrSet = (*pColls)[i]->GetAttrSet();
2978 LanguageType nLang = LANGUAGE_DONTKNOW;;
2979 if (bLatin)
2981 nLang = rAttrSet.GetLanguage( FALSE ).GetLanguage();
2982 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
2983 aAllLangs.insert( nLang );
2985 if (bAsian)
2987 nLang = rAttrSet.GetCJKLanguage( FALSE ).GetLanguage();
2988 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
2989 aAllLangs.insert( nLang );
2991 if (bComplex)
2993 nLang = rAttrSet.GetCTLLanguage( FALSE ).GetLanguage();
2994 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
2995 aAllLangs.insert( nLang );
2999 //AUTO STYLES
3000 const IStyleAccess::SwAutoStyleFamily aFam[2] =
3002 IStyleAccess::AUTO_STYLE_CHAR,
3003 IStyleAccess::AUTO_STYLE_PARA
3005 for (sal_uInt16 i = 0; i < 2; ++i)
3007 std::vector< SfxItemSet_Pointer_t > rStyles;
3008 pDoc->GetIStyleAccess().getAllStyles(rStyles, aFam[i]);
3009 while (!rStyles.empty())
3011 SfxItemSet_Pointer_t pStyle = rStyles.back();
3012 rStyles.pop_back();
3013 const SfxItemSet *pSet = dynamic_cast< const SfxItemSet * >(pStyle.get());
3015 LanguageType nLang = LANGUAGE_DONTKNOW;
3016 if (bLatin)
3018 nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_LANGUAGE, FALSE )).GetLanguage();
3019 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3020 aAllLangs.insert( nLang );
3022 if (bAsian)
3024 nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CJK_LANGUAGE, FALSE )).GetLanguage();
3025 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3026 aAllLangs.insert( nLang );
3028 if (bComplex)
3030 nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CTL_LANGUAGE, FALSE )).GetLanguage();
3031 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3032 aAllLangs.insert( nLang );
3037 //get languages from "drawobject"
3038 SwWrtShell *pWrtSh = pDocShell->GetWrtShell();
3039 SdrView *pSdrView = pWrtSh->GetDrawView();
3041 if( pSdrView )
3043 SdrOutliner* pOutliner = pSdrView->GetTextEditOutliner();
3044 if(pOutliner)
3046 EditEngine& rEditEng = (EditEngine&)pOutliner->GetEditEngine();
3047 ULONG nParCount = pOutliner->GetParagraphCount();
3048 for (ULONG nPar=0; nPar<nParCount; nPar++)
3050 //every paragraph
3051 SvUShorts aPortions;
3052 rEditEng.GetPortions( (USHORT)nPar, aPortions );
3054 for ( USHORT nPos = aPortions.Count(); nPos; )
3056 //every position
3057 --nPos;
3058 USHORT nEnd = aPortions.GetObject( nPos );
3059 USHORT nStart = nPos ? aPortions.GetObject( nPos - 1 ) : 0;
3060 ESelection aSelection( (USHORT)nPar, nStart, (USHORT)nPar, nEnd );
3061 SfxItemSet aAttr = rEditEng.GetAttribs( aSelection );
3063 LanguageType nLang = LANGUAGE_DONTKNOW;
3064 if (bLatin)
3066 nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE, FALSE )).GetLanguage();
3067 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3068 aAllLangs.insert( nLang );
3070 if (bAsian)
3072 nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE_CJK, FALSE )).GetLanguage();
3073 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3074 aAllLangs.insert( nLang );
3076 if (bComplex)
3078 nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE_CTL, FALSE )).GetLanguage();
3079 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3080 aAllLangs.insert( nLang );
3086 // less than nMaxCount languages
3087 if (nMaxCount > static_cast< sal_Int16 >( aAllLangs.size() ))
3088 nMaxCount = static_cast< sal_Int16 >( aAllLangs.size() );
3090 // build return value
3091 sal_Int32 nCount = 0;
3092 uno::Sequence< lang::Locale > aLanguages( nMaxCount );
3093 lang::Locale* pLanguage = aLanguages.getArray();
3094 if (nMaxCount > 0)
3096 const SvtLanguageTable aLangTab;
3097 for (std::set< LanguageType >::const_iterator it = aAllLangs.begin(); it != aAllLangs.end(); ++it)
3099 if (nCount >= nMaxCount)
3100 break;
3101 if (LANGUAGE_NONE != *it)
3103 MsLangId::convertLanguageToLocale( *it, pLanguage[nCount] );
3104 pLanguage[nCount].Language = aLangTab.GetString( *it );
3105 nCount += 1;
3110 return aLanguages;
3113 /* -----------------25.10.99 11:06-------------------
3115 --------------------------------------------------*/
3116 SwXLinkTargetSupplier::SwXLinkTargetSupplier(SwXTextDocument& rxDoc) :
3117 pxDoc(&rxDoc)
3119 sTables = String(SW_RES(STR_CONTENT_TYPE_TABLE));
3120 sFrames = String(SW_RES(STR_CONTENT_TYPE_FRAME));
3121 sGraphics = String(SW_RES(STR_CONTENT_TYPE_GRAPHIC));
3122 sOLEs = String(SW_RES(STR_CONTENT_TYPE_OLE));
3123 sSections = String(SW_RES(STR_CONTENT_TYPE_REGION));
3124 sOutlines = String(SW_RES(STR_CONTENT_TYPE_OUTLINE));
3125 sBookmarks = String(SW_RES(STR_CONTENT_TYPE_BOOKMARK));
3127 /* -----------------25.10.99 11:11-------------------
3129 --------------------------------------------------*/
3130 SwXLinkTargetSupplier::~SwXLinkTargetSupplier()
3134 /*-- 25.10.99 11:12:45---------------------------------------------------
3136 -----------------------------------------------------------------------*/
3137 Any SwXLinkTargetSupplier::getByName(const OUString& rName)
3138 throw( NoSuchElementException, WrappedTargetException, RuntimeException )
3140 Any aRet;
3141 if(!pxDoc)
3142 throw RuntimeException();
3143 String sToCompare(rName);
3144 String sSuffix('|');
3145 if(sToCompare == sTables)
3147 sSuffix += UniString::CreateFromAscii(pMarkToTable);
3149 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
3150 pxDoc->getTextTables(), sToCompare, sSuffix );
3151 Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
3152 aRet.setValue(&xRet, ::getCppuType((Reference<XPropertySet>*)0));
3154 else if(sToCompare == sFrames)
3156 sSuffix += UniString::CreateFromAscii(pMarkToFrame);
3157 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
3158 pxDoc->getTextFrames(), sToCompare, sSuffix );
3159 Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
3160 aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
3162 else if(sToCompare == sSections)
3164 sSuffix += UniString::CreateFromAscii(pMarkToRegion);
3165 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
3166 pxDoc->getTextSections(), sToCompare, sSuffix );
3167 Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
3168 aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
3170 /* else if(sToCompare == )
3172 sSuffix += UniString::CreateFromAscii(pMarkToText);
3173 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
3174 pxDoc->, sSuffix );
3175 Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
3176 aRet.setValue(&xRet, ::getCppuType((const XPropertySet*)0));
3178 else if(sToCompare == sGraphics)
3180 sSuffix += UniString::CreateFromAscii(pMarkToGraphic);
3181 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
3182 pxDoc->getGraphicObjects(), sToCompare, sSuffix );
3183 Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
3184 aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
3186 else if(sToCompare == sOLEs)
3188 sSuffix += UniString::CreateFromAscii(pMarkToOLE);
3189 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
3190 pxDoc->getEmbeddedObjects(), sToCompare, sSuffix );
3191 Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
3192 aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
3194 else if(sToCompare == sOutlines)
3196 sSuffix += UniString::CreateFromAscii(pMarkToOutline);
3197 Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
3198 *pxDoc, sToCompare, sSuffix );
3199 Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
3200 aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
3202 else if(sToCompare == sBookmarks)
3204 sSuffix.Erase();
3205 Reference< XNameAccess > xBkms = new SwXLinkNameAccessWrapper(
3206 pxDoc->getBookmarks(), sToCompare, sSuffix );
3207 Reference< XPropertySet > xRet(xBkms, UNO_QUERY);
3208 aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
3210 else
3211 throw NoSuchElementException();
3212 return aRet;
3214 /*-- 25.10.99 11:12:46---------------------------------------------------
3216 -----------------------------------------------------------------------*/
3217 Sequence< OUString > SwXLinkTargetSupplier::getElementNames(void)
3218 throw( RuntimeException )
3220 Sequence< OUString > aRet(7);
3221 OUString* pNames = aRet.getArray();
3222 pNames[0] = sTables;
3223 pNames[1] = sFrames ;
3224 pNames[2] = sGraphics;
3225 pNames[3] = sOLEs ;
3226 pNames[4] = sSections;
3227 pNames[5] = sOutlines;
3228 pNames[6] = sBookmarks;
3229 return aRet;
3231 /*-- 25.10.99 11:12:46---------------------------------------------------
3233 -----------------------------------------------------------------------*/
3234 sal_Bool SwXLinkTargetSupplier::hasByName(const OUString& rName)
3235 throw( RuntimeException )
3237 String sToCompare(rName);
3238 if( sToCompare == sTables ||
3239 sToCompare == sFrames ||
3240 sToCompare == sGraphics||
3241 sToCompare == sOLEs ||
3242 sToCompare == sSections ||
3243 sToCompare == sOutlines ||
3244 sToCompare == sBookmarks )
3245 return sal_True;
3246 return sal_False;
3248 /*-- 25.10.99 11:12:47---------------------------------------------------
3250 -----------------------------------------------------------------------*/
3251 uno::Type SwXLinkTargetSupplier::getElementType(void)
3252 throw( RuntimeException )
3254 return ::getCppuType((Reference< XPropertySet>*)0);
3257 /*-- 25.10.99 11:12:47---------------------------------------------------
3259 -----------------------------------------------------------------------*/
3260 sal_Bool SwXLinkTargetSupplier::hasElements(void) throw( RuntimeException )
3262 return 0 != pxDoc;
3264 /*-- 25.10.99 11:12:47---------------------------------------------------
3266 -----------------------------------------------------------------------*/
3267 OUString SwXLinkTargetSupplier::getImplementationName(void) throw( RuntimeException )
3269 return C2U("SwXLinkTargetSupplier");
3271 /*-- 25.10.99 11:12:48---------------------------------------------------
3273 -----------------------------------------------------------------------*/
3274 sal_Bool SwXLinkTargetSupplier::supportsService(const OUString& rServiceName)
3275 throw( RuntimeException )
3277 return (rServiceName == C2U("com.sun.star.document.LinkTargets"));
3279 /*-- 25.10.99 11:12:48---------------------------------------------------
3281 -----------------------------------------------------------------------*/
3282 Sequence< OUString > SwXLinkTargetSupplier::getSupportedServiceNames(void)
3283 throw( RuntimeException )
3285 Sequence< OUString > aRet(1);
3286 OUString* pNames = aRet.getArray();
3287 pNames[0] = C2U("com.sun.star.document.LinkTargets");
3288 return aRet;
3291 /*-- 26.10.99 09:16:23---------------------------------------------------
3293 -----------------------------------------------------------------------*/
3294 SwXLinkNameAccessWrapper::SwXLinkNameAccessWrapper(
3295 Reference< XNameAccess > xAccess, const String& rLinkDisplayName, String sSuffix ) :
3296 xRealAccess(xAccess),
3297 pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
3298 sLinkSuffix(sSuffix),
3299 sLinkDisplayName(rLinkDisplayName),
3300 pxDoc(0)
3303 /* -----------------26.10.99 14:17-------------------
3305 --------------------------------------------------*/
3306 SwXLinkNameAccessWrapper::SwXLinkNameAccessWrapper(SwXTextDocument& rxDoc,
3307 const String& rLinkDisplayName, String sSuffix) :
3308 pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
3309 sLinkSuffix(sSuffix),
3310 sLinkDisplayName(rLinkDisplayName),
3311 xDoc(&rxDoc),
3312 pxDoc(&rxDoc)
3315 /*-- 26.10.99 09:16:23---------------------------------------------------
3317 -----------------------------------------------------------------------*/
3318 SwXLinkNameAccessWrapper::~SwXLinkNameAccessWrapper()
3321 /*-- 26.10.99 09:16:24---------------------------------------------------
3323 -----------------------------------------------------------------------*/
3324 Any SwXLinkNameAccessWrapper::getByName(const OUString& rName)
3325 throw( NoSuchElementException, WrappedTargetException, RuntimeException )
3327 Any aRet;
3328 sal_Bool bFound = sal_False;
3329 //cut link extension and call the real NameAccess
3330 String sParam = rName;
3331 String sSuffix(sLinkSuffix);
3332 if(sParam.Len() > sSuffix.Len() )
3334 String sCmp = sParam.Copy(sParam.Len() - sSuffix.Len(),
3335 sSuffix.Len());
3336 if(sCmp == sSuffix)
3338 if(pxDoc)
3340 sParam = sParam.Copy(0, sParam.Len() - sSuffix.Len());
3341 if(!pxDoc->GetDocShell())
3342 throw RuntimeException();
3343 SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
3344 sal_uInt16 nOutlineCount = pDoc->GetNodes().GetOutLineNds().Count();
3346 for (sal_uInt16 i = 0; i < nOutlineCount && !bFound; ++i)
3348 const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
3349 const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
3350 if(sParam ==
3351 lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule))
3353 Reference< XPropertySet > xOutline = new SwXOutlineTarget(sParam);
3354 aRet.setValue(&xOutline, ::getCppuType((Reference<XPropertySet>*)0));
3355 bFound = sal_True;
3359 else
3361 aRet = xRealAccess->getByName(sParam.Copy(0, sParam.Len() - sSuffix.Len()));
3362 Reference< XInterface > xInt;
3363 if(!(aRet >>= xInt))
3364 throw RuntimeException();
3365 Reference< XPropertySet > xProp(xInt, UNO_QUERY);
3366 aRet <<= xProp;
3367 bFound = sal_True;
3371 if(!bFound)
3372 throw NoSuchElementException();
3373 return aRet;
3375 /*-- 26.10.99 09:16:24---------------------------------------------------
3377 -----------------------------------------------------------------------*/
3378 Sequence< OUString > SwXLinkNameAccessWrapper::getElementNames(void)
3379 throw( RuntimeException )
3381 Sequence< OUString > aRet;
3382 if(pxDoc)
3384 if(!pxDoc->GetDocShell())
3385 throw RuntimeException();
3387 SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
3388 const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
3389 sal_uInt16 nOutlineCount = rOutlineNodes.Count();
3390 aRet.realloc(nOutlineCount);
3391 OUString* pResArr = aRet.getArray();
3392 String sSuffix('|');
3393 sSuffix += UniString::CreateFromAscii(pMarkToOutline);
3394 const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
3395 for (sal_uInt16 i = 0; i < nOutlineCount; ++i)
3397 String sEntry = lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule);
3398 sEntry += sSuffix;
3399 pResArr[i] = sEntry;
3402 else
3404 Sequence< OUString > aOrg = xRealAccess->getElementNames();
3405 const OUString* pOrgArr = aOrg.getConstArray();
3406 aRet.realloc(aOrg.getLength());
3407 OUString* pResArr = aRet.getArray();
3408 for(long i = 0; i < aOrg.getLength(); i++)
3410 pResArr[i] = pOrgArr[i] + sLinkSuffix;
3413 return aRet;
3415 /*-- 26.10.99 09:16:25---------------------------------------------------
3417 -----------------------------------------------------------------------*/
3418 sal_Bool SwXLinkNameAccessWrapper::hasByName(const OUString& rName)
3419 throw( RuntimeException )
3421 sal_Bool bRet = sal_False;
3422 String sParam(rName);
3423 if(sParam.Len() > sLinkSuffix.Len() )
3425 String sCmp = sParam.Copy(sParam.Len() - sLinkSuffix.Len(),
3426 sLinkSuffix.Len());
3427 if(sCmp == sLinkSuffix)
3429 sParam = sParam.Copy(0, sParam.Len() - sLinkSuffix.Len());
3430 if(pxDoc)
3432 if(!pxDoc->GetDocShell())
3433 throw RuntimeException();
3434 SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
3435 sal_uInt16 nOutlineCount = pDoc->GetNodes().GetOutLineNds().Count();
3437 for (sal_uInt16 i = 0; i < nOutlineCount && !bRet; ++i)
3439 const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
3440 const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
3441 if(sParam ==
3442 lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule))
3444 bRet = sal_True;
3448 else
3450 bRet = xRealAccess->hasByName(sParam);
3454 return bRet;
3456 /*-- 26.10.99 09:16:25---------------------------------------------------
3458 -----------------------------------------------------------------------*/
3459 uno::Type SwXLinkNameAccessWrapper::getElementType(void)
3460 throw( RuntimeException )
3462 return ::getCppuType((Reference<XPropertySet>*)0);
3464 /*-- 26.10.99 09:16:25---------------------------------------------------
3466 -----------------------------------------------------------------------*/
3467 sal_Bool SwXLinkNameAccessWrapper::hasElements(void) throw( RuntimeException )
3469 sal_Bool bRet = sal_False;
3470 if(pxDoc)
3472 DBG_ERROR("not implemented");
3474 else
3476 bRet = xRealAccess->hasElements();
3478 return bRet;
3480 /*-- 26.10.99 09:16:26---------------------------------------------------
3482 -----------------------------------------------------------------------*/
3483 Reference< XPropertySetInfo > SwXLinkNameAccessWrapper::getPropertySetInfo(void)
3484 throw( RuntimeException )
3486 static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
3487 return xRet;
3489 /*-- 26.10.99 09:16:26---------------------------------------------------
3491 -----------------------------------------------------------------------*/
3492 void SwXLinkNameAccessWrapper::setPropertyValue(
3493 const OUString& , const Any& )
3494 throw( UnknownPropertyException,
3495 PropertyVetoException,
3496 IllegalArgumentException,
3497 WrappedTargetException,
3498 RuntimeException)
3500 throw UnknownPropertyException();
3502 /* -----------------------------08.12.99 11:10--------------------------------
3504 ---------------------------------------------------------------------------*/
3505 Any lcl_GetDisplayBitmap(String sLinkSuffix)
3507 Any aRet;
3508 if(sLinkSuffix.Len())
3509 sLinkSuffix.Erase(0, 1);
3510 sal_uInt16 nImgId = USHRT_MAX;
3512 if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToOutline))
3513 nImgId = CONTENT_TYPE_OUTLINE;
3514 else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToTable))
3515 nImgId = CONTENT_TYPE_TABLE;
3516 else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToFrame))
3517 nImgId = CONTENT_TYPE_FRAME;
3518 else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToGraphic))
3519 nImgId = CONTENT_TYPE_GRAPHIC;
3520 // else if(== sLinkSuffix)
3521 // nImgId = CONTENT_TYPE_BOOKMARK;
3522 else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToRegion))
3523 nImgId = CONTENT_TYPE_REGION;
3524 else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToOLE))
3525 nImgId = CONTENT_TYPE_OLE;
3526 else if(!sLinkSuffix.Len())
3527 nImgId = CONTENT_TYPE_BOOKMARK;
3528 if(USHRT_MAX != nImgId)
3530 nImgId += 20000;
3531 BOOL bHighContrast = Application::GetSettings().GetStyleSettings().GetWindowColor().IsDark();
3532 ImageList aEntryImages( SW_RES(bHighContrast ? IMG_NAVI_ENTRYBMPH : IMG_NAVI_ENTRYBMP) );
3533 const Image& rImage = aEntryImages.GetImage( nImgId );
3534 Bitmap aBitmap( rImage.GetBitmapEx().GetBitmap() );
3535 Reference<awt::XBitmap> xBmp = VCLUnoHelper::CreateBitmap( aBitmap );
3536 aRet.setValue( &xBmp, ::getCppuType((Reference<awt::XBitmap>*)0) );
3538 return aRet;
3540 /*-- 26.10.99 09:16:27---------------------------------------------------
3542 -----------------------------------------------------------------------*/
3543 Any SwXLinkNameAccessWrapper::getPropertyValue(const OUString& rPropertyName)
3544 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3546 Any aRet;
3547 if( rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_NAME)))
3549 aRet <<= OUString(sLinkDisplayName);
3551 else if( rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_BITMAP)))
3553 aRet = lcl_GetDisplayBitmap(sLinkSuffix);
3555 else
3556 throw UnknownPropertyException();
3557 return aRet;
3559 /*-- 26.10.99 09:16:27---------------------------------------------------
3561 -----------------------------------------------------------------------*/
3562 void SwXLinkNameAccessWrapper::addPropertyChangeListener(
3563 const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
3564 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3566 /*-- 26.10.99 09:16:28---------------------------------------------------
3568 -----------------------------------------------------------------------*/
3569 void SwXLinkNameAccessWrapper::removePropertyChangeListener(
3570 const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
3571 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3573 /*-- 26.10.99 09:16:28---------------------------------------------------
3575 -----------------------------------------------------------------------*/
3576 void SwXLinkNameAccessWrapper::addVetoableChangeListener(
3577 const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
3578 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3580 /*-- 26.10.99 09:16:29---------------------------------------------------
3582 -----------------------------------------------------------------------*/
3583 void SwXLinkNameAccessWrapper::removeVetoableChangeListener(
3584 const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
3585 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3587 /*-- 26.10.99 09:16:32---------------------------------------------------
3590 -----------------------------------------------------------------------*/
3591 Reference< XNameAccess > SwXLinkNameAccessWrapper::getLinks(void)
3592 throw( RuntimeException )
3594 return (SwXLinkNameAccessWrapper*)this;
3597 /*-- 26.10.99 09:21:48---------------------------------------------------
3599 -----------------------------------------------------------------------*/
3600 OUString SwXLinkNameAccessWrapper::getImplementationName(void) throw( RuntimeException )
3602 return C2U("SwXLinkNameAccessWrapper");
3604 /*-- 26.10.99 09:21:48---------------------------------------------------
3606 -----------------------------------------------------------------------*/
3607 sal_Bool SwXLinkNameAccessWrapper::supportsService(const OUString& rServiceName)
3608 throw( RuntimeException )
3610 return (rServiceName == C2U("com.sun.star.document.LinkTargets"));
3612 /*-- 26.10.99 09:21:48---------------------------------------------------
3614 -----------------------------------------------------------------------*/
3615 Sequence< OUString > SwXLinkNameAccessWrapper::getSupportedServiceNames(void)
3616 throw( RuntimeException )
3618 Sequence< OUString > aRet(1);
3619 OUString* pNames = aRet.getArray();
3620 pNames[0] = C2U("com.sun.star.document.LinkTargets");
3621 return aRet;
3623 /* -----------------26.10.99 15:50-------------------
3625 --------------------------------------------------*/
3626 SwXOutlineTarget::SwXOutlineTarget(const String& rOutlineText) :
3627 pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
3628 sOutlineText(rOutlineText)
3631 /*-- 26.10.99 15:51:45---------------------------------------------------
3633 -----------------------------------------------------------------------*/
3634 SwXOutlineTarget::~SwXOutlineTarget()
3637 /*-- 26.10.99 15:51:46---------------------------------------------------
3639 -----------------------------------------------------------------------*/
3640 Reference< XPropertySetInfo > SwXOutlineTarget::getPropertySetInfo(void) throw( RuntimeException )
3642 static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
3643 return xRet;
3645 /*-- 26.10.99 15:51:46---------------------------------------------------
3647 -----------------------------------------------------------------------*/
3648 void SwXOutlineTarget::setPropertyValue(
3649 const OUString& /*PropertyName*/, const Any& /*aValue*/)
3650 throw( UnknownPropertyException, PropertyVetoException,
3651 IllegalArgumentException, WrappedTargetException, RuntimeException)
3653 throw UnknownPropertyException();
3655 /*-- 26.10.99 15:51:46---------------------------------------------------
3657 -----------------------------------------------------------------------*/
3658 Any SwXOutlineTarget::getPropertyValue(const OUString& rPropertyName)
3659 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3661 Any aRet;
3662 if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_NAME)))
3663 aRet <<= OUString(sOutlineText);
3664 else
3665 throw UnknownPropertyException();
3666 return aRet;
3668 /*-- 26.10.99 15:51:46---------------------------------------------------
3670 -----------------------------------------------------------------------*/
3671 void SwXOutlineTarget::addPropertyChangeListener(
3672 const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
3673 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3676 /*-- 26.10.99 15:51:47---------------------------------------------------
3678 -----------------------------------------------------------------------*/
3679 void SwXOutlineTarget::removePropertyChangeListener(
3680 const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
3681 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3684 /*-- 26.10.99 15:51:47---------------------------------------------------
3686 -----------------------------------------------------------------------*/
3687 void SwXOutlineTarget::addVetoableChangeListener(
3688 const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
3689 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3692 /*-- 26.10.99 15:51:47---------------------------------------------------
3694 -----------------------------------------------------------------------*/
3695 void SwXOutlineTarget::removeVetoableChangeListener(
3696 const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
3697 throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
3700 /* -----------------03.05.99 12:28-------------------
3702 * --------------------------------------------------*/
3703 OUString SwXOutlineTarget::getImplementationName(void) throw( RuntimeException )
3705 return C2U("SwXOutlineTarget");
3707 /* -----------------03.05.99 12:28-------------------
3709 * --------------------------------------------------*/
3710 sal_Bool SwXOutlineTarget::supportsService(const OUString& ServiceName) throw( RuntimeException )
3712 return C2U("com.sun.star.document.LinkTarget") == ServiceName;
3714 /* -----------------03.05.99 12:28-------------------
3716 * --------------------------------------------------*/
3717 Sequence< OUString > SwXOutlineTarget::getSupportedServiceNames(void) throw( RuntimeException )
3719 Sequence < OUString > aRet(1);
3720 OUString* pArray = aRet.getArray();
3721 pArray[0] = C2U("com.sun.star.document.LinkTarget");
3723 return aRet;
3725 /* -----------------------------17.01.01 16:06--------------------------------
3727 ---------------------------------------------------------------------------*/
3728 SwXDocumentPropertyHelper::SwXDocumentPropertyHelper(SwDoc& rDoc) :
3729 SvxUnoForbiddenCharsTable ( rDoc.getForbiddenCharacterTable() )
3730 ,m_pDoc(&rDoc)
3733 /* -----------------------------17.01.01 16:06--------------------------------
3735 ---------------------------------------------------------------------------*/
3736 SwXDocumentPropertyHelper::~SwXDocumentPropertyHelper()
3739 /* -----------------------------17.01.01 16:06--------------------------------
3741 ---------------------------------------------------------------------------*/
3742 Reference<XInterface> SwXDocumentPropertyHelper::GetDrawTable(short nWhich)
3744 Reference<XInterface> xRet;
3745 if(m_pDoc)
3747 switch(nWhich)
3749 // --> OD 2005-08-08 #i52858#
3750 // assure that Draw model is created, if it doesn't exist.
3751 case SW_CREATE_DASH_TABLE :
3752 if(!xDashTable.is())
3753 xDashTable = SvxUnoDashTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
3754 xRet = xDashTable;
3755 break;
3756 case SW_CREATE_GRADIENT_TABLE :
3757 if(!xGradientTable.is())
3758 xGradientTable = SvxUnoGradientTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
3759 xRet = xGradientTable;
3760 break;
3761 case SW_CREATE_HATCH_TABLE :
3762 if(!xHatchTable.is())
3763 xHatchTable = SvxUnoHatchTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
3764 xRet = xHatchTable;
3765 break;
3766 case SW_CREATE_BITMAP_TABLE :
3767 if(!xBitmapTable.is())
3768 xBitmapTable = SvxUnoBitmapTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
3769 xRet = xBitmapTable;
3770 break;
3771 case SW_CREATE_TRANSGRADIENT_TABLE:
3772 if(!xTransGradientTable.is())
3773 xTransGradientTable = SvxUnoTransGradientTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
3774 xRet = xTransGradientTable;
3775 break;
3776 case SW_CREATE_MARKER_TABLE :
3777 if(!xMarkerTable.is())
3778 xMarkerTable = SvxUnoMarkerTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
3779 xRet = xMarkerTable;
3780 break;
3781 // <--
3782 case SW_CREATE_DRAW_DEFAULTS:
3783 if(!xDrawDefaults.is())
3784 xDrawDefaults = (cppu::OWeakObject*)new SwSvxUnoDrawPool(m_pDoc);
3785 xRet = xDrawDefaults;
3786 break;
3787 #ifdef DBG_UTIL
3788 default: DBG_ERROR("which table?");
3789 #endif
3792 return xRet;
3795 void SwXDocumentPropertyHelper::Invalidate()
3797 xDashTable = 0;
3798 xGradientTable = 0;
3799 xHatchTable = 0;
3800 xBitmapTable = 0;
3801 xTransGradientTable = 0;
3802 xMarkerTable = 0;
3803 xDrawDefaults = 0;
3804 m_pDoc = 0;
3805 SvxUnoForbiddenCharsTable::mxForbiddenChars.unbind();
3807 /* -----------------13.08.2003 12:43-----------------
3809 --------------------------------------------------*/
3810 void SwXDocumentPropertyHelper::onChange()
3812 if(m_pDoc)
3813 m_pDoc->SetModified();