Index: CppComponent.uno.xml
===================================================================
RCS file: /cvs/api/odk/examples/DevelopersGuide/Components/CppComponent/CppComponent.uno.xml,v
retrieving revision 1.3
diff -u -r1.3 CppComponent.uno.xml
--- CppComponent.uno.xml 31 Jan 2005 16:12:37 -0000 1.3
+++ CppComponent.uno.xml 3 Aug 2006 15:38:44 -0000
@@ -27,6 +27,10 @@
my_module.XSomething
my_module.MyService1
my_module.MyService2
+ com.sun.star.lang.DisposedException
+ com.sun.star.linguistic2.XSpellChecker
+ com.sun.star.lang.XServiceDisplayName
+ com.sun.star.linguistic2.XLinguServiceEventBroadcaster
cppuhelper
cppu
Index: Makefile
===================================================================
RCS file: /cvs/api/odk/examples/DevelopersGuide/Components/CppComponent/Makefile,v
retrieving revision 1.8
diff -u -r1.8 Makefile
--- Makefile 1 Aug 2006 16:31:40 -0000 1.8
+++ Makefile 3 Aug 2006 15:38:44 -0000
@@ -118,7 +118,7 @@
$(SAMPLE_SLO_OUT)/%.$(OBJ_EXT) : %.cxx $(COMP_TYPEFLAG)
-$(MKDIR) $(subst /,$(PS),$(@D))
- $(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(SAMPLE_INC_OUT) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
+ $(CC) $(CC_FLAGS) $(CC_INCLUDES) $(STL_INCLUDES) -I$(SAMPLE_INC_OUT) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
ifeq "$(OS)" "WIN"
$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
@@ -159,7 +159,7 @@
ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
-$(MKDIR) $(subst /,$(PS),$(@D))
- $(DEPLOYTOOL) $(COMP_PACKAGE_URL)
+ $(DEPLOYTOOL) --verbose $(COMP_PACKAGE_URL)
@echo flagged > $(subst /,$(PS),$@)
else
@echo --------------------------------------------------------------------------------
Index: service2_impl.cxx
===================================================================
RCS file: /cvs/api/odk/examples/DevelopersGuide/Components/CppComponent/service2_impl.cxx,v
retrieving revision 1.5
diff -u -r1.5 service2_impl.cxx
--- service2_impl.cxx 1 Aug 2006 16:32:26 -0000 1.5
+++ service2_impl.cxx 3 Aug 2006 15:38:44 -0000
@@ -38,7 +38,10 @@
*
*************************************************************************/
-#include // "3" implementing three interfaces
+#include // "6" implementing three interfaces
+#include
+#include
+#include
#include
#include
@@ -64,8 +67,9 @@
static Sequence< OUString > getSupportedServiceNames_MyService2Impl()
{
- Sequence names(1);
+ Sequence names(2);
names[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("my_module.MyService2"));
+ names[1] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.linguistic2.SpellChecker"));
return names;
}
@@ -74,24 +78,126 @@
return OUString( RTL_CONSTASCII_USTRINGPARAM(
"my_module.my_sc_implementation.MyService2") );
}
-
-class MyService2Impl : public ::cppu::WeakImplHelper3<
- ::my_module::XSomething, lang::XServiceInfo, lang::XInitialization >
+
+typedef ::cppu::WeakComponentImplHelper6 <
+::my_module::XSomething,
+ lang::XServiceInfo,
+ lang::XInitialization,
+ linguistic2::XSpellChecker,
+ lang::XServiceDisplayName,
+ linguistic2::XLinguServiceEventBroadcaster
+ > SpellChecker;
+
+static ::osl::Mutex mutex;
+
+class MyService2Impl : public SpellChecker
{
OUString m_sData;
+ int count;
+
+ void disposing () {
+ ::printf ("disposing\n");
+ }
+
// it's good practise to store the context for further use when you use
// other UNO API's in your implementation
Reference< XComponentContext > m_xContext;
public:
inline MyService2Impl(Reference< XComponentContext > const & xContext) throw ()
- : m_xContext(xContext)
+ : SpellChecker (mutex), count (0), m_xContext(xContext)
{}
- virtual ~MyService2Impl() {}
+ virtual ~MyService2Impl() {
+ ::printf ("~MyService2Impl\n");
+ ::printf ("-----------------------------------------------\n");
+ }
// focus on three given interfaces,
// no need to implement XInterface, XTypeProvider, XWeak
-
+
+ virtual Any SAL_CALL queryInterface (const ::com::sun::star::uno::Type &type) throw (RuntimeException) {
+ const ::osl::MutexGuard guard (mutex);
+ ::printf ("queryInterface\n");
+ const Any any (SpellChecker::queryInterface (type));
+ const OString string (OUStringToOString (any.getValueTypeName (), RTL_TEXTENCODING_UTF8));
+ ::printf ("%s\n", string.getStr ());
+ return any;
+ }
+
+ virtual void SAL_CALL acquire () throw () {
+ const ::osl::MutexGuard guard (mutex);
+ ::printf ("Increment reference count: %i\n", ++count);
+ SpellChecker::acquire ();
+ }
+
+ virtual void SAL_CALL release () throw () {
+ const ::osl::MutexGuard guard (mutex);
+ ::printf ("Decrement reference count: %i\n", count--);
+ SpellChecker::release ();
+ }
+
+ virtual Sequence SAL_CALL getLocales () throw (RuntimeException) {
+ const ::osl::MutexGuard guard (mutex);
+ ::printf ("getLocales\n");
+ Sequence locales (1);
+ locales [0] = lang::Locale (OUString::createFromAscii ("de"), OUString::createFromAscii ("DE"), OUString ());
+ return locales;
+ }
+
+ virtual ::sal_Bool SAL_CALL hasLocale(const lang::Locale &locale) throw (RuntimeException) {
+ const ::osl::MutexGuard guard (mutex);
+ ::printf ("hasLocale\n");
+ return locale.Language.equalsAscii ("de") && locale.Country.equalsAscii ("DE");
+ }
+
+ virtual ::sal_Bool SAL_CALL isValid (const OUString &, const lang::Locale &, const Sequence &) throw (lang::IllegalArgumentException, RuntimeException) {
+ const ::osl::MutexGuard guard (mutex);
+ ::printf ("isValid\n");
+ return true;
+ }
+
+ virtual Reference SAL_CALL spell (const OUString &, const lang::Locale &, const Sequence &) throw (lang::IllegalArgumentException, RuntimeException) {
+ const ::osl::MutexGuard guard (mutex);
+ ::printf ("spell\n");
+ return Reference ();
+ }
+
+ virtual ::sal_Bool SAL_CALL addLinguServiceEventListener (const Reference &) throw (RuntimeException) {
+ const ::osl::MutexGuard guard (mutex);
+ ::printf ("addLinguServiceEventListener\n");
+ return true;
+ }
+
+ virtual ::sal_Bool SAL_CALL removeLinguServiceEventListener (const Reference &) throw (RuntimeException) {
+ const ::osl::MutexGuard guard (mutex);
+ ::printf ("removeLinguServiceEventListener\n");
+ return true;
+ }
+
+ virtual void SAL_CALL dispose () throw (RuntimeException) {
+ const ::osl::MutexGuard guard (mutex);
+ ::printf ("dispose\n");
+ SpellChecker::dispose ();
+ }
+
+ OUString SAL_CALL getServiceDisplayName (const lang::Locale &) throw (RuntimeException) {
+ const ::osl::MutexGuard guard (mutex);
+ ::printf ("getServiceDisplayName\n");
+ return OUString::createFromAscii ("Test");
+ }
+
+ virtual void SAL_CALL addEventListener (const Reference &listener) throw (RuntimeException) {
+ const ::osl::MutexGuard guard (mutex);
+ ::printf ("addEventListener\n");
+ SpellChecker::addEventListener (listener);
+ }
+
+ virtual void SAL_CALL removeEventListener (const Reference &listener) throw (RuntimeException) {
+ const ::osl::MutexGuard guard (mutex);
+ ::printf ("removeEventListener\n");
+ SpellChecker::removeEventListener (listener);
+ }
+
// XInitialization will be called upon
// createInstanceWithArguments[AndContext]()
virtual void SAL_CALL initialize( Sequence< Any > const & args )
@@ -114,7 +220,7 @@
void MyService2Impl::initialize( Sequence< Any > const & args )
throw (Exception)
{
- if (args.getLength() != 1)
+ if (args.getLength() < 1)
{
throw lang::IllegalArgumentException(
OUString( RTL_CONSTASCII_USTRINGPARAM(
@@ -122,7 +228,7 @@
// resolve to XInterface reference:
static_cast< ::cppu::OWeakObject * >(this),
0 ); // argument pos
- }
+ } /*
if (! (args[ 0 ] >>= m_sData))
{
throw lang::IllegalArgumentException(
@@ -131,7 +237,7 @@
// resolve to XInterface reference:
static_cast< ::cppu::OWeakObject * >(this),
0 ); // argument pos
- }
+ } */
}
// XSomething implementation
@@ -164,7 +270,8 @@
{
// this object only supports one service, so the test is simple
return serviceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
- "my_module.MyService2") );
+ "my_module.MyService2") ) ||
+ serviceName.equalsAscii ("com.sun.star.linguistic2.SpellChecker");
}
Sequence< OUString > MyService2Impl::getSupportedServiceNames()
@@ -228,4 +335,4 @@
}
-
+// vim:cindent:expandtab:shiftwidth=4