1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: langselectionstatusbarcontroller.cxx,v $
10 * $Revision: 1.6.40.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_framework.hxx"
34 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35 #include <com/sun/star/frame/XModuleManager.hpp>
36 #include <com/sun/star/beans/PropertyValue.hpp>
38 #include <tools/debug.hxx>
39 #include <comphelper/processfactory.hxx>
40 #include <helper/mischelper.hxx>
44 using namespace ::com::sun::star
;
45 using namespace ::com::sun::star::uno
;
46 using namespace ::com::sun::star::frame
;
47 using namespace ::com::sun::star::beans
;
48 using namespace ::com::sun::star::container
;
49 using namespace ::com::sun::star::lang
;
54 uno::Reference
< linguistic2::XLanguageGuessing
> LanguageGuessingHelper::GetGuesser() const
56 if (!m_xLanguageGuesser
.is())
60 m_xLanguageGuesser
= uno::Reference
< linguistic2::XLanguageGuessing
>(
61 m_xServiceManager
->createInstance(
62 rtl::OUString::createFromAscii( "com.sun.star.linguistic2.LanguageGuessing" ) ),
65 catch (uno::Exception
&r
)
68 DBG_ASSERT( 0, "failed to get language guessing component" );
71 return m_xLanguageGuesser
;
74 ::rtl::OUString
RetrieveLabelFromCommand( const ::rtl::OUString
& aCmdURL
75 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _xServiceFactory
76 ,::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
>& _xUICommandLabels
77 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& _xFrame
78 ,::rtl::OUString
& _rModuleIdentifier
80 ,const sal_Char
* _pName
)
82 ::rtl::OUString aLabel
;
84 // Retrieve popup menu labels
85 if ( !_xUICommandLabels
.is() )
92 Reference
< XModuleManager
> xModuleManager( _xServiceFactory
->createInstance( SERVICENAME_MODULEMANAGER
), UNO_QUERY_THROW
);
96 _rModuleIdentifier
= xModuleManager
->identify( _xFrame
);
103 Reference
< XNameAccess
> xNameAccess( _xServiceFactory
->createInstance( SERVICENAME_UICOMMANDDESCRIPTION
), UNO_QUERY
);
104 if ( xNameAccess
.is() )
106 xNameAccess
->getByName( _rModuleIdentifier
) >>= _xUICommandLabels
;
114 if ( _xUICommandLabels
.is() )
118 if ( aCmdURL
.getLength() > 0 )
121 Sequence
< PropertyValue
> aPropSeq
;
122 if ( _xUICommandLabels
->getByName( aCmdURL
) >>= aPropSeq
)
124 for ( sal_Int32 i
= 0; i
< aPropSeq
.getLength(); i
++ )
126 if ( aPropSeq
[i
].Name
.equalsAscii( _pName
/*"Label"*/ ))
128 aPropSeq
[i
].Value
>>= aStr
;
136 catch ( com::sun::star::uno::Exception
& )
144 } // namespace framework