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