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