1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unotxvw.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #include <sfx2/sfxbasecontroller.hxx>
33 #include <com/sun/star/embed/XEmbeddedObject.hpp>
34 #include <com/sun/star/text/XTextViewCursor.hpp>
35 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
36 #include <com/sun/star/text/XRubySelection.hpp>
37 #include <com/sun/star/view/XFormLayerAccess.hpp>
38 #include <com/sun/star/view/XScreenCursor.hpp>
39 #include <com/sun/star/view/XViewSettingsSupplier.hpp>
40 #include <com/sun/star/view/XSelectionSupplier.hpp>
41 #include <com/sun/star/view/XLineCursor.hpp>
42 #include <com/sun/star/view/XViewCursor.hpp>
43 #include <com/sun/star/text/XPageCursor.hpp>
44 #include <com/sun/star/beans/XPropertySet.hpp>
45 #include <com/sun/star/beans/XPropertySetInfo.hpp>
46 #include <com/sun/star/beans/XPropertyState.hpp>
47 #include <com/sun/star/lang/XServiceInfo.hpp>
48 #include <com/sun/star/datatransfer/XTransferableSupplier.hpp>
49 #include <cppuhelper/implbase8.hxx> // helper for implementations
50 #include <svtools/itemprop.hxx>
52 #include "TextCursorHelper.hxx"
53 #include <comphelper/uno3.hxx>
55 #include <sfx2/objsh.hxx>
60 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::view::XSelectionChangeListener
> * XSelectionChangeListenerPtr
;
61 SV_DECL_PTRARR_DEL( SelectionChangeListenerArr
, XSelectionChangeListenerPtr
, 4, 4 )
63 /******************************************************************************
65 ******************************************************************************/
67 public ::com::sun::star::view::XSelectionSupplier
,
68 public ::com::sun::star::lang::XServiceInfo
,
69 public ::com::sun::star::view::XFormLayerAccess
,
70 public ::com::sun::star::text::XTextViewCursorSupplier
,
71 public ::com::sun::star::text::XRubySelection
,
72 public ::com::sun::star::view::XViewSettingsSupplier
,
73 public ::com::sun::star::beans::XPropertySet
,
74 public ::com::sun::star::datatransfer::XTransferableSupplier
,
75 public SfxBaseController
77 SelectionChangeListenerArr aSelChangedListeners
;
80 const SfxItemPropertySet
* m_pPropSet
; // property map for SwXTextView properties
81 // (not related to pxViewSettings!)
83 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> * pxViewSettings
;
84 ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextViewCursor
> * pxTextViewCursor
;
87 SdrObject
* GetControl(
88 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlModel
> & Model
,
89 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControl
>& xToFill
);
92 virtual ~SwXTextView();
94 SwXTextView(SwView
* pSwView
);
97 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& aType
) throw(::com::sun::star::uno::RuntimeException
);
98 virtual void SAL_CALL
acquire( ) throw();
99 virtual void SAL_CALL
release( ) throw();
102 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes( ) throw(::com::sun::star::uno::RuntimeException
);
103 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId( ) throw(::com::sun::star::uno::RuntimeException
);
106 virtual ::com::sun::star::uno::Any SAL_CALL
getSelection(void) throw( ::com::sun::star::uno::RuntimeException
);
107 virtual sal_Bool SAL_CALL
select(const ::com::sun::star::uno::Any
& aInterface
) throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
108 virtual void SAL_CALL
addSelectionChangeListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::view::XSelectionChangeListener
> & xListener
) throw( ::com::sun::star::uno::RuntimeException
);
109 virtual void SAL_CALL
removeSelectionChangeListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::view::XSelectionChangeListener
> & xListener
) throw( ::com::sun::star::uno::RuntimeException
);
112 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::form::XFormController
> SAL_CALL
getFormController( const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XForm
>& Form
) throw (::com::sun::star::uno::RuntimeException
);
113 virtual ::sal_Bool SAL_CALL
isFormDesignMode( ) throw (::com::sun::star::uno::RuntimeException
);
114 virtual void SAL_CALL
setFormDesignMode( ::sal_Bool DesignMode
) throw (::com::sun::star::uno::RuntimeException
);
117 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControl
> SAL_CALL
getControl(const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlModel
> & Model
) throw( ::com::sun::star::container::NoSuchElementException
, ::com::sun::star::uno::RuntimeException
);
119 //XTextViewCursorSupplier
120 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextViewCursor
> SAL_CALL
getViewCursor(void) throw( ::com::sun::star::uno::RuntimeException
);
123 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> SAL_CALL
getViewSettings(void) throw( ::com::sun::star::uno::RuntimeException
);
126 virtual ::com::sun::star::uno::Sequence
<
127 ::com::sun::star::uno::Sequence
<
128 ::com::sun::star::beans::PropertyValue
> > SAL_CALL
getRubyList( sal_Bool bAutomatic
)
129 throw(::com::sun::star::uno::RuntimeException
);
131 virtual void SAL_CALL
setRubyList(
132 const ::com::sun::star::uno::Sequence
<
133 ::com::sun::star::uno::Sequence
<
134 ::com::sun::star::beans::PropertyValue
> >& RubyList
, sal_Bool bAutomatic
)
135 throw(::com::sun::star::uno::RuntimeException
);
138 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw (::com::sun::star::uno::RuntimeException
);
139 virtual void SAL_CALL
setPropertyValue( const ::rtl::OUString
& aPropertyName
, const ::com::sun::star::uno::Any
& aValue
) throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
140 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyValue( const ::rtl::OUString
& PropertyName
) throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
141 virtual void SAL_CALL
addPropertyChangeListener( const ::rtl::OUString
& aPropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyChangeListener
>& xListener
) throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
142 virtual void SAL_CALL
removePropertyChangeListener( const ::rtl::OUString
& aPropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyChangeListener
>& aListener
) throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
143 virtual void SAL_CALL
addVetoableChangeListener( const ::rtl::OUString
& PropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XVetoableChangeListener
>& aListener
) throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
144 virtual void SAL_CALL
removeVetoableChangeListener( const ::rtl::OUString
& PropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XVetoableChangeListener
>& aListener
) throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
147 virtual rtl::OUString SAL_CALL
getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException
);
148 virtual BOOL SAL_CALL
supportsService(const rtl::OUString
& ServiceName
) throw( ::com::sun::star::uno::RuntimeException
);
149 virtual ::com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException
);
151 //XTransferableSupplier
152 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::XTransferable
> SAL_CALL
getTransferable( ) throw (::com::sun::star::uno::RuntimeException
);
153 virtual void SAL_CALL
insertTransferable( const ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::XTransferable
>& xTrans
) throw (::com::sun::star::datatransfer::UnsupportedFlavorException
, ::com::sun::star::uno::RuntimeException
);
155 void NotifySelChanged();
156 void NotifyDBChanged();
158 SwView
* GetView() {return m_pView
;}
161 // temporary document used for PDF export of selections/multi-selections
162 SfxObjectShellRef
BuildTmpSelectionDoc( SfxObjectShellRef
& );
165 /* -----------------17.09.98 12:52-------------------
167 * --------------------------------------------------*/
169 typedef cppu::WeakImplHelper8
<
170 ::com::sun::star::text::XTextViewCursor
,
171 ::com::sun::star::lang::XServiceInfo
,
172 ::com::sun::star::text::XPageCursor
,
173 ::com::sun::star::view::XScreenCursor
,
174 ::com::sun::star::view::XViewCursor
,
175 ::com::sun::star::view::XLineCursor
,
176 ::com::sun::star::beans::XPropertySet
,
177 ::com::sun::star::beans::XPropertyState
178 > SwXTextViewCursor_Base
;
180 class SwXTextViewCursor
: public SwXTextViewCursor_Base
,
182 public OTextCursorHelper
185 const SfxItemPropertySet
* m_pPropSet
;
187 sal_Bool
IsTextSelection( sal_Bool bAllowTables
= sal_True
) const;
188 virtual ~SwXTextViewCursor();
190 SwXTextViewCursor(SwView
* pVw
);
195 virtual sal_Bool SAL_CALL
isVisible(void) throw( ::com::sun::star::uno::RuntimeException
);
196 virtual void SAL_CALL
setVisible(sal_Bool bVisible
) throw( ::com::sun::star::uno::RuntimeException
);
197 virtual ::com::sun::star::awt::Point SAL_CALL
getPosition(void) throw( ::com::sun::star::uno::RuntimeException
);
200 virtual void SAL_CALL
collapseToStart( ) throw(::com::sun::star::uno::RuntimeException
);
201 virtual void SAL_CALL
collapseToEnd( ) throw(::com::sun::star::uno::RuntimeException
);
202 virtual BOOL SAL_CALL
isCollapsed( ) throw(::com::sun::star::uno::RuntimeException
);
203 virtual BOOL SAL_CALL
goLeft( sal_Int16 nCount
, BOOL bExpand
) throw(::com::sun::star::uno::RuntimeException
);
204 virtual BOOL SAL_CALL
goRight( sal_Int16 nCount
, BOOL bExpand
) throw(::com::sun::star::uno::RuntimeException
);
205 virtual void SAL_CALL
gotoStart( BOOL bExpand
) throw(::com::sun::star::uno::RuntimeException
);
206 virtual void SAL_CALL
gotoEnd( BOOL bExpand
) throw(::com::sun::star::uno::RuntimeException
);
207 virtual void SAL_CALL
gotoRange( const ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
>& xRange
, BOOL bExpand
) throw(::com::sun::star::uno::RuntimeException
);
210 virtual sal_Bool SAL_CALL
jumpToFirstPage(void) throw( ::com::sun::star::uno::RuntimeException
);
211 virtual sal_Bool SAL_CALL
jumpToLastPage(void) throw( ::com::sun::star::uno::RuntimeException
);
212 virtual sal_Bool SAL_CALL
jumpToPage(sal_Int16 nPage
) throw( ::com::sun::star::uno::RuntimeException
);
213 virtual sal_Bool SAL_CALL
jumpToNextPage(void) throw( ::com::sun::star::uno::RuntimeException
);
214 virtual sal_Bool SAL_CALL
jumpToPreviousPage(void) throw( ::com::sun::star::uno::RuntimeException
);
215 virtual sal_Bool SAL_CALL
jumpToEndOfPage(void) throw( ::com::sun::star::uno::RuntimeException
);
216 virtual sal_Bool SAL_CALL
jumpToStartOfPage(void) throw( ::com::sun::star::uno::RuntimeException
);
217 virtual sal_Int16 SAL_CALL
getPage(void) throw( ::com::sun::star::uno::RuntimeException
);
220 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XText
> SAL_CALL
getText(void) throw( ::com::sun::star::uno::RuntimeException
);
221 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> SAL_CALL
getStart(void) throw( ::com::sun::star::uno::RuntimeException
);
222 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> SAL_CALL
getEnd(void) throw( ::com::sun::star::uno::RuntimeException
);
223 virtual rtl::OUString SAL_CALL
getString(void) throw( ::com::sun::star::uno::RuntimeException
);
224 virtual void SAL_CALL
setString(const rtl::OUString
& aString
) throw( ::com::sun::star::uno::RuntimeException
);
227 virtual sal_Bool SAL_CALL
screenDown(void) throw( ::com::sun::star::uno::RuntimeException
);
228 virtual sal_Bool SAL_CALL
screenUp(void) throw( ::com::sun::star::uno::RuntimeException
);
231 virtual sal_Bool SAL_CALL
goDown(sal_Int16 nCount
, sal_Bool bExpand
) throw( ::com::sun::star::uno::RuntimeException
);
232 virtual sal_Bool SAL_CALL
goUp(sal_Int16 nCount
, sal_Bool bExpand
) throw( ::com::sun::star::uno::RuntimeException
);
233 // virtual sal_Bool goLeft(sal_Int16 nCount, sal_Bool bExpand) throw( ::com::sun::star::uno::RuntimeException );
234 // virtual sal_Bool goRight(sal_Int16 nCount, sal_Bool bExpand) throw( ::com::sun::star::uno::RuntimeException );
237 virtual sal_Bool SAL_CALL
isAtStartOfLine(void) throw( ::com::sun::star::uno::RuntimeException
);
238 virtual sal_Bool SAL_CALL
isAtEndOfLine(void) throw( ::com::sun::star::uno::RuntimeException
);
239 virtual void SAL_CALL
gotoEndOfLine(sal_Bool bExpand
) throw( ::com::sun::star::uno::RuntimeException
);
240 virtual void SAL_CALL
gotoStartOfLine(sal_Bool bExpand
) throw( ::com::sun::star::uno::RuntimeException
);
243 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
);
244 virtual void SAL_CALL
setPropertyValue( const ::rtl::OUString
& aPropertyName
, const ::com::sun::star::uno::Any
& aValue
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
245 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyValue( const ::rtl::OUString
& PropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
246 virtual void SAL_CALL
addPropertyChangeListener( const ::rtl::OUString
& aPropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyChangeListener
>& xListener
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
247 virtual void SAL_CALL
removePropertyChangeListener( const ::rtl::OUString
& aPropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyChangeListener
>& aListener
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
248 virtual void SAL_CALL
addVetoableChangeListener( const ::rtl::OUString
& PropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XVetoableChangeListener
>& aListener
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
249 virtual void SAL_CALL
removeVetoableChangeListener( const ::rtl::OUString
& PropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XVetoableChangeListener
>& aListener
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
252 virtual ::com::sun::star::beans::PropertyState SAL_CALL
getPropertyState( const ::rtl::OUString
& PropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
);
253 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyState
> SAL_CALL
getPropertyStates( const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& aPropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
);
254 virtual void SAL_CALL
setPropertyToDefault( const ::rtl::OUString
& PropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
);
255 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyDefault( const ::rtl::OUString
& aPropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
258 virtual rtl::OUString SAL_CALL
getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException
);
259 virtual BOOL SAL_CALL
supportsService(const rtl::OUString
& ServiceName
) throw( ::com::sun::star::uno::RuntimeException
);
260 virtual ::com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException
);
262 static const ::com::sun::star::uno::Sequence
< sal_Int8
> & getUnoTunnelId();
265 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& aIdentifier
) throw(::com::sun::star::uno::RuntimeException
);
267 void Invalidate(){m_pView
= 0;}
270 virtual const SwPaM
* GetPaM() const;
271 virtual SwPaM
* GetPaM();
272 virtual const SwDoc
* GetDoc() const;
273 virtual SwDoc
* GetDoc();