summaryrefslogtreecommitdiff
path: root/vbahelper
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2011-05-27 20:46:20 +0200
committerJan Holesovsky <kendy@suse.cz>2011-05-27 20:46:20 +0200
commit9aad9cf77f93f6a689731972d97f2acc04527422 (patch)
treecf79102596e03d339b8429fd5545410b16292870 /vbahelper
parentfde37c1a38273e7a90bb6d26cd1c948e8fe63783 (diff)
parenta019d3e3c180b0ec41e2725e7cfe442afccf9cb0 (diff)
Merge remote-tracking branch 'origin/integration/dev300_m106'
Conflicts: basic/source/classes/sbunoobj.cxx basic/source/inc/runtime.hxx basic/source/runtime/step1.cxx desktop/source/deployment/dp_services.cxx drawinglayer/prj/d.lst drawinglayer/source/primitive2d/makefile.mk sfx2/source/appl/appinit.cxx sfx2/source/appl/appquit.cxx sfx2/source/inc/appdata.hxx sfx2/source/view/viewfrm.cxx svx/source/fmcomp/gridctrl.cxx vbahelper/source/vbahelper/vbahelper.cxx
Diffstat (limited to 'vbahelper')
-rwxr-xr-xvbahelper/Library_msforms.mk11
-rwxr-xr-xvbahelper/Library_vbahelper.mk14
-rwxr-xr-xvbahelper/Package_inc.mk2
-rwxr-xr-xvbahelper/inc/vbahelper/collectionbase.hxx214
-rw-r--r--vbahelper/inc/vbahelper/vbaapplicationbase.hxx1
-rw-r--r--vbahelper/inc/vbahelper/vbacollectionimpl.hxx4
-rw-r--r--vbahelper/inc/vbahelper/vbadocumentbase.hxx1
-rw-r--r--vbahelper/inc/vbahelper/vbaeventshelperbase.hxx70
-rw-r--r--vbahelper/inc/vbahelper/vbahelper.hxx123
-rw-r--r--vbahelper/inc/vbahelper/vbawindowbase.hxx37
-rwxr-xr-xvbahelper/inc/vbahelper/weakreference.hxx94
-rw-r--r--vbahelper/source/msforms/vbabutton.cxx55
-rw-r--r--vbahelper/source/msforms/vbabutton.hxx15
-rw-r--r--vbahelper/source/msforms/vbacheckbox.cxx11
-rw-r--r--vbahelper/source/msforms/vbacheckbox.hxx1
-rw-r--r--vbahelper/source/msforms/vbacombobox.cxx117
-rw-r--r--vbahelper/source/msforms/vbacombobox.hxx14
-rw-r--r--vbahelper/source/msforms/vbacontrol.cxx133
-rw-r--r--vbahelper/source/msforms/vbacontrol.hxx24
-rw-r--r--vbahelper/source/msforms/vbacontrols.cxx187
-rw-r--r--vbahelper/source/msforms/vbacontrols.hxx27
-rw-r--r--vbahelper/source/msforms/vbaframe.cxx83
-rw-r--r--vbahelper/source/msforms/vbaframe.hxx30
-rw-r--r--vbahelper/source/msforms/vbalabel.cxx11
-rw-r--r--vbahelper/source/msforms/vbalabel.hxx1
-rw-r--r--vbahelper/source/msforms/vbalistbox.cxx9
-rw-r--r--vbahelper/source/msforms/vbalistbox.hxx3
-rw-r--r--vbahelper/source/msforms/vbamultipage.cxx9
-rw-r--r--vbahelper/source/msforms/vbamultipage.hxx9
-rwxr-xr-xvbahelper/source/msforms/vbanewfont.cxx160
-rwxr-xr-xvbahelper/source/msforms/vbanewfont.hxx73
-rw-r--r--vbahelper/source/msforms/vbaradiobutton.cxx10
-rw-r--r--vbahelper/source/msforms/vbaradiobutton.hxx1
-rw-r--r--vbahelper/source/msforms/vbatextbox.cxx41
-rw-r--r--vbahelper/source/msforms/vbatextbox.hxx6
-rw-r--r--vbahelper/source/msforms/vbatogglebutton.cxx54
-rw-r--r--vbahelper/source/msforms/vbatogglebutton.hxx12
-rw-r--r--vbahelper/source/msforms/vbauserform.cxx36
-rw-r--r--vbahelper/source/msforms/vbauserform.hxx14
-rwxr-xr-xvbahelper/source/vbahelper/collectionbase.cxx332
-rw-r--r--vbahelper/source/vbahelper/vbaapplicationbase.cxx27
-rw-r--r--vbahelper/source/vbahelper/vbacommandbar.cxx9
-rw-r--r--vbahelper/source/vbahelper/vbacommandbarcontrol.cxx74
-rw-r--r--vbahelper/source/vbahelper/vbacommandbarcontrol.hxx11
-rw-r--r--vbahelper/source/vbahelper/vbacommandbarcontrols.cxx27
-rw-r--r--vbahelper/source/vbahelper/vbacommandbarcontrols.hxx21
-rw-r--r--vbahelper/source/vbahelper/vbacommandbarhelper.hxx1
-rw-r--r--vbahelper/source/vbahelper/vbadocumentbase.cxx16
-rw-r--r--vbahelper/source/vbahelper/vbaeventshelperbase.cxx247
-rw-r--r--vbahelper/source/vbahelper/vbahelper.cxx687
-rw-r--r--vbahelper/source/vbahelper/vbawindowbase.cxx142
51 files changed, 2425 insertions, 886 deletions
diff --git a/vbahelper/Library_msforms.mk b/vbahelper/Library_msforms.mk
index d0b79c8cfb..e1b00c7264 100755
--- a/vbahelper/Library_msforms.mk
+++ b/vbahelper/Library_msforms.mk
@@ -50,16 +50,16 @@ $(eval $(call gb_Library_add_linked_libs,msforms,\
comphelper \
cppu \
cppuhelper \
+ sal \
+ sb \
+ sfx \
svl \
svt \
+ svx \
+ tk \
tl \
- sal \
vbahelper \
- sfx \
- svx \
vcl \
- tk \
- sb \
$(gb_STDLIBS) \
))
@@ -78,6 +78,7 @@ $(eval $(call gb_Library_add_exception_objects,msforms,\
vbahelper/source/msforms/vbalistbox \
vbahelper/source/msforms/vbalistcontrolhelper \
vbahelper/source/msforms/vbamultipage \
+ vbahelper/source/msforms/vbanewfont \
vbahelper/source/msforms/vbapages \
vbahelper/source/msforms/vbaprogressbar \
vbahelper/source/msforms/vbaradiobutton \
diff --git a/vbahelper/Library_vbahelper.mk b/vbahelper/Library_vbahelper.mk
index bb2c78b816..3b78599422 100755
--- a/vbahelper/Library_vbahelper.mk
+++ b/vbahelper/Library_vbahelper.mk
@@ -50,24 +50,26 @@ $(eval $(call gb_Library_set_defs,vbahelper,\
# add libraries to be linked to vbahelper; again these names need to be given as
# specified in Repository.mk
$(eval $(call gb_Library_add_linked_libs,vbahelper,\
+ comphelper \
cppu \
cppuhelper \
- comphelper \
- sb \
- tl \
+ msfilter \
sal \
+ sb \
sfx \
- svt \
- vcl \
svl \
- msfilter \
+ svt \
tk \
+ tl \
+ utl \
+ vcl \
$(gb_STDLIBS) \
))
# add all source files that shall be compiled with exceptions enabled
# the name is relative to $(SRCROOT) and must not contain an extension
$(eval $(call gb_Library_add_exception_objects,vbahelper,\
+ vbahelper/source/vbahelper/collectionbase \
vbahelper/source/vbahelper/vbaapplicationbase \
vbahelper/source/vbahelper/vbacolorformat \
vbahelper/source/vbahelper/vbacommandbar \
diff --git a/vbahelper/Package_inc.mk b/vbahelper/Package_inc.mk
index 6d8033aa5b..385fbf15a6 100755
--- a/vbahelper/Package_inc.mk
+++ b/vbahelper/Package_inc.mk
@@ -26,6 +26,7 @@
#*************************************************************************
$(eval $(call gb_Package_Package,vbahelper_inc,$(SRCDIR)/vbahelper/inc))
+$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/collectionbase.hxx,vbahelper/collectionbase.hxx))
$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/helperdecl.hxx,vbahelper/helperdecl.hxx))
$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbaaccesshelper.hxx,vbahelper/vbaaccesshelper.hxx))
$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbaapplicationbase.hxx,vbahelper/vbaapplicationbase.hxx))
@@ -47,5 +48,6 @@ $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbashaperange.hxx,
$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbashapes.hxx,vbahelper/vbashapes.hxx))
$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbatextframe.hxx,vbahelper/vbatextframe.hxx))
$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbawindowbase.hxx,vbahelper/vbawindowbase.hxx))
+$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/weakreference.hxx,vbahelper/weakreference.hxx))
# vim: set noet sw=4 ts=4:
diff --git a/vbahelper/inc/vbahelper/collectionbase.hxx b/vbahelper/inc/vbahelper/collectionbase.hxx
new file mode 100755
index 0000000000..ebb5bf8f2b
--- /dev/null
+++ b/vbahelper/inc/vbahelper/collectionbase.hxx
@@ -0,0 +1,214 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2011 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef VBAHELPER_COLLECTIONBASE_HXX
+#define VBAHELPER_COLLECTIONBASE_HXX
+
+#include <vector>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/container/XElementAccess.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <ooo/vba/XCollectionBase.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <vbahelper/vbahelper.hxx>
+
+namespace vbahelper {
+
+// ============================================================================
+
+typedef ::cppu::WeakImplHelper1< ov::XCollectionBase > CollectionBase_BASE;
+
+/** Base class of VBA objects implementing the VBA collection concept.
+
+ This base class intentionally does not include the interface
+ XHelperInterface supported by all application VBA object. There may be
+ other VBA objects that do not support the special methods provided by
+ XHelperInterface.
+ */
+class VBAHELPER_DLLPUBLIC CollectionBase : public CollectionBase_BASE
+{
+public:
+ /** Enumerates different container types a VBA collection can be based on. */
+ enum ContainerType
+ {
+ /** Container elements are VBA items.
+
+ The initial container contains the final VBA items provided by the
+ VBA collection. No conversion takes place on item access.
+ */
+ CONTAINER_NATIVE_VBA,
+
+ /** Container elements will be converted to VBA items on demand.
+
+ The initial container contains intermediate objects (e.g. UNO
+ objects) which will be converted to VBA items everytime the item is
+ accessed (e.g. item access method, enumeration). Changes in the
+ initial container are reflected by the collection.
+ */
+ CONTAINER_CONVERT_ON_DEMAND,
+ };
+
+ // ------------------------------------------------------------------------
+
+ CollectionBase( const css::uno::Type& rElementType );
+
+ // ------------------------------------------------------------------------
+
+ // attributes
+ virtual sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
+ // XEnumerationAccess
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+ // XElementAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException);
+ // XDefaultMethod
+ virtual ::rtl::OUString SAL_CALL getDefaultMethodName() throw (css::uno::RuntimeException);
+
+ // ------------------------------------------------------------------------
+
+ /** Associates this collection with the passed UNO container.
+
+ @param rxElementAccess
+ The UNO container with the elements of this collection. Shall
+ support either XIndexAccess or XNameAccess, may support both.
+
+ If the container does not support XIndexAccess, index access is
+ simulated based on the order returned by the function
+ XNameAccess::getElementNames().
+
+ If the container does not support XNameAccess, name access is
+ simulated by iterating the elements via index access and asking the
+ elements for their name via the interface XNamed. If the elements
+ do not support XNamed, the elements cannot be accessed by name.
+
+ @param eContainerType
+ Specifies the type of the passed container.
+ */
+ void initContainer(
+ const css::uno::Reference< css::container::XElementAccess >& rxElementAccess,
+ ContainerType eContainerType ) throw (css::uno::RuntimeException);
+
+ /** Initializes this collection with copies of all elements in the passed
+ temporary STL vector.
+
+ @param rElements
+ The STL vector with the named elements of this collection.
+ @param eContainerType
+ Specifies the type of the passed vector.
+ */
+ void initElements(
+ const ::std::vector< css::uno::Reference< css::container::XNamed > >& rElements,
+ ContainerType eContainerType ) throw (css::uno::RuntimeException);
+
+ /** Initializes this collection with copies of all elements in the passed
+ temporary STL vector.
+
+ @param rElements
+ The STL vector with the named elements of this collection.
+ @param eContainerType
+ Specifies the type of the passed vector.
+ */
+ void initElements(
+ const ::std::vector< css::beans::NamedValue >& rElements,
+ ContainerType eContainerType ) throw (css::uno::RuntimeException);
+
+ /** Returns a VBA implementation object from the passed element.
+
+ If the container type is CONTAINER_NATIVE_VBA, returns the passed
+ object unmodified. If the container type is CONTAINER_CONVERT_ON_DEMAND,
+ calls the virtual function implCreateCollectionItem() that implements
+ creation of the VBA implmentation object.
+
+ @param rElement
+ The container element the VBA implementation object is based on.
+
+ @param rIndex
+ The index or name that has been used to access the item.
+ */
+ css::uno::Any createCollectionItem(
+ const css::uno::Any& rElement,
+ const css::uno::Any& rIndex ) throw (css::uno::RuntimeException);
+
+ /** Returns a collection item specified by its one-based item index.
+
+ @param nIndex
+ The one-based index of the collection item.
+ */
+ css::uno::Any getItemByIndex( sal_Int32 nIndex ) throw (css::uno::RuntimeException);
+
+ /** Returns a collection item specified by its name.
+
+ @param rName
+ The name of the collection item.
+ */
+ css::uno::Any getItemByName( const ::rtl::OUString& rName ) throw (css::uno::RuntimeException);
+
+ /** Returns a collection item specified by its index or name.
+
+ @param rIndex
+ The index or name of the collection item. May be empty, in that
+ case the entire collection is returned.
+ */
+ css::uno::Any getAnyItemOrThis( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException);
+
+ /** Returns a collection item of a specific type specified by its index or
+ name.
+
+ @param rIndex
+ The index or name of the collection item.
+ */
+ template< typename XType >
+ inline css::uno::Reference< XType > getAnyItem( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException)
+ { css::uno::Any aRet; if( rIndex.hasValue() ) aRet = getAnyItemOrThis( rIndex ); return css::uno::Reference< XType >( aRet, css::uno::UNO_QUERY_THROW ); }
+
+protected:
+ /** Derived classes implement creation of a VBA implementation object from
+ the passed intermediate container element.
+
+ May be kept unimplemented if container type is CONTAINER_NATIVE_VBA.
+
+ @param rElement
+ The container element the VBA implementation object is based on.
+
+ @param rIndex
+ The index or name used to access the item. Can be used by
+ implementations as a hint how to find or convert the VBA object.
+ */
+ virtual css::uno::Any implCreateCollectionItem( const css::uno::Any& rElement, const css::uno::Any& rIndex ) throw (css::uno::RuntimeException);
+
+private:
+ css::uno::Reference< css::container::XIndexAccess > mxIndexAccess;
+ css::uno::Reference< css::container::XNameAccess > mxNameAccess;
+ css::uno::Type maElementType;
+ bool mbConvertOnDemand;
+};
+
+// ============================================================================
+
+} // namespace vbahelper
+
+#endif
diff --git a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx
index a7cd8af230..68b8110768 100644
--- a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx
+++ b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx
@@ -61,7 +61,6 @@ public:
virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getVersion() throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL getVBE() throw (css::uno::RuntimeException);
- virtual css::uno::Any SAL_CALL getVBProjects() throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL Run( const ::rtl::OUString& MacroName, const css::uno::Any& varg1, const css::uno::Any& varg2, const css::uno::Any& varg3, const css::uno::Any& varg4, const css::uno::Any& varg5, const css::uno::Any& varg6, const css::uno::Any& varg7, const css::uno::Any& varg8, const css::uno::Any& varg9, const css::uno::Any& varg10, const css::uno::Any& varg11, const css::uno::Any& varg12, const css::uno::Any& varg13, const css::uno::Any& varg14, const css::uno::Any& varg15, const css::uno::Any& varg16, const css::uno::Any& varg17, const css::uno::Any& varg18, const css::uno::Any& varg19, const css::uno::Any& varg20, const css::uno::Any& varg21, const css::uno::Any& varg22, const css::uno::Any& varg23, const css::uno::Any& varg24, const css::uno::Any& varg25, const css::uno::Any& varg26, const css::uno::Any& varg27, const css::uno::Any& varg28, const css::uno::Any& varg29, const css::uno::Any& varg30 ) throw (css::uno::RuntimeException);
virtual void SAL_CALL OnTime( const css::uno::Any& aEarliestTime, const ::rtl::OUString& aFunction, const css::uno::Any& aLatestTime, const css::uno::Any& aSchedule ) throw (css::uno::RuntimeException);
diff --git a/vbahelper/inc/vbahelper/vbacollectionimpl.hxx b/vbahelper/inc/vbahelper/vbacollectionimpl.hxx
index f3f7cb4c19..cf8a200dda 100644
--- a/vbahelper/inc/vbahelper/vbacollectionimpl.hxx
+++ b/vbahelper/inc/vbahelper/vbacollectionimpl.hxx
@@ -89,8 +89,8 @@ private:
/** A wrapper that holds a com.sun.star.container.XEnumeration or a
com.sun.star.container.XIndexAccess and provides an enumeration of VBA objects.
- The method nextElement() needs to be implemented by the derived class. This
- class can be used to convert an enumeration or an index container
+ The method createCollectionObject() needs to be implemented by the derived
+ class. This class can be used to convert an enumeration or an index container
containing UNO objects to an enumeration providing the related VBA objects.
*/
class VBAHELPER_DLLPUBLIC SimpleEnumerationBase : public EnumerationHelper_BASE
diff --git a/vbahelper/inc/vbahelper/vbadocumentbase.hxx b/vbahelper/inc/vbahelper/vbadocumentbase.hxx
index 4a7dc837bf..7f1d3b5ad3 100644
--- a/vbahelper/inc/vbahelper/vbadocumentbase.hxx
+++ b/vbahelper/inc/vbahelper/vbadocumentbase.hxx
@@ -38,6 +38,7 @@ class VBAHELPER_DLLPUBLIC VbaDocumentBase : public VbaDocumentBase_BASE
{
protected:
css::uno::Reference< css::frame::XModel > mxModel;
+ css::uno::Reference< css::uno::XInterface > mxVBProject;
protected:
virtual css::uno::Reference< css::frame::XModel > getModel() { return mxModel; }
VbaDocumentBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext);
diff --git a/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx
index b07dc1358c..99c17e5c75 100644
--- a/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx
+++ b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx
@@ -29,20 +29,26 @@
#ifndef VBAHELPER_VBAEVENTSHELPERBASE_HXX
#define VBAHELPER_VBAEVENTSHELPERBASE_HXX
-#include <com/sun/star/lang/XEventListener.hpp>
-#include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
-#include <cppuhelper/implbase2.hxx>
-#include <map>
#include <deque>
+#include <map>
+#include <boost/unordered_map.hpp>
+#include <com/sun/star/document/XEventListener.hpp>
+#include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
+#include <com/sun/star/util/XChangesListener.hpp>
+#include <cppuhelper/implbase3.hxx>
#include "vbahelper/vbahelper.hxx"
namespace com { namespace sun { namespace star {
+ namespace script { namespace vba { class XVBAModuleInfo; } }
namespace uno { class XComponentContext; }
} } }
// ============================================================================
-typedef ::cppu::WeakImplHelper2< css::script::vba::XVBAEventProcessor, css::lang::XEventListener > VbaEventsHelperBase_BASE;
+typedef ::cppu::WeakImplHelper3<
+ css::script::vba::XVBAEventProcessor,
+ css::document::XEventListener,
+ css::util::XChangesListener > VbaEventsHelperBase_BASE;
class VBAHELPER_DLLPUBLIC VbaEventsHelperBase : public VbaEventsHelperBase_BASE
{
@@ -52,15 +58,24 @@ public:
const css::uno::Reference< css::uno::XComponentContext >& xContext );
virtual ~VbaEventsHelperBase();
- // XVBAEventProcessor
+ // script::vba::XVBAEventProcessor
virtual sal_Bool SAL_CALL hasVbaEventHandler( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
- virtual void SAL_CALL processVbaEvent( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::script::provider::ScriptFrameworkErrorException, css::util::VetoException, css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL processVbaEvent( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::util::VetoException, css::uno::RuntimeException);
- // XEventListener
- virtual void SAL_CALL disposing( const css::lang::EventObject& aSource ) throw (css::uno::RuntimeException);
+ // document::XEventListener
+ virtual void SAL_CALL notifyEvent( const css::document::EventObject& rEvent ) throw (css::uno::RuntimeException);
+
+ // util::XChangesListener
+ virtual void SAL_CALL changesOccurred( const css::util::ChangesEvent& rEvent ) throw (css::uno::RuntimeException);
+
+ // lang::XEventListener
+ virtual void SAL_CALL disposing( const css::lang::EventObject& rEvent ) throw (css::uno::RuntimeException);
// little helpers ---------------------------------------------------------
-
+
+ /** Helper to execute event handlers without throwing any exceptions. */
+ void processVbaEventNoThrow( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs );
+
/** Throws, if the passed sequence does not contain a value at the specified index. */
static inline void checkArgument( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException)
{ if( (nIndex < 0) || (nIndex >= rArgs.getLength()) ) throw css::lang::IllegalArgumentException(); }
@@ -73,12 +88,11 @@ public:
protected:
// ------------------------------------------------------------------------
- enum EventHandlerType { EVENTHANDLER_GLOBAL, EVENTHANDLER_DOCUMENT };
struct EventHandlerInfo
{
sal_Int32 mnEventId;
+ sal_Int32 mnModuleType;
::rtl::OUString maMacroName;
- EventHandlerType meType;
sal_Int32 mnCancelIndex;
css::uno::Any maUserData;
};
@@ -86,14 +100,14 @@ protected:
/** Registers a supported event handler.
@param nEventId Event identifier from com.sun.star.script.vba.VBAEventId.
+ @param nModuleType Type of the module containing the event handler.
@param pcMacroName Name of the associated VBA event handler macro.
- @param eType Document event or global event.
@param nCancelIndex 0-based index of Cancel parameter, or -1.
@param rUserData User data for free usage in derived implementations. */
void registerEventHandler(
sal_Int32 nEventId,
+ sal_Int32 nModuleType,
const sal_Char* pcMacroName,
- EventHandlerType eType = EVENTHANDLER_DOCUMENT,
sal_Int32 nCancelIndex = -1,
const css::uno::Any& rUserData = css::uno::Any() );
@@ -125,7 +139,6 @@ protected:
virtual void implPostProcessEvent(
EventQueue& rEventQueue,
const EventHandlerInfo& rInfo,
- bool bSuccess,
bool bCancel ) throw (css::uno::RuntimeException) = 0;
/** Derived classes have to return the name of the Basic document module. */
@@ -134,25 +147,42 @@ protected:
const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException) = 0;
private:
+ typedef ::std::map< sal_Int32, ::rtl::OUString > ModulePathMap;
+
+ /** Starts listening at the document model. */
+ void startListening();
+ /** Stops listening at the document model. */
+ void stopListening();
+
/** Returns the event handler info struct for the specified event, or throws. */
const EventHandlerInfo& getEventHandlerInfo( sal_Int32 nEventId ) const throw (css::lang::IllegalArgumentException);
/** Searches the event handler in the document and returns its full script path. */
::rtl::OUString getEventHandlerPath(
const EventHandlerInfo& rInfo,
- const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException);
+ const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
- /** Removes this instance from all broadcasters. */
- void stopListening();
+ /** On first call, accesses the Basic library containing the VBA source code. */
+ void ensureVBALibrary() throw (css::uno::RuntimeException);
+
+ /** Returns the type of the Basic module with the specified name. */
+ sal_Int32 getModuleType( const ::rtl::OUString& rModuleName ) throw (css::uno::RuntimeException);
+
+ /** Updates the map containing paths to event handlers for a Basic module. */
+ ModulePathMap& updateModulePathMap( const ::rtl::OUString& rModuleName ) throw (css::uno::RuntimeException);
protected:
css::uno::Reference< css::frame::XModel > mxModel;
SfxObjectShell* mpShell;
private:
- typedef ::std::map< sal_Int32, EventHandlerInfo > EventHandlerMap;
+ typedef ::std::map< sal_Int32, EventHandlerInfo > EventHandlerInfoMap;
+ typedef boost::unordered_map< ::rtl::OUString, ModulePathMap, ::rtl::OUStringHash > EventHandlerPathMap;
- EventHandlerMap maEvents;
+ EventHandlerInfoMap maEventInfos;
+ EventHandlerPathMap maEventPaths;
+ css::uno::Reference< css::script::vba::XVBAModuleInfo > mxModuleInfos;
+ ::rtl::OUString maLibraryName;
bool mbDisposed;
};
diff --git a/vbahelper/inc/vbahelper/vbahelper.hxx b/vbahelper/inc/vbahelper/vbahelper.hxx
index bc6668f537..cfcc71c06b 100644
--- a/vbahelper/inc/vbahelper/vbahelper.hxx
+++ b/vbahelper/inc/vbahelper/vbahelper.hxx
@@ -68,7 +68,12 @@ namespace ooo
throw css::lang::IllegalArgumentException();
return aSomething;
}
- VBAHELPER_DLLPUBLIC css::uno::Reference< css::uno::XInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell );
+
+ class XHelperInterface;
+
+ /** Returns the VBA document implementation object representing the passed UNO document model. */
+ VBAHELPER_DLLPUBLIC css::uno::Reference< XHelperInterface > getVBADocument( const css::uno::Reference< css::frame::XModel >& xModel );
+ VBAHELPER_DLLPUBLIC css::uno::Reference< XHelperInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell );
VBAHELPER_DLLPUBLIC SfxObjectShell* getSfxObjShell( const css::uno::Reference< css::frame::XModel >& xModel ) throw ( css::uno::RuntimeException);
VBAHELPER_DLLPUBLIC css::uno::Reference< css::uno::XInterface > createVBAUnoAPIService( SfxObjectShell* pShell, const sal_Char* _pAsciiName ) throw (css::uno::RuntimeException);
@@ -95,18 +100,32 @@ namespace ooo
VBAHELPER_DLLPUBLIC void PrintOutHelper( SfxViewShell* pViewShell, const css::uno::Any& From, const css::uno::Any& To, const css::uno::Any& Copies, const css::uno::Any& Preview, const css::uno::Any& ActivePrinter, const css::uno::Any& PrintToFile, const css::uno::Any& Collate, const css::uno::Any& PrToFileName, sal_Bool bSelection );
VBAHELPER_DLLPUBLIC void PrintPreviewHelper( const css::uno::Any& EnableChanges, SfxViewShell* );
- /** Extracts a boolean value from the passed Any, which may contain sal_Bool or an integer or floating-point value.
- Returns false, if the Any is empty or contains an incompatible type. */
- VBAHELPER_DLLPUBLIC bool extractBoolFromAny( bool& rbValue, const css::uno::Any& rAny );
- /** Extracts a boolean value from the passed Any, which may contain sal_Bool or an integer or floating-point value.
+ /** Extracts a 32-bit integer value from the passed Any, which may contain an integer or floating-point value.
+ Throws, if the Any is empty or contains an incompatible type. */
+ VBAHELPER_DLLPUBLIC sal_Int32 extractIntFromAny( const css::uno::Any& rAny ) throw (css::uno::RuntimeException);
+ /** Extracts a 32-bit integer value from the passed Any, which may contain an integer or floating-point value.
+ Returns nDefault, if rAny is empty. Throws, if the Any contains an incompatible type. */
+ VBAHELPER_DLLPUBLIC sal_Int32 extractIntFromAny( const css::uno::Any& rAny, sal_Int32 nDefault ) throw (css::uno::RuntimeException);
+
+ /** Extracts a boolean value from the passed Any, which may contain a Boolean or an integer or floating-point value.
Throws, if the Any is empty or contains an incompatible type. */
VBAHELPER_DLLPUBLIC bool extractBoolFromAny( const css::uno::Any& rAny ) throw (css::uno::RuntimeException);
-
+ /** Extracts a boolean value from the passed Any, which may contain a Boolean or an integer or floating-point value.
+ Returns bDefault, if rAny is empty. Throws, if the Any contains an incompatible type. */
+ VBAHELPER_DLLPUBLIC bool extractBoolFromAny( const css::uno::Any& rAny, bool bDefault ) throw (css::uno::RuntimeException);
+
+ /** Extracts a string from the passed Any, which may contain a Boolean, a value, or a string.
+ Throws, if the Any is empty or contains an incompatible type. */
+ VBAHELPER_DLLPUBLIC ::rtl::OUString extractStringFromAny( const css::uno::Any& rAny, bool bUppercaseBool = false ) throw (css::uno::RuntimeException);
+ /** Extracts a string from the passed Any, which may contain a Boolean, a value, or a string.
+ Returns rDefault, if rAny is empty. Throws, if the Any contains an incompatible type. */
+ VBAHELPER_DLLPUBLIC ::rtl::OUString extractStringFromAny( const css::uno::Any& rAny, const ::rtl::OUString& rDefault, bool bUppercaseBool = false ) throw (css::uno::RuntimeException);
+
VBAHELPER_DLLPUBLIC rtl::OUString getAnyAsString( const css::uno::Any& pvargItem ) throw ( css::uno::RuntimeException );
VBAHELPER_DLLPUBLIC rtl::OUString VBAToRegexp(const rtl::OUString &rIn, bool bForLike = false); // needs to be in an uno service ( already this code is duplicated in basic )
- VBAHELPER_DLLPUBLIC double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical);
- VBAHELPER_DLLPUBLIC double PointsToPixels( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical);
- VBAHELPER_DLLPUBLIC double PixelsToPoints( css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical);
+ VBAHELPER_DLLPUBLIC double getPixelTo100thMillimeterConversionFactor( const css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical);
+ VBAHELPER_DLLPUBLIC double PointsToPixels( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical);
+ VBAHELPER_DLLPUBLIC double PixelsToPoints( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical);
VBAHELPER_DLLPUBLIC sal_Int32 PointsToHmm( double fPoints );
VBAHELPER_DLLPUBLIC double HmmToPoints( sal_Int32 nHmm );
VBAHELPER_DLLPUBLIC sal_Int32 getPointerStyle( const css::uno::Reference< css::frame::XModel >& );
@@ -142,14 +161,21 @@ class VBAHELPER_DLLPUBLIC AbstractGeometryAttributes // probably should replace
{
public:
virtual ~AbstractGeometryAttributes() {}
- virtual double getLeft() = 0;
+ virtual double getLeft() const = 0;
virtual void setLeft( double ) = 0;
- virtual double getTop() = 0;
+ virtual double getTop() const = 0;
virtual void setTop( double ) = 0;
- virtual double getHeight() = 0;
+ virtual double getHeight() const = 0;
virtual void setHeight( double ) = 0;
- virtual double getWidth() = 0;
+ virtual double getWidth() const = 0;
virtual void setWidth( double ) = 0;
+
+ virtual double getInnerHeight() const { return 0.0; }
+ virtual void setInnerHeight( double ) {}
+ virtual double getInnerWidth() const { return 0.0; }
+ virtual void setInnerWidth( double ) {}
+ virtual double getOffsetX() const { return 0.0; }
+ virtual double getOffsetY() const { return 0.0; }
};
namespace msforms {
@@ -163,20 +189,13 @@ protected:
public:
ShapeHelper( const css::uno::Reference< css::drawing::XShape >& _xShape) throw (css::script::BasicErrorException );
- double getHeight();
-
- void setHeight(double _fheight) throw ( css::script::BasicErrorException );
-
- double getWidth();
-
+ double getHeight() const;
+ void setHeight(double _fheight) throw ( css::script::BasicErrorException );
+ double getWidth() const;
void setWidth(double _fWidth) throw ( css::script::BasicErrorException );
-
- double getLeft();
-
+ double getLeft() const;
void setLeft(double _fLeft);
-
- double getTop();
-
+ double getTop() const;
void setTop(double _fTop);
};
@@ -185,13 +204,13 @@ class VBAHELPER_DLLPUBLIC ConcreteXShapeGeometryAttributes : public AbstractGeom
std::auto_ptr< ShapeHelper > m_pShapeHelper;
public:
ConcreteXShapeGeometryAttributes( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& xShape );
- virtual double getLeft();
+ virtual double getLeft() const;
virtual void setLeft( double nLeft );
- virtual double getTop();
+ virtual double getTop() const;
virtual void setTop( double nTop );
- virtual double getHeight();
+ virtual double getHeight() const;
virtual void setHeight( double nHeight );
- virtual double getWidth();
+ virtual double getWidth() const;
virtual void setWidth( double nWidth);
virtual ~ConcreteXShapeGeometryAttributes();
};
@@ -202,19 +221,39 @@ public:
#define VBA_WIDTH "Width"
class VBAHELPER_DLLPUBLIC UserFormGeometryHelper : public AbstractGeometryAttributes
{
+public:
+ UserFormGeometryHelper(
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::awt::XControl >& xControl,
+ double fOffsetX, double fOffsetY );
+ virtual double getLeft() const;
+ virtual void setLeft( double fLeft );
+ virtual double getTop() const;
+ virtual void setTop( double fTop );
+ virtual double getWidth() const;
+ virtual void setWidth( double fWidth );
+ virtual double getHeight() const;
+ virtual void setHeight( double fHeight );
+ virtual double getInnerWidth() const;
+ virtual void setInnerWidth( double fWidth );
+ virtual double getInnerHeight() const;
+ virtual void setInnerHeight( double fHeight );
+ virtual double getOffsetX() const;
+ virtual double getOffsetY() const;
+
+private:
+ double implGetPos( bool bPosY ) const;
+ void implSetPos( double fPos, bool bPosY );
+ double implGetSize( bool bHeight, bool bOuter ) const;
+ void implSetSize( double fSize, bool bHeight, bool bOuter );
+
+private:
css::uno::Reference< css::awt::XWindow > mxWindow;
+ css::uno::Reference< css::beans::XPropertySet > mxModelProps;
+ css::uno::Reference< css::awt::XUnitConversion > mxUnitConv;
+ double mfOffsetX;
+ double mfOffsetY;
sal_Bool mbDialog;
-
-public:
- UserFormGeometryHelper( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::awt::XControl >& xControl );
- virtual double getLeft();
- virtual void setLeft( double nLeft );
- virtual double getTop();
- virtual void setTop( double nTop );
- virtual double getHeight();
- virtual void setHeight( double nHeight );
- virtual double getWidth();
- virtual void setWidth( double nWidth);
};
class VBAHELPER_DLLPUBLIC ContainerUtilities
@@ -256,8 +295,8 @@ public:
virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw ( css::uno::RuntimeException );
};
- } // openoffice
-} // org
+ } // vba
+} // ooo
namespace ov = ooo::vba;
diff --git a/vbahelper/inc/vbahelper/vbawindowbase.hxx b/vbahelper/inc/vbahelper/vbawindowbase.hxx
index 963ae4d510..9534fe8f85 100644
--- a/vbahelper/inc/vbahelper/vbawindowbase.hxx
+++ b/vbahelper/inc/vbahelper/vbawindowbase.hxx
@@ -25,24 +25,30 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#ifndef VBA_WINDOWBASE_HXX
#define VBA_WINDOWBASE_HXX
-#include <cppuhelper/implbase1.hxx>
-#include <ooo/vba/XWindowBase.hpp>
-#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/awt/XDevice.hpp>
+#include <ooo/vba/XWindowBase.hpp>
+#include <com/sun/star/awt/XWindow2.hpp>
+#include <com/sun/star/frame/XController.hpp>
#include <vbahelper/vbahelperinterface.hxx>
-typedef InheritedHelperInterfaceImpl1<ov::XWindowBase > WindowBaseImpl_BASE;
+typedef InheritedHelperInterfaceImpl1< ov::XWindowBase > WindowBaseImpl_BASE;
class VBAHELPER_DLLPUBLIC VbaWindowBase : public WindowBaseImpl_BASE
{
-protected:
- css::uno::Reference< css::frame::XModel > m_xModel;
public:
- VbaWindowBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::frame::XModel >& xModel );
- VbaWindowBase( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext > const& xContext );
+ VbaWindowBase(
+ const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::frame::XModel >& xModel,
+ const css::uno::Reference< css::frame::XController >& xController )
+ throw (css::uno::RuntimeException);
+ VbaWindowBase(
+ css::uno::Sequence< css::uno::Any > const& aArgs,
+ css::uno::Reference< css::uno::XComponentContext > const& xContext )
+ throw (css::uno::RuntimeException);
// XWindowBase
virtual sal_Int32 SAL_CALL getHeight() throw (css::uno::RuntimeException) ;
@@ -59,6 +65,19 @@ public:
// XHelperInterface
virtual rtl::OUString& getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+
+protected:
+ css::uno::Reference< css::frame::XController > getController() throw (css::uno::RuntimeException);
+ css::uno::Reference< css::awt::XWindow > getWindow() throw (css::uno::RuntimeException);
+ css::uno::Reference< css::awt::XWindow2 > getWindow2() throw (css::uno::RuntimeException);
+
+ css::uno::Reference< css::frame::XModel > m_xModel;
+
+private:
+ void construct( const css::uno::Reference< css::frame::XController >& xController ) throw (css::uno::RuntimeException);
+
+ css::uno::WeakReference< css::frame::XController > m_xController;
+ css::uno::WeakReference< css::awt::XWindow > m_xWindow;
};
#endif //VBA_WINDOWBASE_HXX
diff --git a/vbahelper/inc/vbahelper/weakreference.hxx b/vbahelper/inc/vbahelper/weakreference.hxx
new file mode 100755
index 0000000000..661f3bc5d7
--- /dev/null
+++ b/vbahelper/inc/vbahelper/weakreference.hxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2011 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef VBAHELPER_WEAKREFERENCE_HXX
+#define VBAHELPER_WEAKREFERENCE_HXX
+
+#include <cppuhelper/weakref.hxx>
+#include <rtl/ref.hxx>
+
+namespace vbahelper {
+
+// ============================================================================
+
+/** A weak reference holding any UNO implementation object.
+
+ The held object must implement the ::com::sun::star::uno::XWeak interface.
+
+ In difference to the ::com::sun::star::uno::WeakReference<> implementation
+ from cppuhelper/weakref.hxx, the class type of this weak reference is not
+ restricted to UNO interface types, but can be used for any C++ class type
+ implementing the XWeak interface somehow (e.g. ::cppu::WeakImplHelperN<>,
+ ::cppu::ImplInheritanceHelperN<>, etc.).
+ */
+template< typename ObjectType >
+class WeakReference
+{
+public:
+ /** Default constructor. Creates an empty weak reference.
+ */
+ inline explicit WeakReference() SAL_THROW( () ) : mpObject( 0 ) {}
+
+ /** Initializes this weak reference with the passed reference to an object.
+ */
+ inline explicit WeakReference( const ::rtl::Reference< ObjectType >& rxObject ) SAL_THROW( () ) :
+ mxWeakRef( rxObject.get() ), mpObject( rxObject.get() ) {}
+
+ /** Releases this weak reference and takes over the passed reference.
+ */
+ inline WeakReference& SAL_CALL operator=( const ::rtl::Reference< ObjectType >& rxObject ) SAL_THROW( () )
+ {
+ mxWeakRef = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XWeak >( rxObject.get() );
+ mpObject = rxObject.get();
+ return *this;
+ }
+
+ /** Gets an RTL reference to the referenced object.
+
+ @return Reference or null, if the weakly referenced object is gone.
+ */
+ inline SAL_CALL operator ::rtl::Reference< ObjectType >() SAL_THROW( () )
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XWeak > xRef = mxWeakRef;
+ ::rtl::Reference< ObjectType > xObject;
+ if( xRef.is() )
+ xObject = mpObject;
+ else
+ mpObject = 0;
+ return xObject;
+ }
+
+private:
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XWeak > mxWeakRef;
+ ObjectType* mpObject;
+};
+
+// ============================================================================
+
+} // namespace vbahelper
+
+#endif
diff --git a/vbahelper/source/msforms/vbabutton.cxx b/vbahelper/source/msforms/vbabutton.cxx
index 69e4733c5d..9b3e870466 100644
--- a/vbahelper/source/msforms/vbabutton.cxx
+++ b/vbahelper/source/msforms/vbabutton.cxx
@@ -25,8 +25,9 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#include "vbabutton.hxx"
-#include <vector>
+#include "vbanewfont.hxx"
using namespace com::sun::star;
using namespace ooo::vba;
@@ -52,7 +53,57 @@ ScVbaButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star
m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
}
-rtl::OUString&
+sal_Bool SAL_CALL ScVbaButton::getAutoSize() throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+void SAL_CALL ScVbaButton::setAutoSize( sal_Bool /*bAutoSize*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Bool SAL_CALL ScVbaButton::getCancel() throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+void SAL_CALL ScVbaButton::setCancel( sal_Bool /*bCancel*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Bool SAL_CALL ScVbaButton::getDefault() throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+void SAL_CALL ScVbaButton::setDefault( sal_Bool /*bDefault*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaButton::getBackColor() throw (uno::RuntimeException)
+{
+ return 0;
+}
+
+void SAL_CALL ScVbaButton::setBackColor( sal_Int32 /*nBackColor*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaButton::getForeColor() throw (uno::RuntimeException)
+{
+ return 0;
+}
+
+void SAL_CALL ScVbaButton::setForeColor( sal_Int32 /*nForeColor*/ ) throw (uno::RuntimeException)
+{
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaButton::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
+rtl::OUString&
ScVbaButton::getServiceImplName()
{
static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaButton") );
diff --git a/vbahelper/source/msforms/vbabutton.hxx b/vbahelper/source/msforms/vbabutton.hxx
index 1a01d69165..24c127b906 100644
--- a/vbahelper/source/msforms/vbabutton.hxx
+++ b/vbahelper/source/msforms/vbabutton.hxx
@@ -28,12 +28,12 @@
#ifndef SC_VBA_BUTTON_HXX
#define SC_VBA_BUTTON_HXX
#include <cppuhelper/implbase1.hxx>
-#include <ooo/vba/msforms/XButton.hpp>
+#include <ooo/vba/msforms/XCommandButton.hpp>
#include "vbacontrol.hxx"
#include <vbahelper/vbahelper.hxx>
-typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XButton > ButtonImpl_BASE;
+typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XCommandButton > ButtonImpl_BASE;
class ScVbaButton : public ButtonImpl_BASE
{
@@ -42,6 +42,17 @@ public:
// Attributes
virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getAutoSize() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getCancel() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCancel( sal_Bool bCancel ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getDefault() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setDefault( sal_Bool bDefault ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getBackColor() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getForeColor() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setForeColor( sal_Int32 nForeColor ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
//XHelperInterface
virtual rtl::OUString& getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
diff --git a/vbahelper/source/msforms/vbacheckbox.cxx b/vbahelper/source/msforms/vbacheckbox.cxx
index fea0853b68..93d54fd13a 100644
--- a/vbahelper/source/msforms/vbacheckbox.cxx
+++ b/vbahelper/source/msforms/vbacheckbox.cxx
@@ -25,9 +25,10 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#include "vbacheckbox.hxx"
+#include "vbanewfont.hxx"
#include <vbahelper/helperdecl.hxx>
-#include <vector>
using namespace com::sun::star;
using namespace ooo::vba;
@@ -88,7 +89,13 @@ ScVbaCheckbox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeExcept
if ( nValue != nOldValue )
fireClickEvent();
}
-rtl::OUString&
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaCheckbox::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
+rtl::OUString&
ScVbaCheckbox::getServiceImplName()
{
static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCheckbox") );
diff --git a/vbahelper/source/msforms/vbacheckbox.hxx b/vbahelper/source/msforms/vbacheckbox.hxx
index 0dbba7412e..3d76210afa 100644
--- a/vbahelper/source/msforms/vbacheckbox.hxx
+++ b/vbahelper/source/msforms/vbacheckbox.hxx
@@ -44,6 +44,7 @@ public:
virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException);
virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
// XDefaultProperty
rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value")); }
//XHelperInterface
diff --git a/vbahelper/source/msforms/vbacombobox.cxx b/vbahelper/source/msforms/vbacombobox.cxx
index d0446bca77..67136d6706 100644
--- a/vbahelper/source/msforms/vbacombobox.cxx
+++ b/vbahelper/source/msforms/vbacombobox.cxx
@@ -25,11 +25,19 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#include "vbacombobox.hxx"
#include <vector>
#include <filter/msfilter/msvbahelper.hxx>
#include <basic/sbstar.hxx>
#include <basic/sbmod.hxx>
+#include "vbanewfont.hxx"
+#include <ooo/vba/msforms/fmStyle.hpp>
+#include <ooo/vba/msforms/fmDropButtonStyle.hpp>
+#include <ooo/vba/msforms/fmDragBehavior.hpp>
+#include <ooo/vba/msforms/fmEnterFieldBehavior.hpp>
+#include <ooo/vba/msforms/fmListStyle.hpp>
+#include <ooo/vba/msforms/fmTextAlign.hpp>
using namespace com::sun::star;
using namespace ooo::vba;
@@ -45,9 +53,17 @@ const static rtl::OUString CONTROLSOURCEPROP( RTL_CONSTASCII_USTRINGPARAM("DataF
ScVbaComboBox::ScVbaComboBox( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper, bool bDialogType ) : ComboBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ), mbDialogType( bDialogType )
{
- mpListHelper.reset( new ListControlHelper( m_xProps ) );
- // grab the default value property name
- m_xProps->getPropertyValue( CONTROLSOURCEPROP ) >>= sSourceName;
+ mpListHelper.reset( new ListControlHelper( m_xProps ) );
+ try
+ {
+ // grab the default value property name
+ m_xProps->getPropertyValue( CONTROLSOURCEPROP ) >>= sSourceName;
+ }
+ catch( uno::Exception& )
+ {
+ }
+ if( sSourceName.getLength() == 0 )
+ sSourceName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) );
}
// Attributes
@@ -114,22 +130,13 @@ void SAL_CALL
ScVbaComboBox::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
{
rtl::OUString sOldValue, sNewValue;
- getValue() >>= sOldValue;
-
- uno::Any aConverted = _value;
- uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext );
- try
- {
- aConverted = xConverter.is() ? xConverter->convertTo( _value, getCppuType( static_cast< const rtl::OUString* >(0) ) ) : aConverted;
- }
- catch( const uno::Exception& /*ex*/ )
- {
- throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid value" ) ), uno::Reference< uno::XInterface >() );
- }
+ // booleans are converted to uppercase strings
+ sOldValue = extractStringFromAny( getValue(), ::rtl::OUString(), true );
+ // booleans are converted to uppercase strings
+ sNewValue = extractStringFromAny( _value, ::rtl::OUString(), true );
- m_xProps->setPropertyValue( sSourceName, aConverted );
+ m_xProps->setPropertyValue( sSourceName, uno::Any( sNewValue ) );
- aConverted >>= sNewValue;
if ( sNewValue != sOldValue )
{
// If the new value is in current list, we should fire click event, otherwise fire the change event.
@@ -172,22 +179,22 @@ ScVbaComboBox::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex )
void SAL_CALL
ScVbaComboBox::removeItem( const uno::Any& index ) throw (uno::RuntimeException)
- {
+{
mpListHelper->removeItem( index );
}
void SAL_CALL
ScVbaComboBox::Clear( ) throw (uno::RuntimeException)
- {
+{
mpListHelper->Clear();
- }
+}
void SAL_CALL
ScVbaComboBox::setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException)
{
ScVbaControl::setRowSource( _rowsource );
mpListHelper->setRowSource( _rowsource );
- }
+}
sal_Int32 SAL_CALL
ScVbaComboBox::getListCount() throw (uno::RuntimeException)
@@ -199,9 +206,73 @@ uno::Any SAL_CALL
ScVbaComboBox::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn ) throw (uno::RuntimeException)
{
return mpListHelper->List( pvargIndex, pvarColumn );
- }
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getStyle() throw (uno::RuntimeException)
+{
+ return msforms::fmStyle::fmStyleDropDownCombo;
+}
+
+void SAL_CALL ScVbaComboBox::setStyle( sal_Int32 /*nStyle*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getDropButtonStyle() throw (uno::RuntimeException)
+{
+ return msforms::fmDropButtonStyle::fmDropButtonStyleArrow;
+}
+
+void SAL_CALL ScVbaComboBox::setDropButtonStyle( sal_Int32 /*nDropButtonStyle*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getDragBehavior() throw (uno::RuntimeException)
+{
+ return msforms::fmDragBehavior::fmDragBehaviorDisabled;
+}
+
+void SAL_CALL ScVbaComboBox::setDragBehavior( sal_Int32 /*nDragBehavior*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getEnterFieldBehavior() throw (uno::RuntimeException)
+{
+ return msforms::fmEnterFieldBehavior::fmEnterFieldBehaviorSelectAll;
+}
+
+void SAL_CALL ScVbaComboBox::setEnterFieldBehavior( sal_Int32 /*nEnterFieldBehavior*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getListStyle() throw (uno::RuntimeException)
+{
+ return msforms::fmListStyle::fmListStylePlain;
+}
+
+void SAL_CALL ScVbaComboBox::setListStyle( sal_Int32 /*nListStyle*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getTextAlign() throw (uno::RuntimeException)
+{
+ return msforms::fmTextAlign::fmTextAlignLeft;
+}
+
+void SAL_CALL ScVbaComboBox::setTextAlign( sal_Int32 /*nTextAlign*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getTextLength() throw (uno::RuntimeException)
+{
+ return getText().getLength();
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaComboBox::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
-rtl::OUString&
+rtl::OUString&
ScVbaComboBox::getServiceImplName()
{
static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaComboBox") );
diff --git a/vbahelper/source/msforms/vbacombobox.hxx b/vbahelper/source/msforms/vbacombobox.hxx
index 77a546e678..cc66c40dae 100644
--- a/vbahelper/source/msforms/vbacombobox.hxx
+++ b/vbahelper/source/msforms/vbacombobox.hxx
@@ -59,6 +59,20 @@ public:
virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
virtual void SAL_CALL setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setStyle( sal_Int32 nStyle ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDropButtonStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setDropButtonStyle( sal_Int32 nDropButtonStyle ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDragBehavior() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setDragBehavior( sal_Int32 nDragBehavior ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getEnterFieldBehavior() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setEnterFieldBehavior( sal_Int32 nEnterFieldBehavior ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getListStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setListStyle( sal_Int32 nListStyle ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getTextAlign() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setTextAlign( sal_Int32 nTextAlign ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getTextLength() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
// Methods
virtual void SAL_CALL AddItem( const css::uno::Any& pvargItem, const css::uno::Any& pvargIndex ) throw (css::uno::RuntimeException);
diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx
index 2d100caa2e..7c19b117b1 100644
--- a/vbahelper/source/msforms/vbacontrol.cxx
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -48,8 +48,8 @@
#ifdef VBA_OOBUILD_HACK
#include <svtools/bindablecontrolhelper.hxx>
#endif
-#include"vbacontrol.hxx"
-#include"vbacombobox.hxx"
+#include "vbacontrol.hxx"
+#include "vbacombobox.hxx"
#include "vbabutton.hxx"
#include "vbalabel.hxx"
#include "vbatextbox.hxx"
@@ -491,112 +491,113 @@ void ScVbaControl::fireClickEvent()
fireEvent( evt );
}
-//ScVbaControlFactory
-
-ScVbaControlFactory::ScVbaControlFactory( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel ): m_xContext( xContext ), m_xControl( xControl ), m_xModel( xModel )
+sal_Int32 SAL_CALL ScVbaControl::getTabIndex() throw (uno::RuntimeException)
{
+ return 1;
}
-ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< uno::XInterface >& xParent ) throw (uno::RuntimeException)
+void SAL_CALL ScVbaControl::setTabIndex( sal_Int32 /*nTabIndex*/ ) throw (uno::RuntimeException)
{
- uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY );
- if ( xControlShape.is() ) // form controls
- return createControl( xControlShape, xParent );
- uno::Reference< awt::XControl > xControl( m_xControl, uno::UNO_QUERY );
- if ( !xControl.is() )
- throw uno::RuntimeException(); // really we should be more informative
- return createControl( xControl, xParent );
}
-ScVbaControl* ScVbaControlFactory::createControl(const uno::Reference< drawing::XControlShape >& xControlShape, const uno::Reference< uno::XInterface >& /*xParent*/ ) throw (uno::RuntimeException)
+//ScVbaControlFactory
+
+/*static*/ uno::Reference< msforms::XControl > ScVbaControlFactory::createShapeControl(
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< drawing::XControlShape >& xControlShape,
+ const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
{
uno::Reference< beans::XPropertySet > xProps( xControlShape->getControl(), uno::UNO_QUERY_THROW );
sal_Int32 nClassId = -1;
const static rtl::OUString sClassId( RTL_CONSTASCII_USTRINGPARAM("ClassId") );
xProps->getPropertyValue( sClassId ) >>= nClassId;
uno::Reference< XHelperInterface > xVbaParent; // #FIXME - should be worksheet I guess
- sal_Bool bToggle = sal_False;
+ uno::Reference< drawing::XShape > xShape( xControlShape, uno::UNO_QUERY_THROW );
+ ::std::auto_ptr< ConcreteXShapeGeometryAttributes > xGeoHelper( new ConcreteXShapeGeometryAttributes( xContext, xShape ) );
switch( nClassId )
{
case form::FormComponentType::COMBOBOX:
- return new ScVbaComboBox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
+ return new ScVbaComboBox( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
case form::FormComponentType::COMMANDBUTTON:
-
- xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Toggle") ) ) >>= bToggle;
- if ( bToggle )
- return new ScVbaToggleButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
- else
- return new ScVbaButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
-
+ return new ScVbaButton( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
case form::FormComponentType::FIXEDTEXT:
- return new ScVbaLabel( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
+ return new ScVbaLabel( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
case form::FormComponentType::TEXTFIELD:
- return new ScVbaTextBox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
+ return new ScVbaTextBox( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
case form::FormComponentType::CHECKBOX:
- return new ScVbaCheckbox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
+ return new ScVbaCheckbox( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
case form::FormComponentType::RADIOBUTTON:
- return new ScVbaRadioButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
+ return new ScVbaRadioButton( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
case form::FormComponentType::LISTBOX:
- return new ScVbaListBox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
+ return new ScVbaListBox( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
case form::FormComponentType::SPINBUTTON:
- return new ScVbaSpinButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
+ return new ScVbaSpinButton( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
case form::FormComponentType::IMAGECONTROL:
- return new ScVbaImage( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
- default:
- throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
- "Donot support this Control Type." )), uno::Reference< uno::XInterface >() );
+ return new ScVbaImage( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
}
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control." ), uno::Reference< uno::XInterface >() );
}
-ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< awt::XControl >& xControl, const uno::Reference< uno::XInterface >& xParent ) throw (uno::RuntimeException)
+/*static*/ uno::Reference< msforms::XControl > ScVbaControlFactory::createUserformControl(
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< awt::XControl >& xControl,
+ const uno::Reference< awt::XControl >& xDialog,
+ const uno::Reference< frame::XModel >& xModel,
+ double fOffsetX, double fOffsetY ) throw (uno::RuntimeException)
{
uno::Reference< beans::XPropertySet > xProps( xControl->getModel(), uno::UNO_QUERY_THROW );
uno::Reference< lang::XServiceInfo > xServiceInfo( xProps, uno::UNO_QUERY_THROW );
- ScVbaControl* pControl = NULL;
+ uno::Reference< msforms::XControl > xVBAControl;
uno::Reference< XHelperInterface > xVbaParent; // #FIXME - should be worksheet I guess
+ ::std::auto_ptr< UserFormGeometryHelper > xGeoHelper( new UserFormGeometryHelper( xContext, xControl, fOffsetX, fOffsetY ) );
+
if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCheckBoxModel") ) ) )
- pControl = new ScVbaCheckbox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaCheckbox( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) ) )
- pControl = new ScVbaRadioButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaRadioButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlEditModel") ) ) )
- pControl = new ScVbaTextBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), true );
+ xVBAControl.set( new ScVbaTextBox( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), true ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlButtonModel") ) ) )
{
sal_Bool bToggle = sal_False;
xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Toggle") ) ) >>= bToggle;
if ( bToggle )
- pControl = new ScVbaToggleButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaToggleButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
else
- pControl = new ScVbaButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
}
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") ) ) )
- pControl = new ScVbaComboBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), true );
+ xVBAControl.set( new ScVbaComboBox( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), true ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) ) )
- pControl = new ScVbaListBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaListBox( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) ) )
- pControl = new ScVbaLabel( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaLabel( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlImageControlModel") ) ) )
- pControl = new ScVbaImage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaImage( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlProgressBarModel") ) ) )
- pControl = new ScVbaProgressBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaProgressBar( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ) )
- pControl = new ScVbaFrame( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaFrame( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), xDialog ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlScrollBarModel") ) ) )
- pControl = new ScVbaScrollBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaScrollBar( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoMultiPageModel") ) ) )
- pControl = new ScVbaMultiPage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), xParent );
+ xVBAControl.set( new ScVbaMultiPage( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), xDialog ) );
+ else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlSpinButtonModel") ) ) )
+ xVBAControl.set( new ScVbaSpinButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
+ else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.custom.awt.UnoControlSystemAXContainerModel") ) ) )
+ xVBAControl.set( new VbaSystemAXControl( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
// #FIXME implement a page control
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoPageModel") ) ) )
- pControl = new ScVbaControl( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaControl( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoFrameModel") ) ) )
- pControl = new ScVbaFrame( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaFrame( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), xDialog ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlSpinButtonModel") ) ) )
- pControl = new ScVbaSpinButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ xVBAControl.set( new ScVbaSpinButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.custom.awt.UnoControlSystemAXContainerModel") ) ) )
- pControl = new VbaSystemAXControl( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
- else
- throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unsupported control ")), uno::Reference< uno::XInterface >() );
- return pControl;
+ xVBAControl.set( new VbaSystemAXControl( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
+ if( xVBAControl.is() )
+ return xVBAControl;
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control." ), uno::Reference< uno::XInterface >() );
}
rtl::OUString&
@@ -618,8 +619,6 @@ ScVbaControl::getServiceNames()
return aServiceNames;
}
-
-
typedef cppu::WeakImplHelper1< XControlProvider > ControlProvider_BASE;
class ControlProviderImpl : public ControlProvider_BASE
{
@@ -627,7 +626,6 @@ class ControlProviderImpl : public ControlProvider_BASE
public:
ControlProviderImpl( const uno::Reference< uno::XComponentContext >& xCtx ) : m_xCtx( xCtx ) {}
virtual uno::Reference< msforms::XControl > SAL_CALL createControl( const uno::Reference< drawing::XControlShape >& xControl, const uno::Reference< frame::XModel >& xDocOwner ) throw (uno::RuntimeException);
- virtual uno::Reference< msforms::XControl > SAL_CALL createUserformControl( const uno::Reference< awt::XControl >& xControl, const uno::Reference< awt::XControl >& xDialog, const uno::Reference< frame::XModel >& xDocOwner ) throw (uno::RuntimeException);
};
uno::Reference< msforms::XControl > SAL_CALL
@@ -635,27 +633,10 @@ ControlProviderImpl::createControl( const uno::Reference< drawing::XControlShape
{
uno::Reference< msforms::XControl > xControlToReturn;
if ( xControlShape.is() )
- {
- ScVbaControlFactory controlFactory( m_xCtx, xControlShape, xDocOwner );
- xControlToReturn.set( controlFactory.createControl( xDocOwner ) );
- }
+ xControlToReturn = ScVbaControlFactory::createShapeControl( m_xCtx, xControlShape, xDocOwner );
return xControlToReturn;
}
-uno::Reference< msforms::XControl > SAL_CALL
-ControlProviderImpl::createUserformControl( const uno::Reference< awt::XControl >& xControl, const uno::Reference< awt::XControl >& xDialog, const uno::Reference< frame::XModel >& xDocOwner ) throw (uno::RuntimeException)
-{
- uno::Reference< msforms::XControl > xControlToReturn;
- if ( xControl.is() && xDialog.is() )
- {
-
- ScVbaControlFactory controlFactory( m_xCtx, xControl, xDocOwner );
- xControlToReturn.set( controlFactory.createControl( xDialog->getModel() ) );
- ScVbaControl* pControl = dynamic_cast< ScVbaControl* >( xControlToReturn.get() );
- pControl->setGeometryHelper( new UserFormGeometryHelper( m_xCtx, xControl ) );
- }
- return xControlToReturn;
-}
namespace controlprovider
{
diff --git a/vbahelper/source/msforms/vbacontrol.hxx b/vbahelper/source/msforms/vbacontrol.hxx
index 2e00b26741..8eba8c5714 100644
--- a/vbahelper/source/msforms/vbacontrol.hxx
+++ b/vbahelper/source/msforms/vbacontrol.hxx
@@ -105,6 +105,8 @@ public:
virtual void SAL_CALL setControlTipText( const rtl::OUString& ) throw (css::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getTag() throw (css::uno::RuntimeException);
virtual void SAL_CALL setTag( const ::rtl::OUString& aTag ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getTabIndex() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setTabIndex( sal_Int32 nTabIndex ) throw (css::uno::RuntimeException);
//remove resouce because ooo.vba.excel.XControl is a wrapper of com.sun.star.drawing.XControlShape
virtual void removeResouce() throw( css::uno::RuntimeException );
virtual ::sal_Int32 SAL_CALL getForeColor() throw (::com::sun::star::uno::RuntimeException);
@@ -118,15 +120,21 @@ public:
class ScVbaControlFactory
{
public:
- ScVbaControlFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext,
- const css::uno::Reference< css::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel );
- ScVbaControl* createControl( const css::uno::Reference< css::uno::XInterface >& xParent ) throw ( css::uno::RuntimeException );
+ static css::uno::Reference< ov::msforms::XControl > createShapeControl(
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::drawing::XControlShape >& xControlShape,
+ const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
+
+ static css::uno::Reference< ov::msforms::XControl > createUserformControl(
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::awt::XControl >& xControl,
+ const css::uno::Reference< css::awt::XControl >& xDialog,
+ const css::uno::Reference< css::frame::XModel >& xModel,
+ double fOffsetX, double fOffsetY ) throw (css::uno::RuntimeException);
+
private:
- ScVbaControl* createControl( const css::uno::Reference< css::awt::XControl >&, const css::uno::Reference< css::uno::XInterface >& ) throw ( css::uno::RuntimeException );
- ScVbaControl* createControl( const css::uno::Reference< css::drawing::XControlShape >&, const css::uno::Reference< css::uno::XInterface >& ) throw ( css::uno::RuntimeException );
- css::uno::Reference< css::uno::XComponentContext > m_xContext;
- css::uno::Reference< css::uno::XInterface > m_xControl;
- css::uno::Reference< css::frame::XModel > m_xModel;
+ ScVbaControlFactory();
+ ~ScVbaControlFactory();
};
#endif//SC_VBA_CONTROL_HXX
diff --git a/vbahelper/source/msforms/vbacontrols.cxx b/vbahelper/source/msforms/vbacontrols.cxx
index 9dbe1e3588..be5d05e7f3 100644
--- a/vbahelper/source/msforms/vbacontrols.cxx
+++ b/vbahelper/source/msforms/vbacontrols.cxx
@@ -28,11 +28,16 @@
#include <com/sun/star/awt/XControl.hpp>
#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/script/XInvocation.hpp>
#include <com/sun/star/lang/WrappedTargetException.hpp>
#include "vbacontrols.hxx"
+#include "vbacontrol.hxx"
#include <cppuhelper/implbase2.hxx>
#include <ooo/vba//XControlProvider.hpp>
#include <boost/unordered_map.hpp>
@@ -166,11 +171,28 @@ class ControlsEnumWrapper : public EnumerationHelper_BASE
uno::Reference<uno::XComponentContext > m_xContext;
uno::Reference<container::XIndexAccess > m_xIndexAccess;
uno::Reference<awt::XControl > m_xDlg;
+ uno::Reference< frame::XModel > m_xModel;
+ double mfOffsetX;
+ double mfOffsetY;
sal_Int32 nIndex;
public:
- ControlsEnumWrapper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess, const uno::Reference< awt::XControl >& xDlg ) : m_xParent( xParent ), m_xContext( xContext), m_xIndexAccess( xIndexAccess ), m_xDlg( xDlg ), nIndex( 0 ) {}
+ ControlsEnumWrapper(
+ const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< container::XIndexAccess >& xIndexAccess,
+ const uno::Reference< awt::XControl >& xDlg,
+ const uno::Reference< frame::XModel >& xModel,
+ double fOffsetX, double fOffsetY ) :
+ m_xParent( xParent ),
+ m_xContext( xContext),
+ m_xIndexAccess( xIndexAccess ),
+ m_xDlg( xDlg ),
+ m_xModel( xModel ),
+ mfOffsetX( fOffsetX ),
+ mfOffsetY( fOffsetY ),
+ nIndex( 0 ) {}
virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
{
@@ -181,14 +203,12 @@ public:
{
if ( nIndex < m_xIndexAccess->getCount() )
{
- uno::Reference< frame::XModel > xModel;
uno::Reference< awt::XControl > xControl;
m_xIndexAccess->getByIndex( nIndex++ ) >>= xControl;
- uno::Reference<lang::XMultiComponentFactory > xServiceManager( m_xContext->getServiceManager(), uno::UNO_QUERY_THROW );
- uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.ControlProvider" ) ), m_xContext ), uno::UNO_QUERY_THROW );
-
- uno::Reference< msforms::XControl > xVBAControl( xControlProvider->createUserformControl( xControl, m_xDlg, xModel ) );
+ uno::Reference< msforms::XControl > xVBAControl;
+ if ( xControl.is() && m_xDlg.is() )
+ xVBAControl = ScVbaControlFactory::createUserformControl( m_xContext, xControl, m_xDlg, m_xModel, mfOffsetX, mfOffsetY );
return uno::makeAny( xVBAControl );
}
throw container::NoSuchElementException();
@@ -203,17 +223,24 @@ lcl_controlsWrapper( const uno::Reference< awt::XControl >& xDlg )
return new ControlArrayWrapper( xDlg );
}
-ScVbaControls::ScVbaControls( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext,
- const css::uno::Reference< awt::XControl >& xDialog )
- : ControlsImpl_BASE( xParent, xContext, lcl_controlsWrapper( xDialog ) )
+ScVbaControls::ScVbaControls(
+ const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const css::uno::Reference< awt::XControl >& xDialog,
+ const uno::Reference< frame::XModel >& xModel,
+ double fOffsetX, double fOffsetY ) :
+ ControlsImpl_BASE( xParent, xContext, lcl_controlsWrapper( xDialog ) ),
+ mxDialog( xDialog ),
+ mxModel( xModel ),
+ mfOffsetX( fOffsetX ),
+ mfOffsetY( fOffsetY )
{
- mxDialog.set( xDialog, uno::UNO_QUERY );
}
uno::Reference< container::XEnumeration >
ScVbaControls::createEnumeration() throw (uno::RuntimeException)
{
- uno::Reference< container::XEnumeration > xEnum( new ControlsEnumWrapper( mxParent, mxContext, m_xIndexAccess, mxDialog ) );
+ uno::Reference< container::XEnumeration > xEnum( new ControlsEnumWrapper( mxParent, mxContext, m_xIndexAccess, mxDialog, mxModel, mfOffsetX, mfOffsetY ) );
if ( !xEnum.is() )
throw uno::RuntimeException();
return xEnum;
@@ -223,15 +250,9 @@ uno::Any
ScVbaControls::createCollectionObject( const css::uno::Any& aSource )
{
// Create control from awt::XControl
- uno::Reference< awt::XControl > xControl;
- aSource >>= xControl;
- uno::Reference< frame::XModel > xModel;
- uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
- uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.ControlProvider" ) ), mxContext ), uno::UNO_QUERY_THROW );
-
- uno::Reference< msforms::XControl > xVBAControl( xControlProvider->createUserformControl( xControl, mxDialog, xModel ) );
-
- return uno::makeAny( xVBAControl );
+ uno::Reference< awt::XControl > xControl( aSource, uno::UNO_QUERY_THROW );
+ uno::Reference< msforms::XControl > xVBAControl = ScVbaControlFactory::createUserformControl( mxContext, xControl, mxDialog, mxModel, mfOffsetX, mfOffsetY );
+ return uno::Any( xVBAControl );
}
void SAL_CALL
@@ -274,23 +295,117 @@ uno::Any SAL_CALL ScVbaControls::Add( const uno::Any& Object, const uno::Any& St
aNewName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Control" ) );
sal_Int32 nInd = 0;
- while( xDialogContainer->hasByName( aNewName ) && nInd < SAL_MAX_INT32 )
+ while( xDialogContainer->hasByName( aNewName ) && (nInd < SAL_MAX_INT32) )
{
aNewName = aComServiceName;
- aNewName += ::rtl::OUString::valueOf( nInd );
+ aNewName += ::rtl::OUString::valueOf( nInd++ );
}
}
+ double fDefWidth = 72.0, fDefHeight = 18.0;
if ( aComServiceName.getLength() )
{
- uno::Reference< awt::XControlModel > xNewModel( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.custom.awt.UnoControlSystemAXContainerModel" ) ) ), uno::UNO_QUERY_THROW );
+ // create a UNO control model based on the passed control type
+ uno::Reference< awt::XControlModel > xNewModel;
+ bool bFontSupport = false;
+ bool bNativeAX = false;
+ if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.CommandButton.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 24.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.Label.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedTextModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.Image.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlImageControlModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 72.0;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.CheckBox.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlCheckBoxModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 108.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.OptionButton.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlRadioButtonModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 108.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.TextBox.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlEditModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ListBox.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlListBoxModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ComboBox.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlComboBoxModel" ) ) ), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xProps( xNewModel, uno::UNO_QUERY_THROW );
+ xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Dropdown" ) ), uno::Any( true ) );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ToggleButton.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" ) ) ), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xProps( xNewModel, uno::UNO_QUERY_THROW );
+ xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Toggle" ) ), uno::Any( true ) );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.Frame.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlGroupBoxModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 216.0; fDefHeight = 144.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.SpinButton.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlSpinButtonModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 12.75; fDefHeight = 25.5;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ScrollBar.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlScrollBarModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 12.75; fDefHeight = 63.8;
+ }
+ else
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.custom.awt.UnoControlSystemAXContainerModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bNativeAX = true;
+ }
+ // need to set a few font properties to get rid of the default DONT_KNOW values
+ if( bFontSupport )
+ {
+ uno::Reference< beans::XPropertySet > xModelProps( xNewModel, uno::UNO_QUERY_THROW );
+ xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontName" ) ), uno::Any( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Tahoma" ) ) ) );
+ xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontHeight" ) ), uno::Any( float( 8.0 ) ) );
+ xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontWeight" ) ), uno::Any( awt::FontWeight::NORMAL ) );
+ xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontSlant" ) ), uno::Any( awt::FontSlant_NONE ) );
+ xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontUnderline" ) ), uno::Any( awt::FontUnderline::NONE ) );
+ xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontStrikeout" ) ), uno::Any( awt::FontStrikeout::NONE ) );
+ }
xDialogContainer->insertByName( aNewName, uno::makeAny( xNewModel ) );
uno::Reference< awt::XControlContainer > xControlContainer( mxDialog, uno::UNO_QUERY_THROW );
xNewControl = xControlContainer->getControl( aNewName );
- try
+ if( bNativeAX ) try
{
uno::Reference< script::XInvocation > xControlInvoke( xNewControl, uno::UNO_QUERY_THROW );
@@ -312,6 +427,11 @@ uno::Any SAL_CALL ScVbaControls::Add( const uno::Any& Object, const uno::Any& St
UpdateCollectionIndex( lcl_controlsWrapper( mxDialog ) );
aResult <<= xNewControl;
aResult = createCollectionObject( aResult );
+ uno::Reference< msforms::XControl > xVBAControl( aResult, uno::UNO_QUERY_THROW );
+ if( fDefWidth > 0.0 )
+ xVBAControl->setWidth( fDefWidth );
+ if( fDefHeight > 0.0 )
+ xVBAControl->setHeight( fDefHeight );
}
else
throw uno::RuntimeException();
@@ -389,23 +509,6 @@ ScVbaControls::getElementType() throw (uno::RuntimeException)
{
return ooo::vba::msforms::XControl::static_type(0);
}
-rtl::OUString&
-ScVbaControls::getServiceImplName()
-{
- static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaControls") );
- return sImplName;
-}
-
-uno::Sequence< rtl::OUString >
-ScVbaControls::getServiceNames()
-{
- static uno::Sequence< rtl::OUString > aServiceNames;
- if ( aServiceNames.getLength() == 0 )
- {
- aServiceNames.realloc( 1 );
- aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Controls" ) );
- }
- return aServiceNames;
-}
+VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaControls, "ooo.vba.msforms.Controls" )
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbacontrols.hxx b/vbahelper/source/msforms/vbacontrols.hxx
index cbbb4fcafe..4745e7b901 100644
--- a/vbahelper/source/msforms/vbacontrols.hxx
+++ b/vbahelper/source/msforms/vbacontrols.hxx
@@ -39,19 +39,17 @@ typedef CollTestImplHelper< ov::msforms::XControls > ControlsImpl_BASE;
class ScVbaControls : public ControlsImpl_BASE
{
- css::uno::Reference< css::awt::XControl > mxDialog;
-
-protected:
- virtual rtl::OUString& getServiceImplName();
- virtual css::uno::Sequence<rtl::OUString> getServiceNames();
-
public:
- ScVbaControls( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext,
- const css::uno::Reference< css::awt::XControl >& xDialog );
+ ScVbaControls(
+ const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::awt::XControl >& xDialog,
+ const css::uno::Reference< css::frame::XModel >& xModel,
+ double fOffsetX, double fOffsetY );
// XControls
virtual void SAL_CALL Move( double cx, double cy ) throw (css::uno::RuntimeException);
- virtual ::com::sun::star::uno::Any SAL_CALL Add( const ::com::sun::star::uno::Any& Object, const ::com::sun::star::uno::Any& StringKey, const ::com::sun::star::uno::Any& Before, const ::com::sun::star::uno::Any& After ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL Remove( const ::com::sun::star::uno::Any& StringKeyOrIndex ) throw (::com::sun::star::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Add( const css::uno::Any& Object, const css::uno::Any& StringKey, const css::uno::Any& Before, const css::uno::Any& After ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Remove( const css::uno::Any& StringKeyOrIndex ) throw (css::uno::RuntimeException);
// XEnumerationAccess
virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
@@ -60,7 +58,16 @@ public:
// ScVbaCollectionBaseImpl
virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ // XHelperInterface
+ VBAHELPER_DECL_XHELPERINTERFACE
+
+private:
+ css::uno::Reference< css::awt::XControl > mxDialog;
+ css::uno::Reference< css::frame::XModel > mxModel;
+ double mfOffsetX;
+ double mfOffsetY;
};
+
#endif //SC_VBA_OLEOBJECTS_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbaframe.cxx b/vbahelper/source/msforms/vbaframe.cxx
index 09d3b3c7fb..7c5f102603 100644
--- a/vbahelper/source/msforms/vbaframe.cxx
+++ b/vbahelper/source/msforms/vbaframe.cxx
@@ -25,45 +25,48 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#include "vbaframe.hxx"
-#include <vector>
+#include "vbanewfont.hxx"
+#include "vbacontrols.hxx"
+#include <ooo/vba/msforms/fmBorderStyle.hpp>
+#include <ooo/vba/msforms/fmSpecialEffect.hpp>
using namespace com::sun::star;
using namespace ooo::vba;
const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
-ScVbaFrame::ScVbaFrame( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper ) : FrameImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
+
+ScVbaFrame::ScVbaFrame(
+ const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< uno::XInterface >& xControl,
+ const uno::Reference< frame::XModel >& xModel,
+ ov::AbstractGeometryAttributes* pGeomHelper,
+ const css::uno::Reference< css::awt::XControl >& xDialog ) :
+ FrameImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ),
+ mxDialog( xDialog )
{
}
-// Attributes
-rtl::OUString SAL_CALL
-ScVbaFrame::getCaption() throw (css::uno::RuntimeException)
+// XFrame attributes
+
+rtl::OUString SAL_CALL ScVbaFrame::getCaption() throw (css::uno::RuntimeException)
{
rtl::OUString Label;
m_xProps->getPropertyValue( LABEL ) >>= Label;
return Label;
}
-void SAL_CALL
-ScVbaFrame::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
+void SAL_CALL ScVbaFrame::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
{
m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
}
-uno::Any SAL_CALL
-ScVbaFrame::getValue() throw (css::uno::RuntimeException)
-{
- return uno::makeAny( getCaption() );
-}
-
-void SAL_CALL
-ScVbaFrame::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException)
+sal_Int32 SAL_CALL ScVbaFrame::getSpecialEffect() throw (uno::RuntimeException)
{
- rtl::OUString sCaption;
- _value >>= sCaption;
- setCaption( sCaption );
+ return msforms::fmSpecialEffect::fmSpecialEffectEtched;
}
::sal_Int32 SAL_CALL ScVbaFrame::getForeColor() throw (::com::sun::star::uno::RuntimeException)
@@ -77,36 +80,40 @@ void SAL_CALL ScVbaFrame::setForeColor( ::sal_Int32 /*_forecolor*/ ) throw (::co
}
-rtl::OUString SAL_CALL
-ScVbaFrame::getAccelerator() throw (css::uno::RuntimeException)
+void SAL_CALL ScVbaFrame::setSpecialEffect( sal_Int32 /*nSpecialEffect*/ ) throw (uno::RuntimeException)
{
- //FIXME: seems not support?
- return rtl::OUString();
}
-void SAL_CALL
-ScVbaFrame::setAccelerator( const rtl::OUString& /*_accelerator*/ ) throw (::com::sun::star::uno::RuntimeException)
+sal_Int32 SAL_CALL ScVbaFrame::getBorderStyle() throw (uno::RuntimeException)
{
- //FIXME: seems not support?
+ return msforms::fmBorderStyle::fmBorderStyleNone;
}
-rtl::OUString&
-ScVbaFrame::getServiceImplName()
+void SAL_CALL ScVbaFrame::setBorderStyle( sal_Int32 /*nBorderStyle*/ ) throw (uno::RuntimeException)
{
- static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaFrame") );
- return sImplName;
}
-uno::Sequence< rtl::OUString >
-ScVbaFrame::getServiceNames()
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaFrame::getFont() throw (uno::RuntimeException)
{
- static uno::Sequence< rtl::OUString > aServiceNames;
- if ( aServiceNames.getLength() == 0 )
- {
- aServiceNames.realloc( 1 );
- aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Frame" ) );
- }
- return aServiceNames;
+ return new VbaNewFont( this, mxContext, m_xProps );
}
+// XFrame methods
+
+uno::Any SAL_CALL ScVbaFrame::Controls( const uno::Any& rIndex ) throw (uno::RuntimeException)
+{
+ // horizontal anchor of frame children is inside border line (add one unit to compensate border line width)
+ double fOffsetX = mpGeometryHelper->getOffsetX() + getLeft() + 1.0;
+ // vertical anchor of frame children is inside border line (add half of text height and one unit to compensate border line width)
+ double fOffsetY = mpGeometryHelper->getOffsetY() + getTop() + (getFont()->getSize() / 2.0) + 1.0;
+
+ uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, mxDialog, m_xModel, fOffsetX, fOffsetY ) );
+ if( rIndex.hasValue() )
+ return uno::Any( xControls->Item( rIndex, uno::Any() ) );
+ return uno::Any( xControls );
+}
+
+// XHelperInterface
+
+VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaFrame, "ooo.vba.msforms.Frame" )
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbaframe.hxx b/vbahelper/source/msforms/vbaframe.hxx
index 9b2c77252f..bb5b198335 100644
--- a/vbahelper/source/msforms/vbaframe.hxx
+++ b/vbahelper/source/msforms/vbaframe.hxx
@@ -28,31 +28,43 @@
#ifndef SC_VBA_FRAME_HXX
#define SC_VBA_FRAME_HXX
#include <cppuhelper/implbase1.hxx>
-#include <ooo/vba/msforms/XLabel.hpp>
+#include <ooo/vba/msforms/XFrame.hpp>
#include "vbacontrol.hxx"
#include <vbahelper/vbahelper.hxx>
-typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XLabel > FrameImpl_BASE;
+typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XFrame > FrameImpl_BASE;
class ScVbaFrame : public FrameImpl_BASE
{
public:
- ScVbaFrame( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper );
- // Attributes
- virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException);
- virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException);
+ ScVbaFrame(
+ const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::uno::XInterface >& xControl,
+ const css::uno::Reference< css::frame::XModel >& xModel,
+ ov::AbstractGeometryAttributes* pGeomHelper,
+ const css::uno::Reference< css::awt::XControl >& xDialog );
+
+ // XFrame attributes
virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getForeColor() throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setForeColor( ::sal_Int32 _forecolor ) throw (::com::sun::star::uno::RuntimeException);
-
- virtual rtl::OUString SAL_CALL getAccelerator() throw (css::uno::RuntimeException);
- virtual void SAL_CALL setAccelerator( const rtl::OUString& _accelerator ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getSpecialEffect() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setSpecialEffect( sal_Int32 nSpecialEffect ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getBorderStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setBorderStyle( sal_Int32 nBorderStyle ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
+ // XFrame methods
+ css::uno::Any SAL_CALL Controls( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException);
//XHelperInterface
virtual rtl::OUString& getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+
+private:
+ css::uno::Reference< css::awt::XControl > mxDialog;
};
#endif //SC_VBA_LABEL_HXX
diff --git a/vbahelper/source/msforms/vbalabel.cxx b/vbahelper/source/msforms/vbalabel.cxx
index 29c8dfa834..4795a25be7 100644
--- a/vbahelper/source/msforms/vbalabel.cxx
+++ b/vbahelper/source/msforms/vbalabel.cxx
@@ -25,8 +25,9 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#include "vbalabel.hxx"
-#include <vector>
+#include "vbanewfont.hxx"
using namespace com::sun::star;
using namespace ooo::vba;
@@ -78,8 +79,12 @@ ScVbaLabel::setAccelerator( const rtl::OUString& /*_accelerator*/ ) throw (::com
//FIXME: seems not support?
}
-rtl::OUString&
-ScVbaLabel::getServiceImplName()
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaLabel::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
+rtl::OUString& ScVbaLabel::getServiceImplName()
{
static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaLabel") );
return sImplName;
diff --git a/vbahelper/source/msforms/vbalabel.hxx b/vbahelper/source/msforms/vbalabel.hxx
index 3619c06e15..47c5c949a1 100644
--- a/vbahelper/source/msforms/vbalabel.hxx
+++ b/vbahelper/source/msforms/vbalabel.hxx
@@ -47,6 +47,7 @@ public:
virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
virtual rtl::OUString SAL_CALL getAccelerator() throw (css::uno::RuntimeException);
virtual void SAL_CALL setAccelerator( const rtl::OUString& _accelerator ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
//XHelperInterface
virtual rtl::OUString& getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
diff --git a/vbahelper/source/msforms/vbalistbox.cxx b/vbahelper/source/msforms/vbalistbox.cxx
index a29c1312ee..f008fef9d5 100644
--- a/vbahelper/source/msforms/vbalistbox.cxx
+++ b/vbahelper/source/msforms/vbalistbox.cxx
@@ -25,12 +25,12 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-#include <com/sun/star/form/validation/XValidatableFormComponent.hpp>
#include "vbalistbox.hxx"
-#include <vector>
+#include "vbanewfont.hxx"
#include <comphelper/anytostring.hxx>
#include <com/sun/star/script/ArrayWrapper.hpp>
+#include <com/sun/star/form/validation/XValidatableFormComponent.hpp>
using namespace com::sun::star;
using namespace ooo::vba;
@@ -276,6 +276,11 @@ ScVbaListBox::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn ) t
return mpListHelper->List( pvargIndex, pvarColumn );
}
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaListBox::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
rtl::OUString&
ScVbaListBox::getServiceImplName()
{
diff --git a/vbahelper/source/msforms/vbalistbox.hxx b/vbahelper/source/msforms/vbalistbox.hxx
index a35f100f4b..3c1bb28d4a 100644
--- a/vbahelper/source/msforms/vbalistbox.hxx
+++ b/vbahelper/source/msforms/vbalistbox.hxx
@@ -61,9 +61,10 @@ public:
virtual void SAL_CALL setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getMultiSelect() throw (css::uno::RuntimeException);
virtual void SAL_CALL setMultiSelect( ::sal_Int32 _multiselect ) throw (css::uno::RuntimeException);
- virtual css::uno::Any SAL_CALL Selected( ::sal_Int32 index ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
// Methods
+ virtual css::uno::Any SAL_CALL Selected( ::sal_Int32 index ) throw (css::uno::RuntimeException);
virtual void SAL_CALL AddItem( const css::uno::Any& pvargItem, const css::uno::Any& pvargIndex ) throw (css::uno::RuntimeException);
virtual void SAL_CALL removeItem( const css::uno::Any& index ) throw (css::uno::RuntimeException);
virtual void SAL_CALL Clear( ) throw (css::uno::RuntimeException);
diff --git a/vbahelper/source/msforms/vbamultipage.cxx b/vbahelper/source/msforms/vbamultipage.cxx
index 1ca77dc436..6d3756ea0f 100644
--- a/vbahelper/source/msforms/vbamultipage.cxx
+++ b/vbahelper/source/msforms/vbamultipage.cxx
@@ -67,7 +67,14 @@ ScVbaMultiPage::getPages( sal_Int32 nPages )
return new PagesImpl( nPages );
}
-ScVbaMultiPage::ScVbaMultiPage( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper, const uno::Reference< uno::XInterface >& xDialog ) : MultiPageImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
+ScVbaMultiPage::ScVbaMultiPage(
+ const uno::Reference< ov::XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< uno::XInterface >& xControl,
+ const uno::Reference< frame::XModel >& xModel,
+ AbstractGeometryAttributes* pGeomHelper,
+ const uno::Reference< awt::XControl >& xDialog ) :
+ MultiPageImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
{
mxDialogProps.set( xDialog, uno::UNO_QUERY_THROW );
}
diff --git a/vbahelper/source/msforms/vbamultipage.hxx b/vbahelper/source/msforms/vbamultipage.hxx
index 34fdb01a93..3c24b748f9 100644
--- a/vbahelper/source/msforms/vbamultipage.hxx
+++ b/vbahelper/source/msforms/vbamultipage.hxx
@@ -42,7 +42,14 @@ class ScVbaMultiPage : public MultiPageImpl_BASE
css::uno::Reference< css::container::XIndexAccess > getPages( sal_Int32 nPages );
css::uno::Reference< css::beans::XPropertySet > mxDialogProps;
public:
- ScVbaMultiPage( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::uno::XInterface >& xControl, css::uno::Reference< css::frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper, const css::uno::Reference< css::uno::XInterface >& xDialog );
+ ScVbaMultiPage(
+ const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::uno::XInterface >& xControl,
+ const css::uno::Reference< css::frame::XModel >& xModel,
+ ov::AbstractGeometryAttributes* pGeomHelper,
+ const css::uno::Reference< css::awt::XControl >& xDialog );
+
// Attributes
virtual sal_Int32 SAL_CALL getValue() throw (css::uno::RuntimeException);
virtual void SAL_CALL setValue( sal_Int32 _value ) throw (css::uno::RuntimeException);
diff --git a/vbahelper/source/msforms/vbanewfont.cxx b/vbahelper/source/msforms/vbanewfont.cxx
new file mode 100755
index 0000000000..f487b4e691
--- /dev/null
+++ b/vbahelper/source/msforms/vbanewfont.cxx
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <vbanewfont.hxx>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+// ============================================================================
+
+VbaNewFont::VbaNewFont(
+ const uno::Reference< XHelperInterface >& rxParent,
+ const uno::Reference< uno::XComponentContext >& rxContext,
+ const uno::Reference< beans::XPropertySet >& rxModelProps ) throw (uno::RuntimeException) :
+ VbaNewFont_BASE( rxParent, rxContext ),
+ mxProps( rxModelProps, uno::UNO_SET_THROW )
+{
+}
+
+// XNewFont attributes
+
+::rtl::OUString SAL_CALL VbaNewFont::getName() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontName" ) ) );
+ return aAny.get< ::rtl::OUString >();
+}
+
+void SAL_CALL VbaNewFont::setName( const ::rtl::OUString& rName ) throw (uno::RuntimeException)
+{
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontName" ) ),
+ uno::Any( rName ) );
+}
+
+double SAL_CALL VbaNewFont::getSize() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontHeight" ) ) );
+ return aAny.get< float >();
+}
+
+void SAL_CALL VbaNewFont::setSize( double fSize ) throw (uno::RuntimeException)
+{
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontHeight" ) ),
+ uno::Any( static_cast< float >( fSize ) ) );
+}
+
+sal_Int16 SAL_CALL VbaNewFont::getCharset() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontCharset" ) ) );
+ return rtl_getBestWindowsCharsetFromTextEncoding( static_cast< rtl_TextEncoding >( aAny.get< sal_Int16 >() ) );
+}
+
+void SAL_CALL VbaNewFont::setCharset( sal_Int16 nCharset ) throw (uno::RuntimeException)
+{
+ rtl_TextEncoding eFontEnc = RTL_TEXTENCODING_DONTKNOW;
+ if( (0 <= nCharset) && (nCharset <= SAL_MAX_UINT8) )
+ eFontEnc = rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8 >( nCharset ) );
+ if( eFontEnc == RTL_TEXTENCODING_DONTKNOW )
+ throw uno::RuntimeException();
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontCharset" ) ),
+ uno::Any( static_cast< sal_Int16 >( eFontEnc ) ) );
+}
+
+sal_Int16 SAL_CALL VbaNewFont::getWeight() throw (uno::RuntimeException)
+{
+ return getBold() ? 700 : 400;
+}
+
+void SAL_CALL VbaNewFont::setWeight( sal_Int16 nWeight ) throw (uno::RuntimeException)
+{
+ setBold( nWeight >= 700 );
+}
+
+sal_Bool SAL_CALL VbaNewFont::getBold() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontWeight" ) ) );
+ return aAny.get< float >() > awt::FontWeight::NORMAL;
+}
+
+void SAL_CALL VbaNewFont::setBold( sal_Bool bBold ) throw (uno::RuntimeException)
+{
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontWeight" ) ),
+ uno::Any( bBold ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL ) );
+}
+
+sal_Bool SAL_CALL VbaNewFont::getItalic() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontSlant" ) ) );
+ return aAny.get< awt::FontSlant >() != awt::FontSlant_NONE;
+}
+
+void SAL_CALL VbaNewFont::setItalic( sal_Bool bItalic ) throw (uno::RuntimeException)
+{
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontSlant" ) ),
+ uno::Any( bItalic ? awt::FontSlant_ITALIC : awt::FontSlant_NONE ) );
+}
+
+sal_Bool SAL_CALL VbaNewFont::getUnderline() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontUnderline" ) ) );
+ return aAny.get< sal_Int16 >() != awt::FontUnderline::NONE;
+}
+
+void SAL_CALL VbaNewFont::setUnderline( sal_Bool bUnderline ) throw (uno::RuntimeException)
+{
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontUnderline" ) ),
+ uno::Any( bUnderline ? awt::FontUnderline::SINGLE : awt::FontUnderline::NONE ) );
+}
+
+sal_Bool SAL_CALL VbaNewFont::getStrikethrough() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontStrikeout" ) ) );
+ return aAny.get< sal_Int16 >() != awt::FontStrikeout::NONE;
+}
+
+void SAL_CALL VbaNewFont::setStrikethrough( sal_Bool bStrikethrough ) throw (uno::RuntimeException)
+{
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontStrikeout" ) ),
+ uno::Any( bStrikethrough ? awt::FontStrikeout::SINGLE : awt::FontStrikeout::NONE ) );
+}
+
+// XHelperInterface
+
+VBAHELPER_IMPL_XHELPERINTERFACE( VbaNewFont, "ooo.vba.msforms.NewFont" )
+
+// ============================================================================
diff --git a/vbahelper/source/msforms/vbanewfont.hxx b/vbahelper/source/msforms/vbanewfont.hxx
new file mode 100755
index 0000000000..d59d5caa13
--- /dev/null
+++ b/vbahelper/source/msforms/vbanewfont.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef VBAHELPER_MSFORMS_VBANEWFONT_HXX
+#define VBAHELPER_MSFORMS_VBANEWFONT_HXX
+
+#include <ooo/vba/msforms/XNewFont.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+// ============================================================================
+
+typedef InheritedHelperInterfaceImpl1< ov::msforms::XNewFont > VbaNewFont_BASE;
+
+class VbaNewFont : public VbaNewFont_BASE
+{
+public:
+ VbaNewFont(
+ const css::uno::Reference< ov::XHelperInterface >& rxParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::beans::XPropertySet >& rxModelProps ) throw (css::uno::RuntimeException);
+
+ // XNewFont attributes
+ virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString& rName ) throw (css::uno::RuntimeException);
+ virtual double SAL_CALL getSize() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setSize( double fSize ) throw (css::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getCharset() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCharset( sal_Int16 nCharset ) throw (css::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getWeight() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setWeight( sal_Int16 nWeight ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getBold() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setBold( sal_Bool bBold ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getItalic() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setItalic( sal_Bool bItalic ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getUnderline() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setUnderline( sal_Bool bUnderline ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getStrikethrough() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setStrikethrough( sal_Bool bStrikethrough ) throw (css::uno::RuntimeException);
+
+ // XHelperInterface
+ VBAHELPER_DECL_XHELPERINTERFACE
+
+private:
+ css::uno::Reference< css::beans::XPropertySet > mxProps;
+};
+
+// ============================================================================
+
+#endif
diff --git a/vbahelper/source/msforms/vbaradiobutton.cxx b/vbahelper/source/msforms/vbaradiobutton.cxx
index aa08851902..99d1f613ec 100644
--- a/vbahelper/source/msforms/vbaradiobutton.cxx
+++ b/vbahelper/source/msforms/vbaradiobutton.cxx
@@ -25,8 +25,9 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#include "vbaradiobutton.hxx"
-#include <vector>
+#include "vbanewfont.hxx"
using namespace com::sun::star;
using namespace ooo::vba;
@@ -97,7 +98,12 @@ ScVbaRadioButton::setValue( const uno::Any& _value ) throw (uno::RuntimeExceptio
}
}
-rtl::OUString&
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaRadioButton::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
+rtl::OUString&
ScVbaRadioButton::getServiceImplName()
{
static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaRadioButton") );
diff --git a/vbahelper/source/msforms/vbaradiobutton.hxx b/vbahelper/source/msforms/vbaradiobutton.hxx
index 0bcbb33f15..48d1040b75 100644
--- a/vbahelper/source/msforms/vbaradiobutton.hxx
+++ b/vbahelper/source/msforms/vbaradiobutton.hxx
@@ -43,6 +43,7 @@ public:
virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException);
virtual void SAL_CALL setValue(const com::sun::star::uno::Any&) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
//XHelperInterface
virtual rtl::OUString& getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
diff --git a/vbahelper/source/msforms/vbatextbox.cxx b/vbahelper/source/msforms/vbatextbox.cxx
index 3fc94c7a17..6fa93fcbae 100644
--- a/vbahelper/source/msforms/vbatextbox.cxx
+++ b/vbahelper/source/msforms/vbatextbox.cxx
@@ -25,16 +25,16 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-#include <com/sun/star/text/XTextRange.hpp>
#include "vbatextbox.hxx"
-#include <vector>
+#include "vbanewfont.hxx"
+#include <com/sun/star/text/XTextRange.hpp>
+#include <ooo/vba/msforms/fmBorderStyle.hpp>
+#include <ooo/vba/msforms/fmSpecialEffect.hpp>
using namespace com::sun::star;
using namespace ooo::vba;
-
-
ScVbaTextBox::ScVbaTextBox( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper, bool bDialog ) : TextBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ), mbDialog( bDialog )
{
}
@@ -49,7 +49,8 @@ ScVbaTextBox::getValue() throw (css::uno::RuntimeException)
void SAL_CALL
ScVbaTextBox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException)
{
- rtl::OUString sVal = getAnyAsString( _value );
+ // booleans are converted to uppercase strings
+ rtl::OUString sVal = extractStringFromAny( _value, true );
setText( sVal );
}
@@ -123,7 +124,35 @@ ScVbaTextBox::setMultiline( sal_Bool _multiline ) throw (css::uno::RuntimeExcept
(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) ), aValue);
}
-rtl::OUString&
+sal_Int32 SAL_CALL ScVbaTextBox::getSpecialEffect() throw (uno::RuntimeException)
+{
+ return msforms::fmSpecialEffect::fmSpecialEffectSunken;
+}
+
+void SAL_CALL ScVbaTextBox::setSpecialEffect( sal_Int32 /*nSpecialEffect*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaTextBox::getBorderStyle() throw (uno::RuntimeException)
+{
+ return msforms::fmBorderStyle::fmBorderStyleNone;
+}
+
+void SAL_CALL ScVbaTextBox::setBorderStyle( sal_Int32 /*nBorderStyle*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaTextBox::getTextLength() throw (uno::RuntimeException)
+{
+ return getText().getLength();
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaTextBox::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
+rtl::OUString&
ScVbaTextBox::getServiceImplName()
{
static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaTextBox") );
diff --git a/vbahelper/source/msforms/vbatextbox.hxx b/vbahelper/source/msforms/vbatextbox.hxx
index 548ae2ab47..dea33bb3af 100644
--- a/vbahelper/source/msforms/vbatextbox.hxx
+++ b/vbahelper/source/msforms/vbatextbox.hxx
@@ -48,6 +48,12 @@ public:
virtual void SAL_CALL setMaxLength( sal_Int32 _maxlength ) throw (css::uno::RuntimeException);
virtual sal_Bool SAL_CALL getMultiline() throw (css::uno::RuntimeException);
virtual void SAL_CALL setMultiline( sal_Bool _multiline ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getSpecialEffect() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setSpecialEffect( sal_Int32 nSpecialEffect ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getBorderStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setBorderStyle( sal_Int32 nBorderStyle ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getTextLength() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
// XDefaultProperty
rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value")); }
//XHelperInterface
diff --git a/vbahelper/source/msforms/vbatogglebutton.cxx b/vbahelper/source/msforms/vbatogglebutton.cxx
index 297e30c103..28b4d511d9 100644
--- a/vbahelper/source/msforms/vbatogglebutton.cxx
+++ b/vbahelper/source/msforms/vbatogglebutton.cxx
@@ -25,8 +25,9 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#include "vbatogglebutton.hxx"
-#include <vector>
+#include "vbanewfont.hxx"
using namespace com::sun::star;
using namespace ooo::vba;
@@ -96,8 +97,57 @@ ScVbaToggleButton::setValue( const uno::Any& _value ) throw (uno::RuntimeExcepti
m_xProps->setPropertyValue( STATE, uno::makeAny( nState ) );
}
+sal_Bool SAL_CALL ScVbaToggleButton::getAutoSize() throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+void SAL_CALL ScVbaToggleButton::setAutoSize( sal_Bool /*bAutoSize*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Bool SAL_CALL ScVbaToggleButton::getCancel() throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+void SAL_CALL ScVbaToggleButton::setCancel( sal_Bool /*bCancel*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Bool SAL_CALL ScVbaToggleButton::getDefault() throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+void SAL_CALL ScVbaToggleButton::setDefault( sal_Bool /*bDefault*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaToggleButton::getBackColor() throw (uno::RuntimeException)
+{
+ return 0;
+}
+
+void SAL_CALL ScVbaToggleButton::setBackColor( sal_Int32 /*nBackColor*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaToggleButton::getForeColor() throw (uno::RuntimeException)
+{
+ return 0;
+}
+
+void SAL_CALL ScVbaToggleButton::setForeColor( sal_Int32 /*nForeColor*/ ) throw (uno::RuntimeException)
+{
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaToggleButton::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
-rtl::OUString&
+rtl::OUString&
ScVbaToggleButton::getServiceImplName()
{
static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaToggleButton") );
diff --git a/vbahelper/source/msforms/vbatogglebutton.hxx b/vbahelper/source/msforms/vbatogglebutton.hxx
index 540069de3d..40e480ee5b 100644
--- a/vbahelper/source/msforms/vbatogglebutton.hxx
+++ b/vbahelper/source/msforms/vbatogglebutton.hxx
@@ -44,9 +44,19 @@ public:
// Attributes
virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException);
virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException);
-
virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getAutoSize() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getCancel() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCancel( sal_Bool bCancel ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getDefault() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setDefault( sal_Bool bDefault ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getBackColor() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getForeColor() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setForeColor( sal_Int32 nForeColor ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
//XHelperInterface
virtual rtl::OUString& getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx
index 2939e053e4..26912388ad 100644
--- a/vbahelper/source/msforms/vbauserform.cxx
+++ b/vbahelper/source/msforms/vbauserform.cxx
@@ -57,9 +57,7 @@ ScVbaUserForm::ScVbaUserForm( uno::Sequence< uno::Any > const& aArgs, uno::Refer
m_xDialog.set( m_xControl, uno::UNO_QUERY_THROW );
uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY_THROW );
m_xProps.set( xControl->getModel(), uno::UNO_QUERY_THROW );
- setGeometryHelper( new UserFormGeometryHelper( xContext, xControl ) );
- if ( aArgs.getLength() >= 4 )
- aArgs[ 3 ] >>= m_sLibName;
+ setGeometryHelper( new UserFormGeometryHelper( xContext, xControl, 0.0, 0.0 ) );
}
ScVbaUserForm::~ScVbaUserForm()
@@ -110,18 +108,38 @@ ScVbaUserForm::Show( ) throw (uno::RuntimeException)
}
rtl::OUString SAL_CALL
-ScVbaUserForm::getCaption() throw (::com::sun::star::uno::RuntimeException)
+ScVbaUserForm::getCaption() throw (uno::RuntimeException)
{
rtl::OUString sCaption;
m_xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ) ) >>= sCaption;
return sCaption;
}
void
-ScVbaUserForm::setCaption( const ::rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
+ScVbaUserForm::setCaption( const ::rtl::OUString& _caption ) throw (uno::RuntimeException)
{
m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ), uno::makeAny( _caption ) );
}
+double SAL_CALL ScVbaUserForm::getInnerWidth() throw (uno::RuntimeException)
+{
+ return mpGeometryHelper->getInnerWidth();
+}
+
+void SAL_CALL ScVbaUserForm::setInnerWidth( double fInnerWidth ) throw (uno::RuntimeException)
+{
+ mpGeometryHelper->setInnerWidth( fInnerWidth );
+}
+
+double SAL_CALL ScVbaUserForm::getInnerHeight() throw (uno::RuntimeException)
+{
+ return mpGeometryHelper->getInnerHeight();
+}
+
+void SAL_CALL ScVbaUserForm::setInnerHeight( double fInnerHeight ) throw (uno::RuntimeException)
+{
+ mpGeometryHelper->setInnerHeight( fInnerHeight );
+}
+
void SAL_CALL
ScVbaUserForm::Hide( ) throw (uno::RuntimeException)
{
@@ -251,10 +269,8 @@ ScVbaUserForm::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::Un
xContainer->getControl( aPropertyName );
if ( xControl.is() )
{
- ScVbaControlFactory aFac( mxContext, xControl, m_xModel );
- uno::Reference< msforms::XControl > xVBAControl( aFac.createControl( xDialogControl->getModel() ) );
- ScVbaControl* pControl = dynamic_cast< ScVbaControl* >( xVBAControl.get() );
- pControl->setGeometryHelper( new UserFormGeometryHelper( mxContext, xControl ) );
+ uno::Reference< msforms::XControl > xVBAControl = ScVbaControlFactory::createUserformControl( mxContext, xControl, xDialogControl, m_xModel, mpGeometryHelper->getOffsetX(), mpGeometryHelper->getOffsetY() );
+ ScVbaControl* pControl = dynamic_cast< ScVbaControl* >( xVBAControl.get() );
if ( m_sLibName.getLength() )
pControl->setLibraryAndCodeName( m_sLibName.concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "." ) ) ).concat( getName() ) );
aResult = uno::makeAny( xVBAControl );
@@ -275,7 +291,7 @@ ScVbaUserForm::Controls( const uno::Any& index ) throw (uno::RuntimeException)
// if the dialog already closed we should do nothing, but the VBA will call methods of the Controls objects
// thus we have to provide a dummy object in this case
uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY );
- uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, xDialogControl ) );
+ uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, xDialogControl, m_xModel, mpGeometryHelper->getOffsetX(), mpGeometryHelper->getOffsetY() ) );
if ( index.hasValue() )
return uno::makeAny( xControls->Item( index, uno::Any() ) );
return uno::makeAny( xControls );
diff --git a/vbahelper/source/msforms/vbauserform.hxx b/vbahelper/source/msforms/vbauserform.hxx
index 625d1fae02..c62fcf2fb8 100644
--- a/vbahelper/source/msforms/vbauserform.hxx
+++ b/vbahelper/source/msforms/vbauserform.hxx
@@ -56,18 +56,22 @@ public:
// XUserForm
virtual void SAL_CALL RePaint( ) throw (css::uno::RuntimeException);
virtual void SAL_CALL Show( ) throw (css::uno::RuntimeException);
- // XIntrospection
- virtual css::uno::Reference< css::beans::XIntrospectionAccess > SAL_CALL getIntrospection( ) throw (css::uno::RuntimeException);
- virtual css::uno::Any SAL_CALL invoke( const ::rtl::OUString& aFunctionName, const css::uno::Sequence< css::uno::Any >& aParams, css::uno::Sequence< ::sal_Int16 >& aOutParamIndex, css::uno::Sequence< css::uno::Any >& aOutParam ) throw (css::lang::IllegalArgumentException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException);
virtual void SAL_CALL setValue( const ::rtl::OUString& aPropertyName, const css::uno::Any& aValue ) throw (css::beans::UnknownPropertyException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL getValue( const ::rtl::OUString& aPropertyName ) throw (css::beans::UnknownPropertyException, css::uno::RuntimeException);
- virtual ::sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException);
- virtual ::sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getCaption() throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setCaption( const ::rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL getInnerWidth() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setInnerWidth( double fInnerWidth ) throw (::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL getInnerHeight() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setInnerHeight( double fInnerHeight ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL Hide( ) throw (css::uno::RuntimeException);
virtual void SAL_CALL UnloadObject( ) throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL Controls( const css::uno::Any& index ) throw (css::uno::RuntimeException);
+ // XIntrospection
+ virtual css::uno::Reference< css::beans::XIntrospectionAccess > SAL_CALL getIntrospection( ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL invoke( const ::rtl::OUString& aFunctionName, const css::uno::Sequence< css::uno::Any >& aParams, css::uno::Sequence< ::sal_Int16 >& aOutParamIndex, css::uno::Sequence< css::uno::Any >& aOutParam ) throw (css::lang::IllegalArgumentException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException);
//XHelperInterface
virtual rtl::OUString& getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
diff --git a/vbahelper/source/vbahelper/collectionbase.cxx b/vbahelper/source/vbahelper/collectionbase.cxx
new file mode 100755
index 0000000000..16fc673f54
--- /dev/null
+++ b/vbahelper/source/vbahelper/collectionbase.cxx
@@ -0,0 +1,332 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2011 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <vbahelper/collectionbase.hxx>
+
+#include <map>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <cppuhelper/implbase2.hxx>
+
+namespace vbahelper {
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+// ============================================================================
+
+namespace {
+
+// ----------------------------------------------------------------------------
+
+class CollectionEnumeration : public ::cppu::WeakImplHelper1< container::XEnumeration >
+{
+public:
+ explicit CollectionEnumeration( const ::rtl::Reference< CollectionBase >& rxCollection );
+ virtual sal_Bool SAL_CALL hasMoreElements() throw (uno::RuntimeException);
+ virtual uno::Any SAL_CALL nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
+
+private:
+ ::rtl::Reference< CollectionBase > mxCollection;
+ sal_Int32 mnCurrIndex;
+};
+
+CollectionEnumeration::CollectionEnumeration( const ::rtl::Reference< CollectionBase >& rxCollection ) :
+ mxCollection( rxCollection ),
+ mnCurrIndex( 1 ) // collection expects one-based indexes
+{
+}
+
+sal_Bool SAL_CALL CollectionEnumeration::hasMoreElements() throw (uno::RuntimeException)
+{
+ return mnCurrIndex <= mxCollection->getCount();
+}
+
+uno::Any SAL_CALL CollectionEnumeration::nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ if( hasMoreElements() )
+ return mxCollection->getItemByIndex( mnCurrIndex++ );
+ throw container::NoSuchElementException();
+}
+
+// ----------------------------------------------------------------------------
+
+struct IsLessIgnoreCase
+{
+ inline bool operator()( const ::rtl::OUString& rName1, const ::rtl::OUString& rName2 ) const
+ { return ::rtl_ustr_compareIgnoreAsciiCase_WithLength( rName1.getStr(), rName1.getLength(), rName2.getStr(), rName2.getLength() ) < 0; }
+};
+
+// ----------------------------------------------------------------------------
+
+class SequenceToContainer : public ::cppu::WeakImplHelper2< container::XIndexAccess, container::XNameAccess >
+{
+public:
+ explicit SequenceToContainer( const ::std::vector< uno::Reference< container::XNamed > >& rElements, const uno::Type& rElementType );
+ explicit SequenceToContainer( const ::std::vector< beans::NamedValue >& rElements, const uno::Type& rElementType );
+ // XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException);
+ virtual uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException);
+ // XNameAccess
+ virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& rName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
+ virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() throw (uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& rName ) throw (uno::RuntimeException);
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException);
+
+private:
+ typedef uno::Sequence< ::rtl::OUString > ElementNameSequence;
+ typedef ::std::vector< uno::Any > ElementVector;
+ typedef ::std::map< ::rtl::OUString, uno::Any, IsLessIgnoreCase > ElementMap;
+
+ ElementNameSequence maElementNames;
+ ElementVector maElements;
+ ElementMap maElementMap;
+ uno::Type maElementType;
+};
+
+SequenceToContainer::SequenceToContainer( const ::std::vector< uno::Reference< container::XNamed > >& rElements, const uno::Type& rElementType ) :
+ maElementType( rElementType )
+{
+ maElementNames.realloc( static_cast< sal_Int32 >( rElements.size() ) );
+ maElements.reserve( rElements.size() );
+ ::rtl::OUString* pElementName = maElementNames.getArray();
+ for( ::std::vector< uno::Reference< container::XNamed > >::const_iterator aIt = rElements.begin(), aEnd = rElements.end(); aIt != aEnd; ++aIt, ++pElementName )
+ {
+ uno::Reference< container::XNamed > xNamed = *aIt;
+ *pElementName = xNamed->getName();
+ maElements.push_back( uno::Any( xNamed ) );
+ // same name may occur multiple times, VBA returns first occurance
+ if( maElementMap.count( *pElementName ) == 0 )
+ maElementMap[ *pElementName ] <<= xNamed;
+ }
+}
+
+SequenceToContainer::SequenceToContainer( const ::std::vector< beans::NamedValue >& rElements, const uno::Type& rElementType ) :
+ maElementType( rElementType )
+{
+ maElementNames.realloc( static_cast< sal_Int32 >( rElements.size() ) );
+ maElements.reserve( rElements.size() );
+ ::rtl::OUString* pElementName = maElementNames.getArray();
+ for( ::std::vector< beans::NamedValue >::const_iterator aIt = rElements.begin(), aEnd = rElements.end(); aIt != aEnd; ++aIt, ++pElementName )
+ {
+ *pElementName = aIt->Name;
+ maElements.push_back( aIt->Value );
+ // same name may occur multiple times, VBA returns first occurance
+ if( maElementMap.count( *pElementName ) == 0 )
+ maElementMap[ *pElementName ] = aIt->Value;
+ }
+}
+
+sal_Int32 SAL_CALL SequenceToContainer::getCount() throw (uno::RuntimeException)
+{
+ return static_cast< sal_Int32 >( maElements.size() );
+}
+
+uno::Any SAL_CALL SequenceToContainer::getByIndex( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ if( (0 <= nIndex) && (nIndex < getCount()) )
+ return maElements[ static_cast< size_t >( nIndex ) ];
+ throw lang::IndexOutOfBoundsException();
+}
+
+uno::Any SAL_CALL SequenceToContainer::getByName( const ::rtl::OUString& rName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ ElementMap::iterator aIt = maElementMap.find( rName );
+ if( aIt != maElementMap.end() )
+ return aIt->second;
+ throw container::NoSuchElementException();
+}
+
+uno::Sequence< ::rtl::OUString > SAL_CALL SequenceToContainer::getElementNames() throw (uno::RuntimeException)
+{
+ return maElementNames;
+}
+
+sal_Bool SAL_CALL SequenceToContainer::hasByName( const ::rtl::OUString& rName ) throw (uno::RuntimeException)
+{
+ return maElementMap.count( rName ) > 0;
+}
+
+uno::Type SAL_CALL SequenceToContainer::getElementType() throw (uno::RuntimeException)
+{
+ return maElementType;
+}
+
+sal_Bool SAL_CALL SequenceToContainer::hasElements() throw (uno::RuntimeException)
+{
+ return !maElements.empty();
+}
+
+} // namespace
+
+// ============================================================================
+
+CollectionBase::CollectionBase( const uno::Type& rElementType ) :
+ maElementType( rElementType ),
+ mbConvertOnDemand( false )
+{
+}
+
+sal_Int32 SAL_CALL CollectionBase::getCount() throw (uno::RuntimeException)
+{
+ if( mxIndexAccess.is() )
+ return mxIndexAccess->getCount();
+ if( mxNameAccess.is() )
+ return mxNameAccess->getElementNames().getLength();
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No element container set." ) ), 0 );
+}
+
+uno::Reference< container::XEnumeration > SAL_CALL CollectionBase::createEnumeration() throw (uno::RuntimeException)
+{
+ return new CollectionEnumeration( this );
+}
+
+uno::Type SAL_CALL CollectionBase::getElementType() throw (uno::RuntimeException)
+{
+ return maElementType;
+}
+
+sal_Bool SAL_CALL CollectionBase::hasElements() throw (uno::RuntimeException)
+{
+ if( mxIndexAccess.is() )
+ return mxIndexAccess->hasElements();
+ if( mxNameAccess.is() )
+ return mxNameAccess->hasElements();
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No element container set." ) ), 0 );
+}
+
+::rtl::OUString SAL_CALL CollectionBase::getDefaultMethodName() throw (uno::RuntimeException)
+{
+ static ::rtl::OUString saDefMethodName( RTL_CONSTASCII_USTRINGPARAM( "Item" ) );
+ return saDefMethodName;
+}
+
+// ----------------------------------------------------------------------------
+
+void CollectionBase::initContainer(
+ const uno::Reference< container::XElementAccess >& rxElementAccess,
+ ContainerType eContainerType ) throw (uno::RuntimeException)
+{
+ mxIndexAccess.set( rxElementAccess, uno::UNO_QUERY );
+ mxNameAccess.set( rxElementAccess, uno::UNO_QUERY );
+ switch( eContainerType )
+ {
+ case CONTAINER_NATIVE_VBA:
+ mbConvertOnDemand = false;
+ break;
+ case CONTAINER_CONVERT_ON_DEMAND:
+ mbConvertOnDemand = true;
+ break;
+ }
+}
+
+void CollectionBase::initElements( const ::std::vector< uno::Reference< container::XNamed > >& rElements, ContainerType eContainerType ) throw (uno::RuntimeException)
+{
+ // SequenceToContainer derives twice from XElementAccess, need to resolve ambiguity
+ initContainer( static_cast< container::XIndexAccess* >( new SequenceToContainer( rElements, maElementType ) ), eContainerType );
+}
+
+void CollectionBase::initElements( const ::std::vector< beans::NamedValue >& rElements, ContainerType eContainerType ) throw (uno::RuntimeException)
+{
+ // SequenceToContainer derives twice from XElementAccess, need to resolve ambiguity
+ initContainer( static_cast< container::XIndexAccess* >( new SequenceToContainer( rElements, maElementType ) ), eContainerType );
+}
+
+uno::Any CollectionBase::createCollectionItem( const uno::Any& rElement, const uno::Any& rIndex ) throw (css::uno::RuntimeException)
+{
+ uno::Any aItem = mbConvertOnDemand ? implCreateCollectionItem( rElement, rIndex ) : rElement;
+ if( aItem.hasValue() )
+ return aItem;
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid item." ) ), 0 );
+}
+
+uno::Any CollectionBase::getItemByIndex( sal_Int32 nIndex ) throw (uno::RuntimeException)
+{
+ if( mxIndexAccess.is() )
+ {
+ if( (1 <= nIndex) && (nIndex <= mxIndexAccess->getCount()) )
+ // createCollectionItem() will convert from container element to VBA item
+ return createCollectionItem( mxIndexAccess->getByIndex( nIndex - 1 ), uno::Any( nIndex ) );
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Index out of bounds." ) ), 0 );
+ }
+ if( mxNameAccess.is() )
+ {
+ uno::Sequence< ::rtl::OUString > aElementNames = mxNameAccess->getElementNames();
+ if( (1 <= nIndex) && (nIndex <= aElementNames.getLength()) )
+ // createCollectionItem() will convert from container element to VBA item
+ return createCollectionItem( mxNameAccess->getByName( aElementNames[ nIndex - 1 ] ), uno::Any( aElementNames[ nIndex - 1 ] ) );
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Index out of bounds." ) ), 0 );
+ }
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No element container set." ) ), 0 );
+}
+
+uno::Any CollectionBase::getItemByName( const ::rtl::OUString& rName ) throw (uno::RuntimeException)
+{
+ if( mxNameAccess.is() )
+ {
+ if( rName.getLength() > 0 )
+ // createCollectionItem() will convert from container element to VBA item
+ return createCollectionItem( mxNameAccess->getByName( rName ), uno::Any( rName ) );
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid item name." ) ), 0 );
+ }
+ if( mxIndexAccess.is() )
+ {
+ for( sal_Int32 nIndex = 0, nSize = mxIndexAccess->getCount(); nIndex < nSize; ++nIndex )
+ {
+ uno::Any aElement = mxIndexAccess->getByIndex( nIndex );
+ uno::Reference< container::XNamed > xNamed( aElement, uno::UNO_QUERY );
+ if( xNamed.is() && xNamed->getName().equalsIgnoreAsciiCase( rName ) )
+ // createCollectionItem() will convert from container element to VBA item
+ return createCollectionItem( aElement, uno::Any( nIndex ) );
+ }
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid item name." ) ), 0 );
+ }
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No element container set." ) ), 0 );
+}
+
+uno::Any CollectionBase::getAnyItemOrThis( const uno::Any& rIndex ) throw (uno::RuntimeException)
+{
+ if( !rIndex.hasValue() )
+ return uno::Any( uno::Reference< XCollectionBase >( this ) );
+ if( rIndex.has< ::rtl::OUString >() )
+ return getItemByName( rIndex.get< ::rtl::OUString >() );
+ // extractIntFromAny() throws if no index can be extracted
+ return getItemByIndex( extractIntFromAny( rIndex ) );
+}
+
+// protected ------------------------------------------------------------------
+
+uno::Any CollectionBase::implCreateCollectionItem( const uno::Any& /*rElement*/, const uno::Any& /*rIndex*/ ) throw (uno::RuntimeException)
+{
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Creation of VBA implementation object not implemented." ) ), 0 );
+}
+
+// ============================================================================
+
+} // namespace vbahelper
diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx
index 57baee722b..ae6b73e6f8 100644
--- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx
+++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx
@@ -388,12 +388,12 @@ uno::Any SAL_CALL VbaApplicationBase::getVBE() throw (uno::RuntimeException)
{
try // return empty object on error
{
- uno::Sequence< uno::Any > aArgs( 2 );
- aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this );
- aArgs[ 1 ] <<= getCurrentDocument();
+ // "VBE" object does not have a parent, but pass document model to be able to determine application type
+ uno::Sequence< uno::Any > aArgs( 1 );
+ aArgs[ 0 ] <<= getCurrentDocument();
uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW );
uno::Reference< uno::XInterface > xVBE = xServiceManager->createInstanceWithArgumentsAndContext(
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBE" ) ), aArgs, mxContext );
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.vbide.VBE" ) ), aArgs, mxContext );
return uno::Any( xVBE );
}
catch( uno::Exception& )
@@ -402,25 +402,6 @@ uno::Any SAL_CALL VbaApplicationBase::getVBE() throw (uno::RuntimeException)
return uno::Any();
}
-uno::Any SAL_CALL
-VbaApplicationBase::getVBProjects() throw (uno::RuntimeException)
-{
- try // return empty object on error
- {
- uno::Sequence< uno::Any > aArgs( 2 );
- aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this );
- aArgs[ 1 ] <<= getCurrentDocument();
- uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW );
- uno::Reference< uno::XInterface > xVBProjects = xServiceManager->createInstanceWithArgumentsAndContext(
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBProjects" ) ), aArgs, mxContext );
- return uno::Any( xVBProjects );
- }
- catch( uno::Exception& )
- {
- }
- return uno::Any();
-}
-
rtl::OUString&
VbaApplicationBase::getServiceImplName()
{
diff --git a/vbahelper/source/vbahelper/vbacommandbar.cxx b/vbahelper/source/vbahelper/vbacommandbar.cxx
index 68fada22d5..cf71425190 100644
--- a/vbahelper/source/vbahelper/vbacommandbar.cxx
+++ b/vbahelper/source/vbahelper/vbacommandbar.cxx
@@ -155,14 +155,7 @@ ScVbaCommandBar::Delete( ) throw (script::BasicErrorException, uno::RuntimeExce
uno::Any SAL_CALL
ScVbaCommandBar::Controls( const uno::Any& aIndex ) throw (script::BasicErrorException, uno::RuntimeException)
{
- uno::Reference< awt::XMenu > xMenu;
- if( m_bIsMenu )
- {
- uno::Reference< frame::XLayoutManager > xLayoutManager = pCBarHelper->getLayoutManager();
- uno::Reference< beans::XPropertySet > xPropertySet( xLayoutManager->getElement( m_sResourceUrl ), uno::UNO_QUERY_THROW );
- xMenu.set( xPropertySet->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("XMenuBar")) ), uno::UNO_QUERY );
- }
- uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, m_xBarSettings, pCBarHelper, m_xBarSettings, m_sResourceUrl, xMenu ) );
+ uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, m_xBarSettings, pCBarHelper, m_xBarSettings, m_sResourceUrl ) );
if( aIndex.hasValue() )
{
return xCommandBarControls->Item( aIndex, uno::Any() );
diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx b/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
index 1151fdccaa..728723296e 100644
--- a/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
+++ b/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
@@ -92,82 +92,55 @@ ScVbaCommandBarControl::setOnAction( const ::rtl::OUString& _onaction ) throw (u
::sal_Bool SAL_CALL
ScVbaCommandBarControl::getVisible() throw (uno::RuntimeException)
{
- /*sal_Bool bVisible = sal_True;
- uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsVisible")) );
+ sal_Bool bVisible = sal_True;
+ uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ISVISIBLE ) );
if( aValue.hasValue() )
aValue >>= bVisible;
- return bVisible;*/
- return getEnabled();
-
+ return bVisible;
}
void SAL_CALL
ScVbaCommandBarControl::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeException)
{
- uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsVisible")) );
+ uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ISVISIBLE ) );
if( aValue.hasValue() )
{
- setPropertyValue( m_aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsVisible")), uno::makeAny( _visible ) );
+ setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ISVISIBLE ), uno::makeAny( _visible ) );
ApplyChange();
}
- setEnabled( _visible);
}
::sal_Bool SAL_CALL
ScVbaCommandBarControl::getEnabled() throw (uno::RuntimeException)
{
sal_Bool bEnabled = sal_True;
- rtl::OUString aCommandURLappendix = rtl::OUString::createFromAscii("___");
- rtl::OUString aCommandURL ;
- if( m_xParentMenu.is() )
+ uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ENABLED ) );
+ if( aValue.hasValue() )
{
- // currently only the menu in the MenuBat support Enable/Disable
- // FIXME: how to support the menu item in Toolbar
- bEnabled = m_xParentMenu->isItemEnabled( m_xParentMenu->getItemId( sal::static_int_cast< sal_Int16 >( m_nPosition ) ) );
+ aValue >>= bEnabled;
}
else
{
// emulated with Visible
- //bEnabled = getVisible();
- uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL") );
- if (aValue >>= aCommandURL){
- if (0 == aCommandURL.indexOf(aCommandURLappendix)){
- bEnabled = sal_False;
- }
- }
-
- }
+ bEnabled = getVisible();
+ }
return bEnabled;
}
void SAL_CALL
ScVbaCommandBarControl::setEnabled( sal_Bool _enabled ) throw (uno::RuntimeException)
{
- rtl::OUString aCommandURL ;
- rtl::OUString aCommandURLappendix = rtl::OUString::createFromAscii("___");
- rtl::OUStringBuffer aCommandURLSringBuffer;
- if( m_xParentMenu.is() )
+ uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ENABLED ) );
+ if( aValue.hasValue() )
{
- // currently only the menu in the MenuBat support Enable/Disable
- m_xParentMenu->enableItem( m_xParentMenu->getItemId( sal::static_int_cast< sal_Int16 >( m_nPosition ) ), _enabled );
+ setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ENABLED ), uno::makeAny( _enabled ) );
+ ApplyChange();
}
else
{
- uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL") );
- if (aValue >>= aCommandURL){
- if (0 == aCommandURL.indexOf(aCommandURLappendix)){
- aCommandURL = aCommandURL.copy(3);
- }
- if (false == _enabled){
- aCommandURLSringBuffer = aCommandURLappendix;
- }
- aCommandURLSringBuffer.append(aCommandURL);
- setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL"), uno::makeAny( aCommandURLSringBuffer.makeStringAndClear()) );
- ApplyChange();
- }
// emulated with Visible
- //setVisible( _enabled );
- }
+ setVisible( _enabled );
+ }
}
::sal_Bool SAL_CALL
@@ -207,14 +180,7 @@ ScVbaCommandBarControl::Controls( const uno::Any& aIndex ) throw (script::BasicE
if( !xSubMenu.is() )
throw uno::RuntimeException();
- uno::Reference< awt::XMenu > xMenu;
- if( m_xParentMenu.is() )
- {
- sal_Int16 nItemId = m_xParentMenu->getItemId( sal::static_int_cast< sal_Int16 >( m_nPosition ) );
- xMenu.set( m_xParentMenu->getPopupMenu( nItemId ), uno::UNO_QUERY );
- }
-
- uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, xSubMenu, pCBarHelper, m_xBarSettings, m_sResourceUrl, xMenu ) );
+ uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, xSubMenu, pCBarHelper, m_xBarSettings, m_sResourceUrl ) );
if( aIndex.hasValue() )
{
return xCommandBarControls->Item( aIndex, uno::Any() );
@@ -242,12 +208,11 @@ ScVbaCommandBarControl::getServiceNames()
}
//////////// ScVbaCommandBarPopup //////////////////////////////
-ScVbaCommandBarPopup::ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw (css::uno::RuntimeException) : CommandBarPopup_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl )
+ScVbaCommandBarPopup::ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException) : CommandBarPopup_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl )
{
m_nPosition = nPosition;
m_bTemporary = bTemporary;
m_xCurrentSettings->getByIndex( m_nPosition ) >>= m_aPropertyValues;
- m_xParentMenu = xMenu;
}
rtl::OUString&
@@ -269,12 +234,11 @@ ScVbaCommandBarPopup::getServiceNames()
}
//////////// ScVbaCommandBarButton //////////////////////////////
-ScVbaCommandBarButton::ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw (css::uno::RuntimeException) : CommandBarButton_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl )
+ScVbaCommandBarButton::ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException) : CommandBarButton_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl )
{
m_nPosition = nPosition;
m_bTemporary = bTemporary;
m_xCurrentSettings->getByIndex( m_nPosition ) >>= m_aPropertyValues;
- m_xParentMenu = xMenu;
}
rtl::OUString&
diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx b/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx
index c599472682..aaec78e0b6 100644
--- a/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx
+++ b/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx
@@ -44,10 +44,9 @@ class ScVbaCommandBarControl : public CommandBarControl_BASE
protected:
VbaCommandBarHelperRef pCBarHelper;
rtl::OUString m_sResourceUrl;
- css::uno::Reference< css::container::XIndexAccess > m_xCurrentSettings;
- css::uno::Reference< css::container::XIndexAccess > m_xBarSettings;
- css::uno::Sequence< css::beans::PropertyValue > m_aPropertyValues;
- css::uno::Reference< css::awt::XMenu > m_xParentMenu;
+ css::uno::Reference< css::container::XIndexAccess > m_xCurrentSettings;
+ css::uno::Reference< css::container::XIndexAccess > m_xBarSettings;
+ css::uno::Sequence< css::beans::PropertyValue > m_aPropertyValues;
sal_Int32 m_nPosition;
sal_Bool m_bTemporary;
@@ -88,7 +87,7 @@ typedef cppu::ImplInheritanceHelper1< ScVbaCommandBarControl, ov::XCommandBarPop
class ScVbaCommandBarPopup : public CommandBarPopup_BASE
{
public:
- ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw (css::uno::RuntimeException);
+ ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException)
{
@@ -103,7 +102,7 @@ typedef cppu::ImplInheritanceHelper1< ScVbaCommandBarControl, ov::XCommandBarBut
class ScVbaCommandBarButton : public CommandBarButton_BASE
{
public:
- ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw (css::uno::RuntimeException);
+ ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException)
{
diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx b/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
index 3c8c531628..d646ce1202 100644
--- a/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
+++ b/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
@@ -56,14 +56,20 @@ public:
}
};
-ScVbaCommandBarControls::ScVbaCommandBarControls( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess>& xIndexAccess, VbaCommandBarHelperRef pHelper, const uno::Reference< container::XIndexAccess>& xBarSettings, const rtl::OUString& sResourceUrl, const uno::Reference< awt::XMenu >& xMenu ) throw (uno::RuntimeException) : CommandBarControls_BASE( xParent, xContext, xIndexAccess ), pCBarHelper( pHelper ), m_xBarSettings( xBarSettings ), m_sResourceUrl( sResourceUrl ), m_xMenu( xMenu )
+ScVbaCommandBarControls::ScVbaCommandBarControls( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess>& xIndexAccess, VbaCommandBarHelperRef pHelper, const uno::Reference< container::XIndexAccess>& xBarSettings, const rtl::OUString& sResourceUrl ) throw (uno::RuntimeException) : CommandBarControls_BASE( xParent, xContext, xIndexAccess ), pCBarHelper( pHelper ), m_xBarSettings( xBarSettings ), m_sResourceUrl( sResourceUrl )
{
m_bIsMenu = sResourceUrl.equalsAscii( ITEM_MENUBAR_URL ) ? sal_True : sal_False;
}
-uno::Sequence< beans::PropertyValue > ScVbaCommandBarControls::CreateMenuItemData( const rtl::OUString& sCommandURL, const rtl::OUString& sHelpURL, const rtl::OUString& sLabel, sal_uInt16 nType, const uno::Any& aSubMenu )
+uno::Sequence< beans::PropertyValue > ScVbaCommandBarControls::CreateMenuItemData( const rtl::OUString& sCommandURL,
+ const rtl::OUString& sHelpURL,
+ const rtl::OUString& sLabel,
+ sal_uInt16 nType,
+ const uno::Any& aSubMenu,
+ sal_Bool isVisible,
+ sal_Bool isEnabled )
{
- uno::Sequence< beans::PropertyValue > aProps(5);
+ uno::Sequence< beans::PropertyValue > aProps(7);
aProps[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_COMMANDURL ));
aProps[0].Value <<= sCommandURL;
@@ -75,6 +81,10 @@ uno::Sequence< beans::PropertyValue > ScVbaCommandBarControls::CreateMenuItemDat
aProps[3].Value <<= nType;
aProps[4].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_CONTAINER ));
aProps[4].Value = aSubMenu;
+ aProps[5].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ISVISIBLE );
+ aProps[5].Value <<= isVisible;
+ aProps[6].Name = rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ENABLED );
+ aProps[6].Value <<= isEnabled;
return aProps;
}
@@ -125,9 +135,9 @@ ScVbaCommandBarControls::createCollectionObject( const uno::Any& aSource )
getPropertyValue( aProps, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_CONTAINER )) ) >>= xSubMenu;
ScVbaCommandBarControl* pNewCommandBarControl = NULL;
if( xSubMenu.is() )
- pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True, m_xMenu );
+ pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True );
else
- pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True, m_xMenu );
+ pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True );
return uno::makeAny( uno::Reference< XCommandBarControl > ( pNewCommandBarControl ) );
}
@@ -203,7 +213,7 @@ ScVbaCommandBarControls::Add( const uno::Any& Type, const uno::Any& Id, const un
sal_uInt16 nItemType = 0;
if( IsMenu() )
{
- aProps = CreateMenuItemData( sCommandUrl, sHelpUrl, sLabel, nItemType, aSubMenu );
+ aProps = CreateMenuItemData( sCommandUrl, sHelpUrl, sLabel, nItemType, aSubMenu, true, true );
}
else
{
@@ -218,12 +228,11 @@ ScVbaCommandBarControls::Add( const uno::Any& Type, const uno::Any& Id, const un
pCBarHelper->ApplyChange( m_sResourceUrl, m_xBarSettings );
- // sometimes it would crash if passing m_xMenu instead of uno::Reference< awt::XMenu >() in Linux.
ScVbaCommandBarControl* pNewCommandBarControl = NULL;
if( nType == office::MsoControlType::msoControlPopup )
- pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary, uno::Reference< awt::XMenu >() );
+ pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary );
else
- pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary, uno::Reference< awt::XMenu >() );
+ pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary );
return uno::Reference< XCommandBarControl >( pNewCommandBarControl );
}
diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx b/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx
index 834c99d8ca..7c6cff9494 100644
--- a/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx
+++ b/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx
@@ -39,18 +39,23 @@ typedef CollTestImplHelper< ov::XCommandBarControls > CommandBarControls_BASE;
class ScVbaCommandBarControls : public CommandBarControls_BASE
{
private:
- VbaCommandBarHelperRef pCBarHelper;
- css::uno::Reference< css::container::XIndexAccess > m_xBarSettings;
- rtl::OUString m_sResourceUrl;
- css::uno::Reference< css::awt::XMenu > m_xMenu;
- sal_Bool m_bIsMenu;
+ VbaCommandBarHelperRef pCBarHelper;
+ css::uno::Reference< css::container::XIndexAccess > m_xBarSettings;
+ rtl::OUString m_sResourceUrl;
+ sal_Bool m_bIsMenu;
- css::uno::Sequence< css::beans::PropertyValue > CreateMenuItemData( const rtl::OUString& sCommandURL, const rtl::OUString& sHelpURL, const rtl::OUString& sLabel, sal_uInt16 nType, const css::uno::Any& aSubMenu );
+ css::uno::Sequence< css::beans::PropertyValue > CreateMenuItemData( const rtl::OUString& sCommandURL,
+ const rtl::OUString& sHelpURL,
+ const rtl::OUString& sLabel,
+ sal_uInt16 nType,
+ const css::uno::Any& aSubMenu,
+ sal_Bool isVisible,
+ sal_Bool isEnabled );
css::uno::Sequence< css::beans::PropertyValue > CreateToolbarItemData( const rtl::OUString& sCommandURL, const rtl::OUString& sHelpURL, const rtl::OUString& sLabel, sal_uInt16 nType, const css::uno::Any& aSubMenu, sal_Bool isVisible, sal_Int32 nStyle );
public:
- ScVbaCommandBarControls( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw( css::uno::RuntimeException );
- sal_Bool IsMenu() const { return m_bIsMenu; }
+ ScVbaCommandBarControls( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl ) throw( css::uno::RuntimeException );
+ sal_Bool IsMenu(){ return m_bIsMenu; }
// XEnumerationAccess
virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
diff --git a/vbahelper/source/vbahelper/vbacommandbarhelper.hxx b/vbahelper/source/vbahelper/vbacommandbarhelper.hxx
index 139e5de906..8f1726af2d 100644
--- a/vbahelper/source/vbahelper/vbacommandbarhelper.hxx
+++ b/vbahelper/source/vbahelper/vbacommandbarhelper.hxx
@@ -48,6 +48,7 @@ static const char ITEM_DESCRIPTOR_STYLE[] = "Style";
static const char ITEM_DESCRIPTOR_ISVISIBLE[] = "IsVisible";
static const char ITEM_DESCRIPTOR_RESOURCEURL[] = "ResourceURL";
static const char ITEM_DESCRIPTOR_UINAME[] = "UIName";
+static const char ITEM_DESCRIPTOR_ENABLED[] = "Enabled";
static const char ITEM_MENUBAR_URL[] = "private:resource/menubar/menubar";
static const char ITEM_TOOLBAR_URL[] = "private:resource/toolbar/";
diff --git a/vbahelper/source/vbahelper/vbadocumentbase.cxx b/vbahelper/source/vbahelper/vbadocumentbase.cxx
index 656a4d44b3..4ccdb94ba3 100644
--- a/vbahelper/source/vbahelper/vbadocumentbase.cxx
+++ b/vbahelper/source/vbahelper/vbadocumentbase.cxx
@@ -40,6 +40,7 @@
#include <com/sun/star/frame/XTitle.hpp>
#include <com/sun/star/document/XEmbeddedScripts.hpp> //Michael E. Bohn
#include <com/sun/star/beans/XPropertySet.hpp>
+#include <ooo/vba/XApplicationBase.hpp>
#include <cppuhelper/exc_hlp.hxx>
#include <comphelper/unwrapargs.hxx>
@@ -277,20 +278,21 @@ VbaDocumentBase::Activate() throw (uno::RuntimeException)
uno::Any SAL_CALL
VbaDocumentBase::getVBProject() throw (uno::RuntimeException)
{
- try // return empty object on error
+ if( !mxVBProject.is() ) try
{
+ uno::Reference< XApplicationBase > xApp( Application(), uno::UNO_QUERY_THROW );
+ uno::Reference< XInterface > xVBE( xApp->getVBE(), uno::UNO_QUERY_THROW );
uno::Sequence< uno::Any > aArgs( 2 );
- aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this );
- aArgs[ 1 ] <<= getModel();
+ aArgs[ 0 ] <<= xVBE; // the VBE
+ aArgs[ 1 ] <<= getModel(); // document model for script container access
uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW );
- uno::Reference< uno::XInterface > xVBProjects = xServiceManager->createInstanceWithArgumentsAndContext(
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBProject" ) ), aArgs, mxContext );
- return uno::Any( xVBProjects );
+ mxVBProject = xServiceManager->createInstanceWithArgumentsAndContext(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.vbide.VBProject" ) ), aArgs, mxContext );
}
catch( uno::Exception& )
{
}
- return uno::Any();
+ return uno::Any( mxVBProject );
}
rtl::OUString&
diff --git a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
index e17d1e0005..a9e0376d0d 100644
--- a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
+++ b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
@@ -27,34 +27,40 @@
************************************************************************/
#include "vbahelper/vbaeventshelperbase.hxx"
+#include <com/sun/star/document/XEventBroadcaster.hpp>
+#include <com/sun/star/script/ModuleType.hpp>
+#include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
+#include <com/sun/star/util/XChangesNotifier.hpp>
#include <filter/msfilter/msvbahelper.hxx>
+#include <unotools/eventcfg.hxx>
using namespace ::com::sun::star;
using namespace ::ooo::vba;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
// ============================================================================
VbaEventsHelperBase::VbaEventsHelperBase( const uno::Sequence< uno::Any >& rArgs, const uno::Reference< uno::XComponentContext >& /*xContext*/ ) :
mpShell( 0 ),
- mbDisposed( false )
+ mbDisposed( true )
{
try
{
mxModel = getXSomethingFromArgs< frame::XModel >( rArgs, 0, false );
mpShell = getSfxObjShell( mxModel );
-
- // add dispose listener
- uno::Reference< lang::XComponent > xComponent( mxModel, uno::UNO_QUERY_THROW );
- xComponent->addEventListener( this );
}
catch( uno::Exception& )
{
}
+ mbDisposed = mpShell == 0;
+ startListening();
}
VbaEventsHelperBase::~VbaEventsHelperBase()
{
- stopListening();
+ OSL_ENSURE( mbDisposed, "VbaEventsHelperBase::~VbaEventsHelperBase - missing disposing notification" );
}
sal_Bool SAL_CALL VbaEventsHelperBase::hasVbaEventHandler( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs )
@@ -66,8 +72,8 @@ sal_Bool SAL_CALL VbaEventsHelperBase::hasVbaEventHandler( sal_Int32 nEventId, c
return getEventHandlerPath( rInfo, rArgs ).getLength() > 0;
}
-void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs )
- throw (lang::IllegalArgumentException, script::provider::ScriptFrameworkErrorException, util::VetoException, uno::RuntimeException)
+sal_Bool SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs )
+ throw (lang::IllegalArgumentException, util::VetoException, uno::RuntimeException)
{
/* Derived classes may add new event identifiers to be processed while
processing the original event. All unprocessed events are collected in
@@ -80,9 +86,9 @@ void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const un
handler receives the Cancel value of the previous event handler. */
bool bCancel = false;
- /* bSuccess will change to true if at least one event handler has been
- executed successfully. */
- bool bSuccess = false;
+ /* bExecuted will change to true if at least one event handler has been
+ found and executed. */
+ bool bExecuted = false;
/* Loop as long as there are more events to be processed. Derived classes
may add new events to be processed in the virtual implPrepareEvent()
@@ -99,15 +105,15 @@ void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const un
const EventHandlerInfo& rInfo = getEventHandlerInfo( aEventQueue.front().mnEventId );
uno::Sequence< uno::Any > aEventArgs = aEventQueue.front().maArgs;
aEventQueue.pop_front();
+ OSL_TRACE( "VbaEventsHelperBase::processVbaEvent( \"%s\" )", ::rtl::OUStringToOString( rInfo.maMacroName, RTL_TEXTENCODING_UTF8 ).getStr() );
/* Let derived classes prepare the event, they may add new events for
next iteration. If false is returned, the event handler must not be
called. */
- bool bEventSuccess = false;
if( implPrepareEvent( aEventQueue, rInfo, aEventArgs ) )
{
// search the event handler macro in the document
- ::rtl::OUString aMacroPath = getEventHandlerPath( rInfo, aEventArgs );
+ OUString aMacroPath = getEventHandlerPath( rInfo, aEventArgs );
if( aMacroPath.getLength() > 0 )
{
// build the argument list
@@ -121,96 +127,225 @@ void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const un
}
// execute the event handler
uno::Any aRet, aCaller;
- bEventSuccess = executeMacro( mpShell, aMacroPath, aVbaArgs, aRet, aCaller );
- // extract new cancel value
+ executeMacro( mpShell, aMacroPath, aVbaArgs, aRet, aCaller );
+ // extract new cancel value (may be boolean or any integer type)
if( rInfo.mnCancelIndex >= 0 )
{
- if( rInfo.mnCancelIndex >= aVbaArgs.getLength() )
- throw lang::IllegalArgumentException();
- // cancel value may be boolean or any integer type, Any(bool) does not extract to sal_Int32
- bool bNewCancel = false;
- sal_Int32 nNewCancel = 0;
- if( aVbaArgs[ rInfo.mnCancelIndex ] >>= bNewCancel )
- bCancel = bNewCancel;
- else if( aVbaArgs[ rInfo.mnCancelIndex ] >>= nNewCancel )
- bCancel = nNewCancel != 0;
+ checkArgument( aVbaArgs, rInfo.mnCancelIndex );
+ bCancel = extractBoolFromAny( aVbaArgs[ rInfo.mnCancelIndex ] );
}
+ // event handler has been found
+ bExecuted = true;
}
- // global success, if at least one event handler succeeded
- bSuccess |= bEventSuccess;
}
// post processing (also, if event handler does not exist, or disabled, or on error
- implPostProcessEvent( aEventQueue, rInfo, bEventSuccess, bCancel );
+ implPostProcessEvent( aEventQueue, rInfo, bCancel );
}
// if event handlers want to cancel the event, do so regardless of any errors
if( bCancel )
throw util::VetoException();
- // if no event handler finished successfully, throw
- if( !bSuccess )
- throw script::provider::ScriptFrameworkErrorException();
+ // return true, if at least one event handler has been found
+ return bExecuted;
}
-void SAL_CALL VbaEventsHelperBase::disposing( const lang::EventObject& /*aSource*/ ) throw (uno::RuntimeException)
+void SAL_CALL VbaEventsHelperBase::notifyEvent( const document::EventObject& rEvent ) throw (uno::RuntimeException)
{
- OSL_TRACE( "VbaEventsHelperBase::disposing" );
- stopListening();
- mbDisposed = true;
+ OSL_TRACE( "VbaEventsHelperBase::notifyEvent( \"%s\" )", ::rtl::OUStringToOString( rEvent.EventName, RTL_TEXTENCODING_UTF8 ).getStr() );
+ if( rEvent.EventName == GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ) )
+ stopListening();
+}
+
+void SAL_CALL VbaEventsHelperBase::changesOccurred( const util::ChangesEvent& rEvent ) throw (uno::RuntimeException)
+{
+ // make sure the VBA library exists
+ try
+ {
+ ensureVBALibrary();
+ }
+ catch( uno::Exception& )
+ {
+ return;
+ }
+
+ // check that the sender of the event is the VBA library
+ uno::Reference< script::vba::XVBAModuleInfo > xSender( rEvent.Base, uno::UNO_QUERY );
+ if( mxModuleInfos.get() != xSender.get() )
+ return;
+
+ // process all changed modules
+ for( sal_Int32 nIndex = 0, nLength = rEvent.Changes.getLength(); nIndex < nLength; ++nIndex )
+ {
+ const util::ElementChange& rChange = rEvent.Changes[ nIndex ];
+ OUString aModuleName;
+ if( (rChange.Accessor >>= aModuleName) && (aModuleName.getLength() > 0) ) try
+ {
+ // invalidate event handler path map depending on module type
+ if( getModuleType( aModuleName ) == script::ModuleType::NORMAL )
+ // paths to global event handlers are stored with empty key (will be searched in all normal code modules)
+ maEventPaths.erase( OUString() );
+ else
+ // paths to class/form/document event handlers are keyed by module name
+ maEventPaths.erase( aModuleName );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+}
+
+void SAL_CALL VbaEventsHelperBase::disposing( const lang::EventObject& rEvent ) throw (uno::RuntimeException)
+{
+ uno::Reference< frame::XModel > xSender( rEvent.Source, uno::UNO_QUERY );
+ if( xSender.is() )
+ stopListening();
+}
+
+void VbaEventsHelperBase::processVbaEventNoThrow( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs )
+{
+ try
+ {
+ processVbaEvent( nEventId, rArgs );
+ }
+ catch( uno::Exception& )
+ {
+ }
}
// protected ------------------------------------------------------------------
-void VbaEventsHelperBase::registerEventHandler( sal_Int32 nEventId,
- const sal_Char* pcMacroName, EventHandlerType eType, sal_Int32 nCancelIndex, const uno::Any& rUserData )
+void VbaEventsHelperBase::registerEventHandler( sal_Int32 nEventId, sal_Int32 nModuleType,
+ const sal_Char* pcMacroName, sal_Int32 nCancelIndex, const uno::Any& rUserData )
{
- EventHandlerInfo& rInfo = maEvents[ nEventId ];
+ EventHandlerInfo& rInfo = maEventInfos[ nEventId ];
rInfo.mnEventId = nEventId;
- rInfo.maMacroName = ::rtl::OUString::createFromAscii( pcMacroName );
- rInfo.meType = eType;
+ rInfo.mnModuleType = nModuleType;
+ rInfo.maMacroName = OUString::createFromAscii( pcMacroName );
rInfo.mnCancelIndex = nCancelIndex;
rInfo.maUserData = rUserData;
}
// private --------------------------------------------------------------------
+void VbaEventsHelperBase::startListening()
+{
+ if( mbDisposed )
+ return;
+
+ uno::Reference< document::XEventBroadcaster > xEventBroadcaster( mxModel, uno::UNO_QUERY );
+ if( xEventBroadcaster.is() )
+ try { xEventBroadcaster->addEventListener( this ); } catch( uno::Exception& ) {}
+}
+
+void VbaEventsHelperBase::stopListening()
+{
+ if( mbDisposed )
+ return;
+
+ uno::Reference< document::XEventBroadcaster > xEventBroadcaster( mxModel, uno::UNO_QUERY );
+ if( xEventBroadcaster.is() )
+ try { xEventBroadcaster->removeEventListener( this ); } catch( uno::Exception& ) {}
+
+ mxModel.clear();
+ mpShell = 0;
+ maEventInfos.clear();
+ mbDisposed = true;
+}
+
const VbaEventsHelperBase::EventHandlerInfo& VbaEventsHelperBase::getEventHandlerInfo(
sal_Int32 nEventId ) const throw (lang::IllegalArgumentException)
{
- EventHandlerMap::const_iterator aIt = maEvents.find( nEventId );
- if( aIt == maEvents.end() )
+ EventHandlerInfoMap::const_iterator aIt = maEventInfos.find( nEventId );
+ if( aIt == maEventInfos.end() )
throw lang::IllegalArgumentException();
return aIt->second;
}
-::rtl::OUString VbaEventsHelperBase::getEventHandlerPath( const EventHandlerInfo& rInfo,
- const uno::Sequence< uno::Any >& rArgs ) const throw (lang::IllegalArgumentException)
+OUString VbaEventsHelperBase::getEventHandlerPath( const EventHandlerInfo& rInfo,
+ const uno::Sequence< uno::Any >& rArgs ) throw (lang::IllegalArgumentException, uno::RuntimeException)
{
- ::rtl::OUString aMacroName;
- switch( rInfo.meType )
+ OUString aModuleName;
+ switch( rInfo.mnModuleType )
{
- case EVENTHANDLER_GLOBAL:
- aMacroName = rInfo.maMacroName;
+ // global event handlers may exist in any standard code module
+ case script::ModuleType::NORMAL:
break;
- case EVENTHANDLER_DOCUMENT:
- aMacroName = ::rtl::OUStringBuffer( implGetDocumentModuleName( rInfo, rArgs ) ).
- append( sal_Unicode( '.' ) ).append( rInfo.maMacroName ).makeStringAndClear();
+
+ // document event: get name of the code module associated to the event sender
+ case script::ModuleType::DOCUMENT:
+ aModuleName = implGetDocumentModuleName( rInfo, rArgs );
+ if( aModuleName.getLength() == 0 )
+ throw lang::IllegalArgumentException();
break;
+
+ default:
+ throw uno::RuntimeException(); // unsupported module type
}
- MacroResolvedInfo aMacroInfo = resolveVBAMacro( mpShell, aMacroName, false );
- return aMacroInfo.mbFound ? ::rtl::OUString( aMacroInfo.msResolvedMacro ) : ::rtl::OUString();
+
+ /* Performance improvement: Check the list of existing event handlers
+ instead of searching in Basic source code every time. */
+ EventHandlerPathMap::iterator aIt = maEventPaths.find( aModuleName );
+ ModulePathMap& rPathMap = (aIt == maEventPaths.end()) ? updateModulePathMap( aModuleName ) : aIt->second;
+ return rPathMap[ rInfo.mnEventId ];
}
-void VbaEventsHelperBase::stopListening()
+void VbaEventsHelperBase::ensureVBALibrary() throw (uno::RuntimeException)
{
- if( !mbDisposed ) try
+ if( !mxModuleInfos.is() ) try
{
- uno::Reference< lang::XComponent > xComponent( mxModel, uno::UNO_QUERY_THROW );
- xComponent->removeEventListener( this );
+ maLibraryName = getDefaultProjectName( mpShell );
+ if( maLibraryName.getLength() == 0 )
+ throw uno::RuntimeException();
+ uno::Reference< beans::XPropertySet > xModelProps( mxModel, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNameAccess > xBasicLibs( xModelProps->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) ), uno::UNO_QUERY_THROW );
+ mxModuleInfos.set( xBasicLibs->getByName( maLibraryName ), uno::UNO_QUERY_THROW );
+ // listen to changes in the VBA source code
+ uno::Reference< util::XChangesNotifier > xChangesNotifier( mxModuleInfos, uno::UNO_QUERY_THROW );
+ xChangesNotifier->addChangesListener( this );
}
catch( uno::Exception& )
{
+ // error accessing the Basic library, so this object is useless
+ stopListening();
+ throw uno::RuntimeException();
+ }
+}
+
+sal_Int32 VbaEventsHelperBase::getModuleType( const OUString& rModuleName ) throw (uno::RuntimeException)
+{
+ // make sure the VBA library exists
+ ensureVBALibrary();
+
+ // no module specified: global event handler in standard code modules
+ if( rModuleName.getLength() == 0 )
+ return script::ModuleType::NORMAL;
+
+ // get module type from module info
+ try
+ {
+ return mxModuleInfos->getModuleInfo( rModuleName ).ModuleType;
+ }
+ catch( uno::Exception& )
+ {
+ }
+ throw uno::RuntimeException();
+}
+
+VbaEventsHelperBase::ModulePathMap& VbaEventsHelperBase::updateModulePathMap( const ::rtl::OUString& rModuleName ) throw (uno::RuntimeException)
+{
+ // get type of the specified module (throws on error)
+ sal_Int32 nModuleType = getModuleType( rModuleName );
+ // search for all event handlers
+ ModulePathMap& rPathMap = maEventPaths[ rModuleName ];
+ for( EventHandlerInfoMap::iterator aIt = maEventInfos.begin(), aEnd = maEventInfos.end(); aIt != aEnd; ++aIt )
+ {
+ const EventHandlerInfo& rInfo = aIt->second;
+ if( rInfo.mnModuleType == nModuleType )
+ rPathMap[ rInfo.mnEventId ] = resolveVBAMacro( mpShell, maLibraryName, rModuleName, rInfo.maMacroName );
}
+ return rPathMap;
}
// ============================================================================
diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx
index 35a75470e5..9b19012af0 100644
--- a/vbahelper/source/vbahelper/vbahelper.cxx
+++ b/vbahelper/source/vbahelper/vbahelper.cxx
@@ -485,82 +485,87 @@ void PrintOutHelper( SfxViewShell* pViewShell, const uno::Any& From, const uno::
dispatchExecute( pViewShell, SID_VIEWSHELL1 );
}
-bool extractBoolFromAny( bool& rbValue, const uno::Any& rAny )
+sal_Int32 extractIntFromAny( const uno::Any& rAny ) throw (uno::RuntimeException)
{
- if( rAny >>= rbValue ) return true;
-
- sal_Int64 nSigned = 0;
- if( rAny >>= nSigned ) { rbValue = nSigned != 0; return true; }
-
- sal_uInt64 nUnsigned = 0;
- if( rAny >>= nUnsigned ) { rbValue = nUnsigned > 0; return true; }
-
- double fDouble = 0.0;
- if( rAny >>= fDouble ) { rbValue = fDouble != 0.0; return true; }
+ switch( rAny.getValueType().getTypeClass() )
+ {
+ case uno::TypeClass_FLOAT:
+ return static_cast< sal_Int32 >( rAny.get< float >() );
+ case uno::TypeClass_DOUBLE:
+ return static_cast< sal_Int32 >( rAny.get< double >() );
+ case uno::TypeClass_BYTE:
+ case uno::TypeClass_SHORT:
+ case uno::TypeClass_LONG:
+ return rAny.get< sal_Int32 >();
+ default:;
+ }
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid type, cannot convert to integer." ) ), 0 );
+}
- return false;
+sal_Int32 extractIntFromAny( const uno::Any& rAny, sal_Int32 nDefault ) throw (uno::RuntimeException)
+{
+ return rAny.hasValue() ? extractIntFromAny( rAny ) : nDefault;
}
bool extractBoolFromAny( const uno::Any& rAny ) throw (uno::RuntimeException)
{
- bool bValue = false;
- if( extractBoolFromAny( bValue, rAny ) )
- return bValue;
- throw uno::RuntimeException();
+ switch( rAny.getValueType().getTypeClass() )
+ {
+ case uno::TypeClass_BOOLEAN:
+ return rAny.get< bool >();
+ case uno::TypeClass_FLOAT:
+ return rAny.get< float >() != 0.0;
+ case uno::TypeClass_DOUBLE:
+ return rAny.get< double >() != 0.0;
+ case uno::TypeClass_BYTE:
+ case uno::TypeClass_SHORT:
+ case uno::TypeClass_LONG:
+ return rAny.get< sal_Int32 >() != 0;
+ case uno::TypeClass_HYPER:
+ return rAny.get< sal_Int64 >() != 0;
+ default:;
+ }
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid type, cannot convert to boolean." ) ), 0 );
+}
+
+bool extractBoolFromAny( const uno::Any& rAny, bool bDefault ) throw (uno::RuntimeException)
+{
+ return rAny.hasValue() ? extractBoolFromAny( rAny ) : bDefault;
}
-rtl::OUString getAnyAsString( const uno::Any& pvargItem ) throw ( uno::RuntimeException )
+::rtl::OUString extractStringFromAny( const uno::Any& rAny, bool bUppercaseBool ) throw (uno::RuntimeException)
{
- uno::Type aType = pvargItem.getValueType();
- uno::TypeClass eTypeClass = aType.getTypeClass();
- rtl::OUString sString;
- switch ( eTypeClass )
+ switch( rAny.getValueType().getTypeClass() )
{
- case uno::TypeClass_BOOLEAN:
- {
- sal_Bool bBool = sal_False;
- pvargItem >>= bBool;
- sString = rtl::OUString::valueOf( bBool );
- break;
- }
case uno::TypeClass_STRING:
- pvargItem >>= sString;
- break;
+ return rAny.get< ::rtl::OUString >();
+ case uno::TypeClass_BOOLEAN:
+ return bUppercaseBool ?
+ (rAny.get< bool >() ? ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TRUE" ) ) : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FALSE" ) )) :
+ ::rtl::OUString::valueOf( (sal_Bool)rAny.get< bool >() );
case uno::TypeClass_FLOAT:
- {
- float aFloat = 0;
- pvargItem >>= aFloat;
- sString = rtl::OUString::valueOf( aFloat );
- break;
- }
+ return ::rtl::OUString::valueOf( rAny.get< float >() );
case uno::TypeClass_DOUBLE:
- {
- double aDouble = 0;
- pvargItem >>= aDouble;
- sString = rtl::OUString::valueOf( aDouble );
- break;
- }
+ return ::rtl::OUString::valueOf( rAny.get< double >() );
+ case uno::TypeClass_BYTE:
case uno::TypeClass_SHORT:
case uno::TypeClass_LONG:
- case uno::TypeClass_BYTE:
- {
- sal_Int32 aNum = 0;
- pvargItem >>= aNum;
- sString = rtl::OUString::valueOf( aNum );
- break;
- }
-
+ return ::rtl::OUString::valueOf( rAny.get< sal_Int32 >() );
case uno::TypeClass_HYPER:
- {
- sal_Int64 aHyper = 0;
- pvargItem >>= aHyper;
- sString = rtl::OUString::valueOf( aHyper );
- break;
- }
- default:
- throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Invalid type, can't convert")), uno::Reference< uno::XInterface >() );
+ return ::rtl::OUString::valueOf( rAny.get< sal_Int64 >() );
+ default:;
}
- return sString;
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid type, cannot convert to string." ) ), 0 );
+}
+
+::rtl::OUString extractStringFromAny( const uno::Any& rAny, const ::rtl::OUString& rDefault, bool bUppercaseBool ) throw (uno::RuntimeException)
+{
+ return rAny.hasValue() ? extractStringFromAny( rAny, bUppercaseBool ) : rDefault;
+}
+
+rtl::OUString getAnyAsString( const uno::Any& pvargItem ) throw ( uno::RuntimeException )
+{
+ return extractStringFromAny( pvargItem );
}
@@ -697,7 +702,7 @@ rtl::OUString VBAToRegexp(const rtl::OUString &rIn, bool bForLike )
return sResult.makeStringAndClear( );
}
-double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical)
+double getPixelTo100thMillimeterConversionFactor( const css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical)
{
double fConvertFactor = 1.0;
if( bVertical )
@@ -711,12 +716,12 @@ double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt:
return fConvertFactor;
}
-double PointsToPixels( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical)
+double PointsToPixels( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical)
{
double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical );
return PointsToHmm( fPoints ) * fConvertFactor;
}
-double PixelsToPoints( css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical)
+double PixelsToPoints( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical)
{
double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical );
return HmmToPoints(static_cast<sal_Int32>(fPixels/fConvertFactor));
@@ -880,345 +885,403 @@ void setOrAppendPropertyValue( uno::Sequence< beans::PropertyValue >& aProp, con
// ====UserFormGeomentryHelper====
//---------------------------------------------
-UserFormGeometryHelper::UserFormGeometryHelper( const uno::Reference< uno::XComponentContext >& /*xContext*/, const uno::Reference< awt::XControl >& xControl )
-: mbDialog( uno::Reference< awt::XDialog >( xControl, uno::UNO_QUERY ).is() )
+UserFormGeometryHelper::UserFormGeometryHelper(
+ const uno::Reference< uno::XComponentContext >& /*xContext*/,
+ const uno::Reference< awt::XControl >& xControl,
+ double fOffsetX, double fOffsetY ) :
+ mfOffsetX( fOffsetX ),
+ mfOffsetY( fOffsetY ),
+ mbDialog( uno::Reference< awt::XDialog >( xControl, uno::UNO_QUERY ).is() )
{
if ( !xControl.is() )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No control is provided!" ) ),
uno::Reference< uno::XInterface >() );
mxWindow.set( xControl->getPeer(), uno::UNO_QUERY_THROW );
+ mxModelProps.set( xControl->getModel(), uno::UNO_QUERY_THROW );
+ mxUnitConv.set( mxWindow, uno::UNO_QUERY_THROW );
}
-//---------------------------------------------
-double UserFormGeometryHelper::getLeft()
+double UserFormGeometryHelper::getLeft() const
{
- return mxWindow->getPosSize().X;
+ return implGetPos( false );
}
-//---------------------------------------------
-void UserFormGeometryHelper::setLeft( double nLeft )
+void UserFormGeometryHelper::setLeft( double fLeft )
{
- mxWindow->setPosSize(static_cast<sal_Int32>(nLeft), mxWindow->getPosSize().Y, 0, 0, awt::PosSize::POS );
+ implSetPos( fLeft, false );
}
-//---------------------------------------------
-double UserFormGeometryHelper::getTop()
+double UserFormGeometryHelper::getTop() const
{
- return mxWindow->getPosSize().Y;
+ return implGetPos( true );
}
-//---------------------------------------------
-void UserFormGeometryHelper::setTop( double nTop )
+void UserFormGeometryHelper::setTop( double fTop )
{
- mxWindow->setPosSize( mxWindow->getPosSize().X, static_cast<sal_Int32>(nTop), 0, 0, awt::PosSize::POS );
+ implSetPos( fTop, true );
}
-//---------------------------------------------
-double UserFormGeometryHelper::getWidth()
+double UserFormGeometryHelper::getWidth() const
{
- if ( mbDialog )
- {
- const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow );
- if ( pWindow )
- {
- // get the size with decoration
- Rectangle aResult = pWindow->GetWindowExtentsRelative( NULL );
- return aResult.getWidth();
- }
- }
-
- return mxWindow->getPosSize().Width;
+ return implGetSize( false, true );
}
-//---------------------------------------------
-void UserFormGeometryHelper::setWidth( double nWidth )
+void UserFormGeometryHelper::setWidth( double fWidth )
{
- sal_Int64 nNewWidth = static_cast<sal_Int64>(nWidth);
+ implSetSize( fWidth, false, true );
+}
- if ( mbDialog )
- {
- const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow );
- if ( pWindow )
- {
- // set the size with decoration
- Rectangle aRDecor = pWindow->GetWindowExtentsRelative( NULL );
- if ( !aRDecor.IsEmpty() )
- {
- sal_Int64 nDecor = aRDecor.getWidth();
- sal_Int64 nUnDecor = mxWindow->getPosSize().Width;
- if ( nWidth < nDecor - nUnDecor )
- nUnDecor = static_cast<sal_Int64>(nDecor - nWidth); // avoid negative size
- nNewWidth = static_cast<sal_Int64>(nWidth + nUnDecor - nDecor);
- }
- }
- }
+double UserFormGeometryHelper::getHeight() const
+{
+ return implGetSize( true, true );
+}
- mxWindow->setPosSize( 0, 0, nNewWidth, 0, awt::PosSize::WIDTH );
+void UserFormGeometryHelper::setHeight( double fHeight )
+{
+ implSetSize( fHeight, true, true );
}
-//---------------------------------------------
-double UserFormGeometryHelper::getHeight()
+double UserFormGeometryHelper::getInnerWidth() const
{
- if ( mbDialog )
- {
- const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow );
- if ( pWindow )
- {
- // get the size with decoration
- Rectangle aResult = pWindow->GetWindowExtentsRelative( NULL );
- return aResult.getHeight();
- }
- }
+ return implGetSize( false, false );
+}
- return mxWindow->getPosSize().Height;
+void UserFormGeometryHelper::setInnerWidth( double fWidth )
+{
+ implSetSize( fWidth, false, false );
}
-//---------------------------------------------
-void UserFormGeometryHelper::setHeight( double nHeight )
+double UserFormGeometryHelper::getInnerHeight() const
{
- sal_Int64 nNewHeight = static_cast<sal_Int64>(nHeight);
- if ( mbDialog )
- {
- const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow );
- if ( pWindow )
- {
- // set the size with decoration
- Rectangle aRDecor = pWindow->GetWindowExtentsRelative( NULL );
- if ( !aRDecor.IsEmpty() )
- {
- sal_Int64 nDecor = aRDecor.getHeight();
- sal_Int64 nUnDecor = mxWindow->getPosSize().Height;
- if ( nHeight < nDecor - nUnDecor )
- nUnDecor = static_cast<sal_Int64>(nDecor - nHeight); // avoid negative size
- nNewHeight = static_cast<sal_Int64>(nHeight + nUnDecor - nDecor);
- }
- }
- }
+ return implGetSize( true, false );
+}
- mxWindow->setPosSize( 0, 0, 0, nNewHeight, awt::PosSize::HEIGHT );
+void UserFormGeometryHelper::setInnerHeight( double fHeight )
+{
+ implSetSize( fHeight, true, false );
}
-// ============
+double UserFormGeometryHelper::getOffsetX() const
+{
+ return mfOffsetX;
+}
- double ConcreteXShapeGeometryAttributes::getLeft()
- {
- return m_pShapeHelper->getLeft();
- }
- void ConcreteXShapeGeometryAttributes::setLeft( double nLeft )
- {
- m_pShapeHelper->setLeft( nLeft );
- }
- double ConcreteXShapeGeometryAttributes::getTop()
- {
- return m_pShapeHelper->getTop();
- }
- void ConcreteXShapeGeometryAttributes::setTop( double nTop )
- {
- m_pShapeHelper->setTop( nTop );
- }
+double UserFormGeometryHelper::getOffsetY() const
+{
+ return mfOffsetY;
+}
- double ConcreteXShapeGeometryAttributes::getHeight()
- {
- return m_pShapeHelper->getHeight();
- }
- void ConcreteXShapeGeometryAttributes::setHeight( double nHeight )
- {
- m_pShapeHelper->setHeight( nHeight );
- }
- double ConcreteXShapeGeometryAttributes::getWidth()
- {
- return m_pShapeHelper->getWidth();
- }
- void ConcreteXShapeGeometryAttributes::setWidth( double nWidth)
- {
- m_pShapeHelper->setWidth( nWidth );
- }
+// ----------------------------------------------------------------------------
+static const ::rtl::OUString saPosXName( RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) );
+static const ::rtl::OUString saPosYName( RTL_CONSTASCII_USTRINGPARAM( "PositionY" ) );
+static const ::rtl::OUString saWidthName( RTL_CONSTASCII_USTRINGPARAM( "Width" ) );
+static const ::rtl::OUString saHeightName( RTL_CONSTASCII_USTRINGPARAM( "Height" ) );
- ShapeHelper::ShapeHelper( const css::uno::Reference< css::drawing::XShape >& _xShape) throw (css::script::BasicErrorException ) : xShape( _xShape )
- {
- if( !xShape.is() )
- throw css::uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No valid shape for helper")), css::uno::Reference< css::uno::XInterface >() );
- }
+double UserFormGeometryHelper::implGetPos( bool bPosY ) const
+{
+ sal_Int32 nPosAppFont = mxModelProps->getPropertyValue( bPosY ? saPosYName : saPosXName ).get< sal_Int32 >();
+ // appfont to pixel
+ awt::Point aPosPixel = mxUnitConv->convertPointToPixel( awt::Point( nPosAppFont, nPosAppFont ), util::MeasureUnit::APPFONT );
+ // pixel to VBA points
+ awt::Point aPosPoint = mxUnitConv->convertPointToLogic( aPosPixel, util::MeasureUnit::POINT );
+ return bPosY ? (aPosPoint.Y - mfOffsetY) : (aPosPoint.X - mfOffsetX);
+}
- double ShapeHelper::getHeight()
- {
- return Millimeter::getInPoints(xShape->getSize().Height);
- }
+void UserFormGeometryHelper::implSetPos( double fPos, bool bPosY )
+{
+ // convert passed VBA points to pixels
+ sal_Int32 nPosPixel = static_cast< sal_Int32 >( fPos + (bPosY ? mfOffsetY : mfOffsetX) );
+ awt::Point aPosPixel = mxUnitConv->convertPointToPixel( awt::Point( nPosPixel, nPosPixel ), util::MeasureUnit::POINT );
+ // pixel to appfont
+ awt::Point aPosAppFont = mxUnitConv->convertPointToLogic( aPosPixel, util::MeasureUnit::APPFONT );
+ mxModelProps->setPropertyValue( bPosY ? saPosYName : saPosXName, uno::Any( bPosY ? aPosAppFont.Y : aPosAppFont.X ) );
+}
+double UserFormGeometryHelper::implGetSize( bool bHeight, bool bOuter ) const
+{
+ sal_Int32 nSizeAppFont = mxModelProps->getPropertyValue( bHeight ? saHeightName : saWidthName ).get< sal_Int32 >();
+ // appfont to pixel
+ awt::Size aSizePixel = mxUnitConv->convertSizeToPixel( awt::Size( nSizeAppFont, nSizeAppFont ), util::MeasureUnit::APPFONT );
- void ShapeHelper::setHeight(double _fheight) throw ( css::script::BasicErrorException )
+ /* The VBA symbols 'Width' and 'Height' return the outer size including
+ window decoration (in difference to the symbols 'InnerWidth' and
+ 'InnerHeight'), but the window API returns the inner size. */
+ if( mbDialog && bOuter )
{
- try
+ if( const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow ) )
{
- css::awt::Size aSize = xShape->getSize();
- aSize.Height = Millimeter::getInHundredthsOfOneMillimeter(_fheight);
- xShape->setSize(aSize);
+ Rectangle aOuterRect = pWindow->GetWindowExtentsRelative( NULL );
+ aSizePixel = awt::Size( aOuterRect.getWidth(), aOuterRect.getHeight() );
}
- catch ( css::uno::Exception& /*e*/)
- {
- throw css::script::BasicErrorException( rtl::OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
- }
}
+ // pixel to VBA points
+ awt::Size aSizePoint = mxUnitConv->convertSizeToLogic( aSizePixel, util::MeasureUnit::POINT );
+ return bHeight ? aSizePoint.Height : aSizePoint.Width;
+}
- double ShapeHelper::getWidth()
- {
- return Millimeter::getInPoints(xShape->getSize().Width);
- }
+void UserFormGeometryHelper::implSetSize( double fSize, bool bHeight, bool bOuter )
+{
+ // convert passed VBA points to pixels
+ sal_Int32 nSize = static_cast< sal_Int32 >( fSize );
+ awt::Size aSizePixel = mxUnitConv->convertSizeToPixel( awt::Size( nSize, nSize ), util::MeasureUnit::POINT );
- void ShapeHelper::setWidth(double _fWidth) throw ( css::script::BasicErrorException )
+ /* The VBA symbols 'Width' and 'Height' set the outer size (in difference
+ to the symbols 'InnerWidth' and 'InnerHeight'), but the dialog model
+ expects the inner size. We have to remove the window extents from the
+ pixel height to get the same result. */
+ if ( mbDialog && bOuter )
{
- try
- {
- css::awt::Size aSize = xShape->getSize();
- aSize.Width = Millimeter::getInHundredthsOfOneMillimeter(_fWidth);
- xShape->setSize(aSize);
- }
- catch (css::uno::Exception& /*e*/)
+ if( const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow ) )
{
- throw css::script::BasicErrorException( rtl::OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ Rectangle aOuterRect = pWindow->GetWindowExtentsRelative( NULL );
+ if( !aOuterRect.IsEmpty() )
+ {
+ awt::Rectangle aInnerRect = mxWindow->getPosSize();
+ sal_Int32 nDecorWidth = aOuterRect.getWidth() - aInnerRect.Width;
+ sal_Int32 nDecorHeight = aOuterRect.getHeight() - aInnerRect.Height;
+ aSizePixel.Width = ::std::max< sal_Int32 >( aSizePixel.Width - nDecorWidth, 1 );
+ aSizePixel.Height = ::std::max< sal_Int32 >( aSizePixel.Height - nDecorHeight, 1 );
+ }
}
}
+ awt::Size aSizeAppFont = mxUnitConv->convertSizeToLogic( aSizePixel, util::MeasureUnit::APPFONT );
+ mxModelProps->setPropertyValue( bHeight ? saHeightName : saWidthName, uno::Any( bHeight ? aSizeAppFont.Height : aSizeAppFont.Width ) );
+}
+
+// ============================================================================
- double ShapeHelper::getLeft()
- {
- return Millimeter::getInPoints(xShape->getPosition().X);
- }
+double ConcreteXShapeGeometryAttributes::getLeft() const
+{
+ return m_pShapeHelper->getLeft();
+}
+void ConcreteXShapeGeometryAttributes::setLeft( double nLeft )
+{
+ m_pShapeHelper->setLeft( nLeft );
+}
+double ConcreteXShapeGeometryAttributes::getTop() const
+{
+ return m_pShapeHelper->getTop();
+}
+void ConcreteXShapeGeometryAttributes::setTop( double nTop )
+{
+ m_pShapeHelper->setTop( nTop );
+}
+double ConcreteXShapeGeometryAttributes::getHeight() const
+{
+ return m_pShapeHelper->getHeight();
+}
+void ConcreteXShapeGeometryAttributes::setHeight( double nHeight )
+{
+ m_pShapeHelper->setHeight( nHeight );
+}
+double ConcreteXShapeGeometryAttributes::getWidth() const
+{
+ return m_pShapeHelper->getWidth();
+}
+void ConcreteXShapeGeometryAttributes::setWidth( double nWidth)
+{
+ m_pShapeHelper->setWidth( nWidth );
+}
- void ShapeHelper::setLeft(double _fLeft)
- {
- css::awt::Point aPoint = xShape->getPosition();
- aPoint.X = Millimeter::getInHundredthsOfOneMillimeter(_fLeft);
- xShape->setPosition(aPoint);
- }
+ShapeHelper::ShapeHelper( const css::uno::Reference< css::drawing::XShape >& _xShape) throw (css::script::BasicErrorException ) : xShape( _xShape )
+{
+ if( !xShape.is() )
+ throw css::uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No valid shape for helper")), css::uno::Reference< css::uno::XInterface >() );
+}
- double ShapeHelper::getTop()
- {
- return Millimeter::getInPoints(xShape->getPosition().Y);
+double ShapeHelper::getHeight() const
+{
+ return Millimeter::getInPoints(xShape->getSize().Height);
}
- void ShapeHelper::setTop(double _fTop)
+ void ShapeHelper::setHeight(double _fheight) throw ( css::script::BasicErrorException )
+{
+ try
{
- css::awt::Point aPoint = xShape->getPosition();
- aPoint.Y = Millimeter::getInHundredthsOfOneMillimeter(_fTop);
- xShape->setPosition(aPoint);
+ css::awt::Size aSize = xShape->getSize();
+ aSize.Height = Millimeter::getInHundredthsOfOneMillimeter(_fheight);
+ xShape->setSize(aSize);
}
-
- void DebugHelper::exception( const rtl::OUString& DetailedMessage, const css::uno::Exception& ex, int err, const rtl::OUString& /*additionalArgument*/ ) throw( css::script::BasicErrorException )
+ catch ( css::uno::Exception& /*e*/)
{
- // #TODO #FIXME ( do we want to support additionalArg here )
- throw css::script::BasicErrorException( DetailedMessage.concat( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ")) ).concat( ex.Message ), css::uno::Reference< css::uno::XInterface >(), err, rtl::OUString() );
+ throw css::script::BasicErrorException( rtl::OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+}
+double ShapeHelper::getWidth() const
+{
+ return Millimeter::getInPoints(xShape->getSize().Width);
}
- void DebugHelper::exception( int err, const rtl::OUString& additionalArgument ) throw( css::script::BasicErrorException )
+void ShapeHelper::setWidth(double _fWidth) throw ( css::script::BasicErrorException )
+{
+ try
{
- exception( rtl::OUString(), css::uno::Exception(), err, additionalArgument );
+ css::awt::Size aSize = xShape->getSize();
+ aSize.Width = Millimeter::getInHundredthsOfOneMillimeter(_fWidth);
+ xShape->setSize(aSize);
}
- void DebugHelper::exception( const css::uno::Exception& ex ) throw( css::script::BasicErrorException )
+ catch (css::uno::Exception& /*e*/)
{
- exception( rtl::OUString(), ex, SbERR_INTERNAL_ERROR, rtl::OUString() );
+ throw css::script::BasicErrorException( rtl::OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
}
+}
- Millimeter::Millimeter():m_nMillimeter(0) {}
- Millimeter::Millimeter(double mm):m_nMillimeter(mm) {}
+double ShapeHelper::getLeft() const
+{
+ return Millimeter::getInPoints(xShape->getPosition().X);
+}
- void Millimeter::set(double mm) { m_nMillimeter = mm; }
- void Millimeter::setInPoints(double points)
- {
- m_nMillimeter = points * factor / 100.0;
- }
- void Millimeter::setInHundredthsOfOneMillimeter(double hmm)
- {
- m_nMillimeter = hmm / 100;
- }
+void ShapeHelper::setLeft(double _fLeft)
+{
+ css::awt::Point aPoint = xShape->getPosition();
+ aPoint.X = Millimeter::getInHundredthsOfOneMillimeter(_fLeft);
+ xShape->setPosition(aPoint);
+}
- double Millimeter::get()
- {
- return m_nMillimeter;
- }
- double Millimeter::getInHundredthsOfOneMillimeter()
- {
- return m_nMillimeter * 100;
- }
- double Millimeter::getInPoints()
- {
- return m_nMillimeter / factor * 100.0;
- }
- sal_Int32 Millimeter::getInHundredthsOfOneMillimeter(double points)
- {
- sal_Int32 mm = static_cast<sal_Int32>(points * factor);
- return mm;
- }
+double ShapeHelper::getTop() const
+{
+ return Millimeter::getInPoints(xShape->getPosition().Y);
+}
- double Millimeter::getInPoints(int _hmm)
- {
- double points = double( static_cast<double>(_hmm) / factor);
- return points;
- }
- uno::Reference< uno::XInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell )
- {
- uno::Reference< uno::XInterface > xIf;
- if ( pShell )
- {
- rtl::OUString sProj( RTL_CONSTASCII_USTRINGPARAM("Standard") );
- BasicManager* pBasMgr = pShell->GetBasicManager();
- if ( pBasMgr && pBasMgr->GetName().Len() )
- sProj = pShell->GetBasicManager()->GetName();
- StarBASIC* pBasic = pShell->GetBasicManager()->GetLib( sProj );
- if ( pBasic )
- {
- SbModule* pMod = pBasic->FindModule( aModName );
- if ( pMod )
- xIf = pMod->GetUnoModule();
- }
- }
- return xIf;
- }
+void ShapeHelper::setTop(double _fTop)
+{
+ css::awt::Point aPoint = xShape->getPosition();
+ aPoint.Y = Millimeter::getInHundredthsOfOneMillimeter(_fTop);
+ xShape->setPosition(aPoint);
+}
- // Listener for XNotifyingDispatch
- VBADispatchListener::VBADispatchListener() : m_State( sal_False )
- {
- }
+void DebugHelper::exception( const rtl::OUString& DetailedMessage, const css::uno::Exception& ex, int err, const rtl::OUString& /*additionalArgument*/ ) throw( css::script::BasicErrorException )
+{
+ // #TODO #FIXME ( do we want to support additionalArg here )
+ throw css::script::BasicErrorException( DetailedMessage.concat( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ")) ).concat( ex.Message ), css::uno::Reference< css::uno::XInterface >(), err, rtl::OUString() );
+}
+
+void DebugHelper::exception( int err, const rtl::OUString& additionalArgument ) throw( css::script::BasicErrorException )
+{
+ exception( rtl::OUString(), css::uno::Exception(), err, additionalArgument );
+}
+void DebugHelper::exception( const css::uno::Exception& ex ) throw( css::script::BasicErrorException )
+{
+ exception( rtl::OUString(), ex, SbERR_INTERNAL_ERROR, rtl::OUString() );
+}
+
+Millimeter::Millimeter():m_nMillimeter(0) {}
- // Listener for XNotifyingDispatch
- VBADispatchListener::~VBADispatchListener()
+Millimeter::Millimeter(double mm):m_nMillimeter(mm) {}
+
+void Millimeter::set(double mm) { m_nMillimeter = mm; }
+void Millimeter::setInPoints(double points)
+{
+ m_nMillimeter = points * factor / 100.0;
+}
+
+void Millimeter::setInHundredthsOfOneMillimeter(double hmm)
+{
+ m_nMillimeter = hmm / 100;
+}
+
+double Millimeter::get()
+{
+ return m_nMillimeter;
+}
+double Millimeter::getInHundredthsOfOneMillimeter()
+{
+ return m_nMillimeter * 100;
+}
+double Millimeter::getInPoints()
+{
+ return m_nMillimeter / factor * 100.0;
+}
+
+sal_Int32 Millimeter::getInHundredthsOfOneMillimeter(double points)
+{
+ sal_Int32 mm = static_cast<sal_Int32>(points * factor);
+ return mm;
+}
+
+double Millimeter::getInPoints(int _hmm)
+{
+ double points = double( static_cast<double>(_hmm) / factor);
+ return points;
+}
+
+// Listener for XNotifyingDispatch
+VBADispatchListener::VBADispatchListener() : m_State( sal_False )
+{
+}
+
+// Listener for XNotifyingDispatch
+VBADispatchListener::~VBADispatchListener()
+{
+}
+
+// Listener for XNotifyingDispatch
+void SAL_CALL VBADispatchListener::dispatchFinished( const frame::DispatchResultEvent& aEvent ) throw ( uno::RuntimeException )
+{
+ m_Result = aEvent.Result;
+ m_State = ( aEvent.State == frame::DispatchResultState::SUCCESS ) ? sal_True : sal_False;
+}
+
+// Listener for XNotifyingDispatch
+void SAL_CALL VBADispatchListener::disposing( const lang::EventObject& /*aEvent*/ ) throw( uno::RuntimeException )
+{
+}
+
+uno::Reference< XHelperInterface > getVBADocument( const uno::Reference< frame::XModel >& xModel )
+{
+ uno::Reference< XHelperInterface > xIf;
+ try
{
+ uno::Reference< beans::XPropertySet > xDocProps( xModel, uno::UNO_QUERY_THROW );
+ ::rtl::OUString aCodeName;
+ xDocProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CodeName" ) ) ) >>= aCodeName;
+ xIf = getUnoDocModule( aCodeName, getSfxObjShell( xModel ) );
}
-
- // Listener for XNotifyingDispatch
- void SAL_CALL VBADispatchListener::dispatchFinished( const frame::DispatchResultEvent& aEvent ) throw ( uno::RuntimeException )
+ catch( uno::Exception& )
{
- m_Result = aEvent.Result;
- m_State = ( aEvent.State == frame::DispatchResultState::SUCCESS ) ? sal_True : sal_False;
}
+ return xIf;
+}
- // Listener for XNotifyingDispatch
- void SAL_CALL VBADispatchListener::disposing( const lang::EventObject& /*aEvent*/ ) throw( uno::RuntimeException )
+uno::Reference< XHelperInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell )
+{
+ uno::Reference< XHelperInterface > xIf;
+ if ( pShell )
+ {
+ rtl::OUString sProj( RTL_CONSTASCII_USTRINGPARAM("Standard") );
+ BasicManager* pBasMgr = pShell->GetBasicManager();
+ if ( pBasMgr && pBasMgr->GetName().Len() )
+ sProj = pBasMgr->GetName();
+ if( StarBASIC* pBasic = pShell->GetBasicManager()->GetLib( sProj ) )
+ if( SbModule* pMod = pBasic->FindModule( aModName ) )
+ xIf.set( pMod->GetUnoModule(), uno::UNO_QUERY );
+ }
+ return xIf;
+}
+
+SfxObjectShell* getSfxObjShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
+{
+ SfxObjectShell* pFoundShell = NULL;
+ if ( xModel.is() )
{
+ uno::Reference< lang::XUnoTunnel > xObjShellTunnel( xModel, uno::UNO_QUERY_THROW );
+ pFoundShell = reinterpret_cast<SfxObjectShell*>( xObjShellTunnel->getSomething(SfxObjectShell::getUnoTunnelId()));
}
-
- SfxObjectShell* getSfxObjShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
- {
- SfxObjectShell* pFoundShell = NULL;
- if ( xModel.is() )
- {
- uno::Reference< lang::XUnoTunnel > xObjShellTunnel( xModel, uno::UNO_QUERY_THROW );
- pFoundShell = reinterpret_cast<SfxObjectShell*>( xObjShellTunnel->getSomething(SfxObjectShell::getUnoTunnelId()));
- }
- if ( !pFoundShell )
- throw uno::RuntimeException();
- return pFoundShell;
- }
+ if ( !pFoundShell )
+ throw uno::RuntimeException();
+ return pFoundShell;
+}
} // openoffice
} //org
diff --git a/vbahelper/source/vbahelper/vbawindowbase.cxx b/vbahelper/source/vbahelper/vbawindowbase.cxx
index 2f9556f79e..e605e39b89 100644
--- a/vbahelper/source/vbahelper/vbawindowbase.cxx
+++ b/vbahelper/source/vbahelper/vbawindowbase.cxx
@@ -25,137 +25,113 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-#include <vbahelper/helperdecl.hxx>
-#include <vbahelper/vbawindowbase.hxx>
-#include <com/sun/star/awt/XWindow.hpp>
-#include <com/sun/star/awt/XWindow2.hpp>
+
+#include "vbahelper/vbawindowbase.hxx"
+#include "vbahelper/helperdecl.hxx"
#include <com/sun/star/awt/PosSize.hpp>
using namespace ::com::sun::star;
using namespace ::ooo::vba;
-VbaWindowBase::VbaWindowBase( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : WindowBaseImpl_BASE( xParent, xContext ), m_xModel( xModel )
+VbaWindowBase::VbaWindowBase(
+ const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::frame::XModel >& xModel,
+ const uno::Reference< frame::XController >& xController ) throw (uno::RuntimeException) :
+ WindowBaseImpl_BASE( xParent, xContext ),
+ m_xModel( xModel, uno::UNO_SET_THROW )
{
+ construct( xController );
}
-VbaWindowBase::VbaWindowBase( uno::Sequence< uno::Any > const & args, uno::Reference< uno::XComponentContext > const & xContext )
- : WindowBaseImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext ),
- m_xModel( getXSomethingFromArgs< frame::XModel >( args, 1 ) )
+VbaWindowBase::VbaWindowBase( uno::Sequence< uno::Any > const & args,
+ uno::Reference< uno::XComponentContext > const & xContext ) throw (uno::RuntimeException) :
+ WindowBaseImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0, false ), xContext ),
+ m_xModel( getXSomethingFromArgs< frame::XModel >( args, 1, false ) )
{
+ construct( getXSomethingFromArgs< frame::XController >( args, 2 ) );
}
sal_Bool SAL_CALL
VbaWindowBase::getVisible() throw (uno::RuntimeException)
{
- sal_Bool bVisible = sal_True;
- uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
- uno::Reference< css::awt::XWindow > xWindow (xController->getFrame()->getContainerWindow(), uno::UNO_QUERY_THROW );
- uno::Reference< css::awt::XWindow2 > xWindow2 (xWindow, uno::UNO_QUERY_THROW );
- if( xWindow2.is() )
- {
- bVisible = xWindow2->isVisible();
- }
- return bVisible;
+ return getWindow2()->isVisible();
}
void SAL_CALL
-VbaWindowBase::setVisible(sal_Bool _visible) throw (uno::RuntimeException)
+VbaWindowBase::setVisible( sal_Bool _visible ) throw (uno::RuntimeException)
{
- uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
- uno::Reference< css::awt::XWindow > xWindow (xController->getFrame()->getContainerWindow(), uno::UNO_QUERY_THROW );
- if( xWindow.is() )
- {
- xWindow->setVisible( _visible );
- }
+ getWindow2()->setVisible( _visible );
}
-css::awt::Rectangle getPosSize( const uno::Reference< frame::XModel >& xModel )
+void setPosSize( const uno::Reference< awt::XWindow >& xWindow, sal_Int32 nValue, sal_Int16 nFlag )
{
- css::awt::Rectangle aRect;
- uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
- uno::Reference< css::awt::XWindow > xWindow (xController->getFrame()->getContainerWindow(), uno::UNO_QUERY_THROW );
- if( xWindow.is() )
+ css::awt::Rectangle aRect = xWindow->getPosSize();
+ switch( nFlag )
{
- aRect = xWindow->getPosSize();
+ case css::awt::PosSize::X:
+ xWindow->setPosSize( nValue, aRect.Y, 0, 0, css::awt::PosSize::X );
+ break;
+ case css::awt::PosSize::Y:
+ xWindow->setPosSize( aRect.X, nValue, 0, 0, css::awt::PosSize::Y );
+ break;
+ case css::awt::PosSize::WIDTH:
+ xWindow->setPosSize( 0, 0, nValue, aRect.Height, css::awt::PosSize::WIDTH );
+ break;
+ case css::awt::PosSize::HEIGHT:
+ xWindow->setPosSize( 0, 0, aRect.Width, nValue, css::awt::PosSize::HEIGHT );
+ break;
+ default:
+ break;
}
- return aRect;
}
-void setPosSize( const uno::Reference< frame::XModel >& xModel, sal_Int32 nValue, sal_uInt16 nFlag )
-{
- uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
- uno::Reference< css::awt::XWindow > xWindow (xController->getFrame()->getContainerWindow(), uno::UNO_QUERY_THROW );
- if( xWindow.is() )
- {
- css::awt::Rectangle aRect = xWindow->getPosSize();
- switch( nFlag )
- {
- case css::awt::PosSize::X:
- xWindow->setPosSize( nValue, aRect.Y, 0, 0, css::awt::PosSize::X );
- break;
- case css::awt::PosSize::Y:
- xWindow->setPosSize( aRect.X, nValue, 0, 0, css::awt::PosSize::Y );
- break;
- case css::awt::PosSize::WIDTH:
- xWindow->setPosSize( 0, 0, nValue, aRect.Height, css::awt::PosSize::WIDTH );
- break;
- case css::awt::PosSize::HEIGHT:
- xWindow->setPosSize( 0, 0, aRect.Width, nValue, css::awt::PosSize::HEIGHT );
- break;
- default:
- break;
- }
- }
-}
-
-sal_Int32 SAL_CALL
+sal_Int32 SAL_CALL
VbaWindowBase::getHeight() throw (uno::RuntimeException)
{
- css::awt::Rectangle aRect = getPosSize(m_xModel);
- return aRect.Height;
+ return getWindow()->getPosSize().Height;
}
void SAL_CALL
VbaWindowBase::setHeight( sal_Int32 _height ) throw (uno::RuntimeException)
{
- setPosSize(m_xModel, _height, css::awt::PosSize::HEIGHT);
+ setPosSize( getWindow(), _height, css::awt::PosSize::HEIGHT );
}
sal_Int32 SAL_CALL
VbaWindowBase::getLeft() throw (uno::RuntimeException)
{
- css::awt::Rectangle aRect = getPosSize(m_xModel);
- return aRect.X;
+ return getWindow()->getPosSize().X;
}
void SAL_CALL
VbaWindowBase::setLeft( sal_Int32 _left ) throw (uno::RuntimeException)
{
- setPosSize(m_xModel, _left, css::awt::PosSize::X);
+ setPosSize( getWindow(), _left, css::awt::PosSize::X );
}
+
sal_Int32 SAL_CALL
VbaWindowBase::getTop() throw (uno::RuntimeException)
{
- css::awt::Rectangle aRect = getPosSize(m_xModel);
- return aRect.Y;
+ return getWindow()->getPosSize().Y;
}
void SAL_CALL
VbaWindowBase::setTop( sal_Int32 _top ) throw (uno::RuntimeException)
{
- setPosSize(m_xModel, _top, css::awt::PosSize::Y);
+ setPosSize( getWindow(), _top, css::awt::PosSize::Y );
}
+
sal_Int32 SAL_CALL
VbaWindowBase::getWidth() throw (uno::RuntimeException)
{
- css::awt::Rectangle aRect = getPosSize(m_xModel);
- return aRect.Width;
+ return getWindow()->getPosSize().Width;
}
void SAL_CALL
VbaWindowBase::setWidth( sal_Int32 _width ) throw (uno::RuntimeException)
{
- setPosSize(m_xModel, _width, css::awt::PosSize::WIDTH);
+ setPosSize( getWindow(), _width, css::awt::PosSize::WIDTH );
}
rtl::OUString&
@@ -177,4 +153,28 @@ VbaWindowBase::getServiceNames()
return aServiceNames;
}
+uno::Reference< frame::XController > VbaWindowBase::getController() throw (css::uno::RuntimeException)
+{
+ return uno::Reference< frame::XController >( m_xController, uno::UNO_SET_THROW );
+}
+
+uno::Reference< awt::XWindow > VbaWindowBase::getWindow() throw (uno::RuntimeException)
+{
+ return uno::Reference< awt::XWindow >( m_xWindow, uno::UNO_SET_THROW );
+}
+
+uno::Reference< awt::XWindow2 > VbaWindowBase::getWindow2() throw (uno::RuntimeException)
+{
+ return uno::Reference< awt::XWindow2 >( getWindow(), uno::UNO_QUERY_THROW );
+}
+
+void VbaWindowBase::construct( const uno::Reference< frame::XController >& xController ) throw (uno::RuntimeException)
+{
+ if( !xController.is() ) throw uno::RuntimeException();
+ uno::Reference< frame::XFrame > xFrame( xController->getFrame(), uno::UNO_SET_THROW );
+ uno::Reference< awt::XWindow > xWindow( xFrame->getContainerWindow(), uno::UNO_SET_THROW );
+ m_xController = xController;
+ m_xWindow = xWindow;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */