xref: /aoo41x/main/sfx2/inc/sfx2/event.hxx (revision 3d720f72)
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 #ifndef _SFXEVENT_HXX
24 #define _SFXEVENT_HXX
25 
26 #include "sal/config.h"
27 #include "sfx2/dllapi.h"
28 #include "sfx2/sfx.hrc"
29 #include <tools/string.hxx>
30 #include <svl/hint.hxx>
31 #include <unotools/eventcfg.hxx>
32 #include <rtl/ustring.hxx>
33 
34 #include <com/sun/star/uno/Sequence.hxx>
35 #include <com/sun/star/beans/PropertyValue.hpp>
36 #include <com/sun/star/frame/XController2.hpp>
37 #include <com/sun/star/view/PrintableState.hpp>
38 
39 namespace css = ::com::sun::star;
40 
41 class SfxObjectShell;
42 
43 //-------------------------------------------------------------------
44 
45 class SFX2_DLLPUBLIC SfxEventHint : public SfxHint
46 {
47 	SfxObjectShell* 	pObjShell;
48 	::rtl::OUString		aEventName;
49 	sal_uInt16				nEventId;
50 
51 public:
52 	TYPEINFO();
SfxEventHint(sal_uInt16 nId,const::rtl::OUString & aName,SfxObjectShell * pObj=0)53 	SfxEventHint( sal_uInt16 nId, const ::rtl::OUString& aName, SfxObjectShell *pObj = 0 )
54 						:	pObjShell(pObj),
55 							aEventName(aName),
56 							nEventId(nId)
57 						{}
58 
GetEventId() const59 	sal_uInt16				GetEventId() const
60 						{ return nEventId; }
61 
GetEventName() const62 	::rtl::OUString		GetEventName() const
63 						{ return aEventName; }
64 
GetObjShell() const65 	SfxObjectShell* 	GetObjShell() const
66 						{ return pObjShell; }
67 };
68 
69 //-------------------------------------------------------------------
70 
71 class SFX2_DLLPUBLIC SfxViewEventHint : public SfxEventHint
72 {
73     ::com::sun::star::uno::Reference< css::frame::XController2 > xViewController;
74 
75 public:
76 	TYPEINFO();
77 
SfxViewEventHint(sal_uInt16 nId,const::rtl::OUString & aName,SfxObjectShell * pObj,const css::uno::Reference<css::frame::XController> & xController)78 	SfxViewEventHint( sal_uInt16 nId, const ::rtl::OUString& aName, SfxObjectShell *pObj, const css::uno::Reference< css::frame::XController >& xController )
79 						: SfxEventHint( nId, aName, pObj )
80                         , xViewController( xController, css::uno::UNO_QUERY )
81 						{}
82 
SfxViewEventHint(sal_uInt16 nId,const::rtl::OUString & aName,SfxObjectShell * pObj,const css::uno::Reference<css::frame::XController2> & xController)83 	SfxViewEventHint( sal_uInt16 nId, const ::rtl::OUString& aName, SfxObjectShell *pObj, const css::uno::Reference< css::frame::XController2 >& xController )
84 						: SfxEventHint( nId, aName, pObj )
85                         , xViewController( xController )
86 						{}
87 
GetController() const88     css::uno::Reference< css::frame::XController2 > GetController() const
89                         { return xViewController; }
90 };
91 
92 //-------------------------------------------------------------------
93 
94 class SfxNamedHint : public SfxHint
95 {
96 	String				_aEventName;
97 	SfxObjectShell* 	_pObjShell;
98 	String				_aArgs;
99 
100 public:
101 						TYPEINFO();
102 
SfxNamedHint(const String & rName,const String & rArgs,SfxObjectShell * pObj=0)103 						SfxNamedHint( const String& rName,
104 									  const String& rArgs,
105 									  SfxObjectShell *pObj = 0  )
106 						:	_aEventName( rName ),
107 							_pObjShell( pObj),
108 							_aArgs( rArgs )
109 						{}
110 
SfxNamedHint(const String & rName,SfxObjectShell * pObj=0)111 						SfxNamedHint( const String& rName,
112 									  SfxObjectShell *pObj = 0 )
113 						:	_aEventName( rName ),
114 							_pObjShell( pObj )
115 						{}
116 
GetArgs() const117 	const String&		GetArgs() const { return _aArgs;}
GetName() const118 	const String&		GetName() const { return _aEventName; }
GetObjShell() const119     SfxObjectShell*     GetObjShell() const { return _pObjShell; }
120 };
121 
122 class Printer;
123 
124 class SfxPrintingHint : public SfxViewEventHint
125 {
126     sal_Int32 mnPrintableState;
127     com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > aOpts;
128 public:
129         TYPEINFO();
130 
SfxPrintingHint(sal_Int32 nEvent,const css::uno::Sequence<css::beans::PropertyValue> & rOpts,SfxObjectShell * pObj,const css::uno::Reference<css::frame::XController2> & xController)131         SfxPrintingHint(
132                 sal_Int32 nEvent,
133                 const css::uno::Sequence < css::beans::PropertyValue >& rOpts,
134                 SfxObjectShell *pObj,
135                 const css::uno::Reference< css::frame::XController2 >& xController )
136         : SfxViewEventHint(
137             SFX_EVENT_PRINTDOC,
138             GlobalEventConfig::GetEventName( STR_EVENT_PRINTDOC ),
139             pObj,
140             xController )
141         , mnPrintableState( nEvent )
142         , aOpts( rOpts )
143         {}
144 
SfxPrintingHint(sal_Int32 nEvent)145         SfxPrintingHint( sal_Int32 nEvent )
146         : SfxViewEventHint( SFX_EVENT_PRINTDOC, rtl::OUString(), 0, css::uno::Reference< css::frame::XController >() )
147         , mnPrintableState( nEvent )
148         {}
149 
GetWhich() const150     sal_Int32 GetWhich() const { return mnPrintableState; }
GetOptions()151     const css::uno::Sequence < css::beans::PropertyValue >& GetOptions() { return aOpts; }
152 };
153 
154 #endif
155