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