summaryrefslogtreecommitdiff
path: root/vbahelper
diff options
context:
space:
mode:
authorDaniel Rentz [dr] <daniel.rentz@oracle.com>2011-03-25 10:40:25 +0100
committerDaniel Rentz [dr] <daniel.rentz@oracle.com>2011-03-25 10:40:25 +0100
commitb46dab973c91c3a94bcda188a9888fef3fd16426 (patch)
treeecf2283bed35cbd42e3fb5fb541194d70179e51d /vbahelper
parent61879c218dd0e6e94884e7c6e06e3c5c18540b4a (diff)
calcvba: #164410# improve VBA compatibility implementation in various areas: Excel symbols, MSForms symbols, document and forms event handling
Diffstat (limited to 'vbahelper')
-rwxr-xr-xvbahelper/Library_msforms.mk13
-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
-rwxr-xr-xvbahelper/inc/vbahelper/vbaeventshelperbase.hxx68
-rw-r--r--vbahelper/inc/vbahelper/vbahelper.hxx121
-rw-r--r--vbahelper/inc/vbahelper/vbawindowbase.hxx37
-rwxr-xr-xvbahelper/inc/vbahelper/weakreference.hxx94
-rw-r--r--vbahelper/prj/build.lst2
-rw-r--r--vbahelper/source/msforms/vbabutton.cxx53
-rw-r--r--vbahelper/source/msforms/vbabutton.hxx15
-rw-r--r--vbahelper/source/msforms/vbacheckbox.cxx9
-rw-r--r--vbahelper/source/msforms/vbacheckbox.hxx5
-rw-r--r--vbahelper/source/msforms/vbacombobox.cxx95
-rw-r--r--vbahelper/source/msforms/vbacombobox.hxx13
-rw-r--r--vbahelper/source/msforms/vbacontrol.cxx117
-rw-r--r--vbahelper/source/msforms/vbacontrol.hxx24
-rw-r--r--vbahelper/source/msforms/vbacontrols.cxx188
-rw-r--r--vbahelper/source/msforms/vbacontrols.hxx27
-rw-r--r--vbahelper/source/msforms/vbaframe.cxx77
-rw-r--r--vbahelper/source/msforms/vbaframe.hxx27
-rw-r--r--vbahelper/source/msforms/vbalabel.cxx7
-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.cxx11
-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.cxx8
-rw-r--r--vbahelper/source/msforms/vbaradiobutton.hxx1
-rw-r--r--vbahelper/source/msforms/vbatextbox.cxx34
-rw-r--r--vbahelper/source/msforms/vbatextbox.hxx5
-rw-r--r--vbahelper/source/msforms/vbatogglebutton.cxx53
-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.cxx333
-rw-r--r--vbahelper/source/vbahelper/vbaapplicationbase.cxx25
-rw-r--r--vbahelper/source/vbahelper/vbacommandbar.cxx9
-rw-r--r--vbahelper/source/vbahelper/vbacommandbarcontrol.cxx72
-rw-r--r--vbahelper/source/vbahelper/vbacommandbarcontrol.hxx11
-rw-r--r--vbahelper/source/vbahelper/vbacommandbarcontrols.cxx27
-rw-r--r--vbahelper/source/vbahelper/vbacommandbarcontrols.hxx19
-rw-r--r--vbahelper/source/vbahelper/vbacommandbarhelper.hxx1
-rw-r--r--vbahelper/source/vbahelper/vbadocumentbase.cxx17
-rwxr-xr-xvbahelper/source/vbahelper/vbaeventshelperbase.cxx247
-rw-r--r--vbahelper/source/vbahelper/vbahelper.cxx411
-rw-r--r--vbahelper/source/vbahelper/vbawindowbase.cxx140
52 files changed, 2265 insertions, 704 deletions
diff --git a/vbahelper/Library_msforms.mk b/vbahelper/Library_msforms.mk
index 3e23c492f32b..58a90a7ccd42 100755
--- a/vbahelper/Library_msforms.mk
+++ b/vbahelper/Library_msforms.mk
@@ -50,17 +50,17 @@ $(eval $(call gb_Library_add_linked_libs,msforms,\
comphelper \
cppu \
cppuhelper \
+ sal \
+ sb \
+ sfx \
svl \
svt \
+ svx \
+ stl \
+ tk \
tl \
- sal \
vbahelper \
- sfx \
- svx \
vcl \
- tk \
- sb \
- stl \
$(gb_STDLIBS) \
))
@@ -79,6 +79,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 722b66d709a1..af6b4089ada8 100755
--- a/vbahelper/Library_vbahelper.mk
+++ b/vbahelper/Library_vbahelper.mk
@@ -50,25 +50,27 @@ $(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 \
stl \
- 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 6d8033aa5b02..385fbf15a625 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 000000000000..ebb5bf8f2b9a
--- /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 6902bc7b5042..10cf0ba6ab70 100644
--- a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx
+++ b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx
@@ -60,7 +60,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 void 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 601d996a5e64..da0fd29267ae 100644
--- a/vbahelper/inc/vbahelper/vbacollectionimpl.hxx
+++ b/vbahelper/inc/vbahelper/vbacollectionimpl.hxx
@@ -88,8 +88,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 2588b7da1720..d1c7320fbfb1 100644
--- a/vbahelper/inc/vbahelper/vbadocumentbase.hxx
+++ b/vbahelper/inc/vbahelper/vbadocumentbase.hxx
@@ -37,6 +37,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 659837535ace..dc554d6a043f 100755
--- a/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx
+++ b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx
@@ -28,20 +28,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 <hash_map>
+#include <map>
+#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
{
@@ -51,15 +57,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(); }
@@ -72,12 +87,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;
};
@@ -85,14 +99,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() );
@@ -124,7 +138,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. */
@@ -133,25 +146,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 ::std::hash_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 22dc9a8f6cc8..bf20541eff1e 100644
--- a/vbahelper/inc/vbahelper/vbahelper.hxx
+++ b/vbahelper/inc/vbahelper/vbahelper.hxx
@@ -63,7 +63,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);
@@ -90,18 +95,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 >& );
@@ -135,14 +154,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 {
@@ -156,20 +182,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);
};
@@ -178,13 +197,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();
};
@@ -195,19 +214,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
@@ -230,8 +269,8 @@ public:
static void exception( css::uno::Exception& ex ) throw( css::script::BasicErrorException );
};
- } // openoffice
-} // org
+ } // vba
+} // ooo
namespace ov = ooo::vba;
diff --git a/vbahelper/inc/vbahelper/vbawindowbase.hxx b/vbahelper/inc/vbahelper/vbawindowbase.hxx
index f42c2a19854e..e9f1d40e4bd4 100644
--- a/vbahelper/inc/vbahelper/vbawindowbase.hxx
+++ b/vbahelper/inc/vbahelper/vbawindowbase.hxx
@@ -24,24 +24,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) ;
@@ -58,6 +64,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 000000000000..661f3bc5d73e
--- /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/prj/build.lst b/vbahelper/prj/build.lst
index 312c9b062233..be2e516de360 100644
--- a/vbahelper/prj/build.lst
+++ b/vbahelper/prj/build.lst
@@ -1,3 +1,3 @@
-vba vbahelper : oovbaapi offuh basic sfx2 svx filter cppuhelper vcl comphelper svtools tools sal LIBXSLT:libxslt NULL
+vba vbahelper : oovbaapi offuh basic sfx2 svx filter cppuhelper vcl comphelper svtools tools sal unotools LIBXSLT:libxslt NULL
vba vbahelper usr1 - all vba_mkout NULL
vba vbahelper\prj nmake - all vba_prj NULL
diff --git a/vbahelper/source/msforms/vbabutton.cxx b/vbahelper/source/msforms/vbabutton.cxx
index 21693128c899..775a05cbb5b5 100644
--- a/vbahelper/source/msforms/vbabutton.cxx
+++ b/vbahelper/source/msforms/vbabutton.cxx
@@ -24,8 +24,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;
@@ -51,6 +52,56 @@ ScVbaButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star
m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
}
+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()
{
diff --git a/vbahelper/source/msforms/vbabutton.hxx b/vbahelper/source/msforms/vbabutton.hxx
index 1c65c293f76c..93a55e1bf73a 100644
--- a/vbahelper/source/msforms/vbabutton.hxx
+++ b/vbahelper/source/msforms/vbabutton.hxx
@@ -27,12 +27,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
{
@@ -41,6 +41,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 e9ea64f772b6..329586cf6b27 100644
--- a/vbahelper/source/msforms/vbacheckbox.cxx
+++ b/vbahelper/source/msforms/vbacheckbox.cxx
@@ -24,9 +24,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;
@@ -83,6 +84,12 @@ ScVbaCheckbox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeExcept
}
m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) );
}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaCheckbox::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
rtl::OUString&
ScVbaCheckbox::getServiceImplName()
{
diff --git a/vbahelper/source/msforms/vbacheckbox.hxx b/vbahelper/source/msforms/vbacheckbox.hxx
index 34d0828e0c66..59e4d7e75e49 100644
--- a/vbahelper/source/msforms/vbacheckbox.hxx
+++ b/vbahelper/source/msforms/vbacheckbox.hxx
@@ -27,12 +27,12 @@
#ifndef SC_VBA_CHECKBOX_HXX
#define SC_VBA_CHECKBOX_HXX
#include <cppuhelper/implbase2.hxx>
-#include <ooo/vba/msforms/XRadioButton.hpp>
+#include <ooo/vba/msforms/XCheckBox.hpp>
#include "vbacontrol.hxx"
#include <vbahelper/vbahelper.hxx>
-typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XRadioButton, css::script::XDefaultProperty > CheckBoxImpl_BASE;
+typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XCheckBox, css::script::XDefaultProperty > CheckBoxImpl_BASE;
class ScVbaCheckbox : public CheckBoxImpl_BASE
{
@@ -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 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::createFromAscii("Value"); }
//XHelperInterface
diff --git a/vbahelper/source/msforms/vbacombobox.cxx b/vbahelper/source/msforms/vbacombobox.cxx
index 0b5f1af30bb7..b0d1680e6101 100644
--- a/vbahelper/source/msforms/vbacombobox.cxx
+++ b/vbahelper/source/msforms/vbacombobox.cxx
@@ -24,8 +24,15 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
#include "vbacombobox.hxx"
-#include <vector>
+#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;
@@ -41,9 +48,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
@@ -103,7 +118,8 @@ ScVbaComboBox::getListIndex() throw (uno::RuntimeException)
void SAL_CALL
ScVbaComboBox::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
{
- m_xProps->setPropertyValue( sSourceName, _value );
+ // booleans are converted to uppercase strings
+ m_xProps->setPropertyValue( sSourceName, uno::Any( extractStringFromAny( _value, ::rtl::OUString(), true ) ) );
}
// see Value
@@ -131,22 +147,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)
@@ -158,7 +174,66 @@ 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)
+{
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaComboBox::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
rtl::OUString&
ScVbaComboBox::getServiceImplName()
diff --git a/vbahelper/source/msforms/vbacombobox.hxx b/vbahelper/source/msforms/vbacombobox.hxx
index 28215d16dcd7..922f6f63ca62 100644
--- a/vbahelper/source/msforms/vbacombobox.hxx
+++ b/vbahelper/source/msforms/vbacombobox.hxx
@@ -58,6 +58,19 @@ 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 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 ed9f83a7c647..780191885049 100644
--- a/vbahelper/source/msforms/vbacontrol.cxx
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -43,8 +43,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"
@@ -397,99 +397,104 @@ void SAL_CALL ScVbaControl::setTag( const ::rtl::OUString& aTag )
m_aControlTag = aTag;
}
-
-//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
+ 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:
- 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::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::createFromAscii(
- "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") ) ) )
- 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::createFromAscii("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&
@@ -520,7 +525,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
@@ -528,27 +532,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 247eabfe95e8..e421f919b6a4 100644
--- a/vbahelper/source/msforms/vbacontrol.hxx
+++ b/vbahelper/source/msforms/vbacontrol.hxx
@@ -93,6 +93,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 );
//XHelperInterface
@@ -104,15 +106,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 8d01687ef905..7411f7ad9463 100644
--- a/vbahelper/source/msforms/vbacontrols.cxx
+++ b/vbahelper/source/msforms/vbacontrols.cxx
@@ -27,13 +27,18 @@
#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 <ooo/vba/XControlProvider.hpp>
#include <hash_map>
using namespace com::sun::star;
@@ -153,11 +158,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)
{
@@ -168,14 +190,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();
@@ -190,17 +210,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;
@@ -210,15 +237,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
@@ -261,23 +282,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 );
@@ -299,6 +414,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();
@@ -376,21 +496,5 @@ 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" )
diff --git a/vbahelper/source/msforms/vbacontrols.hxx b/vbahelper/source/msforms/vbacontrols.hxx
index a72506609531..4b4838a45a8e 100644
--- a/vbahelper/source/msforms/vbacontrols.hxx
+++ b/vbahelper/source/msforms/vbacontrols.hxx
@@ -38,19 +38,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);
@@ -59,6 +57,15 @@ 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
diff --git a/vbahelper/source/msforms/vbaframe.cxx b/vbahelper/source/msforms/vbaframe.cxx
index c470ee0097e4..4a1fe6a58b49 100644
--- a/vbahelper/source/msforms/vbaframe.cxx
+++ b/vbahelper/source/msforms/vbaframe.cxx
@@ -24,62 +24,83 @@
* 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)
+sal_Int32 SAL_CALL ScVbaFrame::getSpecialEffect() throw (uno::RuntimeException)
{
- return uno::makeAny( getCaption() );
+ return msforms::fmSpecialEffect::fmSpecialEffectEtched;
}
-void SAL_CALL
-ScVbaFrame::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException)
+void SAL_CALL ScVbaFrame::setSpecialEffect( sal_Int32 /*nSpecialEffect*/ ) throw (uno::RuntimeException)
{
- rtl::OUString sCaption;
- _value >>= sCaption;
- setCaption( sCaption );
}
-rtl::OUString&
-ScVbaFrame::getServiceImplName()
+sal_Int32 SAL_CALL ScVbaFrame::getBorderStyle() throw (uno::RuntimeException)
{
- static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaFrame") );
- return sImplName;
+ return msforms::fmBorderStyle::fmBorderStyleNone;
}
-uno::Sequence< rtl::OUString >
-ScVbaFrame::getServiceNames()
+void SAL_CALL ScVbaFrame::setBorderStyle( sal_Int32 /*nBorderStyle*/ ) 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;
}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaFrame::getFont() throw (uno::RuntimeException)
+{
+ 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" )
diff --git a/vbahelper/source/msforms/vbaframe.hxx b/vbahelper/source/msforms/vbaframe.hxx
index 567e58b57272..d76f31230bba 100644
--- a/vbahelper/source/msforms/vbaframe.hxx
+++ b/vbahelper/source/msforms/vbaframe.hxx
@@ -27,24 +27,39 @@
#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 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 9bf7a7e001bf..d5aa1176e3d3 100644
--- a/vbahelper/source/msforms/vbalabel.cxx
+++ b/vbahelper/source/msforms/vbalabel.cxx
@@ -24,8 +24,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;
@@ -64,6 +65,10 @@ ScVbaLabel::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::Run
setCaption( sCaption );
}
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaLabel::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
rtl::OUString&
ScVbaLabel::getServiceImplName()
diff --git a/vbahelper/source/msforms/vbalabel.hxx b/vbahelper/source/msforms/vbalabel.hxx
index af3bc074c54d..2dcee186d58b 100644
--- a/vbahelper/source/msforms/vbalabel.hxx
+++ b/vbahelper/source/msforms/vbalabel.hxx
@@ -44,6 +44,7 @@ public:
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 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 17f8c8341588..8829c8ae7256 100644
--- a/vbahelper/source/msforms/vbalistbox.cxx
+++ b/vbahelper/source/msforms/vbalistbox.cxx
@@ -24,12 +24,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;
@@ -267,6 +267,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 3d0797e2b7b2..7dbda1837cb0 100644
--- a/vbahelper/source/msforms/vbalistbox.hxx
+++ b/vbahelper/source/msforms/vbalistbox.hxx
@@ -60,9 +60,10 @@ public:
virtual void SAL_CALL setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException);
virtual sal_Bool SAL_CALL getMultiSelect() throw (css::uno::RuntimeException);
virtual void SAL_CALL setMultiSelect( sal_Bool _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 b6587c9b2367..78590f0fd85b 100644
--- a/vbahelper/source/msforms/vbamultipage.cxx
+++ b/vbahelper/source/msforms/vbamultipage.cxx
@@ -68,9 +68,16 @@ 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 );
+ mxDialogProps.set( xDialog->getModel(), uno::UNO_QUERY_THROW );
// set dialog step to value of multipage pseudo model
setValue(getValue());
}
diff --git a/vbahelper/source/msforms/vbamultipage.hxx b/vbahelper/source/msforms/vbamultipage.hxx
index 4a54525cf95f..328a71b61592 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 000000000000..f487b4e6919c
--- /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 000000000000..d59d5caa139c
--- /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 94d12c5823ba..12ee1ad8ae41 100644
--- a/vbahelper/source/msforms/vbaradiobutton.cxx
+++ b/vbahelper/source/msforms/vbaradiobutton.cxx
@@ -24,8 +24,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;
@@ -84,6 +85,11 @@ ScVbaRadioButton::setValue( const uno::Any& _value ) throw (uno::RuntimeExceptio
m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) );
}
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaRadioButton::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
rtl::OUString&
ScVbaRadioButton::getServiceImplName()
{
diff --git a/vbahelper/source/msforms/vbaradiobutton.hxx b/vbahelper/source/msforms/vbaradiobutton.hxx
index a0de21ae5d0e..3da00eb0765e 100644
--- a/vbahelper/source/msforms/vbaradiobutton.hxx
+++ b/vbahelper/source/msforms/vbaradiobutton.hxx
@@ -42,6 +42,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 2d83d41d77c3..c9e4381f449a 100644
--- a/vbahelper/source/msforms/vbatextbox.cxx
+++ b/vbahelper/source/msforms/vbatextbox.cxx
@@ -24,16 +24,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 )
{
}
@@ -48,7 +48,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 );
}
@@ -114,6 +115,29 @@ ScVbaTextBox::setMultiline( sal_Bool _multiline ) throw (css::uno::RuntimeExcept
(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) ), aValue);
}
+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)
+{
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaTextBox::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
rtl::OUString&
ScVbaTextBox::getServiceImplName()
{
diff --git a/vbahelper/source/msforms/vbatextbox.hxx b/vbahelper/source/msforms/vbatextbox.hxx
index 0553e047488e..fb791db149e4 100644
--- a/vbahelper/source/msforms/vbatextbox.hxx
+++ b/vbahelper/source/msforms/vbatextbox.hxx
@@ -47,6 +47,11 @@ 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 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::createFromAscii("Value"); }
//XHelperInterface
diff --git a/vbahelper/source/msforms/vbatogglebutton.cxx b/vbahelper/source/msforms/vbatogglebutton.cxx
index 071651ff8a36..d1a3b40d6eb7 100644
--- a/vbahelper/source/msforms/vbatogglebutton.cxx
+++ b/vbahelper/source/msforms/vbatogglebutton.cxx
@@ -24,8 +24,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;
@@ -79,6 +80,56 @@ 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&
ScVbaToggleButton::getServiceImplName()
{
diff --git a/vbahelper/source/msforms/vbatogglebutton.hxx b/vbahelper/source/msforms/vbatogglebutton.hxx
index bfdd68d09642..d2bf4c6b7f17 100644
--- a/vbahelper/source/msforms/vbatogglebutton.hxx
+++ b/vbahelper/source/msforms/vbatogglebutton.hxx
@@ -43,9 +43,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 16bc97babd7d..3eb799205389 100644
--- a/vbahelper/source/msforms/vbauserform.cxx
+++ b/vbahelper/source/msforms/vbauserform.cxx
@@ -54,7 +54,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 ) );
+ setGeometryHelper( new UserFormGeometryHelper( xContext, xControl, 0.0, 0.0 ) );
}
ScVbaUserForm::~ScVbaUserForm()
@@ -105,18 +105,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)
{
@@ -202,13 +222,7 @@ ScVbaUserForm::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::Un
uno::Reference< awt::XControlContainer > xContainer( m_xDialog, uno::UNO_QUERY_THROW );
uno::Reference< awt::XControl > xControl = 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 ) );
- aResult = uno::makeAny( xVBAControl );
- }
+ aResult <<= ScVbaControlFactory::createUserformControl( mxContext, xControl, xDialogControl, m_xModel, mpGeometryHelper->getOffsetX(), mpGeometryHelper->getOffsetY() );
}
return aResult;
@@ -225,7 +239,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 71e8b4f62aa9..1777a979b9f2 100644
--- a/vbahelper/source/msforms/vbauserform.hxx
+++ b/vbahelper/source/msforms/vbauserform.hxx
@@ -50,18 +50,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 000000000000..7a99aabecdf8
--- /dev/null
+++ b/vbahelper/source/vbahelper/collectionbase.cxx
@@ -0,0 +1,333 @@
+/*************************************************************************
+ *
+ * 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< sal_Int32 >() )
+ return getItemByIndex( rIndex.get< sal_Int32 >() );
+ if( rIndex.has< ::rtl::OUString >() )
+ return getItemByName( rIndex.get< ::rtl::OUString >() );
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid item index." ) ), 0 );
+}
+
+// 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 54d280094f2c..6f782b629f40 100644
--- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx
+++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx
@@ -387,9 +387,9 @@ 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 );
@@ -401,25 +401,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 1e8d21d53583..11cbacb79894 100644
--- a/vbahelper/source/vbahelper/vbacommandbar.cxx
+++ b/vbahelper/source/vbahelper/vbacommandbar.cxx
@@ -154,14 +154,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::createFromAscii("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 157d54eca7d5..d57bc00644a5 100644
--- a/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
+++ b/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
@@ -91,50 +91,37 @@ 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::createFromAscii("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::createFromAscii("IsVisible") );
+ uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_ISVISIBLE ) );
if( aValue.hasValue() )
{
- setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("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;
}
@@ -142,30 +129,16 @@ ScVbaCommandBarControl::getEnabled() throw (uno::RuntimeException)
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 );
}
}
@@ -206,14 +179,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() );
@@ -241,12 +207,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&
@@ -268,12 +233,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 a165f8e1cccd..5066ba75eea0 100644
--- a/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx
+++ b/vbahelper/source/vbahelper/vbacommandbarcontrol.hxx
@@ -43,10 +43,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;
@@ -87,7 +86,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)
{
@@ -102,7 +101,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 634b4a0e9395..da218d007736 100644
--- a/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
+++ b/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
@@ -55,14 +55,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::createFromAscii( ITEM_DESCRIPTOR_COMMANDURL );
aProps[0].Value <<= sCommandURL;
@@ -74,6 +80,10 @@ uno::Sequence< beans::PropertyValue > ScVbaCommandBarControls::CreateMenuItemDat
aProps[3].Value <<= nType;
aProps[4].Name = rtl::OUString::createFromAscii( 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;
}
@@ -124,9 +134,9 @@ ScVbaCommandBarControls::createCollectionObject( const uno::Any& aSource )
getPropertyValue( aProps, rtl::OUString::createFromAscii( 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 ) );
}
@@ -202,7 +212,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
{
@@ -217,12 +227,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 0b35773660d1..79a4a8c5a5fe 100644
--- a/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx
+++ b/vbahelper/source/vbahelper/vbacommandbarcontrols.hxx
@@ -38,17 +38,22 @@ 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 );
+ 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
diff --git a/vbahelper/source/vbahelper/vbacommandbarhelper.hxx b/vbahelper/source/vbahelper/vbacommandbarhelper.hxx
index 1fa41d7141b3..93c6e5f55457 100644
--- a/vbahelper/source/vbahelper/vbacommandbarhelper.hxx
+++ b/vbahelper/source/vbahelper/vbacommandbarhelper.hxx
@@ -47,6 +47,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 087e7188c8f6..b3053aa3d759 100644
--- a/vbahelper/source/vbahelper/vbadocumentbase.cxx
+++ b/vbahelper/source/vbahelper/vbadocumentbase.cxx
@@ -38,6 +38,7 @@
#include <com/sun/star/frame/XFrame.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>
@@ -265,20 +266,22 @@ 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::Sequence< uno::Any > aArgs( 2 );
- aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this );
- aArgs[ 1 ] <<= getModel();
+ uno::Reference< XApplicationBase > xApp( Application(), uno::UNO_QUERY_THROW );
+ uno::Reference< XInterface > xVBE( xApp->getVBE(), uno::UNO_QUERY_THROW );
+ uno::Sequence< uno::Any > aArgs( 3 );
+ aArgs[ 0 ] <<= xVBE; // the VBE
+ aArgs[ 1 ] <<= xVBE; // parent of a VBA project is the VBE
+ aArgs[ 2 ] <<= 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(
+ mxVBProject = xServiceManager->createInstanceWithArgumentsAndContext(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBProject" ) ), aArgs, mxContext );
- return uno::Any( xVBProjects );
}
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 8000a7cdf66e..5e2cf949c473 100755
--- a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
+++ b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
@@ -26,34 +26,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 )
@@ -65,8 +71,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
@@ -79,9 +85,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()
@@ -98,15 +104,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
@@ -120,96 +126,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 cfce8b49e3d1..827d387f031d 100644
--- a/vbahelper/source/vbahelper/vbahelper.cxx
+++ b/vbahelper/source/vbahelper/vbahelper.cxx
@@ -628,82 +628,85 @@ 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_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 );
}
-rtl::OUString getAnyAsString( const uno::Any& pvargItem ) throw ( uno::RuntimeException )
+bool extractBoolFromAny( const uno::Any& rAny, bool bDefault ) throw (uno::RuntimeException)
+{
+ return rAny.hasValue() ? extractBoolFromAny( rAny ) : bDefault;
+}
+
+::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::createFromAscii( "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 );
}
@@ -840,7 +843,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 )
@@ -854,12 +857,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( fPixels/fConvertFactor );
@@ -994,128 +997,176 @@ sal_Bool setPropertyValue( uno::Sequence< beans::PropertyValue >& aProp, const r
// ====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( 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, 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 implGetSize( false, true );
+}
- return mxWindow->getPosSize().Width;
+void UserFormGeometryHelper::setWidth( double fWidth )
+{
+ implSetSize( fWidth, false, true );
}
-//---------------------------------------------
-void UserFormGeometryHelper::setWidth( double nWidth )
+double UserFormGeometryHelper::getHeight() const
{
- sal_Int64 nNewWidth = nWidth;
+ return implGetSize( true, 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 = nDecor - nWidth; // avoid negative size
- nNewWidth = nWidth + nUnDecor - nDecor;
- }
- }
- }
+void UserFormGeometryHelper::setHeight( double fHeight )
+{
+ implSetSize( fHeight, true, true );
+}
- mxWindow->setPosSize( 0, 0, nNewWidth, 0, awt::PosSize::WIDTH );
+double UserFormGeometryHelper::getInnerWidth() const
+{
+ return implGetSize( false, false );
}
-//---------------------------------------------
-double UserFormGeometryHelper::getHeight()
+void UserFormGeometryHelper::setInnerWidth( double fWidth )
+{
+ implSetSize( fWidth, false, false );
+}
+
+double UserFormGeometryHelper::getInnerHeight() const
{
- if ( mbDialog )
+ return implGetSize( true, false );
+}
+
+void UserFormGeometryHelper::setInnerHeight( double fHeight )
+{
+ implSetSize( fHeight, true, false );
+}
+
+double UserFormGeometryHelper::getOffsetX() const
+{
+ return mfOffsetX;
+}
+
+double UserFormGeometryHelper::getOffsetY() const
+{
+ return mfOffsetY;
+}
+
+// ----------------------------------------------------------------------------
+
+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" ) );
+
+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);
+}
+
+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 );
+
+ /* 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 )
{
- const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow );
- if ( pWindow )
+ if( const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow ) )
{
- // get the size with decoration
- Rectangle aResult = pWindow->GetWindowExtentsRelative( NULL );
- return aResult.getHeight();
+ Rectangle aOuterRect = pWindow->GetWindowExtentsRelative( NULL );
+ aSizePixel = awt::Size( aOuterRect.getWidth(), aOuterRect.getHeight() );
}
}
- return mxWindow->getPosSize().Height;
+ // pixel to VBA points
+ awt::Size aSizePoint = mxUnitConv->convertSizeToLogic( aSizePixel, util::MeasureUnit::POINT );
+ return bHeight ? aSizePoint.Height : aSizePoint.Width;
}
-//---------------------------------------------
-void UserFormGeometryHelper::setHeight( double nHeight )
+void UserFormGeometryHelper::implSetSize( double fSize, bool bHeight, bool bOuter )
{
- sal_Int64 nNewHeight = nHeight;
- if ( mbDialog )
+ // 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 );
+
+ /* 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 )
{
- const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow );
- if ( pWindow )
+ if( const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow ) )
{
- // set the size with decoration
- Rectangle aRDecor = pWindow->GetWindowExtentsRelative( NULL );
- if ( !aRDecor.IsEmpty() )
+ Rectangle aOuterRect = pWindow->GetWindowExtentsRelative( NULL );
+ if( !aOuterRect.IsEmpty() )
{
- sal_Int64 nDecor = aRDecor.getHeight();
- sal_Int64 nUnDecor = mxWindow->getPosSize().Height;
- if ( nHeight < nDecor - nUnDecor )
- nUnDecor = nDecor - nHeight; // avoid negative size
- nNewHeight = nHeight + nUnDecor - nDecor;
+ 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 );
}
}
}
- mxWindow->setPosSize( 0, 0, 0, nNewHeight, awt::PosSize::HEIGHT );
+ awt::Size aSizeAppFont = mxUnitConv->convertSizeToLogic( aSizePixel, util::MeasureUnit::APPFONT );
+ mxModelProps->setPropertyValue( bHeight ? saHeightName : saWidthName, uno::Any( bHeight ? aSizeAppFont.Height : aSizeAppFont.Width ) );
}
-// ============
+// ============================================================================
- double ConcreteXShapeGeometryAttributes::getLeft()
+ double ConcreteXShapeGeometryAttributes::getLeft() const
{
return m_pShapeHelper->getLeft();
}
@@ -1123,7 +1174,7 @@ void UserFormGeometryHelper::setHeight( double nHeight )
{
m_pShapeHelper->setLeft( nLeft );
}
- double ConcreteXShapeGeometryAttributes::getTop()
+ double ConcreteXShapeGeometryAttributes::getTop() const
{
return m_pShapeHelper->getTop();
}
@@ -1132,7 +1183,7 @@ void UserFormGeometryHelper::setHeight( double nHeight )
m_pShapeHelper->setTop( nTop );
}
- double ConcreteXShapeGeometryAttributes::getHeight()
+ double ConcreteXShapeGeometryAttributes::getHeight() const
{
return m_pShapeHelper->getHeight();
}
@@ -1140,7 +1191,7 @@ void UserFormGeometryHelper::setHeight( double nHeight )
{
m_pShapeHelper->setHeight( nHeight );
}
- double ConcreteXShapeGeometryAttributes::getWidth()
+ double ConcreteXShapeGeometryAttributes::getWidth() const
{
return m_pShapeHelper->getWidth();
}
@@ -1156,7 +1207,7 @@ void UserFormGeometryHelper::setHeight( double nHeight )
throw css::uno::RuntimeException( rtl::OUString::createFromAscii("No valid shape for helper"), css::uno::Reference< css::uno::XInterface >() );
}
- double ShapeHelper::getHeight()
+ double ShapeHelper::getHeight() const
{
return Millimeter::getInPoints(xShape->getSize().Height);
}
@@ -1177,7 +1228,7 @@ void UserFormGeometryHelper::setHeight( double nHeight )
}
- double ShapeHelper::getWidth()
+ double ShapeHelper::getWidth() const
{
return Millimeter::getInPoints(xShape->getSize().Width);
}
@@ -1197,7 +1248,7 @@ void UserFormGeometryHelper::setHeight( double nHeight )
}
- double ShapeHelper::getLeft()
+ double ShapeHelper::getLeft() const
{
return Millimeter::getInPoints(xShape->getPosition().X);
}
@@ -1211,7 +1262,7 @@ void UserFormGeometryHelper::setHeight( double nHeight )
}
- double ShapeHelper::getTop()
+ double ShapeHelper::getTop() const
{
return Millimeter::getInPoints(xShape->getPosition().Y);
}
@@ -1279,38 +1330,50 @@ void UserFormGeometryHelper::setHeight( double nHeight )
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;
- }
+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 ) );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ 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()));
- }
- if ( !pFoundShell )
- throw uno::RuntimeException();
- return pFoundShell;
- }
+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()));
+ }
+ if ( !pFoundShell )
+ throw uno::RuntimeException();
+ return pFoundShell;
+}
} // openoffice
} //org
diff --git a/vbahelper/source/vbahelper/vbawindowbase.cxx b/vbahelper/source/vbahelper/vbawindowbase.cxx
index 54546a394690..132caef8b5e1 100644
--- a/vbahelper/source/vbahelper/vbawindowbase.cxx
+++ b/vbahelper/source/vbahelper/vbawindowbase.cxx
@@ -24,137 +24,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)
-{
- 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 );
- }
-}
-
-css::awt::Rectangle getPosSize( const uno::Reference< frame::XModel >& xModel )
+VbaWindowBase::setVisible( sal_Bool _visible ) throw (uno::RuntimeException)
{
- 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() )
- {
- aRect = xWindow->getPosSize();
- }
- return aRect;
+ getWindow2()->setVisible( _visible );
}
-void setPosSize( const uno::Reference< frame::XModel >& xModel, sal_Int32 nValue, sal_uInt16 nFlag )
+void setPosSize( const uno::Reference< awt::XWindow >& xWindow, sal_Int32 nValue, sal_Int16 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 )
{
- 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;
- }
+ 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
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&
@@ -175,3 +151,27 @@ 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;
+}