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 __FRAMEWORK_RECORDING_DISPATCHRECORDER_HXX_ 24 #define __FRAMEWORK_RECORDING_DISPATCHRECORDER_HXX_ 25 26 /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble 27 with solaris headers ... 28 */ 29 #include <vector> 30 31 // own includes 32 #include <threadhelp/threadhelpbase.hxx> 33 #include <macros/xinterface.hxx> 34 #include <macros/xtypeprovider.hxx> 35 #include <macros/xserviceinfo.hxx> 36 #include <macros/debug.hxx> 37 #include <macros/generic.hxx> 38 #include <general.h> 39 #include <rtl/ustring.hxx> 40 #include <rtl/ustrbuf.hxx> 41 #include <com/sun/star/lang/XTypeProvider.hpp> 42 #include <com/sun/star/frame/XDispatchRecorder.hpp> 43 #include <com/sun/star/frame/DispatchStatement.hpp> 44 #include <com/sun/star/container/XIndexReplace.hpp> 45 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 46 #include <com/sun/star/util/URL.hpp> 47 #include <com/sun/star/beans/PropertyValue.hpp> 48 #include <com/sun/star/uno/RuntimeException.hdl> 49 #include <com/sun/star/script/XTypeConverter.hpp> 50 #include <cppuhelper/weak.hxx> 51 52 namespace framework{ 53 54 typedef ::std::vector < com::sun::star::frame::DispatchStatement > DispatchStatementList; 55 56 class DispatchRecorder 57 : private ThreadHelpBase 58 , public css::lang::XTypeProvider 59 , public css::lang::XServiceInfo 60 , public css::frame::XDispatchRecorder 61 , public css::container::XIndexReplace 62 , public ::cppu::OWeakObject 63 { 64 // private member 65 private: 66 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR ; 67 DispatchStatementList m_aStatements; 68 sal_Int32 m_nRecordingID ; 69 css::uno::Reference< css::script::XTypeConverter > m_xConverter; 70 71 // public interface 72 public: 73 DispatchRecorder( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ); 74 ~DispatchRecorder(); 75 76 // XInterface, XTypeProvider, XServiceInfo 77 FWK_DECLARE_XINTERFACE 78 FWK_DECLARE_XTYPEPROVIDER 79 DECLARE_XSERVICEINFO 80 81 // XDispatchRecorder 82 virtual void SAL_CALL startRecording ( const css::uno::Reference< css::frame::XFrame >& xFrame ) throw( css::uno::RuntimeException ); 83 virtual void SAL_CALL recordDispatch ( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException ); 84 virtual void SAL_CALL recordDispatchAsComment( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException ); 85 virtual void SAL_CALL endRecording () throw( css::uno::RuntimeException ); 86 virtual ::rtl::OUString SAL_CALL getRecordedMacro () throw( css::uno::RuntimeException ); 87 88 virtual com::sun::star::uno::Type SAL_CALL getElementType() throw (::com::sun::star::uno::RuntimeException); 89 90 virtual sal_Bool SAL_CALL hasElements() throw (::com::sun::star::uno::RuntimeException); 91 92 virtual sal_Int32 SAL_CALL getCount() throw (::com::sun::star::uno::RuntimeException); 93 94 virtual com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32) throw (com::sun::star::uno::RuntimeException, com::sun::star::lang::WrappedTargetException, com::sun::star::lang::IndexOutOfBoundsException); 95 96 virtual void SAL_CALL replaceByIndex(sal_Int32, const com::sun::star::uno::Any&) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 97 98 // private functions 99 private: 100 void SAL_CALL implts_recordMacro( const ::rtl::OUString& aURL, 101 const css::uno::Sequence< css::beans::PropertyValue >& lArguments, 102 sal_Bool bAsComment, ::rtl::OUStringBuffer& ); 103 void SAL_CALL AppendToBuffer( css::uno::Any aValue, ::rtl::OUStringBuffer& aArgumentBuffer ); 104 105 }; // class DispatcRecorder 106 107 } // namespace framework 108 109 #endif // define __FRAMEWORK... 110