Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef SW_UNOTXVW_HXX
29 : : #define SW_UNOTXVW_HXX
30 : : #include <sfx2/sfxbasecontroller.hxx>
31 : : #include <cppuhelper/interfacecontainer.hxx>
32 : : #include <com/sun/star/embed/XEmbeddedObject.hpp>
33 : : #include <com/sun/star/text/XTextViewCursor.hpp>
34 : : #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
35 : : #include <com/sun/star/text/XRubySelection.hpp>
36 : : #include <com/sun/star/view/XFormLayerAccess.hpp>
37 : : #include <com/sun/star/view/XScreenCursor.hpp>
38 : : #include <com/sun/star/view/XViewSettingsSupplier.hpp>
39 : : #include <com/sun/star/view/XSelectionSupplier.hpp>
40 : : #include <com/sun/star/view/XLineCursor.hpp>
41 : : #include <com/sun/star/view/XViewCursor.hpp>
42 : : #include <com/sun/star/text/XPageCursor.hpp>
43 : : #include <com/sun/star/beans/XPropertySet.hpp>
44 : : #include <com/sun/star/beans/XPropertySetInfo.hpp>
45 : : #include <com/sun/star/beans/XPropertyState.hpp>
46 : : #include <com/sun/star/lang/XServiceInfo.hpp>
47 : : #include <com/sun/star/datatransfer/XTransferableSupplier.hpp>
48 : : #include <cppuhelper/implbase8.hxx> // helper for implementations
49 : : #include <svl/itemprop.hxx>
50 : : #include "calbck.hxx"
51 : : #include "TextCursorHelper.hxx"
52 : : #include <comphelper/uno3.hxx>
53 : :
54 : : #include <sfx2/objsh.hxx>
55 : :
56 : : class SdrObject;
57 : : class SwView;
58 : :
59 : : class SwXTextView :
60 : : public ::com::sun::star::view::XSelectionSupplier,
61 : : public ::com::sun::star::lang::XServiceInfo,
62 : : public ::com::sun::star::view::XFormLayerAccess,
63 : : public ::com::sun::star::text::XTextViewCursorSupplier,
64 : : public ::com::sun::star::text::XRubySelection,
65 : : public ::com::sun::star::view::XViewSettingsSupplier,
66 : : public ::com::sun::star::beans::XPropertySet,
67 : : public ::com::sun::star::datatransfer::XTransferableSupplier,
68 : : public SfxBaseController
69 : : {
70 : : ::cppu::OInterfaceContainerHelper m_SelChangedListeners;
71 : :
72 : : SwView* m_pView;
73 : : const SfxItemPropertySet* m_pPropSet; // property map for SwXTextView properties
74 : : // (not related to pxViewSettings!)
75 : :
76 : : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > * pxViewSettings;
77 : : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextViewCursor > * pxTextViewCursor;
78 : :
79 : :
80 : : SdrObject* GetControl(
81 : : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & Model,
82 : : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& xToFill );
83 : :
84 : : protected:
85 : : virtual ~SwXTextView();
86 : : public:
87 : : SwXTextView(SwView* pSwView);
88 : :
89 : :
90 : : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException);
91 : : virtual void SAL_CALL acquire( ) throw();
92 : : virtual void SAL_CALL release( ) throw();
93 : :
94 : : //XTypeProvider
95 : : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
96 : : virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
97 : :
98 : : //XSelectionSupplier
99 : : virtual ::com::sun::star::uno::Any SAL_CALL getSelection(void) throw( ::com::sun::star::uno::RuntimeException );
100 : : virtual sal_Bool SAL_CALL select(const ::com::sun::star::uno::Any& aInterface) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
101 : : virtual void SAL_CALL addSelectionChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener > & xListener) throw( ::com::sun::star::uno::RuntimeException );
102 : : virtual void SAL_CALL removeSelectionChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener > & xListener) throw( ::com::sun::star::uno::RuntimeException );
103 : :
104 : : // XFormLayerAccess
105 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > SAL_CALL getFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& Form ) throw (::com::sun::star::uno::RuntimeException);
106 : : virtual ::sal_Bool SAL_CALL isFormDesignMode( ) throw (::com::sun::star::uno::RuntimeException);
107 : : virtual void SAL_CALL setFormDesignMode( ::sal_Bool DesignMode ) throw (::com::sun::star::uno::RuntimeException);
108 : :
109 : : // XControlAccess
110 : : 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 );
111 : :
112 : : //XTextViewCursorSupplier
113 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextViewCursor > SAL_CALL getViewCursor(void) throw( ::com::sun::star::uno::RuntimeException );
114 : :
115 : : //XViewSettings
116 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getViewSettings(void) throw( ::com::sun::star::uno::RuntimeException );
117 : :
118 : : //XRubySelection
119 : : virtual ::com::sun::star::uno::Sequence<
120 : : ::com::sun::star::uno::Sequence<
121 : : ::com::sun::star::beans::PropertyValue > > SAL_CALL getRubyList( sal_Bool bAutomatic )
122 : : throw(::com::sun::star::uno::RuntimeException);
123 : :
124 : : virtual void SAL_CALL setRubyList(
125 : : const ::com::sun::star::uno::Sequence<
126 : : ::com::sun::star::uno::Sequence<
127 : : ::com::sun::star::beans::PropertyValue > >& RubyList, sal_Bool bAutomatic )
128 : : throw(::com::sun::star::uno::RuntimeException);
129 : :
130 : : //XPropertySet
131 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (::com::sun::star::uno::RuntimeException);
132 : : 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);
133 : : 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);
134 : : 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);
135 : : 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);
136 : : 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);
137 : : 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);
138 : :
139 : : //XServiceInfo
140 : : virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
141 : : virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
142 : : virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
143 : :
144 : : //XTransferableSupplier
145 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getTransferable( ) throw (::com::sun::star::uno::RuntimeException);
146 : : 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);
147 : :
148 : : void NotifySelChanged();
149 : : void NotifyDBChanged();
150 : :
151 : 240 : SwView* GetView() {return m_pView;}
152 : : void Invalidate();
153 : :
154 : : // temporary document used for PDF export of selections/multi-selections
155 : : SfxObjectShellLock BuildTmpSelectionDoc();
156 : : };
157 : :
158 : : typedef cppu::WeakImplHelper8<
159 : : ::com::sun::star::text::XTextViewCursor,
160 : : ::com::sun::star::lang::XServiceInfo,
161 : : ::com::sun::star::text::XPageCursor,
162 : : ::com::sun::star::view::XScreenCursor,
163 : : ::com::sun::star::view::XViewCursor,
164 : : ::com::sun::star::view::XLineCursor,
165 : : ::com::sun::star::beans::XPropertySet,
166 : : ::com::sun::star::beans::XPropertyState
167 : : > SwXTextViewCursor_Base;
168 : :
169 : : class SwXTextViewCursor : public SwXTextViewCursor_Base,
170 : : public SwClient,
171 : : public OTextCursorHelper
172 : : {
173 : : SwView* m_pView;
174 : : const SfxItemPropertySet* m_pPropSet;
175 : : protected:
176 : : sal_Bool IsTextSelection( sal_Bool bAllowTables = sal_True ) const;
177 : : virtual ~SwXTextViewCursor();
178 : : public:
179 : : SwXTextViewCursor(SwView* pVw);
180 : :
181 : : DECLARE_XINTERFACE()
182 : :
183 : : //XTextViewCursor
184 : : virtual sal_Bool SAL_CALL isVisible(void) throw( ::com::sun::star::uno::RuntimeException );
185 : : virtual void SAL_CALL setVisible(sal_Bool bVisible) throw( ::com::sun::star::uno::RuntimeException );
186 : : virtual ::com::sun::star::awt::Point SAL_CALL getPosition(void) throw( ::com::sun::star::uno::RuntimeException );
187 : :
188 : : //XTextCursor - neu
189 : : virtual void SAL_CALL collapseToStart( ) throw(::com::sun::star::uno::RuntimeException);
190 : : virtual void SAL_CALL collapseToEnd( ) throw(::com::sun::star::uno::RuntimeException);
191 : : virtual sal_Bool SAL_CALL isCollapsed( ) throw(::com::sun::star::uno::RuntimeException);
192 : : virtual sal_Bool SAL_CALL goLeft( sal_Int16 nCount, sal_Bool bExpand ) throw(::com::sun::star::uno::RuntimeException);
193 : : virtual sal_Bool SAL_CALL goRight( sal_Int16 nCount, sal_Bool bExpand ) throw(::com::sun::star::uno::RuntimeException);
194 : : virtual void SAL_CALL gotoStart( sal_Bool bExpand ) throw(::com::sun::star::uno::RuntimeException);
195 : : virtual void SAL_CALL gotoEnd( sal_Bool bExpand ) throw(::com::sun::star::uno::RuntimeException);
196 : : virtual void SAL_CALL gotoRange( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xRange, sal_Bool bExpand ) throw(::com::sun::star::uno::RuntimeException);
197 : :
198 : : //XPageCursor
199 : : virtual sal_Bool SAL_CALL jumpToFirstPage(void) throw( ::com::sun::star::uno::RuntimeException );
200 : : virtual sal_Bool SAL_CALL jumpToLastPage(void) throw( ::com::sun::star::uno::RuntimeException );
201 : : virtual sal_Bool SAL_CALL jumpToPage(sal_Int16 nPage) throw( ::com::sun::star::uno::RuntimeException );
202 : : virtual sal_Bool SAL_CALL jumpToNextPage(void) throw( ::com::sun::star::uno::RuntimeException );
203 : : virtual sal_Bool SAL_CALL jumpToPreviousPage(void) throw( ::com::sun::star::uno::RuntimeException );
204 : : virtual sal_Bool SAL_CALL jumpToEndOfPage(void) throw( ::com::sun::star::uno::RuntimeException );
205 : : virtual sal_Bool SAL_CALL jumpToStartOfPage(void) throw( ::com::sun::star::uno::RuntimeException );
206 : : virtual sal_Int16 SAL_CALL getPage(void) throw( ::com::sun::star::uno::RuntimeException );
207 : :
208 : : //XTextRange
209 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText(void) throw( ::com::sun::star::uno::RuntimeException );
210 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart(void) throw( ::com::sun::star::uno::RuntimeException );
211 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd(void) throw( ::com::sun::star::uno::RuntimeException );
212 : : virtual rtl::OUString SAL_CALL getString(void) throw( ::com::sun::star::uno::RuntimeException );
213 : : virtual void SAL_CALL setString(const rtl::OUString& aString) throw( ::com::sun::star::uno::RuntimeException );
214 : :
215 : : //XScreenCursor
216 : : virtual sal_Bool SAL_CALL screenDown(void) throw( ::com::sun::star::uno::RuntimeException );
217 : : virtual sal_Bool SAL_CALL screenUp(void) throw( ::com::sun::star::uno::RuntimeException );
218 : :
219 : : //XViewCursor
220 : : virtual sal_Bool SAL_CALL goDown(sal_Int16 nCount, sal_Bool bExpand) throw( ::com::sun::star::uno::RuntimeException );
221 : : virtual sal_Bool SAL_CALL goUp(sal_Int16 nCount, sal_Bool bExpand) throw( ::com::sun::star::uno::RuntimeException );
222 : : // virtual sal_Bool goLeft(sal_Int16 nCount, sal_Bool bExpand) throw( ::com::sun::star::uno::RuntimeException );
223 : : // virtual sal_Bool goRight(sal_Int16 nCount, sal_Bool bExpand) throw( ::com::sun::star::uno::RuntimeException );
224 : :
225 : : //XLineCursor
226 : : virtual sal_Bool SAL_CALL isAtStartOfLine(void) throw( ::com::sun::star::uno::RuntimeException );
227 : : virtual sal_Bool SAL_CALL isAtEndOfLine(void) throw( ::com::sun::star::uno::RuntimeException );
228 : : virtual void SAL_CALL gotoEndOfLine(sal_Bool bExpand) throw( ::com::sun::star::uno::RuntimeException );
229 : : virtual void SAL_CALL gotoStartOfLine(sal_Bool bExpand) throw( ::com::sun::star::uno::RuntimeException );
230 : :
231 : : //XPropertySet
232 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
233 : : 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);
234 : : 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);
235 : : 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);
236 : : 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);
237 : : 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);
238 : : 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);
239 : :
240 : : //XPropertyState
241 : : virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
242 : : 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);
243 : : virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
244 : : 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);
245 : :
246 : : //XServiceInfo
247 : : virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
248 : : virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
249 : : virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
250 : :
251 : : static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
252 : :
253 : : //XUnoTunnel
254 : : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
255 : :
256 : 18 : void Invalidate(){m_pView = 0;}
257 : :
258 : : // ITextCursorHelper
259 : : virtual const SwPaM* GetPaM() const;
260 : : virtual SwPaM* GetPaM();
261 : : virtual const SwDoc* GetDoc() const;
262 : : virtual SwDoc* GetDoc();
263 : : };
264 : :
265 : : #endif
266 : :
267 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|