xref: /AOO41X/main/sw/source/ui/uno/unotxvw.cxx (revision 414ea96e738c149cb5488029fbc3e593683c72d1)
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
10cdf0e10cSrcweir  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
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 "viscrs.hxx"
28cdf0e10cSrcweir #include <sfx2/frame.hxx>
29cdf0e10cSrcweir #include <sfx2/printer.hxx>
30cdf0e10cSrcweir #include <cmdid.h>
31cdf0e10cSrcweir #include <hintids.hxx>
32cdf0e10cSrcweir #include <docsh.hxx>
33cdf0e10cSrcweir #include <rubylist.hxx>
34cdf0e10cSrcweir #include <doc.hxx>
35cdf0e10cSrcweir #include <unotxvw.hxx>
36cdf0e10cSrcweir #include <unodispatch.hxx>
37cdf0e10cSrcweir #include <unomap.hxx>
38cdf0e10cSrcweir #include <unostyle.hxx>
39cdf0e10cSrcweir #include <unoprnms.hxx>
40cdf0e10cSrcweir #include <view.hxx>
41cdf0e10cSrcweir #include <viewopt.hxx>
42cdf0e10cSrcweir #include <unomod.hxx>
43cdf0e10cSrcweir #include <unoframe.hxx>
44cdf0e10cSrcweir #include <unocrsr.hxx>
45cdf0e10cSrcweir #include <wrtsh.hxx>
46cdf0e10cSrcweir #include <unotbl.hxx>
47cdf0e10cSrcweir #include <svx/fmshell.hxx>
48cdf0e10cSrcweir #include <svx/svdview.hxx>
49cdf0e10cSrcweir #include <svx/svdpage.hxx>
50cdf0e10cSrcweir #include <svx/svdouno.hxx>
51cdf0e10cSrcweir #include <svx/svdogrp.hxx>
52cdf0e10cSrcweir #include <editeng/pbinitem.hxx>
53cdf0e10cSrcweir #include <pagedesc.hxx>
54cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
55cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
56cdf0e10cSrcweir #include <sfx2/bindings.hxx>
57cdf0e10cSrcweir #include <sfx2/request.hxx>
58cdf0e10cSrcweir #include <frmatr.hxx>
59cdf0e10cSrcweir #include <vos/mutex.hxx>
60cdf0e10cSrcweir #include <IMark.hxx>
61cdf0e10cSrcweir #include <unotxdoc.hxx>
62cdf0e10cSrcweir #include <unodraw.hxx>
63cdf0e10cSrcweir #include <svx/unoshcol.hxx>
64cdf0e10cSrcweir #include <svx/unoshape.hxx>
65cdf0e10cSrcweir #include <svx/svdpagv.hxx>
66cdf0e10cSrcweir #include <swerror.h>
67cdf0e10cSrcweir #include <tools/cachestr.hxx>
68cdf0e10cSrcweir #include <shellio.hxx>
69cdf0e10cSrcweir #include <ndtxt.hxx>
70cdf0e10cSrcweir #include <SwStyleNameMapper.hxx>
71cdf0e10cSrcweir #include <crsskip.hxx>
72cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
73cdf0e10cSrcweir #include <editeng/outliner.hxx>
74cdf0e10cSrcweir #include <editeng/editview.hxx>
75cdf0e10cSrcweir #include <unobookmark.hxx>
76cdf0e10cSrcweir #include <unoparagraph.hxx>
77cdf0e10cSrcweir #include <unocrsrhelper.hxx>
78cdf0e10cSrcweir #include <unotextrange.hxx>
79cdf0e10cSrcweir #include <sfx2/docfile.hxx>
80cdf0e10cSrcweir #include <switerator.hxx>
81cdf0e10cSrcweir #include "swdtflvr.hxx"
82cdf0e10cSrcweir #include <vcl/svapp.hxx>
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 
85cdf0e10cSrcweir using namespace ::com::sun::star;
86cdf0e10cSrcweir using namespace ::com::sun::star::uno;
87cdf0e10cSrcweir using namespace ::com::sun::star::lang;
88cdf0e10cSrcweir using namespace ::com::sun::star::beans;
89cdf0e10cSrcweir using namespace ::com::sun::star::text;
90cdf0e10cSrcweir using namespace ::com::sun::star::view;
91cdf0e10cSrcweir using namespace ::com::sun::star::frame;
92cdf0e10cSrcweir using namespace rtl;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir using ::com::sun::star::util::URL;
95cdf0e10cSrcweir using comphelper::HelperBaseNoState;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir SV_IMPL_PTRARR( SelectionChangeListenerArr, XSelectionChangeListenerPtr );
98cdf0e10cSrcweir 
99cdf0e10cSrcweir /* -----------------22.05.98 12:20-------------------
100cdf0e10cSrcweir  *
101cdf0e10cSrcweir  * --------------------------------------------------*/
lcl_createPamCopy(const SwPaM & rPam)102cdf0e10cSrcweir SwPaM* lcl_createPamCopy(const SwPaM& rPam)
103cdf0e10cSrcweir {
104cdf0e10cSrcweir     SwPaM *const pRet = new SwPaM(*rPam.GetPoint());
105cdf0e10cSrcweir     ::sw::DeepCopyPaM(rPam, *pRet);
106cdf0e10cSrcweir 	return pRet;
107cdf0e10cSrcweir }
108cdf0e10cSrcweir /******************************************************************
109cdf0e10cSrcweir  * SwXTextView
110cdf0e10cSrcweir  ******************************************************************/
111cdf0e10cSrcweir /*-- 17.12.98 09:34:25---------------------------------------------------
112cdf0e10cSrcweir 
113cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SwXTextView(SwView * pSwView)114cdf0e10cSrcweir SwXTextView::SwXTextView(SwView* pSwView) :
115cdf0e10cSrcweir 	SfxBaseController(pSwView),
116cdf0e10cSrcweir     m_pView(pSwView),
117cdf0e10cSrcweir     m_pPropSet( aSwMapProvider.GetPropertySet( PROPERTY_MAP_TEXT_VIEW ) ),
118cdf0e10cSrcweir 	pxViewSettings(0),
119cdf0e10cSrcweir     pxTextViewCursor(0)
120cdf0e10cSrcweir {
121cdf0e10cSrcweir 
122cdf0e10cSrcweir }
123cdf0e10cSrcweir /*-- 17.12.98 09:34:25---------------------------------------------------
124cdf0e10cSrcweir 
125cdf0e10cSrcweir   -----------------------------------------------------------------------*/
~SwXTextView()126cdf0e10cSrcweir SwXTextView::~SwXTextView()
127cdf0e10cSrcweir {
128cdf0e10cSrcweir     Invalidate();
129cdf0e10cSrcweir }
130cdf0e10cSrcweir /* -----------------------------09.03.01 15:47--------------------------------
131cdf0e10cSrcweir 
132cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
Invalidate()133cdf0e10cSrcweir void SwXTextView::Invalidate()
134cdf0e10cSrcweir {
135cdf0e10cSrcweir     if(pxViewSettings)
136cdf0e10cSrcweir 	{
137cdf0e10cSrcweir 	 	HelperBaseNoState *pSettings = static_cast < HelperBaseNoState * > ( pxViewSettings->get() );
138cdf0e10cSrcweir 		static_cast < SwXViewSettings* > ( pSettings )->Invalidate();
139cdf0e10cSrcweir         DELETEZ(pxViewSettings);
140cdf0e10cSrcweir 	}
141cdf0e10cSrcweir 	if(pxTextViewCursor)
142cdf0e10cSrcweir 	{
143cdf0e10cSrcweir         text::XTextViewCursor* pCrsr = pxTextViewCursor->get();
144cdf0e10cSrcweir 		((SwXTextViewCursor*)pCrsr)->Invalidate();
145cdf0e10cSrcweir         DELETEZ(pxTextViewCursor);
146cdf0e10cSrcweir 	}
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	m_refCount++; //prevent second d'tor call
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 	sal_uInt16 nCount = aSelChangedListeners.Count();
151cdf0e10cSrcweir     if(nCount)
152cdf0e10cSrcweir     {
153cdf0e10cSrcweir         uno::Reference< uno::XInterface >  xInt = (cppu::OWeakObject*)(SfxBaseController*)this;
154cdf0e10cSrcweir         lang::EventObject aEvent(xInt);
155cdf0e10cSrcweir         for ( sal_uInt16 i = nCount; i--; )
156cdf0e10cSrcweir         {
157cdf0e10cSrcweir             uno::Reference< view::XSelectionChangeListener >  *pObj = aSelChangedListeners[i];
158cdf0e10cSrcweir             (*pObj)->disposing(aEvent);
159cdf0e10cSrcweir         }
160cdf0e10cSrcweir     }
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	// #i85580: now clean up any possibly remaining entries in the array...
163cdf0e10cSrcweir 	// (i.e. listeners that did not call removeSelectionChangeListener in their disposing.)
164cdf0e10cSrcweir 	while ((nCount = aSelChangedListeners.Count()) != 0)
165cdf0e10cSrcweir 	{
166cdf0e10cSrcweir 		removeSelectionChangeListener( *aSelChangedListeners[0] );
167cdf0e10cSrcweir 	}
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	m_refCount--;
170cdf0e10cSrcweir     m_pView = 0;
171cdf0e10cSrcweir }
172cdf0e10cSrcweir 
173cdf0e10cSrcweir /* -----------------------------18.05.00 10:18--------------------------------
174cdf0e10cSrcweir 
175cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
getTypes()176cdf0e10cSrcweir Sequence< uno::Type > SAL_CALL SwXTextView::getTypes(  ) throw(uno::RuntimeException)
177cdf0e10cSrcweir {
178cdf0e10cSrcweir //	uno::Sequence< uno::Type > aViewTypes = SwXTextViewBaseClass::getTypes();
179cdf0e10cSrcweir 	uno::Sequence< uno::Type > aBaseTypes = SfxBaseController::getTypes();
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 	long nIndex = aBaseTypes.getLength();
182cdf0e10cSrcweir 	aBaseTypes.realloc(
183cdf0e10cSrcweir         aBaseTypes.getLength() + 8 );
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 	uno::Type* pBaseTypes = aBaseTypes.getArray();
186cdf0e10cSrcweir 	pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XSelectionSupplier	>*)0);
187cdf0e10cSrcweir 	pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XServiceInfo			>*)0);
188cdf0e10cSrcweir 	pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XFormLayerAccess   >*)0);
189cdf0e10cSrcweir 	pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XTextViewCursorSupplier>*)0);
190cdf0e10cSrcweir 	pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XViewSettingsSupplier	>*)0);
191cdf0e10cSrcweir 	pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XRubySelection	>*)0);
192cdf0e10cSrcweir     pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XPropertySet  >*)0);
193cdf0e10cSrcweir     pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<datatransfer::XTransferableSupplier >*)0);
194cdf0e10cSrcweir 	return aBaseTypes;
195cdf0e10cSrcweir }
196cdf0e10cSrcweir /* -----------------------------18.05.00 10:18--------------------------------
197cdf0e10cSrcweir 
198cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
getImplementationId()199cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL SwXTextView::getImplementationId(  ) throw(uno::RuntimeException)
200cdf0e10cSrcweir {
201cdf0e10cSrcweir     vos::OGuard aGuard(Application::GetSolarMutex());
202cdf0e10cSrcweir     static Sequence< sal_Int8 > aId( 16 );
203cdf0e10cSrcweir     static sal_Bool bInit = sal_False;
204cdf0e10cSrcweir     if(!bInit)
205cdf0e10cSrcweir     {
206cdf0e10cSrcweir         rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
207cdf0e10cSrcweir         bInit = sal_True;
208cdf0e10cSrcweir     }
209cdf0e10cSrcweir     return aId;
210cdf0e10cSrcweir }
211cdf0e10cSrcweir /* -----------------------------18.05.00 10:18--------------------------------
212cdf0e10cSrcweir 
213cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
acquire()214cdf0e10cSrcweir void SAL_CALL SwXTextView::acquire(  )throw()
215cdf0e10cSrcweir {
216cdf0e10cSrcweir 	SfxBaseController::acquire();
217cdf0e10cSrcweir }
218cdf0e10cSrcweir /* -----------------------------18.05.00 10:18--------------------------------
219cdf0e10cSrcweir 
220cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
release()221cdf0e10cSrcweir void SAL_CALL SwXTextView::release(  )throw()
222cdf0e10cSrcweir {
223cdf0e10cSrcweir 	SfxBaseController::release();
224cdf0e10cSrcweir }
225cdf0e10cSrcweir /* -----------------------------18.05.00 10:23--------------------------------
226cdf0e10cSrcweir 
227cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
queryInterface(const uno::Type & aType)228cdf0e10cSrcweir uno::Any SAL_CALL SwXTextView::queryInterface( const uno::Type& aType )
229cdf0e10cSrcweir 	throw (RuntimeException)
230cdf0e10cSrcweir {
231cdf0e10cSrcweir 	uno::Any aRet;
232cdf0e10cSrcweir 	if(aType == ::getCppuType((uno::Reference<view::XSelectionSupplier	>*)0))
233cdf0e10cSrcweir 	{
234cdf0e10cSrcweir 		uno::Reference<view::XSelectionSupplier> xRet = this;
235cdf0e10cSrcweir 		aRet.setValue(&xRet, aType);
236cdf0e10cSrcweir 	}
237cdf0e10cSrcweir 	else if(aType == ::getCppuType((uno::Reference<lang::XServiceInfo			>*)0))
238cdf0e10cSrcweir 	{
239cdf0e10cSrcweir 		uno::Reference<lang::XServiceInfo> xRet = this;
240cdf0e10cSrcweir 		aRet.setValue(&xRet, aType);
241cdf0e10cSrcweir 	}
242cdf0e10cSrcweir 	else if(aType == ::getCppuType((uno::Reference<view::XControlAccess		>*)0))
243cdf0e10cSrcweir 	{
244cdf0e10cSrcweir 		uno::Reference<view::XControlAccess> xRet = this;
245cdf0e10cSrcweir 		aRet.setValue(&xRet, aType);
246cdf0e10cSrcweir 	}
247cdf0e10cSrcweir     else if(aType == ::getCppuType((uno::Reference<view::XFormLayerAccess   >*)0))
248cdf0e10cSrcweir 	{
249cdf0e10cSrcweir 		uno::Reference<view::XFormLayerAccess> xRet = this;
250cdf0e10cSrcweir 		aRet.setValue(&xRet, aType);
251cdf0e10cSrcweir 	}
252cdf0e10cSrcweir 	else if(aType == ::getCppuType((uno::Reference<text::XTextViewCursorSupplier>*)0))
253cdf0e10cSrcweir 	{
254cdf0e10cSrcweir 		uno::Reference<text::XTextViewCursorSupplier> xRet = this;
255cdf0e10cSrcweir 		aRet.setValue(&xRet, aType);
256cdf0e10cSrcweir 	}
257cdf0e10cSrcweir 	else if(aType == ::getCppuType((uno::Reference<view::XViewSettingsSupplier	>*)0))
258cdf0e10cSrcweir 	{
259cdf0e10cSrcweir 		uno::Reference<view::XViewSettingsSupplier> xRet = this;
260cdf0e10cSrcweir 		aRet.setValue(&xRet, aType);
261cdf0e10cSrcweir 	}
262cdf0e10cSrcweir 	else if(aType == ::getCppuType((uno::Reference<XRubySelection>*)0))
263cdf0e10cSrcweir 	{
264cdf0e10cSrcweir 		uno::Reference<XRubySelection> xRet = this;
265cdf0e10cSrcweir 		aRet.setValue(&xRet, aType);
266cdf0e10cSrcweir 	}
267cdf0e10cSrcweir     else if(aType == ::getCppuType((uno::Reference<XPropertySet>*)0))
268cdf0e10cSrcweir     {
269cdf0e10cSrcweir         uno::Reference<XPropertySet> xRet = this;
270cdf0e10cSrcweir         aRet.setValue(&xRet, aType);
271cdf0e10cSrcweir     }
272cdf0e10cSrcweir     else if(aType == ::getCppuType((uno::Reference<datatransfer::XTransferableSupplier   >*)0))
273cdf0e10cSrcweir 	{
274cdf0e10cSrcweir         uno::Reference<datatransfer::XTransferableSupplier> xRet = this;
275cdf0e10cSrcweir 		aRet.setValue(&xRet, aType);
276cdf0e10cSrcweir 	}
277cdf0e10cSrcweir 	else
278cdf0e10cSrcweir 		aRet = SfxBaseController::queryInterface(aType);
279cdf0e10cSrcweir 	return aRet;
280cdf0e10cSrcweir }
281cdf0e10cSrcweir /*-- 17.12.98 09:34:26---------------------------------------------------
282cdf0e10cSrcweir 
283cdf0e10cSrcweir   -----------------------------------------------------------------------*/
select(const uno::Any & aInterface)284cdf0e10cSrcweir sal_Bool SwXTextView::select(const uno::Any& aInterface) throw( lang::IllegalArgumentException, uno::RuntimeException )
285cdf0e10cSrcweir {
286cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
287cdf0e10cSrcweir     uno::Reference< uno::XInterface >  xInterface;
288cdf0e10cSrcweir     if(GetView() && (aInterface >>= xInterface))
289cdf0e10cSrcweir 	{
290cdf0e10cSrcweir 		SwWrtShell& rSh = GetView()->GetWrtShell();
291cdf0e10cSrcweir 		SwDoc* pDoc = GetView()->GetDocShell()->GetDoc();
292cdf0e10cSrcweir 		uno::Reference< lang::XUnoTunnel >  xIfcTunnel(xInterface, uno::UNO_QUERY);
293cdf0e10cSrcweir 		uno::Reference< text::XTextCursor >  xCrsr(xInterface, uno::UNO_QUERY);
294cdf0e10cSrcweir 		uno::Reference< container::XIndexAccess > 	xPosN(xInterface, uno::UNO_QUERY);
295cdf0e10cSrcweir 		uno::Reference< text::XTextRange > 	xPos(xInterface, uno::UNO_QUERY);
296cdf0e10cSrcweir         SwXFrame* pFrame = xIfcTunnel.is() ? reinterpret_cast<SwXFrame*>(
297cdf0e10cSrcweir             xIfcTunnel->getSomething(SwXFrame::getUnoTunnelId())) : 0;
298cdf0e10cSrcweir 
299cdf0e10cSrcweir         SwXCell* pCell = xIfcTunnel.is() ? reinterpret_cast<SwXCell*>(
300cdf0e10cSrcweir             xIfcTunnel->getSomething(SwXCell::getUnoTunnelId())) : 0;
301cdf0e10cSrcweir 
302cdf0e10cSrcweir 		SwPaM * pPam = 0;
303cdf0e10cSrcweir 		SwXTextRanges* pPosN = 0;
304cdf0e10cSrcweir 		if(xCrsr.is())
305cdf0e10cSrcweir 		{
306cdf0e10cSrcweir 			//
307cdf0e10cSrcweir 			OTextCursorHelper* pCursor =
308cdf0e10cSrcweir 				xIfcTunnel.is() ?
309cdf0e10cSrcweir                     reinterpret_cast<OTextCursorHelper*>(xIfcTunnel->getSomething(OTextCursorHelper::getUnoTunnelId()))
310cdf0e10cSrcweir 					: 0;
311cdf0e10cSrcweir 
312cdf0e10cSrcweir 			if(pCursor && pCursor->GetDoc() == GetView()->GetDocShell()->GetDoc())
313cdf0e10cSrcweir             {
314cdf0e10cSrcweir                 pPam = lcl_createPamCopy(*pCursor->GetPaM());
315cdf0e10cSrcweir             }
316cdf0e10cSrcweir 		}
317cdf0e10cSrcweir 		else if(xPosN.is() &&
318cdf0e10cSrcweir 			xIfcTunnel.is() &&
319cdf0e10cSrcweir                 0 != (pPosN = reinterpret_cast<SwXTextRanges*>(xIfcTunnel->getSomething(SwXTextRanges::getUnoTunnelId()))))
320cdf0e10cSrcweir 		{
321cdf0e10cSrcweir 			const SwUnoCrsr* pUnoCrsr = pPosN->GetCursor();
322cdf0e10cSrcweir 			if(pUnoCrsr)
323cdf0e10cSrcweir 			{
324cdf0e10cSrcweir 				pPam = lcl_createPamCopy(*pUnoCrsr);
325cdf0e10cSrcweir 			}
326cdf0e10cSrcweir 		}
327cdf0e10cSrcweir 		// prevent misinterpretation of text frames that provide a XTextRange interface, too
328cdf0e10cSrcweir 		else if(!pFrame && !pCell && xPos.is())
329cdf0e10cSrcweir 		{
330cdf0e10cSrcweir 			SwUnoInternalPaM aPam(*pDoc);
331cdf0e10cSrcweir             if (::sw::XTextRangeToSwPaM(aPam, xPos))
332cdf0e10cSrcweir 			{
333cdf0e10cSrcweir 				pPam = lcl_createPamCopy(aPam);
334cdf0e10cSrcweir 			}
335cdf0e10cSrcweir 		}
336cdf0e10cSrcweir 		if(pPam)
337cdf0e10cSrcweir 		{
338cdf0e10cSrcweir 			rSh.EnterStdMode();
339cdf0e10cSrcweir 			rSh.SetSelection(*pPam);
340cdf0e10cSrcweir             while( pPam->GetNext() != pPam )
341cdf0e10cSrcweir                 delete pPam->GetNext();
342cdf0e10cSrcweir             delete pPam;
343cdf0e10cSrcweir 			return sal_True;
344cdf0e10cSrcweir 		}
345cdf0e10cSrcweir 		if(pFrame)
346cdf0e10cSrcweir 		{
347cdf0e10cSrcweir 
348cdf0e10cSrcweir 			SwFrmFmt* pFrmFmt = pFrame->GetFrmFmt();
349cdf0e10cSrcweir 			if(pFrmFmt && pFrmFmt->GetDoc() == pDoc)
350cdf0e10cSrcweir 			{
351cdf0e10cSrcweir 				sal_Bool bSuccess = rSh.GotoFly( pFrmFmt->GetName(), pFrame->GetFlyCntType());
352cdf0e10cSrcweir 				if (bSuccess)
353cdf0e10cSrcweir 				{
354cdf0e10cSrcweir 					rSh.HideCrsr();
355cdf0e10cSrcweir 					rSh.EnterSelFrmMode();
356cdf0e10cSrcweir 				}
357cdf0e10cSrcweir 				return sal_True;
358cdf0e10cSrcweir 			}
359cdf0e10cSrcweir 		}
360cdf0e10cSrcweir 
361cdf0e10cSrcweir 		uno::Reference< text::XTextTable >  xTbl(xInterface, uno::UNO_QUERY);;
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 		if(xTbl.is() && xIfcTunnel.is())
364cdf0e10cSrcweir 		{
365cdf0e10cSrcweir             SwXTextTable* pTable = reinterpret_cast<SwXTextTable*>(
366cdf0e10cSrcweir                 xIfcTunnel->getSomething(SwXTextTable::getUnoTunnelId()));
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 			SwFrmFmt* pTblFrmFmt = pTable ? ((SwXTextTable*)pTable)->GetFrmFmt() : 0;
369cdf0e10cSrcweir 			if(pTblFrmFmt &&pTblFrmFmt->GetDoc() == pDoc)
370cdf0e10cSrcweir 			{
371cdf0e10cSrcweir 				rSh.EnterStdMode();
372cdf0e10cSrcweir 				rSh.GotoTable(pTblFrmFmt->GetName());
373cdf0e10cSrcweir 			}
374cdf0e10cSrcweir 			return sal_True;
375cdf0e10cSrcweir 		}
376cdf0e10cSrcweir 
377cdf0e10cSrcweir         if(pCell)
378cdf0e10cSrcweir         {
379cdf0e10cSrcweir             SwFrmFmt* pTblFrmFmt = pCell->GetFrmFmt();
380cdf0e10cSrcweir             if(pTblFrmFmt && pTblFrmFmt->GetDoc() == pDoc)
381cdf0e10cSrcweir             {
382cdf0e10cSrcweir                 SwTableBox* pBox = pCell->GetTblBox();
383cdf0e10cSrcweir                 SwTable* pTable = SwTable::FindTable( pTblFrmFmt );
384cdf0e10cSrcweir                 pBox = pCell->FindBox(pTable, pBox);
385cdf0e10cSrcweir                 if(pBox)
386cdf0e10cSrcweir                 {
387cdf0e10cSrcweir                     const SwStartNode* pSttNd = pBox->GetSttNd();
388cdf0e10cSrcweir                     SwPosition aPos(*pSttNd);
389cdf0e10cSrcweir                     SwPaM aPam(aPos);
390cdf0e10cSrcweir                     aPam.Move(fnMoveForward, fnGoNode);
391cdf0e10cSrcweir                     rSh.EnterStdMode();
392cdf0e10cSrcweir                     rSh.SetSelection(aPam);
393cdf0e10cSrcweir                     return sal_True;
394cdf0e10cSrcweir                 }
395cdf0e10cSrcweir             }
396cdf0e10cSrcweir         }
397cdf0e10cSrcweir         SwXCellRange* pRange = xIfcTunnel.is() ? reinterpret_cast<SwXCellRange*>(
398cdf0e10cSrcweir             xIfcTunnel->getSomething(SwXCellRange::getUnoTunnelId())) : 0;
399cdf0e10cSrcweir         if(pRange)
400cdf0e10cSrcweir         {
401cdf0e10cSrcweir            const SwUnoCrsr* pUnoCrsr = pRange->GetTblCrsr();
402cdf0e10cSrcweir            if(pUnoCrsr)
403cdf0e10cSrcweir            {
404cdf0e10cSrcweir                 UnoActionRemoveContext aContext(pDoc);
405cdf0e10cSrcweir                 rSh.EnterStdMode();
406cdf0e10cSrcweir                 rSh.SetSelection(*pUnoCrsr);
407cdf0e10cSrcweir 				return sal_True;
408cdf0e10cSrcweir            }
409cdf0e10cSrcweir         }
410cdf0e10cSrcweir 		uno::Reference< text::XTextContent >  xBkm(xInterface, uno::UNO_QUERY);;
411cdf0e10cSrcweir 
412cdf0e10cSrcweir 		if(xBkm.is() && xIfcTunnel.is())
413cdf0e10cSrcweir         {
414cdf0e10cSrcweir             ::sw::mark::IMark const*const pMark(
415cdf0e10cSrcweir                     SwXBookmark::GetBookmarkInDoc(pDoc, xIfcTunnel) );
416cdf0e10cSrcweir             if (pMark)
417cdf0e10cSrcweir             {
418cdf0e10cSrcweir                 rSh.EnterStdMode();
419cdf0e10cSrcweir                 rSh.GotoMark(pMark);
420cdf0e10cSrcweir                 return sal_True;
421cdf0e10cSrcweir             }
422cdf0e10cSrcweir         }
423cdf0e10cSrcweir         // IndexMark, Index, TextField, Draw, Section, Footnote, Paragraph
424cdf0e10cSrcweir 		//
425cdf0e10cSrcweir 
426cdf0e10cSrcweir         // detect controls
427cdf0e10cSrcweir 
428cdf0e10cSrcweir         uno::Reference< awt::XControlModel > xCtrlModel(xInterface, UNO_QUERY);
429cdf0e10cSrcweir         if(xCtrlModel.is())
430cdf0e10cSrcweir         {
431cdf0e10cSrcweir             uno::Reference<awt::XControl> XControl;
432cdf0e10cSrcweir             SdrObject* pObj = GetControl(xCtrlModel, XControl);
433cdf0e10cSrcweir             if(pObj)
434cdf0e10cSrcweir             {
435cdf0e10cSrcweir                 SdrView* pDrawView = rSh.GetDrawView();
436cdf0e10cSrcweir                 SdrPageView* pPV = pDrawView->GetSdrPageView();
437cdf0e10cSrcweir                 if ( pPV && pObj->GetPage() == pPV->GetPage() )
438cdf0e10cSrcweir 				{
439cdf0e10cSrcweir 					pDrawView->SdrEndTextEdit();
440cdf0e10cSrcweir 					pDrawView->UnmarkAll();
441cdf0e10cSrcweir                     pDrawView->MarkObj( pObj, pPV );
442cdf0e10cSrcweir 				}
443cdf0e10cSrcweir                 return sal_True;
444cdf0e10cSrcweir             }
445cdf0e10cSrcweir         }
446cdf0e10cSrcweir 
447cdf0e10cSrcweir 		uno::Reference< drawing::XShapes >  xShapeColl( xInterface, uno::UNO_QUERY );
448cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet >  xTmpProp(xInterface, uno::UNO_QUERY);
449cdf0e10cSrcweir 		SwXShape* pSwXShape = 0;
450cdf0e10cSrcweir 		if(xIfcTunnel.is())
451cdf0e10cSrcweir             pSwXShape = reinterpret_cast<SwXShape*>(xIfcTunnel->getSomething(SwXShape::getUnoTunnelId()));
452cdf0e10cSrcweir 		SvxShape* pSvxShape = 0;
453cdf0e10cSrcweir 		if(pSwXShape)
454cdf0e10cSrcweir 		{
455cdf0e10cSrcweir 			uno::Reference< uno::XAggregation > 	xAgg = pSwXShape->GetAggregationInterface();
456cdf0e10cSrcweir 			if(xAgg.is())
457cdf0e10cSrcweir 			{
458cdf0e10cSrcweir                 pSvxShape = reinterpret_cast<SvxShape*>(xIfcTunnel->getSomething(SvxShape::getUnoTunnelId()));
459cdf0e10cSrcweir 			}
460cdf0e10cSrcweir 		}
461cdf0e10cSrcweir 
462cdf0e10cSrcweir 		if ( pSvxShape || xShapeColl.is() )			// Drawing drawing::Layer
463cdf0e10cSrcweir 		{
464cdf0e10cSrcweir 			SdrView* pDrawView = rSh.GetDrawView();
465cdf0e10cSrcweir 			if (pDrawView)
466cdf0e10cSrcweir 			{
467cdf0e10cSrcweir 				pDrawView->SdrEndTextEdit();
468cdf0e10cSrcweir 				pDrawView->UnmarkAll();
469cdf0e10cSrcweir 
470cdf0e10cSrcweir 				if (pSvxShape)		// einzelnes Shape
471cdf0e10cSrcweir 				{
472cdf0e10cSrcweir 					SdrObject *pObj = pSvxShape->GetSdrObject();
473cdf0e10cSrcweir 					if (pObj)
474cdf0e10cSrcweir 					{
475cdf0e10cSrcweir //                      lcl_ShowObject( *m_pViewSh, *pDrawView, pObj );
476cdf0e10cSrcweir 						SdrPageView* pPV = pDrawView->GetSdrPageView();
477cdf0e10cSrcweir 						if ( pPV && pObj->GetPage() == pPV->GetPage() )
478cdf0e10cSrcweir 						{
479cdf0e10cSrcweir 							pDrawView->MarkObj( pObj, pPV );
480cdf0e10cSrcweir                             return sal_True;
481cdf0e10cSrcweir 						}
482cdf0e10cSrcweir 					}
483cdf0e10cSrcweir 				}
484cdf0e10cSrcweir 				else	// Shape Collection
485cdf0e10cSrcweir 				{
486cdf0e10cSrcweir                     sal_Bool bSelected = sal_False;
487cdf0e10cSrcweir 					SdrPageView* pPV = NULL;
488cdf0e10cSrcweir 					long nCount = xShapeColl->getCount();
489cdf0e10cSrcweir 					for ( long i = 0; i < nCount; i++ )
490cdf0e10cSrcweir 					{
491cdf0e10cSrcweir 						uno::Reference< drawing::XShape >  xShapeInt;
492cdf0e10cSrcweir 						uno::Any aAny = xShapeColl->getByIndex(i);
493cdf0e10cSrcweir                         aAny >>= xShapeInt;
494cdf0e10cSrcweir 						if (xShapeInt.is())
495cdf0e10cSrcweir 						{
496cdf0e10cSrcweir 							uno::Reference< lang::XUnoTunnel> xShapeTunnel(xShapeInt, uno::UNO_QUERY);
497cdf0e10cSrcweir 
498cdf0e10cSrcweir 							SvxShape* pShape = xShapeTunnel.is() ?
499cdf0e10cSrcweir                                 reinterpret_cast<SvxShape*>(xShapeTunnel->getSomething(SvxShape::getUnoTunnelId())) : 0;
500cdf0e10cSrcweir 
501cdf0e10cSrcweir 							if (pShape)
502cdf0e10cSrcweir 							{
503cdf0e10cSrcweir 								SdrObject *pObj = pShape->GetSdrObject();
504cdf0e10cSrcweir 								if (pObj)
505cdf0e10cSrcweir 								{
506cdf0e10cSrcweir 									if (!pPV)				// erstes Objekt
507cdf0e10cSrcweir 									{
508cdf0e10cSrcweir //                                      lcl_ShowObject( *m_pViewSh, *pDrawView, pObj );
509cdf0e10cSrcweir 										pPV = pDrawView->GetSdrPageView();
510cdf0e10cSrcweir 									}
511cdf0e10cSrcweir 									if ( pPV && pObj->GetPage() == pPV->GetPage() )
512cdf0e10cSrcweir 									{
513cdf0e10cSrcweir 										pDrawView->MarkObj( pObj, pPV );
514cdf0e10cSrcweir                                         bSelected = sal_True;
515cdf0e10cSrcweir 									}
516cdf0e10cSrcweir 								}
517cdf0e10cSrcweir 							}
518cdf0e10cSrcweir 						}
519cdf0e10cSrcweir 					}
520cdf0e10cSrcweir                     return bSelected;
521cdf0e10cSrcweir 				}
522cdf0e10cSrcweir 			}
523cdf0e10cSrcweir 		}
524cdf0e10cSrcweir 	}
525cdf0e10cSrcweir 	return sal_False;
526cdf0e10cSrcweir 
527cdf0e10cSrcweir }
528cdf0e10cSrcweir /*-- 17.12.98 09:34:26---------------------------------------------------
529cdf0e10cSrcweir 
530cdf0e10cSrcweir   -----------------------------------------------------------------------*/
getSelection(void)531cdf0e10cSrcweir uno::Any SwXTextView::getSelection(void) throw( uno::RuntimeException )
532cdf0e10cSrcweir {
533cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
534cdf0e10cSrcweir 	uno::Reference< uno::XInterface >  aRef;
535cdf0e10cSrcweir     if(GetView())
536cdf0e10cSrcweir 	{
537cdf0e10cSrcweir 		//force immediat shell update
538cdf0e10cSrcweir         m_pView->StopShellTimer();
539cdf0e10cSrcweir 		// ein interface aus der aktuellen Selektion erzeugen
540cdf0e10cSrcweir         SwWrtShell& rSh = m_pView->GetWrtShell();
541cdf0e10cSrcweir         ShellModes  eSelMode = m_pView->GetShellMode();
542cdf0e10cSrcweir 		switch(eSelMode)
543cdf0e10cSrcweir 		{
544cdf0e10cSrcweir 			case SHELL_MODE_TABLE_TEXT      :
545cdf0e10cSrcweir 			{
546cdf0e10cSrcweir 				if(rSh.GetTableCrsr())
547cdf0e10cSrcweir 				{
548cdf0e10cSrcweir 					DBG_ASSERT(rSh.GetTableFmt(), "kein Tabellenformat?");
549cdf0e10cSrcweir 					uno::Reference< text::XTextTableCursor >  xCrsr = new SwXTextTableCursor(*rSh.GetTableFmt(),
550cdf0e10cSrcweir 													rSh.GetTableCrsr());
551cdf0e10cSrcweir 					aRef = uno::Reference< uno::XInterface >  (xCrsr, uno::UNO_QUERY);;
552cdf0e10cSrcweir 					break;
553cdf0e10cSrcweir 				}
554cdf0e10cSrcweir 
555cdf0e10cSrcweir 			}
556cdf0e10cSrcweir 			// ohne Tabellenselektion wird der Text geliefert
557cdf0e10cSrcweir 			//break;
558cdf0e10cSrcweir 			case SHELL_MODE_LIST_TEXT       :
559cdf0e10cSrcweir 			case SHELL_MODE_TABLE_LIST_TEXT:
560cdf0e10cSrcweir 			case SHELL_MODE_TEXT            :
561cdf0e10cSrcweir 			{
562cdf0e10cSrcweir 				uno::Reference< container::XIndexAccess >  xPos = new SwXTextRanges(rSh.GetCrsr());
563cdf0e10cSrcweir 				aRef = uno::Reference< uno::XInterface >(xPos, uno::UNO_QUERY);
564cdf0e10cSrcweir 			}
565cdf0e10cSrcweir 			break;
566cdf0e10cSrcweir 			case SHELL_MODE_FRAME           :
567cdf0e10cSrcweir 			case SHELL_MODE_GRAPHIC         :
568cdf0e10cSrcweir 			case SHELL_MODE_OBJECT          :
569cdf0e10cSrcweir 			{
570cdf0e10cSrcweir 				//Get FlyFrameFormat; fuer UI Macro Anbindung an Flys
571cdf0e10cSrcweir 				const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt();
572cdf0e10cSrcweir 				if (pFmt)
573cdf0e10cSrcweir 				{
574cdf0e10cSrcweir 					SwXFrame* pxFrame = SwIterator<SwXFrame,SwFmt>::FirstElement(*pFmt);
575cdf0e10cSrcweir 					if(pxFrame)				   //das einzige gemeinsame interface fuer alle Frames
576cdf0e10cSrcweir 					{
577cdf0e10cSrcweir 						aRef = uno::Reference< uno::XInterface >((cppu::OWeakObject*)pxFrame, uno::UNO_QUERY);
578cdf0e10cSrcweir 					}
579cdf0e10cSrcweir 					else
580cdf0e10cSrcweir 					{
581cdf0e10cSrcweir 						if(SHELL_MODE_FRAME == eSelMode)
582cdf0e10cSrcweir 						{
583cdf0e10cSrcweir 							uno::Reference< text::XTextFrame >  xFrm =  new SwXTextFrame((SwFrmFmt&)*pFmt);
584cdf0e10cSrcweir 							aRef = uno::Reference< uno::XInterface >(xFrm, uno::UNO_QUERY);
585cdf0e10cSrcweir 						}
586cdf0e10cSrcweir 						else if(SHELL_MODE_GRAPHIC == eSelMode)
587cdf0e10cSrcweir 						{
588cdf0e10cSrcweir 							uno::Reference< text::XTextContent >  xFrm = new SwXTextGraphicObject((SwFrmFmt&)*pFmt);
589cdf0e10cSrcweir 							aRef = xFrm;
590cdf0e10cSrcweir 						}
591cdf0e10cSrcweir 						else
592cdf0e10cSrcweir 						{
593cdf0e10cSrcweir 							uno::Reference< text::XTextContent >  xFrm =  new SwXTextEmbeddedObject((SwFrmFmt&)*pFmt);
594cdf0e10cSrcweir 							aRef = xFrm;
595cdf0e10cSrcweir 						}
596cdf0e10cSrcweir 					}
597cdf0e10cSrcweir 				}
598cdf0e10cSrcweir 			}
599cdf0e10cSrcweir 			break;
600cdf0e10cSrcweir 			case SHELL_MODE_DRAW            :
601cdf0e10cSrcweir 			case SHELL_MODE_DRAW_CTRL       :
602cdf0e10cSrcweir 			case SHELL_MODE_DRAW_FORM       :
603cdf0e10cSrcweir 			case SHELL_MODE_DRAWTEXT        :
604cdf0e10cSrcweir 			case SHELL_MODE_BEZIER          :
605cdf0e10cSrcweir 			{
606cdf0e10cSrcweir 				uno::Reference< drawing::XDrawPageSupplier >  xPageSupp;
607cdf0e10cSrcweir                 uno::Reference< frame::XModel > xModel = m_pView->GetDocShell()->GetBaseModel();
608cdf0e10cSrcweir 				uno::Reference< lang::XUnoTunnel > xModelTunnel(xModel, uno::UNO_QUERY);
609cdf0e10cSrcweir                 SwXTextDocument* pTextDoc = reinterpret_cast<SwXTextDocument*>(xModelTunnel->
610cdf0e10cSrcweir                                 getSomething(SwXTextDocument::getUnoTunnelId()));
611cdf0e10cSrcweir 
612cdf0e10cSrcweir 				SwFmDrawPage* pSvxDrawPage = 	pTextDoc->GetDrawPage()->GetSvxPage();
613cdf0e10cSrcweir 				uno::Reference< drawing::XShapes >  xShCol = new SvxShapeCollection();
614cdf0e10cSrcweir 
615cdf0e10cSrcweir 				const SdrMarkList& rMarkList = rSh.GetDrawView()->GetMarkedObjectList();
616cdf0e10cSrcweir 				for(sal_uInt16 i = 0; i < rMarkList.GetMarkCount(); i++)
617cdf0e10cSrcweir 				{
618cdf0e10cSrcweir 					SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
619cdf0e10cSrcweir 					uno::Reference< uno::XInterface >  xInt = pSvxDrawPage->GetInterface( pObj );
620cdf0e10cSrcweir 					uno::Reference< drawing::XShape >  xShape(xInt, uno::UNO_QUERY);;
621cdf0e10cSrcweir 					xShCol->add(xShape);
622cdf0e10cSrcweir 				}
623cdf0e10cSrcweir 				aRef = uno::Reference< uno::XInterface >(xShCol, uno::UNO_QUERY);
624cdf0e10cSrcweir 			}
625cdf0e10cSrcweir 			break;
626cdf0e10cSrcweir             default:;//prevent warning
627cdf0e10cSrcweir 		}
628cdf0e10cSrcweir 	}
629cdf0e10cSrcweir 	uno::Any aRet(&aRef, ::getCppuType((uno::Reference<uno::XInterface>*)0));
630cdf0e10cSrcweir 	return aRet;
631cdf0e10cSrcweir }
632cdf0e10cSrcweir /*-- 17.12.98 09:34:27---------------------------------------------------
633cdf0e10cSrcweir 
634cdf0e10cSrcweir   -----------------------------------------------------------------------*/
addSelectionChangeListener(const uno::Reference<view::XSelectionChangeListener> & rxListener)635cdf0e10cSrcweir void SwXTextView::addSelectionChangeListener(
636cdf0e10cSrcweir 									const uno::Reference< view::XSelectionChangeListener > & rxListener)
637cdf0e10cSrcweir 									throw( uno::RuntimeException )
638cdf0e10cSrcweir {
639cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
640cdf0e10cSrcweir 	uno::Reference< view::XSelectionChangeListener > * pInsert = new uno::Reference< view::XSelectionChangeListener > ;
641cdf0e10cSrcweir 	*pInsert = rxListener;
642cdf0e10cSrcweir 	aSelChangedListeners.Insert(pInsert, aSelChangedListeners.Count());
643cdf0e10cSrcweir }
644cdf0e10cSrcweir /*-- 17.12.98 09:34:27---------------------------------------------------
645cdf0e10cSrcweir 
646cdf0e10cSrcweir   -----------------------------------------------------------------------*/
removeSelectionChangeListener(const uno::Reference<view::XSelectionChangeListener> & rxListener)647cdf0e10cSrcweir void SwXTextView::removeSelectionChangeListener(
648cdf0e10cSrcweir 										const uno::Reference< view::XSelectionChangeListener > & rxListener)
649cdf0e10cSrcweir 										throw( uno::RuntimeException )
650cdf0e10cSrcweir {
651cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
652cdf0e10cSrcweir 	view::XSelectionChangeListener* pLeft = rxListener.get();
653cdf0e10cSrcweir 	for(sal_uInt16 i = 0; i < aSelChangedListeners.Count(); i++)
654cdf0e10cSrcweir 	{
655cdf0e10cSrcweir 		uno::Reference< view::XSelectionChangeListener > * pElem = aSelChangedListeners.GetObject(i);
656cdf0e10cSrcweir 	 	view::XSelectionChangeListener* pRight = pElem->get();
657cdf0e10cSrcweir 		if(pLeft == pRight)
658cdf0e10cSrcweir 		{
659cdf0e10cSrcweir 			aSelChangedListeners.Remove(i);
660cdf0e10cSrcweir 			delete pElem;
661cdf0e10cSrcweir             break;
662cdf0e10cSrcweir 		}
663cdf0e10cSrcweir 	}
664cdf0e10cSrcweir }
665cdf0e10cSrcweir /* -----------------------------01.06.01 14:41--------------------------------
666cdf0e10cSrcweir 
667cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
GetControl(const uno::Reference<awt::XControlModel> & xModel,uno::Reference<awt::XControl> & xToFill)668cdf0e10cSrcweir SdrObject* SwXTextView::GetControl(
669cdf0e10cSrcweir         const uno::Reference< awt::XControlModel > & xModel,
670cdf0e10cSrcweir         uno::Reference< awt::XControl >& xToFill  )
671cdf0e10cSrcweir {
672cdf0e10cSrcweir     SwView* pView2 = GetView();
673cdf0e10cSrcweir     FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL;
674cdf0e10cSrcweir     SdrView* pDrawView = pView2 ? pView2->GetDrawView() : NULL;
675cdf0e10cSrcweir     Window* pWindow = pView2 ? pView2->GetWrtShell().GetWin() : NULL;
676cdf0e10cSrcweir 
677cdf0e10cSrcweir     DBG_ASSERT( pFormShell && pDrawView && pWindow, "SwXTextView::GetControl: how could I?" );
678cdf0e10cSrcweir 
679cdf0e10cSrcweir     SdrObject* pControl = NULL;
680cdf0e10cSrcweir     if ( pFormShell && pDrawView && pWindow )
681cdf0e10cSrcweir         pControl = pFormShell->GetFormControl( xModel, *pDrawView, *pWindow, xToFill );
682cdf0e10cSrcweir     return pControl;
683cdf0e10cSrcweir }
684cdf0e10cSrcweir /*-- 17.12.98 09:34:27---------------------------------------------------
685cdf0e10cSrcweir 
686cdf0e10cSrcweir   -----------------------------------------------------------------------*/
getControl(const uno::Reference<awt::XControlModel> & xModel)687cdf0e10cSrcweir uno::Reference< awt::XControl >  SwXTextView::getControl(const uno::Reference< awt::XControlModel > & xModel)
688cdf0e10cSrcweir 		throw( container::NoSuchElementException, uno::RuntimeException )
689cdf0e10cSrcweir {
690cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
691cdf0e10cSrcweir     uno::Reference< awt::XControl >  xRet;
692cdf0e10cSrcweir     GetControl(xModel, xRet);
693cdf0e10cSrcweir     return xRet;
694cdf0e10cSrcweir }
695cdf0e10cSrcweir 
696cdf0e10cSrcweir /*-- 08.03.07 13:55------------------------------------------------------
697cdf0e10cSrcweir 
698cdf0e10cSrcweir   -----------------------------------------------------------------------*/
getFormController(const uno::Reference<form::XForm> & _Form)699cdf0e10cSrcweir uno::Reference< form::runtime::XFormController > SAL_CALL SwXTextView::getFormController( const uno::Reference< form::XForm >& _Form ) throw (RuntimeException)
700cdf0e10cSrcweir {
701cdf0e10cSrcweir 	::vos::OGuard aGuard( Application::GetSolarMutex() );
702cdf0e10cSrcweir 
703cdf0e10cSrcweir     SwView* pView2 = GetView();
704cdf0e10cSrcweir     FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL;
705cdf0e10cSrcweir     SdrView* pDrawView = pView2 ? pView2->GetDrawView() : NULL;
706cdf0e10cSrcweir     Window* pWindow = pView2 ? pView2->GetWrtShell().GetWin() : NULL;
707cdf0e10cSrcweir     DBG_ASSERT( pFormShell && pDrawView && pWindow, "SwXTextView::getFormController: how could I?" );
708cdf0e10cSrcweir 
709cdf0e10cSrcweir     uno::Reference< form::runtime::XFormController > xController;
710cdf0e10cSrcweir     if ( pFormShell && pDrawView && pWindow )
711cdf0e10cSrcweir         xController = pFormShell->GetFormController( _Form, *pDrawView, *pWindow );
712cdf0e10cSrcweir     return xController;
713cdf0e10cSrcweir }
714cdf0e10cSrcweir 
715cdf0e10cSrcweir /*-- 08.03.07 13:55------------------------------------------------------
716cdf0e10cSrcweir 
717cdf0e10cSrcweir   -----------------------------------------------------------------------*/
isFormDesignMode()718cdf0e10cSrcweir ::sal_Bool SAL_CALL SwXTextView::isFormDesignMode(  ) throw (uno::RuntimeException)
719cdf0e10cSrcweir {
720cdf0e10cSrcweir 	::vos::OGuard aGuard( Application::GetSolarMutex() );
721cdf0e10cSrcweir     SwView* pView2 = GetView();
722cdf0e10cSrcweir     FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL;
723cdf0e10cSrcweir     return pFormShell ? pFormShell->IsDesignMode() : sal_True;
724cdf0e10cSrcweir }
725cdf0e10cSrcweir 
726cdf0e10cSrcweir /*-- 08.03.07 13:55------------------------------------------------------
727cdf0e10cSrcweir 
728cdf0e10cSrcweir   -----------------------------------------------------------------------*/
setFormDesignMode(::sal_Bool _DesignMode)729cdf0e10cSrcweir void SAL_CALL SwXTextView::setFormDesignMode( ::sal_Bool _DesignMode ) throw (RuntimeException)
730cdf0e10cSrcweir {
731cdf0e10cSrcweir 	::vos::OGuard aGuard( Application::GetSolarMutex() );
732cdf0e10cSrcweir     SwView* pView2 = GetView();
733cdf0e10cSrcweir     FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL;
734cdf0e10cSrcweir     if ( pFormShell )
735cdf0e10cSrcweir         pFormShell->SetDesignMode( _DesignMode );
736cdf0e10cSrcweir }
737cdf0e10cSrcweir 
738cdf0e10cSrcweir /*-- 17.12.98 09:34:28---------------------------------------------------
739cdf0e10cSrcweir 
740cdf0e10cSrcweir   -----------------------------------------------------------------------*/
getViewCursor(void)741cdf0e10cSrcweir uno::Reference< text::XTextViewCursor >  SwXTextView::getViewCursor(void) throw( uno::RuntimeException )
742cdf0e10cSrcweir {
743cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
744cdf0e10cSrcweir     if(GetView())
745cdf0e10cSrcweir 	{
746cdf0e10cSrcweir 		if(!pxTextViewCursor)
747cdf0e10cSrcweir 		{
748cdf0e10cSrcweir 			((SwXTextView*)this)->pxTextViewCursor = new uno::Reference< text::XTextViewCursor > ;
749cdf0e10cSrcweir             *pxTextViewCursor = new  SwXTextViewCursor(GetView());
750cdf0e10cSrcweir 		}
751cdf0e10cSrcweir 		return *pxTextViewCursor;
752cdf0e10cSrcweir 	}
753cdf0e10cSrcweir 	else
754cdf0e10cSrcweir 		throw uno::RuntimeException();
755cdf0e10cSrcweir }
756cdf0e10cSrcweir /*-- 17.12.98 09:34:28---------------------------------------------------
757cdf0e10cSrcweir 
758cdf0e10cSrcweir   -----------------------------------------------------------------------*/
getViewSettings(void)759cdf0e10cSrcweir uno::Reference< beans::XPropertySet >  SwXTextView::getViewSettings(void) throw( uno::RuntimeException )
760cdf0e10cSrcweir {
761cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
762cdf0e10cSrcweir     if(m_pView)
763cdf0e10cSrcweir 	{
764cdf0e10cSrcweir 		if(!pxViewSettings)
765cdf0e10cSrcweir 		{
766cdf0e10cSrcweir 			((SwXTextView*)this)->pxViewSettings = new uno::Reference< beans::XPropertySet > ;
767cdf0e10cSrcweir             *pxViewSettings = static_cast < HelperBaseNoState * > ( new SwXViewSettings( sal_False, m_pView ) );
768cdf0e10cSrcweir 		}
769cdf0e10cSrcweir 	}
770cdf0e10cSrcweir 	else
771cdf0e10cSrcweir 		throw uno::RuntimeException();
772cdf0e10cSrcweir 	return *pxViewSettings;
773cdf0e10cSrcweir }
774cdf0e10cSrcweir /* -----------------------------30.01.01 15:01--------------------------------
775cdf0e10cSrcweir 
776cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
getRubyList(sal_Bool)777cdf0e10cSrcweir Sequence< Sequence< PropertyValue > > SwXTextView::getRubyList( sal_Bool /*bAutomatic*/ ) throw(RuntimeException)
778cdf0e10cSrcweir {
779cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
780cdf0e10cSrcweir 
781cdf0e10cSrcweir     if(!GetView())
782cdf0e10cSrcweir 		throw RuntimeException();
783cdf0e10cSrcweir     SwWrtShell& rSh = m_pView->GetWrtShell();
784cdf0e10cSrcweir     ShellModes  eSelMode = m_pView->GetShellMode();
785cdf0e10cSrcweir 	if (eSelMode != SHELL_MODE_LIST_TEXT      &&
786cdf0e10cSrcweir 		eSelMode != SHELL_MODE_TABLE_LIST_TEXT &&
787cdf0e10cSrcweir         eSelMode != SHELL_MODE_TABLE_TEXT      &&
788cdf0e10cSrcweir         eSelMode != SHELL_MODE_TEXT           )
789cdf0e10cSrcweir 		return Sequence< Sequence< PropertyValue > > ();
790cdf0e10cSrcweir 
791cdf0e10cSrcweir     SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
792cdf0e10cSrcweir 	SwRubyList aList;
793cdf0e10cSrcweir 
794cdf0e10cSrcweir 	sal_uInt16 nCount = pDoc->FillRubyList( *rSh.GetCrsr(), aList, 0 );
795cdf0e10cSrcweir 	Sequence< Sequence< PropertyValue > > aRet(nCount);
796cdf0e10cSrcweir 	Sequence< PropertyValue >* pRet = aRet.getArray();
797cdf0e10cSrcweir 	String aString;
798cdf0e10cSrcweir 	for(sal_uInt16 n = 0; n < nCount; n++)
799cdf0e10cSrcweir 	{
800cdf0e10cSrcweir 		const SwRubyListEntryPtr pEntry = aList[n];
801cdf0e10cSrcweir 
802cdf0e10cSrcweir 		const String& rEntryText = pEntry->GetText();
803cdf0e10cSrcweir 		const SwFmtRuby& rAttr = pEntry->GetRubyAttr();
804cdf0e10cSrcweir 
805cdf0e10cSrcweir         pRet[n].realloc(5);
806cdf0e10cSrcweir 		PropertyValue* pValues = pRet[n].getArray();
807cdf0e10cSrcweir 		pValues[0].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_RUBY_BASE_TEXT));
808cdf0e10cSrcweir 		pValues[0].Value <<= OUString(rEntryText);
809cdf0e10cSrcweir 		pValues[1].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_RUBY_TEXT));
810cdf0e10cSrcweir 		pValues[1].Value <<= OUString(rAttr.GetText());
811cdf0e10cSrcweir 		pValues[2].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_RUBY_CHAR_STYLE_NAME));
812cdf0e10cSrcweir 		SwStyleNameMapper::FillProgName(rAttr.GetCharFmtName(), aString, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
813cdf0e10cSrcweir 		pValues[2].Value <<= OUString( aString );
814cdf0e10cSrcweir 		pValues[3].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_RUBY_ADJUST));
815cdf0e10cSrcweir 		pValues[3].Value <<= (sal_Int16)rAttr.GetAdjustment();
816cdf0e10cSrcweir         pValues[4].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_RUBY_IS_ABOVE));
817cdf0e10cSrcweir         sal_Bool bVal = !rAttr.GetPosition();
818cdf0e10cSrcweir         pValues[4].Value.setValue(&bVal, ::getBooleanCppuType());
819cdf0e10cSrcweir     }
820cdf0e10cSrcweir 	return aRet;
821cdf0e10cSrcweir }
822cdf0e10cSrcweir /* -----------------------------30.01.01 15:02--------------------------------
823cdf0e10cSrcweir 
824cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
setRubyList(const Sequence<Sequence<PropertyValue>> & rRubyList,sal_Bool)825cdf0e10cSrcweir void SAL_CALL SwXTextView::setRubyList(
826cdf0e10cSrcweir     const Sequence< Sequence< PropertyValue > >& rRubyList, sal_Bool /*bAutomatic*/ )
827cdf0e10cSrcweir 		throw(RuntimeException)
828cdf0e10cSrcweir {
829cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
830cdf0e10cSrcweir 
831cdf0e10cSrcweir     if(!GetView() || !rRubyList.getLength())
832cdf0e10cSrcweir 		throw RuntimeException();
833cdf0e10cSrcweir     SwWrtShell& rSh = m_pView->GetWrtShell();
834cdf0e10cSrcweir     ShellModes  eSelMode = m_pView->GetShellMode();
835cdf0e10cSrcweir 	if (eSelMode != SHELL_MODE_LIST_TEXT      &&
836cdf0e10cSrcweir 		eSelMode != SHELL_MODE_TABLE_LIST_TEXT &&
837cdf0e10cSrcweir         eSelMode != SHELL_MODE_TABLE_TEXT      &&
838cdf0e10cSrcweir         eSelMode != SHELL_MODE_TEXT           )
839cdf0e10cSrcweir 		throw RuntimeException();
840cdf0e10cSrcweir 
841cdf0e10cSrcweir 	SwRubyList aList;
842cdf0e10cSrcweir 
843cdf0e10cSrcweir 	const Sequence<PropertyValue>* pRubyList = rRubyList.getConstArray();
844cdf0e10cSrcweir 	for(sal_Int32 nPos = 0; nPos < rRubyList.getLength(); nPos++)
845cdf0e10cSrcweir 	{
846cdf0e10cSrcweir 		SwRubyListEntryPtr pEntry = new SwRubyListEntry;
847cdf0e10cSrcweir 		const PropertyValue* pProperties = pRubyList[nPos].getConstArray();
848cdf0e10cSrcweir 		OUString sTmp;
849cdf0e10cSrcweir 		for(sal_Int32 nProp = 0; nProp < pRubyList[nPos].getLength(); nProp++)
850cdf0e10cSrcweir 		{
851cdf0e10cSrcweir 			if(pProperties[nProp].Name.equalsAsciiL(
852cdf0e10cSrcweir 									SW_PROP_NAME(UNO_NAME_RUBY_BASE_TEXT)))
853cdf0e10cSrcweir 			{
854cdf0e10cSrcweir 				pProperties[nProp].Value >>= sTmp;
855cdf0e10cSrcweir 				pEntry->SetText(sTmp);
856cdf0e10cSrcweir 			}
857cdf0e10cSrcweir 			else if(pProperties[nProp].Name.equalsAsciiL(
858cdf0e10cSrcweir 									SW_PROP_NAME(UNO_NAME_RUBY_TEXT)))
859cdf0e10cSrcweir 			{
860cdf0e10cSrcweir 				pProperties[nProp].Value >>= sTmp;
861cdf0e10cSrcweir 				pEntry->GetRubyAttr().SetText(sTmp);
862cdf0e10cSrcweir 			}
863cdf0e10cSrcweir 			else if(pProperties[nProp].Name.equalsAsciiL(
864cdf0e10cSrcweir 									SW_PROP_NAME(UNO_NAME_RUBY_CHAR_STYLE_NAME)))
865cdf0e10cSrcweir 			{
866cdf0e10cSrcweir 				if((pProperties[nProp].Value >>= sTmp))
867cdf0e10cSrcweir                 {
868cdf0e10cSrcweir 				    String sName;
869cdf0e10cSrcweir 					SwStyleNameMapper::FillUIName(sTmp, sName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
870cdf0e10cSrcweir 				    sal_uInt16 nPoolId = sName.Len() ?
871cdf0e10cSrcweir                         SwStyleNameMapper::GetPoolIdFromUIName( sName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ) : 0;
872cdf0e10cSrcweir 
873cdf0e10cSrcweir 				    pEntry->GetRubyAttr().SetCharFmtName( sName );
874cdf0e10cSrcweir 				    pEntry->GetRubyAttr().SetCharFmtId( nPoolId );
875cdf0e10cSrcweir                 }
876cdf0e10cSrcweir 			}
877cdf0e10cSrcweir 			else if(pProperties[nProp].Name.equalsAsciiL(
878cdf0e10cSrcweir 									SW_PROP_NAME(UNO_NAME_RUBY_ADJUST)))
879cdf0e10cSrcweir 			{
880cdf0e10cSrcweir 				sal_Int16 nTmp = 0;
881cdf0e10cSrcweir 				if((pProperties[nProp].Value >>= nTmp))
882cdf0e10cSrcweir 				    pEntry->GetRubyAttr().SetAdjustment(nTmp);
883cdf0e10cSrcweir 			}
884cdf0e10cSrcweir 			else if(pProperties[nProp].Name.equalsAsciiL(
885cdf0e10cSrcweir 									SW_PROP_NAME(UNO_NAME_RUBY_IS_ABOVE)))
886cdf0e10cSrcweir 			{
887cdf0e10cSrcweir 				sal_Bool bValue = pProperties[nProp].Value.hasValue() ?
888cdf0e10cSrcweir                     *(sal_Bool*)pProperties[nProp].Value.getValue() : sal_True;
889cdf0e10cSrcweir 				pEntry->GetRubyAttr().SetPosition(bValue ? 0 : 1);
890cdf0e10cSrcweir 			}
891cdf0e10cSrcweir 		}
892cdf0e10cSrcweir 		aList.Insert(pEntry, (sal_uInt16)nPos);
893cdf0e10cSrcweir 	}
894cdf0e10cSrcweir     SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
895cdf0e10cSrcweir 	pDoc->SetRubyList( *rSh.GetCrsr(), aList, 0 );
896cdf0e10cSrcweir }
897cdf0e10cSrcweir /*-- 29.12.02 15:45:29---------------------------------------------------
898cdf0e10cSrcweir 
899cdf0e10cSrcweir   -----------------------------------------------------------------------*/
BuildTmpSelectionDoc()900cdf0e10cSrcweir SfxObjectShellLock SwXTextView::BuildTmpSelectionDoc()
901cdf0e10cSrcweir {
902cdf0e10cSrcweir     SwWrtShell& rOldSh = m_pView->GetWrtShell();
903cdf0e10cSrcweir     SfxPrinter *pPrt = rOldSh.getIDocumentDeviceAccess()->getPrinter( false );
904cdf0e10cSrcweir     SwDocShell* pDocSh;
905cdf0e10cSrcweir     SfxObjectShellLock xDocSh( pDocSh = new SwDocShell( /*pPrtDoc, */SFX_CREATE_MODE_STANDARD ) );
906cdf0e10cSrcweir     xDocSh->DoInitNew( 0 );
907cdf0e10cSrcweir     SwDoc *const pTempDoc( pDocSh->GetDoc() );
908cdf0e10cSrcweir     // #i103634#, #i112425#: do not expand numbering and fields on PDF export
909cdf0e10cSrcweir     pTempDoc->SetClipBoard(true);
910cdf0e10cSrcweir     rOldSh.FillPrtDoc(pTempDoc,  pPrt);
911cdf0e10cSrcweir     SfxViewFrame* pDocFrame = SfxViewFrame::LoadHiddenDocument( *xDocSh, 0 );
912cdf0e10cSrcweir     SwView* pDocView = (SwView*) pDocFrame->GetViewShell();
913cdf0e10cSrcweir     pDocView->AttrChangedNotify( &pDocView->GetWrtShell() );//Damit SelectShell gerufen wird.
914cdf0e10cSrcweir     SwWrtShell* pSh = pDocView->GetWrtShellPtr();
915cdf0e10cSrcweir 
916cdf0e10cSrcweir     IDocumentDeviceAccess* pIDDA = pSh->getIDocumentDeviceAccess();
917cdf0e10cSrcweir     SfxPrinter* pTempPrinter = pIDDA->getPrinter( true );
918cdf0e10cSrcweir 
919cdf0e10cSrcweir     const SwPageDesc& rCurPageDesc = rOldSh.GetPageDesc(rOldSh.GetCurPageDesc());
920cdf0e10cSrcweir 
921cdf0e10cSrcweir     IDocumentDeviceAccess* pIDDA_old = rOldSh.getIDocumentDeviceAccess();
922cdf0e10cSrcweir 
923cdf0e10cSrcweir     if( pIDDA_old->getPrinter( false ) )
924cdf0e10cSrcweir     {
925cdf0e10cSrcweir         pIDDA->setJobsetup( *pIDDA_old->getJobsetup() );
926cdf0e10cSrcweir         //#69563# if it isn't the same printer then the pointer has been invalidated!
927cdf0e10cSrcweir         pTempPrinter = pIDDA->getPrinter( true );
928cdf0e10cSrcweir     }
929cdf0e10cSrcweir 
930cdf0e10cSrcweir     pTempPrinter->SetPaperBin(rCurPageDesc.GetMaster().GetPaperBin().GetValue());
931cdf0e10cSrcweir 
932cdf0e10cSrcweir     return xDocSh;
933cdf0e10cSrcweir }
934cdf0e10cSrcweir 
935cdf0e10cSrcweir /*-- 17.12.98 09:34:29---------------------------------------------------
936cdf0e10cSrcweir 
937cdf0e10cSrcweir   -----------------------------------------------------------------------*/
NotifySelChanged()938cdf0e10cSrcweir void SwXTextView::NotifySelChanged()
939cdf0e10cSrcweir {
940cdf0e10cSrcweir     DBG_ASSERT( m_pView, "view is missing" );
941cdf0e10cSrcweir 
942cdf0e10cSrcweir     // destroy temporary document with selected text that is used
943*414ea96eSOliver-Rainer Wittmann     // in PDF export of (multi-)selections and on print of (multi-)selections
944cdf0e10cSrcweir     if (m_pView && m_pView->GetTmpSelectionDoc().Is())
945cdf0e10cSrcweir     {
946*414ea96eSOliver-Rainer Wittmann         // do not destroy the temporary document, if an action is pending
947*414ea96eSOliver-Rainer Wittmann         bool bActionPending = false;
948*414ea96eSOliver-Rainer Wittmann         {
949*414ea96eSOliver-Rainer Wittmann             SfxObjectShellLock& xDocSh = m_pView->GetTmpSelectionDoc();
950*414ea96eSOliver-Rainer Wittmann             SwDoc* pDoc = static_cast< SwDocShell* >(&xDocSh)->GetDoc();
951*414ea96eSOliver-Rainer Wittmann             SwView* pView = pDoc ? pDoc->GetDocShell()->GetView() : 0;
952*414ea96eSOliver-Rainer Wittmann             bActionPending = pView ? pView->GetWrtShell().ActionPend() : false;
953*414ea96eSOliver-Rainer Wittmann         }
954*414ea96eSOliver-Rainer Wittmann         if ( !bActionPending )
955*414ea96eSOliver-Rainer Wittmann         {
956cdf0e10cSrcweir             m_pView->GetTmpSelectionDoc()->DoClose();
957cdf0e10cSrcweir             m_pView->GetTmpSelectionDoc() = 0;
958cdf0e10cSrcweir         }
959*414ea96eSOliver-Rainer Wittmann     }
960cdf0e10cSrcweir 
961cdf0e10cSrcweir 	uno::Reference< uno::XInterface >  xInt = (cppu::OWeakObject*)(SfxBaseController*)this;
962cdf0e10cSrcweir 
963cdf0e10cSrcweir  	lang::EventObject aEvent(xInt);
964cdf0e10cSrcweir 
965cdf0e10cSrcweir 	sal_uInt16 nCount = aSelChangedListeners.Count();
966cdf0e10cSrcweir 	for ( sal_uInt16 i = nCount; i--; )
967cdf0e10cSrcweir 	{
968cdf0e10cSrcweir 		uno::Reference< view::XSelectionChangeListener >  *pObj = aSelChangedListeners[i];
969cdf0e10cSrcweir 		(*pObj)->selectionChanged(aEvent);
970cdf0e10cSrcweir 	}
971cdf0e10cSrcweir }
972cdf0e10cSrcweir /* -----------------------------12.07.01 13:26--------------------------------
973cdf0e10cSrcweir 
974cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
NotifyDBChanged()975cdf0e10cSrcweir void SwXTextView::NotifyDBChanged()
976cdf0e10cSrcweir {
977cdf0e10cSrcweir     URL aURL;
978cdf0e10cSrcweir     aURL.Complete = C2U(SwXDispatch::GetDBChangeURL());
979cdf0e10cSrcweir 
980cdf0e10cSrcweir     sal_uInt16 nCount = aSelChangedListeners.Count();
981cdf0e10cSrcweir 	for ( sal_uInt16 i = nCount; i--; )
982cdf0e10cSrcweir 	{
983cdf0e10cSrcweir 		uno::Reference< view::XSelectionChangeListener >  *pObj = aSelChangedListeners[i];
984cdf0e10cSrcweir         uno::Reference<XDispatch> xDispatch((*pObj), UNO_QUERY);
985cdf0e10cSrcweir         if(xDispatch.is())
986cdf0e10cSrcweir             xDispatch->dispatch(aURL, Sequence<PropertyValue>(0));
987cdf0e10cSrcweir     }
988cdf0e10cSrcweir }
989cdf0e10cSrcweir 
990cdf0e10cSrcweir /* -----------------------------10.12.04 11:07--------------------------------
991cdf0e10cSrcweir 
992cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
993cdf0e10cSrcweir 
getPropertySetInfo()994cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SAL_CALL SwXTextView::getPropertySetInfo(  )
995cdf0e10cSrcweir     throw (uno::RuntimeException)
996cdf0e10cSrcweir {
997cdf0e10cSrcweir     vos::OGuard aGuard( Application::GetSolarMutex() );
998cdf0e10cSrcweir     static uno::Reference< XPropertySetInfo > aRef = m_pPropSet->getPropertySetInfo();
999cdf0e10cSrcweir     return aRef;
1000cdf0e10cSrcweir }
1001cdf0e10cSrcweir 
1002cdf0e10cSrcweir 
setPropertyValue(const OUString & rPropertyName,const uno::Any & rValue)1003cdf0e10cSrcweir void SAL_CALL SwXTextView::setPropertyValue(
1004cdf0e10cSrcweir         const OUString& rPropertyName, const uno::Any& rValue )
1005cdf0e10cSrcweir     throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
1006cdf0e10cSrcweir {
1007cdf0e10cSrcweir     vos::OGuard aGuard( Application::GetSolarMutex() );
1008cdf0e10cSrcweir     const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName );
1009cdf0e10cSrcweir     if (!pEntry)
1010cdf0e10cSrcweir         throw UnknownPropertyException();
1011cdf0e10cSrcweir     else if (pEntry->nFlags & PropertyAttribute::READONLY)
1012cdf0e10cSrcweir         throw PropertyVetoException();
1013cdf0e10cSrcweir     else
1014cdf0e10cSrcweir     {
1015cdf0e10cSrcweir         switch (pEntry->nWID)
1016cdf0e10cSrcweir         {
1017cdf0e10cSrcweir             case WID_IS_HIDE_SPELL_MARKS :
1018cdf0e10cSrcweir                 // deprecated #i91949
1019cdf0e10cSrcweir             break;
1020cdf0e10cSrcweir             case WID_IS_CONSTANT_SPELLCHECK :
1021cdf0e10cSrcweir             {
1022cdf0e10cSrcweir                 sal_Bool bVal = sal_False;
1023cdf0e10cSrcweir                 const SwViewOption *pOpt = m_pView->GetWrtShell().GetViewOptions();
1024cdf0e10cSrcweir                 if (!pOpt || !(rValue >>= bVal))
1025cdf0e10cSrcweir                     throw RuntimeException();
1026cdf0e10cSrcweir                 SwViewOption aNewOpt( *pOpt );
1027cdf0e10cSrcweir                 if (pEntry->nWID == WID_IS_CONSTANT_SPELLCHECK)
1028cdf0e10cSrcweir                     aNewOpt.SetOnlineSpell(bVal);
1029cdf0e10cSrcweir                 m_pView->GetWrtShell().ApplyViewOptions( aNewOpt );
1030cdf0e10cSrcweir             }
1031cdf0e10cSrcweir             break;
1032cdf0e10cSrcweir             default :
1033cdf0e10cSrcweir                 DBG_ERROR("unknown WID");
1034cdf0e10cSrcweir         }
1035cdf0e10cSrcweir     }
1036cdf0e10cSrcweir }
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir 
getPropertyValue(const OUString & rPropertyName)1039cdf0e10cSrcweir uno::Any SAL_CALL SwXTextView::getPropertyValue(
1040cdf0e10cSrcweir         const OUString& rPropertyName )
1041cdf0e10cSrcweir     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1042cdf0e10cSrcweir {
1043cdf0e10cSrcweir     vos::OGuard aGuard( Application::GetSolarMutex() );
1044cdf0e10cSrcweir 
1045cdf0e10cSrcweir     Any aRet;
1046cdf0e10cSrcweir 
1047cdf0e10cSrcweir     const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName );
1048cdf0e10cSrcweir     if (!pEntry)
1049cdf0e10cSrcweir         throw UnknownPropertyException();
1050cdf0e10cSrcweir     else
1051cdf0e10cSrcweir     {
1052cdf0e10cSrcweir         sal_Int16 nWID = pEntry->nWID;
1053cdf0e10cSrcweir         switch (nWID)
1054cdf0e10cSrcweir         {
1055cdf0e10cSrcweir             case WID_PAGE_COUNT :
1056cdf0e10cSrcweir             case WID_LINE_COUNT :
1057cdf0e10cSrcweir             {
1058cdf0e10cSrcweir                 // format document completely in order to get meaningful
1059cdf0e10cSrcweir                 // values for page count and line count
1060cdf0e10cSrcweir                 m_pView->GetWrtShell().CalcLayout();
1061cdf0e10cSrcweir 
1062cdf0e10cSrcweir                 sal_Int32 nCount = -1;
1063cdf0e10cSrcweir                 if (nWID == WID_PAGE_COUNT)
1064cdf0e10cSrcweir                     nCount = m_pView->GetWrtShell().GetPageCount();
1065cdf0e10cSrcweir                 else // WID_LINE_COUNT
1066cdf0e10cSrcweir                     nCount = m_pView->GetWrtShell().GetLineCount( sal_False /*of whole document*/ );
1067cdf0e10cSrcweir                 aRet <<= nCount;
1068cdf0e10cSrcweir             }
1069cdf0e10cSrcweir             break;
1070cdf0e10cSrcweir             case WID_IS_HIDE_SPELL_MARKS :
1071cdf0e10cSrcweir                 // deprecated #i91949
1072cdf0e10cSrcweir             break;
1073cdf0e10cSrcweir             case WID_IS_CONSTANT_SPELLCHECK :
1074cdf0e10cSrcweir             {
1075cdf0e10cSrcweir                 const SwViewOption *pOpt = m_pView->GetWrtShell().GetViewOptions();
1076cdf0e10cSrcweir                 if (!pOpt)
1077cdf0e10cSrcweir                     throw RuntimeException();
1078cdf0e10cSrcweir                 sal_uInt32 nFlag = VIEWOPT_1_ONLINESPELL;
1079cdf0e10cSrcweir                 sal_Bool bVal = 0 != (pOpt->GetCoreOptions() & nFlag);
1080cdf0e10cSrcweir                 aRet <<= bVal;
1081cdf0e10cSrcweir             }
1082cdf0e10cSrcweir             break;
1083cdf0e10cSrcweir             default :
1084cdf0e10cSrcweir                 DBG_ERROR("unknown WID");
1085cdf0e10cSrcweir         }
1086cdf0e10cSrcweir     }
1087cdf0e10cSrcweir 
1088cdf0e10cSrcweir     return aRet;
1089cdf0e10cSrcweir }
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir 
addPropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)1092cdf0e10cSrcweir void SAL_CALL SwXTextView::addPropertyChangeListener(
1093cdf0e10cSrcweir         const OUString& /*rPropertyName*/,
1094cdf0e10cSrcweir         const uno::Reference< beans::XPropertyChangeListener >& /*rxListener*/ )
1095cdf0e10cSrcweir     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1096cdf0e10cSrcweir {
1097cdf0e10cSrcweir     DBG_WARNING("not implemented");
1098cdf0e10cSrcweir }
1099cdf0e10cSrcweir 
1100cdf0e10cSrcweir 
removePropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)1101cdf0e10cSrcweir void SAL_CALL SwXTextView::removePropertyChangeListener(
1102cdf0e10cSrcweir         const OUString& /*rPropertyName*/,
1103cdf0e10cSrcweir         const uno::Reference< beans::XPropertyChangeListener >& /*rxListener*/ )
1104cdf0e10cSrcweir     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1105cdf0e10cSrcweir {
1106cdf0e10cSrcweir     DBG_WARNING("not implemented");
1107cdf0e10cSrcweir }
1108cdf0e10cSrcweir 
1109cdf0e10cSrcweir 
addVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)1110cdf0e10cSrcweir void SAL_CALL SwXTextView::addVetoableChangeListener(
1111cdf0e10cSrcweir         const OUString& /*rPropertyName*/,
1112cdf0e10cSrcweir         const uno::Reference< beans::XVetoableChangeListener >& /*rxListener*/ )
1113cdf0e10cSrcweir     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1114cdf0e10cSrcweir {
1115cdf0e10cSrcweir     DBG_WARNING("not implemented");
1116cdf0e10cSrcweir }
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir 
removeVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)1119cdf0e10cSrcweir void SAL_CALL SwXTextView::removeVetoableChangeListener(
1120cdf0e10cSrcweir         const OUString& /*rPropertyName*/,
1121cdf0e10cSrcweir         const uno::Reference< beans::XVetoableChangeListener >& /*rxListener*/ )
1122cdf0e10cSrcweir     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1123cdf0e10cSrcweir {
1124cdf0e10cSrcweir     DBG_WARNING("not implemented");
1125cdf0e10cSrcweir }
1126cdf0e10cSrcweir 
1127cdf0e10cSrcweir /* -----------------------------06.04.00 11:07--------------------------------
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
getImplementationName(void)1130cdf0e10cSrcweir OUString SwXTextView::getImplementationName(void) throw( RuntimeException )
1131cdf0e10cSrcweir {
1132cdf0e10cSrcweir 	return C2U("SwXTextView");
1133cdf0e10cSrcweir }
1134cdf0e10cSrcweir /* -----------------------------06.04.00 11:07--------------------------------
1135cdf0e10cSrcweir 
1136cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
supportsService(const OUString & rServiceName)1137cdf0e10cSrcweir sal_Bool SwXTextView::supportsService(const OUString& rServiceName) throw( RuntimeException )
1138cdf0e10cSrcweir {
1139cdf0e10cSrcweir     return rServiceName.equalsAscii("com.sun.star.text.TextDocumentView") ||
1140cdf0e10cSrcweir             rServiceName.equalsAscii("com.sun.star.view.OfficeDocumentView");
1141cdf0e10cSrcweir }
1142cdf0e10cSrcweir /* -----------------------------06.04.00 11:07--------------------------------
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
getSupportedServiceNames(void)1145cdf0e10cSrcweir Sequence< OUString > SwXTextView::getSupportedServiceNames(void) throw( RuntimeException )
1146cdf0e10cSrcweir {
1147cdf0e10cSrcweir     Sequence< OUString > aRet(2);
1148cdf0e10cSrcweir 	OUString* pArray = aRet.getArray();
1149cdf0e10cSrcweir     pArray[0] = C2U("com.sun.star.text.TextDocumentView");
1150cdf0e10cSrcweir     pArray[1] = C2U("com.sun.star.view.OfficeDocumentView");
1151cdf0e10cSrcweir 	return aRet;
1152cdf0e10cSrcweir }
1153cdf0e10cSrcweir 
1154cdf0e10cSrcweir /******************************************************************
1155cdf0e10cSrcweir  * SwXTextViewCursor
1156cdf0e10cSrcweir  ******************************************************************/
1157cdf0e10cSrcweir /*-- 17.12.98 09:36:23---------------------------------------------------
1158cdf0e10cSrcweir 
1159cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SwXTextViewCursor(SwView * pVw)1160cdf0e10cSrcweir SwXTextViewCursor::SwXTextViewCursor(SwView* pVw) :
1161cdf0e10cSrcweir     m_pView(pVw),
1162cdf0e10cSrcweir     m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR))
1163cdf0e10cSrcweir {
1164cdf0e10cSrcweir }
1165cdf0e10cSrcweir /*-- 17.12.98 09:36:24---------------------------------------------------
1166cdf0e10cSrcweir 
1167cdf0e10cSrcweir   -----------------------------------------------------------------------*/
~SwXTextViewCursor()1168cdf0e10cSrcweir SwXTextViewCursor::~SwXTextViewCursor()
1169cdf0e10cSrcweir {
1170cdf0e10cSrcweir }
1171cdf0e10cSrcweir /*-- 06.10.04 09:36:25---------------------------------------------------
1172cdf0e10cSrcweir 
1173cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1174cdf0e10cSrcweir 
1175cdf0e10cSrcweir // used to determine if there is a text selction or not.
1176cdf0e10cSrcweir // If there is no text selection the functions that need a working
1177cdf0e10cSrcweir // cursor will be disabled (throw RuntimeException). This will be the case
1178cdf0e10cSrcweir // for the following interfaces:
1179cdf0e10cSrcweir // - XViewCursor
1180cdf0e10cSrcweir // - XTextCursor
1181cdf0e10cSrcweir // - XTextRange
1182cdf0e10cSrcweir // - XLineCursor
1183cdf0e10cSrcweir 
IsTextSelection(sal_Bool bAllowTables) const1184cdf0e10cSrcweir sal_Bool SwXTextViewCursor::IsTextSelection( sal_Bool bAllowTables ) const
1185cdf0e10cSrcweir {
1186cdf0e10cSrcweir 
1187cdf0e10cSrcweir     sal_Bool bRes = sal_False;
1188cdf0e10cSrcweir     DBG_ASSERT(m_pView, "m_pView is NULL ???");
1189cdf0e10cSrcweir     if(m_pView)
1190cdf0e10cSrcweir 	{
1191cdf0e10cSrcweir         //! m_pView->GetShellMode() will only work after the shell
1192cdf0e10cSrcweir 		//! has already changed and thus can not be used here!
1193cdf0e10cSrcweir         SelectionType eSelType = m_pView->GetWrtShell().GetSelectionType();
1194cdf0e10cSrcweir 		bRes =  ( (nsSelectionType::SEL_TXT & eSelType) ||
1195cdf0e10cSrcweir                   (nsSelectionType::SEL_NUM & eSelType) )  &&
1196cdf0e10cSrcweir 				(!(nsSelectionType::SEL_TBL_CELLS & eSelType) || bAllowTables);
1197cdf0e10cSrcweir     }
1198cdf0e10cSrcweir     return bRes;
1199cdf0e10cSrcweir }
1200cdf0e10cSrcweir 
1201cdf0e10cSrcweir /*-- 17.12.98 09:36:25---------------------------------------------------
1202cdf0e10cSrcweir 
1203cdf0e10cSrcweir   -----------------------------------------------------------------------*/
isVisible(void)1204cdf0e10cSrcweir sal_Bool SwXTextViewCursor::isVisible(void) throw( uno::RuntimeException )
1205cdf0e10cSrcweir {
1206cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1207cdf0e10cSrcweir 	DBG_WARNING("not implemented");
1208cdf0e10cSrcweir 	return sal_True;
1209cdf0e10cSrcweir }
1210cdf0e10cSrcweir /*-- 17.12.98 09:36:25---------------------------------------------------
1211cdf0e10cSrcweir 
1212cdf0e10cSrcweir   -----------------------------------------------------------------------*/
setVisible(sal_Bool)1213cdf0e10cSrcweir void SwXTextViewCursor::setVisible(sal_Bool /*bVisible*/) throw( uno::RuntimeException )
1214cdf0e10cSrcweir {
1215cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1216cdf0e10cSrcweir 	DBG_WARNING("not implemented");
1217cdf0e10cSrcweir }
1218cdf0e10cSrcweir /*-- 17.12.98 09:36:26---------------------------------------------------
1219cdf0e10cSrcweir 
1220cdf0e10cSrcweir   -----------------------------------------------------------------------*/
getPosition(void)1221cdf0e10cSrcweir awt::Point SwXTextViewCursor::getPosition(void) throw( uno::RuntimeException )
1222cdf0e10cSrcweir {
1223cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1224cdf0e10cSrcweir 	awt::Point aRet;
1225cdf0e10cSrcweir     if(m_pView)
1226cdf0e10cSrcweir 	{
1227cdf0e10cSrcweir         const SwWrtShell& rSh = m_pView->GetWrtShell();
1228cdf0e10cSrcweir 		const SwRect aCharRect(rSh.GetCharRect());
1229cdf0e10cSrcweir 
1230cdf0e10cSrcweir         const SwFrmFmt& rMaster = rSh.GetPageDesc( rSh.GetCurPageDesc() ).GetMaster();
1231cdf0e10cSrcweir 
1232cdf0e10cSrcweir         const SvxULSpaceItem& rUL = rMaster.GetULSpace();
1233cdf0e10cSrcweir 		const long nY = aCharRect.Top() - (rUL.GetUpper() + DOCUMENTBORDER);
1234cdf0e10cSrcweir 		aRet.Y = TWIP_TO_MM100(nY);
1235cdf0e10cSrcweir 
1236cdf0e10cSrcweir         const SvxLRSpaceItem& rLR = rMaster.GetLRSpace();
1237cdf0e10cSrcweir 		const long nX = aCharRect.Left() - (rLR.GetLeft() + DOCUMENTBORDER);
1238cdf0e10cSrcweir 		aRet.X = TWIP_TO_MM100(nX);
1239cdf0e10cSrcweir 	}
1240cdf0e10cSrcweir 	else
1241cdf0e10cSrcweir 		throw uno::RuntimeException();
1242cdf0e10cSrcweir 	return aRet;
1243cdf0e10cSrcweir }
1244cdf0e10cSrcweir /*-- 17.12.98 09:36:26---------------------------------------------------
1245cdf0e10cSrcweir 
1246cdf0e10cSrcweir   -----------------------------------------------------------------------*/
collapseToStart(void)1247cdf0e10cSrcweir void SwXTextViewCursor::collapseToStart(void) throw( uno::RuntimeException )
1248cdf0e10cSrcweir {
1249cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1250cdf0e10cSrcweir     if(m_pView)
1251cdf0e10cSrcweir 	{
1252cdf0e10cSrcweir         if (!IsTextSelection())
1253cdf0e10cSrcweir             throw  uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
1254cdf0e10cSrcweir 
1255cdf0e10cSrcweir         SwWrtShell& rSh = m_pView->GetWrtShell();
1256cdf0e10cSrcweir 		if(rSh.HasSelection())
1257cdf0e10cSrcweir 		{
1258cdf0e10cSrcweir 			SwPaM* pShellCrsr = rSh.GetCrsr();
1259cdf0e10cSrcweir 			if(*pShellCrsr->GetPoint() > *pShellCrsr->GetMark())
1260cdf0e10cSrcweir 				pShellCrsr->Exchange();
1261cdf0e10cSrcweir 			pShellCrsr->DeleteMark();
1262cdf0e10cSrcweir 			rSh.EnterStdMode();
1263cdf0e10cSrcweir 			rSh.SetSelection(*pShellCrsr);
1264cdf0e10cSrcweir 		}
1265cdf0e10cSrcweir 	}
1266cdf0e10cSrcweir 	else
1267cdf0e10cSrcweir 		throw uno::RuntimeException();
1268cdf0e10cSrcweir }
1269cdf0e10cSrcweir /*-- 17.12.98 09:36:26---------------------------------------------------
1270cdf0e10cSrcweir 
1271cdf0e10cSrcweir   -----------------------------------------------------------------------*/
collapseToEnd(void)1272cdf0e10cSrcweir void SwXTextViewCursor::collapseToEnd(void) throw( uno::RuntimeException )
1273cdf0e10cSrcweir {
1274cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1275cdf0e10cSrcweir     if(m_pView)
1276cdf0e10cSrcweir 	{
1277cdf0e10cSrcweir         if (!IsTextSelection())
1278cdf0e10cSrcweir             throw  uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
1279cdf0e10cSrcweir 
1280cdf0e10cSrcweir         SwWrtShell& rSh = m_pView->GetWrtShell();
1281cdf0e10cSrcweir 		if(rSh.HasSelection())
1282cdf0e10cSrcweir 		{
1283cdf0e10cSrcweir 			SwPaM* pShellCrsr = rSh.GetCrsr();
1284cdf0e10cSrcweir 			if(*pShellCrsr->GetPoint() < *pShellCrsr->GetMark())
1285cdf0e10cSrcweir 				pShellCrsr->Exchange();
1286cdf0e10cSrcweir 			pShellCrsr->DeleteMark();
1287cdf0e10cSrcweir 			rSh.EnterStdMode();
1288cdf0e10cSrcweir 			rSh.SetSelection(*pShellCrsr);
1289cdf0e10cSrcweir 		}
1290cdf0e10cSrcweir 	}
1291cdf0e10cSrcweir 	else
1292cdf0e10cSrcweir 		throw uno::RuntimeException();
1293cdf0e10cSrcweir }
1294cdf0e10cSrcweir /*-- 17.12.98 09:36:27---------------------------------------------------
1295cdf0e10cSrcweir 
1296cdf0e10cSrcweir   -----------------------------------------------------------------------*/
isCollapsed(void)1297cdf0e10cSrcweir sal_Bool SwXTextViewCursor::isCollapsed(void) throw( uno::RuntimeException )
1298cdf0e10cSrcweir {
1299cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1300cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1301cdf0e10cSrcweir     if(m_pView)
1302cdf0e10cSrcweir 	{
1303cdf0e10cSrcweir         if (!IsTextSelection())
1304cdf0e10cSrcweir             throw  uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
1305cdf0e10cSrcweir 
1306cdf0e10cSrcweir         const SwWrtShell& rSh = m_pView->GetWrtShell();
1307cdf0e10cSrcweir         bRet = !rSh.HasSelection();
1308cdf0e10cSrcweir 	}
1309cdf0e10cSrcweir 	else
1310cdf0e10cSrcweir 		throw uno::RuntimeException();
1311cdf0e10cSrcweir 	return bRet;
1312cdf0e10cSrcweir 
1313cdf0e10cSrcweir }
1314cdf0e10cSrcweir /*-- 17.12.98 09:36:27---------------------------------------------------
1315cdf0e10cSrcweir 
1316cdf0e10cSrcweir   -----------------------------------------------------------------------*/
goLeft(sal_Int16 nCount,sal_Bool bExpand)1317cdf0e10cSrcweir sal_Bool SwXTextViewCursor::goLeft(sal_Int16 nCount, sal_Bool bExpand) throw( uno::RuntimeException )
1318cdf0e10cSrcweir {
1319cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1320cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1321cdf0e10cSrcweir     if(m_pView)
1322cdf0e10cSrcweir 	{
1323cdf0e10cSrcweir         if (!IsTextSelection())
1324cdf0e10cSrcweir             throw  uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
1325cdf0e10cSrcweir 
1326cdf0e10cSrcweir 		for( sal_uInt16 i = 0; i < nCount; i++ )
1327cdf0e10cSrcweir             bRet = m_pView->GetWrtShell().Left( CRSR_SKIP_CHARS, bExpand, 1, sal_True );
1328cdf0e10cSrcweir 	}
1329cdf0e10cSrcweir 	else
1330cdf0e10cSrcweir 		throw uno::RuntimeException();
1331cdf0e10cSrcweir 	return bRet;
1332cdf0e10cSrcweir }
1333cdf0e10cSrcweir /*-- 17.12.98 09:36:27---------------------------------------------------
1334cdf0e10cSrcweir 
1335cdf0e10cSrcweir   -----------------------------------------------------------------------*/
goRight(sal_Int16 nCount,sal_Bool bExpand)1336cdf0e10cSrcweir sal_Bool SwXTextViewCursor::goRight(sal_Int16 nCount, sal_Bool bExpand) throw( uno::RuntimeException )
1337cdf0e10cSrcweir {
1338cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1339cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1340cdf0e10cSrcweir     if(m_pView)
1341cdf0e10cSrcweir 	{
1342cdf0e10cSrcweir         if (!IsTextSelection())
1343cdf0e10cSrcweir             throw  uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
1344cdf0e10cSrcweir 
1345cdf0e10cSrcweir 		for( sal_uInt16 i = 0; i < nCount; i++ )
1346cdf0e10cSrcweir             bRet = m_pView->GetWrtShell().Right( CRSR_SKIP_CHARS, bExpand, 1, sal_True );
1347cdf0e10cSrcweir 	}
1348cdf0e10cSrcweir 	else
1349cdf0e10cSrcweir 		throw uno::RuntimeException();
1350cdf0e10cSrcweir 	return bRet;
1351cdf0e10cSrcweir 
1352cdf0e10cSrcweir }
1353cdf0e10cSrcweir /* -----------------08.03.99 11:18-------------------
1354cdf0e10cSrcweir  *
1355cdf0e10cSrcweir  * --------------------------------------------------*/
gotoRange(const uno::Reference<text::XTextRange> & xRange,sal_Bool bExpand)1356cdf0e10cSrcweir void SwXTextViewCursor::gotoRange(
1357cdf0e10cSrcweir 	const uno::Reference< text::XTextRange > & xRange,
1358cdf0e10cSrcweir 	sal_Bool bExpand)
1359cdf0e10cSrcweir 		throw(RuntimeException)
1360cdf0e10cSrcweir {
1361cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1362cdf0e10cSrcweir     if(m_pView && xRange.is())
1363cdf0e10cSrcweir 	{
1364cdf0e10cSrcweir         if (!IsTextSelection())
1365cdf0e10cSrcweir             throw  uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
1366cdf0e10cSrcweir 
1367cdf0e10cSrcweir         SwUnoInternalPaM rDestPam(*m_pView->GetDocShell()->GetDoc());
1368cdf0e10cSrcweir         if (!::sw::XTextRangeToSwPaM(rDestPam, xRange))
1369cdf0e10cSrcweir         {
1370cdf0e10cSrcweir             throw uno::RuntimeException();
1371cdf0e10cSrcweir         }
1372cdf0e10cSrcweir 
1373cdf0e10cSrcweir         ShellModes  eSelMode = m_pView->GetShellMode();
1374cdf0e10cSrcweir         SwWrtShell& rSh = m_pView->GetWrtShell();
1375cdf0e10cSrcweir 		// call EnterStdMode in non-text selections only
1376cdf0e10cSrcweir 		if(!bExpand ||
1377cdf0e10cSrcweir 		   (eSelMode != SHELL_MODE_TABLE_TEXT &&
1378cdf0e10cSrcweir 			eSelMode != SHELL_MODE_LIST_TEXT &&
1379cdf0e10cSrcweir 			eSelMode != SHELL_MODE_TABLE_LIST_TEXT &&
1380cdf0e10cSrcweir 			eSelMode != SHELL_MODE_TEXT ))
1381cdf0e10cSrcweir 				rSh.EnterStdMode();
1382cdf0e10cSrcweir 		SwPaM* pShellCrsr = rSh.GetCrsr();
1383cdf0e10cSrcweir 		SwPaM aOwnPaM(*pShellCrsr->GetPoint());
1384cdf0e10cSrcweir 		if(pShellCrsr->HasMark())
1385cdf0e10cSrcweir 		{
1386cdf0e10cSrcweir 			aOwnPaM.SetMark();
1387cdf0e10cSrcweir 			*aOwnPaM.GetMark() = *pShellCrsr->GetMark();
1388cdf0e10cSrcweir 		}
1389cdf0e10cSrcweir 
1390cdf0e10cSrcweir 		uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY);
1391cdf0e10cSrcweir 		SwXTextRange* pRange = 0;
1392cdf0e10cSrcweir         SwXParagraph* pPara = 0;
1393cdf0e10cSrcweir         OTextCursorHelper* pCursor = 0;
1394cdf0e10cSrcweir 		if(xRangeTunnel.is())
1395cdf0e10cSrcweir 		{
1396cdf0e10cSrcweir             pRange = reinterpret_cast<SwXTextRange*>(xRangeTunnel->getSomething(
1397cdf0e10cSrcweir                                     SwXTextRange::getUnoTunnelId()));
1398cdf0e10cSrcweir             pCursor = reinterpret_cast<OTextCursorHelper*>(xRangeTunnel->getSomething(
1399cdf0e10cSrcweir                                     OTextCursorHelper::getUnoTunnelId()));
1400cdf0e10cSrcweir             pPara = reinterpret_cast<SwXParagraph*>(xRangeTunnel->getSomething(
1401cdf0e10cSrcweir                                     SwXParagraph::getUnoTunnelId()));
1402cdf0e10cSrcweir 		}
1403cdf0e10cSrcweir 
1404cdf0e10cSrcweir         const sal_uInt16 nFrmType = rSh.GetFrmType(0,sal_True);
1405cdf0e10cSrcweir 
1406cdf0e10cSrcweir 		SwStartNodeType eSearchNodeType = SwNormalStartNode;
1407cdf0e10cSrcweir 		if(nFrmType & FRMTYPE_FLY_ANY)
1408cdf0e10cSrcweir 			eSearchNodeType = SwFlyStartNode;
1409cdf0e10cSrcweir 		else if(nFrmType &FRMTYPE_HEADER)
1410cdf0e10cSrcweir 			eSearchNodeType = SwHeaderStartNode;
1411cdf0e10cSrcweir 		else if(nFrmType & FRMTYPE_FOOTER)
1412cdf0e10cSrcweir 			eSearchNodeType = SwFooterStartNode;
1413cdf0e10cSrcweir 		else if(nFrmType & FRMTYPE_TABLE)
1414cdf0e10cSrcweir 			eSearchNodeType = SwTableBoxStartNode;
1415cdf0e10cSrcweir 		else if(nFrmType & FRMTYPE_FOOTNOTE)
1416cdf0e10cSrcweir 			eSearchNodeType = SwFootnoteStartNode;
1417cdf0e10cSrcweir 
1418cdf0e10cSrcweir 		const SwStartNode* pOwnStartNode = aOwnPaM.GetNode()->
1419cdf0e10cSrcweir 												FindSttNodeByType(eSearchNodeType);
1420cdf0e10cSrcweir 
1421cdf0e10cSrcweir 		const SwNode* pSrcNode = 0;
1422cdf0e10cSrcweir         if(pCursor && pCursor->GetPaM())
1423cdf0e10cSrcweir         {
1424cdf0e10cSrcweir             pSrcNode = pCursor->GetPaM()->GetNode();
1425cdf0e10cSrcweir         }
1426cdf0e10cSrcweir         else if (pRange)
1427cdf0e10cSrcweir         {
1428cdf0e10cSrcweir             SwPaM aPam(pRange->GetDoc()->GetNodes());
1429cdf0e10cSrcweir             if (pRange->GetPositions(aPam))
1430cdf0e10cSrcweir             {
1431cdf0e10cSrcweir                 pSrcNode = aPam.GetNode();
1432cdf0e10cSrcweir             }
1433cdf0e10cSrcweir         }
1434cdf0e10cSrcweir         else if (pPara && pPara->GetTxtNode())
1435cdf0e10cSrcweir         {
1436cdf0e10cSrcweir             pSrcNode = pPara->GetTxtNode();
1437cdf0e10cSrcweir         }
1438cdf0e10cSrcweir         const SwStartNode* pTmp = pSrcNode ? pSrcNode->FindSttNodeByType(eSearchNodeType) : 0;
1439cdf0e10cSrcweir 
1440cdf0e10cSrcweir         //SectionNodes ueberspringen
1441cdf0e10cSrcweir 		while(pTmp && pTmp->IsSectionNode())
1442cdf0e10cSrcweir 		{
1443cdf0e10cSrcweir             pTmp = pTmp->StartOfSectionNode();
1444cdf0e10cSrcweir 		}
1445cdf0e10cSrcweir         while(pOwnStartNode && pOwnStartNode->IsSectionNode())
1446cdf0e10cSrcweir         {
1447cdf0e10cSrcweir             pOwnStartNode = pOwnStartNode->StartOfSectionNode();
1448cdf0e10cSrcweir         }
1449cdf0e10cSrcweir 		//ohne Expand darf mit dem ViewCursor ueberall hingesprungen werden
1450cdf0e10cSrcweir 		//mit Expand nur in der gleichen Umgebung
1451cdf0e10cSrcweir 		if(bExpand &&
1452cdf0e10cSrcweir 			(pOwnStartNode != pTmp ||
1453cdf0e10cSrcweir 			(eSelMode != SHELL_MODE_TABLE_TEXT &&
1454cdf0e10cSrcweir 				eSelMode != SHELL_MODE_LIST_TEXT &&
1455cdf0e10cSrcweir 				eSelMode != SHELL_MODE_TABLE_LIST_TEXT &&
1456cdf0e10cSrcweir 				eSelMode != SHELL_MODE_TEXT)))
1457cdf0e10cSrcweir 			throw uno::RuntimeException();
1458cdf0e10cSrcweir 
1459cdf0e10cSrcweir 		//jetzt muss die Selektion erweitert werden
1460cdf0e10cSrcweir 		if(bExpand)
1461cdf0e10cSrcweir 		{
1462cdf0e10cSrcweir 			// der Cursor soll alles einschliessen, was bisher von ihm und dem uebergebenen
1463cdf0e10cSrcweir 			// Range eingeschlossen wurde
1464cdf0e10cSrcweir             SwPosition aOwnLeft(*aOwnPaM.Start());
1465cdf0e10cSrcweir             SwPosition aOwnRight(*aOwnPaM.End());
1466cdf0e10cSrcweir             SwPosition* pParamLeft = rDestPam.Start();
1467cdf0e10cSrcweir             SwPosition* pParamRight = rDestPam.End();
1468cdf0e10cSrcweir             // jetzt sind vier SwPositions da, zwei davon werden gebraucht, also welche?
1469cdf0e10cSrcweir 			if(aOwnRight > *pParamRight)
1470cdf0e10cSrcweir 				*aOwnPaM.GetPoint() = aOwnRight;
1471cdf0e10cSrcweir 			else
1472cdf0e10cSrcweir 				*aOwnPaM.GetPoint() = *pParamRight;
1473cdf0e10cSrcweir 			aOwnPaM.SetMark();
1474cdf0e10cSrcweir 			if(aOwnLeft < *pParamLeft)
1475cdf0e10cSrcweir 				*aOwnPaM.GetMark() = aOwnLeft;
1476cdf0e10cSrcweir 			else
1477cdf0e10cSrcweir 				*aOwnPaM.GetMark() = *pParamLeft;
1478cdf0e10cSrcweir 		}
1479cdf0e10cSrcweir 		else
1480cdf0e10cSrcweir 		{
1481cdf0e10cSrcweir 			//der Cursor soll dem uebergebenen Range entsprechen
1482cdf0e10cSrcweir             *aOwnPaM.GetPoint() = *rDestPam.GetPoint();
1483cdf0e10cSrcweir             if(rDestPam.HasMark())
1484cdf0e10cSrcweir             {
1485cdf0e10cSrcweir                 aOwnPaM.SetMark();
1486cdf0e10cSrcweir                 *aOwnPaM.GetMark() = *rDestPam.GetMark();
1487cdf0e10cSrcweir             }
1488cdf0e10cSrcweir             else
1489cdf0e10cSrcweir                 aOwnPaM.DeleteMark();
1490cdf0e10cSrcweir         }
1491cdf0e10cSrcweir 		rSh.SetSelection(aOwnPaM);
1492cdf0e10cSrcweir 	}
1493cdf0e10cSrcweir 	else
1494cdf0e10cSrcweir 		throw uno::RuntimeException();
1495cdf0e10cSrcweir 
1496cdf0e10cSrcweir }
1497cdf0e10cSrcweir /*-- 17.12.98 09:36:28---------------------------------------------------
1498cdf0e10cSrcweir 
1499cdf0e10cSrcweir   -----------------------------------------------------------------------*/
gotoStart(sal_Bool bExpand)1500cdf0e10cSrcweir void SwXTextViewCursor::gotoStart(sal_Bool bExpand) throw( uno::RuntimeException )
1501cdf0e10cSrcweir {
1502cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1503cdf0e10cSrcweir     if(m_pView)
1504cdf0e10cSrcweir     {
1505cdf0e10cSrcweir         if (!IsTextSelection())
1506cdf0e10cSrcweir             throw  uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
1507cdf0e10cSrcweir 
1508cdf0e10cSrcweir         m_pView->GetWrtShell().SttDoc( bExpand );
1509cdf0e10cSrcweir     }
1510cdf0e10cSrcweir 	else
1511cdf0e10cSrcweir 		throw uno::RuntimeException();
1512cdf0e10cSrcweir }
1513cdf0e10cSrcweir /*-- 17.12.98 09:36:28---------------------------------------------------
1514cdf0e10cSrcweir 
1515cdf0e10cSrcweir   -----------------------------------------------------------------------*/
gotoEnd(sal_Bool bExpand)1516cdf0e10cSrcweir void SwXTextViewCursor::gotoEnd(sal_Bool bExpand) throw( uno::RuntimeException )
1517cdf0e10cSrcweir {
1518cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1519cdf0e10cSrcweir     if(m_pView)
1520cdf0e10cSrcweir     {
1521cdf0e10cSrcweir         if (!IsTextSelection())
1522cdf0e10cSrcweir             throw  uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
1523cdf0e10cSrcweir 
1524cdf0e10cSrcweir         m_pView->GetWrtShell().EndDoc( bExpand );
1525cdf0e10cSrcweir     }
1526cdf0e10cSrcweir 	else
1527cdf0e10cSrcweir 		throw uno::RuntimeException();
1528cdf0e10cSrcweir }
1529cdf0e10cSrcweir /*-- 17.12.98 09:36:28---------------------------------------------------
1530cdf0e10cSrcweir 
1531cdf0e10cSrcweir   -----------------------------------------------------------------------*/
jumpToFirstPage(void)1532cdf0e10cSrcweir sal_Bool SwXTextViewCursor::jumpToFirstPage(void) throw( uno::RuntimeException )
1533cdf0e10cSrcweir {
1534cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1535cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1536cdf0e10cSrcweir     if(m_pView)
1537cdf0e10cSrcweir     {
1538cdf0e10cSrcweir         SwWrtShell& rSh = m_pView->GetWrtShell();
1539cdf0e10cSrcweir         if (rSh.IsSelFrmMode())
1540cdf0e10cSrcweir         {
1541cdf0e10cSrcweir             rSh.UnSelectFrm();
1542cdf0e10cSrcweir             rSh.LeaveSelFrmMode();
1543cdf0e10cSrcweir         }
1544cdf0e10cSrcweir         rSh.EnterStdMode();
1545cdf0e10cSrcweir         bRet = rSh.SttEndDoc(sal_True);
1546cdf0e10cSrcweir     }
1547cdf0e10cSrcweir 	else
1548cdf0e10cSrcweir 		throw uno::RuntimeException();
1549cdf0e10cSrcweir 	return bRet;
1550cdf0e10cSrcweir }
1551cdf0e10cSrcweir /*-- 17.12.98 09:36:29---------------------------------------------------
1552cdf0e10cSrcweir 
1553cdf0e10cSrcweir   -----------------------------------------------------------------------*/
jumpToLastPage(void)1554cdf0e10cSrcweir sal_Bool SwXTextViewCursor::jumpToLastPage(void) throw( uno::RuntimeException )
1555cdf0e10cSrcweir {
1556cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1557cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1558cdf0e10cSrcweir     if(m_pView)
1559cdf0e10cSrcweir 	{
1560cdf0e10cSrcweir         SwWrtShell& rSh = m_pView->GetWrtShell();
1561cdf0e10cSrcweir         if (rSh.IsSelFrmMode())
1562cdf0e10cSrcweir         {
1563cdf0e10cSrcweir             rSh.UnSelectFrm();
1564cdf0e10cSrcweir             rSh.LeaveSelFrmMode();
1565cdf0e10cSrcweir         }
1566cdf0e10cSrcweir         rSh.EnterStdMode();
1567cdf0e10cSrcweir         bRet = rSh.SttEndDoc(sal_False);
1568cdf0e10cSrcweir 		rSh.SttPg();
1569cdf0e10cSrcweir 	}
1570cdf0e10cSrcweir 	else
1571cdf0e10cSrcweir 		throw uno::RuntimeException();
1572cdf0e10cSrcweir 	return bRet;
1573cdf0e10cSrcweir }
1574cdf0e10cSrcweir /*-- 17.12.98 09:36:30---------------------------------------------------
1575cdf0e10cSrcweir 
1576cdf0e10cSrcweir   -----------------------------------------------------------------------*/
jumpToPage(sal_Int16 nPage)1577cdf0e10cSrcweir sal_Bool SwXTextViewCursor::jumpToPage(sal_Int16 nPage) throw( uno::RuntimeException )
1578cdf0e10cSrcweir {
1579cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1580cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1581cdf0e10cSrcweir     if(m_pView)
1582cdf0e10cSrcweir         bRet = m_pView->GetWrtShell().GotoPage(nPage, sal_True);
1583cdf0e10cSrcweir 	else
1584cdf0e10cSrcweir 		throw uno::RuntimeException();
1585cdf0e10cSrcweir 	return bRet;
1586cdf0e10cSrcweir }
1587cdf0e10cSrcweir /*-- 17.12.98 09:36:30---------------------------------------------------
1588cdf0e10cSrcweir 
1589cdf0e10cSrcweir   -----------------------------------------------------------------------*/
jumpToNextPage(void)1590cdf0e10cSrcweir sal_Bool SwXTextViewCursor::jumpToNextPage(void) throw( uno::RuntimeException )
1591cdf0e10cSrcweir {
1592cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1593cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1594cdf0e10cSrcweir     if(m_pView)
1595cdf0e10cSrcweir         bRet = m_pView->GetWrtShell().SttNxtPg();
1596cdf0e10cSrcweir 	else
1597cdf0e10cSrcweir 		throw uno::RuntimeException();
1598cdf0e10cSrcweir 	return bRet;
1599cdf0e10cSrcweir }
1600cdf0e10cSrcweir /*-- 17.12.98 09:36:31---------------------------------------------------
1601cdf0e10cSrcweir 
1602cdf0e10cSrcweir   -----------------------------------------------------------------------*/
jumpToPreviousPage(void)1603cdf0e10cSrcweir sal_Bool SwXTextViewCursor::jumpToPreviousPage(void) throw( uno::RuntimeException )
1604cdf0e10cSrcweir {
1605cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1606cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1607cdf0e10cSrcweir     if(m_pView)
1608cdf0e10cSrcweir         bRet = m_pView->GetWrtShell().EndPrvPg();
1609cdf0e10cSrcweir 	else
1610cdf0e10cSrcweir 		throw uno::RuntimeException();
1611cdf0e10cSrcweir 	return bRet;
1612cdf0e10cSrcweir }
1613cdf0e10cSrcweir /*-- 17.12.98 09:36:32---------------------------------------------------
1614cdf0e10cSrcweir 
1615cdf0e10cSrcweir   -----------------------------------------------------------------------*/
jumpToEndOfPage(void)1616cdf0e10cSrcweir sal_Bool SwXTextViewCursor::jumpToEndOfPage(void) throw( uno::RuntimeException )
1617cdf0e10cSrcweir {
1618cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1619cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1620cdf0e10cSrcweir     if(m_pView)
1621cdf0e10cSrcweir         bRet = m_pView->GetWrtShell().EndPg();
1622cdf0e10cSrcweir 	else
1623cdf0e10cSrcweir 		throw uno::RuntimeException();
1624cdf0e10cSrcweir 	return bRet;
1625cdf0e10cSrcweir }
1626cdf0e10cSrcweir /*-- 17.12.98 09:36:32---------------------------------------------------
1627cdf0e10cSrcweir 
1628cdf0e10cSrcweir   -----------------------------------------------------------------------*/
jumpToStartOfPage(void)1629cdf0e10cSrcweir sal_Bool SwXTextViewCursor::jumpToStartOfPage(void) throw( uno::RuntimeException )
1630cdf0e10cSrcweir {
1631cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1632cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1633cdf0e10cSrcweir     if(m_pView)
1634cdf0e10cSrcweir         bRet = m_pView->GetWrtShell().SttPg();
1635cdf0e10cSrcweir 	else
1636cdf0e10cSrcweir 		throw uno::RuntimeException();
1637cdf0e10cSrcweir 	return bRet;
1638cdf0e10cSrcweir }
1639cdf0e10cSrcweir /* -----------------04.10.99 14:21-------------------
1640cdf0e10cSrcweir 
1641cdf0e10cSrcweir  --------------------------------------------------*/
getPage(void)1642cdf0e10cSrcweir sal_Int16 SwXTextViewCursor::getPage(void) throw( uno::RuntimeException )
1643cdf0e10cSrcweir {
1644cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1645cdf0e10cSrcweir 	short nRet = 0;
1646cdf0e10cSrcweir     if(m_pView)
1647cdf0e10cSrcweir 	{
1648cdf0e10cSrcweir         SwWrtShell& rSh = m_pView->GetWrtShell();
1649cdf0e10cSrcweir         SwPaM* pShellCrsr = rSh.GetCrsr();
1650cdf0e10cSrcweir         nRet = (short)pShellCrsr->GetPageNum( sal_True, 0 );
1651cdf0e10cSrcweir     }
1652cdf0e10cSrcweir 	else
1653cdf0e10cSrcweir 		throw uno::RuntimeException();
1654cdf0e10cSrcweir 	return nRet;
1655cdf0e10cSrcweir }
1656cdf0e10cSrcweir /*-- 17.12.98 09:36:33---------------------------------------------------
1657cdf0e10cSrcweir 
1658cdf0e10cSrcweir   -----------------------------------------------------------------------*/
screenDown(void)1659cdf0e10cSrcweir sal_Bool SwXTextViewCursor::screenDown(void) throw( uno::RuntimeException )
1660cdf0e10cSrcweir {
1661cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1662cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1663cdf0e10cSrcweir     if(m_pView)
1664cdf0e10cSrcweir 	{
1665cdf0e10cSrcweir         SfxRequest aReq(FN_PAGEDOWN, SFX_CALLMODE_SLOT, m_pView->GetPool());
1666cdf0e10cSrcweir         m_pView->Execute(aReq);
1667cdf0e10cSrcweir 		const SfxPoolItem* pRet = aReq.GetReturnValue();
1668cdf0e10cSrcweir 		bRet = pRet && ((const SfxBoolItem*)pRet)->GetValue();
1669cdf0e10cSrcweir 	}
1670cdf0e10cSrcweir 	else
1671cdf0e10cSrcweir 		throw uno::RuntimeException();
1672cdf0e10cSrcweir 	return bRet;
1673cdf0e10cSrcweir }
1674cdf0e10cSrcweir /*-- 17.12.98 09:36:33---------------------------------------------------
1675cdf0e10cSrcweir 
1676cdf0e10cSrcweir   -----------------------------------------------------------------------*/
screenUp(void)1677cdf0e10cSrcweir sal_Bool SwXTextViewCursor::screenUp(void) throw( uno::RuntimeException )
1678cdf0e10cSrcweir {
1679cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1680cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1681cdf0e10cSrcweir     if(m_pView)
1682cdf0e10cSrcweir 	{
1683cdf0e10cSrcweir         SfxRequest aReq(FN_PAGEUP, SFX_CALLMODE_SLOT, m_pView->GetPool());
1684cdf0e10cSrcweir         m_pView->Execute(aReq);
1685cdf0e10cSrcweir 		const SfxPoolItem* pRet = aReq.GetReturnValue();
1686cdf0e10cSrcweir 		bRet = pRet && ((const SfxBoolItem*)pRet)->GetValue();
1687cdf0e10cSrcweir 	}
1688cdf0e10cSrcweir 	else
1689cdf0e10cSrcweir 		throw uno::RuntimeException();
1690cdf0e10cSrcweir 	return bRet;
1691cdf0e10cSrcweir }
1692cdf0e10cSrcweir /*-- 17.12.98 11:59:05---------------------------------------------------
1693cdf0e10cSrcweir 
1694cdf0e10cSrcweir   -----------------------------------------------------------------------*/
getText(void)1695cdf0e10cSrcweir uno::Reference< text::XText >  SwXTextViewCursor::getText(void) throw( uno::RuntimeException )
1696cdf0e10cSrcweir {
1697cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1698cdf0e10cSrcweir 	uno::Reference< text::XText >  xRet;
1699cdf0e10cSrcweir     if(m_pView)
1700cdf0e10cSrcweir 	{
1701cdf0e10cSrcweir         if (!IsTextSelection( sal_False ))
1702cdf0e10cSrcweir             throw  uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
1703cdf0e10cSrcweir 
1704cdf0e10cSrcweir         SwWrtShell& rSh = m_pView->GetWrtShell();
1705cdf0e10cSrcweir 		SwPaM* pShellCrsr = rSh.GetCrsr();
1706cdf0e10cSrcweir         SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
1707cdf0e10cSrcweir         xRet = ::sw::CreateParentXText(*pDoc, *pShellCrsr->Start());
1708cdf0e10cSrcweir 	}
1709cdf0e10cSrcweir 	else
1710cdf0e10cSrcweir 		throw uno::RuntimeException();
1711cdf0e10cSrcweir 	return xRet;
1712cdf0e10cSrcweir }
1713cdf0e10cSrcweir /*-- 17.12.98 11:59:05---------------------------------------------------
1714cdf0e10cSrcweir 
1715cdf0e10cSrcweir   -----------------------------------------------------------------------*/
getStart(void)1716cdf0e10cSrcweir uno::Reference< text::XTextRange >  SwXTextViewCursor::getStart(void) throw( uno::RuntimeException )
1717cdf0e10cSrcweir {
1718cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1719cdf0e10cSrcweir 	uno::Reference< text::XTextRange >  xRet;
1720cdf0e10cSrcweir     if(m_pView)
1721cdf0e10cSrcweir 	{
1722cdf0e10cSrcweir         if (!IsTextSelection())
1723cdf0e10cSrcweir             throw  uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
1724cdf0e10cSrcweir 
1725cdf0e10cSrcweir         SwWrtShell& rSh = m_pView->GetWrtShell();
1726cdf0e10cSrcweir 		SwPaM* pShellCrsr = rSh.GetCrsr();
1727cdf0e10cSrcweir         SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
1728cdf0e10cSrcweir         xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCrsr->Start(), 0);
1729cdf0e10cSrcweir 	}
1730cdf0e10cSrcweir 	else
1731cdf0e10cSrcweir 		throw uno::RuntimeException();
1732cdf0e10cSrcweir 	return xRet;
1733cdf0e10cSrcweir }
1734cdf0e10cSrcweir /*-- 17.12.98 11:59:06---------------------------------------------------
1735cdf0e10cSrcweir 
1736cdf0e10cSrcweir   -----------------------------------------------------------------------*/
getEnd(void)1737cdf0e10cSrcweir uno::Reference< text::XTextRange >  SwXTextViewCursor::getEnd(void) throw( uno::RuntimeException )
1738cdf0e10cSrcweir {
1739cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1740cdf0e10cSrcweir 	uno::Reference< text::XTextRange >  xRet;
1741cdf0e10cSrcweir     if(m_pView)
1742cdf0e10cSrcweir 	{
1743cdf0e10cSrcweir         if (!IsTextSelection())
1744cdf0e10cSrcweir             throw  uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
1745cdf0e10cSrcweir 
1746cdf0e10cSrcweir         SwWrtShell& rSh = m_pView->GetWrtShell();
1747cdf0e10cSrcweir 		SwPaM* pShellCrsr = rSh.GetCrsr();
1748cdf0e10cSrcweir         SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
1749cdf0e10cSrcweir         xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCrsr->End(), 0);
1750cdf0e10cSrcweir 	}
1751cdf0e10cSrcweir 	else
1752cdf0e10cSrcweir 		throw uno::RuntimeException();
1753cdf0e10cSrcweir 	return xRet;
1754cdf0e10cSrcweir }
1755cdf0e10cSrcweir /* -----------------12.10.99 09:03-------------------
1756cdf0e10cSrcweir 
1757cdf0e10cSrcweir  --------------------------------------------------*/
getString(void)1758cdf0e10cSrcweir OUString SwXTextViewCursor::getString(void) throw( uno::RuntimeException )
1759cdf0e10cSrcweir {
1760cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1761cdf0e10cSrcweir 	OUString uRet;
1762cdf0e10cSrcweir     if(m_pView)
1763cdf0e10cSrcweir 	{
1764cdf0e10cSrcweir         if (!IsTextSelection( sal_False ))
1765cdf0e10cSrcweir             throw  uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
1766cdf0e10cSrcweir 
1767cdf0e10cSrcweir         ShellModes  eSelMode = m_pView->GetShellMode();
1768cdf0e10cSrcweir 		switch(eSelMode)
1769cdf0e10cSrcweir         {
1770cdf0e10cSrcweir             //! since setString for SEL_TABLE_TEXT (with possible
1771cdf0e10cSrcweir             //! multi selection of cells) would not work properly we
1772cdf0e10cSrcweir             //! will ignore this case for both
1773cdf0e10cSrcweir             //! functions (setString AND getString) because of symmetrie.
1774cdf0e10cSrcweir 
1775cdf0e10cSrcweir 			case SHELL_MODE_LIST_TEXT       :
1776cdf0e10cSrcweir 			case SHELL_MODE_TABLE_LIST_TEXT:
1777cdf0e10cSrcweir 			case SHELL_MODE_TEXT            :
1778cdf0e10cSrcweir 			{
1779cdf0e10cSrcweir                 SwWrtShell& rSh = m_pView->GetWrtShell();
1780cdf0e10cSrcweir 				SwPaM* pShellCrsr = rSh.GetCrsr();
1781cdf0e10cSrcweir                 SwUnoCursorHelper::GetTextFromPam(*pShellCrsr, uRet);
1782cdf0e10cSrcweir 			}
1783cdf0e10cSrcweir             default:;//prevent warning
1784cdf0e10cSrcweir         }
1785cdf0e10cSrcweir 	}
1786cdf0e10cSrcweir 	return uRet;
1787cdf0e10cSrcweir }
1788cdf0e10cSrcweir /*-- 17.12.98 11:59:06---------------------------------------------------
1789cdf0e10cSrcweir 
1790cdf0e10cSrcweir   -----------------------------------------------------------------------*/
setString(const OUString & aString)1791cdf0e10cSrcweir void SwXTextViewCursor::setString(const OUString& aString) throw( uno::RuntimeException )
1792cdf0e10cSrcweir {
1793cdf0e10cSrcweir     ::vos::OGuard aGuard(Application::GetSolarMutex());
1794cdf0e10cSrcweir     if(m_pView)
1795cdf0e10cSrcweir     {
1796cdf0e10cSrcweir         if (!IsTextSelection( sal_False ))
1797cdf0e10cSrcweir             throw  uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
1798cdf0e10cSrcweir 
1799cdf0e10cSrcweir         ShellModes  eSelMode = m_pView->GetShellMode();
1800cdf0e10cSrcweir         switch(eSelMode)
1801cdf0e10cSrcweir         {
1802cdf0e10cSrcweir             //! since setString for SEL_TABLE_TEXT (with possible
1803cdf0e10cSrcweir             //! multi selection of cells) would not work properly we
1804cdf0e10cSrcweir             //! will ignore this case for both
1805cdf0e10cSrcweir             //! functions (setString AND getString) because of symmetrie.
1806cdf0e10cSrcweir 
1807cdf0e10cSrcweir             case SHELL_MODE_LIST_TEXT       :
1808cdf0e10cSrcweir             case SHELL_MODE_TABLE_LIST_TEXT :
1809cdf0e10cSrcweir             case SHELL_MODE_TEXT            :
1810cdf0e10cSrcweir             {
1811cdf0e10cSrcweir                 SwWrtShell& rSh = m_pView->GetWrtShell();
1812cdf0e10cSrcweir                 SwCursor* pShellCrsr = rSh.GetSwCrsr();
1813cdf0e10cSrcweir                 SwUnoCursorHelper::SetString(*pShellCrsr, aString);
1814cdf0e10cSrcweir             }
1815cdf0e10cSrcweir             default:;//prevent warning
1816cdf0e10cSrcweir         }
1817cdf0e10cSrcweir     }
1818cdf0e10cSrcweir }
1819cdf0e10cSrcweir 
1820cdf0e10cSrcweir /*-- 29.06.00 17:33:38---------------------------------------------------
1821cdf0e10cSrcweir 
1822cdf0e10cSrcweir   -----------------------------------------------------------------------*/
getPropertySetInfo()1823cdf0e10cSrcweir uno::Reference< XPropertySetInfo >  SwXTextViewCursor::getPropertySetInfo(  ) throw(RuntimeException)
1824cdf0e10cSrcweir {
1825cdf0e10cSrcweir     static uno::Reference< XPropertySetInfo >  xRef = m_pPropSet->getPropertySetInfo();
1826cdf0e10cSrcweir 	return xRef;
1827cdf0e10cSrcweir }
1828cdf0e10cSrcweir /*-- 29.06.00 17:33:39---------------------------------------------------
1829cdf0e10cSrcweir 
1830cdf0e10cSrcweir   -----------------------------------------------------------------------*/
setPropertyValue(const OUString & rPropertyName,const Any & aValue)1831cdf0e10cSrcweir void  SwXTextViewCursor::setPropertyValue( const OUString& rPropertyName, const Any& aValue )
1832cdf0e10cSrcweir 							throw(UnknownPropertyException, PropertyVetoException,
1833cdf0e10cSrcweir 								IllegalArgumentException, WrappedTargetException, RuntimeException)
1834cdf0e10cSrcweir {
1835cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1836cdf0e10cSrcweir     if(m_pView)
1837cdf0e10cSrcweir 	{
1838cdf0e10cSrcweir         SwWrtShell& rSh = m_pView->GetWrtShell();
1839cdf0e10cSrcweir 		SwPaM* pShellCrsr = rSh.GetCrsr();
1840cdf0e10cSrcweir 		SwNode *pNode = pShellCrsr->GetNode();
1841cdf0e10cSrcweir 		if (pNode && pNode->IsTxtNode())
1842cdf0e10cSrcweir         {
1843cdf0e10cSrcweir             SwUnoCursorHelper::SetPropertyValue(
1844cdf0e10cSrcweir                 *pShellCrsr, *m_pPropSet, rPropertyName, aValue );
1845cdf0e10cSrcweir         }
1846cdf0e10cSrcweir 		else
1847cdf0e10cSrcweir 			throw RuntimeException();
1848cdf0e10cSrcweir 	}
1849cdf0e10cSrcweir 	else
1850cdf0e10cSrcweir 		throw RuntimeException();
1851cdf0e10cSrcweir }
1852cdf0e10cSrcweir /*-- 29.06.00 17:33:39---------------------------------------------------
1853cdf0e10cSrcweir 
1854cdf0e10cSrcweir   -----------------------------------------------------------------------*/
getPropertyValue(const OUString & rPropertyName)1855cdf0e10cSrcweir Any  SwXTextViewCursor::getPropertyValue( const OUString& rPropertyName )
1856cdf0e10cSrcweir 				throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
1857cdf0e10cSrcweir {
1858cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1859cdf0e10cSrcweir 	Any aRet;
1860cdf0e10cSrcweir     if(m_pView)
1861cdf0e10cSrcweir 	{
1862cdf0e10cSrcweir         SwWrtShell& rSh = m_pView->GetWrtShell();
1863cdf0e10cSrcweir 		SwPaM* pShellCrsr = rSh.GetCrsr();
1864cdf0e10cSrcweir         aRet = SwUnoCursorHelper::GetPropertyValue(
1865cdf0e10cSrcweir                 *pShellCrsr, *m_pPropSet, rPropertyName);
1866cdf0e10cSrcweir 	}
1867cdf0e10cSrcweir 	else
1868cdf0e10cSrcweir 		throw RuntimeException();
1869cdf0e10cSrcweir 	return aRet;
1870cdf0e10cSrcweir }
1871cdf0e10cSrcweir /*-- 29.06.00 17:33:40---------------------------------------------------
1872cdf0e10cSrcweir 
1873cdf0e10cSrcweir   -----------------------------------------------------------------------*/
addPropertyChangeListener(const OUString &,const uno::Reference<XPropertyChangeListener> &)1874cdf0e10cSrcweir void  SwXTextViewCursor::addPropertyChangeListener(
1875cdf0e10cSrcweir     const OUString& /*aPropertyName*/, const uno::Reference< XPropertyChangeListener >& /*xListener*/ )
1876cdf0e10cSrcweir 		throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
1877cdf0e10cSrcweir {
1878cdf0e10cSrcweir }
1879cdf0e10cSrcweir /*-- 29.06.00 17:33:40---------------------------------------------------
1880cdf0e10cSrcweir 
1881cdf0e10cSrcweir   -----------------------------------------------------------------------*/
removePropertyChangeListener(const OUString &,const uno::Reference<XPropertyChangeListener> &)1882cdf0e10cSrcweir void  SwXTextViewCursor::removePropertyChangeListener(
1883cdf0e10cSrcweir     const OUString& /*aPropertyName*/, const uno::Reference< XPropertyChangeListener >& /*aListener*/ )
1884cdf0e10cSrcweir 		throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
1885cdf0e10cSrcweir {
1886cdf0e10cSrcweir }
1887cdf0e10cSrcweir /*-- 29.06.00 17:33:41---------------------------------------------------
1888cdf0e10cSrcweir 
1889cdf0e10cSrcweir   -----------------------------------------------------------------------*/
addVetoableChangeListener(const OUString &,const uno::Reference<XVetoableChangeListener> &)1890cdf0e10cSrcweir void  SwXTextViewCursor::addVetoableChangeListener(
1891cdf0e10cSrcweir     const OUString& /*PropertyName*/, const uno::Reference< XVetoableChangeListener >& /*aListener*/ )
1892cdf0e10cSrcweir 		throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
1893cdf0e10cSrcweir {
1894cdf0e10cSrcweir }
1895cdf0e10cSrcweir /*-- 29.06.00 17:33:41---------------------------------------------------
1896cdf0e10cSrcweir 
1897cdf0e10cSrcweir   -----------------------------------------------------------------------*/
removeVetoableChangeListener(const OUString &,const uno::Reference<XVetoableChangeListener> &)1898cdf0e10cSrcweir void  SwXTextViewCursor::removeVetoableChangeListener(
1899cdf0e10cSrcweir     const OUString& /*PropertyName*/, const uno::Reference< XVetoableChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
1900cdf0e10cSrcweir {
1901cdf0e10cSrcweir }
1902cdf0e10cSrcweir /*-- 29.06.00 17:33:41---------------------------------------------------
1903cdf0e10cSrcweir 
1904cdf0e10cSrcweir   -----------------------------------------------------------------------*/
getPropertyState(const OUString & rPropertyName)1905cdf0e10cSrcweir PropertyState  SwXTextViewCursor::getPropertyState( const OUString& rPropertyName )
1906cdf0e10cSrcweir     throw(UnknownPropertyException, RuntimeException)
1907cdf0e10cSrcweir {
1908cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1909cdf0e10cSrcweir 	PropertyState eState;
1910cdf0e10cSrcweir     if(m_pView)
1911cdf0e10cSrcweir 	{
1912cdf0e10cSrcweir         SwWrtShell& rSh = m_pView->GetWrtShell();
1913cdf0e10cSrcweir 		SwPaM* pShellCrsr = rSh.GetCrsr();
1914cdf0e10cSrcweir         eState = SwUnoCursorHelper::GetPropertyState(
1915cdf0e10cSrcweir                 *pShellCrsr, *m_pPropSet, rPropertyName);
1916cdf0e10cSrcweir 	}
1917cdf0e10cSrcweir 	else
1918cdf0e10cSrcweir 		throw RuntimeException();
1919cdf0e10cSrcweir 	return eState;
1920cdf0e10cSrcweir }
1921cdf0e10cSrcweir /*-- 29.06.00 17:33:42---------------------------------------------------
1922cdf0e10cSrcweir 
1923cdf0e10cSrcweir   -----------------------------------------------------------------------*/
getPropertyStates(const Sequence<OUString> & rPropertyNames)1924cdf0e10cSrcweir Sequence< PropertyState >  SwXTextViewCursor::getPropertyStates(
1925cdf0e10cSrcweir 	const Sequence< OUString >& rPropertyNames ) throw(UnknownPropertyException, RuntimeException)
1926cdf0e10cSrcweir {
1927cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1928cdf0e10cSrcweir 	Sequence< PropertyState >  aRet;
1929cdf0e10cSrcweir     if(m_pView)
1930cdf0e10cSrcweir 	{
1931cdf0e10cSrcweir         SwWrtShell& rSh = m_pView->GetWrtShell();
1932cdf0e10cSrcweir 		SwPaM* pShellCrsr = rSh.GetCrsr();
1933cdf0e10cSrcweir         aRet = SwUnoCursorHelper::GetPropertyStates(
1934cdf0e10cSrcweir                 *pShellCrsr, *m_pPropSet,  rPropertyNames);
1935cdf0e10cSrcweir 	}
1936cdf0e10cSrcweir 	return aRet;
1937cdf0e10cSrcweir }
1938cdf0e10cSrcweir /*-- 29.06.00 17:33:42---------------------------------------------------
1939cdf0e10cSrcweir 
1940cdf0e10cSrcweir   -----------------------------------------------------------------------*/
setPropertyToDefault(const OUString & rPropertyName)1941cdf0e10cSrcweir void  SwXTextViewCursor::setPropertyToDefault( const OUString& rPropertyName )
1942cdf0e10cSrcweir 										throw(UnknownPropertyException, RuntimeException)
1943cdf0e10cSrcweir {
1944cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1945cdf0e10cSrcweir     if(m_pView)
1946cdf0e10cSrcweir 	{
1947cdf0e10cSrcweir         SwWrtShell& rSh = m_pView->GetWrtShell();
1948cdf0e10cSrcweir 		SwPaM* pShellCrsr = rSh.GetCrsr();
1949cdf0e10cSrcweir         SwUnoCursorHelper::SetPropertyToDefault(
1950cdf0e10cSrcweir                 *pShellCrsr, *m_pPropSet, rPropertyName);
1951cdf0e10cSrcweir 	}
1952cdf0e10cSrcweir }
1953cdf0e10cSrcweir /*-- 29.06.00 17:33:43---------------------------------------------------
1954cdf0e10cSrcweir 
1955cdf0e10cSrcweir   -----------------------------------------------------------------------*/
getPropertyDefault(const OUString & rPropertyName)1956cdf0e10cSrcweir Any  SwXTextViewCursor::getPropertyDefault( const OUString& rPropertyName )
1957cdf0e10cSrcweir 						throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
1958cdf0e10cSrcweir {
1959cdf0e10cSrcweir 	Any aRet;
1960cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1961cdf0e10cSrcweir     if(m_pView)
1962cdf0e10cSrcweir 	{
1963cdf0e10cSrcweir         SwWrtShell& rSh = m_pView->GetWrtShell();
1964cdf0e10cSrcweir 		SwPaM* pShellCrsr = rSh.GetCrsr();
1965cdf0e10cSrcweir         aRet = SwUnoCursorHelper::GetPropertyDefault(
1966cdf0e10cSrcweir                 *pShellCrsr, *m_pPropSet, rPropertyName);
1967cdf0e10cSrcweir 	}
1968cdf0e10cSrcweir 	return aRet;
1969cdf0e10cSrcweir }
1970cdf0e10cSrcweir /*-- 28.09.99 08:31:19---------------------------------------------------
1971cdf0e10cSrcweir 
1972cdf0e10cSrcweir   -----------------------------------------------------------------------*/
goDown(sal_Int16 nCount,sal_Bool bExpand)1973cdf0e10cSrcweir sal_Bool SwXTextViewCursor::goDown(sal_Int16 nCount, sal_Bool bExpand) throw( uno::RuntimeException )
1974cdf0e10cSrcweir {
1975cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1976cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1977cdf0e10cSrcweir     if(m_pView)
1978cdf0e10cSrcweir 	{
1979cdf0e10cSrcweir         if (!IsTextSelection())
1980cdf0e10cSrcweir             throw  uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
1981cdf0e10cSrcweir 
1982cdf0e10cSrcweir 		for( sal_uInt16 i = 0; i < nCount; i++ )
1983cdf0e10cSrcweir             bRet = m_pView->GetWrtShell().Down( bExpand, 1, sal_True );
1984cdf0e10cSrcweir 	}
1985cdf0e10cSrcweir 	else
1986cdf0e10cSrcweir 		throw uno::RuntimeException();
1987cdf0e10cSrcweir 	return bRet;
1988cdf0e10cSrcweir }
1989cdf0e10cSrcweir /*-- 28.09.99 08:31:20---------------------------------------------------
1990cdf0e10cSrcweir 
1991cdf0e10cSrcweir   -----------------------------------------------------------------------*/
goUp(sal_Int16 nCount,sal_Bool bExpand)1992cdf0e10cSrcweir sal_Bool SwXTextViewCursor::goUp(sal_Int16 nCount, sal_Bool bExpand) throw( uno::RuntimeException )
1993cdf0e10cSrcweir {
1994cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
1995cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1996cdf0e10cSrcweir     if(m_pView)
1997cdf0e10cSrcweir 	{
1998cdf0e10cSrcweir         if (!IsTextSelection())
1999cdf0e10cSrcweir             throw  uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
2000cdf0e10cSrcweir 
2001cdf0e10cSrcweir 		for( sal_uInt16 i = 0; i < nCount; i++ )
2002cdf0e10cSrcweir             bRet = m_pView->GetWrtShell().Up( bExpand, 1, sal_True );
2003cdf0e10cSrcweir 	}
2004cdf0e10cSrcweir 	else
2005cdf0e10cSrcweir 		throw uno::RuntimeException();
2006cdf0e10cSrcweir 	return bRet;
2007cdf0e10cSrcweir }
2008cdf0e10cSrcweir /*-- 28.09.99 08:31:20---------------------------------------------------
2009cdf0e10cSrcweir 
2010cdf0e10cSrcweir   -----------------------------------------------------------------------*/
isAtStartOfLine(void)2011cdf0e10cSrcweir sal_Bool SwXTextViewCursor::isAtStartOfLine(void) throw( uno::RuntimeException )
2012cdf0e10cSrcweir {
2013cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
2014cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
2015cdf0e10cSrcweir     if(m_pView)
2016cdf0e10cSrcweir 	{
2017cdf0e10cSrcweir         if (!IsTextSelection( sal_False ))
2018cdf0e10cSrcweir             throw  uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
2019cdf0e10cSrcweir 
2020cdf0e10cSrcweir         bRet = m_pView->GetWrtShell().IsAtLeftMargin();
2021cdf0e10cSrcweir 	}
2022cdf0e10cSrcweir 	else
2023cdf0e10cSrcweir 		throw uno::RuntimeException();
2024cdf0e10cSrcweir 	return bRet;
2025cdf0e10cSrcweir }
2026cdf0e10cSrcweir /*-- 28.09.99 08:31:21---------------------------------------------------
2027cdf0e10cSrcweir 
2028cdf0e10cSrcweir   -----------------------------------------------------------------------*/
isAtEndOfLine(void)2029cdf0e10cSrcweir sal_Bool SwXTextViewCursor::isAtEndOfLine(void) throw( uno::RuntimeException )
2030cdf0e10cSrcweir {
2031cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
2032cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
2033cdf0e10cSrcweir     if(m_pView)
2034cdf0e10cSrcweir 	{
2035cdf0e10cSrcweir         if (!IsTextSelection( sal_False ))
2036cdf0e10cSrcweir             throw  uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
2037cdf0e10cSrcweir 
2038cdf0e10cSrcweir         bRet = m_pView->GetWrtShell().IsAtRightMargin(sal_True);
2039cdf0e10cSrcweir 	}
2040cdf0e10cSrcweir 	else
2041cdf0e10cSrcweir 		throw uno::RuntimeException();
2042cdf0e10cSrcweir 	return bRet;
2043cdf0e10cSrcweir }
2044cdf0e10cSrcweir /*-- 28.09.99 08:31:21---------------------------------------------------
2045cdf0e10cSrcweir 
2046cdf0e10cSrcweir   -----------------------------------------------------------------------*/
gotoEndOfLine(sal_Bool bExpand)2047cdf0e10cSrcweir void SwXTextViewCursor::gotoEndOfLine(sal_Bool bExpand) throw( uno::RuntimeException )
2048cdf0e10cSrcweir {
2049cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
2050cdf0e10cSrcweir     if(m_pView)
2051cdf0e10cSrcweir     {
2052cdf0e10cSrcweir         if (!IsTextSelection( sal_False ))
2053cdf0e10cSrcweir             throw  uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
2054cdf0e10cSrcweir 
2055cdf0e10cSrcweir         m_pView->GetWrtShell().RightMargin(bExpand, sal_True);
2056cdf0e10cSrcweir     }
2057cdf0e10cSrcweir 	else
2058cdf0e10cSrcweir 		throw uno::RuntimeException();
2059cdf0e10cSrcweir }
2060cdf0e10cSrcweir /*-- 28.09.99 08:31:22---------------------------------------------------
2061cdf0e10cSrcweir 
2062cdf0e10cSrcweir   -----------------------------------------------------------------------*/
gotoStartOfLine(sal_Bool bExpand)2063cdf0e10cSrcweir void SwXTextViewCursor::gotoStartOfLine(sal_Bool bExpand) throw( uno::RuntimeException )
2064cdf0e10cSrcweir {
2065cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
2066cdf0e10cSrcweir     if(m_pView)
2067cdf0e10cSrcweir     {
2068cdf0e10cSrcweir         if (!IsTextSelection( sal_False ))
2069cdf0e10cSrcweir             throw  uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
2070cdf0e10cSrcweir 
2071cdf0e10cSrcweir         m_pView->GetWrtShell().LeftMargin(bExpand, sal_True);
2072cdf0e10cSrcweir     }
2073cdf0e10cSrcweir 	else
2074cdf0e10cSrcweir 		throw uno::RuntimeException();
2075cdf0e10cSrcweir }
2076cdf0e10cSrcweir /* -----------------------------06.04.00 11:07--------------------------------
2077cdf0e10cSrcweir 
2078cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
getImplementationName(void)2079cdf0e10cSrcweir OUString SwXTextViewCursor::getImplementationName(void) throw( RuntimeException )
2080cdf0e10cSrcweir {
2081cdf0e10cSrcweir 	return C2U("SwXTextViewCursor");
2082cdf0e10cSrcweir }
2083cdf0e10cSrcweir /* -----------------------------06.04.00 11:07--------------------------------
2084cdf0e10cSrcweir 
2085cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
supportsService(const OUString & rServiceName)2086cdf0e10cSrcweir sal_Bool SwXTextViewCursor::supportsService(const OUString& rServiceName) throw( RuntimeException )
2087cdf0e10cSrcweir {
2088cdf0e10cSrcweir     return !rServiceName.compareToAscii("com.sun.star.text.TextViewCursor") ||
2089cdf0e10cSrcweir             !rServiceName.compareToAscii("com.sun.star.style.CharacterProperties") ||
2090cdf0e10cSrcweir             !rServiceName.compareToAscii("com.sun.star.style.CharacterPropertiesAsian") ||
2091cdf0e10cSrcweir             !rServiceName.compareToAscii("com.sun.star.style.CharacterPropertiesComplex") ||
2092cdf0e10cSrcweir             !rServiceName.compareToAscii("com.sun.star.style.ParagraphProperties") ||
2093cdf0e10cSrcweir             !rServiceName.compareToAscii("com.sun.star.style.ParagraphPropertiesAsian") ||
2094cdf0e10cSrcweir             !rServiceName.compareToAscii("com.sun.star.style.ParagraphPropertiesComplex");
2095cdf0e10cSrcweir }
2096cdf0e10cSrcweir /* -----------------------------06.04.00 11:07--------------------------------
2097cdf0e10cSrcweir 
2098cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
getSupportedServiceNames(void)2099cdf0e10cSrcweir Sequence< OUString > SwXTextViewCursor::getSupportedServiceNames(void) throw( RuntimeException )
2100cdf0e10cSrcweir {
2101cdf0e10cSrcweir     Sequence< OUString > aRet(7);
2102cdf0e10cSrcweir 	OUString* pArray = aRet.getArray();
2103cdf0e10cSrcweir 	pArray[0] = C2U("com.sun.star.text.TextViewCursor");
2104cdf0e10cSrcweir     pArray[1] = C2U("com.sun.star.style.CharacterProperties");
2105cdf0e10cSrcweir     pArray[2] = C2U("com.sun.star.style.CharacterPropertiesAsian");
2106cdf0e10cSrcweir     pArray[3] = C2U("com.sun.star.style.CharacterPropertiesComplex");
2107cdf0e10cSrcweir     pArray[4] = C2U("com.sun.star.style.ParagraphProperties");
2108cdf0e10cSrcweir     pArray[5] = C2U("com.sun.star.style.ParagraphPropertiesAsian");
2109cdf0e10cSrcweir     pArray[6] = C2U("com.sun.star.style.ParagraphPropertiesComplex");
2110cdf0e10cSrcweir     return aRet;
2111cdf0e10cSrcweir }
2112cdf0e10cSrcweir /* -----------------------------03.03.03 11:07--------------------------------
2113cdf0e10cSrcweir 
2114cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
getUnoTunnelId()2115cdf0e10cSrcweir const uno::Sequence< sal_Int8 > & SwXTextViewCursor::getUnoTunnelId()
2116cdf0e10cSrcweir {
2117cdf0e10cSrcweir     static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
2118cdf0e10cSrcweir 	return aSeq;
2119cdf0e10cSrcweir }
2120cdf0e10cSrcweir /* -----------------------------03.03.03 11:07--------------------------------
2121cdf0e10cSrcweir 
2122cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
2123cdf0e10cSrcweir //XUnoTunnel
getSomething(const uno::Sequence<sal_Int8> & rId)2124cdf0e10cSrcweir sal_Int64 SAL_CALL SwXTextViewCursor::getSomething(
2125cdf0e10cSrcweir 	const uno::Sequence< sal_Int8 >& rId )
2126cdf0e10cSrcweir 		throw(uno::RuntimeException)
2127cdf0e10cSrcweir {
2128cdf0e10cSrcweir     if( rId.getLength() == 16
2129cdf0e10cSrcweir         && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
2130cdf0e10cSrcweir 										rId.getConstArray(), 16 ) )
2131cdf0e10cSrcweir         {
2132cdf0e10cSrcweir                 return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
2133cdf0e10cSrcweir         }
2134cdf0e10cSrcweir 	return OTextCursorHelper::getSomething(rId);;
2135cdf0e10cSrcweir }
2136cdf0e10cSrcweir // -----------------------------------------------------------------------------
2137cdf0e10cSrcweir 
IMPLEMENT_FORWARD_XINTERFACE2(SwXTextViewCursor,SwXTextViewCursor_Base,OTextCursorHelper) const2138cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2(SwXTextViewCursor,SwXTextViewCursor_Base,OTextCursorHelper)
2139cdf0e10cSrcweir const SwDoc* 		SwXTextViewCursor::GetDoc() const
2140cdf0e10cSrcweir {
2141cdf0e10cSrcweir     SwWrtShell& rSh = m_pView->GetWrtShell();
2142cdf0e10cSrcweir 	return	 rSh.GetCrsr() ? rSh.GetCrsr()->GetDoc() : 0;
2143cdf0e10cSrcweir }
2144cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetDoc()2145cdf0e10cSrcweir SwDoc* 	SwXTextViewCursor::GetDoc()
2146cdf0e10cSrcweir {
2147cdf0e10cSrcweir     SwWrtShell& rSh = m_pView->GetWrtShell();
2148cdf0e10cSrcweir 	return	 rSh.GetCrsr() ? rSh.GetCrsr()->GetDoc() : 0;
2149cdf0e10cSrcweir }
2150cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetPaM() const2151cdf0e10cSrcweir const SwPaM* 	SwXTextViewCursor::GetPaM() const
2152cdf0e10cSrcweir {
2153cdf0e10cSrcweir     SwWrtShell& rSh = m_pView->GetWrtShell();
2154cdf0e10cSrcweir 	return rSh.GetCrsr();
2155cdf0e10cSrcweir }
2156cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetPaM()2157cdf0e10cSrcweir SwPaM* 	SwXTextViewCursor::GetPaM()
2158cdf0e10cSrcweir {
2159cdf0e10cSrcweir     SwWrtShell& rSh = m_pView->GetWrtShell();
2160cdf0e10cSrcweir 	return rSh.GetCrsr();
2161cdf0e10cSrcweir }
2162cdf0e10cSrcweir 
getTransferable()2163cdf0e10cSrcweir uno::Reference< datatransfer::XTransferable > SAL_CALL SwXTextView::getTransferable(  ) throw (uno::RuntimeException)
2164cdf0e10cSrcweir {
2165cdf0e10cSrcweir 	::vos::OGuard aGuard(Application::GetSolarMutex());
2166cdf0e10cSrcweir 
2167cdf0e10cSrcweir     //force immediat shell update
2168cdf0e10cSrcweir     GetView()->StopShellTimer();
2169cdf0e10cSrcweir     SwWrtShell& rSh = GetView()->GetWrtShell();
2170cdf0e10cSrcweir     if ( GetView()->GetShellMode() == SHELL_MODE_DRAWTEXT )
2171cdf0e10cSrcweir     {
2172cdf0e10cSrcweir         SdrView *pSdrView = rSh.GetDrawView();
2173cdf0e10cSrcweir         OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
2174cdf0e10cSrcweir         return pOLV->GetEditView().GetTransferable();
2175cdf0e10cSrcweir     }
2176cdf0e10cSrcweir     else
2177cdf0e10cSrcweir     {
2178cdf0e10cSrcweir         SwTransferable* pTransfer = new SwTransferable( rSh );
2179cdf0e10cSrcweir         const sal_Bool bLockedView = rSh.IsViewLocked();
2180cdf0e10cSrcweir         rSh.LockView( sal_True );    //lock visible section
2181cdf0e10cSrcweir         pTransfer->PrepareForCopy();
2182cdf0e10cSrcweir         rSh.LockView( bLockedView );
2183cdf0e10cSrcweir         return uno::Reference< datatransfer::XTransferable >( pTransfer );
2184cdf0e10cSrcweir     }
2185cdf0e10cSrcweir }
2186cdf0e10cSrcweir 
insertTransferable(const uno::Reference<datatransfer::XTransferable> & xTrans)2187cdf0e10cSrcweir void SAL_CALL SwXTextView::insertTransferable( const uno::Reference< datatransfer::XTransferable >& xTrans ) throw (datatransfer::UnsupportedFlavorException, uno::RuntimeException)
2188cdf0e10cSrcweir {
2189cdf0e10cSrcweir     ::vos::OGuard aGuard(Application::GetSolarMutex());
2190cdf0e10cSrcweir 
2191cdf0e10cSrcweir     //force immediat shell update
2192cdf0e10cSrcweir     GetView()->StopShellTimer();
2193cdf0e10cSrcweir     SwWrtShell& rSh = GetView()->GetWrtShell();
2194cdf0e10cSrcweir     if ( GetView()->GetShellMode() == SHELL_MODE_DRAWTEXT )
2195cdf0e10cSrcweir     {
2196cdf0e10cSrcweir         SdrView *pSdrView = rSh.GetDrawView();
2197cdf0e10cSrcweir         OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
2198cdf0e10cSrcweir         pOLV->GetEditView().InsertText( xTrans, GetView()->GetDocShell()->GetMedium()->GetBaseURL(), sal_False );
2199cdf0e10cSrcweir     }
2200cdf0e10cSrcweir     else
2201cdf0e10cSrcweir     {
2202cdf0e10cSrcweir         TransferableDataHelper aDataHelper( xTrans );
2203cdf0e10cSrcweir         if ( SwTransferable::IsPaste( rSh, aDataHelper ) )
2204cdf0e10cSrcweir         {
2205cdf0e10cSrcweir             SwTransferable::Paste( rSh, aDataHelper );
2206cdf0e10cSrcweir             if( rSh.IsFrmSelected() || rSh.IsObjSelected() )
2207cdf0e10cSrcweir                 rSh.EnterSelFrmMode();
2208cdf0e10cSrcweir             GetView()->AttrChangedNotify( &rSh );
2209cdf0e10cSrcweir         }
2210cdf0e10cSrcweir     }
2211cdf0e10cSrcweir }
2212cdf0e10cSrcweir 
2213cdf0e10cSrcweir // -----------------------------------------------------------------------------
2214cdf0e10cSrcweir 
2215