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 #ifndef FORMS_SOURCE_RICHTEXT_RICHTEXTCONTROL_HXX
25 #define FORMS_SOURCE_RICHTEXT_RICHTEXTCONTROL_HXX
26 
27 #include <toolkit/controls/unocontrols.hxx>
28 #include <toolkit/awt/vclxwindow.hxx>
29 
30 /** === begin UNO includes === **/
31 #include <com/sun/star/frame/XDispatchProvider.hpp>
32 /** === end UNO includes === **/
33 #include <comphelper/uno3.hxx>
34 #include <comphelper/implementationreference.hxx>
35 #include <cppuhelper/implbase1.hxx>
36 #include <tools/wintypes.hxx>
37 #include "rtattributes.hxx"
38 #include "attributedispatcher.hxx"
39 
40 #include <map>
41 
42 //.........................................................................
43 namespace frm
44 {
45 //.........................................................................
46 
47     class ORichTextFeatureDispatcher;
48     class RichTextControl;
49 
50     //==================================================================
51     // ORichTextControl
52     //==================================================================
53     typedef ::cppu::ImplHelper1 <   ::com::sun::star::frame::XDispatchProvider
54                                 >   ORichTextControl_Base;
55     class ORichTextControl  :public UnoEditControl
56                             ,public ORichTextControl_Base
57     {
58     public:
59         ORichTextControl(
60             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
61         );
62 
63     protected:
64         ~ORichTextControl();
65 
66     public:
67         // XServiceInfo - static version
68         static	::rtl::OUString	SAL_CALL getImplementationName_Static();
69         static	::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_Static();
70         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 );
71 
72     protected:
73         // UNO
74         DECLARE_UNO3_AGG_DEFAULTS( ORichTextControl, UnoEditControl );
75         virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw ( ::com::sun::star::uno::RuntimeException );
76 
77         // XControl
78         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 );
79 
80         // XServiceInfo
81         virtual ::rtl::OUString	SAL_CALL getImplementationName()  throw(::com::sun::star::uno::RuntimeException);
82         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()  throw(::com::sun::star::uno::RuntimeException);
83 
84         // XTypeProvider
85         DECLARE_XTYPEPROVIDER()
86 
87         // XDispatchProvider
88         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);
89         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);
90 
91         // UnoControl
92         virtual sal_Bool   requiresNewPeer( const ::rtl::OUString& _rPropertyName ) const;
93     };
94 
95     //==================================================================
96     // ORichTextPeer
97     //==================================================================
98     typedef ::cppu::ImplHelper1 <   ::com::sun::star::frame::XDispatchProvider
99                                 >   ORichTextPeer_Base;
100     class ORichTextPeer :public VCLXWindow
101                         ,public ORichTextPeer_Base
102                         ,public ITextSelectionListener
103     {
104     private:
105         typedef ::comphelper::ImplementationReference< ORichTextFeatureDispatcher, ::com::sun::star::frame::XDispatch > SingleAttributeDispatcher;
106         typedef ::std::map< SfxSlotId, SingleAttributeDispatcher >                                                      AttributeDispatchers;
107         AttributeDispatchers                                                                                            m_aDispatchers;
108 
109     public:
110         /** factory method
111             @return
112                 a new ORichTextPeer instance, which has been aquired once!
113         */
114         static ORichTextPeer* Create(
115             const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >&         _rxModel,
116             Window* _pParentWindow,
117             WinBits _nStyle
118         );
119 
120         // XInterface
121         DECLARE_XINTERFACE( )
122 
123     protected:
124         ORichTextPeer();
125         ~ORichTextPeer();
126 
127         // XView
128         void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno::RuntimeException);
129 
130         // XVclWindowPeer
131         virtual void SAL_CALL setProperty( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::uno::RuntimeException);
132 
133         // XTypeProvider
134         DECLARE_XTYPEPROVIDER( )
135 
136         // XComponent
137         virtual void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException);
138 
139         // XDispatchProvider
140         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);
141         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);
142 
143         // ITextSelectionListener
144         virtual void    onSelectionChanged( const ESelection& _rSelection );
145 
146     private:
147         SingleAttributeDispatcher implCreateDispatcher( SfxSlotId _nSlotId, const ::com::sun::star::util::URL& _rURL );
148     };
149 
150 //.........................................................................
151 }   // namespace frm
152 //.........................................................................
153 
154 #endif // FORMS_SOURCE_RICHTEXT_RICHTEXTCONTROL_HXX
155 
156