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