1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef FORMS_SOURCE_RICHTEXT_RICHTEXTCONTROL_HXX
29 #define FORMS_SOURCE_RICHTEXT_RICHTEXTCONTROL_HXX
30 
31 #include <toolkit/controls/unocontrols.hxx>
32 #include <toolkit/awt/vclxwindow.hxx>
33 
34 /** === begin UNO includes === **/
35 #include <com/sun/star/frame/XDispatchProvider.hpp>
36 /** === end UNO includes === **/
37 #include <comphelper/uno3.hxx>
38 #include <comphelper/implementationreference.hxx>
39 #include <cppuhelper/implbase1.hxx>
40 #include <tools/wintypes.hxx>
41 #include "rtattributes.hxx"
42 #include "attributedispatcher.hxx"
43 
44 #include <map>
45 
46 //.........................................................................
47 namespace frm
48 {
49 //.........................................................................
50 
51     class ORichTextFeatureDispatcher;
52     class RichTextControl;
53 
54     //==================================================================
55     // ORichTextControl
56     //==================================================================
57     typedef ::cppu::ImplHelper1 <   ::com::sun::star::frame::XDispatchProvider
58                                 >   ORichTextControl_Base;
59     class ORichTextControl  :public UnoEditControl
60                             ,public ORichTextControl_Base
61     {
62     public:
63         ORichTextControl(
64             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
65         );
66 
67     protected:
68         ~ORichTextControl();
69 
70     public:
71         // XServiceInfo - static version
72         static	::rtl::OUString	SAL_CALL getImplementationName_Static();
73         static	::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_Static();
74         static	::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory );
75 
76     protected:
77         // UNO
78         DECLARE_UNO3_AGG_DEFAULTS( ORichTextControl, UnoEditControl );
79         virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw ( ::com::sun::star::uno::RuntimeException );
80 
81         // XControl
82         virtual void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& _rToolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& _rParent ) throw( ::com::sun::star::uno::RuntimeException );
83 
84         // XServiceInfo
85         virtual ::rtl::OUString	SAL_CALL getImplementationName()  throw(::com::sun::star::uno::RuntimeException);
86         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()  throw(::com::sun::star::uno::RuntimeException);
87 
88         // XTypeProvider
89         DECLARE_XTYPEPROVIDER()
90 
91         // XDispatchProvider
92         virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& _rURL, const ::rtl::OUString& _rTargetFrameName, sal_Int32 _rSearchFlags ) throw (::com::sun::star::uno::RuntimeException);
93         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& Requests ) throw (::com::sun::star::uno::RuntimeException);
94 
95         // UnoControl
96         virtual sal_Bool   requiresNewPeer( const ::rtl::OUString& _rPropertyName ) const;
97     };
98 
99     //==================================================================
100     // ORichTextPeer
101     //==================================================================
102     typedef ::cppu::ImplHelper1 <   ::com::sun::star::frame::XDispatchProvider
103                                 >   ORichTextPeer_Base;
104     class ORichTextPeer :public VCLXWindow
105                         ,public ORichTextPeer_Base
106                         ,public ITextSelectionListener
107     {
108     private:
109         typedef ::comphelper::ImplementationReference< ORichTextFeatureDispatcher, ::com::sun::star::frame::XDispatch > SingleAttributeDispatcher;
110         typedef ::std::map< SfxSlotId, SingleAttributeDispatcher >                                                      AttributeDispatchers;
111         AttributeDispatchers                                                                                            m_aDispatchers;
112 
113     public:
114         /** factory method
115             @return
116                 a new ORichTextPeer instance, which has been aquired once!
117         */
118         static ORichTextPeer* Create(
119             const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >&         _rxModel,
120             Window* _pParentWindow,
121             WinBits _nStyle
122         );
123 
124         // XInterface
125         DECLARE_XINTERFACE( )
126 
127     protected:
128         ORichTextPeer();
129         ~ORichTextPeer();
130 
131         // XView
132         void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno::RuntimeException);
133 
134         // XVclWindowPeer
135         virtual void SAL_CALL setProperty( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::uno::RuntimeException);
136 
137         // XTypeProvider
138         DECLARE_XTYPEPROVIDER( )
139 
140         // XComponent
141         virtual void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException);
142 
143         // XDispatchProvider
144         virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& _rURL, const ::rtl::OUString& _rTargetFrameName, sal_Int32 _rSearchFlags ) throw (::com::sun::star::uno::RuntimeException);
145         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& Requests ) throw (::com::sun::star::uno::RuntimeException);
146 
147         // ITextSelectionListener
148         virtual void    onSelectionChanged( const ESelection& _rSelection );
149 
150     private:
151         SingleAttributeDispatcher implCreateDispatcher( SfxSlotId _nSlotId, const ::com::sun::star::util::URL& _rURL );
152     };
153 
154 //.........................................................................
155 }   // namespace frm
156 //.........................................................................
157 
158 #endif // FORMS_SOURCE_RICHTEXT_RICHTEXTCONTROL_HXX
159 
160