summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2009-02-20 10:24:14 +0000
committerOliver Bolte <obo@openoffice.org>2009-02-20 10:24:14 +0000
commit74e4b152bbe46cf55cec4da21b9365363ec2fa8d (patch)
tree6f6053f670377f1a22d6367266c3e8ad2dc6af2f
parentc307957e719ddc275da8baccbc9d64a296921c7f (diff)
#i99305#,#i99132# remove DOS lineends, remove solenv/unxmacxp/inc/poll.h
-rw-r--r--sc/source/filter/inc/filt_pch.hxx648
-rw-r--r--sc/source/filter/inc/xlformula.hxx954
-rw-r--r--sc/source/filter/xml/XMLStylesExportHelper.cxx2490
-rw-r--r--sc/source/filter/xml/xmlcvali.cxx1576
-rw-r--r--sc/source/filter/xml/xmlnexpi.cxx524
-rw-r--r--sc/source/ui/formdlg/dwfunctr.cxx2370
-rw-r--r--sc/source/ui/formdlg/formdlgs.src64
-rw-r--r--sc/source/ui/miscdlgs/crnrdlg.cxx2350
-rw-r--r--sc/source/ui/miscdlgs/optsolver.cxx2138
-rw-r--r--sc/source/ui/miscdlgs/solvrdlg.cxx632
-rw-r--r--sc/source/ui/miscdlgs/tabopdlg.cxx748
-rw-r--r--sc/source/ui/namedlg/namedlg.cxx1304
-rw-r--r--sc/source/ui/pagedlg/areasdlg.cxx1818
13 files changed, 8808 insertions, 8808 deletions
diff --git a/sc/source/filter/inc/filt_pch.hxx b/sc/source/filter/inc/filt_pch.hxx
index 4f576c861272..b0ef236519a3 100644
--- a/sc/source/filter/inc/filt_pch.hxx
+++ b/sc/source/filter/inc/filt_pch.hxx
@@ -1,324 +1,324 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: filt_pch.hxx,v $
- * $Revision: 1.13 $
- *
- * 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.
- *
- ************************************************************************/
-
-// ItemID-Defines etc. muessen immer ganz vorne stehen
-
-#include "scitems.hxx"
-
-
-#define _ZFORLIST_DECLARE_TABLE
-
-#define SC_PROGRESS_CXX
-
-// ab hier automatisch per makepch generiert
-// folgende duerfen nicht aufgenommen werden:
-// ...
-
-#include <tools/solar.h>
-#include <tools/string.hxx>
-#include <rtl/textenc.h>
-#include <sal/types.h>
-#include <sal/config.h>
-#include <rtl/textcvt.h>
-#include <rtl/string.hxx>
-#include <rtl/string.h>
-#include <rtl/ustring.h>
-#include <rtl/memory.h>
-#include <rtl/ustring.hxx>
-#include <rtl/locale.hxx>
-#include <rtl/locale.h>
-#include <tools/contnr.hxx>
-#include <i18npool/lang.h>
-#include <tools/list.hxx>
-#include <global.hxx>
-#include <tools/stream.hxx>
-#include <tools/errinf.hxx>
-#include <tools/rtti.hxx>
-#include <tools/errcode.hxx>
-#include <tools/ref.hxx>
-#include <tools/link.hxx>
-#include <tools/debug.hxx>
-#include <tools/time.hxx>
-#include <tools/date.hxx>
-#include <svtools/svarray.hxx>
-#include <vcl/sv.h>
-#include <vcl/timer.hxx>
-#include <tools/gen.hxx>
-#include <tools/color.hxx>
-#include <tools/color.hxx>
-#include <filter.hxx>
-#include <rangelst.hxx>
-#include <osl/mutex.h>
-#include <com/sun/star/uno/Any.hxx>
-#include <com/sun/star/uno/Any.h>
-#include <cppu/macros.hxx>
-#include <uno/lbnames.h>
-#include <uno/any2.h>
-#include <uno/data.h>
-#include <typelib/typedescription.h>
-#include <typelib/uik.h>
-#include <typelib/typeclass.h>
-#include <com/sun/star/uno/Type.h>
-#include <com/sun/star/uno/TypeClass.hdl>
-#include <com/sun/star/uno/Type.hxx>
-#include <osl/mutex.hxx>
-#include <com/sun/star/uno/genfunc.hxx>
-#include <com/sun/star/uno/genfunc.h>
-#include <com/sun/star/uno/XInterface.hpp>
-#include <com/sun/star/uno/XInterface.hdl>
-#include <com/sun/star/uno/Reference.h>
-#include <com/sun/star/uno/RuntimeException.hdl>
-#include <com/sun/star/uno/Exception.hdl>
-#include <com/sun/star/uno/Reference.hxx>
-#include <com/sun/star/uno/RuntimeException.hpp>
-#include <com/sun/star/uno/Exception.hpp>
-#include <svtools/hint.hxx>
-#include <svtools/poolitem.hxx>
-#include <document.hxx>
-#include <vcl/prntypes.hxx>
-#include <table.hxx>
-#include <column.hxx>
-#include <markarr.hxx>
-#include <root.hxx>
-#include <flttypes.hxx>
-#include <svtools/solar.hrc>
-#include <sfx2/sfxsids.hrc>
-#include <svtools/cntwids.hrc>
-#include <sfx2/cntids.hrc>
-#include <tools/mempool.hxx>
-#include <compiler.hxx>
-#include <formula/compiler.hrc>
-#include <sfx2/sfx.hrc>
-#include <scitems.hxx>
-#include <svx/svxids.hrc>
-#include <svtools/itemset.hxx>
-#include <svtools/memberid.hrc>
-#include <tools/table.hxx>
-#include <flttools.hxx>
-#include <vcl/vclenum.hxx>
-#include <tools/resid.hxx>
-#include <tools/rc.hxx>
-#include <tools/resmgr.hxx>
-#include <tools/fract.hxx>
-#include <vcl/bitmap.hxx>
-#include <vcl/mapmod.hxx>
-#include <vcl/mapunit.hxx>
-#include <vcl/region.hxx>
-#include <svtools/lstner.hxx>
-#include <patattr.hxx>
-#include <vcl/font.hxx>
-#include <svtools/cenumitm.hxx>
-#include <svtools/eitem.hxx>
-#include <svtools/intitem.hxx>
-#include <svtools/cintitem.hxx>
-#include <svtools/brdcst.hxx>
-#include <sot/sotref.hxx>
-#include <tools/globname.hxx>
-#include <sot/factory.hxx>
-#include <sot/object.hxx>
-#include <sot/sotdata.hxx>
-#include <vcl/bitmapex.hxx>
-#include <vcl/alpha.hxx>
-#include <vcl/gdimtf.hxx>
-#include <tools/unqidx.hxx>
-#include <vcl/graph.hxx>
-#include <vcl/animate.hxx>
-#include <vcl/graph.h>
-#include <vcl/gfxlink.hxx>
-#include <rsc/rscsfx.hxx>
-#include <vcl/wall.hxx>
-#include <vcl/settings.hxx>
-#include <vcl/accel.hxx>
-#include <vcl/keycod.hxx>
-#include <vcl/keycodes.hxx>
-#include <namebuff.hxx>
-#include <tools/shl.hxx>
-#include <tools/pstm.hxx>
-#include <svx/fhgtitem.hxx>
-#include <vos/types.hxx>
-#include <vos/object.hxx>
-#include <vos/macros.hxx>
-#include <tools/unqid.hxx>
-#include <com/sun/star/uno/Sequence.h>
-#include <uno/sequence2.h>
-#include <com/sun/star/uno/Sequence.hxx>
-#include <attrib.hxx>
-#include <svtools/zforlist.hxx>
-#include <svx/fontitem.hxx>
-#include <com/sun/star/lang/XEventListener.hpp>
-#include <com/sun/star/lang/XEventListener.hdl>
-#include <com/sun/star/lang/EventObject.hdl>
-#include <com/sun/star/lang/EventObject.hpp>
-#include <vcl/outdev.hxx>
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/beans/PropertyValue.hdl>
-#include <com/sun/star/beans/PropertyState.hdl>
-#include <com/sun/star/beans/PropertyState.hpp>
-#include <collect.hxx>
-#include <vcl/window.hxx>
-#include <vcl/pointr.hxx>
-#include <vcl/ptrstyle.hxx>
-#include <vcl/wintypes.hxx>
-#include <vcl/inputctx.hxx>
-#include <vcl/event.hxx>
-#include <tools/ownlist.hxx>
-#include <vcl/cmdevt.hxx>
-#include <vcl/vclenum.hxx>
-#include <cell.hxx>
-#include <osl/interlck.h>
-#include <sfx2/sfxuno.hxx>
-#include <colrowst.hxx>
-#include <com/sun/star/util/URL.hpp>
-#include <com/sun/star/util/URL.hdl>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hdl>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-#include <com/sun/star/lang/XSingleServiceFactory.hdl>
-#include <com/sun/star/lang/XTypeProvider.hpp>
-#include <com/sun/star/lang/XTypeProvider.hdl>
-#include <cppuhelper/typeprovider.hxx>
-#include <rtl/uuid.h>
-#include <cppuhelper/queryinterface.hxx>
-#include <cppuhelper/factory.hxx>
-#include <uno/dispatcher.h>
-#include <com/sun/star/registry/XRegistryKey.hpp>
-#include <com/sun/star/registry/XRegistryKey.hdl>
-#include <com/sun/star/registry/InvalidRegistryException.hdl>
-#include <com/sun/star/registry/InvalidValueException.hdl>
-#include <com/sun/star/registry/RegistryKeyType.hdl>
-#include <com/sun/star/registry/RegistryValueType.hdl>
-#include <com/sun/star/registry/InvalidRegistryException.hpp>
-#include <com/sun/star/registry/InvalidValueException.hpp>
-#include <com/sun/star/registry/RegistryKeyType.hpp>
-#include <com/sun/star/registry/RegistryValueType.hpp>
-#include <sot/storage.hxx>
-#include <tools/datetime.hxx>
-#include <osl/thread.h>
-#include <imp_op.hxx>
-#include <otlnbuff.hxx>
-#include <tokstack.hxx>
-#include <com/sun/star/container/NoSuchElementException.hdl>
-#include <com/sun/star/container/NoSuchElementException.hpp>
-#include <vcl/svapp.hxx>
-#include <vos/thread.hxx>
-#include <vos/runnable.hxx>
-#include <vos/refernce.hxx>
-#include <vcl/apptypes.hxx>
-#include <svx/editdata.hxx>
-#include <svx/editeng.hxx>
-#include <com/sun/star/lang/WrappedTargetException.hdl>
-#include <com/sun/star/lang/WrappedTargetException.hpp>
-#include <sfx2/shell.hxx>
-#include <tools/stack.hxx>
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/lang/XComponent.hdl>
-#include <svx/svxenum.hxx>
-#include <formel.hxx>
-#include <com/sun/star/container/XElementAccess.hdl>
-#include <com/sun/star/container/XElementAccess.hpp>
-#include <svtools/itempool.hxx>
-#include <svx/eeitem.hxx>
-#include <rangenam.hxx>
-#include <vcl/syswin.hxx>
-#include <svtools/smplhint.hxx>
-#include <fontbuff.hxx>
-#include <vcl/ctrl.hxx>
-#include <vcl/field.hxx>
-#include <vcl/spinfld.hxx>
-#include <vcl/edit.hxx>
-#include <vcl/menu.hxx>
-#include <vcl/combobox.hxx>
-#include <vcl/combobox.h>
-#include <vcl/fldunit.hxx>
-#include <com/sun/star/frame/XFrame.hpp>
-#include <com/sun/star/frame/XFrame.hdl>
-#include <com/sun/star/awt/XWindow.hpp>
-#include <com/sun/star/awt/XWindow.hdl>
-#include <com/sun/star/awt/Rectangle.hdl>
-#include <com/sun/star/awt/Rectangle.hpp>
-#include <com/sun/star/awt/XFocusListener.hpp>
-#include <com/sun/star/awt/XFocusListener.hdl>
-#include <com/sun/star/awt/FocusEvent.hdl>
-#include <com/sun/star/awt/FocusEvent.hpp>
-#include <com/sun/star/awt/XKeyListener.hpp>
-#include <com/sun/star/awt/XKeyListener.hdl>
-#include <com/sun/star/awt/KeyEvent.hdl>
-#include <com/sun/star/awt/InputEvent.hdl>
-#include <com/sun/star/awt/KeyEvent.hpp>
-#include <com/sun/star/awt/InputEvent.hpp>
-#include <com/sun/star/awt/XMouseListener.hpp>
-#include <com/sun/star/awt/XMouseListener.hdl>
-#include <com/sun/star/awt/MouseEvent.hdl>
-#include <com/sun/star/awt/MouseEvent.hpp>
-#include <com/sun/star/awt/XMouseMotionListener.hpp>
-#include <com/sun/star/awt/XMouseMotionListener.hdl>
-#include <com/sun/star/awt/XPaintListener.hpp>
-#include <com/sun/star/awt/XPaintListener.hdl>
-#include <com/sun/star/awt/PaintEvent.hdl>
-#include <com/sun/star/awt/PaintEvent.hpp>
-#include <com/sun/star/awt/XWindowListener.hpp>
-#include <com/sun/star/awt/XWindowListener.hdl>
-#include <com/sun/star/awt/WindowEvent.hdl>
-#include <com/sun/star/awt/WindowEvent.hpp>
-#include <com/sun/star/frame/XController.hpp>
-#include <com/sun/star/frame/XController.hdl>
-#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/frame/XModel.hdl>
-#include <com/sun/star/lang/IndexOutOfBoundsException.hdl>
-#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
-#include <com/sun/star/container/XIndexAccess.hdl>
-#include <com/sun/star/container/XIndexAccess.hpp>
-#include <excrecds.hxx>
-#include <scerrors.hxx>
-#include <docpool.hxx>
-#include <svx/msdffimp.hxx>
-#include <com/sun/star/lang/IllegalArgumentException.hdl>
-#include <com/sun/star/lang/IllegalArgumentException.hpp>
-#include <tools/urlobj.hxx>
-#include <svx/colritem.hxx>
-#include <vcl/wrkwin.hxx>
-#include <excimp8.hxx>
-#include <excscen.hxx>
-#include <com/sun/star/frame/XFrameActionListener.hpp>
-#include <com/sun/star/frame/XFrameActionListener.hdl>
-#include <com/sun/star/frame/FrameActionEvent.hdl>
-#include <com/sun/star/frame/FrameAction.hdl>
-#include <com/sun/star/frame/FrameActionEvent.hpp>
-#include <com/sun/star/frame/FrameAction.hpp>
-#include <com/sun/star/frame/XFramesSupplier.hpp>
-#include <com/sun/star/frame/XFramesSupplier.hdl>
-#include <com/sun/star/frame/XFrames.hpp>
-#include <com/sun/star/frame/XFrames.hdl>
-#include <svx/msdffdef.hxx>
-#include <vcl/image.hxx>
-
-
-
-
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: filt_pch.hxx,v $
+ * $Revision: 1.13 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// ItemID-Defines etc. muessen immer ganz vorne stehen
+
+#include "scitems.hxx"
+
+
+#define _ZFORLIST_DECLARE_TABLE
+
+#define SC_PROGRESS_CXX
+
+// ab hier automatisch per makepch generiert
+// folgende duerfen nicht aufgenommen werden:
+// ...
+
+#include <tools/solar.h>
+#include <tools/string.hxx>
+#include <rtl/textenc.h>
+#include <sal/types.h>
+#include <sal/config.h>
+#include <rtl/textcvt.h>
+#include <rtl/string.hxx>
+#include <rtl/string.h>
+#include <rtl/ustring.h>
+#include <rtl/memory.h>
+#include <rtl/ustring.hxx>
+#include <rtl/locale.hxx>
+#include <rtl/locale.h>
+#include <tools/contnr.hxx>
+#include <i18npool/lang.h>
+#include <tools/list.hxx>
+#include <global.hxx>
+#include <tools/stream.hxx>
+#include <tools/errinf.hxx>
+#include <tools/rtti.hxx>
+#include <tools/errcode.hxx>
+#include <tools/ref.hxx>
+#include <tools/link.hxx>
+#include <tools/debug.hxx>
+#include <tools/time.hxx>
+#include <tools/date.hxx>
+#include <svtools/svarray.hxx>
+#include <vcl/sv.h>
+#include <vcl/timer.hxx>
+#include <tools/gen.hxx>
+#include <tools/color.hxx>
+#include <tools/color.hxx>
+#include <filter.hxx>
+#include <rangelst.hxx>
+#include <osl/mutex.h>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Any.h>
+#include <cppu/macros.hxx>
+#include <uno/lbnames.h>
+#include <uno/any2.h>
+#include <uno/data.h>
+#include <typelib/typedescription.h>
+#include <typelib/uik.h>
+#include <typelib/typeclass.h>
+#include <com/sun/star/uno/Type.h>
+#include <com/sun/star/uno/TypeClass.hdl>
+#include <com/sun/star/uno/Type.hxx>
+#include <osl/mutex.hxx>
+#include <com/sun/star/uno/genfunc.hxx>
+#include <com/sun/star/uno/genfunc.h>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/XInterface.hdl>
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/RuntimeException.hdl>
+#include <com/sun/star/uno/Exception.hdl>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/uno/Exception.hpp>
+#include <svtools/hint.hxx>
+#include <svtools/poolitem.hxx>
+#include <document.hxx>
+#include <vcl/prntypes.hxx>
+#include <table.hxx>
+#include <column.hxx>
+#include <markarr.hxx>
+#include <root.hxx>
+#include <flttypes.hxx>
+#include <svtools/solar.hrc>
+#include <sfx2/sfxsids.hrc>
+#include <svtools/cntwids.hrc>
+#include <sfx2/cntids.hrc>
+#include <tools/mempool.hxx>
+#include <compiler.hxx>
+#include <formula/compiler.hrc>
+#include <sfx2/sfx.hrc>
+#include <scitems.hxx>
+#include <svx/svxids.hrc>
+#include <svtools/itemset.hxx>
+#include <svtools/memberid.hrc>
+#include <tools/table.hxx>
+#include <flttools.hxx>
+#include <vcl/vclenum.hxx>
+#include <tools/resid.hxx>
+#include <tools/rc.hxx>
+#include <tools/resmgr.hxx>
+#include <tools/fract.hxx>
+#include <vcl/bitmap.hxx>
+#include <vcl/mapmod.hxx>
+#include <vcl/mapunit.hxx>
+#include <vcl/region.hxx>
+#include <svtools/lstner.hxx>
+#include <patattr.hxx>
+#include <vcl/font.hxx>
+#include <svtools/cenumitm.hxx>
+#include <svtools/eitem.hxx>
+#include <svtools/intitem.hxx>
+#include <svtools/cintitem.hxx>
+#include <svtools/brdcst.hxx>
+#include <sot/sotref.hxx>
+#include <tools/globname.hxx>
+#include <sot/factory.hxx>
+#include <sot/object.hxx>
+#include <sot/sotdata.hxx>
+#include <vcl/bitmapex.hxx>
+#include <vcl/alpha.hxx>
+#include <vcl/gdimtf.hxx>
+#include <tools/unqidx.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/animate.hxx>
+#include <vcl/graph.h>
+#include <vcl/gfxlink.hxx>
+#include <rsc/rscsfx.hxx>
+#include <vcl/wall.hxx>
+#include <vcl/settings.hxx>
+#include <vcl/accel.hxx>
+#include <vcl/keycod.hxx>
+#include <vcl/keycodes.hxx>
+#include <namebuff.hxx>
+#include <tools/shl.hxx>
+#include <tools/pstm.hxx>
+#include <svx/fhgtitem.hxx>
+#include <vos/types.hxx>
+#include <vos/object.hxx>
+#include <vos/macros.hxx>
+#include <tools/unqid.hxx>
+#include <com/sun/star/uno/Sequence.h>
+#include <uno/sequence2.h>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <attrib.hxx>
+#include <svtools/zforlist.hxx>
+#include <svx/fontitem.hxx>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/lang/XEventListener.hdl>
+#include <com/sun/star/lang/EventObject.hdl>
+#include <com/sun/star/lang/EventObject.hpp>
+#include <vcl/outdev.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/PropertyValue.hdl>
+#include <com/sun/star/beans/PropertyState.hdl>
+#include <com/sun/star/beans/PropertyState.hpp>
+#include <collect.hxx>
+#include <vcl/window.hxx>
+#include <vcl/pointr.hxx>
+#include <vcl/ptrstyle.hxx>
+#include <vcl/wintypes.hxx>
+#include <vcl/inputctx.hxx>
+#include <vcl/event.hxx>
+#include <tools/ownlist.hxx>
+#include <vcl/cmdevt.hxx>
+#include <vcl/vclenum.hxx>
+#include <cell.hxx>
+#include <osl/interlck.h>
+#include <sfx2/sfxuno.hxx>
+#include <colrowst.hxx>
+#include <com/sun/star/util/URL.hpp>
+#include <com/sun/star/util/URL.hdl>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hdl>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hdl>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/lang/XTypeProvider.hdl>
+#include <cppuhelper/typeprovider.hxx>
+#include <rtl/uuid.h>
+#include <cppuhelper/queryinterface.hxx>
+#include <cppuhelper/factory.hxx>
+#include <uno/dispatcher.h>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/registry/XRegistryKey.hdl>
+#include <com/sun/star/registry/InvalidRegistryException.hdl>
+#include <com/sun/star/registry/InvalidValueException.hdl>
+#include <com/sun/star/registry/RegistryKeyType.hdl>
+#include <com/sun/star/registry/RegistryValueType.hdl>
+#include <com/sun/star/registry/InvalidRegistryException.hpp>
+#include <com/sun/star/registry/InvalidValueException.hpp>
+#include <com/sun/star/registry/RegistryKeyType.hpp>
+#include <com/sun/star/registry/RegistryValueType.hpp>
+#include <sot/storage.hxx>
+#include <tools/datetime.hxx>
+#include <osl/thread.h>
+#include <imp_op.hxx>
+#include <otlnbuff.hxx>
+#include <tokstack.hxx>
+#include <com/sun/star/container/NoSuchElementException.hdl>
+#include <com/sun/star/container/NoSuchElementException.hpp>
+#include <vcl/svapp.hxx>
+#include <vos/thread.hxx>
+#include <vos/runnable.hxx>
+#include <vos/refernce.hxx>
+#include <vcl/apptypes.hxx>
+#include <svx/editdata.hxx>
+#include <svx/editeng.hxx>
+#include <com/sun/star/lang/WrappedTargetException.hdl>
+#include <com/sun/star/lang/WrappedTargetException.hpp>
+#include <sfx2/shell.hxx>
+#include <tools/stack.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XComponent.hdl>
+#include <svx/svxenum.hxx>
+#include <formel.hxx>
+#include <com/sun/star/container/XElementAccess.hdl>
+#include <com/sun/star/container/XElementAccess.hpp>
+#include <svtools/itempool.hxx>
+#include <svx/eeitem.hxx>
+#include <rangenam.hxx>
+#include <vcl/syswin.hxx>
+#include <svtools/smplhint.hxx>
+#include <fontbuff.hxx>
+#include <vcl/ctrl.hxx>
+#include <vcl/field.hxx>
+#include <vcl/spinfld.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/combobox.h>
+#include <vcl/fldunit.hxx>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XFrame.hdl>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/awt/XWindow.hdl>
+#include <com/sun/star/awt/Rectangle.hdl>
+#include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/awt/XFocusListener.hpp>
+#include <com/sun/star/awt/XFocusListener.hdl>
+#include <com/sun/star/awt/FocusEvent.hdl>
+#include <com/sun/star/awt/FocusEvent.hpp>
+#include <com/sun/star/awt/XKeyListener.hpp>
+#include <com/sun/star/awt/XKeyListener.hdl>
+#include <com/sun/star/awt/KeyEvent.hdl>
+#include <com/sun/star/awt/InputEvent.hdl>
+#include <com/sun/star/awt/KeyEvent.hpp>
+#include <com/sun/star/awt/InputEvent.hpp>
+#include <com/sun/star/awt/XMouseListener.hpp>
+#include <com/sun/star/awt/XMouseListener.hdl>
+#include <com/sun/star/awt/MouseEvent.hdl>
+#include <com/sun/star/awt/MouseEvent.hpp>
+#include <com/sun/star/awt/XMouseMotionListener.hpp>
+#include <com/sun/star/awt/XMouseMotionListener.hdl>
+#include <com/sun/star/awt/XPaintListener.hpp>
+#include <com/sun/star/awt/XPaintListener.hdl>
+#include <com/sun/star/awt/PaintEvent.hdl>
+#include <com/sun/star/awt/PaintEvent.hpp>
+#include <com/sun/star/awt/XWindowListener.hpp>
+#include <com/sun/star/awt/XWindowListener.hdl>
+#include <com/sun/star/awt/WindowEvent.hdl>
+#include <com/sun/star/awt/WindowEvent.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/frame/XController.hdl>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/XModel.hdl>
+#include <com/sun/star/lang/IndexOutOfBoundsException.hdl>
+#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <com/sun/star/container/XIndexAccess.hdl>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <excrecds.hxx>
+#include <scerrors.hxx>
+#include <docpool.hxx>
+#include <svx/msdffimp.hxx>
+#include <com/sun/star/lang/IllegalArgumentException.hdl>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <tools/urlobj.hxx>
+#include <svx/colritem.hxx>
+#include <vcl/wrkwin.hxx>
+#include <excimp8.hxx>
+#include <excscen.hxx>
+#include <com/sun/star/frame/XFrameActionListener.hpp>
+#include <com/sun/star/frame/XFrameActionListener.hdl>
+#include <com/sun/star/frame/FrameActionEvent.hdl>
+#include <com/sun/star/frame/FrameAction.hdl>
+#include <com/sun/star/frame/FrameActionEvent.hpp>
+#include <com/sun/star/frame/FrameAction.hpp>
+#include <com/sun/star/frame/XFramesSupplier.hpp>
+#include <com/sun/star/frame/XFramesSupplier.hdl>
+#include <com/sun/star/frame/XFrames.hpp>
+#include <com/sun/star/frame/XFrames.hdl>
+#include <svx/msdffdef.hxx>
+#include <vcl/image.hxx>
+
+
+
+
diff --git a/sc/source/filter/inc/xlformula.hxx b/sc/source/filter/inc/xlformula.hxx
index 0c3496bdee30..ef9274bc0338 100644
--- a/sc/source/filter/inc/xlformula.hxx
+++ b/sc/source/filter/inc/xlformula.hxx
@@ -1,477 +1,477 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: xlformula.hxx,v $
- * $Revision: 1.14 $
- *
- * 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 SC_XLFORMULA_HXX
-#define SC_XLFORMULA_HXX
-
-#include <map>
-#include "address.hxx"
-#include "formula/opcode.hxx"
-#include "ftools.hxx"
-
-// Constants ==================================================================
-
-const size_t EXC_TOKARR_MAXLEN = 4096; /// Maximum size of a token array.
-
-// Token class flags ----------------------------------------------------------
-
-const sal_uInt8 EXC_TOKCLASS_MASK = 0x60;
-const sal_uInt8 EXC_TOKCLASS_INOP_FLAG = 0x80; /// Used in operators (internal flag).
-
-const sal_uInt8 EXC_TOKCLASS_NONE = 0x00; /// 00-1F: Base tokens.
-const sal_uInt8 EXC_TOKCLASS_REF = 0x20; /// 20-3F: Reference class tokens.
-const sal_uInt8 EXC_TOKCLASS_VAL = 0x40; /// 40-5F: Value class tokens.
-const sal_uInt8 EXC_TOKCLASS_ARR = 0x60; /// 60-7F: Array class tokens.
-
-const sal_uInt8 EXC_TOKCLASS_ANY_IN_REFOP = EXC_TOKCLASS_INOP_FLAG | EXC_TOKCLASS_NONE;
-const sal_uInt8 EXC_TOKCLASS_REF_IN_VALOP = EXC_TOKCLASS_INOP_FLAG | EXC_TOKCLASS_REF;
-const sal_uInt8 EXC_TOKCLASS_VAL_IN_VALOP = EXC_TOKCLASS_INOP_FLAG | EXC_TOKCLASS_VAL;
-const sal_uInt8 EXC_TOKCLASS_ARR_IN_VALOP = EXC_TOKCLASS_INOP_FLAG | EXC_TOKCLASS_ARR;
-
-// Base tokens ----------------------------------------------------------------
-
-const sal_uInt8 EXC_TOKID_MASK = 0x1F;
-
-const sal_uInt8 EXC_TOKID_NONE = 0x00; /// Placeholder for invalid token id.
-const sal_uInt8 EXC_TOKID_EXP = 0x01; /// Array or shared formula reference.
-const sal_uInt8 EXC_TOKID_TBL = 0x02; /// Multiple operation reference.
-const sal_uInt8 EXC_TOKID_ADD = 0x03; /// Addition operator.
-const sal_uInt8 EXC_TOKID_SUB = 0x04; /// Subtraction operator.
-const sal_uInt8 EXC_TOKID_MUL = 0x05; /// Multiplication operator.
-const sal_uInt8 EXC_TOKID_DIV = 0x06; /// Division operator.
-const sal_uInt8 EXC_TOKID_POWER = 0x07; /// Power operator.
-const sal_uInt8 EXC_TOKID_CONCAT = 0x08; /// String concatenation operator.
-const sal_uInt8 EXC_TOKID_LT = 0x09; /// Less than operator.
-const sal_uInt8 EXC_TOKID_LE = 0x0A; /// Less than or equal operator.
-const sal_uInt8 EXC_TOKID_EQ = 0x0B; /// Equal operator.
-const sal_uInt8 EXC_TOKID_GE = 0x0C; /// Greater than or equal operator.
-const sal_uInt8 EXC_TOKID_GT = 0x0D; /// Greater than operator.
-const sal_uInt8 EXC_TOKID_NE = 0x0E; /// Not equal operator.
-const sal_uInt8 EXC_TOKID_ISECT = 0x0F; /// Intersection operator.
-const sal_uInt8 EXC_TOKID_LIST = 0x10; /// List operator.
-const sal_uInt8 EXC_TOKID_RANGE = 0x11; /// Range operator.
-const sal_uInt8 EXC_TOKID_UPLUS = 0x12; /// Unary plus.
-const sal_uInt8 EXC_TOKID_UMINUS = 0x13; /// Unary minus.
-const sal_uInt8 EXC_TOKID_PERCENT = 0x14; /// Percent sign.
-const sal_uInt8 EXC_TOKID_PAREN = 0x15; /// Parentheses.
-const sal_uInt8 EXC_TOKID_MISSARG = 0x16; /// Missing argument.
-const sal_uInt8 EXC_TOKID_STR = 0x17; /// String constant.
-const sal_uInt8 EXC_TOKID_NLR = 0x18; /// Natural language reference (NLR).
-const sal_uInt8 EXC_TOKID_ATTR = 0x19; /// Special attribute.
-const sal_uInt8 EXC_TOKID_SHEET = 0x1A; /// Start of a sheet reference (BIFF2-BIFF4).
-const sal_uInt8 EXC_TOKID_ENDSHEET = 0x1B; /// End of a sheet reference (BIFF2-BIFF4).
-const sal_uInt8 EXC_TOKID_ERR = 0x1C; /// Error constant.
-const sal_uInt8 EXC_TOKID_BOOL = 0x1D; /// Boolean constant.
-const sal_uInt8 EXC_TOKID_INT = 0x1E; /// Integer constant.
-const sal_uInt8 EXC_TOKID_NUM = 0x1F; /// Floating-point constant.
-
-// Base IDs of classified tokens ----------------------------------------------
-
-const sal_uInt8 EXC_TOKID_ARRAY = 0x00; /// Array constant.
-const sal_uInt8 EXC_TOKID_FUNC = 0x01; /// Function, fixed number of arguments.
-const sal_uInt8 EXC_TOKID_FUNCVAR = 0x02; /// Function, variable number of arguments.
-const sal_uInt8 EXC_TOKID_NAME = 0x03; /// Defined name.
-const sal_uInt8 EXC_TOKID_REF = 0x04; /// 2D cell reference.
-const sal_uInt8 EXC_TOKID_AREA = 0x05; /// 2D area reference.
-const sal_uInt8 EXC_TOKID_MEMAREA = 0x06; /// Constant reference subexpression.
-const sal_uInt8 EXC_TOKID_MEMERR = 0x07; /// Deleted reference subexpression.
-const sal_uInt8 EXC_TOKID_MEMNOMEM = 0x08; /// Constant reference subexpression without result.
-const sal_uInt8 EXC_TOKID_MEMFUNC = 0x09; /// Variable reference subexpression.
-const sal_uInt8 EXC_TOKID_REFERR = 0x0A; /// Deleted 2D cell reference.
-const sal_uInt8 EXC_TOKID_AREAERR = 0x0B; /// Deleted 2D area reference.
-const sal_uInt8 EXC_TOKID_REFN = 0x0C; /// Relative 2D cell reference (in names).
-const sal_uInt8 EXC_TOKID_AREAN = 0x0D; /// Relative 2D area reference (in names).
-const sal_uInt8 EXC_TOKID_MEMAREAN = 0x0E; /// Reference subexpression (in names).
-const sal_uInt8 EXC_TOKID_MEMNOMEMN = 0x0F; /// Reference subexpression (in names) without result.
-const sal_uInt8 EXC_TOKID_FUNCCE = 0x18;
-const sal_uInt8 EXC_TOKID_NAMEX = 0x19; /// External reference.
-const sal_uInt8 EXC_TOKID_REF3D = 0x1A; /// 3D cell reference.
-const sal_uInt8 EXC_TOKID_AREA3D = 0x1B; /// 3D area reference.
-const sal_uInt8 EXC_TOKID_REFERR3D = 0x1C; /// Deleted 3D cell reference.
-const sal_uInt8 EXC_TOKID_AREAERR3D = 0x1D; /// Deleted 3D area reference
-
-// specific token constants ---------------------------------------------------
-
-const sal_uInt16 EXC_TOK_STR_MAXLEN = 255; /// Maximum string length of a tStr token.
-
-const sal_uInt8 EXC_TOK_BOOL_FALSE = 0; /// FALSE value of a tBool token.
-const sal_uInt8 EXC_TOK_BOOL_TRUE = 1; /// TRUE value of a tBool token.
-
-const sal_uInt8 EXC_TOK_ATTR_VOLATILE = 0x01; /// Volatile function.
-const sal_uInt8 EXC_TOK_ATTR_IF = 0x02; /// Start of true condition in IF function.
-const sal_uInt8 EXC_TOK_ATTR_CHOOSE = 0x04; /// Jump array of CHOOSE function.
-const sal_uInt8 EXC_TOK_ATTR_GOTO = 0x08; /// Jump to token.
-const sal_uInt8 EXC_TOK_ATTR_SUM = 0x10; /// SUM function with one parameter.
-const sal_uInt8 EXC_TOK_ATTR_ASSIGN = 0x20; /// BASIC style assignment.
-const sal_uInt8 EXC_TOK_ATTR_SPACE = 0x40; /// Spaces in formula representation.
-
-const sal_uInt8 EXC_TOK_ATTR_SPACE_SP = 0x00; /// Spaces before next token.
-const sal_uInt8 EXC_TOK_ATTR_SPACE_BR = 0x01; /// Line breaks before next token.
-const sal_uInt8 EXC_TOK_ATTR_SPACE_SP_OPEN = 0x02; /// Spaces before opening parenthesis.
-const sal_uInt8 EXC_TOK_ATTR_SPACE_BR_OPEN = 0x03; /// Line breaks before opening parenthesis.
-const sal_uInt8 EXC_TOK_ATTR_SPACE_SP_CLOSE = 0x04; /// Spaces before closing parenthesis.
-const sal_uInt8 EXC_TOK_ATTR_SPACE_BR_CLOSE = 0x05; /// Line breaks before closing parenthesis.
-const sal_uInt8 EXC_TOK_ATTR_SPACE_SP_PRE = 0x06; /// Spaces before formula (BIFF3).
-
-const sal_uInt16 EXC_TOK_FUNCVAR_CMD = 0x8000; /// Macro command.
-const sal_uInt16 EXC_TOK_FUNCVAR_INDEXMASK = 0x7FFF; /// Mask for function/command index.
-const sal_uInt8 EXC_TOK_FUNCVAR_PROMPT = 0x80; /// User prompt for macro commands.
-const sal_uInt8 EXC_TOK_FUNCVAR_COUNTMASK = 0x7F; /// Mask for parameter count.
-
-const sal_uInt16 EXC_TOK_REF_COLREL = 0x4000; /// True = Column is relative.
-const sal_uInt16 EXC_TOK_REF_ROWREL = 0x8000; /// True = Row is relative.
-
-const sal_uInt8 EXC_TOK_NLR_ERR = 0x01; /// NLR: Invalid/deleted.
-const sal_uInt8 EXC_TOK_NLR_ROWR = 0x02; /// NLR: Row index.
-const sal_uInt8 EXC_TOK_NLR_COLR = 0x03; /// NLR: Column index.
-const sal_uInt8 EXC_TOK_NLR_ROWV = 0x06; /// NLR: Value in row.
-const sal_uInt8 EXC_TOK_NLR_COLV = 0x07; /// NLR: Value in column.
-const sal_uInt8 EXC_TOK_NLR_RANGE = 0x0A; /// NLR: Range.
-const sal_uInt8 EXC_TOK_NLR_SRANGE = 0x0B; /// Stacked NLR: Range.
-const sal_uInt8 EXC_TOK_NLR_SROWR = 0x0C; /// Stacked NLR: Row index.
-const sal_uInt8 EXC_TOK_NLR_SCOLR = 0x0D; /// Stacked NLR: Column index.
-const sal_uInt8 EXC_TOK_NLR_SROWV = 0x0E; /// Stacked NLR: Value in row.
-const sal_uInt8 EXC_TOK_NLR_SCOLV = 0x0F; /// Stacked NLR: Value in column.
-const sal_uInt8 EXC_TOK_NLR_RANGEERR = 0x10; /// NLR: Invalid/deleted range.
-const sal_uInt8 EXC_TOK_NLR_SXNAME = 0x1D; /// NLR: Pivot table name.
-const sal_uInt16 EXC_TOK_NLR_REL = 0x8000; /// True = Natural language ref is relative.
-
-const sal_uInt32 EXC_TOK_NLR_ADDREL = 0x80000000; /// NLR relative (in appended data).
-const sal_uInt32 EXC_TOK_NLR_ADDMASK = 0x3FFFFFFF; /// Mask for number of appended ranges.
-
-// ----------------------------------------------------------------------------
-
-/** Type of a formula. */
-enum XclFormulaType
-{
- EXC_FMLATYPE_CELL, /// Simple cell formula, also used in change tracking.
- EXC_FMLATYPE_MATRIX, /// Matrix (array) formula.
- EXC_FMLATYPE_SHARED, /// Shared formula.
- EXC_FMLATYPE_CONDFMT, /// Conditional format.
- EXC_FMLATYPE_DATAVAL, /// Data validation.
- EXC_FMLATYPE_NAME, /// Defined name.
- EXC_FMLATYPE_CHART, /// Chart source ranges.
- EXC_FMLATYPE_CONTROL, /// Spreadsheet links in form controls.
- EXC_FMLATYPE_WQUERY, /// Web query source range.
- EXC_FMLATYPE_LISTVAL /// List (cell range) validation.
-};
-
-// Function data ==============================================================
-
-const sal_uInt8 EXC_FUNC_MAXPARAM = 30; /// Maximum parameter count.
-
-const sal_uInt8 EXC_FUNC_PAR_CALCONLY = 0xFD; /// Placeholder for a parameter existing in Calc, but not in Excel.
-const sal_uInt8 EXC_FUNC_PAR_EXCELONLY = 0xFE; /// Placeholder for a parameter existing in Excel, but not in Calc.
-const sal_uInt8 EXC_FUNC_PAR_INVALID = 0xFF; /// Placeholder for an invalid token class.
-
-const sal_uInt8 EXC_FUNCINFO_CLASSCOUNT = 5; /// Number of token class entries.
-
-const sal_uInt8 EXC_FUNCFLAG_VOLATILE = 0x01; /// Result is volatile (e.g. NOW() function).
-const sal_uInt8 EXC_FUNCFLAG_IMPORTONLY = 0x02; /// Only used in import filter.
-const sal_uInt8 EXC_FUNCFLAG_EXPORTONLY = 0x04; /// Only used in export filter.
-
-// selected function IDs
-const sal_uInt16 EXC_FUNCID_IF = 1;
-const sal_uInt16 EXC_FUNCID_SUM = 4;
-const sal_uInt16 EXC_FUNCID_AND = 36;
-const sal_uInt16 EXC_FUNCID_OR = 37;
-const sal_uInt16 EXC_FUNCID_CHOOSE = 100;
-const sal_uInt16 EXC_FUNCID_EXTERNCALL = 255;
-
-/** Represents information for a spreadsheet function for import and export.
-
- The member mpnParamClass contains an array of token classes for each
- parameter of the function. The last existing (non-null) value in this array
- is used for all following parameters used in a function. Additionally to
- the three actual token classes, this array may contain the special values
- EXC_FUNC_PAR_CALCONLY, EXC_FUNC_PAR_EXCELONLY, and EXC_FUNC_PAR_INVALID.
- The former two specify parameters only existing in one of the applications.
- EXC_FUNC_PAR_INVALID is simply a terminator for the array to prevent that
- the last token class or special value is repeated for additional parameters.
- */
-struct XclFunctionInfo
-{
- OpCode meOpCode; /// Calc function opcode.
- sal_uInt16 mnXclFunc; /// Excel function index.
- sal_uInt8 mnMinParamCount; /// Minimum number of parameters.
- sal_uInt8 mnMaxParamCount; /// Maximum number of parameters.
- sal_uInt8 mnRetClass; /// Token class of the return value.
- sal_uInt8 mpnParamClass[ EXC_FUNCINFO_CLASSCOUNT ]; /// Expected token classes of parameters.
- sal_uInt8 mnFlags; /// Additional flags.
- const sal_Char* mpcMacroName; /// Function name, if simulated by a macro call (UTF-8).
-
- /** Returns true, if the function is volatile. */
- inline bool IsVolatile() const { return ::get_flag( mnFlags, EXC_FUNCFLAG_VOLATILE ); }
- /** Returns true, if the function is simulated by a macro call. */
- inline bool IsMacroFunc() const { return mpcMacroName != 0; }
- /** Returns the name of the external function as string. */
- String GetMacroFuncName() const;
-};
-
-// ----------------------------------------------------------------------------
-
-class XclRoot;
-
-/** Provides access to function info structs for all available functions. */
-class XclFunctionProvider
-{
-public:
- explicit XclFunctionProvider( const XclRoot& rRoot );
-
- /** Returns the function data for an Excel function index, or 0 on error. */
- const XclFunctionInfo* GetFuncInfoFromXclFunc( sal_uInt16 nXclFunc ) const;
- /** Returns the function data for an Excel function simulated by a macro call, or 0 on error. */
- const XclFunctionInfo* GetFuncInfoFromXclMacroName( const String& rXclMacroName ) const;
- /** Returns the function data for a Calc opcode, or 0 on error. */
- const XclFunctionInfo* GetFuncInfoFromOpCode( OpCode eOpCode ) const;
-
-private:
- void FillXclFuncMap( const XclFunctionInfo* pBeg, const XclFunctionInfo* pEnd );
- void FillScFuncMap( const XclFunctionInfo* pBeg, const XclFunctionInfo* pEnd );
-
-private:
- typedef ::std::map< sal_uInt16, const XclFunctionInfo* > XclFuncMap;
- typedef ::std::map< String, const XclFunctionInfo* > XclMacroNameMap;
- typedef ::std::map< OpCode, const XclFunctionInfo* > ScFuncMap;
-
- XclFuncMap maXclFuncMap; /// Maps Excel function indexes to function data.
- XclMacroNameMap maXclMacroNameMap; /// Maps macro function names to function data.
- ScFuncMap maScFuncMap; /// Maps Calc opcodes to function data.
-};
-
-// Token array ================================================================
-
-class XclImpStream;
-class XclExpStream;
-
-/** Binary representation of an Excel token array. */
-class XclTokenArray
-{
-public:
- /** Creates an empty token array. */
- explicit XclTokenArray( bool bVolatile = false );
- /** Creates a token array, swaps passed token vector into own data. */
- explicit XclTokenArray( ScfUInt8Vec& rTokVec, bool bVolatile = false,
- ScfUInt8Vec* pExtensionTokens = NULL);
-
- /** Returns true, if the token array is empty. */
- inline bool Empty() const { return maTokVec.empty(); }
- /** Returns the size of the token array in bytes. */
- sal_uInt16 GetSize() const;
- /** Returns read-only access to the byte vector storing token data. */
- inline const sal_uInt8* GetData() const { return maTokVec.empty() ? 0 : &maTokVec.front(); }
- /** Returns true, if the formula contains a volatile function. */
- inline bool IsVolatile() const { return mbVolatile; }
-
- /** Reads the size field of the token array. */
- void ReadSize( XclImpStream& rStrm );
- /** Reads the tokens of the token array (without size field). */
- void ReadArray( XclImpStream& rStrm );
- /** Reads size field and the tokens. */
- void Read( XclImpStream& rStrm );
-
- /** Writes the size field of the token array. */
- void WriteSize( XclExpStream& rStrm ) const;
- /** Writes the tokens of the token array (without size field). */
- void WriteArray( XclExpStream& rStrm ) const;
- /** Writes size field and the tokens. */
- void Write( XclExpStream& rStrm ) const;
-
- /** Compares this token array with the passed. */
- bool operator==( const XclTokenArray& rTokArr ) const;
-
-private:
- ScfUInt8Vec maTokVec; /// Byte vector containing token data.
- ScfUInt8Vec maExtensions; /// Byte vector of extensions (eg inline arrays)
- bool mbVolatile; /// True = Formula contains volatile function.
-};
-
-typedef ScfRef< XclTokenArray > XclTokenArrayRef;
-
-/** Calls the Read() function at the passed token array. */
-XclImpStream& operator>>( XclImpStream& rStrm, XclTokenArray& rTokArr );
-/** Calls the Read() function at the passed token array. */
-XclImpStream& operator>>( XclImpStream& rStrm, XclTokenArrayRef& rxTokArr );
-/** Calls the Write() function at the passed token array. */
-XclExpStream& operator<<( XclExpStream& rStrm, const XclTokenArray& rTokArr );
-/** Calls the Write() function at the passed token array. */
-XclExpStream& operator<<( XclExpStream& rStrm, const XclTokenArrayRef& rxTokArr );
-
-// ----------------------------------------------------------------------------
-
-namespace formula
-{
- class FormulaToken;
-}
-class ScTokenArray;
-
-/** Special token array iterator for the Excel filters.
-
- Iterates over a Calc token array without modifying it (therefore the
- iterator can be used with constant token arrays).
-
- Usage: Construct a new iterator object and pass a Calc token array, or use
- the Init() function to assign another Calc token array. As long as the Is()
- function returns true, the accessor functions can be used to get the
- current Calc token.
- */
-class XclTokenArrayIterator
-{
-public:
- explicit XclTokenArrayIterator();
- explicit XclTokenArrayIterator( const ScTokenArray& rScTokArr, bool bSkipSpaces );
- /** Copy constructor that allowa to change the skip-spaces mode. */
- explicit XclTokenArrayIterator( const XclTokenArrayIterator& rTokArrIt, bool bSkipSpaces );
-
- void Init();
- void Init( const ScTokenArray& rScTokArr, bool bSkipSpaces );
-
- inline bool Is() const { return mppScToken != 0; }
- inline bool operator!() const { return !Is(); }
- inline const formula::FormulaToken* Get() const { return mppScToken ? *mppScToken : 0; }
- inline const formula::FormulaToken* operator->() const { return Get(); }
- inline const formula::FormulaToken& operator*() const { return *Get(); }
-
- XclTokenArrayIterator& operator++();
-
-private:
- void NextRawToken();
- void SkipSpaces();
-
-private:
- const formula::FormulaToken*const* mppScTokenBeg; /// Pointer to first token pointer of token array.
- const formula::FormulaToken*const* mppScTokenEnd; /// Pointer behind last token pointer of token array.
- const formula::FormulaToken*const* mppScToken; /// Pointer to current token pointer of token array.
- bool mbSkipSpaces; /// true = Skip whitespace tokens.
-};
-
-// ----------------------------------------------------------------------------
-
-/** Contains all cell references that can be extracted from a multiple operations formula. */
-struct XclMultipleOpRefs
-{
- ScAddress maFmlaScPos; /// Position of the (first) formula cell.
- ScAddress maColFirstScPos;
- ScAddress maColRelScPos;
- ScAddress maRowFirstScPos;
- ScAddress maRowRelScPos;
- bool mbDblRefMode; /// true = One formula with row and column values.
-};
-
-// ----------------------------------------------------------------------------
-
-/** A helper with Excel specific token array functions.
-
- The purpose to not add these functions to ScTokenArray is to prevent code
- changes in low-level Calc headers and to keep the Excel specific source
- code in the filter directory. Deriving from ScTokenArray is not viable
- because that would need expensive copy-constructions of the token arrays.
- */
-class XclTokenArrayHelper
-{
-public:
- // token identifiers ------------------------------------------------------
-
- /** Returns the base token ID of the passed (classified) token ID. */
- inline static sal_uInt8 GetBaseTokenId( sal_uInt8 nTokenId ) { return nTokenId & EXC_TOKID_MASK; }
- /** Returns the classified token ID from a base ID and the token class. */
- inline static sal_uInt8 GetTokenId( sal_uInt8 nBaseId, sal_uInt8 nTokenClass );
-
- /** Returns the token class of the passed token ID. */
- inline static sal_uInt8 GetTokenClass( sal_uInt8 nTokenId ) { return nTokenId & EXC_TOKCLASS_MASK; }
- /** Changes the token class in the passed classified token ID. */
- inline static void ChangeTokenClass( sal_uInt8& rnTokenId, sal_uInt8 nTokenClass );
-
- // strings and string lists -----------------------------------------------
-
- /** Tries to extract a string from the passed token.
- @param rString (out-parameter) The string contained in the token.
- @return true = Passed token is a string token, rString parameter is valid. */
- static bool GetTokenString( String& rString, const formula::FormulaToken& rScToken );
-
- /** Parses the passed formula and tries to find a single string token, i.e. "abc".
- @param rString (out-parameter) The string contained in the formula.
- @return true = String token found, rString parameter is valid. */
- static bool GetString( String& rString, const ScTokenArray& rScTokArr );
-
- /** Parses the passed formula and tries to find a string token list, i.e. "abc";"def";"ghi".
- @descr Returns the unquoted (!) strings in a single string, separated with the
- passed character. If a comma is specified, the function will return abc,def,ghi from
- the example above.
- @param rStringList (out-parameter) All strings contained in the formula as list.
- @param cSep List separator character.
- @return true = String token list found, rString parameter is valid. */
- static bool GetStringList( String& rStringList, const ScTokenArray& rScTokArr, sal_Unicode cSep );
-
- /** Tries to convert a formula that consists of a single string token to a list of strings.
- @descr Example: The formula ="abc\ndef\nghi" will be converted to the formula
- ="abc";"def";"ghi", if the LF character is specified as separator.
- @param rScTokArr (in/out-parameter) The token array to modify.
- @param cStringSep The separator in the source string.
- @param bTrimLeadingSpaces true = remove leading spaces from each token. */
- static void ConvertStringToList( ScTokenArray& rScTokArr, sal_Unicode cStringSep, bool bTrimLeadingSpaces );
-
- // shared formulas --------------------------------------------------------
-
- /** Tries to extract the definition of a shared formula from the passed token array.
- @descr Shared formulas are stored as hidden defined names in Calc. This
- function looks if the passed token array consists of the reference to
- such a hidden defined name and returns its definition on success. */
- static const ScTokenArray* GetSharedFormula( const XclRoot& rRoot, const ScTokenArray& rScTokArr );
-
- // multiple operations ----------------------------------------------------
-
- /** Parses the passed formula and tries to extract references of a multiple operation.
- @descr Requires that the formula contains a single MULTIPLE.OPERATION function call.
- Spaces in the formula are silently ignored.
- @return true = Multiple operation found, and all references successfully extracted. */
- static bool GetMultipleOpRefs( XclMultipleOpRefs& rRefs, const ScTokenArray& rScTokArr );
-};
-
-// ----------------------------------------------------------------------------
-
-inline sal_uInt8 XclTokenArrayHelper::GetTokenId( sal_uInt8 nBaseId, sal_uInt8 nTokenClass )
-{
- DBG_ASSERT( !::get_flag( nBaseId, static_cast< sal_uInt8 >( ~EXC_TOKID_MASK ) ), "XclTokenArrayHelper::GetTokenId - invalid token ID" );
- DBG_ASSERT( !::get_flag( nTokenClass, static_cast< sal_uInt8 >( ~EXC_TOKCLASS_MASK ) ), "XclTokenArrayHelper::GetTokenId - invalid token class" );
- return nBaseId | nTokenClass;
-}
-
-inline void XclTokenArrayHelper::ChangeTokenClass( sal_uInt8& rnTokenId, sal_uInt8 nTokenClass )
-{
- DBG_ASSERT( !::get_flag( nTokenClass, static_cast< sal_uInt8 >( ~EXC_TOKCLASS_MASK ) ), "XclTokenArrayHelper::ChangeTokenClass - invalid token class" );
- ::set_flag( rnTokenId, EXC_TOKCLASS_MASK, false );
- ::set_flag( rnTokenId, nTokenClass );
-}
-
-// ============================================================================
-
-#endif
-
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: xlformula.hxx,v $
+ * $Revision: 1.14 $
+ *
+ * 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 SC_XLFORMULA_HXX
+#define SC_XLFORMULA_HXX
+
+#include <map>
+#include "address.hxx"
+#include "formula/opcode.hxx"
+#include "ftools.hxx"
+
+// Constants ==================================================================
+
+const size_t EXC_TOKARR_MAXLEN = 4096; /// Maximum size of a token array.
+
+// Token class flags ----------------------------------------------------------
+
+const sal_uInt8 EXC_TOKCLASS_MASK = 0x60;
+const sal_uInt8 EXC_TOKCLASS_INOP_FLAG = 0x80; /// Used in operators (internal flag).
+
+const sal_uInt8 EXC_TOKCLASS_NONE = 0x00; /// 00-1F: Base tokens.
+const sal_uInt8 EXC_TOKCLASS_REF = 0x20; /// 20-3F: Reference class tokens.
+const sal_uInt8 EXC_TOKCLASS_VAL = 0x40; /// 40-5F: Value class tokens.
+const sal_uInt8 EXC_TOKCLASS_ARR = 0x60; /// 60-7F: Array class tokens.
+
+const sal_uInt8 EXC_TOKCLASS_ANY_IN_REFOP = EXC_TOKCLASS_INOP_FLAG | EXC_TOKCLASS_NONE;
+const sal_uInt8 EXC_TOKCLASS_REF_IN_VALOP = EXC_TOKCLASS_INOP_FLAG | EXC_TOKCLASS_REF;
+const sal_uInt8 EXC_TOKCLASS_VAL_IN_VALOP = EXC_TOKCLASS_INOP_FLAG | EXC_TOKCLASS_VAL;
+const sal_uInt8 EXC_TOKCLASS_ARR_IN_VALOP = EXC_TOKCLASS_INOP_FLAG | EXC_TOKCLASS_ARR;
+
+// Base tokens ----------------------------------------------------------------
+
+const sal_uInt8 EXC_TOKID_MASK = 0x1F;
+
+const sal_uInt8 EXC_TOKID_NONE = 0x00; /// Placeholder for invalid token id.
+const sal_uInt8 EXC_TOKID_EXP = 0x01; /// Array or shared formula reference.
+const sal_uInt8 EXC_TOKID_TBL = 0x02; /// Multiple operation reference.
+const sal_uInt8 EXC_TOKID_ADD = 0x03; /// Addition operator.
+const sal_uInt8 EXC_TOKID_SUB = 0x04; /// Subtraction operator.
+const sal_uInt8 EXC_TOKID_MUL = 0x05; /// Multiplication operator.
+const sal_uInt8 EXC_TOKID_DIV = 0x06; /// Division operator.
+const sal_uInt8 EXC_TOKID_POWER = 0x07; /// Power operator.
+const sal_uInt8 EXC_TOKID_CONCAT = 0x08; /// String concatenation operator.
+const sal_uInt8 EXC_TOKID_LT = 0x09; /// Less than operator.
+const sal_uInt8 EXC_TOKID_LE = 0x0A; /// Less than or equal operator.
+const sal_uInt8 EXC_TOKID_EQ = 0x0B; /// Equal operator.
+const sal_uInt8 EXC_TOKID_GE = 0x0C; /// Greater than or equal operator.
+const sal_uInt8 EXC_TOKID_GT = 0x0D; /// Greater than operator.
+const sal_uInt8 EXC_TOKID_NE = 0x0E; /// Not equal operator.
+const sal_uInt8 EXC_TOKID_ISECT = 0x0F; /// Intersection operator.
+const sal_uInt8 EXC_TOKID_LIST = 0x10; /// List operator.
+const sal_uInt8 EXC_TOKID_RANGE = 0x11; /// Range operator.
+const sal_uInt8 EXC_TOKID_UPLUS = 0x12; /// Unary plus.
+const sal_uInt8 EXC_TOKID_UMINUS = 0x13; /// Unary minus.
+const sal_uInt8 EXC_TOKID_PERCENT = 0x14; /// Percent sign.
+const sal_uInt8 EXC_TOKID_PAREN = 0x15; /// Parentheses.
+const sal_uInt8 EXC_TOKID_MISSARG = 0x16; /// Missing argument.
+const sal_uInt8 EXC_TOKID_STR = 0x17; /// String constant.
+const sal_uInt8 EXC_TOKID_NLR = 0x18; /// Natural language reference (NLR).
+const sal_uInt8 EXC_TOKID_ATTR = 0x19; /// Special attribute.
+const sal_uInt8 EXC_TOKID_SHEET = 0x1A; /// Start of a sheet reference (BIFF2-BIFF4).
+const sal_uInt8 EXC_TOKID_ENDSHEET = 0x1B; /// End of a sheet reference (BIFF2-BIFF4).
+const sal_uInt8 EXC_TOKID_ERR = 0x1C; /// Error constant.
+const sal_uInt8 EXC_TOKID_BOOL = 0x1D; /// Boolean constant.
+const sal_uInt8 EXC_TOKID_INT = 0x1E; /// Integer constant.
+const sal_uInt8 EXC_TOKID_NUM = 0x1F; /// Floating-point constant.
+
+// Base IDs of classified tokens ----------------------------------------------
+
+const sal_uInt8 EXC_TOKID_ARRAY = 0x00; /// Array constant.
+const sal_uInt8 EXC_TOKID_FUNC = 0x01; /// Function, fixed number of arguments.
+const sal_uInt8 EXC_TOKID_FUNCVAR = 0x02; /// Function, variable number of arguments.
+const sal_uInt8 EXC_TOKID_NAME = 0x03; /// Defined name.
+const sal_uInt8 EXC_TOKID_REF = 0x04; /// 2D cell reference.
+const sal_uInt8 EXC_TOKID_AREA = 0x05; /// 2D area reference.
+const sal_uInt8 EXC_TOKID_MEMAREA = 0x06; /// Constant reference subexpression.
+const sal_uInt8 EXC_TOKID_MEMERR = 0x07; /// Deleted reference subexpression.
+const sal_uInt8 EXC_TOKID_MEMNOMEM = 0x08; /// Constant reference subexpression without result.
+const sal_uInt8 EXC_TOKID_MEMFUNC = 0x09; /// Variable reference subexpression.
+const sal_uInt8 EXC_TOKID_REFERR = 0x0A; /// Deleted 2D cell reference.
+const sal_uInt8 EXC_TOKID_AREAERR = 0x0B; /// Deleted 2D area reference.
+const sal_uInt8 EXC_TOKID_REFN = 0x0C; /// Relative 2D cell reference (in names).
+const sal_uInt8 EXC_TOKID_AREAN = 0x0D; /// Relative 2D area reference (in names).
+const sal_uInt8 EXC_TOKID_MEMAREAN = 0x0E; /// Reference subexpression (in names).
+const sal_uInt8 EXC_TOKID_MEMNOMEMN = 0x0F; /// Reference subexpression (in names) without result.
+const sal_uInt8 EXC_TOKID_FUNCCE = 0x18;
+const sal_uInt8 EXC_TOKID_NAMEX = 0x19; /// External reference.
+const sal_uInt8 EXC_TOKID_REF3D = 0x1A; /// 3D cell reference.
+const sal_uInt8 EXC_TOKID_AREA3D = 0x1B; /// 3D area reference.
+const sal_uInt8 EXC_TOKID_REFERR3D = 0x1C; /// Deleted 3D cell reference.
+const sal_uInt8 EXC_TOKID_AREAERR3D = 0x1D; /// Deleted 3D area reference
+
+// specific token constants ---------------------------------------------------
+
+const sal_uInt16 EXC_TOK_STR_MAXLEN = 255; /// Maximum string length of a tStr token.
+
+const sal_uInt8 EXC_TOK_BOOL_FALSE = 0; /// FALSE value of a tBool token.
+const sal_uInt8 EXC_TOK_BOOL_TRUE = 1; /// TRUE value of a tBool token.
+
+const sal_uInt8 EXC_TOK_ATTR_VOLATILE = 0x01; /// Volatile function.
+const sal_uInt8 EXC_TOK_ATTR_IF = 0x02; /// Start of true condition in IF function.
+const sal_uInt8 EXC_TOK_ATTR_CHOOSE = 0x04; /// Jump array of CHOOSE function.
+const sal_uInt8 EXC_TOK_ATTR_GOTO = 0x08; /// Jump to token.
+const sal_uInt8 EXC_TOK_ATTR_SUM = 0x10; /// SUM function with one parameter.
+const sal_uInt8 EXC_TOK_ATTR_ASSIGN = 0x20; /// BASIC style assignment.
+const sal_uInt8 EXC_TOK_ATTR_SPACE = 0x40; /// Spaces in formula representation.
+
+const sal_uInt8 EXC_TOK_ATTR_SPACE_SP = 0x00; /// Spaces before next token.
+const sal_uInt8 EXC_TOK_ATTR_SPACE_BR = 0x01; /// Line breaks before next token.
+const sal_uInt8 EXC_TOK_ATTR_SPACE_SP_OPEN = 0x02; /// Spaces before opening parenthesis.
+const sal_uInt8 EXC_TOK_ATTR_SPACE_BR_OPEN = 0x03; /// Line breaks before opening parenthesis.
+const sal_uInt8 EXC_TOK_ATTR_SPACE_SP_CLOSE = 0x04; /// Spaces before closing parenthesis.
+const sal_uInt8 EXC_TOK_ATTR_SPACE_BR_CLOSE = 0x05; /// Line breaks before closing parenthesis.
+const sal_uInt8 EXC_TOK_ATTR_SPACE_SP_PRE = 0x06; /// Spaces before formula (BIFF3).
+
+const sal_uInt16 EXC_TOK_FUNCVAR_CMD = 0x8000; /// Macro command.
+const sal_uInt16 EXC_TOK_FUNCVAR_INDEXMASK = 0x7FFF; /// Mask for function/command index.
+const sal_uInt8 EXC_TOK_FUNCVAR_PROMPT = 0x80; /// User prompt for macro commands.
+const sal_uInt8 EXC_TOK_FUNCVAR_COUNTMASK = 0x7F; /// Mask for parameter count.
+
+const sal_uInt16 EXC_TOK_REF_COLREL = 0x4000; /// True = Column is relative.
+const sal_uInt16 EXC_TOK_REF_ROWREL = 0x8000; /// True = Row is relative.
+
+const sal_uInt8 EXC_TOK_NLR_ERR = 0x01; /// NLR: Invalid/deleted.
+const sal_uInt8 EXC_TOK_NLR_ROWR = 0x02; /// NLR: Row index.
+const sal_uInt8 EXC_TOK_NLR_COLR = 0x03; /// NLR: Column index.
+const sal_uInt8 EXC_TOK_NLR_ROWV = 0x06; /// NLR: Value in row.
+const sal_uInt8 EXC_TOK_NLR_COLV = 0x07; /// NLR: Value in column.
+const sal_uInt8 EXC_TOK_NLR_RANGE = 0x0A; /// NLR: Range.
+const sal_uInt8 EXC_TOK_NLR_SRANGE = 0x0B; /// Stacked NLR: Range.
+const sal_uInt8 EXC_TOK_NLR_SROWR = 0x0C; /// Stacked NLR: Row index.
+const sal_uInt8 EXC_TOK_NLR_SCOLR = 0x0D; /// Stacked NLR: Column index.
+const sal_uInt8 EXC_TOK_NLR_SROWV = 0x0E; /// Stacked NLR: Value in row.
+const sal_uInt8 EXC_TOK_NLR_SCOLV = 0x0F; /// Stacked NLR: Value in column.
+const sal_uInt8 EXC_TOK_NLR_RANGEERR = 0x10; /// NLR: Invalid/deleted range.
+const sal_uInt8 EXC_TOK_NLR_SXNAME = 0x1D; /// NLR: Pivot table name.
+const sal_uInt16 EXC_TOK_NLR_REL = 0x8000; /// True = Natural language ref is relative.
+
+const sal_uInt32 EXC_TOK_NLR_ADDREL = 0x80000000; /// NLR relative (in appended data).
+const sal_uInt32 EXC_TOK_NLR_ADDMASK = 0x3FFFFFFF; /// Mask for number of appended ranges.
+
+// ----------------------------------------------------------------------------
+
+/** Type of a formula. */
+enum XclFormulaType
+{
+ EXC_FMLATYPE_CELL, /// Simple cell formula, also used in change tracking.
+ EXC_FMLATYPE_MATRIX, /// Matrix (array) formula.
+ EXC_FMLATYPE_SHARED, /// Shared formula.
+ EXC_FMLATYPE_CONDFMT, /// Conditional format.
+ EXC_FMLATYPE_DATAVAL, /// Data validation.
+ EXC_FMLATYPE_NAME, /// Defined name.
+ EXC_FMLATYPE_CHART, /// Chart source ranges.
+ EXC_FMLATYPE_CONTROL, /// Spreadsheet links in form controls.
+ EXC_FMLATYPE_WQUERY, /// Web query source range.
+ EXC_FMLATYPE_LISTVAL /// List (cell range) validation.
+};
+
+// Function data ==============================================================
+
+const sal_uInt8 EXC_FUNC_MAXPARAM = 30; /// Maximum parameter count.
+
+const sal_uInt8 EXC_FUNC_PAR_CALCONLY = 0xFD; /// Placeholder for a parameter existing in Calc, but not in Excel.
+const sal_uInt8 EXC_FUNC_PAR_EXCELONLY = 0xFE; /// Placeholder for a parameter existing in Excel, but not in Calc.
+const sal_uInt8 EXC_FUNC_PAR_INVALID = 0xFF; /// Placeholder for an invalid token class.
+
+const sal_uInt8 EXC_FUNCINFO_CLASSCOUNT = 5; /// Number of token class entries.
+
+const sal_uInt8 EXC_FUNCFLAG_VOLATILE = 0x01; /// Result is volatile (e.g. NOW() function).
+const sal_uInt8 EXC_FUNCFLAG_IMPORTONLY = 0x02; /// Only used in import filter.
+const sal_uInt8 EXC_FUNCFLAG_EXPORTONLY = 0x04; /// Only used in export filter.
+
+// selected function IDs
+const sal_uInt16 EXC_FUNCID_IF = 1;
+const sal_uInt16 EXC_FUNCID_SUM = 4;
+const sal_uInt16 EXC_FUNCID_AND = 36;
+const sal_uInt16 EXC_FUNCID_OR = 37;
+const sal_uInt16 EXC_FUNCID_CHOOSE = 100;
+const sal_uInt16 EXC_FUNCID_EXTERNCALL = 255;
+
+/** Represents information for a spreadsheet function for import and export.
+
+ The member mpnParamClass contains an array of token classes for each
+ parameter of the function. The last existing (non-null) value in this array
+ is used for all following parameters used in a function. Additionally to
+ the three actual token classes, this array may contain the special values
+ EXC_FUNC_PAR_CALCONLY, EXC_FUNC_PAR_EXCELONLY, and EXC_FUNC_PAR_INVALID.
+ The former two specify parameters only existing in one of the applications.
+ EXC_FUNC_PAR_INVALID is simply a terminator for the array to prevent that
+ the last token class or special value is repeated for additional parameters.
+ */
+struct XclFunctionInfo
+{
+ OpCode meOpCode; /// Calc function opcode.
+ sal_uInt16 mnXclFunc; /// Excel function index.
+ sal_uInt8 mnMinParamCount; /// Minimum number of parameters.
+ sal_uInt8 mnMaxParamCount; /// Maximum number of parameters.
+ sal_uInt8 mnRetClass; /// Token class of the return value.
+ sal_uInt8 mpnParamClass[ EXC_FUNCINFO_CLASSCOUNT ]; /// Expected token classes of parameters.
+ sal_uInt8 mnFlags; /// Additional flags.
+ const sal_Char* mpcMacroName; /// Function name, if simulated by a macro call (UTF-8).
+
+ /** Returns true, if the function is volatile. */
+ inline bool IsVolatile() const { return ::get_flag( mnFlags, EXC_FUNCFLAG_VOLATILE ); }
+ /** Returns true, if the function is simulated by a macro call. */
+ inline bool IsMacroFunc() const { return mpcMacroName != 0; }
+ /** Returns the name of the external function as string. */
+ String GetMacroFuncName() const;
+};
+
+// ----------------------------------------------------------------------------
+
+class XclRoot;
+
+/** Provides access to function info structs for all available functions. */
+class XclFunctionProvider
+{
+public:
+ explicit XclFunctionProvider( const XclRoot& rRoot );
+
+ /** Returns the function data for an Excel function index, or 0 on error. */
+ const XclFunctionInfo* GetFuncInfoFromXclFunc( sal_uInt16 nXclFunc ) const;
+ /** Returns the function data for an Excel function simulated by a macro call, or 0 on error. */
+ const XclFunctionInfo* GetFuncInfoFromXclMacroName( const String& rXclMacroName ) const;
+ /** Returns the function data for a Calc opcode, or 0 on error. */
+ const XclFunctionInfo* GetFuncInfoFromOpCode( OpCode eOpCode ) const;
+
+private:
+ void FillXclFuncMap( const XclFunctionInfo* pBeg, const XclFunctionInfo* pEnd );
+ void FillScFuncMap( const XclFunctionInfo* pBeg, const XclFunctionInfo* pEnd );
+
+private:
+ typedef ::std::map< sal_uInt16, const XclFunctionInfo* > XclFuncMap;
+ typedef ::std::map< String, const XclFunctionInfo* > XclMacroNameMap;
+ typedef ::std::map< OpCode, const XclFunctionInfo* > ScFuncMap;
+
+ XclFuncMap maXclFuncMap; /// Maps Excel function indexes to function data.
+ XclMacroNameMap maXclMacroNameMap; /// Maps macro function names to function data.
+ ScFuncMap maScFuncMap; /// Maps Calc opcodes to function data.
+};
+
+// Token array ================================================================
+
+class XclImpStream;
+class XclExpStream;
+
+/** Binary representation of an Excel token array. */
+class XclTokenArray
+{
+public:
+ /** Creates an empty token array. */
+ explicit XclTokenArray( bool bVolatile = false );
+ /** Creates a token array, swaps passed token vector into own data. */
+ explicit XclTokenArray( ScfUInt8Vec& rTokVec, bool bVolatile = false,
+ ScfUInt8Vec* pExtensionTokens = NULL);
+
+ /** Returns true, if the token array is empty. */
+ inline bool Empty() const { return maTokVec.empty(); }
+ /** Returns the size of the token array in bytes. */
+ sal_uInt16 GetSize() const;
+ /** Returns read-only access to the byte vector storing token data. */
+ inline const sal_uInt8* GetData() const { return maTokVec.empty() ? 0 : &maTokVec.front(); }
+ /** Returns true, if the formula contains a volatile function. */
+ inline bool IsVolatile() const { return mbVolatile; }
+
+ /** Reads the size field of the token array. */
+ void ReadSize( XclImpStream& rStrm );
+ /** Reads the tokens of the token array (without size field). */
+ void ReadArray( XclImpStream& rStrm );
+ /** Reads size field and the tokens. */
+ void Read( XclImpStream& rStrm );
+
+ /** Writes the size field of the token array. */
+ void WriteSize( XclExpStream& rStrm ) const;
+ /** Writes the tokens of the token array (without size field). */
+ void WriteArray( XclExpStream& rStrm ) const;
+ /** Writes size field and the tokens. */
+ void Write( XclExpStream& rStrm ) const;
+
+ /** Compares this token array with the passed. */
+ bool operator==( const XclTokenArray& rTokArr ) const;
+
+private:
+ ScfUInt8Vec maTokVec; /// Byte vector containing token data.
+ ScfUInt8Vec maExtensions; /// Byte vector of extensions (eg inline arrays)
+ bool mbVolatile; /// True = Formula contains volatile function.
+};
+
+typedef ScfRef< XclTokenArray > XclTokenArrayRef;
+
+/** Calls the Read() function at the passed token array. */
+XclImpStream& operator>>( XclImpStream& rStrm, XclTokenArray& rTokArr );
+/** Calls the Read() function at the passed token array. */
+XclImpStream& operator>>( XclImpStream& rStrm, XclTokenArrayRef& rxTokArr );
+/** Calls the Write() function at the passed token array. */
+XclExpStream& operator<<( XclExpStream& rStrm, const XclTokenArray& rTokArr );
+/** Calls the Write() function at the passed token array. */
+XclExpStream& operator<<( XclExpStream& rStrm, const XclTokenArrayRef& rxTokArr );
+
+// ----------------------------------------------------------------------------
+
+namespace formula
+{
+ class FormulaToken;
+}
+class ScTokenArray;
+
+/** Special token array iterator for the Excel filters.
+
+ Iterates over a Calc token array without modifying it (therefore the
+ iterator can be used with constant token arrays).
+
+ Usage: Construct a new iterator object and pass a Calc token array, or use
+ the Init() function to assign another Calc token array. As long as the Is()
+ function returns true, the accessor functions can be used to get the
+ current Calc token.
+ */
+class XclTokenArrayIterator
+{
+public:
+ explicit XclTokenArrayIterator();
+ explicit XclTokenArrayIterator( const ScTokenArray& rScTokArr, bool bSkipSpaces );
+ /** Copy constructor that allowa to change the skip-spaces mode. */
+ explicit XclTokenArrayIterator( const XclTokenArrayIterator& rTokArrIt, bool bSkipSpaces );
+
+ void Init();
+ void Init( const ScTokenArray& rScTokArr, bool bSkipSpaces );
+
+ inline bool Is() const { return mppScToken != 0; }
+ inline bool operator!() const { return !Is(); }
+ inline const formula::FormulaToken* Get() const { return mppScToken ? *mppScToken : 0; }
+ inline const formula::FormulaToken* operator->() const { return Get(); }
+ inline const formula::FormulaToken& operator*() const { return *Get(); }
+
+ XclTokenArrayIterator& operator++();
+
+private:
+ void NextRawToken();
+ void SkipSpaces();
+
+private:
+ const formula::FormulaToken*const* mppScTokenBeg; /// Pointer to first token pointer of token array.
+ const formula::FormulaToken*const* mppScTokenEnd; /// Pointer behind last token pointer of token array.
+ const formula::FormulaToken*const* mppScToken; /// Pointer to current token pointer of token array.
+ bool mbSkipSpaces; /// true = Skip whitespace tokens.
+};
+
+// ----------------------------------------------------------------------------
+
+/** Contains all cell references that can be extracted from a multiple operations formula. */
+struct XclMultipleOpRefs
+{
+ ScAddress maFmlaScPos; /// Position of the (first) formula cell.
+ ScAddress maColFirstScPos;
+ ScAddress maColRelScPos;
+ ScAddress maRowFirstScPos;
+ ScAddress maRowRelScPos;
+ bool mbDblRefMode; /// true = One formula with row and column values.
+};
+
+// ----------------------------------------------------------------------------
+
+/** A helper with Excel specific token array functions.
+
+ The purpose to not add these functions to ScTokenArray is to prevent code
+ changes in low-level Calc headers and to keep the Excel specific source
+ code in the filter directory. Deriving from ScTokenArray is not viable
+ because that would need expensive copy-constructions of the token arrays.
+ */
+class XclTokenArrayHelper
+{
+public:
+ // token identifiers ------------------------------------------------------
+
+ /** Returns the base token ID of the passed (classified) token ID. */
+ inline static sal_uInt8 GetBaseTokenId( sal_uInt8 nTokenId ) { return nTokenId & EXC_TOKID_MASK; }
+ /** Returns the classified token ID from a base ID and the token class. */
+ inline static sal_uInt8 GetTokenId( sal_uInt8 nBaseId, sal_uInt8 nTokenClass );
+
+ /** Returns the token class of the passed token ID. */
+ inline static sal_uInt8 GetTokenClass( sal_uInt8 nTokenId ) { return nTokenId & EXC_TOKCLASS_MASK; }
+ /** Changes the token class in the passed classified token ID. */
+ inline static void ChangeTokenClass( sal_uInt8& rnTokenId, sal_uInt8 nTokenClass );
+
+ // strings and string lists -----------------------------------------------
+
+ /** Tries to extract a string from the passed token.
+ @param rString (out-parameter) The string contained in the token.
+ @return true = Passed token is a string token, rString parameter is valid. */
+ static bool GetTokenString( String& rString, const formula::FormulaToken& rScToken );
+
+ /** Parses the passed formula and tries to find a single string token, i.e. "abc".
+ @param rString (out-parameter) The string contained in the formula.
+ @return true = String token found, rString parameter is valid. */
+ static bool GetString( String& rString, const ScTokenArray& rScTokArr );
+
+ /** Parses the passed formula and tries to find a string token list, i.e. "abc";"def";"ghi".
+ @descr Returns the unquoted (!) strings in a single string, separated with the
+ passed character. If a comma is specified, the function will return abc,def,ghi from
+ the example above.
+ @param rStringList (out-parameter) All strings contained in the formula as list.
+ @param cSep List separator character.
+ @return true = String token list found, rString parameter is valid. */
+ static bool GetStringList( String& rStringList, const ScTokenArray& rScTokArr, sal_Unicode cSep );
+
+ /** Tries to convert a formula that consists of a single string token to a list of strings.
+ @descr Example: The formula ="abc\ndef\nghi" will be converted to the formula
+ ="abc";"def";"ghi", if the LF character is specified as separator.
+ @param rScTokArr (in/out-parameter) The token array to modify.
+ @param cStringSep The separator in the source string.
+ @param bTrimLeadingSpaces true = remove leading spaces from each token. */
+ static void ConvertStringToList( ScTokenArray& rScTokArr, sal_Unicode cStringSep, bool bTrimLeadingSpaces );
+
+ // shared formulas --------------------------------------------------------
+
+ /** Tries to extract the definition of a shared formula from the passed token array.
+ @descr Shared formulas are stored as hidden defined names in Calc. This
+ function looks if the passed token array consists of the reference to
+ such a hidden defined name and returns its definition on success. */
+ static const ScTokenArray* GetSharedFormula( const XclRoot& rRoot, const ScTokenArray& rScTokArr );
+
+ // multiple operations ----------------------------------------------------
+
+ /** Parses the passed formula and tries to extract references of a multiple operation.
+ @descr Requires that the formula contains a single MULTIPLE.OPERATION function call.
+ Spaces in the formula are silently ignored.
+ @return true = Multiple operation found, and all references successfully extracted. */
+ static bool GetMultipleOpRefs( XclMultipleOpRefs& rRefs, const ScTokenArray& rScTokArr );
+};
+
+// ----------------------------------------------------------------------------
+
+inline sal_uInt8 XclTokenArrayHelper::GetTokenId( sal_uInt8 nBaseId, sal_uInt8 nTokenClass )
+{
+ DBG_ASSERT( !::get_flag( nBaseId, static_cast< sal_uInt8 >( ~EXC_TOKID_MASK ) ), "XclTokenArrayHelper::GetTokenId - invalid token ID" );
+ DBG_ASSERT( !::get_flag( nTokenClass, static_cast< sal_uInt8 >( ~EXC_TOKCLASS_MASK ) ), "XclTokenArrayHelper::GetTokenId - invalid token class" );
+ return nBaseId | nTokenClass;
+}
+
+inline void XclTokenArrayHelper::ChangeTokenClass( sal_uInt8& rnTokenId, sal_uInt8 nTokenClass )
+{
+ DBG_ASSERT( !::get_flag( nTokenClass, static_cast< sal_uInt8 >( ~EXC_TOKCLASS_MASK ) ), "XclTokenArrayHelper::ChangeTokenClass - invalid token class" );
+ ::set_flag( rnTokenId, EXC_TOKCLASS_MASK, false );
+ ::set_flag( rnTokenId, nTokenClass );
+}
+
+// ============================================================================
+
+#endif
+
diff --git a/sc/source/filter/xml/XMLStylesExportHelper.cxx b/sc/source/filter/xml/XMLStylesExportHelper.cxx
index c38c01f7efec..bc607c0a2ab0 100644
--- a/sc/source/filter/xml/XMLStylesExportHelper.cxx
+++ b/sc/source/filter/xml/XMLStylesExportHelper.cxx
@@ -1,1245 +1,1245 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: XMLStylesExportHelper.cxx,v $
- * $Revision: 1.52 $
- *
- * 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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sc.hxx"
-
-
-// INCLUDE ---------------------------------------------------------------
-#include "XMLStylesExportHelper.hxx"
-#include "global.hxx"
-#include "unonames.hxx"
-#include "XMLConverter.hxx"
-#include "xmlexprt.hxx"
-#include "document.hxx"
-#include "rangeutl.hxx"
-#include <xmloff/xmltoken.hxx>
-#include <xmloff/xmlnmspe.hxx>
-#include <xmloff/XMLEventExport.hxx>
-#include <xmloff/nmspmap.hxx>
-#include <tools/debug.hxx>
-#include <com/sun/star/uno/Reference.h>
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/sheet/XSheetCondition.hpp>
-#include <com/sun/star/sheet/TableValidationVisibility.hpp>
-#include <comphelper/extract.hxx>
-#include <sfx2/app.hxx>
-
-#include <algorithm>
-
-using namespace com::sun::star;
-using namespace xmloff::token;
-
-ScMyValidation::ScMyValidation()
- : sName(),
- sErrorMessage(),
- sErrorTitle(),
- sImputMessage(),
- sImputTitle(),
- sFormula1(),
- sFormula2(),
- bShowErrorMessage(sal_False),
- bShowImputMessage(sal_False),
- bIgnoreBlanks(sal_False)
-{
-}
-
-ScMyValidation::~ScMyValidation()
-{
-}
-
-sal_Bool ScMyValidation::IsEqual(const ScMyValidation& aVal) const
-{
- if (aVal.bIgnoreBlanks == bIgnoreBlanks &&
- aVal.bShowImputMessage == bShowImputMessage &&
- aVal.bShowErrorMessage == bShowErrorMessage &&
- aVal.aBaseCell.Sheet == aBaseCell.Sheet &&
- aVal.aBaseCell.Column == aBaseCell.Column &&
- aVal.aBaseCell.Row == aBaseCell.Row &&
- aVal.aAlertStyle == aAlertStyle &&
- aVal.aValidationType == aValidationType &&
- aVal.aOperator == aOperator &&
- aVal.sErrorTitle == sErrorTitle &&
- aVal.sImputTitle == sImputTitle &&
- aVal.sErrorMessage == sErrorMessage &&
- aVal.sImputMessage == sImputMessage &&
- aVal.sFormula1 == sFormula1 &&
- aVal.sFormula2 == sFormula2)
- return sal_True;
- else
- return sal_False;
-}
-
-ScMyValidationsContainer::ScMyValidationsContainer()
- : aValidationVec(),
- sEmptyString(),
- sERRALSTY(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRALSTY)),
- sIGNOREBL(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_IGNOREBL)),
- sSHOWLIST(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SHOWLIST)),
- sTYPE(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_TYPE)),
- sSHOWINP(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SHOWINP)),
- sSHOWERR(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SHOWERR)),
- sINPTITLE(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_INPTITLE)),
- sINPMESS(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_INPMESS)),
- sERRTITLE(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRTITLE)),
- sERRMESS(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRMESS)),
- sOnError(RTL_CONSTASCII_USTRINGPARAM("OnError")),
- sEventType(RTL_CONSTASCII_USTRINGPARAM("EventType")),
- sStarBasic(RTL_CONSTASCII_USTRINGPARAM("StarBasic")),
- sScript(RTL_CONSTASCII_USTRINGPARAM("Script")),
- sLibrary(RTL_CONSTASCII_USTRINGPARAM("Library")),
- sMacroName(RTL_CONSTASCII_USTRINGPARAM("MacroName"))
-{
-}
-
-ScMyValidationsContainer::~ScMyValidationsContainer()
-{
-}
-
-sal_Bool ScMyValidationsContainer::AddValidation(const uno::Any& aTempAny,
- sal_Int32& nValidationIndex)
-{
- sal_Bool bAdded(sal_False);
- uno::Reference<beans::XPropertySet> xPropertySet(aTempAny, uno::UNO_QUERY);
- if (xPropertySet.is())
- {
- rtl::OUString sErrorMessage;
- xPropertySet->getPropertyValue(sERRMESS) >>= sErrorMessage;
- rtl::OUString sErrorTitle;
- xPropertySet->getPropertyValue(sERRTITLE) >>= sErrorTitle;
- rtl::OUString sImputMessage;
- xPropertySet->getPropertyValue(sINPMESS) >>= sImputMessage;
- rtl::OUString sImputTitle;
- xPropertySet->getPropertyValue(sINPTITLE) >>= sImputTitle;
- sal_Bool bShowErrorMessage = ::cppu::any2bool(xPropertySet->getPropertyValue(sSHOWERR));
- sal_Bool bShowImputMessage = ::cppu::any2bool(xPropertySet->getPropertyValue(sSHOWINP));
- sheet::ValidationType aValidationType;
- xPropertySet->getPropertyValue(sTYPE) >>= aValidationType;
- if (bShowErrorMessage || bShowImputMessage || aValidationType != sheet::ValidationType_ANY ||
- sErrorMessage.getLength() || sErrorTitle.getLength() || sImputMessage.getLength() || sImputTitle.getLength())
- {
- ScMyValidation aValidation;
- aValidation.sErrorMessage = sErrorMessage;
- aValidation.sErrorTitle = sErrorTitle;
- aValidation.sImputMessage = sImputMessage;
- aValidation.sImputTitle = sImputTitle;
- aValidation.bShowErrorMessage = bShowErrorMessage;
- aValidation.bShowImputMessage = bShowImputMessage;
- aValidation.aValidationType = aValidationType;
- aValidation.bIgnoreBlanks = ::cppu::any2bool(xPropertySet->getPropertyValue(sIGNOREBL));
- xPropertySet->getPropertyValue(sSHOWLIST) >>= aValidation.nShowList;
- xPropertySet->getPropertyValue(sERRALSTY) >>= aValidation.aAlertStyle;
- uno::Reference<sheet::XSheetCondition> xCondition(xPropertySet, uno::UNO_QUERY);
- if (xCondition.is())
- {
- aValidation.sFormula1 = xCondition->getFormula1();
- aValidation.sFormula2 = xCondition->getFormula2();
- aValidation.aOperator = xCondition->getOperator();
- aValidation.aBaseCell = xCondition->getSourcePosition();
- }
- //ScMyValidationRange aValidationRange;
- sal_Bool bEqualFound(sal_False);
- sal_Int32 i(0);
- sal_Int32 nCount(aValidationVec.size());
- while (i < nCount && !bEqualFound)
- {
- bEqualFound = aValidationVec[i].IsEqual(aValidation);
- if (!bEqualFound)
- ++i;
- }
- if (bEqualFound)
- nValidationIndex = i;
- else
- {
- sal_Int32 nNameIndex(nCount + 1);
- rtl::OUString sCount(rtl::OUString::valueOf(nNameIndex));
- rtl::OUString sPrefix(RTL_CONSTASCII_USTRINGPARAM("val"));
- aValidation.sName += sPrefix;
- aValidation.sName += sCount;
- aValidationVec.push_back(aValidation);
- nValidationIndex = nCount;
- bAdded = sal_True;
- }
- }
- }
- return bAdded;
-}
-
-rtl::OUString ScMyValidationsContainer::GetCondition(ScXMLExport& rExport, const ScMyValidation& aValidation)
-{
- rtl::OUString sCondition;
- if (aValidation.aValidationType != sheet::ValidationType_ANY)
- {
- switch (aValidation.aValidationType)
- {
- //case sheet::ValidationType_CUSTOM
- case sheet::ValidationType_DATE :
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-date()"));
- break;
- case sheet::ValidationType_DECIMAL :
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-decimal-number()"));
- break;
- case sheet::ValidationType_LIST :
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-in-list("));
- sCondition += aValidation.sFormula1;
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")"));
- break;
- case sheet::ValidationType_TEXT_LEN :
- if (aValidation.aOperator != sheet::ConditionOperator_BETWEEN &&
- aValidation.aOperator != sheet::ConditionOperator_NOT_BETWEEN)
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length()"));
- break;
- case sheet::ValidationType_TIME :
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-time()"));
- break;
- case sheet::ValidationType_WHOLE :
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-whole-number()"));
- break;
- default:
- {
- // added to avoid warnings
- }
- }
- if (aValidation.aValidationType != sheet::ValidationType_LIST &&
- (aValidation.sFormula1.getLength() ||
- (aValidation.aOperator == sheet::ConditionOperator_BETWEEN &&
- aValidation.aOperator == sheet::ConditionOperator_NOT_BETWEEN &&
- aValidation.sFormula2.getLength())))
- {
- if (aValidation.aValidationType != sheet::ValidationType_TEXT_LEN)
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" and "));
- if (aValidation.aOperator != sheet::ConditionOperator_BETWEEN &&
- aValidation.aOperator != sheet::ConditionOperator_NOT_BETWEEN)
- {
- if (aValidation.aValidationType != sheet::ValidationType_TEXT_LEN)
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content()"));
- switch (aValidation.aOperator)
- {
- case sheet::ConditionOperator_EQUAL :
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("="));
- break;
- case sheet::ConditionOperator_GREATER :
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">"));
- break;
- case sheet::ConditionOperator_GREATER_EQUAL :
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">="));
- break;
- case sheet::ConditionOperator_LESS :
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<"));
- break;
- case sheet::ConditionOperator_LESS_EQUAL :
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<="));
- break;
- case sheet::ConditionOperator_NOT_EQUAL :
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("!="));
- break;
- default:
- {
- // added to avoid warnings
- }
- }
- sCondition += aValidation.sFormula1;
- }
- else
- {
- if (aValidation.aValidationType == sheet::ValidationType_TEXT_LEN)
- {
- if (aValidation.aOperator == sheet::ConditionOperator_BETWEEN)
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-between("));
- else
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-not-between("));
- }
- else
- {
- if (aValidation.aOperator == sheet::ConditionOperator_BETWEEN)
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-between("));
- else
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-not-between("));
- }
- sCondition += aValidation.sFormula1;
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(","));
- sCondition += aValidation.sFormula2;
- sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")"));
- }
- }
- else
- if (aValidation.aValidationType == sheet::ValidationType_TEXT_LEN)
- sCondition = rtl::OUString();
- }
- if (sCondition.getLength())
- {
- const formula::FormulaGrammar::Grammar eGrammar = rExport.GetDocument()->GetStorageGrammar();
- sal_uInt16 nNamespacePrefix = (eGrammar == formula::FormulaGrammar::GRAM_ODFF ? XML_NAMESPACE_OF : XML_NAMESPACE_OOOC);
- sCondition = rExport.GetNamespaceMap().GetQNameByKey( nNamespacePrefix, sCondition, sal_False );
- }
-
- return sCondition;
-}
-
-rtl::OUString ScMyValidationsContainer::GetBaseCellAddress(ScDocument* pDoc, const table::CellAddress& aCell)
-{
- rtl::OUString sAddress;
- ScRangeStringConverter::GetStringFromAddress( sAddress, aCell, pDoc );
- return sAddress;
-}
-
-void ScMyValidationsContainer::WriteMessage(ScXMLExport& rExport,
- const rtl::OUString& sTitle, const rtl::OUString& sOUMessage,
- const sal_Bool bShowMessage, const sal_Bool bIsHelpMessage)
-{
- if (sTitle.getLength())
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TITLE, sTitle);
- if (bShowMessage)
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, XML_TRUE);
- else
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, XML_FALSE);
- SvXMLElementExport* pMessage(NULL);
- if (bIsHelpMessage)
- pMessage = new SvXMLElementExport(rExport, XML_NAMESPACE_TABLE, XML_HELP_MESSAGE, sal_True, sal_True);
- else
- pMessage = new SvXMLElementExport(rExport, XML_NAMESPACE_TABLE, XML_ERROR_MESSAGE, sal_True, sal_True);
- if (sOUMessage.getLength())
- {
- sal_Int32 i(0);
- rtl::OUStringBuffer sTemp;
- String sMessage(sOUMessage);
- rtl::OUString sText (sMessage.ConvertLineEnd(LINEEND_LF));
- sal_Bool bPrevCharWasSpace(sal_True);
- while(i < sText.getLength())
- {
- if ((sText[i] == '\n'))
- {
- SvXMLElementExport aElemP(rExport, XML_NAMESPACE_TEXT, XML_P, sal_True, sal_False);
- rExport.GetTextParagraphExport()->exportText(sTemp.makeStringAndClear(), bPrevCharWasSpace);
- }
- else
- sTemp.append(sText[i]);
- ++i;
- }
- if (sTemp.getLength())
- {
- SvXMLElementExport aElemP(rExport, XML_NAMESPACE_TEXT, XML_P, sal_True, sal_False);
- rExport.GetTextParagraphExport()->exportText(sTemp.makeStringAndClear(), bPrevCharWasSpace);
- }
- }
- if (pMessage)
- delete pMessage;
-}
-
-void ScMyValidationsContainer::WriteValidations(ScXMLExport& rExport)
-{
- if (aValidationVec.size())
- {
- SvXMLElementExport aElemVs(rExport, XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATIONS, sal_True, sal_True);
- ScMyValidationVec::iterator aItr(aValidationVec.begin());
- ScMyValidationVec::iterator aEndItr(aValidationVec.end());
- while (aItr != aEndItr)
- {
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, aItr->sName);
- rtl::OUString sCondition(GetCondition(rExport, *aItr));
- if (sCondition.getLength())
- {
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CONDITION, sCondition);
- if (aItr->bIgnoreBlanks)
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ALLOW_EMPTY_CELL, XML_TRUE);
- else
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ALLOW_EMPTY_CELL, XML_FALSE);
- if (aItr->aValidationType == sheet::ValidationType_LIST)
- {
- switch (aItr->nShowList)
- {
- case sheet::TableValidationVisibility::INVISIBLE:
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_LIST, XML_NO);
- break;
- case sheet::TableValidationVisibility::UNSORTED:
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_LIST, XML_UNSORTED);
- break;
- case sheet::TableValidationVisibility::SORTEDASCENDING:
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_LIST, XML_SORTED_ASCENDING);
- break;
- default:
- DBG_ERROR("unknown ListType");
- }
- }
- }
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, GetBaseCellAddress(rExport.GetDocument(), aItr->aBaseCell));
- SvXMLElementExport aElemV(rExport, XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION, sal_True, sal_True);
- if (aItr->bShowImputMessage || aItr->sImputMessage.getLength() || aItr->sImputTitle.getLength())
- {
- WriteMessage(rExport, aItr->sImputTitle, aItr->sImputMessage, aItr->bShowImputMessage, sal_True);
- }
- if (aItr->bShowErrorMessage || aItr->sErrorMessage.getLength() || aItr->sErrorTitle.getLength())
- {
- switch (aItr->aAlertStyle)
- {
- case sheet::ValidationAlertStyle_INFO :
- {
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_INFORMATION);
- WriteMessage(rExport, aItr->sErrorTitle, aItr->sErrorMessage, aItr->bShowErrorMessage, sal_False);
- }
- break;
- case sheet::ValidationAlertStyle_WARNING :
- {
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_WARNING);
- WriteMessage(rExport, aItr->sErrorTitle, aItr->sErrorMessage, aItr->bShowErrorMessage, sal_False);
- }
- break;
- case sheet::ValidationAlertStyle_STOP :
- {
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_STOP);
- WriteMessage(rExport, aItr->sErrorTitle, aItr->sErrorMessage, aItr->bShowErrorMessage, sal_False);
- }
- break;
- case sheet::ValidationAlertStyle_MACRO :
- {
- {
- //rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, aItr->sErrorTitle);
- if (aItr->bShowErrorMessage)
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_EXECUTE, XML_TRUE);
- else
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_EXECUTE, XML_FALSE);
- SvXMLElementExport aEMElem(rExport, XML_NAMESPACE_TABLE, XML_ERROR_MACRO, sal_True, sal_True);
- }
- {
- // #i47525# for a script URL the type and the property name for the URL
- // are both "Script", for a simple macro name the type is "StarBasic"
- // and the property name is "MacroName".
- bool bScriptURL = SfxApplication::IsXScriptURL( aItr->sErrorTitle );
-
- uno::Sequence<beans::PropertyValue> aSeq(3);
- beans::PropertyValue* pArr(aSeq.getArray());
- pArr[0].Name = sEventType;
- pArr[0].Value <<= bScriptURL ? sScript : sStarBasic;
- pArr[1].Name = sLibrary;
- pArr[1].Value <<= sEmptyString;
- pArr[2].Name = bScriptURL ? sScript : sMacroName;
- pArr[2].Value <<= aItr->sErrorTitle;
-
- // 2) export the sequence
- rExport.GetEventExport().ExportSingleEvent( aSeq, sOnError);
- }
- }
- break;
- default:
- {
- // added to avoid warnings
- }
- }
- }
- ++aItr;
- }
- }
-}
-
-const rtl::OUString& ScMyValidationsContainer::GetValidationName(const sal_Int32 nIndex)
-{
- DBG_ASSERT( static_cast<size_t>(nIndex) < aValidationVec.size(), "out of range" );
- return aValidationVec[nIndex].sName;
-}
-
-//==============================================================================
-
-sal_Int32 ScMyDefaultStyles::GetStyleNameIndex(const ScFormatRangeStyles* pCellStyles,
- const sal_Int32 nTable, const sal_Int32 nPos,
- const sal_Int32 i, const sal_Bool bRow, sal_Bool& bIsAutoStyle)
-{
- if (bRow)
- return pCellStyles->GetStyleNameIndex(nTable, nPos, i,
- bIsAutoStyle);
- else
- return pCellStyles->GetStyleNameIndex(nTable, i, nPos,
- bIsAutoStyle);
-}
-
-void ScMyDefaultStyles::FillDefaultStyles(const sal_Int32 nTable,
- const sal_Int32 nLastRow, const sal_Int32 nLastCol,
- const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc,
- const sal_Bool bRow)
-{
- if (pDoc)
- {
- SCTAB nTab = static_cast<SCTAB>(nTable);
- sal_Int32 nPos;
- sal_Int32 nLast;
- ScMyDefaultStyleList* pDefaults;
- if (bRow)
- {
- pDefaults = pRowDefaults;
- nLast = nLastRow;
- }
- else
- {
- pDefaults = pColDefaults;
- nLast = nLastCol;
- }
- sal_Bool bPrevAutoStyle(sal_False);
- sal_Bool bIsAutoStyle;
- sal_Bool bResult;
- sal_Int32 nPrevIndex(0);
- sal_Int32 nIndex;
- sal_Int32 nRepeat(0);
- sal_Int32 nEmptyRepeat(0);
- for (sal_Int32 i = nLast; i >= 0; --i)
- {
- if (bRow)
- {
- SCCOL nCol;
- bResult = pDoc->GetRowDefault(nTab,
- static_cast<SCROW>(i), static_cast<SCCOL>(nLastCol), nCol);
- nPos = static_cast<sal_Int32>(nCol);
- }
- else
- {
- SCROW nRow;
- bResult = pDoc->GetColDefault(nTab,
- static_cast<SCCOL>(i), static_cast<SCROW>(nLastRow), nRow);
- nPos = static_cast<sal_Int32>(nRow);
- }
- if (bResult)
- {
- nEmptyRepeat = 0;
- if (!nRepeat)
- {
- nPrevIndex = GetStyleNameIndex(pCellStyles, nTab, nPos, i,
- bRow, bPrevAutoStyle);
- (*pDefaults)[i].nIndex = nPrevIndex;
- (*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle;
- nRepeat = 1;
- }
- else
- {
- nIndex = GetStyleNameIndex(pCellStyles, nTab, nPos, i,
- bRow, bIsAutoStyle);
- if ((nIndex != nPrevIndex) || (bIsAutoStyle != bPrevAutoStyle))
- {
- nRepeat = 1;
- nPrevIndex = GetStyleNameIndex(pCellStyles, nTab, nPos, i,
- bRow, bPrevAutoStyle);
- (*pDefaults)[i].nIndex = nPrevIndex;
- (*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle;
- }
- else
- {
- (*pDefaults)[i].nIndex = nPrevIndex;
- (*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle;
- ++nRepeat;
- if (nRepeat > 1)
- (*pDefaults)[i].nRepeat = nRepeat;
- }
- }
- }
- else
- {
- nRepeat = 0;
- if (!nEmptyRepeat)
- nEmptyRepeat = 1;
- else
- {
- ++nEmptyRepeat;
- if (nEmptyRepeat > 1)
- (*pDefaults)[i].nRepeat = nEmptyRepeat;
- }
- }
- }
- }
-}
-
-void ScMyDefaultStyles::FillDefaultStyles(const sal_Int32 nTable,
- const sal_Int32 nLastRow, const sal_Int32 nLastCol,
- const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc)
-{
- if (pRowDefaults)
- delete pRowDefaults;
- pRowDefaults = new ScMyDefaultStyleList(nLastRow + 1);
- FillDefaultStyles(nTable, nLastRow, nLastCol, pCellStyles, pDoc, sal_True);
- if (pColDefaults)
- delete pColDefaults;
- pColDefaults = new ScMyDefaultStyleList(nLastCol + 1);
- FillDefaultStyles(nTable, nLastRow, nLastCol, pCellStyles, pDoc, sal_False);
-}
-
-ScMyDefaultStyles::~ScMyDefaultStyles()
-{
- if (pRowDefaults)
- delete pRowDefaults;
- if (pColDefaults)
- delete pColDefaults;
-}
-
-ScMyRowFormatRange::ScMyRowFormatRange()
- : nStartColumn(0),
- nRepeatColumns(0),
- nRepeatRows(0),
- nIndex(-1),
- nValidationIndex(-1),
- bIsAutoStyle(sal_True)
-{
-}
-
-sal_Bool ScMyRowFormatRange::operator< (const ScMyRowFormatRange& rRange) const
-{
- return (nStartColumn < rRange.nStartColumn);
-}
-
-ScRowFormatRanges::ScRowFormatRanges()
- : aRowFormatRanges(),
- pRowDefaults(NULL),
- pColDefaults(NULL),
- nSize(0)
-{
-}
-
-ScRowFormatRanges::ScRowFormatRanges(const ScRowFormatRanges* pRanges)
- : aRowFormatRanges(pRanges->aRowFormatRanges),
- pRowDefaults(pRanges->pRowDefaults),
- pColDefaults(pRanges->pColDefaults),
- nSize(pRanges->nSize)
-{
-}
-
-ScRowFormatRanges::~ScRowFormatRanges()
-{
-}
-
-void ScRowFormatRanges::Clear()
-{
- aRowFormatRanges.clear();
- nSize = 0;
-}
-
-void ScRowFormatRanges::AddRange(const sal_Int32 nPrevStartCol, const sal_Int32 nRepeat, const sal_Int32 nPrevIndex,
- const sal_Bool bPrevAutoStyle, const ScMyRowFormatRange& rFormatRange)
-{
- sal_Int32 nIndex(-1);
- if ((nPrevIndex != rFormatRange.nIndex) ||
- (bPrevAutoStyle != rFormatRange.bIsAutoStyle))
- nIndex = rFormatRange.nIndex;
-
- sal_Bool bInserted(sal_False);
- if (!aRowFormatRanges.empty())
- {
- ScMyRowFormatRange* pRange(&aRowFormatRanges.back());
- if (pRange)
- {
- if ((nPrevStartCol == (pRange->nStartColumn + pRange->nRepeatColumns)) &&
- (pRange->bIsAutoStyle == rFormatRange.bIsAutoStyle) &&
- (pRange->nIndex == nIndex) &&
- (pRange->nValidationIndex == rFormatRange.nValidationIndex))
- {
- if (rFormatRange.nRepeatRows < pRange->nRepeatRows)
- pRange->nRepeatRows = rFormatRange.nRepeatRows;
- pRange->nRepeatColumns += nRepeat;
- bInserted = sal_True;
- }
- }
- }
- if (!bInserted)
- {
- ScMyRowFormatRange aRange;
- aRange.nStartColumn = nPrevStartCol;
- aRange.nRepeatColumns = nRepeat;
- aRange.nRepeatRows = rFormatRange.nRepeatRows;
- aRange.nValidationIndex = rFormatRange.nValidationIndex;
- aRange.bIsAutoStyle = rFormatRange.bIsAutoStyle;
- aRange.nIndex = nIndex;
- aRowFormatRanges.push_back(aRange);
- ++nSize;
- }
-}
-
-void ScRowFormatRanges::AddRange(ScMyRowFormatRange& rFormatRange,
- const sal_Int32 nRow)
-{
- DBG_ASSERT(pRowDefaults, "no row defaults");
- DBG_ASSERT(pColDefaults, "no column defaults");
- sal_uInt32 nEnd (rFormatRange.nRepeatRows + nRow - 1);
- sal_Int32 nPrevIndex((*pRowDefaults)[nRow].nIndex);
- sal_Bool bPrevAutoStyle((*pRowDefaults)[nRow].bIsAutoStyle);
- sal_uInt32 i(nRow + 1);
- sal_Bool bReady(sal_False);
- while ((i < nEnd) && !bReady && (i < pRowDefaults->size()))
- {
- if ((nPrevIndex != (*pRowDefaults)[i].nIndex) ||
- (bPrevAutoStyle != (*pRowDefaults)[i].bIsAutoStyle))
- bReady = sal_True;
- else
- i += (*pRowDefaults)[i].nRepeat;
- }
- if (i > nEnd)
- i = nEnd;
- if (bReady)
- rFormatRange.nRepeatRows = i - nRow + 1;
- if (nPrevIndex == -1)
- {
- nPrevIndex = (*pColDefaults)[rFormatRange.nStartColumn].nIndex;
- bPrevAutoStyle = (*pColDefaults)[rFormatRange.nStartColumn].bIsAutoStyle;
- sal_uInt32 nPrevStartCol(rFormatRange.nStartColumn);
- sal_uInt32 nRepeat((*pColDefaults)[rFormatRange.nStartColumn].nRepeat);
- nEnd = rFormatRange.nStartColumn + rFormatRange.nRepeatColumns;
- for(i = nPrevStartCol + nRepeat; i < nEnd; i += (*pColDefaults)[i].nRepeat)
- {
- DBG_ASSERT(sal_uInt32(nPrevStartCol + nRepeat) <= nEnd, "something wents wrong");
- if ((nPrevIndex != (*pColDefaults)[i].nIndex) ||
- (bPrevAutoStyle != (*pColDefaults)[i].bIsAutoStyle))
- {
- AddRange(nPrevStartCol, nRepeat, nPrevIndex, bPrevAutoStyle, rFormatRange);
- nPrevStartCol = i;
- nRepeat = (*pColDefaults)[i].nRepeat;
- nPrevIndex = (*pColDefaults)[i].nIndex;
- bPrevAutoStyle = (*pColDefaults)[i].bIsAutoStyle;
- }
- else
- nRepeat += (*pColDefaults)[i].nRepeat;
- }
- if (sal_uInt32(nPrevStartCol + nRepeat) > nEnd)
- nRepeat = nEnd - nPrevStartCol;
- AddRange(nPrevStartCol, nRepeat, nPrevIndex, bPrevAutoStyle, rFormatRange);
- }
- else if ((nPrevIndex == rFormatRange.nIndex) &&
- (bPrevAutoStyle == rFormatRange.bIsAutoStyle))
- {
- rFormatRange.nIndex = -1;
- aRowFormatRanges.push_back(rFormatRange);
- ++nSize;
- }
-}
-
-sal_Bool ScRowFormatRanges::GetNext(ScMyRowFormatRange& aFormatRange)
-{
- ScMyRowFormatRangesList::iterator aItr(aRowFormatRanges.begin());
- if (aItr != aRowFormatRanges.end())
- {
- aFormatRange = (*aItr);
- aRowFormatRanges.erase(aItr);
- --nSize;
- return sal_True;
- }
- return sal_False;
-}
-
-sal_Int32 ScRowFormatRanges::GetMaxRows()
-{
- ScMyRowFormatRangesList::iterator aItr(aRowFormatRanges.begin());
- ScMyRowFormatRangesList::iterator aEndItr(aRowFormatRanges.end());
- sal_Int32 nMaxRows = MAXROW + 1;
- if (aItr != aEndItr)
- while (aItr != aEndItr)
- {
- if ((*aItr).nRepeatRows < nMaxRows)
- nMaxRows = (*aItr).nRepeatRows;
- ++aItr;
- }
- else
- {
- DBG_ERROR("no ranges found");
- }
- return nMaxRows;
-}
-
-sal_Int32 ScRowFormatRanges::GetSize()
-{
- return nSize;
-}
-
-void ScRowFormatRanges::Sort()
-{
- aRowFormatRanges.sort();
-}
-
-// ============================================================================
-ScMyFormatRange::ScMyFormatRange()
- : nStyleNameIndex(-1),
- nValidationIndex(-1),
- bIsAutoStyle(sal_True)
-{
-}
-
-sal_Bool ScMyFormatRange::operator<(const ScMyFormatRange& rRange) const
-{
- if (aRangeAddress.StartRow < rRange.aRangeAddress.StartRow)
- return sal_True;
- else
- if (aRangeAddress.StartRow == rRange.aRangeAddress.StartRow)
- return (aRangeAddress.StartColumn < rRange.aRangeAddress.StartColumn);
- else
- return sal_False;
-}
-
-ScFormatRangeStyles::ScFormatRangeStyles()
- : aTables(),
- aStyleNames(),
- aAutoStyleNames()
-{
-}
-
-ScFormatRangeStyles::~ScFormatRangeStyles()
-{
- ScMyOUStringVec::iterator i(aStyleNames.begin());
- ScMyOUStringVec::iterator endi(aStyleNames.end());
- while (i != endi)
- {
- delete *i;
- ++i;
- }
- i = aAutoStyleNames.begin();
- endi = aAutoStyleNames.end();
- while (i != endi)
- {
- delete *i;
- ++i;
- }
- ScMyFormatRangeListVec::iterator j(aTables.begin());
- ScMyFormatRangeListVec::iterator endj(aTables.end());
- while (j != endj)
- {
- delete *j;
- ++j;
- }
-}
-
-void ScFormatRangeStyles::AddNewTable(const sal_Int32 nTable)
-{
- sal_Int32 nSize = aTables.size() - 1;
- if (nTable > nSize)
- for (sal_Int32 i = nSize; i < nTable; ++i)
- {
- ScMyFormatRangeAddresses* aRangeAddresses(new ScMyFormatRangeAddresses);
- aTables.push_back(aRangeAddresses);
- }
-}
-
-sal_Bool ScFormatRangeStyles::AddStyleName(rtl::OUString* rpString, sal_Int32& rIndex, const sal_Bool bIsAutoStyle)
-{
- if (bIsAutoStyle)
- {
- aAutoStyleNames.push_back(rpString);
- rIndex = aAutoStyleNames.size() - 1;
- return sal_True;
- }
- else
- {
- sal_Int32 nCount(aStyleNames.size());
- sal_Bool bFound(sal_False);
- sal_Int32 i(nCount - 1);
- while ((i >= 0) && (!bFound))
- {
- if (aStyleNames.at(i)->equals(*rpString))
- bFound = sal_True;
- else
- i--;
- }
- if (bFound)
- {
- rIndex = i;
- return sal_False;
- }
- else
- {
- aStyleNames.push_back(rpString);
- rIndex = aStyleNames.size() - 1;
- return sal_True;
- }
- }
-}
-
-sal_Int32 ScFormatRangeStyles::GetIndexOfStyleName(const rtl::OUString& rString, const rtl::OUString& rPrefix, sal_Bool& bIsAutoStyle)
-{
- sal_Int32 nPrefixLength(rPrefix.getLength());
- rtl::OUString sTemp(rString.copy(nPrefixLength));
- sal_Int32 nIndex(sTemp.toInt32());
- if (aAutoStyleNames.at(nIndex - 1)->equals(rString))
- {
- bIsAutoStyle = sal_True;
- return nIndex - 1;
- }
- else
- {
- sal_Int32 i(0);
- sal_Bool bFound(sal_False);
- while (!bFound && static_cast<size_t>(i) < aStyleNames.size())
- {
- if (aStyleNames[i]->equals(rString))
- bFound = sal_True;
- else
- ++i;
- }
- if (bFound)
- {
- bIsAutoStyle = sal_False;
- return i;
- }
- else
- {
- i = 0;
- while (!bFound && static_cast<size_t>(i) < aAutoStyleNames.size())
- {
- if (aAutoStyleNames[i]->equals(rString))
- bFound = sal_True;
- else
- ++i;
- }
- if (bFound)
- {
- bIsAutoStyle = sal_True;
- return i;
- }
- else
- return -1;
- }
- }
-}
-
-sal_Int32 ScFormatRangeStyles::GetStyleNameIndex(const sal_Int32 nTable,
- const sal_Int32 nColumn, const sal_Int32 nRow, sal_Bool& bIsAutoStyle) const
-{
- DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
- ScMyFormatRangeAddresses* pFormatRanges(aTables[nTable]);
- ScMyFormatRangeAddresses::iterator aItr(pFormatRanges->begin());
- ScMyFormatRangeAddresses::iterator aEndItr(pFormatRanges->end());
- while (aItr != aEndItr)
- {
- if (((*aItr).aRangeAddress.StartColumn <= nColumn) &&
- ((*aItr).aRangeAddress.EndColumn >= nColumn) &&
- ((*aItr).aRangeAddress.StartRow <= nRow) &&
- ((*aItr).aRangeAddress.EndRow >= nRow))
- {
- bIsAutoStyle = aItr->bIsAutoStyle;
- return (*aItr).nStyleNameIndex;
- }
- else
- ++aItr;
- }
- return -1;
-}
-
-sal_Int32 ScFormatRangeStyles::GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nColumn, const sal_Int32 nRow,
- sal_Bool& bIsAutoStyle, sal_Int32& nValidationIndex, sal_Int32& nNumberFormat, const sal_Bool bRemoveRange)
-{
- DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
- ScMyFormatRangeAddresses* pFormatRanges(aTables[nTable]);
- ScMyFormatRangeAddresses::iterator aItr(pFormatRanges->begin());
- ScMyFormatRangeAddresses::iterator aEndItr(pFormatRanges->end());
- while (aItr != aEndItr)
- {
- if (((*aItr).aRangeAddress.StartColumn <= nColumn) &&
- ((*aItr).aRangeAddress.EndColumn >= nColumn) &&
- ((*aItr).aRangeAddress.StartRow <= nRow) &&
- ((*aItr).aRangeAddress.EndRow >= nRow))
- {
- bIsAutoStyle = aItr->bIsAutoStyle;
- nValidationIndex = aItr->nValidationIndex;
- nNumberFormat = aItr->nNumberFormat;
- if (((*pRowDefaults)[nRow].nIndex != -1))
- {
- if (((*pRowDefaults)[nRow].nIndex == (*aItr).nStyleNameIndex) &&
- ((*pRowDefaults)[nRow].bIsAutoStyle == (*aItr).bIsAutoStyle))
- return -1;
- else
- return (*aItr).nStyleNameIndex;
- }
- else if (((*pColDefaults)[nColumn].nIndex != -1) &&
- ((*pColDefaults)[nColumn].nIndex == (*aItr).nStyleNameIndex) &&
- ((*pColDefaults)[nColumn].bIsAutoStyle == (*aItr).bIsAutoStyle))
- return -1;
- else
- return (*aItr).nStyleNameIndex;
- }
- else
- {
- if (bRemoveRange && (*aItr).aRangeAddress.EndRow < nRow)
- aItr = pFormatRanges->erase(aItr);
- else
- ++aItr;
- }
- }
- return -1;
-}
-
-void ScFormatRangeStyles::GetFormatRanges(const sal_Int32 nStartColumn, const sal_Int32 nEndColumn, const sal_Int32 nRow,
- const sal_Int32 nTable, ScRowFormatRanges* pRowFormatRanges)
-{
- sal_Int32 nTotalColumns(nEndColumn - nStartColumn + 1);
- DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
- ScMyFormatRangeAddresses* pFormatRanges(aTables[nTable]);
- ScMyFormatRangeAddresses::iterator aItr(pFormatRanges->begin());
- ScMyFormatRangeAddresses::iterator aEndItr(pFormatRanges->end());
- sal_Int32 nColumns = 0;
- while (aItr != aEndItr && nColumns < nTotalColumns)
- {
-#if OSL_DEBUG_LEVEL > 1
- table::CellRangeAddress aTempRangeAddress((*aItr).aRangeAddress);
-#endif
- if (((*aItr).aRangeAddress.StartRow <= nRow) &&
- ((*aItr).aRangeAddress.EndRow >= nRow))
- {
- if ((((*aItr).aRangeAddress.StartColumn <= nStartColumn) &&
- ((*aItr).aRangeAddress.EndColumn >= nStartColumn)) ||
- (((*aItr).aRangeAddress.StartColumn <= nEndColumn) &&
- ((*aItr).aRangeAddress.EndColumn >= nEndColumn)) ||
- (((*aItr).aRangeAddress.StartColumn >= nStartColumn) &&
- ((*aItr).aRangeAddress.EndColumn <= nEndColumn)))
- {
- ScMyRowFormatRange aRange;
- aRange.nIndex = aItr->nStyleNameIndex;
- aRange.nValidationIndex = aItr->nValidationIndex;
- aRange.bIsAutoStyle = aItr->bIsAutoStyle;
- if ((aItr->aRangeAddress.StartColumn < nStartColumn) &&
- (aItr->aRangeAddress.EndColumn >= nStartColumn))
- {
- if (aItr->aRangeAddress.EndColumn >= nEndColumn)
- aRange.nRepeatColumns = nTotalColumns;
- else
- aRange.nRepeatColumns = aItr->aRangeAddress.EndColumn - nStartColumn + 1;
- aRange.nStartColumn = nStartColumn;
- }
- else if ((aItr->aRangeAddress.StartColumn >= nStartColumn) &&
- (aItr->aRangeAddress.EndColumn <= nEndColumn))
- {
- aRange.nRepeatColumns = aItr->aRangeAddress.EndColumn - aItr->aRangeAddress.StartColumn + 1;
- aRange.nStartColumn = aItr->aRangeAddress.StartColumn;
- }
- else if ((aItr->aRangeAddress.StartColumn >= nStartColumn) &&
- (aItr->aRangeAddress.StartColumn <= nEndColumn) &&
- (aItr->aRangeAddress.EndColumn > nEndColumn))
- {
- aRange.nRepeatColumns = nEndColumn - aItr->aRangeAddress.StartColumn + 1;
- aRange.nStartColumn = aItr->aRangeAddress.StartColumn;
- }
- aRange.nRepeatRows = aItr->aRangeAddress.EndRow - nRow + 1;
- pRowFormatRanges->AddRange(aRange, nRow);
- nColumns += aRange.nRepeatColumns;
- }
- ++aItr;
- }
- else
- if(aItr->aRangeAddress.EndRow < nRow)
- aItr = pFormatRanges->erase(aItr);
- else
- ++aItr;
- }
- pRowFormatRanges->Sort();
-}
-
-void ScFormatRangeStyles::AddRangeStyleName(const table::CellRangeAddress aCellRangeAddress,
- const sal_Int32 nStringIndex, const sal_Bool bIsAutoStyle, const sal_Int32 nValidationIndex,
- const sal_Int32 nNumberFormat)
-{
- ScMyFormatRange aFormatRange;
- aFormatRange.aRangeAddress = aCellRangeAddress;
- aFormatRange.nStyleNameIndex = nStringIndex;
- aFormatRange.nValidationIndex = nValidationIndex;
- aFormatRange.nNumberFormat = nNumberFormat;
- aFormatRange.bIsAutoStyle = bIsAutoStyle;
- DBG_ASSERT(static_cast<size_t>(aCellRangeAddress.Sheet) < aTables.size(), "wrong table");
- ScMyFormatRangeAddresses* pFormatRanges(aTables[aCellRangeAddress.Sheet]);
- pFormatRanges->push_back(aFormatRange);
-}
-
-rtl::OUString* ScFormatRangeStyles::GetStyleNameByIndex(const sal_Int32 nIndex, const sal_Bool bIsAutoStyle)
-{
- if (bIsAutoStyle)
- return aAutoStyleNames[nIndex];
- else
- return aStyleNames[nIndex];
-}
-
-void ScFormatRangeStyles::Sort()
-{
- sal_Int32 nTables = aTables.size();
- for (sal_Int16 i = 0; i < nTables; ++i)
- if (!aTables[i]->empty())
- aTables[i]->sort();
-}
-
-//===========================================================================
-
-ScColumnRowStylesBase::ScColumnRowStylesBase()
- : aStyleNames()
-{
-}
-
-ScColumnRowStylesBase::~ScColumnRowStylesBase()
-{
- ScMyOUStringVec::iterator i(aStyleNames.begin());
- ScMyOUStringVec::iterator endi(aStyleNames.end());
- while (i != endi)
- {
- delete *i;
- ++i;
- }
-}
-
-sal_Int32 ScColumnRowStylesBase::AddStyleName(rtl::OUString* pString)
-{
- aStyleNames.push_back(pString);
- return aStyleNames.size() - 1;
-}
-
-sal_Int32 ScColumnRowStylesBase::GetIndexOfStyleName(const rtl::OUString& rString, const rtl::OUString& rPrefix)
-{
- sal_Int32 nPrefixLength(rPrefix.getLength());
- rtl::OUString sTemp(rString.copy(nPrefixLength));
- sal_Int32 nIndex(sTemp.toInt32());
- if (aStyleNames.at(nIndex - 1)->equals(rString))
- return nIndex - 1;
- else
- {
- sal_Int32 i(0);
- sal_Bool bFound(sal_False);
- while (!bFound && static_cast<size_t>(i) < aStyleNames.size())
- {
- if (aStyleNames.at(i)->equals(rString))
- bFound = sal_True;
- else
- ++i;
- }
- if (bFound)
- return i;
- else
- return -1;
- }
-}
-
-rtl::OUString* ScColumnRowStylesBase::GetStyleNameByIndex(const sal_Int32 nIndex)
-{
- if ( nIndex < 0 || nIndex >= sal::static_int_cast<sal_Int32>( aStyleNames.size() ) )
- {
- // #123981# should no longer happen, use first style then
- DBG_ERRORFILE("GetStyleNameByIndex: invalid index");
- return aStyleNames[0];
- }
-
- return aStyleNames[nIndex];
-}
-
-//===========================================================================
-
-ScColumnStyles::ScColumnStyles()
- : ScColumnRowStylesBase(),
- aTables()
-{
-}
-
-ScColumnStyles::~ScColumnStyles()
-{
-}
-
-void ScColumnStyles::AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields)
-{
- sal_Int32 nSize(aTables.size() - 1);
- if (nTable > nSize)
- for (sal_Int32 i = nSize; i < nTable; ++i)
- {
- ScMyColumnStyleVec aFieldsVec(nFields + 1, ScColumnStyle());
- aTables.push_back(aFieldsVec);
- }
-}
-
-sal_Int32 ScColumnStyles::GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField,
- sal_Bool& bIsVisible)
-{
- DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
- if (static_cast<size_t>(nField) < aTables[nTable].size())
- {
- bIsVisible = aTables[nTable][nField].bIsVisible;
- return aTables[nTable][nField].nIndex;
- }
- else
- {
- bIsVisible = aTables[nTable][aTables[nTable].size() - 1].bIsVisible;
- return aTables[nTable][aTables[nTable].size() - 1].nIndex;
- }
-}
-
-void ScColumnStyles::AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField,
- const sal_Int32 nStringIndex, const sal_Bool bIsVisible)
-{
- DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
- DBG_ASSERT(aTables[nTable].size() >= static_cast<sal_uInt32>(nField), "wrong field");
- ScColumnStyle aStyle;
- aStyle.nIndex = nStringIndex;
- aStyle.bIsVisible = bIsVisible;
- if (aTables[nTable].size() == static_cast<sal_uInt32>(nField))
- aTables[nTable].push_back(aStyle);
- aTables[nTable][nField] = aStyle;
-}
-
-rtl::OUString* ScColumnStyles::GetStyleName(const sal_Int32 nTable, const sal_Int32 nField)
-{
- sal_Bool bTemp;
- return GetStyleNameByIndex(GetStyleNameIndex(nTable, nField, bTemp));
-}
-
-//===========================================================================
-
-ScRowStyles::ScRowStyles()
- : ScColumnRowStylesBase(),
- aTables()
-{
-}
-
-ScRowStyles::~ScRowStyles()
-{
-}
-
-void ScRowStyles::AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields)
-{
- sal_Int32 nSize(aTables.size() - 1);
- if (nTable > nSize)
- for (sal_Int32 i = nSize; i < nTable; ++i)
- {
- ScMysalInt32Vec aFieldsVec(nFields + 1, -1);
- aTables.push_back(aFieldsVec);
- }
-}
-
-sal_Int32 ScRowStyles::GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField)
-{
- DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
- if (static_cast<size_t>(nField) < aTables[nTable].size())
- return aTables[nTable][nField];
- else
- return aTables[nTable][aTables[nTable].size() - 1];
-}
-
-void ScRowStyles::AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField,
- const sal_Int32 nStringIndex)
-{
- DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
- DBG_ASSERT(aTables[nTable].size() >= static_cast<sal_uInt32>(nField), "wrong field");
- if (aTables[nTable].size() == static_cast<sal_uInt32>(nField))
- aTables[nTable].push_back(nStringIndex);
- aTables[nTable][nField] = nStringIndex;
-}
-
-rtl::OUString* ScRowStyles::GetStyleName(const sal_Int32 nTable, const sal_Int32 nField)
-{
- return GetStyleNameByIndex(GetStyleNameIndex(nTable, nField));
-}
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: XMLStylesExportHelper.cxx,v $
+ * $Revision: 1.52 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+// INCLUDE ---------------------------------------------------------------
+#include "XMLStylesExportHelper.hxx"
+#include "global.hxx"
+#include "unonames.hxx"
+#include "XMLConverter.hxx"
+#include "xmlexprt.hxx"
+#include "document.hxx"
+#include "rangeutl.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/XMLEventExport.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XSheetCondition.hpp>
+#include <com/sun/star/sheet/TableValidationVisibility.hpp>
+#include <comphelper/extract.hxx>
+#include <sfx2/app.hxx>
+
+#include <algorithm>
+
+using namespace com::sun::star;
+using namespace xmloff::token;
+
+ScMyValidation::ScMyValidation()
+ : sName(),
+ sErrorMessage(),
+ sErrorTitle(),
+ sImputMessage(),
+ sImputTitle(),
+ sFormula1(),
+ sFormula2(),
+ bShowErrorMessage(sal_False),
+ bShowImputMessage(sal_False),
+ bIgnoreBlanks(sal_False)
+{
+}
+
+ScMyValidation::~ScMyValidation()
+{
+}
+
+sal_Bool ScMyValidation::IsEqual(const ScMyValidation& aVal) const
+{
+ if (aVal.bIgnoreBlanks == bIgnoreBlanks &&
+ aVal.bShowImputMessage == bShowImputMessage &&
+ aVal.bShowErrorMessage == bShowErrorMessage &&
+ aVal.aBaseCell.Sheet == aBaseCell.Sheet &&
+ aVal.aBaseCell.Column == aBaseCell.Column &&
+ aVal.aBaseCell.Row == aBaseCell.Row &&
+ aVal.aAlertStyle == aAlertStyle &&
+ aVal.aValidationType == aValidationType &&
+ aVal.aOperator == aOperator &&
+ aVal.sErrorTitle == sErrorTitle &&
+ aVal.sImputTitle == sImputTitle &&
+ aVal.sErrorMessage == sErrorMessage &&
+ aVal.sImputMessage == sImputMessage &&
+ aVal.sFormula1 == sFormula1 &&
+ aVal.sFormula2 == sFormula2)
+ return sal_True;
+ else
+ return sal_False;
+}
+
+ScMyValidationsContainer::ScMyValidationsContainer()
+ : aValidationVec(),
+ sEmptyString(),
+ sERRALSTY(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRALSTY)),
+ sIGNOREBL(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_IGNOREBL)),
+ sSHOWLIST(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SHOWLIST)),
+ sTYPE(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_TYPE)),
+ sSHOWINP(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SHOWINP)),
+ sSHOWERR(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SHOWERR)),
+ sINPTITLE(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_INPTITLE)),
+ sINPMESS(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_INPMESS)),
+ sERRTITLE(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRTITLE)),
+ sERRMESS(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRMESS)),
+ sOnError(RTL_CONSTASCII_USTRINGPARAM("OnError")),
+ sEventType(RTL_CONSTASCII_USTRINGPARAM("EventType")),
+ sStarBasic(RTL_CONSTASCII_USTRINGPARAM("StarBasic")),
+ sScript(RTL_CONSTASCII_USTRINGPARAM("Script")),
+ sLibrary(RTL_CONSTASCII_USTRINGPARAM("Library")),
+ sMacroName(RTL_CONSTASCII_USTRINGPARAM("MacroName"))
+{
+}
+
+ScMyValidationsContainer::~ScMyValidationsContainer()
+{
+}
+
+sal_Bool ScMyValidationsContainer::AddValidation(const uno::Any& aTempAny,
+ sal_Int32& nValidationIndex)
+{
+ sal_Bool bAdded(sal_False);
+ uno::Reference<beans::XPropertySet> xPropertySet(aTempAny, uno::UNO_QUERY);
+ if (xPropertySet.is())
+ {
+ rtl::OUString sErrorMessage;
+ xPropertySet->getPropertyValue(sERRMESS) >>= sErrorMessage;
+ rtl::OUString sErrorTitle;
+ xPropertySet->getPropertyValue(sERRTITLE) >>= sErrorTitle;
+ rtl::OUString sImputMessage;
+ xPropertySet->getPropertyValue(sINPMESS) >>= sImputMessage;
+ rtl::OUString sImputTitle;
+ xPropertySet->getPropertyValue(sINPTITLE) >>= sImputTitle;
+ sal_Bool bShowErrorMessage = ::cppu::any2bool(xPropertySet->getPropertyValue(sSHOWERR));
+ sal_Bool bShowImputMessage = ::cppu::any2bool(xPropertySet->getPropertyValue(sSHOWINP));
+ sheet::ValidationType aValidationType;
+ xPropertySet->getPropertyValue(sTYPE) >>= aValidationType;
+ if (bShowErrorMessage || bShowImputMessage || aValidationType != sheet::ValidationType_ANY ||
+ sErrorMessage.getLength() || sErrorTitle.getLength() || sImputMessage.getLength() || sImputTitle.getLength())
+ {
+ ScMyValidation aValidation;
+ aValidation.sErrorMessage = sErrorMessage;
+ aValidation.sErrorTitle = sErrorTitle;
+ aValidation.sImputMessage = sImputMessage;
+ aValidation.sImputTitle = sImputTitle;
+ aValidation.bShowErrorMessage = bShowErrorMessage;
+ aValidation.bShowImputMessage = bShowImputMessage;
+ aValidation.aValidationType = aValidationType;
+ aValidation.bIgnoreBlanks = ::cppu::any2bool(xPropertySet->getPropertyValue(sIGNOREBL));
+ xPropertySet->getPropertyValue(sSHOWLIST) >>= aValidation.nShowList;
+ xPropertySet->getPropertyValue(sERRALSTY) >>= aValidation.aAlertStyle;
+ uno::Reference<sheet::XSheetCondition> xCondition(xPropertySet, uno::UNO_QUERY);
+ if (xCondition.is())
+ {
+ aValidation.sFormula1 = xCondition->getFormula1();
+ aValidation.sFormula2 = xCondition->getFormula2();
+ aValidation.aOperator = xCondition->getOperator();
+ aValidation.aBaseCell = xCondition->getSourcePosition();
+ }
+ //ScMyValidationRange aValidationRange;
+ sal_Bool bEqualFound(sal_False);
+ sal_Int32 i(0);
+ sal_Int32 nCount(aValidationVec.size());
+ while (i < nCount && !bEqualFound)
+ {
+ bEqualFound = aValidationVec[i].IsEqual(aValidation);
+ if (!bEqualFound)
+ ++i;
+ }
+ if (bEqualFound)
+ nValidationIndex = i;
+ else
+ {
+ sal_Int32 nNameIndex(nCount + 1);
+ rtl::OUString sCount(rtl::OUString::valueOf(nNameIndex));
+ rtl::OUString sPrefix(RTL_CONSTASCII_USTRINGPARAM("val"));
+ aValidation.sName += sPrefix;
+ aValidation.sName += sCount;
+ aValidationVec.push_back(aValidation);
+ nValidationIndex = nCount;
+ bAdded = sal_True;
+ }
+ }
+ }
+ return bAdded;
+}
+
+rtl::OUString ScMyValidationsContainer::GetCondition(ScXMLExport& rExport, const ScMyValidation& aValidation)
+{
+ rtl::OUString sCondition;
+ if (aValidation.aValidationType != sheet::ValidationType_ANY)
+ {
+ switch (aValidation.aValidationType)
+ {
+ //case sheet::ValidationType_CUSTOM
+ case sheet::ValidationType_DATE :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-date()"));
+ break;
+ case sheet::ValidationType_DECIMAL :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-decimal-number()"));
+ break;
+ case sheet::ValidationType_LIST :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-in-list("));
+ sCondition += aValidation.sFormula1;
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")"));
+ break;
+ case sheet::ValidationType_TEXT_LEN :
+ if (aValidation.aOperator != sheet::ConditionOperator_BETWEEN &&
+ aValidation.aOperator != sheet::ConditionOperator_NOT_BETWEEN)
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length()"));
+ break;
+ case sheet::ValidationType_TIME :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-time()"));
+ break;
+ case sheet::ValidationType_WHOLE :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-whole-number()"));
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ if (aValidation.aValidationType != sheet::ValidationType_LIST &&
+ (aValidation.sFormula1.getLength() ||
+ (aValidation.aOperator == sheet::ConditionOperator_BETWEEN &&
+ aValidation.aOperator == sheet::ConditionOperator_NOT_BETWEEN &&
+ aValidation.sFormula2.getLength())))
+ {
+ if (aValidation.aValidationType != sheet::ValidationType_TEXT_LEN)
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" and "));
+ if (aValidation.aOperator != sheet::ConditionOperator_BETWEEN &&
+ aValidation.aOperator != sheet::ConditionOperator_NOT_BETWEEN)
+ {
+ if (aValidation.aValidationType != sheet::ValidationType_TEXT_LEN)
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content()"));
+ switch (aValidation.aOperator)
+ {
+ case sheet::ConditionOperator_EQUAL :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("="));
+ break;
+ case sheet::ConditionOperator_GREATER :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">"));
+ break;
+ case sheet::ConditionOperator_GREATER_EQUAL :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">="));
+ break;
+ case sheet::ConditionOperator_LESS :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<"));
+ break;
+ case sheet::ConditionOperator_LESS_EQUAL :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<="));
+ break;
+ case sheet::ConditionOperator_NOT_EQUAL :
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("!="));
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ sCondition += aValidation.sFormula1;
+ }
+ else
+ {
+ if (aValidation.aValidationType == sheet::ValidationType_TEXT_LEN)
+ {
+ if (aValidation.aOperator == sheet::ConditionOperator_BETWEEN)
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-between("));
+ else
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-not-between("));
+ }
+ else
+ {
+ if (aValidation.aOperator == sheet::ConditionOperator_BETWEEN)
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-between("));
+ else
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-not-between("));
+ }
+ sCondition += aValidation.sFormula1;
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(","));
+ sCondition += aValidation.sFormula2;
+ sCondition += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")"));
+ }
+ }
+ else
+ if (aValidation.aValidationType == sheet::ValidationType_TEXT_LEN)
+ sCondition = rtl::OUString();
+ }
+ if (sCondition.getLength())
+ {
+ const formula::FormulaGrammar::Grammar eGrammar = rExport.GetDocument()->GetStorageGrammar();
+ sal_uInt16 nNamespacePrefix = (eGrammar == formula::FormulaGrammar::GRAM_ODFF ? XML_NAMESPACE_OF : XML_NAMESPACE_OOOC);
+ sCondition = rExport.GetNamespaceMap().GetQNameByKey( nNamespacePrefix, sCondition, sal_False );
+ }
+
+ return sCondition;
+}
+
+rtl::OUString ScMyValidationsContainer::GetBaseCellAddress(ScDocument* pDoc, const table::CellAddress& aCell)
+{
+ rtl::OUString sAddress;
+ ScRangeStringConverter::GetStringFromAddress( sAddress, aCell, pDoc );
+ return sAddress;
+}
+
+void ScMyValidationsContainer::WriteMessage(ScXMLExport& rExport,
+ const rtl::OUString& sTitle, const rtl::OUString& sOUMessage,
+ const sal_Bool bShowMessage, const sal_Bool bIsHelpMessage)
+{
+ if (sTitle.getLength())
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TITLE, sTitle);
+ if (bShowMessage)
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, XML_TRUE);
+ else
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, XML_FALSE);
+ SvXMLElementExport* pMessage(NULL);
+ if (bIsHelpMessage)
+ pMessage = new SvXMLElementExport(rExport, XML_NAMESPACE_TABLE, XML_HELP_MESSAGE, sal_True, sal_True);
+ else
+ pMessage = new SvXMLElementExport(rExport, XML_NAMESPACE_TABLE, XML_ERROR_MESSAGE, sal_True, sal_True);
+ if (sOUMessage.getLength())
+ {
+ sal_Int32 i(0);
+ rtl::OUStringBuffer sTemp;
+ String sMessage(sOUMessage);
+ rtl::OUString sText (sMessage.ConvertLineEnd(LINEEND_LF));
+ sal_Bool bPrevCharWasSpace(sal_True);
+ while(i < sText.getLength())
+ {
+ if ((sText[i] == '\n'))
+ {
+ SvXMLElementExport aElemP(rExport, XML_NAMESPACE_TEXT, XML_P, sal_True, sal_False);
+ rExport.GetTextParagraphExport()->exportText(sTemp.makeStringAndClear(), bPrevCharWasSpace);
+ }
+ else
+ sTemp.append(sText[i]);
+ ++i;
+ }
+ if (sTemp.getLength())
+ {
+ SvXMLElementExport aElemP(rExport, XML_NAMESPACE_TEXT, XML_P, sal_True, sal_False);
+ rExport.GetTextParagraphExport()->exportText(sTemp.makeStringAndClear(), bPrevCharWasSpace);
+ }
+ }
+ if (pMessage)
+ delete pMessage;
+}
+
+void ScMyValidationsContainer::WriteValidations(ScXMLExport& rExport)
+{
+ if (aValidationVec.size())
+ {
+ SvXMLElementExport aElemVs(rExport, XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATIONS, sal_True, sal_True);
+ ScMyValidationVec::iterator aItr(aValidationVec.begin());
+ ScMyValidationVec::iterator aEndItr(aValidationVec.end());
+ while (aItr != aEndItr)
+ {
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, aItr->sName);
+ rtl::OUString sCondition(GetCondition(rExport, *aItr));
+ if (sCondition.getLength())
+ {
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CONDITION, sCondition);
+ if (aItr->bIgnoreBlanks)
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ALLOW_EMPTY_CELL, XML_TRUE);
+ else
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ALLOW_EMPTY_CELL, XML_FALSE);
+ if (aItr->aValidationType == sheet::ValidationType_LIST)
+ {
+ switch (aItr->nShowList)
+ {
+ case sheet::TableValidationVisibility::INVISIBLE:
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_LIST, XML_NO);
+ break;
+ case sheet::TableValidationVisibility::UNSORTED:
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_LIST, XML_UNSORTED);
+ break;
+ case sheet::TableValidationVisibility::SORTEDASCENDING:
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_LIST, XML_SORTED_ASCENDING);
+ break;
+ default:
+ DBG_ERROR("unknown ListType");
+ }
+ }
+ }
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, GetBaseCellAddress(rExport.GetDocument(), aItr->aBaseCell));
+ SvXMLElementExport aElemV(rExport, XML_NAMESPACE_TABLE, XML_CONTENT_VALIDATION, sal_True, sal_True);
+ if (aItr->bShowImputMessage || aItr->sImputMessage.getLength() || aItr->sImputTitle.getLength())
+ {
+ WriteMessage(rExport, aItr->sImputTitle, aItr->sImputMessage, aItr->bShowImputMessage, sal_True);
+ }
+ if (aItr->bShowErrorMessage || aItr->sErrorMessage.getLength() || aItr->sErrorTitle.getLength())
+ {
+ switch (aItr->aAlertStyle)
+ {
+ case sheet::ValidationAlertStyle_INFO :
+ {
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_INFORMATION);
+ WriteMessage(rExport, aItr->sErrorTitle, aItr->sErrorMessage, aItr->bShowErrorMessage, sal_False);
+ }
+ break;
+ case sheet::ValidationAlertStyle_WARNING :
+ {
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_WARNING);
+ WriteMessage(rExport, aItr->sErrorTitle, aItr->sErrorMessage, aItr->bShowErrorMessage, sal_False);
+ }
+ break;
+ case sheet::ValidationAlertStyle_STOP :
+ {
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_MESSAGE_TYPE, XML_STOP);
+ WriteMessage(rExport, aItr->sErrorTitle, aItr->sErrorMessage, aItr->bShowErrorMessage, sal_False);
+ }
+ break;
+ case sheet::ValidationAlertStyle_MACRO :
+ {
+ {
+ //rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, aItr->sErrorTitle);
+ if (aItr->bShowErrorMessage)
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_EXECUTE, XML_TRUE);
+ else
+ rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_EXECUTE, XML_FALSE);
+ SvXMLElementExport aEMElem(rExport, XML_NAMESPACE_TABLE, XML_ERROR_MACRO, sal_True, sal_True);
+ }
+ {
+ // #i47525# for a script URL the type and the property name for the URL
+ // are both "Script", for a simple macro name the type is "StarBasic"
+ // and the property name is "MacroName".
+ bool bScriptURL = SfxApplication::IsXScriptURL( aItr->sErrorTitle );
+
+ uno::Sequence<beans::PropertyValue> aSeq(3);
+ beans::PropertyValue* pArr(aSeq.getArray());
+ pArr[0].Name = sEventType;
+ pArr[0].Value <<= bScriptURL ? sScript : sStarBasic;
+ pArr[1].Name = sLibrary;
+ pArr[1].Value <<= sEmptyString;
+ pArr[2].Name = bScriptURL ? sScript : sMacroName;
+ pArr[2].Value <<= aItr->sErrorTitle;
+
+ // 2) export the sequence
+ rExport.GetEventExport().ExportSingleEvent( aSeq, sOnError);
+ }
+ }
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+ ++aItr;
+ }
+ }
+}
+
+const rtl::OUString& ScMyValidationsContainer::GetValidationName(const sal_Int32 nIndex)
+{
+ DBG_ASSERT( static_cast<size_t>(nIndex) < aValidationVec.size(), "out of range" );
+ return aValidationVec[nIndex].sName;
+}
+
+//==============================================================================
+
+sal_Int32 ScMyDefaultStyles::GetStyleNameIndex(const ScFormatRangeStyles* pCellStyles,
+ const sal_Int32 nTable, const sal_Int32 nPos,
+ const sal_Int32 i, const sal_Bool bRow, sal_Bool& bIsAutoStyle)
+{
+ if (bRow)
+ return pCellStyles->GetStyleNameIndex(nTable, nPos, i,
+ bIsAutoStyle);
+ else
+ return pCellStyles->GetStyleNameIndex(nTable, i, nPos,
+ bIsAutoStyle);
+}
+
+void ScMyDefaultStyles::FillDefaultStyles(const sal_Int32 nTable,
+ const sal_Int32 nLastRow, const sal_Int32 nLastCol,
+ const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc,
+ const sal_Bool bRow)
+{
+ if (pDoc)
+ {
+ SCTAB nTab = static_cast<SCTAB>(nTable);
+ sal_Int32 nPos;
+ sal_Int32 nLast;
+ ScMyDefaultStyleList* pDefaults;
+ if (bRow)
+ {
+ pDefaults = pRowDefaults;
+ nLast = nLastRow;
+ }
+ else
+ {
+ pDefaults = pColDefaults;
+ nLast = nLastCol;
+ }
+ sal_Bool bPrevAutoStyle(sal_False);
+ sal_Bool bIsAutoStyle;
+ sal_Bool bResult;
+ sal_Int32 nPrevIndex(0);
+ sal_Int32 nIndex;
+ sal_Int32 nRepeat(0);
+ sal_Int32 nEmptyRepeat(0);
+ for (sal_Int32 i = nLast; i >= 0; --i)
+ {
+ if (bRow)
+ {
+ SCCOL nCol;
+ bResult = pDoc->GetRowDefault(nTab,
+ static_cast<SCROW>(i), static_cast<SCCOL>(nLastCol), nCol);
+ nPos = static_cast<sal_Int32>(nCol);
+ }
+ else
+ {
+ SCROW nRow;
+ bResult = pDoc->GetColDefault(nTab,
+ static_cast<SCCOL>(i), static_cast<SCROW>(nLastRow), nRow);
+ nPos = static_cast<sal_Int32>(nRow);
+ }
+ if (bResult)
+ {
+ nEmptyRepeat = 0;
+ if (!nRepeat)
+ {
+ nPrevIndex = GetStyleNameIndex(pCellStyles, nTab, nPos, i,
+ bRow, bPrevAutoStyle);
+ (*pDefaults)[i].nIndex = nPrevIndex;
+ (*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle;
+ nRepeat = 1;
+ }
+ else
+ {
+ nIndex = GetStyleNameIndex(pCellStyles, nTab, nPos, i,
+ bRow, bIsAutoStyle);
+ if ((nIndex != nPrevIndex) || (bIsAutoStyle != bPrevAutoStyle))
+ {
+ nRepeat = 1;
+ nPrevIndex = GetStyleNameIndex(pCellStyles, nTab, nPos, i,
+ bRow, bPrevAutoStyle);
+ (*pDefaults)[i].nIndex = nPrevIndex;
+ (*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle;
+ }
+ else
+ {
+ (*pDefaults)[i].nIndex = nPrevIndex;
+ (*pDefaults)[i].bIsAutoStyle = bPrevAutoStyle;
+ ++nRepeat;
+ if (nRepeat > 1)
+ (*pDefaults)[i].nRepeat = nRepeat;
+ }
+ }
+ }
+ else
+ {
+ nRepeat = 0;
+ if (!nEmptyRepeat)
+ nEmptyRepeat = 1;
+ else
+ {
+ ++nEmptyRepeat;
+ if (nEmptyRepeat > 1)
+ (*pDefaults)[i].nRepeat = nEmptyRepeat;
+ }
+ }
+ }
+ }
+}
+
+void ScMyDefaultStyles::FillDefaultStyles(const sal_Int32 nTable,
+ const sal_Int32 nLastRow, const sal_Int32 nLastCol,
+ const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc)
+{
+ if (pRowDefaults)
+ delete pRowDefaults;
+ pRowDefaults = new ScMyDefaultStyleList(nLastRow + 1);
+ FillDefaultStyles(nTable, nLastRow, nLastCol, pCellStyles, pDoc, sal_True);
+ if (pColDefaults)
+ delete pColDefaults;
+ pColDefaults = new ScMyDefaultStyleList(nLastCol + 1);
+ FillDefaultStyles(nTable, nLastRow, nLastCol, pCellStyles, pDoc, sal_False);
+}
+
+ScMyDefaultStyles::~ScMyDefaultStyles()
+{
+ if (pRowDefaults)
+ delete pRowDefaults;
+ if (pColDefaults)
+ delete pColDefaults;
+}
+
+ScMyRowFormatRange::ScMyRowFormatRange()
+ : nStartColumn(0),
+ nRepeatColumns(0),
+ nRepeatRows(0),
+ nIndex(-1),
+ nValidationIndex(-1),
+ bIsAutoStyle(sal_True)
+{
+}
+
+sal_Bool ScMyRowFormatRange::operator< (const ScMyRowFormatRange& rRange) const
+{
+ return (nStartColumn < rRange.nStartColumn);
+}
+
+ScRowFormatRanges::ScRowFormatRanges()
+ : aRowFormatRanges(),
+ pRowDefaults(NULL),
+ pColDefaults(NULL),
+ nSize(0)
+{
+}
+
+ScRowFormatRanges::ScRowFormatRanges(const ScRowFormatRanges* pRanges)
+ : aRowFormatRanges(pRanges->aRowFormatRanges),
+ pRowDefaults(pRanges->pRowDefaults),
+ pColDefaults(pRanges->pColDefaults),
+ nSize(pRanges->nSize)
+{
+}
+
+ScRowFormatRanges::~ScRowFormatRanges()
+{
+}
+
+void ScRowFormatRanges::Clear()
+{
+ aRowFormatRanges.clear();
+ nSize = 0;
+}
+
+void ScRowFormatRanges::AddRange(const sal_Int32 nPrevStartCol, const sal_Int32 nRepeat, const sal_Int32 nPrevIndex,
+ const sal_Bool bPrevAutoStyle, const ScMyRowFormatRange& rFormatRange)
+{
+ sal_Int32 nIndex(-1);
+ if ((nPrevIndex != rFormatRange.nIndex) ||
+ (bPrevAutoStyle != rFormatRange.bIsAutoStyle))
+ nIndex = rFormatRange.nIndex;
+
+ sal_Bool bInserted(sal_False);
+ if (!aRowFormatRanges.empty())
+ {
+ ScMyRowFormatRange* pRange(&aRowFormatRanges.back());
+ if (pRange)
+ {
+ if ((nPrevStartCol == (pRange->nStartColumn + pRange->nRepeatColumns)) &&
+ (pRange->bIsAutoStyle == rFormatRange.bIsAutoStyle) &&
+ (pRange->nIndex == nIndex) &&
+ (pRange->nValidationIndex == rFormatRange.nValidationIndex))
+ {
+ if (rFormatRange.nRepeatRows < pRange->nRepeatRows)
+ pRange->nRepeatRows = rFormatRange.nRepeatRows;
+ pRange->nRepeatColumns += nRepeat;
+ bInserted = sal_True;
+ }
+ }
+ }
+ if (!bInserted)
+ {
+ ScMyRowFormatRange aRange;
+ aRange.nStartColumn = nPrevStartCol;
+ aRange.nRepeatColumns = nRepeat;
+ aRange.nRepeatRows = rFormatRange.nRepeatRows;
+ aRange.nValidationIndex = rFormatRange.nValidationIndex;
+ aRange.bIsAutoStyle = rFormatRange.bIsAutoStyle;
+ aRange.nIndex = nIndex;
+ aRowFormatRanges.push_back(aRange);
+ ++nSize;
+ }
+}
+
+void ScRowFormatRanges::AddRange(ScMyRowFormatRange& rFormatRange,
+ const sal_Int32 nRow)
+{
+ DBG_ASSERT(pRowDefaults, "no row defaults");
+ DBG_ASSERT(pColDefaults, "no column defaults");
+ sal_uInt32 nEnd (rFormatRange.nRepeatRows + nRow - 1);
+ sal_Int32 nPrevIndex((*pRowDefaults)[nRow].nIndex);
+ sal_Bool bPrevAutoStyle((*pRowDefaults)[nRow].bIsAutoStyle);
+ sal_uInt32 i(nRow + 1);
+ sal_Bool bReady(sal_False);
+ while ((i < nEnd) && !bReady && (i < pRowDefaults->size()))
+ {
+ if ((nPrevIndex != (*pRowDefaults)[i].nIndex) ||
+ (bPrevAutoStyle != (*pRowDefaults)[i].bIsAutoStyle))
+ bReady = sal_True;
+ else
+ i += (*pRowDefaults)[i].nRepeat;
+ }
+ if (i > nEnd)
+ i = nEnd;
+ if (bReady)
+ rFormatRange.nRepeatRows = i - nRow + 1;
+ if (nPrevIndex == -1)
+ {
+ nPrevIndex = (*pColDefaults)[rFormatRange.nStartColumn].nIndex;
+ bPrevAutoStyle = (*pColDefaults)[rFormatRange.nStartColumn].bIsAutoStyle;
+ sal_uInt32 nPrevStartCol(rFormatRange.nStartColumn);
+ sal_uInt32 nRepeat((*pColDefaults)[rFormatRange.nStartColumn].nRepeat);
+ nEnd = rFormatRange.nStartColumn + rFormatRange.nRepeatColumns;
+ for(i = nPrevStartCol + nRepeat; i < nEnd; i += (*pColDefaults)[i].nRepeat)
+ {
+ DBG_ASSERT(sal_uInt32(nPrevStartCol + nRepeat) <= nEnd, "something wents wrong");
+ if ((nPrevIndex != (*pColDefaults)[i].nIndex) ||
+ (bPrevAutoStyle != (*pColDefaults)[i].bIsAutoStyle))
+ {
+ AddRange(nPrevStartCol, nRepeat, nPrevIndex, bPrevAutoStyle, rFormatRange);
+ nPrevStartCol = i;
+ nRepeat = (*pColDefaults)[i].nRepeat;
+ nPrevIndex = (*pColDefaults)[i].nIndex;
+ bPrevAutoStyle = (*pColDefaults)[i].bIsAutoStyle;
+ }
+ else
+ nRepeat += (*pColDefaults)[i].nRepeat;
+ }
+ if (sal_uInt32(nPrevStartCol + nRepeat) > nEnd)
+ nRepeat = nEnd - nPrevStartCol;
+ AddRange(nPrevStartCol, nRepeat, nPrevIndex, bPrevAutoStyle, rFormatRange);
+ }
+ else if ((nPrevIndex == rFormatRange.nIndex) &&
+ (bPrevAutoStyle == rFormatRange.bIsAutoStyle))
+ {
+ rFormatRange.nIndex = -1;
+ aRowFormatRanges.push_back(rFormatRange);
+ ++nSize;
+ }
+}
+
+sal_Bool ScRowFormatRanges::GetNext(ScMyRowFormatRange& aFormatRange)
+{
+ ScMyRowFormatRangesList::iterator aItr(aRowFormatRanges.begin());
+ if (aItr != aRowFormatRanges.end())
+ {
+ aFormatRange = (*aItr);
+ aRowFormatRanges.erase(aItr);
+ --nSize;
+ return sal_True;
+ }
+ return sal_False;
+}
+
+sal_Int32 ScRowFormatRanges::GetMaxRows()
+{
+ ScMyRowFormatRangesList::iterator aItr(aRowFormatRanges.begin());
+ ScMyRowFormatRangesList::iterator aEndItr(aRowFormatRanges.end());
+ sal_Int32 nMaxRows = MAXROW + 1;
+ if (aItr != aEndItr)
+ while (aItr != aEndItr)
+ {
+ if ((*aItr).nRepeatRows < nMaxRows)
+ nMaxRows = (*aItr).nRepeatRows;
+ ++aItr;
+ }
+ else
+ {
+ DBG_ERROR("no ranges found");
+ }
+ return nMaxRows;
+}
+
+sal_Int32 ScRowFormatRanges::GetSize()
+{
+ return nSize;
+}
+
+void ScRowFormatRanges::Sort()
+{
+ aRowFormatRanges.sort();
+}
+
+// ============================================================================
+ScMyFormatRange::ScMyFormatRange()
+ : nStyleNameIndex(-1),
+ nValidationIndex(-1),
+ bIsAutoStyle(sal_True)
+{
+}
+
+sal_Bool ScMyFormatRange::operator<(const ScMyFormatRange& rRange) const
+{
+ if (aRangeAddress.StartRow < rRange.aRangeAddress.StartRow)
+ return sal_True;
+ else
+ if (aRangeAddress.StartRow == rRange.aRangeAddress.StartRow)
+ return (aRangeAddress.StartColumn < rRange.aRangeAddress.StartColumn);
+ else
+ return sal_False;
+}
+
+ScFormatRangeStyles::ScFormatRangeStyles()
+ : aTables(),
+ aStyleNames(),
+ aAutoStyleNames()
+{
+}
+
+ScFormatRangeStyles::~ScFormatRangeStyles()
+{
+ ScMyOUStringVec::iterator i(aStyleNames.begin());
+ ScMyOUStringVec::iterator endi(aStyleNames.end());
+ while (i != endi)
+ {
+ delete *i;
+ ++i;
+ }
+ i = aAutoStyleNames.begin();
+ endi = aAutoStyleNames.end();
+ while (i != endi)
+ {
+ delete *i;
+ ++i;
+ }
+ ScMyFormatRangeListVec::iterator j(aTables.begin());
+ ScMyFormatRangeListVec::iterator endj(aTables.end());
+ while (j != endj)
+ {
+ delete *j;
+ ++j;
+ }
+}
+
+void ScFormatRangeStyles::AddNewTable(const sal_Int32 nTable)
+{
+ sal_Int32 nSize = aTables.size() - 1;
+ if (nTable > nSize)
+ for (sal_Int32 i = nSize; i < nTable; ++i)
+ {
+ ScMyFormatRangeAddresses* aRangeAddresses(new ScMyFormatRangeAddresses);
+ aTables.push_back(aRangeAddresses);
+ }
+}
+
+sal_Bool ScFormatRangeStyles::AddStyleName(rtl::OUString* rpString, sal_Int32& rIndex, const sal_Bool bIsAutoStyle)
+{
+ if (bIsAutoStyle)
+ {
+ aAutoStyleNames.push_back(rpString);
+ rIndex = aAutoStyleNames.size() - 1;
+ return sal_True;
+ }
+ else
+ {
+ sal_Int32 nCount(aStyleNames.size());
+ sal_Bool bFound(sal_False);
+ sal_Int32 i(nCount - 1);
+ while ((i >= 0) && (!bFound))
+ {
+ if (aStyleNames.at(i)->equals(*rpString))
+ bFound = sal_True;
+ else
+ i--;
+ }
+ if (bFound)
+ {
+ rIndex = i;
+ return sal_False;
+ }
+ else
+ {
+ aStyleNames.push_back(rpString);
+ rIndex = aStyleNames.size() - 1;
+ return sal_True;
+ }
+ }
+}
+
+sal_Int32 ScFormatRangeStyles::GetIndexOfStyleName(const rtl::OUString& rString, const rtl::OUString& rPrefix, sal_Bool& bIsAutoStyle)
+{
+ sal_Int32 nPrefixLength(rPrefix.getLength());
+ rtl::OUString sTemp(rString.copy(nPrefixLength));
+ sal_Int32 nIndex(sTemp.toInt32());
+ if (aAutoStyleNames.at(nIndex - 1)->equals(rString))
+ {
+ bIsAutoStyle = sal_True;
+ return nIndex - 1;
+ }
+ else
+ {
+ sal_Int32 i(0);
+ sal_Bool bFound(sal_False);
+ while (!bFound && static_cast<size_t>(i) < aStyleNames.size())
+ {
+ if (aStyleNames[i]->equals(rString))
+ bFound = sal_True;
+ else
+ ++i;
+ }
+ if (bFound)
+ {
+ bIsAutoStyle = sal_False;
+ return i;
+ }
+ else
+ {
+ i = 0;
+ while (!bFound && static_cast<size_t>(i) < aAutoStyleNames.size())
+ {
+ if (aAutoStyleNames[i]->equals(rString))
+ bFound = sal_True;
+ else
+ ++i;
+ }
+ if (bFound)
+ {
+ bIsAutoStyle = sal_True;
+ return i;
+ }
+ else
+ return -1;
+ }
+ }
+}
+
+sal_Int32 ScFormatRangeStyles::GetStyleNameIndex(const sal_Int32 nTable,
+ const sal_Int32 nColumn, const sal_Int32 nRow, sal_Bool& bIsAutoStyle) const
+{
+ DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
+ ScMyFormatRangeAddresses* pFormatRanges(aTables[nTable]);
+ ScMyFormatRangeAddresses::iterator aItr(pFormatRanges->begin());
+ ScMyFormatRangeAddresses::iterator aEndItr(pFormatRanges->end());
+ while (aItr != aEndItr)
+ {
+ if (((*aItr).aRangeAddress.StartColumn <= nColumn) &&
+ ((*aItr).aRangeAddress.EndColumn >= nColumn) &&
+ ((*aItr).aRangeAddress.StartRow <= nRow) &&
+ ((*aItr).aRangeAddress.EndRow >= nRow))
+ {
+ bIsAutoStyle = aItr->bIsAutoStyle;
+ return (*aItr).nStyleNameIndex;
+ }
+ else
+ ++aItr;
+ }
+ return -1;
+}
+
+sal_Int32 ScFormatRangeStyles::GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nColumn, const sal_Int32 nRow,
+ sal_Bool& bIsAutoStyle, sal_Int32& nValidationIndex, sal_Int32& nNumberFormat, const sal_Bool bRemoveRange)
+{
+ DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
+ ScMyFormatRangeAddresses* pFormatRanges(aTables[nTable]);
+ ScMyFormatRangeAddresses::iterator aItr(pFormatRanges->begin());
+ ScMyFormatRangeAddresses::iterator aEndItr(pFormatRanges->end());
+ while (aItr != aEndItr)
+ {
+ if (((*aItr).aRangeAddress.StartColumn <= nColumn) &&
+ ((*aItr).aRangeAddress.EndColumn >= nColumn) &&
+ ((*aItr).aRangeAddress.StartRow <= nRow) &&
+ ((*aItr).aRangeAddress.EndRow >= nRow))
+ {
+ bIsAutoStyle = aItr->bIsAutoStyle;
+ nValidationIndex = aItr->nValidationIndex;
+ nNumberFormat = aItr->nNumberFormat;
+ if (((*pRowDefaults)[nRow].nIndex != -1))
+ {
+ if (((*pRowDefaults)[nRow].nIndex == (*aItr).nStyleNameIndex) &&
+ ((*pRowDefaults)[nRow].bIsAutoStyle == (*aItr).bIsAutoStyle))
+ return -1;
+ else
+ return (*aItr).nStyleNameIndex;
+ }
+ else if (((*pColDefaults)[nColumn].nIndex != -1) &&
+ ((*pColDefaults)[nColumn].nIndex == (*aItr).nStyleNameIndex) &&
+ ((*pColDefaults)[nColumn].bIsAutoStyle == (*aItr).bIsAutoStyle))
+ return -1;
+ else
+ return (*aItr).nStyleNameIndex;
+ }
+ else
+ {
+ if (bRemoveRange && (*aItr).aRangeAddress.EndRow < nRow)
+ aItr = pFormatRanges->erase(aItr);
+ else
+ ++aItr;
+ }
+ }
+ return -1;
+}
+
+void ScFormatRangeStyles::GetFormatRanges(const sal_Int32 nStartColumn, const sal_Int32 nEndColumn, const sal_Int32 nRow,
+ const sal_Int32 nTable, ScRowFormatRanges* pRowFormatRanges)
+{
+ sal_Int32 nTotalColumns(nEndColumn - nStartColumn + 1);
+ DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
+ ScMyFormatRangeAddresses* pFormatRanges(aTables[nTable]);
+ ScMyFormatRangeAddresses::iterator aItr(pFormatRanges->begin());
+ ScMyFormatRangeAddresses::iterator aEndItr(pFormatRanges->end());
+ sal_Int32 nColumns = 0;
+ while (aItr != aEndItr && nColumns < nTotalColumns)
+ {
+#if OSL_DEBUG_LEVEL > 1
+ table::CellRangeAddress aTempRangeAddress((*aItr).aRangeAddress);
+#endif
+ if (((*aItr).aRangeAddress.StartRow <= nRow) &&
+ ((*aItr).aRangeAddress.EndRow >= nRow))
+ {
+ if ((((*aItr).aRangeAddress.StartColumn <= nStartColumn) &&
+ ((*aItr).aRangeAddress.EndColumn >= nStartColumn)) ||
+ (((*aItr).aRangeAddress.StartColumn <= nEndColumn) &&
+ ((*aItr).aRangeAddress.EndColumn >= nEndColumn)) ||
+ (((*aItr).aRangeAddress.StartColumn >= nStartColumn) &&
+ ((*aItr).aRangeAddress.EndColumn <= nEndColumn)))
+ {
+ ScMyRowFormatRange aRange;
+ aRange.nIndex = aItr->nStyleNameIndex;
+ aRange.nValidationIndex = aItr->nValidationIndex;
+ aRange.bIsAutoStyle = aItr->bIsAutoStyle;
+ if ((aItr->aRangeAddress.StartColumn < nStartColumn) &&
+ (aItr->aRangeAddress.EndColumn >= nStartColumn))
+ {
+ if (aItr->aRangeAddress.EndColumn >= nEndColumn)
+ aRange.nRepeatColumns = nTotalColumns;
+ else
+ aRange.nRepeatColumns = aItr->aRangeAddress.EndColumn - nStartColumn + 1;
+ aRange.nStartColumn = nStartColumn;
+ }
+ else if ((aItr->aRangeAddress.StartColumn >= nStartColumn) &&
+ (aItr->aRangeAddress.EndColumn <= nEndColumn))
+ {
+ aRange.nRepeatColumns = aItr->aRangeAddress.EndColumn - aItr->aRangeAddress.StartColumn + 1;
+ aRange.nStartColumn = aItr->aRangeAddress.StartColumn;
+ }
+ else if ((aItr->aRangeAddress.StartColumn >= nStartColumn) &&
+ (aItr->aRangeAddress.StartColumn <= nEndColumn) &&
+ (aItr->aRangeAddress.EndColumn > nEndColumn))
+ {
+ aRange.nRepeatColumns = nEndColumn - aItr->aRangeAddress.StartColumn + 1;
+ aRange.nStartColumn = aItr->aRangeAddress.StartColumn;
+ }
+ aRange.nRepeatRows = aItr->aRangeAddress.EndRow - nRow + 1;
+ pRowFormatRanges->AddRange(aRange, nRow);
+ nColumns += aRange.nRepeatColumns;
+ }
+ ++aItr;
+ }
+ else
+ if(aItr->aRangeAddress.EndRow < nRow)
+ aItr = pFormatRanges->erase(aItr);
+ else
+ ++aItr;
+ }
+ pRowFormatRanges->Sort();
+}
+
+void ScFormatRangeStyles::AddRangeStyleName(const table::CellRangeAddress aCellRangeAddress,
+ const sal_Int32 nStringIndex, const sal_Bool bIsAutoStyle, const sal_Int32 nValidationIndex,
+ const sal_Int32 nNumberFormat)
+{
+ ScMyFormatRange aFormatRange;
+ aFormatRange.aRangeAddress = aCellRangeAddress;
+ aFormatRange.nStyleNameIndex = nStringIndex;
+ aFormatRange.nValidationIndex = nValidationIndex;
+ aFormatRange.nNumberFormat = nNumberFormat;
+ aFormatRange.bIsAutoStyle = bIsAutoStyle;
+ DBG_ASSERT(static_cast<size_t>(aCellRangeAddress.Sheet) < aTables.size(), "wrong table");
+ ScMyFormatRangeAddresses* pFormatRanges(aTables[aCellRangeAddress.Sheet]);
+ pFormatRanges->push_back(aFormatRange);
+}
+
+rtl::OUString* ScFormatRangeStyles::GetStyleNameByIndex(const sal_Int32 nIndex, const sal_Bool bIsAutoStyle)
+{
+ if (bIsAutoStyle)
+ return aAutoStyleNames[nIndex];
+ else
+ return aStyleNames[nIndex];
+}
+
+void ScFormatRangeStyles::Sort()
+{
+ sal_Int32 nTables = aTables.size();
+ for (sal_Int16 i = 0; i < nTables; ++i)
+ if (!aTables[i]->empty())
+ aTables[i]->sort();
+}
+
+//===========================================================================
+
+ScColumnRowStylesBase::ScColumnRowStylesBase()
+ : aStyleNames()
+{
+}
+
+ScColumnRowStylesBase::~ScColumnRowStylesBase()
+{
+ ScMyOUStringVec::iterator i(aStyleNames.begin());
+ ScMyOUStringVec::iterator endi(aStyleNames.end());
+ while (i != endi)
+ {
+ delete *i;
+ ++i;
+ }
+}
+
+sal_Int32 ScColumnRowStylesBase::AddStyleName(rtl::OUString* pString)
+{
+ aStyleNames.push_back(pString);
+ return aStyleNames.size() - 1;
+}
+
+sal_Int32 ScColumnRowStylesBase::GetIndexOfStyleName(const rtl::OUString& rString, const rtl::OUString& rPrefix)
+{
+ sal_Int32 nPrefixLength(rPrefix.getLength());
+ rtl::OUString sTemp(rString.copy(nPrefixLength));
+ sal_Int32 nIndex(sTemp.toInt32());
+ if (aStyleNames.at(nIndex - 1)->equals(rString))
+ return nIndex - 1;
+ else
+ {
+ sal_Int32 i(0);
+ sal_Bool bFound(sal_False);
+ while (!bFound && static_cast<size_t>(i) < aStyleNames.size())
+ {
+ if (aStyleNames.at(i)->equals(rString))
+ bFound = sal_True;
+ else
+ ++i;
+ }
+ if (bFound)
+ return i;
+ else
+ return -1;
+ }
+}
+
+rtl::OUString* ScColumnRowStylesBase::GetStyleNameByIndex(const sal_Int32 nIndex)
+{
+ if ( nIndex < 0 || nIndex >= sal::static_int_cast<sal_Int32>( aStyleNames.size() ) )
+ {
+ // #123981# should no longer happen, use first style then
+ DBG_ERRORFILE("GetStyleNameByIndex: invalid index");
+ return aStyleNames[0];
+ }
+
+ return aStyleNames[nIndex];
+}
+
+//===========================================================================
+
+ScColumnStyles::ScColumnStyles()
+ : ScColumnRowStylesBase(),
+ aTables()
+{
+}
+
+ScColumnStyles::~ScColumnStyles()
+{
+}
+
+void ScColumnStyles::AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields)
+{
+ sal_Int32 nSize(aTables.size() - 1);
+ if (nTable > nSize)
+ for (sal_Int32 i = nSize; i < nTable; ++i)
+ {
+ ScMyColumnStyleVec aFieldsVec(nFields + 1, ScColumnStyle());
+ aTables.push_back(aFieldsVec);
+ }
+}
+
+sal_Int32 ScColumnStyles::GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField,
+ sal_Bool& bIsVisible)
+{
+ DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
+ if (static_cast<size_t>(nField) < aTables[nTable].size())
+ {
+ bIsVisible = aTables[nTable][nField].bIsVisible;
+ return aTables[nTable][nField].nIndex;
+ }
+ else
+ {
+ bIsVisible = aTables[nTable][aTables[nTable].size() - 1].bIsVisible;
+ return aTables[nTable][aTables[nTable].size() - 1].nIndex;
+ }
+}
+
+void ScColumnStyles::AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField,
+ const sal_Int32 nStringIndex, const sal_Bool bIsVisible)
+{
+ DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
+ DBG_ASSERT(aTables[nTable].size() >= static_cast<sal_uInt32>(nField), "wrong field");
+ ScColumnStyle aStyle;
+ aStyle.nIndex = nStringIndex;
+ aStyle.bIsVisible = bIsVisible;
+ if (aTables[nTable].size() == static_cast<sal_uInt32>(nField))
+ aTables[nTable].push_back(aStyle);
+ aTables[nTable][nField] = aStyle;
+}
+
+rtl::OUString* ScColumnStyles::GetStyleName(const sal_Int32 nTable, const sal_Int32 nField)
+{
+ sal_Bool bTemp;
+ return GetStyleNameByIndex(GetStyleNameIndex(nTable, nField, bTemp));
+}
+
+//===========================================================================
+
+ScRowStyles::ScRowStyles()
+ : ScColumnRowStylesBase(),
+ aTables()
+{
+}
+
+ScRowStyles::~ScRowStyles()
+{
+}
+
+void ScRowStyles::AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields)
+{
+ sal_Int32 nSize(aTables.size() - 1);
+ if (nTable > nSize)
+ for (sal_Int32 i = nSize; i < nTable; ++i)
+ {
+ ScMysalInt32Vec aFieldsVec(nFields + 1, -1);
+ aTables.push_back(aFieldsVec);
+ }
+}
+
+sal_Int32 ScRowStyles::GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField)
+{
+ DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
+ if (static_cast<size_t>(nField) < aTables[nTable].size())
+ return aTables[nTable][nField];
+ else
+ return aTables[nTable][aTables[nTable].size() - 1];
+}
+
+void ScRowStyles::AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField,
+ const sal_Int32 nStringIndex)
+{
+ DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
+ DBG_ASSERT(aTables[nTable].size() >= static_cast<sal_uInt32>(nField), "wrong field");
+ if (aTables[nTable].size() == static_cast<sal_uInt32>(nField))
+ aTables[nTable].push_back(nStringIndex);
+ aTables[nTable][nField] = nStringIndex;
+}
+
+rtl::OUString* ScRowStyles::GetStyleName(const sal_Int32 nTable, const sal_Int32 nField)
+{
+ return GetStyleNameByIndex(GetStyleNameIndex(nTable, nField));
+}
diff --git a/sc/source/filter/xml/xmlcvali.cxx b/sc/source/filter/xml/xmlcvali.cxx
index 0d78a79a5eea..d8d8eb0d7cc2 100644
--- a/sc/source/filter/xml/xmlcvali.cxx
+++ b/sc/source/filter/xml/xmlcvali.cxx
@@ -1,788 +1,788 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: xmlcvali.cxx,v $
- * $Revision: 1.27 $
- *
- * 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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sc.hxx"
-
-
-
-// INCLUDE ---------------------------------------------------------------
-
-#include "xmlcvali.hxx"
-#include "xmlimprt.hxx"
-#include "xmlconti.hxx"
-#include "document.hxx"
-#include "XMLConverter.hxx"
-
-#include <xmloff/xmltkmap.hxx>
-#include <xmloff/nmspmap.hxx>
-#include <xmloff/xmltoken.hxx>
-#include <xmloff/xmlnmspe.hxx>
-#include <xmloff/XMLEventsImportContext.hxx>
-#include <com/sun/star/sheet/TableValidationVisibility.hpp>
-#include <tools/debug.hxx>
-
-using namespace com::sun::star;
-using namespace xmloff::token;
-
-class ScXMLContentValidationContext : public SvXMLImportContext
-{
- rtl::OUString sName;
- rtl::OUString sHelpTitle;
- rtl::OUString sHelpMessage;
- rtl::OUString sErrorTitle;
- rtl::OUString sErrorMessage;
- rtl::OUString sErrorMessageType;
- rtl::OUString sBaseCellAddress;
- rtl::OUString sCondition;
- formula::FormulaGrammar::Grammar eGrammar;
- sal_Int16 nShowList;
- sal_Bool bAllowEmptyCell;
- sal_Bool bDisplayHelp;
- sal_Bool bDisplayError;
-
- SvXMLImportContextRef xEventContext;
-
- const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
- ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
-
- void GetAlertStyle(const rtl::OUString& sMessageType, com::sun::star::sheet::ValidationAlertStyle& aAlertStyle);
- void SetFormulas(const rtl::OUString& sFormulas, rtl::OUString& sFormula1, rtl::OUString& sFormula2) const;
- void GetCondition(const rtl::OUString& sCondition, rtl::OUString& sFormula1, rtl::OUString& sFormula2,
- com::sun::star::sheet::ValidationType& aValidationType,
- com::sun::star::sheet::ConditionOperator& aOperator);
-
-public:
-
- ScXMLContentValidationContext( ScXMLImport& rImport, USHORT nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList);
-
- virtual ~ScXMLContentValidationContext();
-
- virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix,
- const ::rtl::OUString& rLocalName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
-
- virtual void EndElement();
-
- void SetHelpMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage, const sal_Bool bDisplay);
- void SetErrorMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage, const rtl::OUString& sMessageType, const sal_Bool bDisplay);
- void SetErrorMacro(const sal_Bool bExecute);
-};
-
-class ScXMLHelpMessageContext : public SvXMLImportContext
-{
- rtl::OUString sTitle;
- rtl::OUStringBuffer sMessage;
- sal_Int32 nParagraphCount;
- sal_Bool bDisplay;
-
- ScXMLContentValidationContext* pValidationContext;
-
- const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
- ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
-
-public:
-
- ScXMLHelpMessageContext( ScXMLImport& rImport, USHORT nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
- ScXMLContentValidationContext* pValidationContext);
-
- virtual ~ScXMLHelpMessageContext();
-
- virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix,
- const ::rtl::OUString& rLocalName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
-
- virtual void EndElement();
-};
-
-class ScXMLErrorMessageContext : public SvXMLImportContext
-{
- rtl::OUString sTitle;
- rtl::OUStringBuffer sMessage;
- rtl::OUString sMessageType;
- sal_Int32 nParagraphCount;
- sal_Bool bDisplay;
-
- ScXMLContentValidationContext* pValidationContext;
-
- const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
- ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
-
-public:
-
- ScXMLErrorMessageContext( ScXMLImport& rImport, USHORT nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
- ScXMLContentValidationContext* pValidationContext);
-
- virtual ~ScXMLErrorMessageContext();
-
- virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix,
- const ::rtl::OUString& rLocalName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
-
- virtual void EndElement();
-};
-
-class ScXMLErrorMacroContext : public SvXMLImportContext
-{
- rtl::OUString sName;
- sal_Bool bExecute;
-
- ScXMLContentValidationContext* pValidationContext;
-
- const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
- ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
-
-public:
-
- ScXMLErrorMacroContext( ScXMLImport& rImport, USHORT nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
- ScXMLContentValidationContext* pValidationContext);
-
- virtual ~ScXMLErrorMacroContext();
-
- virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix,
- const ::rtl::OUString& rLocalName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
- virtual void EndElement();
-};
-
-//------------------------------------------------------------------
-
-ScXMLContentValidationsContext::ScXMLContentValidationsContext( ScXMLImport& rImport,
- USHORT nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ ) :
- SvXMLImportContext( rImport, nPrfx, rLName )
-{
- // here are no attributes
-}
-
-ScXMLContentValidationsContext::~ScXMLContentValidationsContext()
-{
-}
-
-SvXMLImportContext *ScXMLContentValidationsContext::CreateChildContext( USHORT nPrefix,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
-{
- SvXMLImportContext *pContext = 0;
-
- const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationsElemTokenMap();
- switch( rTokenMap.Get( nPrefix, rLName ) )
- {
- case XML_TOK_CONTENT_VALIDATION:
- pContext = new ScXMLContentValidationContext( GetScImport(), nPrefix, rLName, xAttrList);
- break;
- }
-
- if( !pContext )
- pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
-
- return pContext;
-}
-
-void ScXMLContentValidationsContext::EndElement()
-{
-}
-
-ScXMLContentValidationContext::ScXMLContentValidationContext( ScXMLImport& rImport,
- USHORT nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList) :
- SvXMLImportContext( rImport, nPrfx, rLName ),
- sName(),
- sHelpTitle(),
- sHelpMessage(),
- sErrorTitle(),
- sErrorMessage(),
- sErrorMessageType(),
- sBaseCellAddress(),
- sCondition(),
- nShowList(sheet::TableValidationVisibility::UNSORTED),
- bAllowEmptyCell(sal_True),
- bDisplayHelp(sal_False),
- bDisplayError(sal_False)
-{
- const formula::FormulaGrammar::Grammar eStorageGrammar = eGrammar = GetScImport().GetDocument()->GetStorageGrammar();
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationAttrTokenMap();
- for( sal_Int16 i=0; i < nAttrCount; ++i )
- {
- const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
- rtl::OUString aLocalName;
- USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
- sAttrName, &aLocalName );
- const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
-
- switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
- {
- case XML_TOK_CONTENT_VALIDATION_NAME:
- sName = sValue;
- break;
- case XML_TOK_CONTENT_VALIDATION_CONDITION:
- {
- sal_uInt16 nCondPrefix = GetImport().GetNamespaceMap().
- _GetKeyByAttrName( sValue, &sCondition, sal_False );
-
- if (!ScXMLImport::IsAcceptedFormulaNamespace( nCondPrefix,
- sValue, eGrammar, eStorageGrammar))
- sCondition = sValue;
- }
- break;
- case XML_TOK_CONTENT_VALIDATION_BASE_CELL_ADDRESS:
- sBaseCellAddress = sValue;
- break;
- case XML_TOK_CONTENT_VALIDATION_ALLOW_EMPTY_CELL:
- if (IsXMLToken(sValue, XML_FALSE))
- bAllowEmptyCell = sal_False;
- break;
- case XML_TOK_CONTENT_VALIDATION_DISPLAY_LIST:
- {
- if (IsXMLToken(sValue, XML_NO))
- {
- nShowList = sheet::TableValidationVisibility::INVISIBLE;
- }
- else if (IsXMLToken(sValue, XML_UNSORTED))
- {
- nShowList = sheet::TableValidationVisibility::UNSORTED;
- }
- else if (IsXMLToken(sValue, XML_SORTED_ASCENDING))
- {
- nShowList = sheet::TableValidationVisibility::SORTEDASCENDING;
- }
- }
- break;
- }
- }
-}
-
-ScXMLContentValidationContext::~ScXMLContentValidationContext()
-{
-}
-
-SvXMLImportContext *ScXMLContentValidationContext::CreateChildContext( USHORT nPrefix,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
-{
- SvXMLImportContext *pContext = 0;
-
- const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationElemTokenMap();
- switch( rTokenMap.Get( nPrefix, rLName ) )
- {
- case XML_TOK_CONTENT_VALIDATION_ELEM_HELP_MESSAGE:
- pContext = new ScXMLHelpMessageContext( GetScImport(), nPrefix, rLName, xAttrList, this);
- break;
- case XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MESSAGE:
- pContext = new ScXMLErrorMessageContext( GetScImport(), nPrefix, rLName, xAttrList, this);
- break;
- case XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MACRO:
- pContext = new ScXMLErrorMacroContext( GetScImport(), nPrefix, rLName, xAttrList, this);
- break;
- case XML_TOK_CONTENT_VALIDATION_ELEM_EVENT_LISTENERS:
- pContext = new XMLEventsImportContext( GetImport(), nPrefix, rLName );
- xEventContext = pContext;
- break;
- }
-
- if( !pContext )
- pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
-
- return pContext;
-}
-
-void ScXMLContentValidationContext::GetAlertStyle(const rtl::OUString& sMessageType, com::sun::star::sheet::ValidationAlertStyle& aAlertStyle)
-{
- if (IsXMLToken(sMessageType, XML_MACRO))
- aAlertStyle = sheet::ValidationAlertStyle_MACRO;
- else if (IsXMLToken(sMessageType, XML_STOP))
- aAlertStyle = sheet::ValidationAlertStyle_STOP;
- else if (IsXMLToken(sMessageType, XML_WARNING))
- aAlertStyle = sheet::ValidationAlertStyle_WARNING;
- else if (IsXMLToken(sMessageType, XML_INFORMATION))
- aAlertStyle = sheet::ValidationAlertStyle_INFO;
- else // don't leave uninitialized
- aAlertStyle = sheet::ValidationAlertStyle_STOP;
-}
-
-void ScXMLContentValidationContext::SetFormulas(const rtl::OUString& sFormulas, rtl::OUString& sFormula1, rtl::OUString& sFormula2) const
-{
- sal_Int32 i = 0;
- sal_Bool bString = sal_False;
- sal_Int32 nBrakes = 0;
- while ((sFormulas[i] != ',' || nBrakes > 0 || bString) && i < sFormulas.getLength())
- {
- if (sFormulas[i] == '(')
- ++nBrakes;
- if (sFormulas[i] == ')')
- --nBrakes;
- if (sFormulas[i] == '"')
- bString = !bString;
- ++i;
- }
- if (sFormulas[i] == ',')
- {
- sFormula1 = sFormulas.copy(0, i);
- sFormula2 = sFormulas.copy(i + 1);
- }
-}
-
-void ScXMLContentValidationContext::GetCondition(const rtl::OUString& sTempCondition, rtl::OUString& sFormula1, rtl::OUString& sFormula2,
- com::sun::star::sheet::ValidationType& aValidationType,
- com::sun::star::sheet::ConditionOperator& aOperator)
-{
- aValidationType = sheet::ValidationType_ANY; // #b6343997# default if no condition is given
- aOperator = sheet::ConditionOperator_NONE;
-
- rtl::OUString sLocalCondition(sTempCondition);
- if (sLocalCondition.getLength())
- {
- // ToDo: erase all blanks in the condition, but not in formulas or strings
- rtl::OUString scell_content(RTL_CONSTASCII_USTRINGPARAM("cell_content"));
- rtl::OUString scell_content_is_date(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-date"));
- rtl::OUString scell_content_is_time(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-time"));
- rtl::OUString scell_content_is_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-between"));
- rtl::OUString scell_content_is_in_list(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-in-list"));
- rtl::OUString scell_content_text_length(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length"));
- rtl::OUString scell_content_is_not_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-not-between"));
- rtl::OUString scell_content_is_whole_number(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-whole-number"));
- rtl::OUString scell_content_is_decimal_number(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-decimal-number"));
- rtl::OUString scell_content_text_length_is_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-between"));
- rtl::OUString scell_content_text_length_is_not_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-not-between"));
- sal_Int32 i = 0;
- sal_Bool bAnd(sal_True);
- while (sLocalCondition[i] != '(' && i < sLocalCondition.getLength())
- ++i;
- if (sLocalCondition[i] == '(')
- {
- if (i != scell_content_text_length.getLength() &&
- i != scell_content_text_length_is_between.getLength() &&
- i != scell_content_text_length_is_not_between.getLength() &&
- i != scell_content_is_in_list.getLength())
- {
- if (i == scell_content_is_time.getLength())
- {
- rtl::OUString sTemp = sLocalCondition.copy(0, i);
- if (sTemp == scell_content_is_time)
- aValidationType = sheet::ValidationType_TIME;
- else
- aValidationType = sheet::ValidationType_DATE;
- }
- else if (i == scell_content_is_whole_number.getLength())
- aValidationType = sheet::ValidationType_WHOLE;
- else if (i == scell_content_is_decimal_number.getLength())
- aValidationType = sheet::ValidationType_DECIMAL;
- sLocalCondition = sLocalCondition.copy(i + 2);
- rtl::OUString sTemp = sLocalCondition.copy(0, 5);
- if (sTemp.compareToAscii(" and ") == 0)
- sLocalCondition = sLocalCondition.copy(5);
- else
- bAnd = sal_False;
- }
- if (sLocalCondition.getLength() && bAnd)
- {
- i = 0;
- while (sLocalCondition[i] != '(' && i < sLocalCondition.getLength())
- ++i;
- if (sLocalCondition[i] == '(')
- {
- rtl::OUString sTemp = sLocalCondition.copy(0, i);
- sLocalCondition = sLocalCondition.copy(i + 1);
- if (i == scell_content_is_between.getLength() ||
- i == scell_content_text_length_is_between.getLength())
- {
- if (sTemp == scell_content_is_in_list)
- {
- aValidationType = sheet::ValidationType_LIST;
- sFormula1 = sLocalCondition.copy(0, sLocalCondition.getLength() - 1);
- aOperator = sheet::ConditionOperator_EQUAL;
- }
- else
- {
- if (i == scell_content_text_length_is_between.getLength())
- aValidationType = sheet::ValidationType_TEXT_LEN;
- aOperator = sheet::ConditionOperator_BETWEEN;
- sLocalCondition = sLocalCondition.copy(0, sLocalCondition.getLength() - 1);
- SetFormulas(sLocalCondition, sFormula1, sFormula2);
- }
- }
- else if (i == scell_content_is_not_between.getLength() ||
- i == scell_content_text_length_is_not_between.getLength())
- {
- if (i == scell_content_text_length_is_not_between.getLength())
- aValidationType = sheet::ValidationType_TEXT_LEN;
- aOperator = sheet::ConditionOperator_NOT_BETWEEN;
- sLocalCondition = sLocalCondition.copy(0, sLocalCondition.getLength() - 1);
- SetFormulas(sLocalCondition, sFormula1, sFormula2);
- }
- else if (i == scell_content.getLength() ||
- i == scell_content_text_length.getLength())
- {
- if (i == scell_content_text_length.getLength())
- aValidationType = sheet::ValidationType_TEXT_LEN;
- sLocalCondition = sLocalCondition.copy(1);
- switch (sLocalCondition[0])
- {
- case '<' :
- {
- if (sLocalCondition[1] == '=')
- {
- aOperator = sheet::ConditionOperator_LESS_EQUAL;
- sLocalCondition = sLocalCondition.copy(2);
- }
- else
- {
- aOperator = sheet::ConditionOperator_LESS;
- sLocalCondition = sLocalCondition.copy(1);
- }
- }
- break;
- case '>' :
- {
- if (sLocalCondition[1] == '=')
- {
- aOperator = sheet::ConditionOperator_GREATER_EQUAL;
- sLocalCondition = sLocalCondition.copy(2);
- }
- else
- {
- aOperator = sheet::ConditionOperator_GREATER;
- sLocalCondition = sLocalCondition.copy(1);
- }
- }
- break;
- case '=' :
- {
- aOperator = sheet::ConditionOperator_EQUAL;
- sLocalCondition = sLocalCondition.copy(1);
- }
- break;
- case '!' :
- {
- aOperator = sheet::ConditionOperator_NOT_EQUAL;
- sLocalCondition = sLocalCondition.copy(1);
- }
- break;
- }
- sFormula1 = sLocalCondition;
- }
- }
- }
- }
- }
-
- // a validation type (date, integer) without a condition isn't possible
- if ( aOperator == sheet::ConditionOperator_NONE )
- aValidationType = sheet::ValidationType_ANY;
-}
-
-void ScXMLContentValidationContext::EndElement()
-{
- // #i36650# event-listeners element moved up one level
- if (xEventContext.Is())
- {
- rtl::OUString sOnError(RTL_CONSTASCII_USTRINGPARAM("OnError"));
- XMLEventsImportContext* pEvents =
- (XMLEventsImportContext*)&xEventContext;
- uno::Sequence<beans::PropertyValue> aValues;
- pEvents->GetEventSequence( sOnError, aValues );
-
- sal_Int32 nLength = aValues.getLength();
- for( sal_Int32 i = 0; i < nLength; i++ )
- {
- // #i47525# must allow "MacroName" or "Script"
- if ( aValues[i].Name.equalsAsciiL( "MacroName", sizeof("MacroName")-1 ) ||
- aValues[i].Name.equalsAsciiL( "Script", sizeof("Script")-1 ) )
- {
- aValues[i].Value >>= sErrorTitle;
- break;
- }
- }
- }
-
- ScMyImportValidation aValidation;
- aValidation.eGrammar = eGrammar;
- aValidation.sName = sName;
- aValidation.sBaseCellAddress = sBaseCellAddress;
- aValidation.sImputTitle = sHelpTitle;
- aValidation.sImputMessage = sHelpMessage;
- aValidation.sErrorTitle = sErrorTitle;
- aValidation.sErrorMessage = sErrorMessage;
- GetCondition(sCondition, aValidation.sFormula1, aValidation.sFormula2, aValidation.aValidationType, aValidation.aOperator);
- GetAlertStyle(sErrorMessageType, aValidation.aAlertStyle);
- aValidation.bShowErrorMessage = bDisplayError;
- aValidation.bShowImputMessage = bDisplayHelp;
- aValidation.bIgnoreBlanks = bAllowEmptyCell;
- aValidation.nShowList = nShowList;
- GetScImport().AddValidation(aValidation);
-}
-
-void ScXMLContentValidationContext::SetHelpMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage, const sal_Bool bDisplay)
-{
- sHelpTitle = sTitle;
- sHelpMessage = sMessage;
- bDisplayHelp = bDisplay;
-}
-
-void ScXMLContentValidationContext::SetErrorMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage,
- const rtl::OUString& sMessageType, const sal_Bool bDisplay)
-{
- sErrorTitle = sTitle;
- sErrorMessage = sMessage;
- sErrorMessageType = sMessageType;
- bDisplayError = bDisplay;
-}
-
-void ScXMLContentValidationContext::SetErrorMacro(const sal_Bool bExecute)
-{
- sErrorMessageType = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("macro"));
- bDisplayError = bExecute;
-}
-
-ScXMLHelpMessageContext::ScXMLHelpMessageContext( ScXMLImport& rImport,
- USHORT nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
- ScXMLContentValidationContext* pTempValidationContext) :
- SvXMLImportContext( rImport, nPrfx, rLName ),
- sTitle(),
- sMessage(),
- nParagraphCount(0),
- bDisplay(sal_False)
-{
- pValidationContext = pTempValidationContext;
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationHelpMessageAttrTokenMap();
- for( sal_Int16 i=0; i < nAttrCount; ++i )
- {
- const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
- rtl::OUString aLocalName;
- USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
- sAttrName, &aLocalName );
- const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
-
- switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
- {
- case XML_TOK_HELP_MESSAGE_ATTR_TITLE:
- sTitle = sValue;
- break;
- case XML_TOK_HELP_MESSAGE_ATTR_DISPLAY:
- bDisplay = IsXMLToken(sValue, XML_TRUE);
- break;
- }
- }
-}
-
-ScXMLHelpMessageContext::~ScXMLHelpMessageContext()
-{
-}
-
-SvXMLImportContext *ScXMLHelpMessageContext::CreateChildContext( USHORT nPrefix,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
-{
- SvXMLImportContext *pContext = 0;
-
- const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationMessageElemTokenMap();
- switch( rTokenMap.Get( nPrefix, rLName ) )
- {
- case XML_TOK_P:
- {
- if(nParagraphCount)
- sMessage.append(static_cast<sal_Unicode>('\n'));
- ++nParagraphCount;
- pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLName, xAttrList, sMessage);
- }
- break;
- }
-
- if( !pContext )
- pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
-
- return pContext;
-}
-
-void ScXMLHelpMessageContext::EndElement()
-{
- pValidationContext->SetHelpMessage(sTitle, sMessage.makeStringAndClear(), bDisplay);
-}
-
-ScXMLErrorMessageContext::ScXMLErrorMessageContext( ScXMLImport& rImport,
- USHORT nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
- ScXMLContentValidationContext* pTempValidationContext) :
- SvXMLImportContext( rImport, nPrfx, rLName ),
- sTitle(),
- sMessage(),
- sMessageType(),
- nParagraphCount(0),
- bDisplay(sal_False)
-{
- pValidationContext = pTempValidationContext;
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationErrorMessageAttrTokenMap();
- for( sal_Int16 i=0; i < nAttrCount; ++i )
- {
- const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
- rtl::OUString aLocalName;
- USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
- sAttrName, &aLocalName );
- const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
-
- switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
- {
- case XML_TOK_ERROR_MESSAGE_ATTR_TITLE:
- sTitle = sValue;
- break;
- case XML_TOK_ERROR_MESSAGE_ATTR_MESSAGE_TYPE:
- sMessageType = sValue;
- break;
- case XML_TOK_ERROR_MESSAGE_ATTR_DISPLAY:
- bDisplay = IsXMLToken(sValue, XML_TRUE);
- break;
- }
- }
-}
-
-ScXMLErrorMessageContext::~ScXMLErrorMessageContext()
-{
-}
-
-SvXMLImportContext *ScXMLErrorMessageContext::CreateChildContext( USHORT nPrefix,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
-{
- SvXMLImportContext *pContext = 0;
-
- const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationMessageElemTokenMap();
- switch( rTokenMap.Get( nPrefix, rLName ) )
- {
- case XML_TOK_P:
- {
- if(nParagraphCount)
- sMessage.append(static_cast<sal_Unicode>('\n'));
- ++nParagraphCount;
- pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLName, xAttrList, sMessage);
- }
- break;
- }
-
- if( !pContext )
- pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
-
- return pContext;
-}
-
-void ScXMLErrorMessageContext::EndElement()
-{
- pValidationContext->SetErrorMessage(sTitle, sMessage.makeStringAndClear(), sMessageType, bDisplay);
-}
-
-ScXMLErrorMacroContext::ScXMLErrorMacroContext( ScXMLImport& rImport,
- USHORT nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
- ScXMLContentValidationContext* pTempValidationContext) :
- SvXMLImportContext( rImport, nPrfx, rLName ),
- sName(),
- bExecute(sal_False)
-{
- pValidationContext = pTempValidationContext;
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationErrorMacroAttrTokenMap();
- for( sal_Int16 i=0; i < nAttrCount; ++i )
- {
- const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
- rtl::OUString aLocalName;
- USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
- sAttrName, &aLocalName );
- const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
-
- switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
- {
- case XML_TOK_ERROR_MACRO_ATTR_NAME:
- sName = sValue;
- break;
- case XML_TOK_ERROR_MACRO_ATTR_EXECUTE:
- bExecute = IsXMLToken(sValue, XML_TRUE);
- break;
- }
- }
-}
-
-ScXMLErrorMacroContext::~ScXMLErrorMacroContext()
-{
-}
-
-SvXMLImportContext *ScXMLErrorMacroContext::CreateChildContext( USHORT nPrefix,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
-{
- SvXMLImportContext *pContext = NULL;
-
- if ((nPrefix == XML_NAMESPACE_SCRIPT) && IsXMLToken(rLName, XML_EVENTS))
- {
- pContext = new XMLEventsImportContext(GetImport(), nPrefix, rLName);
- }
- if (!pContext)
- pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
-
- return pContext;
-}
-
-void ScXMLErrorMacroContext::EndElement()
-{
- pValidationContext->SetErrorMacro( bExecute );
-}
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: xmlcvali.cxx,v $
+ * $Revision: 1.27 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "xmlcvali.hxx"
+#include "xmlimprt.hxx"
+#include "xmlconti.hxx"
+#include "document.hxx"
+#include "XMLConverter.hxx"
+
+#include <xmloff/xmltkmap.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/XMLEventsImportContext.hxx>
+#include <com/sun/star/sheet/TableValidationVisibility.hpp>
+#include <tools/debug.hxx>
+
+using namespace com::sun::star;
+using namespace xmloff::token;
+
+class ScXMLContentValidationContext : public SvXMLImportContext
+{
+ rtl::OUString sName;
+ rtl::OUString sHelpTitle;
+ rtl::OUString sHelpMessage;
+ rtl::OUString sErrorTitle;
+ rtl::OUString sErrorMessage;
+ rtl::OUString sErrorMessageType;
+ rtl::OUString sBaseCellAddress;
+ rtl::OUString sCondition;
+ formula::FormulaGrammar::Grammar eGrammar;
+ sal_Int16 nShowList;
+ sal_Bool bAllowEmptyCell;
+ sal_Bool bDisplayHelp;
+ sal_Bool bDisplayError;
+
+ SvXMLImportContextRef xEventContext;
+
+ const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
+ ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
+
+ void GetAlertStyle(const rtl::OUString& sMessageType, com::sun::star::sheet::ValidationAlertStyle& aAlertStyle);
+ void SetFormulas(const rtl::OUString& sFormulas, rtl::OUString& sFormula1, rtl::OUString& sFormula2) const;
+ void GetCondition(const rtl::OUString& sCondition, rtl::OUString& sFormula1, rtl::OUString& sFormula2,
+ com::sun::star::sheet::ValidationType& aValidationType,
+ com::sun::star::sheet::ConditionOperator& aOperator);
+
+public:
+
+ ScXMLContentValidationContext( ScXMLImport& rImport, USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList);
+
+ virtual ~ScXMLContentValidationContext();
+
+ virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
+
+ virtual void EndElement();
+
+ void SetHelpMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage, const sal_Bool bDisplay);
+ void SetErrorMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage, const rtl::OUString& sMessageType, const sal_Bool bDisplay);
+ void SetErrorMacro(const sal_Bool bExecute);
+};
+
+class ScXMLHelpMessageContext : public SvXMLImportContext
+{
+ rtl::OUString sTitle;
+ rtl::OUStringBuffer sMessage;
+ sal_Int32 nParagraphCount;
+ sal_Bool bDisplay;
+
+ ScXMLContentValidationContext* pValidationContext;
+
+ const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
+ ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
+
+public:
+
+ ScXMLHelpMessageContext( ScXMLImport& rImport, USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScXMLContentValidationContext* pValidationContext);
+
+ virtual ~ScXMLHelpMessageContext();
+
+ virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
+
+ virtual void EndElement();
+};
+
+class ScXMLErrorMessageContext : public SvXMLImportContext
+{
+ rtl::OUString sTitle;
+ rtl::OUStringBuffer sMessage;
+ rtl::OUString sMessageType;
+ sal_Int32 nParagraphCount;
+ sal_Bool bDisplay;
+
+ ScXMLContentValidationContext* pValidationContext;
+
+ const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
+ ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
+
+public:
+
+ ScXMLErrorMessageContext( ScXMLImport& rImport, USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScXMLContentValidationContext* pValidationContext);
+
+ virtual ~ScXMLErrorMessageContext();
+
+ virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
+
+ virtual void EndElement();
+};
+
+class ScXMLErrorMacroContext : public SvXMLImportContext
+{
+ rtl::OUString sName;
+ sal_Bool bExecute;
+
+ ScXMLContentValidationContext* pValidationContext;
+
+ const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
+ ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
+
+public:
+
+ ScXMLErrorMacroContext( ScXMLImport& rImport, USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScXMLContentValidationContext* pValidationContext);
+
+ virtual ~ScXMLErrorMacroContext();
+
+ virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
+ virtual void EndElement();
+};
+
+//------------------------------------------------------------------
+
+ScXMLContentValidationsContext::ScXMLContentValidationsContext( ScXMLImport& rImport,
+ USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ ) :
+ SvXMLImportContext( rImport, nPrfx, rLName )
+{
+ // here are no attributes
+}
+
+ScXMLContentValidationsContext::~ScXMLContentValidationsContext()
+{
+}
+
+SvXMLImportContext *ScXMLContentValidationsContext::CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationsElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLName ) )
+ {
+ case XML_TOK_CONTENT_VALIDATION:
+ pContext = new ScXMLContentValidationContext( GetScImport(), nPrefix, rLName, xAttrList);
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
+
+ return pContext;
+}
+
+void ScXMLContentValidationsContext::EndElement()
+{
+}
+
+ScXMLContentValidationContext::ScXMLContentValidationContext( ScXMLImport& rImport,
+ USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ sName(),
+ sHelpTitle(),
+ sHelpMessage(),
+ sErrorTitle(),
+ sErrorMessage(),
+ sErrorMessageType(),
+ sBaseCellAddress(),
+ sCondition(),
+ nShowList(sheet::TableValidationVisibility::UNSORTED),
+ bAllowEmptyCell(sal_True),
+ bDisplayHelp(sal_False),
+ bDisplayError(sal_False)
+{
+ const formula::FormulaGrammar::Grammar eStorageGrammar = eGrammar = GetScImport().GetDocument()->GetStorageGrammar();
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationAttrTokenMap();
+ for( sal_Int16 i=0; i < nAttrCount; ++i )
+ {
+ const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+ rtl::OUString aLocalName;
+ USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
+ sAttrName, &aLocalName );
+ const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_CONTENT_VALIDATION_NAME:
+ sName = sValue;
+ break;
+ case XML_TOK_CONTENT_VALIDATION_CONDITION:
+ {
+ sal_uInt16 nCondPrefix = GetImport().GetNamespaceMap().
+ _GetKeyByAttrName( sValue, &sCondition, sal_False );
+
+ if (!ScXMLImport::IsAcceptedFormulaNamespace( nCondPrefix,
+ sValue, eGrammar, eStorageGrammar))
+ sCondition = sValue;
+ }
+ break;
+ case XML_TOK_CONTENT_VALIDATION_BASE_CELL_ADDRESS:
+ sBaseCellAddress = sValue;
+ break;
+ case XML_TOK_CONTENT_VALIDATION_ALLOW_EMPTY_CELL:
+ if (IsXMLToken(sValue, XML_FALSE))
+ bAllowEmptyCell = sal_False;
+ break;
+ case XML_TOK_CONTENT_VALIDATION_DISPLAY_LIST:
+ {
+ if (IsXMLToken(sValue, XML_NO))
+ {
+ nShowList = sheet::TableValidationVisibility::INVISIBLE;
+ }
+ else if (IsXMLToken(sValue, XML_UNSORTED))
+ {
+ nShowList = sheet::TableValidationVisibility::UNSORTED;
+ }
+ else if (IsXMLToken(sValue, XML_SORTED_ASCENDING))
+ {
+ nShowList = sheet::TableValidationVisibility::SORTEDASCENDING;
+ }
+ }
+ break;
+ }
+ }
+}
+
+ScXMLContentValidationContext::~ScXMLContentValidationContext()
+{
+}
+
+SvXMLImportContext *ScXMLContentValidationContext::CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLName ) )
+ {
+ case XML_TOK_CONTENT_VALIDATION_ELEM_HELP_MESSAGE:
+ pContext = new ScXMLHelpMessageContext( GetScImport(), nPrefix, rLName, xAttrList, this);
+ break;
+ case XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MESSAGE:
+ pContext = new ScXMLErrorMessageContext( GetScImport(), nPrefix, rLName, xAttrList, this);
+ break;
+ case XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MACRO:
+ pContext = new ScXMLErrorMacroContext( GetScImport(), nPrefix, rLName, xAttrList, this);
+ break;
+ case XML_TOK_CONTENT_VALIDATION_ELEM_EVENT_LISTENERS:
+ pContext = new XMLEventsImportContext( GetImport(), nPrefix, rLName );
+ xEventContext = pContext;
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
+
+ return pContext;
+}
+
+void ScXMLContentValidationContext::GetAlertStyle(const rtl::OUString& sMessageType, com::sun::star::sheet::ValidationAlertStyle& aAlertStyle)
+{
+ if (IsXMLToken(sMessageType, XML_MACRO))
+ aAlertStyle = sheet::ValidationAlertStyle_MACRO;
+ else if (IsXMLToken(sMessageType, XML_STOP))
+ aAlertStyle = sheet::ValidationAlertStyle_STOP;
+ else if (IsXMLToken(sMessageType, XML_WARNING))
+ aAlertStyle = sheet::ValidationAlertStyle_WARNING;
+ else if (IsXMLToken(sMessageType, XML_INFORMATION))
+ aAlertStyle = sheet::ValidationAlertStyle_INFO;
+ else // don't leave uninitialized
+ aAlertStyle = sheet::ValidationAlertStyle_STOP;
+}
+
+void ScXMLContentValidationContext::SetFormulas(const rtl::OUString& sFormulas, rtl::OUString& sFormula1, rtl::OUString& sFormula2) const
+{
+ sal_Int32 i = 0;
+ sal_Bool bString = sal_False;
+ sal_Int32 nBrakes = 0;
+ while ((sFormulas[i] != ',' || nBrakes > 0 || bString) && i < sFormulas.getLength())
+ {
+ if (sFormulas[i] == '(')
+ ++nBrakes;
+ if (sFormulas[i] == ')')
+ --nBrakes;
+ if (sFormulas[i] == '"')
+ bString = !bString;
+ ++i;
+ }
+ if (sFormulas[i] == ',')
+ {
+ sFormula1 = sFormulas.copy(0, i);
+ sFormula2 = sFormulas.copy(i + 1);
+ }
+}
+
+void ScXMLContentValidationContext::GetCondition(const rtl::OUString& sTempCondition, rtl::OUString& sFormula1, rtl::OUString& sFormula2,
+ com::sun::star::sheet::ValidationType& aValidationType,
+ com::sun::star::sheet::ConditionOperator& aOperator)
+{
+ aValidationType = sheet::ValidationType_ANY; // #b6343997# default if no condition is given
+ aOperator = sheet::ConditionOperator_NONE;
+
+ rtl::OUString sLocalCondition(sTempCondition);
+ if (sLocalCondition.getLength())
+ {
+ // ToDo: erase all blanks in the condition, but not in formulas or strings
+ rtl::OUString scell_content(RTL_CONSTASCII_USTRINGPARAM("cell_content"));
+ rtl::OUString scell_content_is_date(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-date"));
+ rtl::OUString scell_content_is_time(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-time"));
+ rtl::OUString scell_content_is_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-between"));
+ rtl::OUString scell_content_is_in_list(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-in-list"));
+ rtl::OUString scell_content_text_length(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length"));
+ rtl::OUString scell_content_is_not_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-not-between"));
+ rtl::OUString scell_content_is_whole_number(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-whole-number"));
+ rtl::OUString scell_content_is_decimal_number(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-decimal-number"));
+ rtl::OUString scell_content_text_length_is_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-between"));
+ rtl::OUString scell_content_text_length_is_not_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-not-between"));
+ sal_Int32 i = 0;
+ sal_Bool bAnd(sal_True);
+ while (sLocalCondition[i] != '(' && i < sLocalCondition.getLength())
+ ++i;
+ if (sLocalCondition[i] == '(')
+ {
+ if (i != scell_content_text_length.getLength() &&
+ i != scell_content_text_length_is_between.getLength() &&
+ i != scell_content_text_length_is_not_between.getLength() &&
+ i != scell_content_is_in_list.getLength())
+ {
+ if (i == scell_content_is_time.getLength())
+ {
+ rtl::OUString sTemp = sLocalCondition.copy(0, i);
+ if (sTemp == scell_content_is_time)
+ aValidationType = sheet::ValidationType_TIME;
+ else
+ aValidationType = sheet::ValidationType_DATE;
+ }
+ else if (i == scell_content_is_whole_number.getLength())
+ aValidationType = sheet::ValidationType_WHOLE;
+ else if (i == scell_content_is_decimal_number.getLength())
+ aValidationType = sheet::ValidationType_DECIMAL;
+ sLocalCondition = sLocalCondition.copy(i + 2);
+ rtl::OUString sTemp = sLocalCondition.copy(0, 5);
+ if (sTemp.compareToAscii(" and ") == 0)
+ sLocalCondition = sLocalCondition.copy(5);
+ else
+ bAnd = sal_False;
+ }
+ if (sLocalCondition.getLength() && bAnd)
+ {
+ i = 0;
+ while (sLocalCondition[i] != '(' && i < sLocalCondition.getLength())
+ ++i;
+ if (sLocalCondition[i] == '(')
+ {
+ rtl::OUString sTemp = sLocalCondition.copy(0, i);
+ sLocalCondition = sLocalCondition.copy(i + 1);
+ if (i == scell_content_is_between.getLength() ||
+ i == scell_content_text_length_is_between.getLength())
+ {
+ if (sTemp == scell_content_is_in_list)
+ {
+ aValidationType = sheet::ValidationType_LIST;
+ sFormula1 = sLocalCondition.copy(0, sLocalCondition.getLength() - 1);
+ aOperator = sheet::ConditionOperator_EQUAL;
+ }
+ else
+ {
+ if (i == scell_content_text_length_is_between.getLength())
+ aValidationType = sheet::ValidationType_TEXT_LEN;
+ aOperator = sheet::ConditionOperator_BETWEEN;
+ sLocalCondition = sLocalCondition.copy(0, sLocalCondition.getLength() - 1);
+ SetFormulas(sLocalCondition, sFormula1, sFormula2);
+ }
+ }
+ else if (i == scell_content_is_not_between.getLength() ||
+ i == scell_content_text_length_is_not_between.getLength())
+ {
+ if (i == scell_content_text_length_is_not_between.getLength())
+ aValidationType = sheet::ValidationType_TEXT_LEN;
+ aOperator = sheet::ConditionOperator_NOT_BETWEEN;
+ sLocalCondition = sLocalCondition.copy(0, sLocalCondition.getLength() - 1);
+ SetFormulas(sLocalCondition, sFormula1, sFormula2);
+ }
+ else if (i == scell_content.getLength() ||
+ i == scell_content_text_length.getLength())
+ {
+ if (i == scell_content_text_length.getLength())
+ aValidationType = sheet::ValidationType_TEXT_LEN;
+ sLocalCondition = sLocalCondition.copy(1);
+ switch (sLocalCondition[0])
+ {
+ case '<' :
+ {
+ if (sLocalCondition[1] == '=')
+ {
+ aOperator = sheet::ConditionOperator_LESS_EQUAL;
+ sLocalCondition = sLocalCondition.copy(2);
+ }
+ else
+ {
+ aOperator = sheet::ConditionOperator_LESS;
+ sLocalCondition = sLocalCondition.copy(1);
+ }
+ }
+ break;
+ case '>' :
+ {
+ if (sLocalCondition[1] == '=')
+ {
+ aOperator = sheet::ConditionOperator_GREATER_EQUAL;
+ sLocalCondition = sLocalCondition.copy(2);
+ }
+ else
+ {
+ aOperator = sheet::ConditionOperator_GREATER;
+ sLocalCondition = sLocalCondition.copy(1);
+ }
+ }
+ break;
+ case '=' :
+ {
+ aOperator = sheet::ConditionOperator_EQUAL;
+ sLocalCondition = sLocalCondition.copy(1);
+ }
+ break;
+ case '!' :
+ {
+ aOperator = sheet::ConditionOperator_NOT_EQUAL;
+ sLocalCondition = sLocalCondition.copy(1);
+ }
+ break;
+ }
+ sFormula1 = sLocalCondition;
+ }
+ }
+ }
+ }
+ }
+
+ // a validation type (date, integer) without a condition isn't possible
+ if ( aOperator == sheet::ConditionOperator_NONE )
+ aValidationType = sheet::ValidationType_ANY;
+}
+
+void ScXMLContentValidationContext::EndElement()
+{
+ // #i36650# event-listeners element moved up one level
+ if (xEventContext.Is())
+ {
+ rtl::OUString sOnError(RTL_CONSTASCII_USTRINGPARAM("OnError"));
+ XMLEventsImportContext* pEvents =
+ (XMLEventsImportContext*)&xEventContext;
+ uno::Sequence<beans::PropertyValue> aValues;
+ pEvents->GetEventSequence( sOnError, aValues );
+
+ sal_Int32 nLength = aValues.getLength();
+ for( sal_Int32 i = 0; i < nLength; i++ )
+ {
+ // #i47525# must allow "MacroName" or "Script"
+ if ( aValues[i].Name.equalsAsciiL( "MacroName", sizeof("MacroName")-1 ) ||
+ aValues[i].Name.equalsAsciiL( "Script", sizeof("Script")-1 ) )
+ {
+ aValues[i].Value >>= sErrorTitle;
+ break;
+ }
+ }
+ }
+
+ ScMyImportValidation aValidation;
+ aValidation.eGrammar = eGrammar;
+ aValidation.sName = sName;
+ aValidation.sBaseCellAddress = sBaseCellAddress;
+ aValidation.sImputTitle = sHelpTitle;
+ aValidation.sImputMessage = sHelpMessage;
+ aValidation.sErrorTitle = sErrorTitle;
+ aValidation.sErrorMessage = sErrorMessage;
+ GetCondition(sCondition, aValidation.sFormula1, aValidation.sFormula2, aValidation.aValidationType, aValidation.aOperator);
+ GetAlertStyle(sErrorMessageType, aValidation.aAlertStyle);
+ aValidation.bShowErrorMessage = bDisplayError;
+ aValidation.bShowImputMessage = bDisplayHelp;
+ aValidation.bIgnoreBlanks = bAllowEmptyCell;
+ aValidation.nShowList = nShowList;
+ GetScImport().AddValidation(aValidation);
+}
+
+void ScXMLContentValidationContext::SetHelpMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage, const sal_Bool bDisplay)
+{
+ sHelpTitle = sTitle;
+ sHelpMessage = sMessage;
+ bDisplayHelp = bDisplay;
+}
+
+void ScXMLContentValidationContext::SetErrorMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage,
+ const rtl::OUString& sMessageType, const sal_Bool bDisplay)
+{
+ sErrorTitle = sTitle;
+ sErrorMessage = sMessage;
+ sErrorMessageType = sMessageType;
+ bDisplayError = bDisplay;
+}
+
+void ScXMLContentValidationContext::SetErrorMacro(const sal_Bool bExecute)
+{
+ sErrorMessageType = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("macro"));
+ bDisplayError = bExecute;
+}
+
+ScXMLHelpMessageContext::ScXMLHelpMessageContext( ScXMLImport& rImport,
+ USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScXMLContentValidationContext* pTempValidationContext) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ sTitle(),
+ sMessage(),
+ nParagraphCount(0),
+ bDisplay(sal_False)
+{
+ pValidationContext = pTempValidationContext;
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationHelpMessageAttrTokenMap();
+ for( sal_Int16 i=0; i < nAttrCount; ++i )
+ {
+ const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+ rtl::OUString aLocalName;
+ USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
+ sAttrName, &aLocalName );
+ const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_HELP_MESSAGE_ATTR_TITLE:
+ sTitle = sValue;
+ break;
+ case XML_TOK_HELP_MESSAGE_ATTR_DISPLAY:
+ bDisplay = IsXMLToken(sValue, XML_TRUE);
+ break;
+ }
+ }
+}
+
+ScXMLHelpMessageContext::~ScXMLHelpMessageContext()
+{
+}
+
+SvXMLImportContext *ScXMLHelpMessageContext::CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationMessageElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLName ) )
+ {
+ case XML_TOK_P:
+ {
+ if(nParagraphCount)
+ sMessage.append(static_cast<sal_Unicode>('\n'));
+ ++nParagraphCount;
+ pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLName, xAttrList, sMessage);
+ }
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
+
+ return pContext;
+}
+
+void ScXMLHelpMessageContext::EndElement()
+{
+ pValidationContext->SetHelpMessage(sTitle, sMessage.makeStringAndClear(), bDisplay);
+}
+
+ScXMLErrorMessageContext::ScXMLErrorMessageContext( ScXMLImport& rImport,
+ USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScXMLContentValidationContext* pTempValidationContext) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ sTitle(),
+ sMessage(),
+ sMessageType(),
+ nParagraphCount(0),
+ bDisplay(sal_False)
+{
+ pValidationContext = pTempValidationContext;
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationErrorMessageAttrTokenMap();
+ for( sal_Int16 i=0; i < nAttrCount; ++i )
+ {
+ const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+ rtl::OUString aLocalName;
+ USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
+ sAttrName, &aLocalName );
+ const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_ERROR_MESSAGE_ATTR_TITLE:
+ sTitle = sValue;
+ break;
+ case XML_TOK_ERROR_MESSAGE_ATTR_MESSAGE_TYPE:
+ sMessageType = sValue;
+ break;
+ case XML_TOK_ERROR_MESSAGE_ATTR_DISPLAY:
+ bDisplay = IsXMLToken(sValue, XML_TRUE);
+ break;
+ }
+ }
+}
+
+ScXMLErrorMessageContext::~ScXMLErrorMessageContext()
+{
+}
+
+SvXMLImportContext *ScXMLErrorMessageContext::CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
+{
+ SvXMLImportContext *pContext = 0;
+
+ const SvXMLTokenMap& rTokenMap = GetScImport().GetContentValidationMessageElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLName ) )
+ {
+ case XML_TOK_P:
+ {
+ if(nParagraphCount)
+ sMessage.append(static_cast<sal_Unicode>('\n'));
+ ++nParagraphCount;
+ pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLName, xAttrList, sMessage);
+ }
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
+
+ return pContext;
+}
+
+void ScXMLErrorMessageContext::EndElement()
+{
+ pValidationContext->SetErrorMessage(sTitle, sMessage.makeStringAndClear(), sMessageType, bDisplay);
+}
+
+ScXMLErrorMacroContext::ScXMLErrorMacroContext( ScXMLImport& rImport,
+ USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScXMLContentValidationContext* pTempValidationContext) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ sName(),
+ bExecute(sal_False)
+{
+ pValidationContext = pTempValidationContext;
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationErrorMacroAttrTokenMap();
+ for( sal_Int16 i=0; i < nAttrCount; ++i )
+ {
+ const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+ rtl::OUString aLocalName;
+ USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
+ sAttrName, &aLocalName );
+ const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_ERROR_MACRO_ATTR_NAME:
+ sName = sValue;
+ break;
+ case XML_TOK_ERROR_MACRO_ATTR_EXECUTE:
+ bExecute = IsXMLToken(sValue, XML_TRUE);
+ break;
+ }
+ }
+}
+
+ScXMLErrorMacroContext::~ScXMLErrorMacroContext()
+{
+}
+
+SvXMLImportContext *ScXMLErrorMacroContext::CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
+{
+ SvXMLImportContext *pContext = NULL;
+
+ if ((nPrefix == XML_NAMESPACE_SCRIPT) && IsXMLToken(rLName, XML_EVENTS))
+ {
+ pContext = new XMLEventsImportContext(GetImport(), nPrefix, rLName);
+ }
+ if (!pContext)
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
+
+ return pContext;
+}
+
+void ScXMLErrorMacroContext::EndElement()
+{
+ pValidationContext->SetErrorMacro( bExecute );
+}
diff --git a/sc/source/filter/xml/xmlnexpi.cxx b/sc/source/filter/xml/xmlnexpi.cxx
index 249522c1a9bc..3f822d5274c6 100644
--- a/sc/source/filter/xml/xmlnexpi.cxx
+++ b/sc/source/filter/xml/xmlnexpi.cxx
@@ -1,262 +1,262 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: xmlnexpi.cxx,v $
- * $Revision: 1.18 $
- *
- * 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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sc.hxx"
-
-
-
-// INCLUDE ---------------------------------------------------------------
-#include <rtl/ustrbuf.hxx>
-
-#include "xmlnexpi.hxx"
-#include "xmlimprt.hxx"
-#include "xmlcelli.hxx"
-#include "docuno.hxx"
-#include "global.hxx"
-#include "document.hxx"
-#include "XMLConverter.hxx"
-
-#include <xmloff/xmltkmap.hxx>
-#include <xmloff/nmspmap.hxx>
-
-using namespace com::sun::star;
-
-//------------------------------------------------------------------
-
-ScXMLNamedExpressionsContext::ScXMLNamedExpressionsContext( ScXMLImport& rImport,
- USHORT nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ ) :
- SvXMLImportContext( rImport, nPrfx, rLName )
-{
-/* sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- for( sal_Int16 i=0; i < nAttrCount; ++i )
- {
- const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
- rtl::OUString aLocalName;
- USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
- sAttrName, &aLocalName );
- const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
-
- const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetNamedRangeAttrTokenMap();
-
- switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
- {
- }
- }*/
- rImport.LockSolarMutex();
-}
-
-ScXMLNamedExpressionsContext::~ScXMLNamedExpressionsContext()
-{
- GetScImport().UnlockSolarMutex();
-}
-
-SvXMLImportContext *ScXMLNamedExpressionsContext::CreateChildContext( USHORT nPrefix,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
-{
- SvXMLImportContext *pContext(0);
-
- const SvXMLTokenMap& rTokenMap(GetScImport().GetNamedExpressionsElemTokenMap());
- switch( rTokenMap.Get( nPrefix, rLName ) )
- {
- case XML_TOK_NAMED_EXPRESSIONS_NAMED_RANGE:
- pContext = new ScXMLNamedRangeContext( GetScImport(), nPrefix,
- rLName, xAttrList//,
- //this
- );
- break;
- case XML_TOK_NAMED_EXPRESSIONS_NAMED_EXPRESSION:
- pContext = new ScXMLNamedExpressionContext( GetScImport(), nPrefix,
- rLName, xAttrList//,
- //this
- );
- break;
- }
-
- if( !pContext )
- pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
-
- return pContext;
-}
-
-void ScXMLNamedExpressionsContext::EndElement()
-{
- // happends in ScXMLImport::EndDocument()
- // because it has to be set after the Database Ranges
-}
-
-ScXMLNamedRangeContext::ScXMLNamedRangeContext( ScXMLImport& rImport,
- USHORT nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList) :
- SvXMLImportContext( rImport, nPrfx, rLName )
-{
- ScMyNamedExpression* pNamedExpression(new ScMyNamedExpression);
- // A simple table:cell-range-address is not a formula expression, stored
- // without [] brackets but with dot, .A1
- pNamedExpression->eGrammar = formula::FormulaGrammar::mergeToGrammar(
- GetScImport().GetDocument()->GetStorageGrammar(),
- formula::FormulaGrammar::CONV_OOO);
- sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
- const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetNamedRangeAttrTokenMap();
- for( sal_Int16 i=0; i < nAttrCount; ++i )
- {
- const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
- rtl::OUString aLocalName;
- USHORT nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
- sAttrName, &aLocalName ));
- const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
-
- switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
- {
- case XML_TOK_NAMED_RANGE_ATTR_NAME :
- {
- pNamedExpression->sName = sValue;
- }
- break;
- case XML_TOK_NAMED_RANGE_ATTR_CELL_RANGE_ADDRESS :
- {
- pNamedExpression->sContent = sValue;
- }
- break;
- case XML_TOK_NAMED_RANGE_ATTR_BASE_CELL_ADDRESS :
- {
- pNamedExpression->sBaseCellAddress = sValue;
- }
- break;
- case XML_TOK_NAMED_RANGE_ATTR_RANGE_USABLE_AS :
- {
- pNamedExpression->sRangeType = sValue;
- }
- break;
- }
- }
- pNamedExpression->bIsExpression = sal_False;
- GetScImport().AddNamedExpression(pNamedExpression);
-}
-
-ScXMLNamedRangeContext::~ScXMLNamedRangeContext()
-{
-}
-
-SvXMLImportContext *ScXMLNamedRangeContext::CreateChildContext( USHORT nPrefix,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
-{
-/* const SvXMLTokenMap& rTokenMap = GetScImport().GetTableElemTokenMap();
- switch( rTokenMap.Get( nPrefix, rLName ) )
- {
- }*/
- return new SvXMLImportContext( GetImport(), nPrefix, rLName );
-}
-
-void ScXMLNamedRangeContext::EndElement()
-{
-}
-
-ScXMLNamedExpressionContext::ScXMLNamedExpressionContext( ScXMLImport& rImport,
- USHORT nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList) :
- SvXMLImportContext( rImport, nPrfx, rLName )
-{
- ScMyNamedExpression* pNamedExpression(new ScMyNamedExpression);
- const formula::FormulaGrammar::Grammar eStorageGrammar = pNamedExpression->eGrammar =
- GetScImport().GetDocument()->GetStorageGrammar();
- sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
- const SvXMLTokenMap& rAttrTokenMap(GetScImport().GetNamedExpressionAttrTokenMap());
- for( sal_Int16 i=0; i < nAttrCount; ++i )
- {
- const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
- rtl::OUString aLocalName;
- USHORT nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
- sAttrName, &aLocalName ));
- const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
-
- switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
- {
- case XML_TOK_NAMED_EXPRESSION_ATTR_NAME :
- {
- pNamedExpression->sName = sValue;
- }
- break;
- case XML_TOK_NAMED_EXPRESSION_ATTR_EXPRESSION :
- {
- rtl::OUString sFormula;
- sal_uInt16 nFormulaPrefix = GetImport().GetNamespaceMap().
- _GetKeyByAttrName( sValue, &sFormula, sal_False );
-
- if (ScXMLImport::IsAcceptedFormulaNamespace( nFormulaPrefix,
- sValue, pNamedExpression->eGrammar,
- eStorageGrammar))
- pNamedExpression->sContent = sFormula;
- else
- pNamedExpression->sContent = sValue;
- }
- break;
- case XML_TOK_NAMED_EXPRESSION_ATTR_BASE_CELL_ADDRESS :
- {
- pNamedExpression->sBaseCellAddress = sValue;
- }
- break;
- }
- }
- pNamedExpression->bIsExpression = sal_True;
- GetScImport().AddNamedExpression(pNamedExpression);
-}
-
-ScXMLNamedExpressionContext::~ScXMLNamedExpressionContext()
-{
-}
-
-SvXMLImportContext *ScXMLNamedExpressionContext::CreateChildContext( USHORT nPrefix,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
-{
-/* const SvXMLTokenMap& rTokenMap = GetScImport().GetTableElemTokenMap();
- switch( rTokenMap.Get( nPrefix, rLName ) )
- {
- }*/
- return new SvXMLImportContext( GetImport(), nPrefix, rLName );;
-}
-
-void ScXMLNamedExpressionContext::EndElement()
-{
-}
-
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: xmlnexpi.cxx,v $
+ * $Revision: 1.18 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+#include <rtl/ustrbuf.hxx>
+
+#include "xmlnexpi.hxx"
+#include "xmlimprt.hxx"
+#include "xmlcelli.hxx"
+#include "docuno.hxx"
+#include "global.hxx"
+#include "document.hxx"
+#include "XMLConverter.hxx"
+
+#include <xmloff/xmltkmap.hxx>
+#include <xmloff/nmspmap.hxx>
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------
+
+ScXMLNamedExpressionsContext::ScXMLNamedExpressionsContext( ScXMLImport& rImport,
+ USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ ) :
+ SvXMLImportContext( rImport, nPrfx, rLName )
+{
+/* sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; ++i )
+ {
+ const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+ rtl::OUString aLocalName;
+ USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
+ sAttrName, &aLocalName );
+ const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetNamedRangeAttrTokenMap();
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ }
+ }*/
+ rImport.LockSolarMutex();
+}
+
+ScXMLNamedExpressionsContext::~ScXMLNamedExpressionsContext()
+{
+ GetScImport().UnlockSolarMutex();
+}
+
+SvXMLImportContext *ScXMLNamedExpressionsContext::CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
+{
+ SvXMLImportContext *pContext(0);
+
+ const SvXMLTokenMap& rTokenMap(GetScImport().GetNamedExpressionsElemTokenMap());
+ switch( rTokenMap.Get( nPrefix, rLName ) )
+ {
+ case XML_TOK_NAMED_EXPRESSIONS_NAMED_RANGE:
+ pContext = new ScXMLNamedRangeContext( GetScImport(), nPrefix,
+ rLName, xAttrList//,
+ //this
+ );
+ break;
+ case XML_TOK_NAMED_EXPRESSIONS_NAMED_EXPRESSION:
+ pContext = new ScXMLNamedExpressionContext( GetScImport(), nPrefix,
+ rLName, xAttrList//,
+ //this
+ );
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
+
+ return pContext;
+}
+
+void ScXMLNamedExpressionsContext::EndElement()
+{
+ // happends in ScXMLImport::EndDocument()
+ // because it has to be set after the Database Ranges
+}
+
+ScXMLNamedRangeContext::ScXMLNamedRangeContext( ScXMLImport& rImport,
+ USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList) :
+ SvXMLImportContext( rImport, nPrfx, rLName )
+{
+ ScMyNamedExpression* pNamedExpression(new ScMyNamedExpression);
+ // A simple table:cell-range-address is not a formula expression, stored
+ // without [] brackets but with dot, .A1
+ pNamedExpression->eGrammar = formula::FormulaGrammar::mergeToGrammar(
+ GetScImport().GetDocument()->GetStorageGrammar(),
+ formula::FormulaGrammar::CONV_OOO);
+ sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetNamedRangeAttrTokenMap();
+ for( sal_Int16 i=0; i < nAttrCount; ++i )
+ {
+ const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+ rtl::OUString aLocalName;
+ USHORT nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
+ sAttrName, &aLocalName ));
+ const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_NAMED_RANGE_ATTR_NAME :
+ {
+ pNamedExpression->sName = sValue;
+ }
+ break;
+ case XML_TOK_NAMED_RANGE_ATTR_CELL_RANGE_ADDRESS :
+ {
+ pNamedExpression->sContent = sValue;
+ }
+ break;
+ case XML_TOK_NAMED_RANGE_ATTR_BASE_CELL_ADDRESS :
+ {
+ pNamedExpression->sBaseCellAddress = sValue;
+ }
+ break;
+ case XML_TOK_NAMED_RANGE_ATTR_RANGE_USABLE_AS :
+ {
+ pNamedExpression->sRangeType = sValue;
+ }
+ break;
+ }
+ }
+ pNamedExpression->bIsExpression = sal_False;
+ GetScImport().AddNamedExpression(pNamedExpression);
+}
+
+ScXMLNamedRangeContext::~ScXMLNamedRangeContext()
+{
+}
+
+SvXMLImportContext *ScXMLNamedRangeContext::CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
+{
+/* const SvXMLTokenMap& rTokenMap = GetScImport().GetTableElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLName ) )
+ {
+ }*/
+ return new SvXMLImportContext( GetImport(), nPrefix, rLName );
+}
+
+void ScXMLNamedRangeContext::EndElement()
+{
+}
+
+ScXMLNamedExpressionContext::ScXMLNamedExpressionContext( ScXMLImport& rImport,
+ USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList) :
+ SvXMLImportContext( rImport, nPrfx, rLName )
+{
+ ScMyNamedExpression* pNamedExpression(new ScMyNamedExpression);
+ const formula::FormulaGrammar::Grammar eStorageGrammar = pNamedExpression->eGrammar =
+ GetScImport().GetDocument()->GetStorageGrammar();
+ sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
+ const SvXMLTokenMap& rAttrTokenMap(GetScImport().GetNamedExpressionAttrTokenMap());
+ for( sal_Int16 i=0; i < nAttrCount; ++i )
+ {
+ const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+ rtl::OUString aLocalName;
+ USHORT nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
+ sAttrName, &aLocalName ));
+ const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_NAMED_EXPRESSION_ATTR_NAME :
+ {
+ pNamedExpression->sName = sValue;
+ }
+ break;
+ case XML_TOK_NAMED_EXPRESSION_ATTR_EXPRESSION :
+ {
+ rtl::OUString sFormula;
+ sal_uInt16 nFormulaPrefix = GetImport().GetNamespaceMap().
+ _GetKeyByAttrName( sValue, &sFormula, sal_False );
+
+ if (ScXMLImport::IsAcceptedFormulaNamespace( nFormulaPrefix,
+ sValue, pNamedExpression->eGrammar,
+ eStorageGrammar))
+ pNamedExpression->sContent = sFormula;
+ else
+ pNamedExpression->sContent = sValue;
+ }
+ break;
+ case XML_TOK_NAMED_EXPRESSION_ATTR_BASE_CELL_ADDRESS :
+ {
+ pNamedExpression->sBaseCellAddress = sValue;
+ }
+ break;
+ }
+ }
+ pNamedExpression->bIsExpression = sal_True;
+ GetScImport().AddNamedExpression(pNamedExpression);
+}
+
+ScXMLNamedExpressionContext::~ScXMLNamedExpressionContext()
+{
+}
+
+SvXMLImportContext *ScXMLNamedExpressionContext::CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
+{
+/* const SvXMLTokenMap& rTokenMap = GetScImport().GetTableElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLName ) )
+ {
+ }*/
+ return new SvXMLImportContext( GetImport(), nPrefix, rLName );;
+}
+
+void ScXMLNamedExpressionContext::EndElement()
+{
+}
+
diff --git a/sc/source/ui/formdlg/dwfunctr.cxx b/sc/source/ui/formdlg/dwfunctr.cxx
index 787932f59c53..feda9d1657f1 100644
--- a/sc/source/ui/formdlg/dwfunctr.cxx
+++ b/sc/source/ui/formdlg/dwfunctr.cxx
@@ -1,1185 +1,1185 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: dwfunctr.cxx,v $
- * $Revision: 1.15 $
- *
- * 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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sc.hxx"
-
-
-
-// INCLUDE ---------------------------------------------------------------
-
-#include <svx/editview.hxx>
-#include <sfx2/bindings.hxx>
-#include <sfx2/dispatch.hxx>
-#include <sfx2/objsh.hxx>
-#include <sfx2/viewsh.hxx>
-
-#include "sc.hrc"
-#include "global.hxx" // ScAddress
-#include "scresid.hxx"
-#include "reffact.hxx"
-#include "document.hxx"
-#include "cell.hxx"
-#include "scmod.hxx"
-#include "inputhdl.hxx"
-#include "tabvwsh.hxx"
-#include "appoptio.hxx"
-#include "compiler.hxx"
-
-#include "dwfunctr.hrc"
-#include "dwfunctr.hxx"
-
-// -----------------------------------------------------------------------
-
-#define ARG_SEPERATOR String("; ")
-SFX_IMPL_DOCKINGWINDOW( ScFunctionChildWindow, FID_FUNCTION_BOX )
-
-/*************************************************************************
-#* Member: ScFunctionChildWindow Datum:06.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionChildWindow
-#*
-#* Funktion: Konstruktor der Klasse ScFunctionChildWindow
-#* Ableitung vom SfxChildWindow als "Behaelter" fuer
-#* Funktions- Fenster in Clac
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-__EXPORT ScFunctionChildWindow::ScFunctionChildWindow( Window* pParentP,
- USHORT nId,
- SfxBindings* pBindings,
- SfxChildWinInfo* pInfo ) :
- SfxChildWindow( pParentP, nId )
-{
- ScFunctionDockWin* pWin = new ScFunctionDockWin( pBindings, this,
- pParentP, ScResId( FID_FUNCTION_BOX ) );
- pWindow = pWin;
-
- eChildAlignment = SFX_ALIGN_RIGHT;
-
- pWin->Initialize( pInfo );
-}
-
-/*************************************************************************
-#* Member: ScFunctionDockWin Datum:06.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Konstruktor der Klasse ScFunctionDockWin
-#*
-#* Input: Sfx- Verknuepfungen, Fenster, Resource
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-ScFunctionDockWin::ScFunctionDockWin( SfxBindings* pBindingsP,
- SfxChildWindow *pCW, Window* pParent, const ResId& rResId ) :
-
- SfxDockingWindow( pBindingsP, pCW, pParent, rResId ),
- aPrivatSplit ( this, ResId( FT_SPLIT, *rResId.GetResMgr() ),SC_SPLIT_VERT),
- aCatBox ( this, ResId( CB_CAT, *rResId.GetResMgr() ) ),
- aFuncList ( this, ResId( LB_FUNC, *rResId.GetResMgr() ) ),
- aDDFuncList ( this, ResId( DDLB_FUNC, *rResId.GetResMgr() ) ),
- aInsertButton ( this, ResId( IMB_INSERT, *rResId.GetResMgr() ) ),
- aFiFuncDesc ( this, ResId( FI_FUNCDESC, *rResId.GetResMgr() ) ),
- aOldSize (0,0)
-{
- FreeResource();
- InitLRUList();
- SetStyle(GetStyle()|WB_CLIPCHILDREN);
-
- aTimer.SetTimeout(200);
- aTimer.SetTimeoutHdl(LINK( this, ScFunctionDockWin, TimerHdl));
-
- eSfxNewAlignment=GetAlignment();
- eSfxOldAlignment=eSfxNewAlignment;
- aFiFuncDesc.SetUpdateMode(TRUE);
- pAllFuncList=&aFuncList;
- aDDFuncList.Disable();
- aDDFuncList.Hide();
- nArgs=0;
- nDockMode=0;
- bSizeFlag=FALSE;
- aCatBox.SetDropDownLineCount(9);
- Font aFont=aFiFuncDesc.GetFont();
- aFont.SetColor(Color(COL_BLACK));
- aFiFuncDesc.SetFont(aFont);
- aFiFuncDesc.SetBackground( GetBackground() ); //! never transparent?
-//? SetBackground();
-
- Link aLink=LINK( this, ScFunctionDockWin, SelHdl);
- aCatBox.SetSelectHdl(aLink);
- aFuncList.SetSelectHdl(aLink);
- aDDFuncList.SetSelectHdl(aLink);
-
- Link a2Link=LINK( this, ScFunctionDockWin, SetSelectionHdl);
- aFuncList.SetDoubleClickHdl(a2Link);
- aDDFuncList.SetSelectHdl(aLink);
- aInsertButton.SetClickHdl(a2Link);
-
- Link a3Link=LINK( this, ScFunctionDockWin, SetSplitHdl);
- aPrivatSplit.SetCtrModifiedHdl(a3Link);
- StartListening( *pBindingsP, TRUE );
-
- Point aTopLeft=aCatBox.GetPosPixel();
- //String aString=aCatBox.GetEntry( 0)+String("www");
- String aString=String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww"));
- Size aTxtSize( aFiFuncDesc.GetTextWidth(aString), aFiFuncDesc.GetTextHeight() );
- nMinWidth=aTxtSize.Width()+aTopLeft.X()
- +2*aFuncList.GetPosPixel().X();
- nMinHeight=19*aTxtSize.Height();
- aCatBox.SelectEntryPos(0);
-
- Range aYRange(3*aTxtSize.Height()+aFuncList.GetPosPixel().Y(),
- GetOutputSizePixel().Height()-2*aTxtSize.Height());
- aPrivatSplit.SetYRange(aYRange);
- SelHdl(&aCatBox);
- bInit=TRUE;
-}
-
-/*************************************************************************
-#* Member: ScFunctionDockWin Datum:06.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Destruktor der Klasse ScFunctionDockWin
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-__EXPORT ScFunctionDockWin::~ScFunctionDockWin()
-{
- EndListening( GetBindings() );
-}
-
-/*************************************************************************
-#* Member: UpdateFunctionList Datum:06.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Aktualisiert die Liste der Funktionen ab-
-#* haengig von der eingestellten Kategorie.
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void ScFunctionDockWin::InitLRUList()
-{
- const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions();
- USHORT nLRUFuncCount = Min( rAppOpt.GetLRUFuncListCount(), (USHORT)LRU_MAX );
- USHORT* pLRUListIds = rAppOpt.GetLRUFuncList();
-
- USHORT i;
- for ( i=0; i<LRU_MAX; i++ )
- aLRUList[i] = NULL;
-
- if ( pLRUListIds )
- {
- ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr();
- for ( i=0; i<nLRUFuncCount; i++ )
- aLRUList[i] = pFuncMgr->Get( pLRUListIds[i] );
- }
-
- USHORT nSelPos = aCatBox.GetSelectEntryPos();
-
- if(nSelPos == 0)
- UpdateFunctionList();
-}
-
-/*************************************************************************
-#* Member: UpdateFunctionList Datum:10.12.99
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Aktualisiert die Liste der zuletzt verwendeten Funktionen.
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void ScFunctionDockWin::UpdateLRUList()
-{
- if (pFuncDesc && pFuncDesc->nFIndex!=0)
- {
- ScModule* pScMod = SC_MOD();
- pScMod->InsertEntryToLRUList(pFuncDesc->nFIndex);
- }
-}
-
-
-/*************************************************************************
-#* Member: SetSize Datum:06.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Groesse fuer die einzelnen Controls einzustellen.
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void ScFunctionDockWin::SetSize()
-{
- USHORT nSelEntry=0;
- SfxChildAlignment aChildAlign=eSfxOldAlignment;//GetAlignment();
- short nNewDockMode;
- switch(aChildAlign)
- {
- case SFX_ALIGN_HIGHESTTOP:
- case SFX_ALIGN_TOP:
- case SFX_ALIGN_LOWESTTOP:
- case SFX_ALIGN_LOWESTBOTTOM:
- case SFX_ALIGN_BOTTOM:
- case SFX_ALIGN_TOOLBOXTOP:
- case SFX_ALIGN_TOOLBOXBOTTOM:
-
-
- nNewDockMode=1;
- if(nDockMode!=nNewDockMode)
- {
- nDockMode=nNewDockMode;
- nSelEntry=aFuncList.GetSelectEntryPos();
- aFuncList.Clear();
- aFiFuncDesc.SetPosPixel(aFuncList.GetPosPixel());
- aDDFuncList.Enable();
- aDDFuncList.Show();
- aPrivatSplit.Disable();
- aPrivatSplit.Hide();
- aFuncList.Disable();
- aFuncList.Hide();
- pAllFuncList=&aDDFuncList;
- SelHdl(&aCatBox);
- aDDFuncList.SelectEntryPos(nSelEntry);
- }
- break;
-
- default: nNewDockMode=0;
- if(nDockMode!=nNewDockMode)
- {
- nDockMode=nNewDockMode;
- nSelEntry=aDDFuncList.GetSelectEntryPos();
- aDDFuncList.Clear();
- aDDFuncList.Disable();
- aDDFuncList.Hide();
- aPrivatSplit.Enable();
- aPrivatSplit.Show();
- aFuncList.Enable();
- aFuncList.Show();
- pAllFuncList=&aFuncList;
- SelHdl(&aCatBox);
- aFuncList.SelectEntryPos(nSelEntry);
- }
- break;
- }
-
- if(nDockMode==0)
- {
- SetLeftRightSize();
- }
- else
- {
- SetTopBottonSize();
- }
-}
-/*************************************************************************
-#* Member: SetLeftRightSize Datum:15.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Groesse fuer die einzelnen Controls einstellen,
-#* wenn Links oder Rechts angedockt wird.
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void ScFunctionDockWin::SetLeftRightSize()
-{
- if(bSizeFlag==FALSE)
- {
- bSizeFlag=TRUE;
-
- Size aDiffSize=GetSizePixel();
- Size aNewSize=GetOutputSizePixel();
- aDiffSize.Width()-=aNewSize.Width();
- aDiffSize.Height()-=aNewSize.Height();
-
- //@ SetUpdateMode( FALSE);
-
- String aString = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww"));
-
- Size aTxtSize( aFuncList.GetTextWidth(aString), aFuncList.GetTextHeight() );
-
- Range aYRange(3*aTxtSize.Height()+aFuncList.GetPosPixel().Y(),
- GetOutputSizePixel().Height()-2*aTxtSize.Height());
- aPrivatSplit.SetYRange(aYRange);
-
-
- if(aOldSize.Width()!=aNewSize.Width())
- SetMyWidthLeRi(aNewSize);
-
- if(aOldSize.Height()!=aNewSize.Height())
- SetMyHeightLeRi(aNewSize);
-
- aOldSize=aNewSize;
- aNewSize.Width()+=aDiffSize.Width();
- aNewSize.Height()+=aDiffSize.Height();
- //SetSizePixel(aNewSize);
- //@ SetUpdateMode( TRUE);
- bSizeFlag=FALSE;
- }
-
-}
-/*************************************************************************
-#* Member: SetTopBottonSize Datum:15.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Groesse fuer die einzelnen Controls einzustellen.
-#* wenn oben oder unten angedockt wird.
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void ScFunctionDockWin::SetTopBottonSize()
-{
- if(bSizeFlag==FALSE)
- {
- bSizeFlag=TRUE;
- Size aDiffSize=GetSizePixel();
- Size aNewSize=GetOutputSizePixel();
- aDiffSize.Width()-=aNewSize.Width();
- aDiffSize.Height()-=aNewSize.Height();
-
- SetMyWidthToBo(aNewSize);
- SetMyHeightToBo(aNewSize);
-
- aNewSize.Width()+=aDiffSize.Width();
- aNewSize.Height()+=aDiffSize.Height();
- //SetSizePixel(aNewSize);
- //@ SetUpdateMode( TRUE);
- bSizeFlag=FALSE;
- }
-}
-
-/*************************************************************************
-#* Member: SetMyWidthLeRi Datum:15.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Breite fuer die einzelnen Controls und
-#* das Fenster einstellen,wenn Li oder Re
-#*
-#* Input: neue Fenstergroesse
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void ScFunctionDockWin::SetMyWidthLeRi(Size &aNewSize)
-{
- if((ULONG)aNewSize.Width()<nMinWidth) aNewSize.Width()=nMinWidth;
-
- Size aCDSize=aCatBox.GetSizePixel();
- Size aFLSize=aFuncList.GetSizePixel();
- Size aSplitterSize=aPrivatSplit.GetSizePixel();
- Size aFDSize=aFiFuncDesc.GetSizePixel();
-
- Point aCDTopLeft=aCatBox.GetPosPixel();
- Point aFLTopLeft=aFuncList.GetPosPixel();
- Point aSplitterTopLeft=aPrivatSplit.GetPosPixel();
- Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
-
- aCDSize.Width()=aNewSize.Width()-aCDTopLeft.X()-aFLTopLeft.X();
- aFLSize.Width()=aNewSize.Width()-2*aFLTopLeft.X();
- aFDSize.Width()=aFLSize.Width();
- aSplitterSize.Width()=aFLSize.Width();
-
- aCatBox.SetSizePixel(aCDSize);
- aFuncList.SetSizePixel(aFLSize);
- aPrivatSplit.SetSizePixel(aSplitterSize);
- aFiFuncDesc.SetSizePixel(aFDSize);
-}
-
-/*************************************************************************
-#* Member: SetHeight Datum:06.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Hoehe fuer die einzelnen Controls und
-#* das Fenster einstellen bei Li oder Re
-#*
-#* Input: neue Fenstergroesse
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void ScFunctionDockWin::SetMyHeightLeRi(Size &aNewSize)
-{
- if((ULONG)aNewSize.Height()<nMinHeight) aNewSize.Height()=nMinHeight;
-
- Size aFLSize=aFuncList.GetSizePixel();
- Size aSplitterSize=aPrivatSplit.GetSizePixel();
- Size aFDSize=aFiFuncDesc.GetSizePixel();
-
- Point aFLTopLeft=aFuncList.GetPosPixel();
- Point aSplitterTopLeft=aPrivatSplit.GetPosPixel();
- Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
-
- long nTxtHeight = aFuncList.GetTextHeight();
-
- short nY=(short)(3*nTxtHeight+
- aFuncList.GetPosPixel().Y()+aSplitterSize.Height());
-
- aFDTopLeft.Y()=aNewSize.Height()-aFDSize.Height()-4;
- if(nY>aFDTopLeft.Y())
- {
- aFDSize.Height()-=nY-aFDTopLeft.Y();
- aFDTopLeft.Y()=nY;
- }
- aSplitterTopLeft.Y()=aFDTopLeft.Y()-aSplitterSize.Height()-1;
- aFLSize.Height()=aSplitterTopLeft.Y()-aFLTopLeft.Y()-1;
-
- aFuncList.SetSizePixel(aFLSize);
- aPrivatSplit.SetPosPixel(aSplitterTopLeft);
- aFiFuncDesc.SetPosPixel(aFDTopLeft);
- aFiFuncDesc.SetSizePixel(aFDSize);
-
-}
-
-/*************************************************************************
-#* Member: SetMyWidthToBo Datum:16.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Breite fuer die einzelnen Controls und
-#* das Fenster einstellen, wenn oben oder
-#* unten angedockt werden soll.
-#*
-#* Input: neue Fenstergroesse
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void ScFunctionDockWin::SetMyWidthToBo(Size &aNewSize)
-{
- if((ULONG)aNewSize.Width()<nMinWidth) aNewSize.Width()=nMinWidth;
-
- Size aCDSize=aCatBox.GetSizePixel();
- Size aDdFLSize=aDDFuncList.GetSizePixel();
- Size aFDSize=aFiFuncDesc.GetSizePixel();
-
- Point aCDTopLeft=aCatBox.GetPosPixel();
- Point aDdFLTopLeft=aDDFuncList.GetPosPixel();
- Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
-
- aCDSize.Width()=aDdFLTopLeft.X()-aFDTopLeft.X()-aCDTopLeft.X();
- aDdFLTopLeft.X()=aCDSize.Width()+aCDTopLeft.X()+aFDTopLeft.X();
-
- aDdFLSize.Width()=aNewSize.Width()-aDdFLTopLeft.X()-aFDTopLeft.X();
-
- aFDSize.Width()=aNewSize.Width()-2*aFDTopLeft.X();
-
- aDDFuncList.SetPosPixel(aDdFLTopLeft);
- aDDFuncList.SetSizePixel(aDdFLSize);
- aCatBox.SetSizePixel(aCDSize);
- aFiFuncDesc.SetSizePixel(aFDSize);
-}
-
-/*************************************************************************
-#* Member: SetHeight Datum:16.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Hoehe fuer die einzelnen Controls und
-#* das Fenster einstellen, wenn oben oder
-#* unten angedockt werden soll.
-#*
-#* Input: neue Fenstergroesse
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void ScFunctionDockWin::SetMyHeightToBo(Size &aNewSize)
-{
- if((ULONG)aNewSize.Height()<nMinHeight) aNewSize.Height()=nMinHeight;
-
- Size aFDSize=aFiFuncDesc.GetSizePixel();
-
- Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
- Point aCBTopLeft=aCatBox.GetPosPixel();
- aFDSize.Height()=aNewSize.Height()-aFDTopLeft.Y()-aCBTopLeft.Y();
- aFiFuncDesc.SetSizePixel(aFDSize);
-
-}
-
-/*************************************************************************
-#* Member: SetDescription Datum:13.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Erklaerungstext fuer die Funktion einstellen.
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void ScFunctionDockWin::SetDescription()
-{
- aFiFuncDesc.SetText( EMPTY_STRING );
- const ScFuncDesc* pDesc =
- (const ScFuncDesc*)pAllFuncList->GetEntryData(
- pAllFuncList->GetSelectEntryPos() );
- if (pDesc)
- {
- pDesc->initArgumentInfo(); // full argument info is needed
-
- String aString=pAllFuncList->GetSelectEntry();
- if(nDockMode==0)
- {
- aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ":\n\n" ));
- }
- else
- {
- aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
- }
-
- aString+=pDesc->GetParamList();
-
- if(nDockMode==0)
- {
- aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "\n\n" ));
- }
- else
- {
- aString += '\n';
- }
-
- aString+=*(pDesc->pFuncDesc);
-
- aFiFuncDesc.SetText(aString);
- aFiFuncDesc.StateChanged(STATE_CHANGE_TEXT);
- aFiFuncDesc.Invalidate();
- aFiFuncDesc.Update();
-
- }
- }
-
-/*************************************************************************
-#* Member: Resizing Datum:06.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Ueberladene Funktion um die Groesse der
-#* einzelnen Controls einzustellen.
-#*
-#* Input: neue Groesse
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void __EXPORT ScFunctionDockWin::Resizing( Size& rNewSize )
-{
- if((ULONG)rNewSize.Width()<nMinWidth) rNewSize.Width()=nMinWidth;
- if((ULONG)rNewSize.Height()<nMinHeight) rNewSize.Height()=nMinHeight;
-
-}
-
-/*************************************************************************
-#* Member: Close Datum:07.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Schliessen des Fensters
-#*
-#* Input: ---
-#*
-#* Output: TRUE
-#*
-#************************************************************************/
-
-BOOL __EXPORT ScFunctionDockWin::Close()
-{
- SfxBoolItem aItem( FID_FUNCTION_BOX, FALSE );
-
- GetBindings().GetDispatcher()->Execute( FID_FUNCTION_BOX,
- SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
- &aItem, 0L );
-
- SfxDockingWindow::Close();
-
- return( TRUE );
-}
-
-
-/*************************************************************************
-#* Member: CheckAlignment Datum:16.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Ueberprueft den Andockmodus und stellt die
-#* Groessen dementsprechend ein.
-#*
-#* Input: Das neue Alignment
-#*
-#* Output: Das uebergebene Alignment
-#*
-#************************************************************************/
-SfxChildAlignment __EXPORT ScFunctionDockWin::CheckAlignment(SfxChildAlignment /* abla */,
- SfxChildAlignment aChildAlign)
-{
- String aString = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww"));
- Size aTxtSize( aFiFuncDesc.GetTextWidth(aString), aFiFuncDesc.GetTextHeight() );
- if(!bInit)
- {
- eSfxOldAlignment=eSfxNewAlignment;
- eSfxNewAlignment=aChildAlign;
- }
- else
- {
- bInit=FALSE;
- eSfxOldAlignment=aChildAlign;
- eSfxNewAlignment=aChildAlign;
- }
-
- switch(eSfxOldAlignment)
- {
- case SFX_ALIGN_HIGHESTTOP:
- case SFX_ALIGN_TOP:
- case SFX_ALIGN_LOWESTTOP:
- case SFX_ALIGN_LOWESTBOTTOM:
- case SFX_ALIGN_BOTTOM:
- case SFX_ALIGN_TOOLBOXTOP:
- case SFX_ALIGN_TOOLBOXBOTTOM:
-
- nMinWidth= 0;/*aDDFuncList.GetPosPixel().X()+
- 10*aTxtSize.Width()+
- aFuncList.GetPosPixel().X();*/
- nMinHeight=0;
-
- break;
-
- case SFX_ALIGN_NOALIGNMENT:
-
- aString = aCatBox.GetEntry(0);
- aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM("www"));
- aTxtSize = Size( aFiFuncDesc.GetTextWidth(aString),
- aFiFuncDesc.GetTextHeight() );
-
- default: Point aTopLeft=aCatBox.GetPosPixel();
- nMinWidth=aTxtSize.Width()+aTopLeft.X()
- +2*aFuncList.GetPosPixel().X();
- nMinHeight=19*aTxtSize.Height();
- //aCatBox.SelectEntryPos(0);
-
- break;
- }
-
- return aChildAlign;
-}
-/*************************************************************************
-#* Member: Close Datum:07.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Aenderungen erkennen
-#*
-#* Input: ---
-#*
-#* Output: TRUE
-#*
-#************************************************************************/
-void ScFunctionDockWin::Notify( SfxBroadcaster&, const SfxHint& /* rHint */ )
-{
-// const SfxPoolItemHint *pPoolItemHint = PTR_CAST(SfxPoolItemHint, &rHint);
- /*
- if ( pPoolItemHint
- && ( pPoolItemHint->GetObject()->ISA( SvxColorTableItem ) ) )
- {
- // Die Liste der Farben hat sich geaendert
- pColorTable = ( (SvxColorTableItem*) pPoolItemHint->GetObject() )->GetColorTable();
- FillValueSet();
- }
- */
-}
-
-
-/*************************************************************************
-#* Member: Resize Datum:06.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Ueberladene Funktion um die Groesse der
-#* einzelnen Controls einzustellen.
-#*
-#* Input: neue Groesse
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void __EXPORT ScFunctionDockWin::Resize()
-{
- if ( !IsFloatingMode() ||
- !GetFloatingWindow()->IsRollUp() )
- {
- Size aQSize=GetOutputSizePixel();
- Resizing( aQSize);
- SetSize();
- }
- SfxDockingWindow::Resize();
-}
-
-/*************************************************************************
-#* Member: UpdateFunctionList Datum:06.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Aktualisiert die Liste der Funktionen ab-
-#* haengig von der eingestellten Kategorie.
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void ScFunctionDockWin::UpdateFunctionList()
-{
- USHORT nSelPos = aCatBox.GetSelectEntryPos();
- USHORT nCategory = ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
- ? (nSelPos-1) : 0;
-
- pAllFuncList->Clear();
- pAllFuncList->SetUpdateMode( FALSE );
-
- if ( nSelPos > 0 )
- {
- ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr();
-
- const ScFuncDesc* pDesc = pFuncMgr->First( nCategory );
- while ( pDesc )
- {
- pAllFuncList->SetEntryData(
- pAllFuncList->InsertEntry( *(pDesc->pFuncName) ),
- (void*)pDesc );
- pDesc = pFuncMgr->Next();
- }
- }
- else // LRU-Liste
- {
- for ( USHORT i=0; i<LRU_MAX && aLRUList[i]; i++ )
- {
- const ScFuncDesc* pDesc = aLRUList[i];
- pAllFuncList->SetEntryData(
- pAllFuncList->InsertEntry( *(pDesc->pFuncName) ),
- (void*)pDesc );
- }
- }
-
-
- //------------------------------------------------------
- pAllFuncList->SetUpdateMode( TRUE );
-
- if ( pAllFuncList->GetEntryCount() > 0 )
- {
- pAllFuncList->Enable();
- pAllFuncList->SelectEntryPos( 0 );
- }
- else
- {
- pAllFuncList->Disable();
- }
-}
-
-/*************************************************************************
-#* Member: DoEnter Datum:06.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Eingabe ins Dokument uebernehmen. Wird aufgerufen
-#* nach betaetigen der Uebernehmen- Schaltflaeche
-#* oder einem Doppelklick in die Funktionsliste.
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void ScFunctionDockWin::DoEnter(BOOL /* bOk */) //@@ ???
-{
- String aFirstArgStr;
- String aParaStr;
- String aArgStr;
- String aString=pAllFuncList->GetSelectEntry();
- SfxViewShell* pCurSh = SfxViewShell::Current();
- nArgs=0;
-
- if(aString.Len()>0)
- {
-
- ScModule* pScMod = SC_MOD();
- ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, pCurSh);
- ScInputHandler* pHdl = pScMod->GetInputHdl( pViewSh );
- if(!pScMod->IsEditMode())
- {
- pScMod->SetInputMode(SC_INPUT_TABLE);
- aString = '=';
- aString += pAllFuncList->GetSelectEntry();
- if (pHdl)
- pHdl->ClearText();
- }
- const ScFuncDesc* pDesc =
- (const ScFuncDesc*)pAllFuncList->GetEntryData(
- pAllFuncList->GetSelectEntryPos() );
- if (pDesc)
- {
- pFuncDesc=pDesc;
- UpdateLRUList();
- nArgs = pDesc->nArgCount;
- if(nArgs>0)
- {
- // NOTE: Theoretically the first parameter could have the
- // suppress flag as well, but practically it doesn't.
- aFirstArgStr = *(pDesc->ppDefArgNames[0]);
- aFirstArgStr.EraseLeadingAndTrailingChars();
- aFirstArgStr.SearchAndReplaceAll(' ', '_');
- aArgStr = aFirstArgStr;
- if ( nArgs != VAR_ARGS )
- { // no VarArgs or Fix plus VarArgs, but not VarArgs only
- String aArgSep = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( "; " ));
- USHORT nFix = ( nArgs < VAR_ARGS ? nArgs : nArgs - VAR_ARGS + 1 );
- for ( USHORT nArg = 1;
- nArg < nFix && !pDesc->pDefArgFlags[nArg].bOptional; nArg++ )
- {
- if (!pDesc->pDefArgFlags[nArg].bSuppress)
- {
- aArgStr += aArgSep;
- String sTmp(*(pDesc->ppDefArgNames[nArg]));
- sTmp.EraseLeadingAndTrailingChars();
- sTmp.SearchAndReplaceAll(' ', '_');
- aArgStr += sTmp;
- }
- }
- }
- }
- }
- if (pHdl)
- {
- if(pHdl->GetEditString().Len()==0)
- {
- aString = '=';
- aString += pAllFuncList->GetSelectEntry();
- }
- EditView *pEdView=pHdl->GetActiveView();
- if(pEdView!=NULL) // @ Wegen Absturz bei Namen festlegen
- {
- if(nArgs>0)
- {
- pHdl->InsertFunction(aString);
- pEdView->InsertText(aArgStr,TRUE);
- ESelection aESel=pEdView->GetSelection();
- aESel.nEndPos=aESel.nStartPos+aFirstArgStr.Len();
- pEdView->SetSelection(aESel);
- pHdl->DataChanged();
- }
- else
- {
- aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "()" ));
- pEdView->InsertText(aString,FALSE);
- pHdl->DataChanged();
- }
- }
- }
- InitLRUList();
- }
- if ( pCurSh )
- {
- Window* pShellWnd = pCurSh->GetWindow();
-
- if ( pShellWnd )
- pShellWnd->GrabFocus();
- }
-
-
-}
-
-
-
-/*************************************************************************
-#* Handle: SelHdl Datum:06.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Bei einer Aenderung der Kategorie wird die
-#* die Liste der Funktionen aktualisiert.
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-IMPL_LINK( ScFunctionDockWin, SelHdl, ListBox*, pLb )
-{
- if ( pLb == &aCatBox)
- {
- UpdateFunctionList();
- SetDescription();
- }
-
- if ( pLb == &aFuncList||pLb == &aDDFuncList)
- {
- SetDescription();
- }
-
-
- //SetSize();
- return 0;
-}
-
-/*************************************************************************
-#* Handle: SelHdl Datum:06.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Bei einer Aenderung der Kategorie wird die
-#* die Liste der Funktionen aktualisiert.
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-IMPL_LINK( ScFunctionDockWin, SetSelectionHdl, void*, pCtrl )
-{
- if ((ImageButton *)pCtrl == &aInsertButton ||
- (ListBox *)pCtrl == &aFuncList)
- {
- DoEnter(TRUE); // Uebernimmt die Eingabe
- }
- //...
-
- return 0;
-}
-
-/*************************************************************************
-#* Handle: SetSplitHdl Datum:13.10.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScFunctionDockWin
-#*
-#* Funktion: Bei einer Aenderung des Split- Controls werden die
-#* einzelnen Controls an die neue Groesse angepasst.
-#*
-#* Input: Zeiger auf Control
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-IMPL_LINK( ScFunctionDockWin, SetSplitHdl, ScPrivatSplit*, pCtrl )
-{
- if (pCtrl == &aPrivatSplit)
- {
- short nDeltaY=aPrivatSplit.GetDeltaY();
- Size aFLSize=aFuncList.GetSizePixel();
- Size aFDSize=aFiFuncDesc.GetSizePixel();
- Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
-
- aFLSize.Height()+=nDeltaY;
- aFDSize.Height()-=nDeltaY;
- aFDTopLeft.Y()+=nDeltaY;
- aFuncList.SetSizePixel(aFLSize);
- aFiFuncDesc.SetPosPixel(aFDTopLeft);
- aFiFuncDesc.SetSizePixel(aFDSize);
- /*
- aFuncList.Invalidate();
- aFuncList.Update();
- aFiFuncDesc.Invalidate();
- aFiFuncDesc.Update();
- */
- }
- //...
-
- return 0;
-}
-
-void ScFunctionDockWin::ToggleFloatingMode()
-{
- aSplitterInitPos = Point();
- SfxDockingWindow::ToggleFloatingMode();
-
- eSfxNewAlignment=GetAlignment();
- eSfxOldAlignment=eSfxNewAlignment;
-
- aOldSize.Height()=0;
- aOldSize.Width()=0;
- aTimer.Start();
-}
-
-IMPL_LINK( ScFunctionDockWin, TimerHdl, Timer*, EMPTYARG )
-{
- CheckAlignment(eSfxOldAlignment,eSfxNewAlignment);
- SetSize();
- return 0;
-}
-
-void ScFunctionDockWin::Initialize(SfxChildWinInfo *pInfo)
-{
- String aStr;
- if(pInfo!=NULL)
- {
- if ( pInfo->aExtraString.Len() )
- {
- xub_StrLen nPos = pInfo->aExtraString.Search(
- String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScFuncList:")));
-
- // Versuche, den Alignment-String "ALIGN:(...)" einzulesen; wenn
- // er nicht vorhanden ist, liegt eine "altere Version vor
- if ( nPos != STRING_NOTFOUND )
- {
- xub_StrLen n1 = pInfo->aExtraString.Search('(', nPos);
- if ( n1 != STRING_NOTFOUND )
- {
- xub_StrLen n2 = pInfo->aExtraString.Search(')', n1);
- if ( n2 != STRING_NOTFOUND )
- {
- // Alignment-String herausschneiden
- aStr = pInfo->aExtraString.Copy(nPos, n2 - nPos + 1);
- pInfo->aExtraString.Erase(nPos, n2 - nPos + 1);
- aStr.Erase(0, n1-nPos+1);
- }
- }
- }
- }
- }
- SfxDockingWindow::Initialize(pInfo);
-
- if ( aStr.Len())
- {
- aSplitterInitPos=aPrivatSplit.GetPosPixel();
- aSplitterInitPos.Y()=(USHORT) aStr.ToInt32();
- xub_StrLen n1 = aStr.Search(';');
- aStr.Erase(0, n1+1);
- USHORT nSelPos=sal::static_int_cast<USHORT>( aStr.ToInt32() );
- aCatBox.SelectEntryPos(nSelPos);
- SelHdl(&aCatBox);
-
- // if the window has already been shown (from SfxDockingWindow::Initialize if docked),
- // set the splitter position now, otherwise it is set in StateChanged with type INITSHOW
-
- UseSplitterInitPos();
- }
-}
-
-//-------------------------------------------------------------------------
-
-void ScFunctionDockWin::FillInfo(SfxChildWinInfo& rInfo) const
-{
- SfxDockingWindow::FillInfo(rInfo);
- Point aPoint=aPrivatSplit.GetPosPixel();
- rInfo.aExtraString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "ScFuncList:(" ));
- rInfo.aExtraString += String::CreateFromInt32(aPoint.Y());
- rInfo.aExtraString += ';';
- rInfo.aExtraString += String::CreateFromInt32(aCatBox.GetSelectEntryPos());
- rInfo.aExtraString += ')';
-}
-
-void ScFunctionDockWin::UseSplitterInitPos()
-{
- if ( IsVisible() && aPrivatSplit.IsEnabled() && aSplitterInitPos != Point() )
- {
- aPrivatSplit.MoveSplitTo(aSplitterInitPos);
- aSplitterInitPos = Point(); // use only once
- }
-}
-
-void ScFunctionDockWin::StateChanged( StateChangedType nStateChange )
-{
- SfxDockingWindow::StateChanged( nStateChange );
-
- if (nStateChange == STATE_CHANGE_INITSHOW)
- {
- UseSplitterInitPos(); // set initial splitter position if necessary
- }
-}
-
-
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dwfunctr.cxx,v $
+ * $Revision: 1.15 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svx/editview.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewsh.hxx>
+
+#include "sc.hrc"
+#include "global.hxx" // ScAddress
+#include "scresid.hxx"
+#include "reffact.hxx"
+#include "document.hxx"
+#include "cell.hxx"
+#include "scmod.hxx"
+#include "inputhdl.hxx"
+#include "tabvwsh.hxx"
+#include "appoptio.hxx"
+#include "compiler.hxx"
+
+#include "dwfunctr.hrc"
+#include "dwfunctr.hxx"
+
+// -----------------------------------------------------------------------
+
+#define ARG_SEPERATOR String("; ")
+SFX_IMPL_DOCKINGWINDOW( ScFunctionChildWindow, FID_FUNCTION_BOX )
+
+/*************************************************************************
+#* Member: ScFunctionChildWindow Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionChildWindow
+#*
+#* Funktion: Konstruktor der Klasse ScFunctionChildWindow
+#* Ableitung vom SfxChildWindow als "Behaelter" fuer
+#* Funktions- Fenster in Clac
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+__EXPORT ScFunctionChildWindow::ScFunctionChildWindow( Window* pParentP,
+ USHORT nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo ) :
+ SfxChildWindow( pParentP, nId )
+{
+ ScFunctionDockWin* pWin = new ScFunctionDockWin( pBindings, this,
+ pParentP, ScResId( FID_FUNCTION_BOX ) );
+ pWindow = pWin;
+
+ eChildAlignment = SFX_ALIGN_RIGHT;
+
+ pWin->Initialize( pInfo );
+}
+
+/*************************************************************************
+#* Member: ScFunctionDockWin Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Konstruktor der Klasse ScFunctionDockWin
+#*
+#* Input: Sfx- Verknuepfungen, Fenster, Resource
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+ScFunctionDockWin::ScFunctionDockWin( SfxBindings* pBindingsP,
+ SfxChildWindow *pCW, Window* pParent, const ResId& rResId ) :
+
+ SfxDockingWindow( pBindingsP, pCW, pParent, rResId ),
+ aPrivatSplit ( this, ResId( FT_SPLIT, *rResId.GetResMgr() ),SC_SPLIT_VERT),
+ aCatBox ( this, ResId( CB_CAT, *rResId.GetResMgr() ) ),
+ aFuncList ( this, ResId( LB_FUNC, *rResId.GetResMgr() ) ),
+ aDDFuncList ( this, ResId( DDLB_FUNC, *rResId.GetResMgr() ) ),
+ aInsertButton ( this, ResId( IMB_INSERT, *rResId.GetResMgr() ) ),
+ aFiFuncDesc ( this, ResId( FI_FUNCDESC, *rResId.GetResMgr() ) ),
+ aOldSize (0,0)
+{
+ FreeResource();
+ InitLRUList();
+ SetStyle(GetStyle()|WB_CLIPCHILDREN);
+
+ aTimer.SetTimeout(200);
+ aTimer.SetTimeoutHdl(LINK( this, ScFunctionDockWin, TimerHdl));
+
+ eSfxNewAlignment=GetAlignment();
+ eSfxOldAlignment=eSfxNewAlignment;
+ aFiFuncDesc.SetUpdateMode(TRUE);
+ pAllFuncList=&aFuncList;
+ aDDFuncList.Disable();
+ aDDFuncList.Hide();
+ nArgs=0;
+ nDockMode=0;
+ bSizeFlag=FALSE;
+ aCatBox.SetDropDownLineCount(9);
+ Font aFont=aFiFuncDesc.GetFont();
+ aFont.SetColor(Color(COL_BLACK));
+ aFiFuncDesc.SetFont(aFont);
+ aFiFuncDesc.SetBackground( GetBackground() ); //! never transparent?
+//? SetBackground();
+
+ Link aLink=LINK( this, ScFunctionDockWin, SelHdl);
+ aCatBox.SetSelectHdl(aLink);
+ aFuncList.SetSelectHdl(aLink);
+ aDDFuncList.SetSelectHdl(aLink);
+
+ Link a2Link=LINK( this, ScFunctionDockWin, SetSelectionHdl);
+ aFuncList.SetDoubleClickHdl(a2Link);
+ aDDFuncList.SetSelectHdl(aLink);
+ aInsertButton.SetClickHdl(a2Link);
+
+ Link a3Link=LINK( this, ScFunctionDockWin, SetSplitHdl);
+ aPrivatSplit.SetCtrModifiedHdl(a3Link);
+ StartListening( *pBindingsP, TRUE );
+
+ Point aTopLeft=aCatBox.GetPosPixel();
+ //String aString=aCatBox.GetEntry( 0)+String("www");
+ String aString=String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww"));
+ Size aTxtSize( aFiFuncDesc.GetTextWidth(aString), aFiFuncDesc.GetTextHeight() );
+ nMinWidth=aTxtSize.Width()+aTopLeft.X()
+ +2*aFuncList.GetPosPixel().X();
+ nMinHeight=19*aTxtSize.Height();
+ aCatBox.SelectEntryPos(0);
+
+ Range aYRange(3*aTxtSize.Height()+aFuncList.GetPosPixel().Y(),
+ GetOutputSizePixel().Height()-2*aTxtSize.Height());
+ aPrivatSplit.SetYRange(aYRange);
+ SelHdl(&aCatBox);
+ bInit=TRUE;
+}
+
+/*************************************************************************
+#* Member: ScFunctionDockWin Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Destruktor der Klasse ScFunctionDockWin
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+__EXPORT ScFunctionDockWin::~ScFunctionDockWin()
+{
+ EndListening( GetBindings() );
+}
+
+/*************************************************************************
+#* Member: UpdateFunctionList Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Aktualisiert die Liste der Funktionen ab-
+#* haengig von der eingestellten Kategorie.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::InitLRUList()
+{
+ const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions();
+ USHORT nLRUFuncCount = Min( rAppOpt.GetLRUFuncListCount(), (USHORT)LRU_MAX );
+ USHORT* pLRUListIds = rAppOpt.GetLRUFuncList();
+
+ USHORT i;
+ for ( i=0; i<LRU_MAX; i++ )
+ aLRUList[i] = NULL;
+
+ if ( pLRUListIds )
+ {
+ ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr();
+ for ( i=0; i<nLRUFuncCount; i++ )
+ aLRUList[i] = pFuncMgr->Get( pLRUListIds[i] );
+ }
+
+ USHORT nSelPos = aCatBox.GetSelectEntryPos();
+
+ if(nSelPos == 0)
+ UpdateFunctionList();
+}
+
+/*************************************************************************
+#* Member: UpdateFunctionList Datum:10.12.99
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Aktualisiert die Liste der zuletzt verwendeten Funktionen.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::UpdateLRUList()
+{
+ if (pFuncDesc && pFuncDesc->nFIndex!=0)
+ {
+ ScModule* pScMod = SC_MOD();
+ pScMod->InsertEntryToLRUList(pFuncDesc->nFIndex);
+ }
+}
+
+
+/*************************************************************************
+#* Member: SetSize Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Groesse fuer die einzelnen Controls einzustellen.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetSize()
+{
+ USHORT nSelEntry=0;
+ SfxChildAlignment aChildAlign=eSfxOldAlignment;//GetAlignment();
+ short nNewDockMode;
+ switch(aChildAlign)
+ {
+ case SFX_ALIGN_HIGHESTTOP:
+ case SFX_ALIGN_TOP:
+ case SFX_ALIGN_LOWESTTOP:
+ case SFX_ALIGN_LOWESTBOTTOM:
+ case SFX_ALIGN_BOTTOM:
+ case SFX_ALIGN_TOOLBOXTOP:
+ case SFX_ALIGN_TOOLBOXBOTTOM:
+
+
+ nNewDockMode=1;
+ if(nDockMode!=nNewDockMode)
+ {
+ nDockMode=nNewDockMode;
+ nSelEntry=aFuncList.GetSelectEntryPos();
+ aFuncList.Clear();
+ aFiFuncDesc.SetPosPixel(aFuncList.GetPosPixel());
+ aDDFuncList.Enable();
+ aDDFuncList.Show();
+ aPrivatSplit.Disable();
+ aPrivatSplit.Hide();
+ aFuncList.Disable();
+ aFuncList.Hide();
+ pAllFuncList=&aDDFuncList;
+ SelHdl(&aCatBox);
+ aDDFuncList.SelectEntryPos(nSelEntry);
+ }
+ break;
+
+ default: nNewDockMode=0;
+ if(nDockMode!=nNewDockMode)
+ {
+ nDockMode=nNewDockMode;
+ nSelEntry=aDDFuncList.GetSelectEntryPos();
+ aDDFuncList.Clear();
+ aDDFuncList.Disable();
+ aDDFuncList.Hide();
+ aPrivatSplit.Enable();
+ aPrivatSplit.Show();
+ aFuncList.Enable();
+ aFuncList.Show();
+ pAllFuncList=&aFuncList;
+ SelHdl(&aCatBox);
+ aFuncList.SelectEntryPos(nSelEntry);
+ }
+ break;
+ }
+
+ if(nDockMode==0)
+ {
+ SetLeftRightSize();
+ }
+ else
+ {
+ SetTopBottonSize();
+ }
+}
+/*************************************************************************
+#* Member: SetLeftRightSize Datum:15.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Groesse fuer die einzelnen Controls einstellen,
+#* wenn Links oder Rechts angedockt wird.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetLeftRightSize()
+{
+ if(bSizeFlag==FALSE)
+ {
+ bSizeFlag=TRUE;
+
+ Size aDiffSize=GetSizePixel();
+ Size aNewSize=GetOutputSizePixel();
+ aDiffSize.Width()-=aNewSize.Width();
+ aDiffSize.Height()-=aNewSize.Height();
+
+ //@ SetUpdateMode( FALSE);
+
+ String aString = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww"));
+
+ Size aTxtSize( aFuncList.GetTextWidth(aString), aFuncList.GetTextHeight() );
+
+ Range aYRange(3*aTxtSize.Height()+aFuncList.GetPosPixel().Y(),
+ GetOutputSizePixel().Height()-2*aTxtSize.Height());
+ aPrivatSplit.SetYRange(aYRange);
+
+
+ if(aOldSize.Width()!=aNewSize.Width())
+ SetMyWidthLeRi(aNewSize);
+
+ if(aOldSize.Height()!=aNewSize.Height())
+ SetMyHeightLeRi(aNewSize);
+
+ aOldSize=aNewSize;
+ aNewSize.Width()+=aDiffSize.Width();
+ aNewSize.Height()+=aDiffSize.Height();
+ //SetSizePixel(aNewSize);
+ //@ SetUpdateMode( TRUE);
+ bSizeFlag=FALSE;
+ }
+
+}
+/*************************************************************************
+#* Member: SetTopBottonSize Datum:15.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Groesse fuer die einzelnen Controls einzustellen.
+#* wenn oben oder unten angedockt wird.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetTopBottonSize()
+{
+ if(bSizeFlag==FALSE)
+ {
+ bSizeFlag=TRUE;
+ Size aDiffSize=GetSizePixel();
+ Size aNewSize=GetOutputSizePixel();
+ aDiffSize.Width()-=aNewSize.Width();
+ aDiffSize.Height()-=aNewSize.Height();
+
+ SetMyWidthToBo(aNewSize);
+ SetMyHeightToBo(aNewSize);
+
+ aNewSize.Width()+=aDiffSize.Width();
+ aNewSize.Height()+=aDiffSize.Height();
+ //SetSizePixel(aNewSize);
+ //@ SetUpdateMode( TRUE);
+ bSizeFlag=FALSE;
+ }
+}
+
+/*************************************************************************
+#* Member: SetMyWidthLeRi Datum:15.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Breite fuer die einzelnen Controls und
+#* das Fenster einstellen,wenn Li oder Re
+#*
+#* Input: neue Fenstergroesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetMyWidthLeRi(Size &aNewSize)
+{
+ if((ULONG)aNewSize.Width()<nMinWidth) aNewSize.Width()=nMinWidth;
+
+ Size aCDSize=aCatBox.GetSizePixel();
+ Size aFLSize=aFuncList.GetSizePixel();
+ Size aSplitterSize=aPrivatSplit.GetSizePixel();
+ Size aFDSize=aFiFuncDesc.GetSizePixel();
+
+ Point aCDTopLeft=aCatBox.GetPosPixel();
+ Point aFLTopLeft=aFuncList.GetPosPixel();
+ Point aSplitterTopLeft=aPrivatSplit.GetPosPixel();
+ Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
+
+ aCDSize.Width()=aNewSize.Width()-aCDTopLeft.X()-aFLTopLeft.X();
+ aFLSize.Width()=aNewSize.Width()-2*aFLTopLeft.X();
+ aFDSize.Width()=aFLSize.Width();
+ aSplitterSize.Width()=aFLSize.Width();
+
+ aCatBox.SetSizePixel(aCDSize);
+ aFuncList.SetSizePixel(aFLSize);
+ aPrivatSplit.SetSizePixel(aSplitterSize);
+ aFiFuncDesc.SetSizePixel(aFDSize);
+}
+
+/*************************************************************************
+#* Member: SetHeight Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Hoehe fuer die einzelnen Controls und
+#* das Fenster einstellen bei Li oder Re
+#*
+#* Input: neue Fenstergroesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetMyHeightLeRi(Size &aNewSize)
+{
+ if((ULONG)aNewSize.Height()<nMinHeight) aNewSize.Height()=nMinHeight;
+
+ Size aFLSize=aFuncList.GetSizePixel();
+ Size aSplitterSize=aPrivatSplit.GetSizePixel();
+ Size aFDSize=aFiFuncDesc.GetSizePixel();
+
+ Point aFLTopLeft=aFuncList.GetPosPixel();
+ Point aSplitterTopLeft=aPrivatSplit.GetPosPixel();
+ Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
+
+ long nTxtHeight = aFuncList.GetTextHeight();
+
+ short nY=(short)(3*nTxtHeight+
+ aFuncList.GetPosPixel().Y()+aSplitterSize.Height());
+
+ aFDTopLeft.Y()=aNewSize.Height()-aFDSize.Height()-4;
+ if(nY>aFDTopLeft.Y())
+ {
+ aFDSize.Height()-=nY-aFDTopLeft.Y();
+ aFDTopLeft.Y()=nY;
+ }
+ aSplitterTopLeft.Y()=aFDTopLeft.Y()-aSplitterSize.Height()-1;
+ aFLSize.Height()=aSplitterTopLeft.Y()-aFLTopLeft.Y()-1;
+
+ aFuncList.SetSizePixel(aFLSize);
+ aPrivatSplit.SetPosPixel(aSplitterTopLeft);
+ aFiFuncDesc.SetPosPixel(aFDTopLeft);
+ aFiFuncDesc.SetSizePixel(aFDSize);
+
+}
+
+/*************************************************************************
+#* Member: SetMyWidthToBo Datum:16.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Breite fuer die einzelnen Controls und
+#* das Fenster einstellen, wenn oben oder
+#* unten angedockt werden soll.
+#*
+#* Input: neue Fenstergroesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetMyWidthToBo(Size &aNewSize)
+{
+ if((ULONG)aNewSize.Width()<nMinWidth) aNewSize.Width()=nMinWidth;
+
+ Size aCDSize=aCatBox.GetSizePixel();
+ Size aDdFLSize=aDDFuncList.GetSizePixel();
+ Size aFDSize=aFiFuncDesc.GetSizePixel();
+
+ Point aCDTopLeft=aCatBox.GetPosPixel();
+ Point aDdFLTopLeft=aDDFuncList.GetPosPixel();
+ Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
+
+ aCDSize.Width()=aDdFLTopLeft.X()-aFDTopLeft.X()-aCDTopLeft.X();
+ aDdFLTopLeft.X()=aCDSize.Width()+aCDTopLeft.X()+aFDTopLeft.X();
+
+ aDdFLSize.Width()=aNewSize.Width()-aDdFLTopLeft.X()-aFDTopLeft.X();
+
+ aFDSize.Width()=aNewSize.Width()-2*aFDTopLeft.X();
+
+ aDDFuncList.SetPosPixel(aDdFLTopLeft);
+ aDDFuncList.SetSizePixel(aDdFLSize);
+ aCatBox.SetSizePixel(aCDSize);
+ aFiFuncDesc.SetSizePixel(aFDSize);
+}
+
+/*************************************************************************
+#* Member: SetHeight Datum:16.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Hoehe fuer die einzelnen Controls und
+#* das Fenster einstellen, wenn oben oder
+#* unten angedockt werden soll.
+#*
+#* Input: neue Fenstergroesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetMyHeightToBo(Size &aNewSize)
+{
+ if((ULONG)aNewSize.Height()<nMinHeight) aNewSize.Height()=nMinHeight;
+
+ Size aFDSize=aFiFuncDesc.GetSizePixel();
+
+ Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
+ Point aCBTopLeft=aCatBox.GetPosPixel();
+ aFDSize.Height()=aNewSize.Height()-aFDTopLeft.Y()-aCBTopLeft.Y();
+ aFiFuncDesc.SetSizePixel(aFDSize);
+
+}
+
+/*************************************************************************
+#* Member: SetDescription Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Erklaerungstext fuer die Funktion einstellen.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetDescription()
+{
+ aFiFuncDesc.SetText( EMPTY_STRING );
+ const ScFuncDesc* pDesc =
+ (const ScFuncDesc*)pAllFuncList->GetEntryData(
+ pAllFuncList->GetSelectEntryPos() );
+ if (pDesc)
+ {
+ pDesc->initArgumentInfo(); // full argument info is needed
+
+ String aString=pAllFuncList->GetSelectEntry();
+ if(nDockMode==0)
+ {
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ":\n\n" ));
+ }
+ else
+ {
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
+ }
+
+ aString+=pDesc->GetParamList();
+
+ if(nDockMode==0)
+ {
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "\n\n" ));
+ }
+ else
+ {
+ aString += '\n';
+ }
+
+ aString+=*(pDesc->pFuncDesc);
+
+ aFiFuncDesc.SetText(aString);
+ aFiFuncDesc.StateChanged(STATE_CHANGE_TEXT);
+ aFiFuncDesc.Invalidate();
+ aFiFuncDesc.Update();
+
+ }
+ }
+
+/*************************************************************************
+#* Member: Resizing Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Ueberladene Funktion um die Groesse der
+#* einzelnen Controls einzustellen.
+#*
+#* Input: neue Groesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void __EXPORT ScFunctionDockWin::Resizing( Size& rNewSize )
+{
+ if((ULONG)rNewSize.Width()<nMinWidth) rNewSize.Width()=nMinWidth;
+ if((ULONG)rNewSize.Height()<nMinHeight) rNewSize.Height()=nMinHeight;
+
+}
+
+/*************************************************************************
+#* Member: Close Datum:07.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Schliessen des Fensters
+#*
+#* Input: ---
+#*
+#* Output: TRUE
+#*
+#************************************************************************/
+
+BOOL __EXPORT ScFunctionDockWin::Close()
+{
+ SfxBoolItem aItem( FID_FUNCTION_BOX, FALSE );
+
+ GetBindings().GetDispatcher()->Execute( FID_FUNCTION_BOX,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
+ &aItem, 0L );
+
+ SfxDockingWindow::Close();
+
+ return( TRUE );
+}
+
+
+/*************************************************************************
+#* Member: CheckAlignment Datum:16.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Ueberprueft den Andockmodus und stellt die
+#* Groessen dementsprechend ein.
+#*
+#* Input: Das neue Alignment
+#*
+#* Output: Das uebergebene Alignment
+#*
+#************************************************************************/
+SfxChildAlignment __EXPORT ScFunctionDockWin::CheckAlignment(SfxChildAlignment /* abla */,
+ SfxChildAlignment aChildAlign)
+{
+ String aString = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww"));
+ Size aTxtSize( aFiFuncDesc.GetTextWidth(aString), aFiFuncDesc.GetTextHeight() );
+ if(!bInit)
+ {
+ eSfxOldAlignment=eSfxNewAlignment;
+ eSfxNewAlignment=aChildAlign;
+ }
+ else
+ {
+ bInit=FALSE;
+ eSfxOldAlignment=aChildAlign;
+ eSfxNewAlignment=aChildAlign;
+ }
+
+ switch(eSfxOldAlignment)
+ {
+ case SFX_ALIGN_HIGHESTTOP:
+ case SFX_ALIGN_TOP:
+ case SFX_ALIGN_LOWESTTOP:
+ case SFX_ALIGN_LOWESTBOTTOM:
+ case SFX_ALIGN_BOTTOM:
+ case SFX_ALIGN_TOOLBOXTOP:
+ case SFX_ALIGN_TOOLBOXBOTTOM:
+
+ nMinWidth= 0;/*aDDFuncList.GetPosPixel().X()+
+ 10*aTxtSize.Width()+
+ aFuncList.GetPosPixel().X();*/
+ nMinHeight=0;
+
+ break;
+
+ case SFX_ALIGN_NOALIGNMENT:
+
+ aString = aCatBox.GetEntry(0);
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM("www"));
+ aTxtSize = Size( aFiFuncDesc.GetTextWidth(aString),
+ aFiFuncDesc.GetTextHeight() );
+
+ default: Point aTopLeft=aCatBox.GetPosPixel();
+ nMinWidth=aTxtSize.Width()+aTopLeft.X()
+ +2*aFuncList.GetPosPixel().X();
+ nMinHeight=19*aTxtSize.Height();
+ //aCatBox.SelectEntryPos(0);
+
+ break;
+ }
+
+ return aChildAlign;
+}
+/*************************************************************************
+#* Member: Close Datum:07.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Aenderungen erkennen
+#*
+#* Input: ---
+#*
+#* Output: TRUE
+#*
+#************************************************************************/
+void ScFunctionDockWin::Notify( SfxBroadcaster&, const SfxHint& /* rHint */ )
+{
+// const SfxPoolItemHint *pPoolItemHint = PTR_CAST(SfxPoolItemHint, &rHint);
+ /*
+ if ( pPoolItemHint
+ && ( pPoolItemHint->GetObject()->ISA( SvxColorTableItem ) ) )
+ {
+ // Die Liste der Farben hat sich geaendert
+ pColorTable = ( (SvxColorTableItem*) pPoolItemHint->GetObject() )->GetColorTable();
+ FillValueSet();
+ }
+ */
+}
+
+
+/*************************************************************************
+#* Member: Resize Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Ueberladene Funktion um die Groesse der
+#* einzelnen Controls einzustellen.
+#*
+#* Input: neue Groesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void __EXPORT ScFunctionDockWin::Resize()
+{
+ if ( !IsFloatingMode() ||
+ !GetFloatingWindow()->IsRollUp() )
+ {
+ Size aQSize=GetOutputSizePixel();
+ Resizing( aQSize);
+ SetSize();
+ }
+ SfxDockingWindow::Resize();
+}
+
+/*************************************************************************
+#* Member: UpdateFunctionList Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Aktualisiert die Liste der Funktionen ab-
+#* haengig von der eingestellten Kategorie.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::UpdateFunctionList()
+{
+ USHORT nSelPos = aCatBox.GetSelectEntryPos();
+ USHORT nCategory = ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
+ ? (nSelPos-1) : 0;
+
+ pAllFuncList->Clear();
+ pAllFuncList->SetUpdateMode( FALSE );
+
+ if ( nSelPos > 0 )
+ {
+ ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr();
+
+ const ScFuncDesc* pDesc = pFuncMgr->First( nCategory );
+ while ( pDesc )
+ {
+ pAllFuncList->SetEntryData(
+ pAllFuncList->InsertEntry( *(pDesc->pFuncName) ),
+ (void*)pDesc );
+ pDesc = pFuncMgr->Next();
+ }
+ }
+ else // LRU-Liste
+ {
+ for ( USHORT i=0; i<LRU_MAX && aLRUList[i]; i++ )
+ {
+ const ScFuncDesc* pDesc = aLRUList[i];
+ pAllFuncList->SetEntryData(
+ pAllFuncList->InsertEntry( *(pDesc->pFuncName) ),
+ (void*)pDesc );
+ }
+ }
+
+
+ //------------------------------------------------------
+ pAllFuncList->SetUpdateMode( TRUE );
+
+ if ( pAllFuncList->GetEntryCount() > 0 )
+ {
+ pAllFuncList->Enable();
+ pAllFuncList->SelectEntryPos( 0 );
+ }
+ else
+ {
+ pAllFuncList->Disable();
+ }
+}
+
+/*************************************************************************
+#* Member: DoEnter Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Eingabe ins Dokument uebernehmen. Wird aufgerufen
+#* nach betaetigen der Uebernehmen- Schaltflaeche
+#* oder einem Doppelklick in die Funktionsliste.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::DoEnter(BOOL /* bOk */) //@@ ???
+{
+ String aFirstArgStr;
+ String aParaStr;
+ String aArgStr;
+ String aString=pAllFuncList->GetSelectEntry();
+ SfxViewShell* pCurSh = SfxViewShell::Current();
+ nArgs=0;
+
+ if(aString.Len()>0)
+ {
+
+ ScModule* pScMod = SC_MOD();
+ ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, pCurSh);
+ ScInputHandler* pHdl = pScMod->GetInputHdl( pViewSh );
+ if(!pScMod->IsEditMode())
+ {
+ pScMod->SetInputMode(SC_INPUT_TABLE);
+ aString = '=';
+ aString += pAllFuncList->GetSelectEntry();
+ if (pHdl)
+ pHdl->ClearText();
+ }
+ const ScFuncDesc* pDesc =
+ (const ScFuncDesc*)pAllFuncList->GetEntryData(
+ pAllFuncList->GetSelectEntryPos() );
+ if (pDesc)
+ {
+ pFuncDesc=pDesc;
+ UpdateLRUList();
+ nArgs = pDesc->nArgCount;
+ if(nArgs>0)
+ {
+ // NOTE: Theoretically the first parameter could have the
+ // suppress flag as well, but practically it doesn't.
+ aFirstArgStr = *(pDesc->ppDefArgNames[0]);
+ aFirstArgStr.EraseLeadingAndTrailingChars();
+ aFirstArgStr.SearchAndReplaceAll(' ', '_');
+ aArgStr = aFirstArgStr;
+ if ( nArgs != VAR_ARGS )
+ { // no VarArgs or Fix plus VarArgs, but not VarArgs only
+ String aArgSep = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( "; " ));
+ USHORT nFix = ( nArgs < VAR_ARGS ? nArgs : nArgs - VAR_ARGS + 1 );
+ for ( USHORT nArg = 1;
+ nArg < nFix && !pDesc->pDefArgFlags[nArg].bOptional; nArg++ )
+ {
+ if (!pDesc->pDefArgFlags[nArg].bSuppress)
+ {
+ aArgStr += aArgSep;
+ String sTmp(*(pDesc->ppDefArgNames[nArg]));
+ sTmp.EraseLeadingAndTrailingChars();
+ sTmp.SearchAndReplaceAll(' ', '_');
+ aArgStr += sTmp;
+ }
+ }
+ }
+ }
+ }
+ if (pHdl)
+ {
+ if(pHdl->GetEditString().Len()==0)
+ {
+ aString = '=';
+ aString += pAllFuncList->GetSelectEntry();
+ }
+ EditView *pEdView=pHdl->GetActiveView();
+ if(pEdView!=NULL) // @ Wegen Absturz bei Namen festlegen
+ {
+ if(nArgs>0)
+ {
+ pHdl->InsertFunction(aString);
+ pEdView->InsertText(aArgStr,TRUE);
+ ESelection aESel=pEdView->GetSelection();
+ aESel.nEndPos=aESel.nStartPos+aFirstArgStr.Len();
+ pEdView->SetSelection(aESel);
+ pHdl->DataChanged();
+ }
+ else
+ {
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "()" ));
+ pEdView->InsertText(aString,FALSE);
+ pHdl->DataChanged();
+ }
+ }
+ }
+ InitLRUList();
+ }
+ if ( pCurSh )
+ {
+ Window* pShellWnd = pCurSh->GetWindow();
+
+ if ( pShellWnd )
+ pShellWnd->GrabFocus();
+ }
+
+
+}
+
+
+
+/*************************************************************************
+#* Handle: SelHdl Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Bei einer Aenderung der Kategorie wird die
+#* die Liste der Funktionen aktualisiert.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScFunctionDockWin, SelHdl, ListBox*, pLb )
+{
+ if ( pLb == &aCatBox)
+ {
+ UpdateFunctionList();
+ SetDescription();
+ }
+
+ if ( pLb == &aFuncList||pLb == &aDDFuncList)
+ {
+ SetDescription();
+ }
+
+
+ //SetSize();
+ return 0;
+}
+
+/*************************************************************************
+#* Handle: SelHdl Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Bei einer Aenderung der Kategorie wird die
+#* die Liste der Funktionen aktualisiert.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScFunctionDockWin, SetSelectionHdl, void*, pCtrl )
+{
+ if ((ImageButton *)pCtrl == &aInsertButton ||
+ (ListBox *)pCtrl == &aFuncList)
+ {
+ DoEnter(TRUE); // Uebernimmt die Eingabe
+ }
+ //...
+
+ return 0;
+}
+
+/*************************************************************************
+#* Handle: SetSplitHdl Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Bei einer Aenderung des Split- Controls werden die
+#* einzelnen Controls an die neue Groesse angepasst.
+#*
+#* Input: Zeiger auf Control
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScFunctionDockWin, SetSplitHdl, ScPrivatSplit*, pCtrl )
+{
+ if (pCtrl == &aPrivatSplit)
+ {
+ short nDeltaY=aPrivatSplit.GetDeltaY();
+ Size aFLSize=aFuncList.GetSizePixel();
+ Size aFDSize=aFiFuncDesc.GetSizePixel();
+ Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
+
+ aFLSize.Height()+=nDeltaY;
+ aFDSize.Height()-=nDeltaY;
+ aFDTopLeft.Y()+=nDeltaY;
+ aFuncList.SetSizePixel(aFLSize);
+ aFiFuncDesc.SetPosPixel(aFDTopLeft);
+ aFiFuncDesc.SetSizePixel(aFDSize);
+ /*
+ aFuncList.Invalidate();
+ aFuncList.Update();
+ aFiFuncDesc.Invalidate();
+ aFiFuncDesc.Update();
+ */
+ }
+ //...
+
+ return 0;
+}
+
+void ScFunctionDockWin::ToggleFloatingMode()
+{
+ aSplitterInitPos = Point();
+ SfxDockingWindow::ToggleFloatingMode();
+
+ eSfxNewAlignment=GetAlignment();
+ eSfxOldAlignment=eSfxNewAlignment;
+
+ aOldSize.Height()=0;
+ aOldSize.Width()=0;
+ aTimer.Start();
+}
+
+IMPL_LINK( ScFunctionDockWin, TimerHdl, Timer*, EMPTYARG )
+{
+ CheckAlignment(eSfxOldAlignment,eSfxNewAlignment);
+ SetSize();
+ return 0;
+}
+
+void ScFunctionDockWin::Initialize(SfxChildWinInfo *pInfo)
+{
+ String aStr;
+ if(pInfo!=NULL)
+ {
+ if ( pInfo->aExtraString.Len() )
+ {
+ xub_StrLen nPos = pInfo->aExtraString.Search(
+ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScFuncList:")));
+
+ // Versuche, den Alignment-String "ALIGN:(...)" einzulesen; wenn
+ // er nicht vorhanden ist, liegt eine "altere Version vor
+ if ( nPos != STRING_NOTFOUND )
+ {
+ xub_StrLen n1 = pInfo->aExtraString.Search('(', nPos);
+ if ( n1 != STRING_NOTFOUND )
+ {
+ xub_StrLen n2 = pInfo->aExtraString.Search(')', n1);
+ if ( n2 != STRING_NOTFOUND )
+ {
+ // Alignment-String herausschneiden
+ aStr = pInfo->aExtraString.Copy(nPos, n2 - nPos + 1);
+ pInfo->aExtraString.Erase(nPos, n2 - nPos + 1);
+ aStr.Erase(0, n1-nPos+1);
+ }
+ }
+ }
+ }
+ }
+ SfxDockingWindow::Initialize(pInfo);
+
+ if ( aStr.Len())
+ {
+ aSplitterInitPos=aPrivatSplit.GetPosPixel();
+ aSplitterInitPos.Y()=(USHORT) aStr.ToInt32();
+ xub_StrLen n1 = aStr.Search(';');
+ aStr.Erase(0, n1+1);
+ USHORT nSelPos=sal::static_int_cast<USHORT>( aStr.ToInt32() );
+ aCatBox.SelectEntryPos(nSelPos);
+ SelHdl(&aCatBox);
+
+ // if the window has already been shown (from SfxDockingWindow::Initialize if docked),
+ // set the splitter position now, otherwise it is set in StateChanged with type INITSHOW
+
+ UseSplitterInitPos();
+ }
+}
+
+//-------------------------------------------------------------------------
+
+void ScFunctionDockWin::FillInfo(SfxChildWinInfo& rInfo) const
+{
+ SfxDockingWindow::FillInfo(rInfo);
+ Point aPoint=aPrivatSplit.GetPosPixel();
+ rInfo.aExtraString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "ScFuncList:(" ));
+ rInfo.aExtraString += String::CreateFromInt32(aPoint.Y());
+ rInfo.aExtraString += ';';
+ rInfo.aExtraString += String::CreateFromInt32(aCatBox.GetSelectEntryPos());
+ rInfo.aExtraString += ')';
+}
+
+void ScFunctionDockWin::UseSplitterInitPos()
+{
+ if ( IsVisible() && aPrivatSplit.IsEnabled() && aSplitterInitPos != Point() )
+ {
+ aPrivatSplit.MoveSplitTo(aSplitterInitPos);
+ aSplitterInitPos = Point(); // use only once
+ }
+}
+
+void ScFunctionDockWin::StateChanged( StateChangedType nStateChange )
+{
+ SfxDockingWindow::StateChanged( nStateChange );
+
+ if (nStateChange == STATE_CHANGE_INITSHOW)
+ {
+ UseSplitterInitPos(); // set initial splitter position if necessary
+ }
+}
+
+
diff --git a/sc/source/ui/formdlg/formdlgs.src b/sc/source/ui/formdlg/formdlgs.src
index 2e9ceb6b1dd3..bc7a2fd573d3 100644
--- a/sc/source/ui/formdlg/formdlgs.src
+++ b/sc/source/ui/formdlg/formdlgs.src
@@ -1,32 +1,32 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: formdlgs.src,v $
- * $Revision: 1.49 $
- *
- * 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 "sc.hrc"
- //---------------------------------------------------------------------------
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: formdlgs.src,v $
+ * $Revision: 1.49 $
+ *
+ * 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 "sc.hrc"
+ //---------------------------------------------------------------------------
diff --git a/sc/source/ui/miscdlgs/crnrdlg.cxx b/sc/source/ui/miscdlgs/crnrdlg.cxx
index 8684ea3fa558..8ec33d49b874 100644
--- a/sc/source/ui/miscdlgs/crnrdlg.cxx
+++ b/sc/source/ui/miscdlgs/crnrdlg.cxx
@@ -1,1175 +1,1175 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: crnrdlg.cxx,v $
- * $Revision: 1.11 $
- *
- * 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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sc.hxx"
-
-// System - Includes ---------------------------------------------------------
-
-
-
-// INCLUDE -------------------------------------------------------------------
-
-#include "reffact.hxx"
-#include "document.hxx"
-#include "scresid.hxx"
-#include "globstr.hrc"
-#include "crnrdlg.hrc"
-#include "docsh.hxx"
-
-#define _CRNRDLG_CXX
-#include "crnrdlg.hxx"
-#undef _CRNRDLG_CXX
-#include <vcl/msgbox.hxx>
-
-
-//============================================================================
-
-#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute()
-#define QUERYBOX(m) QueryBox(this,WinBits(WB_YES_NO|WB_DEF_YES),m).Execute()
-
-const ULONG nEntryDataCol = 0;
-const ULONG nEntryDataRow = 1;
-const ULONG nEntryDataDelim = 2;
-
-
-//============================================================================
-// class ScColRowNameRangesDlg
-
-
-/*************************************************************************
-#* Member: ScColRowNameRangesDlg Datum:04.09.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScColRowNameRangesDlg
-#*
-#* Funktion: Konstruktor der Klasse ScColRowNameRangesDlg.
-#* Initialisieren der Klassen- Mitglieder,
-#* Uebernahme der Range- Angaben und Aufruf
-#* der eigentlichen Initialisierungsroutine
-#*
-#* Input: Sfx- Verknuepfungen
-#* Parent- Window
-#* SCViewData
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-ScColRowNameRangesDlg::ScColRowNameRangesDlg( SfxBindings* pB,
- SfxChildWindow* pCW,
- Window* pParent,
- ScViewData* ptrViewData )
-
- : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_COLROWNAMERANGES ),
- //
- aFlAssign ( this, ScResId( FL_ASSIGN ) ),
- aLbRange ( this, ScResId( LB_RANGE ) ),
-
- aEdAssign ( this, ScResId( ED_AREA ) ),
- aRbAssign ( this, ScResId( RB_AREA ), &aEdAssign, this ),
- aBtnColHead ( this, ScResId( BTN_COLHEAD ) ),
- aBtnRowHead ( this, ScResId( BTN_ROWHEAD ) ),
- aFtAssign2 ( this, ScResId( FT_DATA_LABEL ) ),
- aEdAssign2 ( this, ScResId( ED_DATA ) ),
- aRbAssign2 ( this, ScResId( RB_DATA ), &aEdAssign2, this ),
-
- aBtnOk ( this, ScResId( BTN_OK ) ),
- aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
- aBtnHelp ( this, ScResId( BTN_HELP ) ),
- aBtnAdd ( this, ScResId( BTN_ADD ) ),
- aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
-
- pViewData ( ptrViewData ),
- pDoc ( ptrViewData->GetDocument() ),
-
- pEdActive ( NULL ),
- bDlgLostFocus ( FALSE )
-{
- xColNameRanges = pDoc->GetColNameRanges()->Clone();
- xRowNameRanges = pDoc->GetRowNameRanges()->Clone();
- Init();
- FreeResource();
-}
-
-
-/*************************************************************************
-#* Member: ~ScColRowNameRangesDlg Datum:04.09.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScColRowNameRangesDlg
-#*
-#* Funktion: Destruktor der Klasse
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-__EXPORT ScColRowNameRangesDlg::~ScColRowNameRangesDlg()
-{
-}
-
-
-/*************************************************************************
-#* Member: Init Datum:04.09.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScColRowNameRangesDlg
-#*
-#* Funktion: Initialisierungs- Routine:
-#* Umlenken der Event- Handler und einstellen der
-#* Startparameter.
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void ScColRowNameRangesDlg::Init()
-{
- SCCOL nStartCol = 0;
- SCROW nStartRow = 0;
- SCTAB nStartTab = 0;
- SCCOL nEndCol = 0;
- SCROW nEndRow = 0;
- SCTAB nEndTab = 0;
-
- aBtnOk.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, OkBtnHdl ) );
- aBtnCancel.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, CancelBtnHdl ) );
- aBtnAdd.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, AddBtnHdl ) );
- aBtnRemove.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, RemoveBtnHdl ) );
- aLbRange.SetSelectHdl ( LINK( this, ScColRowNameRangesDlg, Range1SelectHdl ) );
- aEdAssign.SetModifyHdl ( LINK( this, ScColRowNameRangesDlg, Range1DataModifyHdl ) );
- aBtnColHead.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, ColClickHdl ) );
- aBtnRowHead.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, RowClickHdl ) );
- aEdAssign2.SetModifyHdl ( LINK( this, ScColRowNameRangesDlg, Range2DataModifyHdl ) );
-
- Link aLink = LINK( this, ScColRowNameRangesDlg, GetFocusHdl );
- aEdAssign.SetGetFocusHdl( aLink );
- aRbAssign.SetGetFocusHdl( aLink );
- aEdAssign2.SetGetFocusHdl( aLink );
- aRbAssign2.SetGetFocusHdl( aLink );
-
- aLink = LINK( this, ScColRowNameRangesDlg, LoseFocusHdl );
- aEdAssign.SetLoseFocusHdl( aLink );
- aRbAssign.SetLoseFocusHdl( aLink );
- aEdAssign2.SetLoseFocusHdl( aLink );
- aRbAssign2.SetLoseFocusHdl( aLink );
-
- pEdActive = &aEdAssign;
-
- UpdateNames();
-
- if ( pViewData && pDoc )
- {
- pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
- nEndCol, nEndRow, nEndTab );
- SetColRowData( ScRange( ScAddress( nStartCol, nStartRow, nStartTab ),
- ScAddress( nEndCol, nEndRow, nEndTab ) ) );
- }
- else
- {
- aBtnColHead.Check( TRUE );
- aBtnRowHead.Check( FALSE );
- aEdAssign.SetText( EMPTY_STRING );
- aEdAssign2.SetText( EMPTY_STRING );
- }
-
- aLbRange.SetBorderStyle( WINDOW_BORDER_MONO );
- aBtnColHead.Enable();
- aBtnRowHead.Enable();
- aEdAssign.Enable();
- aEdAssign.GrabFocus();
- aRbAssign.Enable();
- //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
- //SFX_APPWINDOW->Enable(); // Ref-Feld hat Focus
-
- Range1SelectHdl( 0 );
-}
-
-
-/*************************************************************************
-#* Member: SetColRowData Datum:04.09.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScColRowNameRangesDlg
-#*
-#* Funktion: zugehoerigen Datenbereich eines Beschriftungsbereiches
-#* auf default Werte setzen und beide Referenz-Edit-Felder
-#* fuellen.
-#*
-#* Input: Einstellbereich fuer Labels
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void ScColRowNameRangesDlg::SetColRowData( const ScRange& rLabelRange,BOOL bRef)
-{
- theCurData = theCurArea = rLabelRange;
- BOOL bValid = TRUE;
- SCCOL nCol1 = theCurArea.aStart.Col();
- SCCOL nCol2 = theCurArea.aEnd.Col();
- SCROW nRow1 = theCurArea.aStart.Row();
- SCROW nRow2 = theCurArea.aEnd.Row();
- if ( (static_cast<SCCOLROW>(nCol2 - nCol1) >= nRow2 - nRow1) || (nCol1 == 0 && nCol2 == MAXCOL) )
- { // Spaltenkoepfe und Grenzfall gesamte Tabelle
- aBtnColHead.Check( TRUE );
- aBtnRowHead.Check( FALSE );
- if ( nRow2 == MAXROW )
- {
- if ( nRow1 == 0 )
- bValid = FALSE; // Grenzfall gesamte Tabelle
- else
- { // Head unten, Data oben
- theCurData.aStart.SetRow( 0 );
- theCurData.aEnd.SetRow( nRow1 - 1 );
- }
- }
- else
- { // Head oben, Data unten
- theCurData.aStart.SetRow( nRow2 + 1 );
- theCurData.aEnd.SetRow( MAXROW );
- }
- }
- else
- { // Zeilenkoepfe
- aBtnRowHead.Check( TRUE );
- aBtnColHead.Check( FALSE );
- if ( nCol2 == MAXCOL )
- { // Head rechts, Data links
- theCurData.aStart.SetCol( 0 );
- theCurData.aEnd.SetCol( nCol2 - 1 );
- }
- else
- { // Head links, Data rechts
- theCurData.aStart.SetCol( nCol2 + 1 );
- theCurData.aEnd.SetCol( MAXCOL );
- }
- }
- if ( bValid )
- {
- const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
- String aStr;
- theCurArea.Format( aStr, SCR_ABS_3D, pDoc, eConv );
-
- if(bRef)
- aEdAssign.SetRefString( aStr );
- else
- aEdAssign.SetText( aStr );
-
- aEdAssign.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) );
- theCurData.Format( aStr, SCR_ABS_3D, pDoc, eConv );
-
- if(bRef)
- aEdAssign2.SetRefString( aStr );
- else
- aEdAssign2.SetText( aStr );
- }
- else
- {
- theCurData = theCurArea = ScRange();
-
- if(bRef)
- {
- aEdAssign.SetRefString( EMPTY_STRING );
- aEdAssign2.SetRefString( EMPTY_STRING );
- }
- else
- {
- aEdAssign.SetText( EMPTY_STRING );
- aEdAssign2.SetText( EMPTY_STRING );
- }
-
- aBtnColHead.Disable();
- aBtnRowHead.Disable();
- aEdAssign2.Disable();
- aRbAssign2.Disable();
- }
-}
-
-
-/*************************************************************************
-#* Member: AdjustColRowData Datum:04.09.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScColRowNameRangesDlg
-#*
-#* Funktion: zugehoerigen Datenbereich eines Beschriftungsbereiches
-#* anpassen und Data-Referenz-Edit-Feld fuellen.
-#*
-#* Input: Bereich fuer Labels
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void ScColRowNameRangesDlg::AdjustColRowData( const ScRange& rDataRange,BOOL bRef)
-{
- theCurData = rDataRange;
- if ( aBtnColHead.IsChecked() )
- { // Datenbereich gleiche Spalten wie Koepfe
- theCurData.aStart.SetCol( theCurArea.aStart.Col() );
- theCurData.aEnd.SetCol( theCurArea.aEnd.Col() );
- if ( theCurData.Intersects( theCurArea ) )
- {
- SCROW nRow1 = theCurArea.aStart.Row();
- SCROW nRow2 = theCurArea.aEnd.Row();
- if ( nRow1 > 0
- && (theCurData.aEnd.Row() < nRow2 || nRow2 == MAXROW) )
- { // Data oben
- theCurData.aEnd.SetRow( nRow1 - 1 );
- if ( theCurData.aStart.Row() > theCurData.aEnd.Row() )
- theCurData.aStart.SetRow( theCurData.aEnd.Row() );
- }
- else
- { // Data unten
- theCurData.aStart.SetRow( nRow2 + 1 );
- if ( theCurData.aStart.Row() > theCurData.aEnd.Row() )
- theCurData.aEnd.SetRow( theCurData.aStart.Row() );
- }
- }
- }
- else
- { // Datenbereich gleiche Zeilen wie Koepfe
- theCurData.aStart.SetRow( theCurArea.aStart.Row() );
- theCurData.aEnd.SetRow( theCurArea.aEnd.Row() );
- if ( theCurData.Intersects( theCurArea ) )
- {
- SCCOL nCol1 = theCurArea.aStart.Col();
- SCCOL nCol2 = theCurArea.aEnd.Col();
- if ( nCol1 > 0
- && (theCurData.aEnd.Col() < nCol2 || nCol2 == MAXCOL) )
- { // Data links
- theCurData.aEnd.SetCol( nCol1 - 1 );
- if ( theCurData.aStart.Col() > theCurData.aEnd.Col() )
- theCurData.aStart.SetCol( theCurData.aEnd.Col() );
- }
- else
- { // Data rechts
- theCurData.aStart.SetCol( nCol2 + 1 );
- if ( theCurData.aStart.Col() > theCurData.aEnd.Col() )
- theCurData.aEnd.SetCol( theCurData.aStart.Col() );
- }
- }
- }
- String aStr;
- theCurData.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
-
- if(bRef)
- aEdAssign2.SetRefString( aStr );
- else
- aEdAssign2.SetText( aStr );
-
- aEdAssign2.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) );
-}
-
-
-/*************************************************************************
-#* Member: SetReference Datum:04.09.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScColRowNameRangesDlg
-#*
-#* Funktion: Uebergabe eines mit der Maus selektierten Tabellen-
-#* bereiches, der dann als neue Selektion im Referenz-
-#* Fenster angezeigt wird.
-#*
-#* Input: Bereich fuer Labels
-#* Dokumentklasse
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void ScColRowNameRangesDlg::SetReference( const ScRange& rRef, ScDocument* /* pDoc */ )
-{
- if ( pEdActive )
- {
- if ( rRef.aStart != rRef.aEnd )
- RefInputStart( pEdActive );
-
- String aRefStr;
- if ( pEdActive == &aEdAssign )
- SetColRowData( rRef, TRUE );
- else
- AdjustColRowData( rRef, TRUE );
- aBtnColHead.Enable();
- aBtnRowHead.Enable();
- aBtnAdd.Enable();
- aBtnRemove.Disable();
- }
-}
-
-
-/*************************************************************************
-#* Member: Close Datum:04.09.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScColRowNameRangesDlg
-#*
-#* Funktion: Schliessen des Fensters
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-BOOL __EXPORT ScColRowNameRangesDlg::Close()
-{
- return DoClose( ScColRowNameRangesDlgWrapper::GetChildWindowId() );
-}
-
-
-/*************************************************************************
-#* Member: SetActive Datum:04.09.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScColRowNameRangesDlg
-#*
-#* Funktion: Aktivieren des Fensters
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void ScColRowNameRangesDlg::SetActive()
-{
- if ( bDlgLostFocus )
- {
- bDlgLostFocus = FALSE;
- if( pEdActive )
- pEdActive->GrabFocus();
- }
- else
- GrabFocus();
-
- if( pEdActive == &aEdAssign )
- Range1DataModifyHdl( 0 );
- else if( pEdActive == &aEdAssign2 )
- Range2DataModifyHdl( 0 );
-
- RefInputDone();
-}
-
-
-/*************************************************************************
-#* Member: UpdateNames Datum:04.09.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScColRowNameRangesDlg
-#*
-#* Funktion: Aktualisieren der Namen
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void ScColRowNameRangesDlg::UpdateNames()
-{
- aLbRange.SetUpdateMode( FALSE );
- //-----------------------------------------------------------
- aLbRange.Clear();
- aRangeMap.clear();
- aEdAssign.SetText( EMPTY_STRING );
-
- ULONG nCount, j;
- USHORT nPos; //@008 Hilfsvariable q eingefuegt
-
- SCCOL nCol1; //@008 04.09.97
- SCROW nRow1; //Erweiterung fuer Bereichsnamen
- SCTAB nTab1;
- SCCOL nCol2;
- SCROW nRow2;
- SCTAB nTab2;
- String rString;
- String strShow;
- const ScAddress::Details aDetails(pDoc->GetAddressConvention());
-
- String aString;
- String strDelim = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( " --- " ));
- aString = strDelim;
- aString += ScGlobal::GetRscString( STR_COLUMN );
- aString += strDelim;
- nPos = aLbRange.InsertEntry( aString );
- aLbRange.SetEntryData( nPos, (void*)nEntryDataDelim );
- if ( (nCount = xColNameRanges->Count()) > 0 )
- {
- ScRangePair** ppSortArray = xColNameRanges->CreateNameSortedArray(
- nCount, pDoc );
- for ( j=0; j < nCount; j++ )
- {
- const ScRange aRange(ppSortArray[j]->GetRange(0));
- aRange.Format( aString, SCR_ABS_3D, pDoc, aDetails );
-
- //@008 Hole Bereichsparameter aus Dok
- ppSortArray[j]->GetRange(0).GetVars( nCol1, nRow1, nTab1,
- nCol2, nRow2, nTab2 );
- SCCOL q=nCol1+3;
- if(q>nCol2) q=nCol2;
- //@008 Baue String zusammen
- strShow.AssignAscii(RTL_CONSTASCII_STRINGPARAM(" ["));
- if(pDoc!=NULL)
- {
- pDoc->GetString(nCol1, nRow1, nTab1,rString);
- strShow +=rString;
- for(SCCOL i=nCol1+1;i<=q;i++)
- {
- strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
- pDoc->GetString(i, nRow1, nTab1,rString);
- strShow += rString;
- }
- }
- if(q<nCol2) // Zu lang? Ergaenzen um ",..."
- {
- strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", ..."));
- }
- strShow += ']';
-
- //@008 String einfuegen in Listbox
- String aInsStr = aString;
- aInsStr += strShow;
- nPos = aLbRange.InsertEntry( aInsStr );
- aRangeMap.insert( NameRangeMap::value_type(aInsStr, aRange) );
- aLbRange.SetEntryData( nPos, (void*)nEntryDataCol );
- }
- delete [] ppSortArray;
- }
- aString = strDelim;
- aString += ScGlobal::GetRscString( STR_ROW );
- aString += strDelim;
- nPos = aLbRange.InsertEntry( aString );
- aLbRange.SetEntryData( nPos, (void*)nEntryDataDelim );
- if ( (nCount = xRowNameRanges->Count()) > 0 )
- {
- ScRangePair** ppSortArray = xRowNameRanges->CreateNameSortedArray(
- nCount, pDoc );
- for ( j=0; j < nCount; j++ )
- {
- const ScRange aRange(ppSortArray[j]->GetRange(0));
- aRange.Format( aString, SCR_ABS_3D, pDoc, aDetails );
-
- //@008 Ab hier baue String fuer Zeilen
- ppSortArray[j]->GetRange(0).GetVars( nCol1, nRow1, nTab1,
- nCol2, nRow2, nTab2 );
- SCROW q=nRow1+3;
- if(q>nRow2) q=nRow2;
- strShow.AssignAscii(RTL_CONSTASCII_STRINGPARAM(" ["));
- if(pDoc!=NULL)
- {
- pDoc->GetString(nCol1, nRow1, nTab1,rString);
- strShow += rString;
- for(SCROW i=nRow1+1;i<=q;i++)
- {
- strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
- pDoc->GetString(nCol1, i, nTab1,rString);
- strShow += rString;
- }
- }
- if(q<nRow2)
- {
- strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", ..."));
- }
- strShow += ']';
-
- String aInsStr = aString;
- aInsStr += strShow;
- nPos = aLbRange.InsertEntry( aInsStr );
- aRangeMap.insert( NameRangeMap::value_type(aInsStr, aRange) );
- aLbRange.SetEntryData( nPos, (void*)nEntryDataRow );
- }
- delete [] ppSortArray;
- }
- //-----------------------------------------------------------
- aLbRange.SetUpdateMode( TRUE );
- aLbRange.Invalidate();
-}
-
-
-/*************************************************************************
-#* Member: UpdateRangeData Datum:04.09.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScColRowNameRangesDlg
-#*
-#* Funktion: Aktualisieren der Bereichsdaten
-#*
-#* Input: Bereichs-String
-#* Flag fuer Spalten
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-void ScColRowNameRangesDlg::UpdateRangeData( const ScRange& rRange, BOOL bColName )
-{
- ScRangePair* pPair = NULL;
- BOOL bFound = FALSE;
- if ( bColName && (pPair = xColNameRanges->Find( rRange )) != NULL )
- bFound = TRUE;
- else if ( !bColName && (pPair = xRowNameRanges->Find( rRange )) != NULL )
- bFound = TRUE;
-
- if ( bFound )
- {
- const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
- String aStr;
- theCurArea = rRange;
- theCurArea.Format( aStr, SCR_ABS_3D, pDoc, eConv );
- aEdAssign.SetText( aStr );
- aBtnAdd.Disable();
- aBtnRemove.Enable();
- aBtnColHead.Check( bColName );
- aBtnRowHead.Check( !bColName );
- theCurData = pPair->GetRange(1);
- theCurData.Format( aStr, SCR_ABS_3D, pDoc, eConv );
- aEdAssign2.SetText( aStr );
- }
- else
- {
- aBtnAdd.Enable();
- aBtnRemove.Disable();
- }
- aBtnColHead.Enable();
- aBtnRowHead.Enable();
- aEdAssign2.Enable();
- aRbAssign2.Enable();
-}
-
-
-/*************************************************************************
-#* Member: IsRefInputMode Datum:04.09.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScColRowNameRangesDlg
-#*
-#* Funktion: Abfragefunktion fuer Referenz- Input- Mode.
-#*
-#* Input: Bereichs-String
-#* Flag fuer Spalten
-#*
-#* Output: true, wenn Referenz- Input- Mode
-#*
-#************************************************************************/
-
-BOOL ScColRowNameRangesDlg::IsRefInputMode() const
-{
- return (pEdActive != NULL);
-}
-
-//------------------------------------------------------------------------
-// Handler:
-// ========
-
-/*************************************************************************
-#* Handler: OkBtnHdl Datum:04.09.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScColRowNameRangesDlg
-#*
-#* Funktion: Wird ausgeloest, wenn der OK- Button gedrueckt wurde.
-#* Hinzufuegen- Button ausloesen, und die neu einge-
-#* stellten Bereiche ans Dokument uebergeben.
-#* Fensterschliessen- Anweisung ausloesen.
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-IMPL_LINK( ScColRowNameRangesDlg, OkBtnHdl, void *, EMPTYARG )
-{
- AddBtnHdl( 0 );
-
- // die RangeLists den Refs am Doc zuweisen
- pDoc->GetColNameRangesRef() = xColNameRanges;
- pDoc->GetRowNameRangesRef() = xRowNameRanges;
- // geaenderte Datenbereiche muessen sich auswirken
- pDoc->CompileColRowNameFormula();
- ScDocShell* pDocShell = pViewData->GetDocShell();
- pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID );
- pDocShell->SetDocumentModified();
-
- Close();
- return 0;
-}
-
-
-/*************************************************************************
-#* Handler: CancelBtnHdl Datum:04.09.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScColRowNameRangesDlg
-#*
-#* Funktion: Fensterschliessen- Anweisung ausloesen.
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-IMPL_LINK_INLINE_START( ScColRowNameRangesDlg, CancelBtnHdl, void *, EMPTYARG )
-{
- Close();
- return 0;
-}
-IMPL_LINK_INLINE_END( ScColRowNameRangesDlg, CancelBtnHdl, void *, EMPTYARG )
-
-
-/*************************************************************************
-#* Handler: AddBtnHdl Datum:04.09.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScColRowNameRangesDlg
-#*
-#* Funktion: Nach betaetigen des Hinzufuegen- Buttons, werden
-#* die Bereichsangaben eingestellt und in der
-#* Listbox dargestellt.
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-IMPL_LINK( ScColRowNameRangesDlg, AddBtnHdl, void *, EMPTYARG )
-{
- String aNewArea( aEdAssign.GetText() );
- String aNewData( aEdAssign2.GetText() );
-
- if ( aNewArea.Len() > 0 && aNewData.Len() > 0 )
- {
- const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
- ScRange aRange1, aRange2;
- BOOL bOk1;
- if ( (bOk1 = ((aRange1.ParseAny( aNewArea, pDoc, eConv ) & SCA_VALID) == SCA_VALID)) != FALSE
- && ((aRange2.ParseAny( aNewData, pDoc, eConv ) & SCA_VALID) == SCA_VALID) )
- {
- theCurArea = aRange1;
- AdjustColRowData( aRange2 );
- ScRangePair* pPair;
- if ( ( pPair = xColNameRanges->Find( theCurArea ) ) != NULL )
- {
- xColNameRanges->Remove( pPair );
- delete pPair;
- }
- if ( ( pPair = xRowNameRanges->Find( theCurArea ) ) != NULL )
- {
- xRowNameRanges->Remove( pPair );
- delete pPair;
- }
- if ( aBtnColHead.IsChecked() )
- xColNameRanges->Join( ScRangePair( theCurArea, theCurData ) );
- else
- xRowNameRanges->Join( ScRangePair( theCurArea, theCurData ) );
-
- UpdateNames();
-
- aEdAssign.GrabFocus();
- aBtnAdd.Disable();
- aBtnRemove.Disable();
- aEdAssign.SetText( EMPTY_STRING );
- aBtnColHead.Check( TRUE );
- aBtnRowHead.Check( FALSE );
- aEdAssign2.SetText( EMPTY_STRING );
- theCurArea = ScRange();
- theCurData = theCurArea;
- Range1SelectHdl( 0 );
- }
- else
- {
- ERRORBOX( ScGlobal::GetRscString(STR_INVALIDTABNAME) );
- if ( !bOk1 )
- aEdAssign.GrabFocus();
- else
- aEdAssign2.GrabFocus();
- }
- }
- return 0;
-}
-
-
-/*************************************************************************
-#* Handler: RemoveBtnHdl Datum:04.09.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScColRowNameRangesDlg
-#*
-#* Funktion: Nach betaetigen des Loeschen- Buttons, wird
-#* die markierte Bereichsangabe geloescht.
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-IMPL_LINK( ScColRowNameRangesDlg, RemoveBtnHdl, void *, EMPTYARG )
-{
- String aRangeStr = aLbRange.GetSelectEntry();
- USHORT nSelectPos = aLbRange.GetSelectEntryPos();
- BOOL bColName =
- ((ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataCol);
- NameRangeMap::const_iterator itr = aRangeMap.find(aRangeStr);
- if (itr == aRangeMap.end())
- return 0;
- const ScRange& rRange = itr->second;
-
- ScRangePair* pPair = NULL;
- BOOL bFound = FALSE;
- if ( bColName && (pPair = xColNameRanges->Find( rRange )) != NULL )
- bFound = TRUE;
- else if ( !bColName && (pPair = xRowNameRanges->Find( rRange )) != NULL )
- bFound = TRUE;
- if ( bFound )
- {
- String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY );
- String aMsg = aStrDelMsg.GetToken( 0, '#' );
-
- aMsg += aRangeStr;
- aMsg += aStrDelMsg.GetToken( 1, '#' );
-
- if ( RET_YES == QUERYBOX(aMsg) )
- {
- if ( bColName )
- xColNameRanges->Remove( pPair );
- else
- xRowNameRanges->Remove( pPair );
- delete pPair;
-
- UpdateNames();
- USHORT nCnt = aLbRange.GetEntryCount();
- if ( nSelectPos >= nCnt )
- {
- if ( nCnt )
- nSelectPos = nCnt - 1;
- else
- nSelectPos = 0;
- }
- aLbRange.SelectEntryPos( nSelectPos );
- if ( nSelectPos &&
- (ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataDelim )
- aLbRange.SelectEntryPos( --nSelectPos ); // ---Zeile---
-
- aLbRange.GrabFocus();
- aBtnAdd.Disable();
- aBtnRemove.Disable();
- aEdAssign.SetText( EMPTY_STRING );
- theCurArea = theCurData = ScRange();
- aBtnColHead.Check( TRUE );
- aBtnRowHead.Check( FALSE );
- aEdAssign2.SetText( EMPTY_STRING );
- Range1SelectHdl( 0 );
- }
- }
- return 0;
-}
-
-
-/*************************************************************************
-#* Handler: Range1SelectHdl Datum:04.09.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScColRowNameRangesDlg
-#*
-#* Funktion: Wenn Zeile in Listbox ausgewaehlt wird,
-#* werden die Eingabefelder entsprechend
-#* eingestellt.
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-IMPL_LINK( ScColRowNameRangesDlg, Range1SelectHdl, void *, EMPTYARG )
-{
- USHORT nSelectPos = aLbRange.GetSelectEntryPos();
- USHORT nCnt = aLbRange.GetEntryCount();
- USHORT nMoves = 0;
- while ( nSelectPos < nCnt
- && (ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataDelim )
- { // skip Delimiter
- ++nMoves;
- aLbRange.SelectEntryPos( ++nSelectPos );
- }
- String aRangeStr = aLbRange.GetSelectEntry();
- if ( nMoves )
- {
- if ( nSelectPos > 1 && nSelectPos >= nCnt )
- { // am Ende nicht auf dem " --- Zeile --- " Delimiter stehenbleiben
- // wenn davor Eintraege existieren
- nSelectPos = nCnt - 2;
- aLbRange.SelectEntryPos( nSelectPos );
- aRangeStr = aLbRange.GetSelectEntry();
- }
- else if ( nSelectPos > 2 && nSelectPos < nCnt && aRangeStr.Len()
- && aRangeStr == aEdAssign.GetText() )
- { // nach oben wandern statt nach unten auf die vorherige Position
- nSelectPos -= 2;
- aLbRange.SelectEntryPos( nSelectPos );
- aRangeStr = aLbRange.GetSelectEntry();
- }
- }
- NameRangeMap::const_iterator itr = aRangeMap.find(aRangeStr);
- if ( itr != aRangeMap.end() )
- {
- BOOL bColName =
- ((ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataCol);
- UpdateRangeData( itr->second, bColName );
- aBtnAdd.Disable();
- aBtnRemove.Enable();
- }
- else
- {
- if ( aEdAssign.GetText().Len() > 0 )
- {
- if ( aEdAssign2.GetText().Len() > 0 )
- aBtnAdd.Enable();
- else
- aBtnAdd.Disable();
- aBtnColHead.Enable();
- aBtnRowHead.Enable();
- aEdAssign2.Enable();
- aRbAssign2.Enable();
- }
- else
- {
- aBtnAdd.Disable();
- aBtnColHead.Disable();
- aBtnRowHead.Disable();
- aEdAssign2.Disable();
- aRbAssign2.Disable();
- }
- aBtnRemove.Disable();
- aEdAssign.GrabFocus();
- }
-
- aEdAssign.Enable();
- aRbAssign.Enable();
-
- //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
- //SFX_APPWINDOW->Enable();
- return 0;
-}
-
-
-/*************************************************************************
-#* Handler: Range1DataModifyHdl Datum:04.09.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScColRowNameRangesDlg
-#*
-#* Funktion: Wird ausgeloest, wenn in der Tabelle, der Label-
-#* Bereich geaendert wurde.
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-IMPL_LINK( ScColRowNameRangesDlg, Range1DataModifyHdl, void *, EMPTYARG )
-{
- String aNewArea( aEdAssign.GetText() );
- BOOL bValid = FALSE;
- if ( aNewArea.Len() > 0 )
- {
- ScRange aRange;
- if ( (aRange.ParseAny( aNewArea, pDoc, pDoc->GetAddressConvention() ) & SCA_VALID) == SCA_VALID )
- {
- SetColRowData( aRange );
- bValid = TRUE;
- }
- }
- if ( bValid )
- {
- aBtnAdd.Enable();
- aBtnColHead.Enable();
- aBtnRowHead.Enable();
- aEdAssign2.Enable();
- aRbAssign2.Enable();
- }
- else
- {
- aBtnAdd.Disable();
- aBtnColHead.Disable();
- aBtnRowHead.Disable();
- aEdAssign2.Disable();
- aRbAssign2.Disable();
- }
- aBtnRemove.Disable();
- return 0;
-}
-
-
-/*************************************************************************
-#* Handler: Range2DataModifyHdl Datum:04.09.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScColRowNameRangesDlg
-#*
-#* Funktion: Wird ausgeloest, wenn in der Tabelle, der Daten-
-#* Bereich geaendert wurde
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-IMPL_LINK( ScColRowNameRangesDlg, Range2DataModifyHdl, void *, EMPTYARG )
-{
- String aNewData( aEdAssign2.GetText() );
- if ( aNewData.Len() > 0 )
- {
- ScRange aRange;
- if ( (aRange.ParseAny( aNewData, pDoc, pDoc->GetAddressConvention() ) & SCA_VALID) == SCA_VALID )
- {
- AdjustColRowData( aRange );
- aBtnAdd.Enable();
- }
- else
- aBtnAdd.Disable();
- }
- else
- {
- aBtnAdd.Disable();
- }
- return 0;
-}
-
-
-/*************************************************************************
-#* Handler: ColClickHdl Datum:04.09.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScColRowNameRangesDlg
-#*
-#* Funktion: Radiobutton fuer Spalten wurde betaetigt,
-#* die entsprechenden Einstellungen werden
-#* vorgenommen
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-IMPL_LINK( ScColRowNameRangesDlg, ColClickHdl, void *, EMPTYARG )
-{
- if ( !aBtnColHead.GetSavedValue() )
- {
- aBtnColHead.Check( TRUE );
- aBtnRowHead.Check( FALSE );
- if ( theCurArea.aStart.Row() == 0 && theCurArea.aEnd.Row() == MAXROW )
- {
- theCurArea.aEnd.SetRow( MAXROW - 1 );
- String aStr;
- theCurArea.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
- aEdAssign.SetText( aStr );
- }
- ScRange aRange( theCurData );
- aRange.aStart.SetRow( Min( (long)(theCurArea.aEnd.Row() + 1), (long)MAXROW ) );
- aRange.aEnd.SetRow( MAXROW );
- AdjustColRowData( aRange );
- }
- return 0;
-}
-
-
-/*************************************************************************
-#* Handler: RowClickHdl Datum:04.09.97
-#*------------------------------------------------------------------------
-#*
-#* Klasse: ScColRowNameRangesDlg
-#*
-#* Funktion: Radiobutton fuer Zeilen wurde betaetigt,
-#* die entsprechenden Einstellungen werden
-#* vorgenommen
-#*
-#* Input: ---
-#*
-#* Output: ---
-#*
-#************************************************************************/
-
-IMPL_LINK( ScColRowNameRangesDlg, RowClickHdl, void *, EMPTYARG )
-{
- if ( !aBtnRowHead.GetSavedValue() )
- {
- aBtnRowHead.Check( TRUE );
- aBtnColHead.Check( FALSE );
- if ( theCurArea.aStart.Col() == 0 && theCurArea.aEnd.Col() == MAXCOL )
- {
- theCurArea.aEnd.SetCol( MAXCOL - 1 );
- String aStr;
- theCurArea.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
- aEdAssign.SetText( aStr );
- }
- ScRange aRange( theCurData );
- aRange.aStart.SetCol( static_cast<SCCOL>(Min( (long)(theCurArea.aEnd.Col() + 1), (long)MAXCOL )) );
- aRange.aEnd.SetCol( MAXCOL );
- AdjustColRowData( aRange );
- }
- return 0;
-}
-
-
-IMPL_LINK( ScColRowNameRangesDlg, GetFocusHdl, Control*, pCtrl )
-{
- if( (pCtrl == (Control*)&aEdAssign) || (pCtrl == (Control*)&aRbAssign) )
- pEdActive = &aEdAssign;
- else if( (pCtrl == (Control*)&aEdAssign2) || (pCtrl == (Control*)&aRbAssign2) )
- pEdActive = &aEdAssign2;
- else
- pEdActive = NULL;
-
- if( pEdActive )
- pEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
-
- return 0;
-}
-
-
-IMPL_LINK( ScColRowNameRangesDlg, LoseFocusHdl, Control*, EMPTYARG )
-{
- bDlgLostFocus = !IsActive();
- return 0;
-}
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: crnrdlg.cxx,v $
+ * $Revision: 1.11 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+// INCLUDE -------------------------------------------------------------------
+
+#include "reffact.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "globstr.hrc"
+#include "crnrdlg.hrc"
+#include "docsh.hxx"
+
+#define _CRNRDLG_CXX
+#include "crnrdlg.hxx"
+#undef _CRNRDLG_CXX
+#include <vcl/msgbox.hxx>
+
+
+//============================================================================
+
+#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute()
+#define QUERYBOX(m) QueryBox(this,WinBits(WB_YES_NO|WB_DEF_YES),m).Execute()
+
+const ULONG nEntryDataCol = 0;
+const ULONG nEntryDataRow = 1;
+const ULONG nEntryDataDelim = 2;
+
+
+//============================================================================
+// class ScColRowNameRangesDlg
+
+
+/*************************************************************************
+#* Member: ScColRowNameRangesDlg Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Konstruktor der Klasse ScColRowNameRangesDlg.
+#* Initialisieren der Klassen- Mitglieder,
+#* Uebernahme der Range- Angaben und Aufruf
+#* der eigentlichen Initialisierungsroutine
+#*
+#* Input: Sfx- Verknuepfungen
+#* Parent- Window
+#* SCViewData
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+ScColRowNameRangesDlg::ScColRowNameRangesDlg( SfxBindings* pB,
+ SfxChildWindow* pCW,
+ Window* pParent,
+ ScViewData* ptrViewData )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_COLROWNAMERANGES ),
+ //
+ aFlAssign ( this, ScResId( FL_ASSIGN ) ),
+ aLbRange ( this, ScResId( LB_RANGE ) ),
+
+ aEdAssign ( this, ScResId( ED_AREA ) ),
+ aRbAssign ( this, ScResId( RB_AREA ), &aEdAssign, this ),
+ aBtnColHead ( this, ScResId( BTN_COLHEAD ) ),
+ aBtnRowHead ( this, ScResId( BTN_ROWHEAD ) ),
+ aFtAssign2 ( this, ScResId( FT_DATA_LABEL ) ),
+ aEdAssign2 ( this, ScResId( ED_DATA ) ),
+ aRbAssign2 ( this, ScResId( RB_DATA ), &aEdAssign2, this ),
+
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnAdd ( this, ScResId( BTN_ADD ) ),
+ aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
+
+ pViewData ( ptrViewData ),
+ pDoc ( ptrViewData->GetDocument() ),
+
+ pEdActive ( NULL ),
+ bDlgLostFocus ( FALSE )
+{
+ xColNameRanges = pDoc->GetColNameRanges()->Clone();
+ xRowNameRanges = pDoc->GetRowNameRanges()->Clone();
+ Init();
+ FreeResource();
+}
+
+
+/*************************************************************************
+#* Member: ~ScColRowNameRangesDlg Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Destruktor der Klasse
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+__EXPORT ScColRowNameRangesDlg::~ScColRowNameRangesDlg()
+{
+}
+
+
+/*************************************************************************
+#* Member: Init Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Initialisierungs- Routine:
+#* Umlenken der Event- Handler und einstellen der
+#* Startparameter.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::Init()
+{
+ SCCOL nStartCol = 0;
+ SCROW nStartRow = 0;
+ SCTAB nStartTab = 0;
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = 0;
+ SCTAB nEndTab = 0;
+
+ aBtnOk.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, OkBtnHdl ) );
+ aBtnCancel.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, CancelBtnHdl ) );
+ aBtnAdd.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, AddBtnHdl ) );
+ aBtnRemove.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, RemoveBtnHdl ) );
+ aLbRange.SetSelectHdl ( LINK( this, ScColRowNameRangesDlg, Range1SelectHdl ) );
+ aEdAssign.SetModifyHdl ( LINK( this, ScColRowNameRangesDlg, Range1DataModifyHdl ) );
+ aBtnColHead.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, ColClickHdl ) );
+ aBtnRowHead.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, RowClickHdl ) );
+ aEdAssign2.SetModifyHdl ( LINK( this, ScColRowNameRangesDlg, Range2DataModifyHdl ) );
+
+ Link aLink = LINK( this, ScColRowNameRangesDlg, GetFocusHdl );
+ aEdAssign.SetGetFocusHdl( aLink );
+ aRbAssign.SetGetFocusHdl( aLink );
+ aEdAssign2.SetGetFocusHdl( aLink );
+ aRbAssign2.SetGetFocusHdl( aLink );
+
+ aLink = LINK( this, ScColRowNameRangesDlg, LoseFocusHdl );
+ aEdAssign.SetLoseFocusHdl( aLink );
+ aRbAssign.SetLoseFocusHdl( aLink );
+ aEdAssign2.SetLoseFocusHdl( aLink );
+ aRbAssign2.SetLoseFocusHdl( aLink );
+
+ pEdActive = &aEdAssign;
+
+ UpdateNames();
+
+ if ( pViewData && pDoc )
+ {
+ pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab );
+ SetColRowData( ScRange( ScAddress( nStartCol, nStartRow, nStartTab ),
+ ScAddress( nEndCol, nEndRow, nEndTab ) ) );
+ }
+ else
+ {
+ aBtnColHead.Check( TRUE );
+ aBtnRowHead.Check( FALSE );
+ aEdAssign.SetText( EMPTY_STRING );
+ aEdAssign2.SetText( EMPTY_STRING );
+ }
+
+ aLbRange.SetBorderStyle( WINDOW_BORDER_MONO );
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aEdAssign.Enable();
+ aEdAssign.GrabFocus();
+ aRbAssign.Enable();
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable(); // Ref-Feld hat Focus
+
+ Range1SelectHdl( 0 );
+}
+
+
+/*************************************************************************
+#* Member: SetColRowData Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: zugehoerigen Datenbereich eines Beschriftungsbereiches
+#* auf default Werte setzen und beide Referenz-Edit-Felder
+#* fuellen.
+#*
+#* Input: Einstellbereich fuer Labels
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::SetColRowData( const ScRange& rLabelRange,BOOL bRef)
+{
+ theCurData = theCurArea = rLabelRange;
+ BOOL bValid = TRUE;
+ SCCOL nCol1 = theCurArea.aStart.Col();
+ SCCOL nCol2 = theCurArea.aEnd.Col();
+ SCROW nRow1 = theCurArea.aStart.Row();
+ SCROW nRow2 = theCurArea.aEnd.Row();
+ if ( (static_cast<SCCOLROW>(nCol2 - nCol1) >= nRow2 - nRow1) || (nCol1 == 0 && nCol2 == MAXCOL) )
+ { // Spaltenkoepfe und Grenzfall gesamte Tabelle
+ aBtnColHead.Check( TRUE );
+ aBtnRowHead.Check( FALSE );
+ if ( nRow2 == MAXROW )
+ {
+ if ( nRow1 == 0 )
+ bValid = FALSE; // Grenzfall gesamte Tabelle
+ else
+ { // Head unten, Data oben
+ theCurData.aStart.SetRow( 0 );
+ theCurData.aEnd.SetRow( nRow1 - 1 );
+ }
+ }
+ else
+ { // Head oben, Data unten
+ theCurData.aStart.SetRow( nRow2 + 1 );
+ theCurData.aEnd.SetRow( MAXROW );
+ }
+ }
+ else
+ { // Zeilenkoepfe
+ aBtnRowHead.Check( TRUE );
+ aBtnColHead.Check( FALSE );
+ if ( nCol2 == MAXCOL )
+ { // Head rechts, Data links
+ theCurData.aStart.SetCol( 0 );
+ theCurData.aEnd.SetCol( nCol2 - 1 );
+ }
+ else
+ { // Head links, Data rechts
+ theCurData.aStart.SetCol( nCol2 + 1 );
+ theCurData.aEnd.SetCol( MAXCOL );
+ }
+ }
+ if ( bValid )
+ {
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ String aStr;
+ theCurArea.Format( aStr, SCR_ABS_3D, pDoc, eConv );
+
+ if(bRef)
+ aEdAssign.SetRefString( aStr );
+ else
+ aEdAssign.SetText( aStr );
+
+ aEdAssign.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) );
+ theCurData.Format( aStr, SCR_ABS_3D, pDoc, eConv );
+
+ if(bRef)
+ aEdAssign2.SetRefString( aStr );
+ else
+ aEdAssign2.SetText( aStr );
+ }
+ else
+ {
+ theCurData = theCurArea = ScRange();
+
+ if(bRef)
+ {
+ aEdAssign.SetRefString( EMPTY_STRING );
+ aEdAssign2.SetRefString( EMPTY_STRING );
+ }
+ else
+ {
+ aEdAssign.SetText( EMPTY_STRING );
+ aEdAssign2.SetText( EMPTY_STRING );
+ }
+
+ aBtnColHead.Disable();
+ aBtnRowHead.Disable();
+ aEdAssign2.Disable();
+ aRbAssign2.Disable();
+ }
+}
+
+
+/*************************************************************************
+#* Member: AdjustColRowData Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: zugehoerigen Datenbereich eines Beschriftungsbereiches
+#* anpassen und Data-Referenz-Edit-Feld fuellen.
+#*
+#* Input: Bereich fuer Labels
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::AdjustColRowData( const ScRange& rDataRange,BOOL bRef)
+{
+ theCurData = rDataRange;
+ if ( aBtnColHead.IsChecked() )
+ { // Datenbereich gleiche Spalten wie Koepfe
+ theCurData.aStart.SetCol( theCurArea.aStart.Col() );
+ theCurData.aEnd.SetCol( theCurArea.aEnd.Col() );
+ if ( theCurData.Intersects( theCurArea ) )
+ {
+ SCROW nRow1 = theCurArea.aStart.Row();
+ SCROW nRow2 = theCurArea.aEnd.Row();
+ if ( nRow1 > 0
+ && (theCurData.aEnd.Row() < nRow2 || nRow2 == MAXROW) )
+ { // Data oben
+ theCurData.aEnd.SetRow( nRow1 - 1 );
+ if ( theCurData.aStart.Row() > theCurData.aEnd.Row() )
+ theCurData.aStart.SetRow( theCurData.aEnd.Row() );
+ }
+ else
+ { // Data unten
+ theCurData.aStart.SetRow( nRow2 + 1 );
+ if ( theCurData.aStart.Row() > theCurData.aEnd.Row() )
+ theCurData.aEnd.SetRow( theCurData.aStart.Row() );
+ }
+ }
+ }
+ else
+ { // Datenbereich gleiche Zeilen wie Koepfe
+ theCurData.aStart.SetRow( theCurArea.aStart.Row() );
+ theCurData.aEnd.SetRow( theCurArea.aEnd.Row() );
+ if ( theCurData.Intersects( theCurArea ) )
+ {
+ SCCOL nCol1 = theCurArea.aStart.Col();
+ SCCOL nCol2 = theCurArea.aEnd.Col();
+ if ( nCol1 > 0
+ && (theCurData.aEnd.Col() < nCol2 || nCol2 == MAXCOL) )
+ { // Data links
+ theCurData.aEnd.SetCol( nCol1 - 1 );
+ if ( theCurData.aStart.Col() > theCurData.aEnd.Col() )
+ theCurData.aStart.SetCol( theCurData.aEnd.Col() );
+ }
+ else
+ { // Data rechts
+ theCurData.aStart.SetCol( nCol2 + 1 );
+ if ( theCurData.aStart.Col() > theCurData.aEnd.Col() )
+ theCurData.aEnd.SetCol( theCurData.aStart.Col() );
+ }
+ }
+ }
+ String aStr;
+ theCurData.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+
+ if(bRef)
+ aEdAssign2.SetRefString( aStr );
+ else
+ aEdAssign2.SetText( aStr );
+
+ aEdAssign2.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) );
+}
+
+
+/*************************************************************************
+#* Member: SetReference Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Uebergabe eines mit der Maus selektierten Tabellen-
+#* bereiches, der dann als neue Selektion im Referenz-
+#* Fenster angezeigt wird.
+#*
+#* Input: Bereich fuer Labels
+#* Dokumentklasse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::SetReference( const ScRange& rRef, ScDocument* /* pDoc */ )
+{
+ if ( pEdActive )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart( pEdActive );
+
+ String aRefStr;
+ if ( pEdActive == &aEdAssign )
+ SetColRowData( rRef, TRUE );
+ else
+ AdjustColRowData( rRef, TRUE );
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aBtnAdd.Enable();
+ aBtnRemove.Disable();
+ }
+}
+
+
+/*************************************************************************
+#* Member: Close Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Schliessen des Fensters
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+BOOL __EXPORT ScColRowNameRangesDlg::Close()
+{
+ return DoClose( ScColRowNameRangesDlgWrapper::GetChildWindowId() );
+}
+
+
+/*************************************************************************
+#* Member: SetActive Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Aktivieren des Fensters
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::SetActive()
+{
+ if ( bDlgLostFocus )
+ {
+ bDlgLostFocus = FALSE;
+ if( pEdActive )
+ pEdActive->GrabFocus();
+ }
+ else
+ GrabFocus();
+
+ if( pEdActive == &aEdAssign )
+ Range1DataModifyHdl( 0 );
+ else if( pEdActive == &aEdAssign2 )
+ Range2DataModifyHdl( 0 );
+
+ RefInputDone();
+}
+
+
+/*************************************************************************
+#* Member: UpdateNames Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Aktualisieren der Namen
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::UpdateNames()
+{
+ aLbRange.SetUpdateMode( FALSE );
+ //-----------------------------------------------------------
+ aLbRange.Clear();
+ aRangeMap.clear();
+ aEdAssign.SetText( EMPTY_STRING );
+
+ ULONG nCount, j;
+ USHORT nPos; //@008 Hilfsvariable q eingefuegt
+
+ SCCOL nCol1; //@008 04.09.97
+ SCROW nRow1; //Erweiterung fuer Bereichsnamen
+ SCTAB nTab1;
+ SCCOL nCol2;
+ SCROW nRow2;
+ SCTAB nTab2;
+ String rString;
+ String strShow;
+ const ScAddress::Details aDetails(pDoc->GetAddressConvention());
+
+ String aString;
+ String strDelim = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( " --- " ));
+ aString = strDelim;
+ aString += ScGlobal::GetRscString( STR_COLUMN );
+ aString += strDelim;
+ nPos = aLbRange.InsertEntry( aString );
+ aLbRange.SetEntryData( nPos, (void*)nEntryDataDelim );
+ if ( (nCount = xColNameRanges->Count()) > 0 )
+ {
+ ScRangePair** ppSortArray = xColNameRanges->CreateNameSortedArray(
+ nCount, pDoc );
+ for ( j=0; j < nCount; j++ )
+ {
+ const ScRange aRange(ppSortArray[j]->GetRange(0));
+ aRange.Format( aString, SCR_ABS_3D, pDoc, aDetails );
+
+ //@008 Hole Bereichsparameter aus Dok
+ ppSortArray[j]->GetRange(0).GetVars( nCol1, nRow1, nTab1,
+ nCol2, nRow2, nTab2 );
+ SCCOL q=nCol1+3;
+ if(q>nCol2) q=nCol2;
+ //@008 Baue String zusammen
+ strShow.AssignAscii(RTL_CONSTASCII_STRINGPARAM(" ["));
+ if(pDoc!=NULL)
+ {
+ pDoc->GetString(nCol1, nRow1, nTab1,rString);
+ strShow +=rString;
+ for(SCCOL i=nCol1+1;i<=q;i++)
+ {
+ strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ pDoc->GetString(i, nRow1, nTab1,rString);
+ strShow += rString;
+ }
+ }
+ if(q<nCol2) // Zu lang? Ergaenzen um ",..."
+ {
+ strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", ..."));
+ }
+ strShow += ']';
+
+ //@008 String einfuegen in Listbox
+ String aInsStr = aString;
+ aInsStr += strShow;
+ nPos = aLbRange.InsertEntry( aInsStr );
+ aRangeMap.insert( NameRangeMap::value_type(aInsStr, aRange) );
+ aLbRange.SetEntryData( nPos, (void*)nEntryDataCol );
+ }
+ delete [] ppSortArray;
+ }
+ aString = strDelim;
+ aString += ScGlobal::GetRscString( STR_ROW );
+ aString += strDelim;
+ nPos = aLbRange.InsertEntry( aString );
+ aLbRange.SetEntryData( nPos, (void*)nEntryDataDelim );
+ if ( (nCount = xRowNameRanges->Count()) > 0 )
+ {
+ ScRangePair** ppSortArray = xRowNameRanges->CreateNameSortedArray(
+ nCount, pDoc );
+ for ( j=0; j < nCount; j++ )
+ {
+ const ScRange aRange(ppSortArray[j]->GetRange(0));
+ aRange.Format( aString, SCR_ABS_3D, pDoc, aDetails );
+
+ //@008 Ab hier baue String fuer Zeilen
+ ppSortArray[j]->GetRange(0).GetVars( nCol1, nRow1, nTab1,
+ nCol2, nRow2, nTab2 );
+ SCROW q=nRow1+3;
+ if(q>nRow2) q=nRow2;
+ strShow.AssignAscii(RTL_CONSTASCII_STRINGPARAM(" ["));
+ if(pDoc!=NULL)
+ {
+ pDoc->GetString(nCol1, nRow1, nTab1,rString);
+ strShow += rString;
+ for(SCROW i=nRow1+1;i<=q;i++)
+ {
+ strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ pDoc->GetString(nCol1, i, nTab1,rString);
+ strShow += rString;
+ }
+ }
+ if(q<nRow2)
+ {
+ strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", ..."));
+ }
+ strShow += ']';
+
+ String aInsStr = aString;
+ aInsStr += strShow;
+ nPos = aLbRange.InsertEntry( aInsStr );
+ aRangeMap.insert( NameRangeMap::value_type(aInsStr, aRange) );
+ aLbRange.SetEntryData( nPos, (void*)nEntryDataRow );
+ }
+ delete [] ppSortArray;
+ }
+ //-----------------------------------------------------------
+ aLbRange.SetUpdateMode( TRUE );
+ aLbRange.Invalidate();
+}
+
+
+/*************************************************************************
+#* Member: UpdateRangeData Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Aktualisieren der Bereichsdaten
+#*
+#* Input: Bereichs-String
+#* Flag fuer Spalten
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::UpdateRangeData( const ScRange& rRange, BOOL bColName )
+{
+ ScRangePair* pPair = NULL;
+ BOOL bFound = FALSE;
+ if ( bColName && (pPair = xColNameRanges->Find( rRange )) != NULL )
+ bFound = TRUE;
+ else if ( !bColName && (pPair = xRowNameRanges->Find( rRange )) != NULL )
+ bFound = TRUE;
+
+ if ( bFound )
+ {
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ String aStr;
+ theCurArea = rRange;
+ theCurArea.Format( aStr, SCR_ABS_3D, pDoc, eConv );
+ aEdAssign.SetText( aStr );
+ aBtnAdd.Disable();
+ aBtnRemove.Enable();
+ aBtnColHead.Check( bColName );
+ aBtnRowHead.Check( !bColName );
+ theCurData = pPair->GetRange(1);
+ theCurData.Format( aStr, SCR_ABS_3D, pDoc, eConv );
+ aEdAssign2.SetText( aStr );
+ }
+ else
+ {
+ aBtnAdd.Enable();
+ aBtnRemove.Disable();
+ }
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aEdAssign2.Enable();
+ aRbAssign2.Enable();
+}
+
+
+/*************************************************************************
+#* Member: IsRefInputMode Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Abfragefunktion fuer Referenz- Input- Mode.
+#*
+#* Input: Bereichs-String
+#* Flag fuer Spalten
+#*
+#* Output: true, wenn Referenz- Input- Mode
+#*
+#************************************************************************/
+
+BOOL ScColRowNameRangesDlg::IsRefInputMode() const
+{
+ return (pEdActive != NULL);
+}
+
+//------------------------------------------------------------------------
+// Handler:
+// ========
+
+/*************************************************************************
+#* Handler: OkBtnHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Wird ausgeloest, wenn der OK- Button gedrueckt wurde.
+#* Hinzufuegen- Button ausloesen, und die neu einge-
+#* stellten Bereiche ans Dokument uebergeben.
+#* Fensterschliessen- Anweisung ausloesen.
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, OkBtnHdl, void *, EMPTYARG )
+{
+ AddBtnHdl( 0 );
+
+ // die RangeLists den Refs am Doc zuweisen
+ pDoc->GetColNameRangesRef() = xColNameRanges;
+ pDoc->GetRowNameRangesRef() = xRowNameRanges;
+ // geaenderte Datenbereiche muessen sich auswirken
+ pDoc->CompileColRowNameFormula();
+ ScDocShell* pDocShell = pViewData->GetDocShell();
+ pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID );
+ pDocShell->SetDocumentModified();
+
+ Close();
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: CancelBtnHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Fensterschliessen- Anweisung ausloesen.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK_INLINE_START( ScColRowNameRangesDlg, CancelBtnHdl, void *, EMPTYARG )
+{
+ Close();
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScColRowNameRangesDlg, CancelBtnHdl, void *, EMPTYARG )
+
+
+/*************************************************************************
+#* Handler: AddBtnHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Nach betaetigen des Hinzufuegen- Buttons, werden
+#* die Bereichsangaben eingestellt und in der
+#* Listbox dargestellt.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, AddBtnHdl, void *, EMPTYARG )
+{
+ String aNewArea( aEdAssign.GetText() );
+ String aNewData( aEdAssign2.GetText() );
+
+ if ( aNewArea.Len() > 0 && aNewData.Len() > 0 )
+ {
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ ScRange aRange1, aRange2;
+ BOOL bOk1;
+ if ( (bOk1 = ((aRange1.ParseAny( aNewArea, pDoc, eConv ) & SCA_VALID) == SCA_VALID)) != FALSE
+ && ((aRange2.ParseAny( aNewData, pDoc, eConv ) & SCA_VALID) == SCA_VALID) )
+ {
+ theCurArea = aRange1;
+ AdjustColRowData( aRange2 );
+ ScRangePair* pPair;
+ if ( ( pPair = xColNameRanges->Find( theCurArea ) ) != NULL )
+ {
+ xColNameRanges->Remove( pPair );
+ delete pPair;
+ }
+ if ( ( pPair = xRowNameRanges->Find( theCurArea ) ) != NULL )
+ {
+ xRowNameRanges->Remove( pPair );
+ delete pPair;
+ }
+ if ( aBtnColHead.IsChecked() )
+ xColNameRanges->Join( ScRangePair( theCurArea, theCurData ) );
+ else
+ xRowNameRanges->Join( ScRangePair( theCurArea, theCurData ) );
+
+ UpdateNames();
+
+ aEdAssign.GrabFocus();
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ aEdAssign.SetText( EMPTY_STRING );
+ aBtnColHead.Check( TRUE );
+ aBtnRowHead.Check( FALSE );
+ aEdAssign2.SetText( EMPTY_STRING );
+ theCurArea = ScRange();
+ theCurData = theCurArea;
+ Range1SelectHdl( 0 );
+ }
+ else
+ {
+ ERRORBOX( ScGlobal::GetRscString(STR_INVALIDTABNAME) );
+ if ( !bOk1 )
+ aEdAssign.GrabFocus();
+ else
+ aEdAssign2.GrabFocus();
+ }
+ }
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: RemoveBtnHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Nach betaetigen des Loeschen- Buttons, wird
+#* die markierte Bereichsangabe geloescht.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, RemoveBtnHdl, void *, EMPTYARG )
+{
+ String aRangeStr = aLbRange.GetSelectEntry();
+ USHORT nSelectPos = aLbRange.GetSelectEntryPos();
+ BOOL bColName =
+ ((ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataCol);
+ NameRangeMap::const_iterator itr = aRangeMap.find(aRangeStr);
+ if (itr == aRangeMap.end())
+ return 0;
+ const ScRange& rRange = itr->second;
+
+ ScRangePair* pPair = NULL;
+ BOOL bFound = FALSE;
+ if ( bColName && (pPair = xColNameRanges->Find( rRange )) != NULL )
+ bFound = TRUE;
+ else if ( !bColName && (pPair = xRowNameRanges->Find( rRange )) != NULL )
+ bFound = TRUE;
+ if ( bFound )
+ {
+ String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY );
+ String aMsg = aStrDelMsg.GetToken( 0, '#' );
+
+ aMsg += aRangeStr;
+ aMsg += aStrDelMsg.GetToken( 1, '#' );
+
+ if ( RET_YES == QUERYBOX(aMsg) )
+ {
+ if ( bColName )
+ xColNameRanges->Remove( pPair );
+ else
+ xRowNameRanges->Remove( pPair );
+ delete pPair;
+
+ UpdateNames();
+ USHORT nCnt = aLbRange.GetEntryCount();
+ if ( nSelectPos >= nCnt )
+ {
+ if ( nCnt )
+ nSelectPos = nCnt - 1;
+ else
+ nSelectPos = 0;
+ }
+ aLbRange.SelectEntryPos( nSelectPos );
+ if ( nSelectPos &&
+ (ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataDelim )
+ aLbRange.SelectEntryPos( --nSelectPos ); // ---Zeile---
+
+ aLbRange.GrabFocus();
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ aEdAssign.SetText( EMPTY_STRING );
+ theCurArea = theCurData = ScRange();
+ aBtnColHead.Check( TRUE );
+ aBtnRowHead.Check( FALSE );
+ aEdAssign2.SetText( EMPTY_STRING );
+ Range1SelectHdl( 0 );
+ }
+ }
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: Range1SelectHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Wenn Zeile in Listbox ausgewaehlt wird,
+#* werden die Eingabefelder entsprechend
+#* eingestellt.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, Range1SelectHdl, void *, EMPTYARG )
+{
+ USHORT nSelectPos = aLbRange.GetSelectEntryPos();
+ USHORT nCnt = aLbRange.GetEntryCount();
+ USHORT nMoves = 0;
+ while ( nSelectPos < nCnt
+ && (ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataDelim )
+ { // skip Delimiter
+ ++nMoves;
+ aLbRange.SelectEntryPos( ++nSelectPos );
+ }
+ String aRangeStr = aLbRange.GetSelectEntry();
+ if ( nMoves )
+ {
+ if ( nSelectPos > 1 && nSelectPos >= nCnt )
+ { // am Ende nicht auf dem " --- Zeile --- " Delimiter stehenbleiben
+ // wenn davor Eintraege existieren
+ nSelectPos = nCnt - 2;
+ aLbRange.SelectEntryPos( nSelectPos );
+ aRangeStr = aLbRange.GetSelectEntry();
+ }
+ else if ( nSelectPos > 2 && nSelectPos < nCnt && aRangeStr.Len()
+ && aRangeStr == aEdAssign.GetText() )
+ { // nach oben wandern statt nach unten auf die vorherige Position
+ nSelectPos -= 2;
+ aLbRange.SelectEntryPos( nSelectPos );
+ aRangeStr = aLbRange.GetSelectEntry();
+ }
+ }
+ NameRangeMap::const_iterator itr = aRangeMap.find(aRangeStr);
+ if ( itr != aRangeMap.end() )
+ {
+ BOOL bColName =
+ ((ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataCol);
+ UpdateRangeData( itr->second, bColName );
+ aBtnAdd.Disable();
+ aBtnRemove.Enable();
+ }
+ else
+ {
+ if ( aEdAssign.GetText().Len() > 0 )
+ {
+ if ( aEdAssign2.GetText().Len() > 0 )
+ aBtnAdd.Enable();
+ else
+ aBtnAdd.Disable();
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aEdAssign2.Enable();
+ aRbAssign2.Enable();
+ }
+ else
+ {
+ aBtnAdd.Disable();
+ aBtnColHead.Disable();
+ aBtnRowHead.Disable();
+ aEdAssign2.Disable();
+ aRbAssign2.Disable();
+ }
+ aBtnRemove.Disable();
+ aEdAssign.GrabFocus();
+ }
+
+ aEdAssign.Enable();
+ aRbAssign.Enable();
+
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable();
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: Range1DataModifyHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Wird ausgeloest, wenn in der Tabelle, der Label-
+#* Bereich geaendert wurde.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, Range1DataModifyHdl, void *, EMPTYARG )
+{
+ String aNewArea( aEdAssign.GetText() );
+ BOOL bValid = FALSE;
+ if ( aNewArea.Len() > 0 )
+ {
+ ScRange aRange;
+ if ( (aRange.ParseAny( aNewArea, pDoc, pDoc->GetAddressConvention() ) & SCA_VALID) == SCA_VALID )
+ {
+ SetColRowData( aRange );
+ bValid = TRUE;
+ }
+ }
+ if ( bValid )
+ {
+ aBtnAdd.Enable();
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aEdAssign2.Enable();
+ aRbAssign2.Enable();
+ }
+ else
+ {
+ aBtnAdd.Disable();
+ aBtnColHead.Disable();
+ aBtnRowHead.Disable();
+ aEdAssign2.Disable();
+ aRbAssign2.Disable();
+ }
+ aBtnRemove.Disable();
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: Range2DataModifyHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Wird ausgeloest, wenn in der Tabelle, der Daten-
+#* Bereich geaendert wurde
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, Range2DataModifyHdl, void *, EMPTYARG )
+{
+ String aNewData( aEdAssign2.GetText() );
+ if ( aNewData.Len() > 0 )
+ {
+ ScRange aRange;
+ if ( (aRange.ParseAny( aNewData, pDoc, pDoc->GetAddressConvention() ) & SCA_VALID) == SCA_VALID )
+ {
+ AdjustColRowData( aRange );
+ aBtnAdd.Enable();
+ }
+ else
+ aBtnAdd.Disable();
+ }
+ else
+ {
+ aBtnAdd.Disable();
+ }
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: ColClickHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Radiobutton fuer Spalten wurde betaetigt,
+#* die entsprechenden Einstellungen werden
+#* vorgenommen
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, ColClickHdl, void *, EMPTYARG )
+{
+ if ( !aBtnColHead.GetSavedValue() )
+ {
+ aBtnColHead.Check( TRUE );
+ aBtnRowHead.Check( FALSE );
+ if ( theCurArea.aStart.Row() == 0 && theCurArea.aEnd.Row() == MAXROW )
+ {
+ theCurArea.aEnd.SetRow( MAXROW - 1 );
+ String aStr;
+ theCurArea.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+ aEdAssign.SetText( aStr );
+ }
+ ScRange aRange( theCurData );
+ aRange.aStart.SetRow( Min( (long)(theCurArea.aEnd.Row() + 1), (long)MAXROW ) );
+ aRange.aEnd.SetRow( MAXROW );
+ AdjustColRowData( aRange );
+ }
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: RowClickHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Radiobutton fuer Zeilen wurde betaetigt,
+#* die entsprechenden Einstellungen werden
+#* vorgenommen
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, RowClickHdl, void *, EMPTYARG )
+{
+ if ( !aBtnRowHead.GetSavedValue() )
+ {
+ aBtnRowHead.Check( TRUE );
+ aBtnColHead.Check( FALSE );
+ if ( theCurArea.aStart.Col() == 0 && theCurArea.aEnd.Col() == MAXCOL )
+ {
+ theCurArea.aEnd.SetCol( MAXCOL - 1 );
+ String aStr;
+ theCurArea.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+ aEdAssign.SetText( aStr );
+ }
+ ScRange aRange( theCurData );
+ aRange.aStart.SetCol( static_cast<SCCOL>(Min( (long)(theCurArea.aEnd.Col() + 1), (long)MAXCOL )) );
+ aRange.aEnd.SetCol( MAXCOL );
+ AdjustColRowData( aRange );
+ }
+ return 0;
+}
+
+
+IMPL_LINK( ScColRowNameRangesDlg, GetFocusHdl, Control*, pCtrl )
+{
+ if( (pCtrl == (Control*)&aEdAssign) || (pCtrl == (Control*)&aRbAssign) )
+ pEdActive = &aEdAssign;
+ else if( (pCtrl == (Control*)&aEdAssign2) || (pCtrl == (Control*)&aRbAssign2) )
+ pEdActive = &aEdAssign2;
+ else
+ pEdActive = NULL;
+
+ if( pEdActive )
+ pEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+
+ return 0;
+}
+
+
+IMPL_LINK( ScColRowNameRangesDlg, LoseFocusHdl, Control*, EMPTYARG )
+{
+ bDlgLostFocus = !IsActive();
+ return 0;
+}
diff --git a/sc/source/ui/miscdlgs/optsolver.cxx b/sc/source/ui/miscdlgs/optsolver.cxx
index e7e902caecd6..6fa5ba1d7098 100644
--- a/sc/source/ui/miscdlgs/optsolver.cxx
+++ b/sc/source/ui/miscdlgs/optsolver.cxx
@@ -1,1069 +1,1069 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: optsolver.cxx,v $
- * $Revision: 1.5 $
- *
- * 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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sc.hxx"
-
-//----------------------------------------------------------------------------
-
-#include "rangelst.hxx"
-#include "scitems.hxx"
-#include <sfx2/bindings.hxx>
-#include <sfx2/imagemgr.hxx>
-#include <svtools/zforlist.hxx>
-#include <vcl/msgbox.hxx>
-#include <vcl/svapp.hxx>
-
-#include "uiitems.hxx"
-#include "reffact.hxx"
-#include "docsh.hxx"
-#include "docfunc.hxx"
-#include "cell.hxx"
-#include "rangeutl.hxx"
-#include "scresid.hxx"
-#include "convuno.hxx"
-#include "unonames.hxx"
-#include "solveroptions.hxx"
-#include "solverutil.hxx"
-#include "optsolver.hrc"
-
-#include "optsolver.hxx"
-
-#include <com/sun/star/sheet/Solver.hpp>
-#include <com/sun/star/sheet/XSolverDescription.hpp>
-
-using namespace com::sun::star;
-
-//----------------------------------------------------------------------------
-
-ScSolverProgressDialog::ScSolverProgressDialog( Window* pParent )
- : ModelessDialog( pParent, ScResId( RID_SCDLG_SOLVER_PROGRESS ) ),
- maFtProgress ( this, ScResId( FT_PROGRESS ) ),
- maFtTime ( this, ScResId( FT_TIMELIMIT ) ),
- maFlButtons ( this, ScResId( FL_BUTTONS ) ),
- maBtnOk ( this, ScResId( BTN_OK ) )
-{
- maBtnOk.Enable(FALSE);
- FreeResource();
-}
-
-ScSolverProgressDialog::~ScSolverProgressDialog()
-{
-}
-
-void ScSolverProgressDialog::HideTimeLimit()
-{
- maFtTime.Hide();
-}
-
-void ScSolverProgressDialog::SetTimeLimit( sal_Int32 nSeconds )
-{
- String aOld = maFtTime.GetText();
- String aNew = aOld.GetToken(0,'#');
- aNew += String::CreateFromInt32( nSeconds );
- aNew += aOld.GetToken(1,'#');
- maFtTime.SetText( aNew );
-}
-
-//----------------------------------------------------------------------------
-
-ScSolverNoSolutionDialog::ScSolverNoSolutionDialog( Window* pParent, const String& rErrorText )
- : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVER_NOSOLUTION ) ),
- maFtNoSolution ( this, ScResId( FT_NOSOLUTION ) ),
- maFtErrorText ( this, ScResId( FT_ERRORTEXT ) ),
- maFlButtons ( this, ScResId( FL_BUTTONS ) ),
- maBtnOk ( this, ScResId( BTN_OK ) )
-{
- maFtErrorText.SetText( rErrorText );
- FreeResource();
-}
-
-ScSolverNoSolutionDialog::~ScSolverNoSolutionDialog()
-{
-}
-
-//----------------------------------------------------------------------------
-
-ScSolverSuccessDialog::ScSolverSuccessDialog( Window* pParent, const String& rSolution )
- : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVER_SUCCESS ) ),
- maFtSuccess ( this, ScResId( FT_SUCCESS ) ),
- maFtResult ( this, ScResId( FT_RESULT ) ),
- maFtQuestion ( this, ScResId( FT_QUESTION ) ),
- maFlButtons ( this, ScResId( FL_BUTTONS ) ),
- maBtnOk ( this, ScResId( BTN_OK ) ),
- maBtnCancel ( this, ScResId( BTN_CANCEL ) )
-{
- String aMessage = maFtResult.GetText();
- aMessage.Append( (sal_Char) ' ' );
- aMessage.Append( rSolution );
- maFtResult.SetText( aMessage );
- FreeResource();
-}
-
-ScSolverSuccessDialog::~ScSolverSuccessDialog()
-{
-}
-
-//----------------------------------------------------------------------------
-
-ScCursorRefEdit::ScCursorRefEdit( ScAnyRefDlg* pParent, const ResId& rResId ) :
- formula::RefEdit( pParent, rResId )
-{
-}
-
-void ScCursorRefEdit::SetCursorLinks( const Link& rUp, const Link& rDown )
-{
- maCursorUpLink = rUp;
- maCursorDownLink = rDown;
-}
-
-void ScCursorRefEdit::KeyInput( const KeyEvent& rKEvt )
-{
- KeyCode aCode = rKEvt.GetKeyCode();
- bool bUp = (aCode.GetCode() == KEY_UP);
- bool bDown = (aCode.GetCode() == KEY_DOWN);
- if ( !aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() && ( bUp || bDown ) )
- {
- if ( bUp )
- maCursorUpLink.Call( this );
- else
- maCursorDownLink.Call( this );
- }
- else
- formula::RefEdit::KeyInput( rKEvt );
-}
-
-//----------------------------------------------------------------------------
-
-ScOptSolverSave::ScOptSolverSave( const String& rObjective, BOOL bMax, BOOL bMin, BOOL bValue,
- const String& rTarget, const String& rVariable,
- const std::vector<ScOptConditionRow>& rConditions,
- const String& rEngine,
- const uno::Sequence<beans::PropertyValue>& rProperties ) :
- maObjective( rObjective ),
- mbMax( bMax ),
- mbMin( bMin ),
- mbValue( bValue ),
- maTarget( rTarget ),
- maVariable( rVariable ),
- maConditions( rConditions ),
- maEngine( rEngine ),
- maProperties( rProperties )
-{
-}
-
-//============================================================================
-// class ScOptSolverDlg
-//----------------------------------------------------------------------------
-
-ScOptSolverDlg::ScOptSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
- ScDocShell* pDocSh, ScAddress aCursorPos )
-
- : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_OPTSOLVER ),
- //
- maFtObjectiveCell ( this, ScResId( FT_OBJECTIVECELL ) ),
- maEdObjectiveCell ( this, ScResId( ED_OBJECTIVECELL ) ),
- maRBObjectiveCell ( this, ScResId( IB_OBJECTIVECELL ), &maEdObjectiveCell, this ),
- maFtDirection ( this, ScResId( FT_DIRECTION ) ),
- maRbMax ( this, ScResId( RB_MAX ) ),
- maRbMin ( this, ScResId( RB_MIN ) ),
- maRbValue ( this, ScResId( RB_VALUE ) ),
- maEdTargetValue ( this, ScResId( ED_TARGET ) ),
- maRBTargetValue ( this, ScResId( IB_TARGET ), &maEdTargetValue, this ),
- maFtVariableCells ( this, ScResId( FT_VARIABLECELLS ) ),
- maEdVariableCells ( this, ScResId( ED_VARIABLECELLS ) ),
- maRBVariableCells ( this, ScResId( IB_VARIABLECELLS ), &maEdVariableCells, this),
- maFlConditions ( this, ScResId( FL_CONDITIONS ) ),
- maFtCellRef ( this, ScResId( FT_CELLREF ) ),
- maEdLeft1 ( this, ScResId( ED_LEFT1 ) ),
- maRBLeft1 ( this, ScResId( IB_LEFT1 ), &maEdLeft1, this ),
- maFtOperator ( this, ScResId( FT_OPERATOR ) ),
- maLbOp1 ( this, ScResId( LB_OP1 ) ),
- maFtConstraint ( this, ScResId( FT_CONSTRAINT ) ),
- maEdRight1 ( this, ScResId( ED_RIGHT1 ) ),
- maRBRight1 ( this, ScResId( IB_RIGHT1 ), &maEdRight1, this ),
- maBtnDel1 ( this, ScResId( IB_DELETE1 ) ),
- maEdLeft2 ( this, ScResId( ED_LEFT2 ) ),
- maRBLeft2 ( this, ScResId( IB_LEFT2 ), &maEdLeft2, this ),
- maLbOp2 ( this, ScResId( LB_OP2 ) ),
- maEdRight2 ( this, ScResId( ED_RIGHT2 ) ),
- maRBRight2 ( this, ScResId( IB_RIGHT2 ), &maEdRight2, this ),
- maBtnDel2 ( this, ScResId( IB_DELETE2 ) ),
- maEdLeft3 ( this, ScResId( ED_LEFT3 ) ),
- maRBLeft3 ( this, ScResId( IB_LEFT3 ), &maEdLeft3, this ),
- maLbOp3 ( this, ScResId( LB_OP3 ) ),
- maEdRight3 ( this, ScResId( ED_RIGHT3 ) ),
- maRBRight3 ( this, ScResId( IB_RIGHT3 ), &maEdRight3, this ),
- maBtnDel3 ( this, ScResId( IB_DELETE3 ) ),
- maEdLeft4 ( this, ScResId( ED_LEFT4 ) ),
- maRBLeft4 ( this, ScResId( IB_LEFT4 ), &maEdLeft4, this ),
- maLbOp4 ( this, ScResId( LB_OP4 ) ),
- maEdRight4 ( this, ScResId( ED_RIGHT4 ) ),
- maRBRight4 ( this, ScResId( IB_RIGHT4 ), &maEdRight4, this ),
- maBtnDel4 ( this, ScResId( IB_DELETE4 ) ),
- maScrollBar ( this, ScResId( SB_SCROLL ) ),
- maFlButtons ( this, ScResId( FL_BUTTONS ) ),
- maBtnOpt ( this, ScResId( BTN_OPTIONS ) ),
- maBtnHelp ( this, ScResId( BTN_HELP ) ),
- maBtnCancel ( this, ScResId( BTN_CLOSE ) ),
- maBtnSolve ( this, ScResId( BTN_SOLVE ) ),
- maInputError ( ScResId( STR_INVALIDINPUT ) ),
- maConditionError ( ScResId( STR_INVALIDCONDITION ) ),
- //
- mpDocShell ( pDocSh ),
- mpDoc ( pDocSh->GetDocument() ),
- mnCurTab ( aCursorPos.Tab() ),
- mpEdActive ( NULL ),
- mbDlgLostFocus ( false ),
- nScrollPos ( 0 )
-{
- mpLeftEdit[0] = &maEdLeft1;
- mpLeftButton[0] = &maRBLeft1;
- mpRightEdit[0] = &maEdRight1;
- mpRightButton[0] = &maRBRight1;
- mpOperator[0] = &maLbOp1;
- mpDelButton[0] = &maBtnDel1;
-
- mpLeftEdit[1] = &maEdLeft2;
- mpLeftButton[1] = &maRBLeft2;
- mpRightEdit[1] = &maEdRight2;
- mpRightButton[1] = &maRBRight2;
- mpOperator[1] = &maLbOp2;
- mpDelButton[1] = &maBtnDel2;
-
- mpLeftEdit[2] = &maEdLeft3;
- mpLeftButton[2] = &maRBLeft3;
- mpRightEdit[2] = &maEdRight3;
- mpRightButton[2] = &maRBRight3;
- mpOperator[2] = &maLbOp3;
- mpDelButton[2] = &maBtnDel3;
-
- mpLeftEdit[3] = &maEdLeft4;
- mpLeftButton[3] = &maRBLeft4;
- mpRightEdit[3] = &maEdRight4;
- mpRightButton[3] = &maRBRight4;
- mpOperator[3] = &maLbOp4;
- mpDelButton[3] = &maBtnDel4;
-
- Init( aCursorPos );
- FreeResource();
-}
-
-//----------------------------------------------------------------------------
-
-ScOptSolverDlg::~ScOptSolverDlg()
-{
-}
-
-//----------------------------------------------------------------------------
-
-void ScOptSolverDlg::Init(const ScAddress& rCursorPos)
-{
- // Get the "Delete Rows" commandimagelist images from sfx instead of
- // adding a second copy to sc (see ScTbxInsertCtrl::StateChanged)
-
- rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
- aSlotURL += rtl::OUString::valueOf( sal_Int32( SID_DEL_ROWS ) );
- uno::Reference<frame::XFrame> xFrame = GetBindings().GetActiveFrame();
- Image aDelNm = ::GetImage( xFrame, aSlotURL, FALSE, FALSE );
- Image aDelHC = ::GetImage( xFrame, aSlotURL, FALSE, TRUE ); // high contrast
-
- for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
- {
- mpDelButton[nRow]->SetModeImage( aDelNm, BMP_COLOR_NORMAL );
- mpDelButton[nRow]->SetModeImage( aDelHC, BMP_COLOR_HIGHCONTRAST );
- }
-
- maBtnOpt.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) );
- maBtnCancel.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) );
- maBtnSolve.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) );
-
- Link aLink = LINK( this, ScOptSolverDlg, GetFocusHdl );
- maEdObjectiveCell.SetGetFocusHdl( aLink );
- maRBObjectiveCell.SetGetFocusHdl( aLink );
- maEdTargetValue.SetGetFocusHdl( aLink );
- maRBTargetValue.SetGetFocusHdl( aLink );
- maEdVariableCells.SetGetFocusHdl( aLink );
- maRBVariableCells.SetGetFocusHdl( aLink );
- maRbValue.SetGetFocusHdl( aLink );
- for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
- {
- mpLeftEdit[nRow]->SetGetFocusHdl( aLink );
- mpLeftButton[nRow]->SetGetFocusHdl( aLink );
- mpRightEdit[nRow]->SetGetFocusHdl( aLink );
- mpRightButton[nRow]->SetGetFocusHdl( aLink );
- mpOperator[nRow]->SetGetFocusHdl( aLink );
- }
-
- aLink = LINK( this, ScOptSolverDlg, LoseFocusHdl );
- maEdObjectiveCell.SetLoseFocusHdl( aLink );
- maRBObjectiveCell.SetLoseFocusHdl( aLink );
- maEdTargetValue. SetLoseFocusHdl( aLink );
- maRBTargetValue. SetLoseFocusHdl( aLink );
- maEdVariableCells.SetLoseFocusHdl( aLink );
- maRBVariableCells.SetLoseFocusHdl( aLink );
- for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
- {
- mpLeftEdit[nRow]->SetLoseFocusHdl( aLink );
- mpLeftButton[nRow]->SetLoseFocusHdl( aLink );
- mpRightEdit[nRow]->SetLoseFocusHdl( aLink );
- mpRightButton[nRow]->SetLoseFocusHdl( aLink );
- }
-
- Link aCursorUp = LINK( this, ScOptSolverDlg, CursorUpHdl );
- Link aCursorDown = LINK( this, ScOptSolverDlg, CursorDownHdl );
- Link aCondModify = LINK( this, ScOptSolverDlg, CondModifyHdl );
- for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
- {
- mpLeftEdit[nRow]->SetCursorLinks( aCursorUp, aCursorDown );
- mpRightEdit[nRow]->SetCursorLinks( aCursorUp, aCursorDown );
- mpLeftEdit[nRow]->SetModifyHdl( aCondModify );
- mpRightEdit[nRow]->SetModifyHdl( aCondModify );
- mpDelButton[nRow]->SetClickHdl( LINK( this, ScOptSolverDlg, DelBtnHdl ) );
- mpOperator[nRow]->SetSelectHdl( LINK( this, ScOptSolverDlg, SelectHdl ) );
- }
- maEdTargetValue.SetModifyHdl( LINK( this, ScOptSolverDlg, TargetModifyHdl ) );
-
- maScrollBar.SetEndScrollHdl( LINK( this, ScOptSolverDlg, ScrollHdl ) );
- maScrollBar.SetScrollHdl( LINK( this, ScOptSolverDlg, ScrollHdl ) );
-
- maScrollBar.SetPageSize( EDIT_ROW_COUNT );
- maScrollBar.SetVisibleSize( EDIT_ROW_COUNT );
- maScrollBar.SetLineSize( 1 );
- // Range is set in ShowConditions
-
- // get available solver implementations
- //! sort by descriptions?
- ScSolverUtil::GetImplementations( maImplNames, maDescriptions );
- sal_Int32 nImplCount = maImplNames.getLength();
-
- const ScOptSolverSave* pOldData = mpDocShell->GetSolverSaveData();
- if ( pOldData )
- {
- maEdObjectiveCell.SetRefString( pOldData->GetObjective() );
- maRbMax.Check( pOldData->GetMax() );
- maRbMin.Check( pOldData->GetMin() );
- maRbValue.Check( pOldData->GetValue() );
- maEdTargetValue.SetRefString( pOldData->GetTarget() );
- maEdVariableCells.SetRefString( pOldData->GetVariable() );
- maConditions = pOldData->GetConditions();
- maEngine = pOldData->GetEngine();
- maProperties = pOldData->GetProperties();
- }
- else
- {
- maRbMax.Check();
- String aCursorStr;
- if ( !mpDoc->GetRangeAtBlock( ScRange(rCursorPos), &aCursorStr ) )
- rCursorPos.Format( aCursorStr, SCA_ABS, NULL, mpDoc->GetAddressConvention() );
- maEdObjectiveCell.SetRefString( aCursorStr );
- if ( nImplCount > 0 )
- maEngine = maImplNames[0]; // use first implementation
- }
- ShowConditions();
-
- maEdObjectiveCell.GrabFocus();
- mpEdActive = &maEdObjectiveCell;
-}
-
-//----------------------------------------------------------------------------
-
-void ScOptSolverDlg::ReadConditions()
-{
- for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
- {
- ScOptConditionRow aRowEntry;
- aRowEntry.aLeftStr = mpLeftEdit[nRow]->GetText();
- aRowEntry.aRightStr = mpRightEdit[nRow]->GetText();
- aRowEntry.nOperator = mpOperator[nRow]->GetSelectEntryPos();
-
- long nVecPos = nScrollPos + nRow;
- if ( nVecPos >= (long)maConditions.size() && !aRowEntry.IsDefault() )
- maConditions.resize( nVecPos + 1 );
-
- if ( nVecPos < (long)maConditions.size() )
- maConditions[nVecPos] = aRowEntry;
-
- // remove default entries at the end
- size_t nSize = maConditions.size();
- while ( nSize > 0 && maConditions[ nSize-1 ].IsDefault() )
- --nSize;
- maConditions.resize( nSize );
- }
-}
-
-void ScOptSolverDlg::ShowConditions()
-{
- for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
- {
- ScOptConditionRow aRowEntry;
-
- long nVecPos = nScrollPos + nRow;
- if ( nVecPos < (long)maConditions.size() )
- aRowEntry = maConditions[nVecPos];
-
- mpLeftEdit[nRow]->SetRefString( aRowEntry.aLeftStr );
- mpRightEdit[nRow]->SetRefString( aRowEntry.aRightStr );
- mpOperator[nRow]->SelectEntryPos( aRowEntry.nOperator );
- }
-
- // allow to scroll one page behind the visible or stored rows
- long nVisible = nScrollPos + EDIT_ROW_COUNT;
- long nMax = std::max( nVisible, (long) maConditions.size() );
- maScrollBar.SetRange( Range( 0, nMax + EDIT_ROW_COUNT ) );
- maScrollBar.SetThumbPos( nScrollPos );
-
- EnableButtons();
-}
-
-void ScOptSolverDlg::EnableButtons()
-{
- for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
- {
- long nVecPos = nScrollPos + nRow;
- mpDelButton[nRow]->Enable( nVecPos < (long)maConditions.size() );
- }
-}
-
-//----------------------------------------------------------------------------
-
-BOOL ScOptSolverDlg::Close()
-{
- return DoClose( ScOptSolverDlgWrapper::GetChildWindowId() );
-}
-
-//----------------------------------------------------------------------------
-
-void ScOptSolverDlg::SetActive()
-{
- if ( mbDlgLostFocus )
- {
- mbDlgLostFocus = false;
- if( mpEdActive )
- mpEdActive->GrabFocus();
- }
- else
- {
- GrabFocus();
- }
- RefInputDone();
-}
-
-//----------------------------------------------------------------------------
-
-void ScOptSolverDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
-{
- if( mpEdActive )
- {
- if ( rRef.aStart != rRef.aEnd )
- RefInputStart(mpEdActive);
-
- // "target"/"value": single cell
- bool bSingle = ( mpEdActive == &maEdObjectiveCell || mpEdActive == &maEdTargetValue );
-
- String aStr;
- ScAddress aAdr = rRef.aStart;
- ScRange aNewRef( rRef );
- if ( bSingle )
- aNewRef.aEnd = aAdr;
-
- String aName;
- if ( pDocP->GetRangeAtBlock( aNewRef, &aName ) ) // named range: show name
- aStr = aName;
- else // format cell/range reference
- {
- USHORT nFmt = ( aAdr.Tab() == mnCurTab ) ? SCA_ABS : SCA_ABS_3D;
- if ( bSingle )
- aAdr.Format( aStr, nFmt, pDocP, pDocP->GetAddressConvention() );
- else
- rRef.Format( aStr, nFmt | SCR_ABS, pDocP, pDocP->GetAddressConvention() );
- }
-
- // variable cells can be several ranges, so only the selection is replaced
- if ( mpEdActive == &maEdVariableCells )
- {
- String aVal = mpEdActive->GetText();
- Selection aSel = mpEdActive->GetSelection();
- aSel.Justify();
- aVal.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() );
- aVal.Insert( aStr, (xub_StrLen)aSel.Min() );
- Selection aNewSel( aSel.Min(), aSel.Min()+aStr.Len() );
- mpEdActive->SetRefString( aVal );
- mpEdActive->SetSelection( aNewSel );
- }
- else
- mpEdActive->SetRefString( aStr );
-
- ReadConditions();
- EnableButtons();
-
- // select "Value of" if a ref is input into "target" edit
- if ( mpEdActive == &maEdTargetValue )
- maRbValue.Check();
- }
-}
-
-//----------------------------------------------------------------------------
-
-BOOL ScOptSolverDlg::IsRefInputMode() const
-{
- return mpEdActive != NULL;
-}
-
-//----------------------------------------------------------------------------
-// Handler:
-
-IMPL_LINK( ScOptSolverDlg, BtnHdl, PushButton*, pBtn )
-{
- if ( pBtn == &maBtnSolve || pBtn == &maBtnCancel )
- {
- bool bSolve = ( pBtn == &maBtnSolve );
-
- SetDispatcherLock( FALSE );
- SwitchToDocument();
-
- bool bClose = true;
- if ( bSolve )
- bClose = CallSolver();
-
- if ( bClose )
- {
- // Close: write dialog settings to DocShell for subsequent calls
- ReadConditions();
- ScOptSolverSave aSave(
- maEdObjectiveCell.GetText(), maRbMax.IsChecked(), maRbMin.IsChecked(), maRbValue.IsChecked(),
- maEdTargetValue.GetText(), maEdVariableCells.GetText(), maConditions, maEngine, maProperties );
- mpDocShell->SetSolverSaveData( aSave );
- Close();
- }
- else
- {
- // no solution -> dialog is kept open
- SetDispatcherLock( TRUE );
- }
- }
- else if ( pBtn == &maBtnOpt )
- {
- //! move options dialog to UI lib?
- ScSolverOptionsDialog* pOptDlg =
- new ScSolverOptionsDialog( this, maImplNames, maDescriptions, maEngine, maProperties );
- if ( pOptDlg->Execute() == RET_OK )
- {
- maEngine = pOptDlg->GetEngine();
- maProperties = pOptDlg->GetProperties();
- }
- delete pOptDlg;
- }
-
- return 0;
-}
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScOptSolverDlg, GetFocusHdl, Control*, pCtrl )
-{
- Edit* pEdit = NULL;
- mpEdActive = NULL;
-
- if( pCtrl == &maEdObjectiveCell || pCtrl == &maRBObjectiveCell )
- pEdit = mpEdActive = &maEdObjectiveCell;
- else if( pCtrl == &maEdTargetValue || pCtrl == &maRBTargetValue )
- pEdit = mpEdActive = &maEdTargetValue;
- else if( pCtrl == &maEdVariableCells || pCtrl == &maRBVariableCells )
- pEdit = mpEdActive = &maEdVariableCells;
- for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
- {
- if( pCtrl == mpLeftEdit[nRow] || pCtrl == mpLeftButton[nRow] )
- pEdit = mpEdActive = mpLeftEdit[nRow];
- else if( pCtrl == mpRightEdit[nRow] || pCtrl == mpRightButton[nRow] )
- pEdit = mpEdActive = mpRightEdit[nRow];
- else if( pCtrl == mpOperator[nRow] ) // focus on "operator" list box
- mpEdActive = mpRightEdit[nRow]; // use right edit for ref input, but don't change selection
- }
- if( pCtrl == &maRbValue ) // focus on "Value of" radio button
- mpEdActive = &maEdTargetValue; // use value edit for ref input, but don't change selection
-
- if( pEdit )
- pEdit->SetSelection( Selection( 0, SELECTION_MAX ) );
-
- return 0;
-}
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScOptSolverDlg, LoseFocusHdl, Control*, EMPTYARG )
-{
- mbDlgLostFocus = !IsActive();
- return 0;
-}
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScOptSolverDlg, DelBtnHdl, PushButton*, pBtn )
-{
- for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
- if( pBtn == mpDelButton[nRow] )
- {
- BOOL bHadFocus = pBtn->HasFocus();
-
- ReadConditions();
- long nVecPos = nScrollPos + nRow;
- if ( nVecPos < (long)maConditions.size() )
- {
- maConditions.erase( maConditions.begin() + nVecPos );
- ShowConditions();
-
- if ( bHadFocus && !pBtn->IsEnabled() )
- {
- // If the button is disabled, focus would normally move to the next control,
- // (left edit of the next row). Move it to left edit of this row instead.
-
- mpEdActive = mpLeftEdit[nRow];
- mpEdActive->GrabFocus();
- }
- }
- }
-
- return 0;
-}
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScOptSolverDlg, TargetModifyHdl, Edit*, EMPTYARG )
-{
- // modify handler for the target edit:
- // select "Value of" if something is input into the edit
- if ( maEdTargetValue.GetText().Len() )
- maRbValue.Check();
- return 0;
-}
-
-IMPL_LINK( ScOptSolverDlg, CondModifyHdl, Edit*, EMPTYARG )
-{
- // modify handler for the condition edits, just to enable/disable "delete" buttons
- ReadConditions();
- EnableButtons();
- return 0;
-}
-
-IMPL_LINK( ScOptSolverDlg, SelectHdl, ListBox*, EMPTYARG )
-{
- // select handler for operator list boxes, just to enable/disable "delete" buttons
- ReadConditions();
- EnableButtons();
- return 0;
-}
-
-IMPL_LINK( ScOptSolverDlg, ScrollHdl, ScrollBar*, EMPTYARG )
-{
- ReadConditions();
- nScrollPos = maScrollBar.GetThumbPos();
- ShowConditions();
- if( mpEdActive )
- mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
- return 0;
-}
-
-IMPL_LINK( ScOptSolverDlg, CursorUpHdl, ScCursorRefEdit*, pEdit )
-{
- if ( pEdit == mpLeftEdit[0] || pEdit == mpRightEdit[0] )
- {
- if ( nScrollPos > 0 )
- {
- ReadConditions();
- --nScrollPos;
- ShowConditions();
- if( mpEdActive )
- mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
- }
- }
- else
- {
- formula::RefEdit* pFocus = NULL;
- for ( sal_uInt16 nRow = 1; nRow < EDIT_ROW_COUNT; ++nRow ) // second row or below: move focus
- {
- if ( pEdit == mpLeftEdit[nRow] )
- pFocus = mpLeftEdit[nRow-1];
- else if ( pEdit == mpRightEdit[nRow] )
- pFocus = mpRightEdit[nRow-1];
- }
- if (pFocus)
- {
- mpEdActive = pFocus;
- pFocus->GrabFocus();
- }
- }
-
- return 0;
-}
-
-IMPL_LINK( ScOptSolverDlg, CursorDownHdl, ScCursorRefEdit*, pEdit )
-{
- if ( pEdit == mpLeftEdit[EDIT_ROW_COUNT-1] || pEdit == mpRightEdit[EDIT_ROW_COUNT-1] )
- {
- //! limit scroll position?
- ReadConditions();
- ++nScrollPos;
- ShowConditions();
- if( mpEdActive )
- mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
- }
- else
- {
- formula::RefEdit* pFocus = NULL;
- for ( sal_uInt16 nRow = 0; nRow+1 < EDIT_ROW_COUNT; ++nRow ) // before last row: move focus
- {
- if ( pEdit == mpLeftEdit[nRow] )
- pFocus = mpLeftEdit[nRow+1];
- else if ( pEdit == mpRightEdit[nRow] )
- pFocus = mpRightEdit[nRow+1];
- }
- if (pFocus)
- {
- mpEdActive = pFocus;
- pFocus->GrabFocus();
- }
- }
-
- return 0;
-}
-
-//----------------------------------------------------------------------------
-
-void ScOptSolverDlg::ShowError( bool bCondition, formula::RefEdit* pFocus )
-{
- String aMessage = bCondition ? maConditionError : maInputError;
- ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ), aMessage ).Execute();
- if (pFocus)
- {
- mpEdActive = pFocus;
- pFocus->GrabFocus();
- }
-}
-
-//----------------------------------------------------------------------------
-
-bool ScOptSolverDlg::ParseRef( ScRange& rRange, const String& rInput, bool bAllowRange )
-{
- ScRangeUtil aRangeUtil;
- ScAddress::Details aDetails(mpDoc->GetAddressConvention(), 0, 0);
- USHORT nFlags = rRange.ParseAny( rInput, mpDoc, aDetails );
- if ( nFlags & SCA_VALID )
- {
- if ( (nFlags & SCA_TAB_3D) == 0 )
- rRange.aStart.SetTab( mnCurTab );
- if ( (nFlags & SCA_TAB2_3D) == 0 )
- rRange.aEnd.SetTab( rRange.aStart.Tab() );
- return ( bAllowRange || rRange.aStart == rRange.aEnd );
- }
- else if ( aRangeUtil.MakeRangeFromName( rInput, mpDoc, mnCurTab, rRange, RUTL_NAMES, aDetails ) )
- return ( bAllowRange || rRange.aStart == rRange.aEnd );
-
- return false; // not recognized
-}
-
-bool ScOptSolverDlg::FindTimeout( sal_Int32& rTimeout )
-{
- bool bFound = false;
-
- if ( !maProperties.getLength() )
- maProperties = ScSolverUtil::GetDefaults( maEngine ); // get property defaults from component
-
- sal_Int32 nPropCount = maProperties.getLength();
- for (sal_Int32 nProp=0; nProp<nPropCount && !bFound; ++nProp)
- {
- const beans::PropertyValue& rValue = maProperties[nProp];
- if ( rValue.Name.equalsAscii( SC_UNONAME_TIMEOUT ) )
- bFound = ( rValue.Value >>= rTimeout );
- }
- return bFound;
-}
-
-bool ScOptSolverDlg::CallSolver() // return true -> close dialog after calling
-{
- // show progress dialog
-
- ScSolverProgressDialog aProgress( this );
- sal_Int32 nTimeout = 0;
- if ( FindTimeout( nTimeout ) )
- aProgress.SetTimeLimit( nTimeout );
- else
- aProgress.HideTimeLimit();
- aProgress.Show();
- aProgress.Update();
- aProgress.Sync();
- // try to make sure the progress dialog is painted before continuing
- Application::Reschedule(true);
-
- // collect solver parameters
-
- ReadConditions();
-
- uno::Reference<sheet::XSpreadsheetDocument> xDocument( mpDocShell->GetModel(), uno::UNO_QUERY );
-
- ScRange aObjRange;
- if ( !ParseRef( aObjRange, maEdObjectiveCell.GetText(), false ) )
- {
- ShowError( false, &maEdObjectiveCell );
- return false;
- }
- table::CellAddress aObjective( aObjRange.aStart.Tab(), aObjRange.aStart.Col(), aObjRange.aStart.Row() );
-
- // "changing cells" can be several ranges
- ScRangeList aVarRanges;
- if ( !ParseWithNames( aVarRanges, maEdVariableCells.GetText(), mpDoc ) )
- {
- ShowError( false, &maEdVariableCells );
- return false;
- }
- uno::Sequence<table::CellAddress> aVariables;
- sal_Int32 nVarPos = 0;
- ULONG nRangeCount = aVarRanges.Count();
- for (ULONG nRangePos=0; nRangePos<nRangeCount; ++nRangePos)
- {
- ScRange aRange(*aVarRanges.GetObject(nRangePos));
- aRange.Justify();
- SCTAB nTab = aRange.aStart.Tab();
-
- // resolve into single cells
-
- sal_Int32 nAdd = ( aRange.aEnd.Col() - aRange.aStart.Col() + 1 ) *
- ( aRange.aEnd.Row() - aRange.aStart.Row() + 1 );
- aVariables.realloc( nVarPos + nAdd );
-
- for (SCROW nRow = aRange.aStart.Row(); nRow <= aRange.aEnd.Row(); ++nRow)
- for (SCCOL nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); ++nCol)
- aVariables[nVarPos++] = table::CellAddress( nTab, nCol, nRow );
- }
-
- uno::Sequence<sheet::SolverConstraint> aConstraints;
- sal_Int32 nConstrPos = 0;
- for ( std::vector<ScOptConditionRow>::const_iterator aConstrIter = maConditions.begin();
- aConstrIter != maConditions.end(); ++aConstrIter )
- {
- if ( aConstrIter->aLeftStr.Len() )
- {
- sheet::SolverConstraint aConstraint;
- // order of list box entries must match enum values
- aConstraint.Operator = static_cast<sheet::SolverConstraintOperator>(aConstrIter->nOperator);
-
- ScRange aLeftRange;
- if ( !ParseRef( aLeftRange, aConstrIter->aLeftStr, true ) )
- {
- ShowError( true, NULL );
- return false;
- }
-
- bool bIsRange = false;
- ScRange aRightRange;
- if ( ParseRef( aRightRange, aConstrIter->aRightStr, true ) )
- {
- if ( aRightRange.aStart == aRightRange.aEnd )
- aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(),
- aRightRange.aStart.Col(), aRightRange.aStart.Row() );
- else if ( aRightRange.aEnd.Col()-aRightRange.aStart.Col() == aLeftRange.aEnd.Col()-aLeftRange.aStart.Col() &&
- aRightRange.aEnd.Row()-aRightRange.aStart.Row() == aLeftRange.aEnd.Row()-aLeftRange.aStart.Row() )
- bIsRange = true; // same size as "left" range, resolve into single cells
- else
- {
- ShowError( true, NULL );
- return false;
- }
- }
- else
- {
- sal_uInt32 nFormat = 0; //! explicit language?
- double fValue = 0.0;
- if ( mpDoc->GetFormatTable()->IsNumberFormat( aConstrIter->aRightStr, nFormat, fValue ) )
- aConstraint.Right <<= fValue;
- else if ( aConstraint.Operator != sheet::SolverConstraintOperator_INTEGER &&
- aConstraint.Operator != sheet::SolverConstraintOperator_BINARY )
- {
- ShowError( true, NULL );
- return false;
- }
- }
-
- // resolve into single cells
-
- sal_Int32 nAdd = ( aLeftRange.aEnd.Col() - aLeftRange.aStart.Col() + 1 ) *
- ( aLeftRange.aEnd.Row() - aLeftRange.aStart.Row() + 1 );
- aConstraints.realloc( nConstrPos + nAdd );
-
- for (SCROW nRow = aLeftRange.aStart.Row(); nRow <= aLeftRange.aEnd.Row(); ++nRow)
- for (SCCOL nCol = aLeftRange.aStart.Col(); nCol <= aLeftRange.aEnd.Col(); ++nCol)
- {
- aConstraint.Left = table::CellAddress( aLeftRange.aStart.Tab(), nCol, nRow );
- if ( bIsRange )
- aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(),
- aRightRange.aStart.Col() + ( nCol - aLeftRange.aStart.Col() ),
- aRightRange.aStart.Row() + ( nRow - aLeftRange.aStart.Row() ) );
-
- aConstraints[nConstrPos++] = aConstraint;
- }
- }
- }
-
- sal_Bool bMaximize = maRbMax.IsChecked();
- if ( maRbValue.IsChecked() )
- {
- // handle "value of" with an additional constraint (and then minimize)
-
- sheet::SolverConstraint aConstraint;
- aConstraint.Left = aObjective;
- aConstraint.Operator = sheet::SolverConstraintOperator_EQUAL;
-
- String aValStr = maEdTargetValue.GetText();
- ScRange aRightRange;
- if ( ParseRef( aRightRange, aValStr, false ) )
- aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(),
- aRightRange.aStart.Col(), aRightRange.aStart.Row() );
- else
- {
- sal_uInt32 nFormat = 0; //! explicit language?
- double fValue = 0.0;
- if ( mpDoc->GetFormatTable()->IsNumberFormat( aValStr, nFormat, fValue ) )
- aConstraint.Right <<= fValue;
- else
- {
- ShowError( false, &maEdTargetValue );
- return false;
- }
- }
-
- aConstraints.realloc( nConstrPos + 1 );
- aConstraints[nConstrPos++] = aConstraint;
- }
-
- // copy old document values
-
- sal_Int32 nVarCount = aVariables.getLength();
- uno::Sequence<double> aOldValues;
- aOldValues.realloc( nVarCount );
- for (nVarPos=0; nVarPos<nVarCount; ++nVarPos)
- {
- ScAddress aCellPos;
- ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
- aOldValues[nVarPos] = mpDoc->GetValue( aCellPos );
- }
-
- // create and initialize solver
-
- uno::Reference<sheet::XSolver> xSolver = ScSolverUtil::GetSolver( maEngine );
- DBG_ASSERT( xSolver.is(), "can't get solver component" );
- if ( !xSolver.is() )
- return false;
-
- xSolver->setDocument( xDocument );
- xSolver->setObjective( aObjective );
- xSolver->setVariables( aVariables );
- xSolver->setConstraints( aConstraints );
- xSolver->setMaximize( bMaximize );
-
- // set options
- uno::Reference<beans::XPropertySet> xOptProp(xSolver, uno::UNO_QUERY);
- if ( xOptProp.is() )
- {
- sal_Int32 nPropCount = maProperties.getLength();
- for (sal_Int32 nProp=0; nProp<nPropCount; ++nProp)
- {
- const beans::PropertyValue& rValue = maProperties[nProp];
- try
- {
- xOptProp->setPropertyValue( rValue.Name, rValue.Value );
- }
- catch ( uno::Exception & )
- {
- DBG_ERRORFILE("Exception in solver option property");
- }
- }
- }
-
- xSolver->solve();
- sal_Bool bSuccess = xSolver->getSuccess();
-
- aProgress.Hide();
- bool bClose = false;
- bool bRestore = true; // restore old values unless a solution is accepted
- if ( bSuccess )
- {
- // put solution into document so it is visible when asking
- uno::Sequence<double> aSolution = xSolver->getSolution();
- if ( aSolution.getLength() == nVarCount )
- {
- mpDocShell->LockPaint();
- ScDocFunc aFunc(*mpDocShell);
- for (nVarPos=0; nVarPos<nVarCount; ++nVarPos)
- {
- ScAddress aCellPos;
- ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
- aFunc.PutCell( aCellPos, new ScValueCell( aSolution[nVarPos] ), TRUE );
- }
- mpDocShell->UnlockPaint();
- }
- //! else error?
-
- // take formatted result from document (result value from component is ignored)
- String aResultStr;
- mpDoc->GetString( (SCCOL)aObjective.Column, (SCROW)aObjective.Row, (SCTAB)aObjective.Sheet, aResultStr );
- ScSolverSuccessDialog aDialog( this, aResultStr );
- if ( aDialog.Execute() == RET_OK )
- {
- // keep results and close dialog
- bRestore = false;
- bClose = true;
- }
- }
- else
- {
- rtl::OUString aError;
- uno::Reference<sheet::XSolverDescription> xDesc( xSolver, uno::UNO_QUERY );
- if ( xDesc.is() )
- aError = xDesc->getStatusDescription(); // error description from component
- ScSolverNoSolutionDialog aDialog( this, aError );
- aDialog.Execute();
- }
-
- if ( bRestore ) // restore old values
- {
- mpDocShell->LockPaint();
- ScDocFunc aFunc(*mpDocShell);
- for (nVarPos=0; nVarPos<nVarCount; ++nVarPos)
- {
- ScAddress aCellPos;
- ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
- aFunc.PutCell( aCellPos, new ScValueCell( aOldValues[nVarPos] ), TRUE );
- }
- mpDocShell->UnlockPaint();
- }
-
- return bClose;
-}
-
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: optsolver.cxx,v $
+ * $Revision: 1.5 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+//----------------------------------------------------------------------------
+
+#include "rangelst.hxx"
+#include "scitems.hxx"
+#include <sfx2/bindings.hxx>
+#include <sfx2/imagemgr.hxx>
+#include <svtools/zforlist.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+
+#include "uiitems.hxx"
+#include "reffact.hxx"
+#include "docsh.hxx"
+#include "docfunc.hxx"
+#include "cell.hxx"
+#include "rangeutl.hxx"
+#include "scresid.hxx"
+#include "convuno.hxx"
+#include "unonames.hxx"
+#include "solveroptions.hxx"
+#include "solverutil.hxx"
+#include "optsolver.hrc"
+
+#include "optsolver.hxx"
+
+#include <com/sun/star/sheet/Solver.hpp>
+#include <com/sun/star/sheet/XSolverDescription.hpp>
+
+using namespace com::sun::star;
+
+//----------------------------------------------------------------------------
+
+ScSolverProgressDialog::ScSolverProgressDialog( Window* pParent )
+ : ModelessDialog( pParent, ScResId( RID_SCDLG_SOLVER_PROGRESS ) ),
+ maFtProgress ( this, ScResId( FT_PROGRESS ) ),
+ maFtTime ( this, ScResId( FT_TIMELIMIT ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) )
+{
+ maBtnOk.Enable(FALSE);
+ FreeResource();
+}
+
+ScSolverProgressDialog::~ScSolverProgressDialog()
+{
+}
+
+void ScSolverProgressDialog::HideTimeLimit()
+{
+ maFtTime.Hide();
+}
+
+void ScSolverProgressDialog::SetTimeLimit( sal_Int32 nSeconds )
+{
+ String aOld = maFtTime.GetText();
+ String aNew = aOld.GetToken(0,'#');
+ aNew += String::CreateFromInt32( nSeconds );
+ aNew += aOld.GetToken(1,'#');
+ maFtTime.SetText( aNew );
+}
+
+//----------------------------------------------------------------------------
+
+ScSolverNoSolutionDialog::ScSolverNoSolutionDialog( Window* pParent, const String& rErrorText )
+ : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVER_NOSOLUTION ) ),
+ maFtNoSolution ( this, ScResId( FT_NOSOLUTION ) ),
+ maFtErrorText ( this, ScResId( FT_ERRORTEXT ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) )
+{
+ maFtErrorText.SetText( rErrorText );
+ FreeResource();
+}
+
+ScSolverNoSolutionDialog::~ScSolverNoSolutionDialog()
+{
+}
+
+//----------------------------------------------------------------------------
+
+ScSolverSuccessDialog::ScSolverSuccessDialog( Window* pParent, const String& rSolution )
+ : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVER_SUCCESS ) ),
+ maFtSuccess ( this, ScResId( FT_SUCCESS ) ),
+ maFtResult ( this, ScResId( FT_RESULT ) ),
+ maFtQuestion ( this, ScResId( FT_QUESTION ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) )
+{
+ String aMessage = maFtResult.GetText();
+ aMessage.Append( (sal_Char) ' ' );
+ aMessage.Append( rSolution );
+ maFtResult.SetText( aMessage );
+ FreeResource();
+}
+
+ScSolverSuccessDialog::~ScSolverSuccessDialog()
+{
+}
+
+//----------------------------------------------------------------------------
+
+ScCursorRefEdit::ScCursorRefEdit( ScAnyRefDlg* pParent, const ResId& rResId ) :
+ formula::RefEdit( pParent, rResId )
+{
+}
+
+void ScCursorRefEdit::SetCursorLinks( const Link& rUp, const Link& rDown )
+{
+ maCursorUpLink = rUp;
+ maCursorDownLink = rDown;
+}
+
+void ScCursorRefEdit::KeyInput( const KeyEvent& rKEvt )
+{
+ KeyCode aCode = rKEvt.GetKeyCode();
+ bool bUp = (aCode.GetCode() == KEY_UP);
+ bool bDown = (aCode.GetCode() == KEY_DOWN);
+ if ( !aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() && ( bUp || bDown ) )
+ {
+ if ( bUp )
+ maCursorUpLink.Call( this );
+ else
+ maCursorDownLink.Call( this );
+ }
+ else
+ formula::RefEdit::KeyInput( rKEvt );
+}
+
+//----------------------------------------------------------------------------
+
+ScOptSolverSave::ScOptSolverSave( const String& rObjective, BOOL bMax, BOOL bMin, BOOL bValue,
+ const String& rTarget, const String& rVariable,
+ const std::vector<ScOptConditionRow>& rConditions,
+ const String& rEngine,
+ const uno::Sequence<beans::PropertyValue>& rProperties ) :
+ maObjective( rObjective ),
+ mbMax( bMax ),
+ mbMin( bMin ),
+ mbValue( bValue ),
+ maTarget( rTarget ),
+ maVariable( rVariable ),
+ maConditions( rConditions ),
+ maEngine( rEngine ),
+ maProperties( rProperties )
+{
+}
+
+//============================================================================
+// class ScOptSolverDlg
+//----------------------------------------------------------------------------
+
+ScOptSolverDlg::ScOptSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScDocShell* pDocSh, ScAddress aCursorPos )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_OPTSOLVER ),
+ //
+ maFtObjectiveCell ( this, ScResId( FT_OBJECTIVECELL ) ),
+ maEdObjectiveCell ( this, ScResId( ED_OBJECTIVECELL ) ),
+ maRBObjectiveCell ( this, ScResId( IB_OBJECTIVECELL ), &maEdObjectiveCell, this ),
+ maFtDirection ( this, ScResId( FT_DIRECTION ) ),
+ maRbMax ( this, ScResId( RB_MAX ) ),
+ maRbMin ( this, ScResId( RB_MIN ) ),
+ maRbValue ( this, ScResId( RB_VALUE ) ),
+ maEdTargetValue ( this, ScResId( ED_TARGET ) ),
+ maRBTargetValue ( this, ScResId( IB_TARGET ), &maEdTargetValue, this ),
+ maFtVariableCells ( this, ScResId( FT_VARIABLECELLS ) ),
+ maEdVariableCells ( this, ScResId( ED_VARIABLECELLS ) ),
+ maRBVariableCells ( this, ScResId( IB_VARIABLECELLS ), &maEdVariableCells, this),
+ maFlConditions ( this, ScResId( FL_CONDITIONS ) ),
+ maFtCellRef ( this, ScResId( FT_CELLREF ) ),
+ maEdLeft1 ( this, ScResId( ED_LEFT1 ) ),
+ maRBLeft1 ( this, ScResId( IB_LEFT1 ), &maEdLeft1, this ),
+ maFtOperator ( this, ScResId( FT_OPERATOR ) ),
+ maLbOp1 ( this, ScResId( LB_OP1 ) ),
+ maFtConstraint ( this, ScResId( FT_CONSTRAINT ) ),
+ maEdRight1 ( this, ScResId( ED_RIGHT1 ) ),
+ maRBRight1 ( this, ScResId( IB_RIGHT1 ), &maEdRight1, this ),
+ maBtnDel1 ( this, ScResId( IB_DELETE1 ) ),
+ maEdLeft2 ( this, ScResId( ED_LEFT2 ) ),
+ maRBLeft2 ( this, ScResId( IB_LEFT2 ), &maEdLeft2, this ),
+ maLbOp2 ( this, ScResId( LB_OP2 ) ),
+ maEdRight2 ( this, ScResId( ED_RIGHT2 ) ),
+ maRBRight2 ( this, ScResId( IB_RIGHT2 ), &maEdRight2, this ),
+ maBtnDel2 ( this, ScResId( IB_DELETE2 ) ),
+ maEdLeft3 ( this, ScResId( ED_LEFT3 ) ),
+ maRBLeft3 ( this, ScResId( IB_LEFT3 ), &maEdLeft3, this ),
+ maLbOp3 ( this, ScResId( LB_OP3 ) ),
+ maEdRight3 ( this, ScResId( ED_RIGHT3 ) ),
+ maRBRight3 ( this, ScResId( IB_RIGHT3 ), &maEdRight3, this ),
+ maBtnDel3 ( this, ScResId( IB_DELETE3 ) ),
+ maEdLeft4 ( this, ScResId( ED_LEFT4 ) ),
+ maRBLeft4 ( this, ScResId( IB_LEFT4 ), &maEdLeft4, this ),
+ maLbOp4 ( this, ScResId( LB_OP4 ) ),
+ maEdRight4 ( this, ScResId( ED_RIGHT4 ) ),
+ maRBRight4 ( this, ScResId( IB_RIGHT4 ), &maEdRight4, this ),
+ maBtnDel4 ( this, ScResId( IB_DELETE4 ) ),
+ maScrollBar ( this, ScResId( SB_SCROLL ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnOpt ( this, ScResId( BTN_OPTIONS ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+ maBtnCancel ( this, ScResId( BTN_CLOSE ) ),
+ maBtnSolve ( this, ScResId( BTN_SOLVE ) ),
+ maInputError ( ScResId( STR_INVALIDINPUT ) ),
+ maConditionError ( ScResId( STR_INVALIDCONDITION ) ),
+ //
+ mpDocShell ( pDocSh ),
+ mpDoc ( pDocSh->GetDocument() ),
+ mnCurTab ( aCursorPos.Tab() ),
+ mpEdActive ( NULL ),
+ mbDlgLostFocus ( false ),
+ nScrollPos ( 0 )
+{
+ mpLeftEdit[0] = &maEdLeft1;
+ mpLeftButton[0] = &maRBLeft1;
+ mpRightEdit[0] = &maEdRight1;
+ mpRightButton[0] = &maRBRight1;
+ mpOperator[0] = &maLbOp1;
+ mpDelButton[0] = &maBtnDel1;
+
+ mpLeftEdit[1] = &maEdLeft2;
+ mpLeftButton[1] = &maRBLeft2;
+ mpRightEdit[1] = &maEdRight2;
+ mpRightButton[1] = &maRBRight2;
+ mpOperator[1] = &maLbOp2;
+ mpDelButton[1] = &maBtnDel2;
+
+ mpLeftEdit[2] = &maEdLeft3;
+ mpLeftButton[2] = &maRBLeft3;
+ mpRightEdit[2] = &maEdRight3;
+ mpRightButton[2] = &maRBRight3;
+ mpOperator[2] = &maLbOp3;
+ mpDelButton[2] = &maBtnDel3;
+
+ mpLeftEdit[3] = &maEdLeft4;
+ mpLeftButton[3] = &maRBLeft4;
+ mpRightEdit[3] = &maEdRight4;
+ mpRightButton[3] = &maRBRight4;
+ mpOperator[3] = &maLbOp4;
+ mpDelButton[3] = &maBtnDel4;
+
+ Init( aCursorPos );
+ FreeResource();
+}
+
+//----------------------------------------------------------------------------
+
+ScOptSolverDlg::~ScOptSolverDlg()
+{
+}
+
+//----------------------------------------------------------------------------
+
+void ScOptSolverDlg::Init(const ScAddress& rCursorPos)
+{
+ // Get the "Delete Rows" commandimagelist images from sfx instead of
+ // adding a second copy to sc (see ScTbxInsertCtrl::StateChanged)
+
+ rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
+ aSlotURL += rtl::OUString::valueOf( sal_Int32( SID_DEL_ROWS ) );
+ uno::Reference<frame::XFrame> xFrame = GetBindings().GetActiveFrame();
+ Image aDelNm = ::GetImage( xFrame, aSlotURL, FALSE, FALSE );
+ Image aDelHC = ::GetImage( xFrame, aSlotURL, FALSE, TRUE ); // high contrast
+
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ mpDelButton[nRow]->SetModeImage( aDelNm, BMP_COLOR_NORMAL );
+ mpDelButton[nRow]->SetModeImage( aDelHC, BMP_COLOR_HIGHCONTRAST );
+ }
+
+ maBtnOpt.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) );
+ maBtnCancel.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) );
+ maBtnSolve.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) );
+
+ Link aLink = LINK( this, ScOptSolverDlg, GetFocusHdl );
+ maEdObjectiveCell.SetGetFocusHdl( aLink );
+ maRBObjectiveCell.SetGetFocusHdl( aLink );
+ maEdTargetValue.SetGetFocusHdl( aLink );
+ maRBTargetValue.SetGetFocusHdl( aLink );
+ maEdVariableCells.SetGetFocusHdl( aLink );
+ maRBVariableCells.SetGetFocusHdl( aLink );
+ maRbValue.SetGetFocusHdl( aLink );
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ mpLeftEdit[nRow]->SetGetFocusHdl( aLink );
+ mpLeftButton[nRow]->SetGetFocusHdl( aLink );
+ mpRightEdit[nRow]->SetGetFocusHdl( aLink );
+ mpRightButton[nRow]->SetGetFocusHdl( aLink );
+ mpOperator[nRow]->SetGetFocusHdl( aLink );
+ }
+
+ aLink = LINK( this, ScOptSolverDlg, LoseFocusHdl );
+ maEdObjectiveCell.SetLoseFocusHdl( aLink );
+ maRBObjectiveCell.SetLoseFocusHdl( aLink );
+ maEdTargetValue. SetLoseFocusHdl( aLink );
+ maRBTargetValue. SetLoseFocusHdl( aLink );
+ maEdVariableCells.SetLoseFocusHdl( aLink );
+ maRBVariableCells.SetLoseFocusHdl( aLink );
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ mpLeftEdit[nRow]->SetLoseFocusHdl( aLink );
+ mpLeftButton[nRow]->SetLoseFocusHdl( aLink );
+ mpRightEdit[nRow]->SetLoseFocusHdl( aLink );
+ mpRightButton[nRow]->SetLoseFocusHdl( aLink );
+ }
+
+ Link aCursorUp = LINK( this, ScOptSolverDlg, CursorUpHdl );
+ Link aCursorDown = LINK( this, ScOptSolverDlg, CursorDownHdl );
+ Link aCondModify = LINK( this, ScOptSolverDlg, CondModifyHdl );
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ mpLeftEdit[nRow]->SetCursorLinks( aCursorUp, aCursorDown );
+ mpRightEdit[nRow]->SetCursorLinks( aCursorUp, aCursorDown );
+ mpLeftEdit[nRow]->SetModifyHdl( aCondModify );
+ mpRightEdit[nRow]->SetModifyHdl( aCondModify );
+ mpDelButton[nRow]->SetClickHdl( LINK( this, ScOptSolverDlg, DelBtnHdl ) );
+ mpOperator[nRow]->SetSelectHdl( LINK( this, ScOptSolverDlg, SelectHdl ) );
+ }
+ maEdTargetValue.SetModifyHdl( LINK( this, ScOptSolverDlg, TargetModifyHdl ) );
+
+ maScrollBar.SetEndScrollHdl( LINK( this, ScOptSolverDlg, ScrollHdl ) );
+ maScrollBar.SetScrollHdl( LINK( this, ScOptSolverDlg, ScrollHdl ) );
+
+ maScrollBar.SetPageSize( EDIT_ROW_COUNT );
+ maScrollBar.SetVisibleSize( EDIT_ROW_COUNT );
+ maScrollBar.SetLineSize( 1 );
+ // Range is set in ShowConditions
+
+ // get available solver implementations
+ //! sort by descriptions?
+ ScSolverUtil::GetImplementations( maImplNames, maDescriptions );
+ sal_Int32 nImplCount = maImplNames.getLength();
+
+ const ScOptSolverSave* pOldData = mpDocShell->GetSolverSaveData();
+ if ( pOldData )
+ {
+ maEdObjectiveCell.SetRefString( pOldData->GetObjective() );
+ maRbMax.Check( pOldData->GetMax() );
+ maRbMin.Check( pOldData->GetMin() );
+ maRbValue.Check( pOldData->GetValue() );
+ maEdTargetValue.SetRefString( pOldData->GetTarget() );
+ maEdVariableCells.SetRefString( pOldData->GetVariable() );
+ maConditions = pOldData->GetConditions();
+ maEngine = pOldData->GetEngine();
+ maProperties = pOldData->GetProperties();
+ }
+ else
+ {
+ maRbMax.Check();
+ String aCursorStr;
+ if ( !mpDoc->GetRangeAtBlock( ScRange(rCursorPos), &aCursorStr ) )
+ rCursorPos.Format( aCursorStr, SCA_ABS, NULL, mpDoc->GetAddressConvention() );
+ maEdObjectiveCell.SetRefString( aCursorStr );
+ if ( nImplCount > 0 )
+ maEngine = maImplNames[0]; // use first implementation
+ }
+ ShowConditions();
+
+ maEdObjectiveCell.GrabFocus();
+ mpEdActive = &maEdObjectiveCell;
+}
+
+//----------------------------------------------------------------------------
+
+void ScOptSolverDlg::ReadConditions()
+{
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ ScOptConditionRow aRowEntry;
+ aRowEntry.aLeftStr = mpLeftEdit[nRow]->GetText();
+ aRowEntry.aRightStr = mpRightEdit[nRow]->GetText();
+ aRowEntry.nOperator = mpOperator[nRow]->GetSelectEntryPos();
+
+ long nVecPos = nScrollPos + nRow;
+ if ( nVecPos >= (long)maConditions.size() && !aRowEntry.IsDefault() )
+ maConditions.resize( nVecPos + 1 );
+
+ if ( nVecPos < (long)maConditions.size() )
+ maConditions[nVecPos] = aRowEntry;
+
+ // remove default entries at the end
+ size_t nSize = maConditions.size();
+ while ( nSize > 0 && maConditions[ nSize-1 ].IsDefault() )
+ --nSize;
+ maConditions.resize( nSize );
+ }
+}
+
+void ScOptSolverDlg::ShowConditions()
+{
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ ScOptConditionRow aRowEntry;
+
+ long nVecPos = nScrollPos + nRow;
+ if ( nVecPos < (long)maConditions.size() )
+ aRowEntry = maConditions[nVecPos];
+
+ mpLeftEdit[nRow]->SetRefString( aRowEntry.aLeftStr );
+ mpRightEdit[nRow]->SetRefString( aRowEntry.aRightStr );
+ mpOperator[nRow]->SelectEntryPos( aRowEntry.nOperator );
+ }
+
+ // allow to scroll one page behind the visible or stored rows
+ long nVisible = nScrollPos + EDIT_ROW_COUNT;
+ long nMax = std::max( nVisible, (long) maConditions.size() );
+ maScrollBar.SetRange( Range( 0, nMax + EDIT_ROW_COUNT ) );
+ maScrollBar.SetThumbPos( nScrollPos );
+
+ EnableButtons();
+}
+
+void ScOptSolverDlg::EnableButtons()
+{
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ long nVecPos = nScrollPos + nRow;
+ mpDelButton[nRow]->Enable( nVecPos < (long)maConditions.size() );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+BOOL ScOptSolverDlg::Close()
+{
+ return DoClose( ScOptSolverDlgWrapper::GetChildWindowId() );
+}
+
+//----------------------------------------------------------------------------
+
+void ScOptSolverDlg::SetActive()
+{
+ if ( mbDlgLostFocus )
+ {
+ mbDlgLostFocus = false;
+ if( mpEdActive )
+ mpEdActive->GrabFocus();
+ }
+ else
+ {
+ GrabFocus();
+ }
+ RefInputDone();
+}
+
+//----------------------------------------------------------------------------
+
+void ScOptSolverDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if( mpEdActive )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart(mpEdActive);
+
+ // "target"/"value": single cell
+ bool bSingle = ( mpEdActive == &maEdObjectiveCell || mpEdActive == &maEdTargetValue );
+
+ String aStr;
+ ScAddress aAdr = rRef.aStart;
+ ScRange aNewRef( rRef );
+ if ( bSingle )
+ aNewRef.aEnd = aAdr;
+
+ String aName;
+ if ( pDocP->GetRangeAtBlock( aNewRef, &aName ) ) // named range: show name
+ aStr = aName;
+ else // format cell/range reference
+ {
+ USHORT nFmt = ( aAdr.Tab() == mnCurTab ) ? SCA_ABS : SCA_ABS_3D;
+ if ( bSingle )
+ aAdr.Format( aStr, nFmt, pDocP, pDocP->GetAddressConvention() );
+ else
+ rRef.Format( aStr, nFmt | SCR_ABS, pDocP, pDocP->GetAddressConvention() );
+ }
+
+ // variable cells can be several ranges, so only the selection is replaced
+ if ( mpEdActive == &maEdVariableCells )
+ {
+ String aVal = mpEdActive->GetText();
+ Selection aSel = mpEdActive->GetSelection();
+ aSel.Justify();
+ aVal.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() );
+ aVal.Insert( aStr, (xub_StrLen)aSel.Min() );
+ Selection aNewSel( aSel.Min(), aSel.Min()+aStr.Len() );
+ mpEdActive->SetRefString( aVal );
+ mpEdActive->SetSelection( aNewSel );
+ }
+ else
+ mpEdActive->SetRefString( aStr );
+
+ ReadConditions();
+ EnableButtons();
+
+ // select "Value of" if a ref is input into "target" edit
+ if ( mpEdActive == &maEdTargetValue )
+ maRbValue.Check();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+BOOL ScOptSolverDlg::IsRefInputMode() const
+{
+ return mpEdActive != NULL;
+}
+
+//----------------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScOptSolverDlg, BtnHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &maBtnSolve || pBtn == &maBtnCancel )
+ {
+ bool bSolve = ( pBtn == &maBtnSolve );
+
+ SetDispatcherLock( FALSE );
+ SwitchToDocument();
+
+ bool bClose = true;
+ if ( bSolve )
+ bClose = CallSolver();
+
+ if ( bClose )
+ {
+ // Close: write dialog settings to DocShell for subsequent calls
+ ReadConditions();
+ ScOptSolverSave aSave(
+ maEdObjectiveCell.GetText(), maRbMax.IsChecked(), maRbMin.IsChecked(), maRbValue.IsChecked(),
+ maEdTargetValue.GetText(), maEdVariableCells.GetText(), maConditions, maEngine, maProperties );
+ mpDocShell->SetSolverSaveData( aSave );
+ Close();
+ }
+ else
+ {
+ // no solution -> dialog is kept open
+ SetDispatcherLock( TRUE );
+ }
+ }
+ else if ( pBtn == &maBtnOpt )
+ {
+ //! move options dialog to UI lib?
+ ScSolverOptionsDialog* pOptDlg =
+ new ScSolverOptionsDialog( this, maImplNames, maDescriptions, maEngine, maProperties );
+ if ( pOptDlg->Execute() == RET_OK )
+ {
+ maEngine = pOptDlg->GetEngine();
+ maProperties = pOptDlg->GetProperties();
+ }
+ delete pOptDlg;
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScOptSolverDlg, GetFocusHdl, Control*, pCtrl )
+{
+ Edit* pEdit = NULL;
+ mpEdActive = NULL;
+
+ if( pCtrl == &maEdObjectiveCell || pCtrl == &maRBObjectiveCell )
+ pEdit = mpEdActive = &maEdObjectiveCell;
+ else if( pCtrl == &maEdTargetValue || pCtrl == &maRBTargetValue )
+ pEdit = mpEdActive = &maEdTargetValue;
+ else if( pCtrl == &maEdVariableCells || pCtrl == &maRBVariableCells )
+ pEdit = mpEdActive = &maEdVariableCells;
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ if( pCtrl == mpLeftEdit[nRow] || pCtrl == mpLeftButton[nRow] )
+ pEdit = mpEdActive = mpLeftEdit[nRow];
+ else if( pCtrl == mpRightEdit[nRow] || pCtrl == mpRightButton[nRow] )
+ pEdit = mpEdActive = mpRightEdit[nRow];
+ else if( pCtrl == mpOperator[nRow] ) // focus on "operator" list box
+ mpEdActive = mpRightEdit[nRow]; // use right edit for ref input, but don't change selection
+ }
+ if( pCtrl == &maRbValue ) // focus on "Value of" radio button
+ mpEdActive = &maEdTargetValue; // use value edit for ref input, but don't change selection
+
+ if( pEdit )
+ pEdit->SetSelection( Selection( 0, SELECTION_MAX ) );
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScOptSolverDlg, LoseFocusHdl, Control*, EMPTYARG )
+{
+ mbDlgLostFocus = !IsActive();
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScOptSolverDlg, DelBtnHdl, PushButton*, pBtn )
+{
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ if( pBtn == mpDelButton[nRow] )
+ {
+ BOOL bHadFocus = pBtn->HasFocus();
+
+ ReadConditions();
+ long nVecPos = nScrollPos + nRow;
+ if ( nVecPos < (long)maConditions.size() )
+ {
+ maConditions.erase( maConditions.begin() + nVecPos );
+ ShowConditions();
+
+ if ( bHadFocus && !pBtn->IsEnabled() )
+ {
+ // If the button is disabled, focus would normally move to the next control,
+ // (left edit of the next row). Move it to left edit of this row instead.
+
+ mpEdActive = mpLeftEdit[nRow];
+ mpEdActive->GrabFocus();
+ }
+ }
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScOptSolverDlg, TargetModifyHdl, Edit*, EMPTYARG )
+{
+ // modify handler for the target edit:
+ // select "Value of" if something is input into the edit
+ if ( maEdTargetValue.GetText().Len() )
+ maRbValue.Check();
+ return 0;
+}
+
+IMPL_LINK( ScOptSolverDlg, CondModifyHdl, Edit*, EMPTYARG )
+{
+ // modify handler for the condition edits, just to enable/disable "delete" buttons
+ ReadConditions();
+ EnableButtons();
+ return 0;
+}
+
+IMPL_LINK( ScOptSolverDlg, SelectHdl, ListBox*, EMPTYARG )
+{
+ // select handler for operator list boxes, just to enable/disable "delete" buttons
+ ReadConditions();
+ EnableButtons();
+ return 0;
+}
+
+IMPL_LINK( ScOptSolverDlg, ScrollHdl, ScrollBar*, EMPTYARG )
+{
+ ReadConditions();
+ nScrollPos = maScrollBar.GetThumbPos();
+ ShowConditions();
+ if( mpEdActive )
+ mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+ return 0;
+}
+
+IMPL_LINK( ScOptSolverDlg, CursorUpHdl, ScCursorRefEdit*, pEdit )
+{
+ if ( pEdit == mpLeftEdit[0] || pEdit == mpRightEdit[0] )
+ {
+ if ( nScrollPos > 0 )
+ {
+ ReadConditions();
+ --nScrollPos;
+ ShowConditions();
+ if( mpEdActive )
+ mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+ }
+ }
+ else
+ {
+ formula::RefEdit* pFocus = NULL;
+ for ( sal_uInt16 nRow = 1; nRow < EDIT_ROW_COUNT; ++nRow ) // second row or below: move focus
+ {
+ if ( pEdit == mpLeftEdit[nRow] )
+ pFocus = mpLeftEdit[nRow-1];
+ else if ( pEdit == mpRightEdit[nRow] )
+ pFocus = mpRightEdit[nRow-1];
+ }
+ if (pFocus)
+ {
+ mpEdActive = pFocus;
+ pFocus->GrabFocus();
+ }
+ }
+
+ return 0;
+}
+
+IMPL_LINK( ScOptSolverDlg, CursorDownHdl, ScCursorRefEdit*, pEdit )
+{
+ if ( pEdit == mpLeftEdit[EDIT_ROW_COUNT-1] || pEdit == mpRightEdit[EDIT_ROW_COUNT-1] )
+ {
+ //! limit scroll position?
+ ReadConditions();
+ ++nScrollPos;
+ ShowConditions();
+ if( mpEdActive )
+ mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+ }
+ else
+ {
+ formula::RefEdit* pFocus = NULL;
+ for ( sal_uInt16 nRow = 0; nRow+1 < EDIT_ROW_COUNT; ++nRow ) // before last row: move focus
+ {
+ if ( pEdit == mpLeftEdit[nRow] )
+ pFocus = mpLeftEdit[nRow+1];
+ else if ( pEdit == mpRightEdit[nRow] )
+ pFocus = mpRightEdit[nRow+1];
+ }
+ if (pFocus)
+ {
+ mpEdActive = pFocus;
+ pFocus->GrabFocus();
+ }
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+void ScOptSolverDlg::ShowError( bool bCondition, formula::RefEdit* pFocus )
+{
+ String aMessage = bCondition ? maConditionError : maInputError;
+ ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ), aMessage ).Execute();
+ if (pFocus)
+ {
+ mpEdActive = pFocus;
+ pFocus->GrabFocus();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+bool ScOptSolverDlg::ParseRef( ScRange& rRange, const String& rInput, bool bAllowRange )
+{
+ ScRangeUtil aRangeUtil;
+ ScAddress::Details aDetails(mpDoc->GetAddressConvention(), 0, 0);
+ USHORT nFlags = rRange.ParseAny( rInput, mpDoc, aDetails );
+ if ( nFlags & SCA_VALID )
+ {
+ if ( (nFlags & SCA_TAB_3D) == 0 )
+ rRange.aStart.SetTab( mnCurTab );
+ if ( (nFlags & SCA_TAB2_3D) == 0 )
+ rRange.aEnd.SetTab( rRange.aStart.Tab() );
+ return ( bAllowRange || rRange.aStart == rRange.aEnd );
+ }
+ else if ( aRangeUtil.MakeRangeFromName( rInput, mpDoc, mnCurTab, rRange, RUTL_NAMES, aDetails ) )
+ return ( bAllowRange || rRange.aStart == rRange.aEnd );
+
+ return false; // not recognized
+}
+
+bool ScOptSolverDlg::FindTimeout( sal_Int32& rTimeout )
+{
+ bool bFound = false;
+
+ if ( !maProperties.getLength() )
+ maProperties = ScSolverUtil::GetDefaults( maEngine ); // get property defaults from component
+
+ sal_Int32 nPropCount = maProperties.getLength();
+ for (sal_Int32 nProp=0; nProp<nPropCount && !bFound; ++nProp)
+ {
+ const beans::PropertyValue& rValue = maProperties[nProp];
+ if ( rValue.Name.equalsAscii( SC_UNONAME_TIMEOUT ) )
+ bFound = ( rValue.Value >>= rTimeout );
+ }
+ return bFound;
+}
+
+bool ScOptSolverDlg::CallSolver() // return true -> close dialog after calling
+{
+ // show progress dialog
+
+ ScSolverProgressDialog aProgress( this );
+ sal_Int32 nTimeout = 0;
+ if ( FindTimeout( nTimeout ) )
+ aProgress.SetTimeLimit( nTimeout );
+ else
+ aProgress.HideTimeLimit();
+ aProgress.Show();
+ aProgress.Update();
+ aProgress.Sync();
+ // try to make sure the progress dialog is painted before continuing
+ Application::Reschedule(true);
+
+ // collect solver parameters
+
+ ReadConditions();
+
+ uno::Reference<sheet::XSpreadsheetDocument> xDocument( mpDocShell->GetModel(), uno::UNO_QUERY );
+
+ ScRange aObjRange;
+ if ( !ParseRef( aObjRange, maEdObjectiveCell.GetText(), false ) )
+ {
+ ShowError( false, &maEdObjectiveCell );
+ return false;
+ }
+ table::CellAddress aObjective( aObjRange.aStart.Tab(), aObjRange.aStart.Col(), aObjRange.aStart.Row() );
+
+ // "changing cells" can be several ranges
+ ScRangeList aVarRanges;
+ if ( !ParseWithNames( aVarRanges, maEdVariableCells.GetText(), mpDoc ) )
+ {
+ ShowError( false, &maEdVariableCells );
+ return false;
+ }
+ uno::Sequence<table::CellAddress> aVariables;
+ sal_Int32 nVarPos = 0;
+ ULONG nRangeCount = aVarRanges.Count();
+ for (ULONG nRangePos=0; nRangePos<nRangeCount; ++nRangePos)
+ {
+ ScRange aRange(*aVarRanges.GetObject(nRangePos));
+ aRange.Justify();
+ SCTAB nTab = aRange.aStart.Tab();
+
+ // resolve into single cells
+
+ sal_Int32 nAdd = ( aRange.aEnd.Col() - aRange.aStart.Col() + 1 ) *
+ ( aRange.aEnd.Row() - aRange.aStart.Row() + 1 );
+ aVariables.realloc( nVarPos + nAdd );
+
+ for (SCROW nRow = aRange.aStart.Row(); nRow <= aRange.aEnd.Row(); ++nRow)
+ for (SCCOL nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); ++nCol)
+ aVariables[nVarPos++] = table::CellAddress( nTab, nCol, nRow );
+ }
+
+ uno::Sequence<sheet::SolverConstraint> aConstraints;
+ sal_Int32 nConstrPos = 0;
+ for ( std::vector<ScOptConditionRow>::const_iterator aConstrIter = maConditions.begin();
+ aConstrIter != maConditions.end(); ++aConstrIter )
+ {
+ if ( aConstrIter->aLeftStr.Len() )
+ {
+ sheet::SolverConstraint aConstraint;
+ // order of list box entries must match enum values
+ aConstraint.Operator = static_cast<sheet::SolverConstraintOperator>(aConstrIter->nOperator);
+
+ ScRange aLeftRange;
+ if ( !ParseRef( aLeftRange, aConstrIter->aLeftStr, true ) )
+ {
+ ShowError( true, NULL );
+ return false;
+ }
+
+ bool bIsRange = false;
+ ScRange aRightRange;
+ if ( ParseRef( aRightRange, aConstrIter->aRightStr, true ) )
+ {
+ if ( aRightRange.aStart == aRightRange.aEnd )
+ aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(),
+ aRightRange.aStart.Col(), aRightRange.aStart.Row() );
+ else if ( aRightRange.aEnd.Col()-aRightRange.aStart.Col() == aLeftRange.aEnd.Col()-aLeftRange.aStart.Col() &&
+ aRightRange.aEnd.Row()-aRightRange.aStart.Row() == aLeftRange.aEnd.Row()-aLeftRange.aStart.Row() )
+ bIsRange = true; // same size as "left" range, resolve into single cells
+ else
+ {
+ ShowError( true, NULL );
+ return false;
+ }
+ }
+ else
+ {
+ sal_uInt32 nFormat = 0; //! explicit language?
+ double fValue = 0.0;
+ if ( mpDoc->GetFormatTable()->IsNumberFormat( aConstrIter->aRightStr, nFormat, fValue ) )
+ aConstraint.Right <<= fValue;
+ else if ( aConstraint.Operator != sheet::SolverConstraintOperator_INTEGER &&
+ aConstraint.Operator != sheet::SolverConstraintOperator_BINARY )
+ {
+ ShowError( true, NULL );
+ return false;
+ }
+ }
+
+ // resolve into single cells
+
+ sal_Int32 nAdd = ( aLeftRange.aEnd.Col() - aLeftRange.aStart.Col() + 1 ) *
+ ( aLeftRange.aEnd.Row() - aLeftRange.aStart.Row() + 1 );
+ aConstraints.realloc( nConstrPos + nAdd );
+
+ for (SCROW nRow = aLeftRange.aStart.Row(); nRow <= aLeftRange.aEnd.Row(); ++nRow)
+ for (SCCOL nCol = aLeftRange.aStart.Col(); nCol <= aLeftRange.aEnd.Col(); ++nCol)
+ {
+ aConstraint.Left = table::CellAddress( aLeftRange.aStart.Tab(), nCol, nRow );
+ if ( bIsRange )
+ aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(),
+ aRightRange.aStart.Col() + ( nCol - aLeftRange.aStart.Col() ),
+ aRightRange.aStart.Row() + ( nRow - aLeftRange.aStart.Row() ) );
+
+ aConstraints[nConstrPos++] = aConstraint;
+ }
+ }
+ }
+
+ sal_Bool bMaximize = maRbMax.IsChecked();
+ if ( maRbValue.IsChecked() )
+ {
+ // handle "value of" with an additional constraint (and then minimize)
+
+ sheet::SolverConstraint aConstraint;
+ aConstraint.Left = aObjective;
+ aConstraint.Operator = sheet::SolverConstraintOperator_EQUAL;
+
+ String aValStr = maEdTargetValue.GetText();
+ ScRange aRightRange;
+ if ( ParseRef( aRightRange, aValStr, false ) )
+ aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(),
+ aRightRange.aStart.Col(), aRightRange.aStart.Row() );
+ else
+ {
+ sal_uInt32 nFormat = 0; //! explicit language?
+ double fValue = 0.0;
+ if ( mpDoc->GetFormatTable()->IsNumberFormat( aValStr, nFormat, fValue ) )
+ aConstraint.Right <<= fValue;
+ else
+ {
+ ShowError( false, &maEdTargetValue );
+ return false;
+ }
+ }
+
+ aConstraints.realloc( nConstrPos + 1 );
+ aConstraints[nConstrPos++] = aConstraint;
+ }
+
+ // copy old document values
+
+ sal_Int32 nVarCount = aVariables.getLength();
+ uno::Sequence<double> aOldValues;
+ aOldValues.realloc( nVarCount );
+ for (nVarPos=0; nVarPos<nVarCount; ++nVarPos)
+ {
+ ScAddress aCellPos;
+ ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
+ aOldValues[nVarPos] = mpDoc->GetValue( aCellPos );
+ }
+
+ // create and initialize solver
+
+ uno::Reference<sheet::XSolver> xSolver = ScSolverUtil::GetSolver( maEngine );
+ DBG_ASSERT( xSolver.is(), "can't get solver component" );
+ if ( !xSolver.is() )
+ return false;
+
+ xSolver->setDocument( xDocument );
+ xSolver->setObjective( aObjective );
+ xSolver->setVariables( aVariables );
+ xSolver->setConstraints( aConstraints );
+ xSolver->setMaximize( bMaximize );
+
+ // set options
+ uno::Reference<beans::XPropertySet> xOptProp(xSolver, uno::UNO_QUERY);
+ if ( xOptProp.is() )
+ {
+ sal_Int32 nPropCount = maProperties.getLength();
+ for (sal_Int32 nProp=0; nProp<nPropCount; ++nProp)
+ {
+ const beans::PropertyValue& rValue = maProperties[nProp];
+ try
+ {
+ xOptProp->setPropertyValue( rValue.Name, rValue.Value );
+ }
+ catch ( uno::Exception & )
+ {
+ DBG_ERRORFILE("Exception in solver option property");
+ }
+ }
+ }
+
+ xSolver->solve();
+ sal_Bool bSuccess = xSolver->getSuccess();
+
+ aProgress.Hide();
+ bool bClose = false;
+ bool bRestore = true; // restore old values unless a solution is accepted
+ if ( bSuccess )
+ {
+ // put solution into document so it is visible when asking
+ uno::Sequence<double> aSolution = xSolver->getSolution();
+ if ( aSolution.getLength() == nVarCount )
+ {
+ mpDocShell->LockPaint();
+ ScDocFunc aFunc(*mpDocShell);
+ for (nVarPos=0; nVarPos<nVarCount; ++nVarPos)
+ {
+ ScAddress aCellPos;
+ ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
+ aFunc.PutCell( aCellPos, new ScValueCell( aSolution[nVarPos] ), TRUE );
+ }
+ mpDocShell->UnlockPaint();
+ }
+ //! else error?
+
+ // take formatted result from document (result value from component is ignored)
+ String aResultStr;
+ mpDoc->GetString( (SCCOL)aObjective.Column, (SCROW)aObjective.Row, (SCTAB)aObjective.Sheet, aResultStr );
+ ScSolverSuccessDialog aDialog( this, aResultStr );
+ if ( aDialog.Execute() == RET_OK )
+ {
+ // keep results and close dialog
+ bRestore = false;
+ bClose = true;
+ }
+ }
+ else
+ {
+ rtl::OUString aError;
+ uno::Reference<sheet::XSolverDescription> xDesc( xSolver, uno::UNO_QUERY );
+ if ( xDesc.is() )
+ aError = xDesc->getStatusDescription(); // error description from component
+ ScSolverNoSolutionDialog aDialog( this, aError );
+ aDialog.Execute();
+ }
+
+ if ( bRestore ) // restore old values
+ {
+ mpDocShell->LockPaint();
+ ScDocFunc aFunc(*mpDocShell);
+ for (nVarPos=0; nVarPos<nVarCount; ++nVarPos)
+ {
+ ScAddress aCellPos;
+ ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
+ aFunc.PutCell( aCellPos, new ScValueCell( aOldValues[nVarPos] ), TRUE );
+ }
+ mpDocShell->UnlockPaint();
+ }
+
+ return bClose;
+}
+
diff --git a/sc/source/ui/miscdlgs/solvrdlg.cxx b/sc/source/ui/miscdlgs/solvrdlg.cxx
index 7b81004dc43c..8e3803623972 100644
--- a/sc/source/ui/miscdlgs/solvrdlg.cxx
+++ b/sc/source/ui/miscdlgs/solvrdlg.cxx
@@ -1,316 +1,316 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: solvrdlg.cxx,v $
- * $Revision: 1.13 $
- *
- * 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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sc.hxx"
-
-
-
-//----------------------------------------------------------------------------
-
-#include "rangelst.hxx"
-#include "scitems.hxx"
-#include <sfx2/dispatch.hxx>
-#include <svtools/zforlist.hxx>
-#include <vcl/msgbox.hxx>
-
-#include "uiitems.hxx"
-#include "reffact.hxx"
-#include "document.hxx"
-#include "scresid.hxx"
-#include "solvrdlg.hrc"
-
-#define _SOLVRDLG_CXX
-#include "solvrdlg.hxx"
-#undef _SOLVERDLG_CXX
-
-
-#define ERRORBOX(s) ErrorBox( this, WinBits( WB_OK | WB_DEF_OK), s ).Execute()
-
-
-//============================================================================
-// class ScSolverDlg
-//----------------------------------------------------------------------------
-
-ScSolverDlg::ScSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
- ScDocument* pDocument,
- ScAddress aCursorPos )
-
- : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_SOLVER ),
- //
- aFlVariables ( this, ScResId( FL_VARIABLES ) ),
- aFtFormulaCell ( this, ScResId( FT_FORMULACELL ) ),
- aEdFormulaCell ( this, ScResId( ED_FORMULACELL ) ),
- aRBFormulaCell ( this, ScResId( RB_FORMULACELL ), &aEdFormulaCell, this ),
- aFtTargetVal ( this, ScResId( FT_TARGETVAL ) ),
- aEdTargetVal ( this, ScResId( ED_TARGETVAL ) ),
- aFtVariableCell ( this, ScResId( FT_VARCELL ) ),
- aEdVariableCell ( this, ScResId( ED_VARCELL ) ),
- aRBVariableCell ( this, ScResId( RB_VARCELL ), &aEdVariableCell, this ),
- aBtnOk ( this, ScResId( BTN_OK ) ),
- aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
- aBtnHelp ( this, ScResId( BTN_HELP ) ),
- //
- theFormulaCell ( aCursorPos ),
- theVariableCell ( aCursorPos ),
- pDoc ( pDocument ),
- nCurTab ( aCursorPos.Tab() ),
- pEdActive ( NULL ),
- bDlgLostFocus ( FALSE ),
- errMsgInvalidVar ( ScResId( STR_INVALIDVAR ) ),
- errMsgInvalidForm ( ScResId( STR_INVALIDFORM ) ),
- errMsgNoFormula ( ScResId( STR_NOFORMULA ) ),
- errMsgInvalidVal ( ScResId( STR_INVALIDVAL ) )
-{
- Init();
- FreeResource();
-}
-
-//----------------------------------------------------------------------------
-
-__EXPORT ScSolverDlg::~ScSolverDlg()
-{
-}
-
-//----------------------------------------------------------------------------
-
-void __EXPORT ScSolverDlg::Init()
-{
- String aStr;
-
- aBtnOk. SetClickHdl ( LINK( this, ScSolverDlg, BtnHdl ) );
- aBtnCancel. SetClickHdl ( LINK( this, ScSolverDlg, BtnHdl ) );
-
- Link aLink = LINK( this, ScSolverDlg, GetFocusHdl );
- aEdFormulaCell. SetGetFocusHdl ( aLink );
- aRBFormulaCell. SetGetFocusHdl ( aLink );
- aEdVariableCell.SetGetFocusHdl ( aLink );
- aRBVariableCell.SetGetFocusHdl ( aLink );
- aEdTargetVal. SetGetFocusHdl ( aLink );
-
- aLink = LINK( this, ScSolverDlg, LoseFocusHdl );
- aEdFormulaCell. SetLoseFocusHdl ( aLink );
- aRBFormulaCell. SetLoseFocusHdl ( aLink );
- aEdVariableCell.SetLoseFocusHdl ( aLink );
- aRBVariableCell.SetLoseFocusHdl ( aLink );
-
- theFormulaCell.Format( aStr, SCA_ABS, NULL, pDoc->GetAddressConvention() );
-
- aEdFormulaCell.SetText( aStr );
- aEdFormulaCell.GrabFocus();
- pEdActive = &aEdFormulaCell;
-}
-
-//----------------------------------------------------------------------------
-
-BOOL __EXPORT ScSolverDlg::Close()
-{
- return DoClose( ScSolverDlgWrapper::GetChildWindowId() );
-}
-
-//----------------------------------------------------------------------------
-
-void ScSolverDlg::SetActive()
-{
- if ( bDlgLostFocus )
- {
- bDlgLostFocus = FALSE;
- if( pEdActive )
- pEdActive->GrabFocus();
- }
- else
- {
- GrabFocus();
- }
- RefInputDone();
-}
-
-//----------------------------------------------------------------------------
-
-void ScSolverDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
-{
- if( pEdActive )
- {
- if ( rRef.aStart != rRef.aEnd )
- RefInputStart(pEdActive);
-
- String aStr;
- ScAddress aAdr = rRef.aStart;
- USHORT nFmt = ( aAdr.Tab() == nCurTab )
- ? SCA_ABS
- : SCA_ABS_3D;
-
- aAdr.Format( aStr, nFmt, pDocP, pDocP->GetAddressConvention() );
- pEdActive->SetRefString( aStr );
-
- if ( pEdActive == &aEdFormulaCell )
- theFormulaCell = aAdr;
- else if ( pEdActive == &aEdVariableCell )
- theVariableCell = aAdr;
- }
-}
-
-//----------------------------------------------------------------------------
-
-void ScSolverDlg::RaiseError( ScSolverErr eError )
-{
- switch ( eError )
- {
- case SOLVERR_NOFORMULA:
- ERRORBOX( errMsgNoFormula );
- aEdFormulaCell.GrabFocus();
- break;
-
- case SOLVERR_INVALID_FORMULA:
- ERRORBOX( errMsgInvalidForm );
- aEdFormulaCell.GrabFocus();
- break;
-
- case SOLVERR_INVALID_VARIABLE:
- ERRORBOX( errMsgInvalidVar );
- aEdVariableCell.GrabFocus();
- break;
-
- case SOLVERR_INVALID_TARGETVALUE:
- ERRORBOX( errMsgInvalidVal );
- aEdTargetVal.GrabFocus();
- break;
- }
-}
-
-//----------------------------------------------------------------------------
-
-BOOL ScSolverDlg::IsRefInputMode() const
-{
- return pEdActive != NULL;
-}
-
-//----------------------------------------------------------------------------
-
-BOOL __EXPORT ScSolverDlg::CheckTargetValue( String& rStrVal )
-{
- sal_uInt32 n1 = 0;
- double n2;
-
- return pDoc->GetFormatTable()->IsNumberFormat( rStrVal, n1, n2 );
-}
-
-//----------------------------------------------------------------------------
-// Handler:
-
-IMPL_LINK( ScSolverDlg, BtnHdl, PushButton*, pBtn )
-{
- if ( pBtn == &aBtnOk )
- {
- theTargetValStr = aEdTargetVal.GetText();
-
- // Zu ueberpruefen:
- // 1. enthalten die Strings korrekte Tabellenkoordinaten/def.Namen?
- // 2. verweist die Formel-Koordinate wirklich auf eine Formelzelle?
- // 3. wurde ein korrekter Zielwert eingegeben
-
- const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
- USHORT nRes1 = theFormulaCell .Parse( aEdFormulaCell.GetText(), pDoc, eConv );
- USHORT nRes2 = theVariableCell.Parse( aEdVariableCell.GetText(), pDoc, eConv );
-
- if ( SCA_VALID == ( nRes1 & SCA_VALID ) )
- {
- if ( SCA_VALID == ( nRes2 & SCA_VALID ) )
- {
- if ( CheckTargetValue( theTargetValStr ) )
- {
- CellType eType;
- pDoc->GetCellType( theFormulaCell.Col(),
- theFormulaCell.Row(),
- theFormulaCell.Tab(),
- eType );
-
- if ( CELLTYPE_FORMULA == eType )
- {
- ScSolveParam aOutParam( theFormulaCell,
- theVariableCell,
- theTargetValStr );
- ScSolveItem aOutItem( SCITEM_SOLVEDATA, &aOutParam );
-
- SetDispatcherLock( FALSE );
-
- SwitchToDocument();
- GetBindings().GetDispatcher()->Execute( SID_SOLVE,
- SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
- &aOutItem, 0L, 0L );
- Close();
- }
- else RaiseError( SOLVERR_NOFORMULA );
- }
- else RaiseError( SOLVERR_INVALID_TARGETVALUE );
- }
- else RaiseError( SOLVERR_INVALID_VARIABLE );
- }
- else RaiseError( SOLVERR_INVALID_FORMULA );
- }
- else if ( pBtn == &aBtnCancel )
- {
- Close();
- }
-
- return 0;
-}
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScSolverDlg, GetFocusHdl, Control*, pCtrl )
-{
- Edit* pEdit = NULL;
- pEdActive = NULL;
-
- if( (pCtrl == (Control*)&aEdFormulaCell) || (pCtrl == (Control*)&aRBFormulaCell) )
- pEdit = pEdActive = &aEdFormulaCell;
- else if( (pCtrl == (Control*)&aEdVariableCell) || (pCtrl == (Control*)&aRBVariableCell) )
- pEdit = pEdActive = &aEdVariableCell;
- else if( pCtrl == (Control*)&aEdTargetVal )
- pEdit = &aEdTargetVal;
-
- if( pEdit )
- pEdit->SetSelection( Selection( 0, SELECTION_MAX ) );
-
- return 0;
-}
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScSolverDlg, LoseFocusHdl, Control*, EMPTYARG )
-{
- bDlgLostFocus = !IsActive();
- return 0;
-}
-
-
-
-
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: solvrdlg.cxx,v $
+ * $Revision: 1.13 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//----------------------------------------------------------------------------
+
+#include "rangelst.hxx"
+#include "scitems.hxx"
+#include <sfx2/dispatch.hxx>
+#include <svtools/zforlist.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "uiitems.hxx"
+#include "reffact.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "solvrdlg.hrc"
+
+#define _SOLVRDLG_CXX
+#include "solvrdlg.hxx"
+#undef _SOLVERDLG_CXX
+
+
+#define ERRORBOX(s) ErrorBox( this, WinBits( WB_OK | WB_DEF_OK), s ).Execute()
+
+
+//============================================================================
+// class ScSolverDlg
+//----------------------------------------------------------------------------
+
+ScSolverDlg::ScSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScDocument* pDocument,
+ ScAddress aCursorPos )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_SOLVER ),
+ //
+ aFlVariables ( this, ScResId( FL_VARIABLES ) ),
+ aFtFormulaCell ( this, ScResId( FT_FORMULACELL ) ),
+ aEdFormulaCell ( this, ScResId( ED_FORMULACELL ) ),
+ aRBFormulaCell ( this, ScResId( RB_FORMULACELL ), &aEdFormulaCell, this ),
+ aFtTargetVal ( this, ScResId( FT_TARGETVAL ) ),
+ aEdTargetVal ( this, ScResId( ED_TARGETVAL ) ),
+ aFtVariableCell ( this, ScResId( FT_VARCELL ) ),
+ aEdVariableCell ( this, ScResId( ED_VARCELL ) ),
+ aRBVariableCell ( this, ScResId( RB_VARCELL ), &aEdVariableCell, this ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ //
+ theFormulaCell ( aCursorPos ),
+ theVariableCell ( aCursorPos ),
+ pDoc ( pDocument ),
+ nCurTab ( aCursorPos.Tab() ),
+ pEdActive ( NULL ),
+ bDlgLostFocus ( FALSE ),
+ errMsgInvalidVar ( ScResId( STR_INVALIDVAR ) ),
+ errMsgInvalidForm ( ScResId( STR_INVALIDFORM ) ),
+ errMsgNoFormula ( ScResId( STR_NOFORMULA ) ),
+ errMsgInvalidVal ( ScResId( STR_INVALIDVAL ) )
+{
+ Init();
+ FreeResource();
+}
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScSolverDlg::~ScSolverDlg()
+{
+}
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScSolverDlg::Init()
+{
+ String aStr;
+
+ aBtnOk. SetClickHdl ( LINK( this, ScSolverDlg, BtnHdl ) );
+ aBtnCancel. SetClickHdl ( LINK( this, ScSolverDlg, BtnHdl ) );
+
+ Link aLink = LINK( this, ScSolverDlg, GetFocusHdl );
+ aEdFormulaCell. SetGetFocusHdl ( aLink );
+ aRBFormulaCell. SetGetFocusHdl ( aLink );
+ aEdVariableCell.SetGetFocusHdl ( aLink );
+ aRBVariableCell.SetGetFocusHdl ( aLink );
+ aEdTargetVal. SetGetFocusHdl ( aLink );
+
+ aLink = LINK( this, ScSolverDlg, LoseFocusHdl );
+ aEdFormulaCell. SetLoseFocusHdl ( aLink );
+ aRBFormulaCell. SetLoseFocusHdl ( aLink );
+ aEdVariableCell.SetLoseFocusHdl ( aLink );
+ aRBVariableCell.SetLoseFocusHdl ( aLink );
+
+ theFormulaCell.Format( aStr, SCA_ABS, NULL, pDoc->GetAddressConvention() );
+
+ aEdFormulaCell.SetText( aStr );
+ aEdFormulaCell.GrabFocus();
+ pEdActive = &aEdFormulaCell;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScSolverDlg::Close()
+{
+ return DoClose( ScSolverDlgWrapper::GetChildWindowId() );
+}
+
+//----------------------------------------------------------------------------
+
+void ScSolverDlg::SetActive()
+{
+ if ( bDlgLostFocus )
+ {
+ bDlgLostFocus = FALSE;
+ if( pEdActive )
+ pEdActive->GrabFocus();
+ }
+ else
+ {
+ GrabFocus();
+ }
+ RefInputDone();
+}
+
+//----------------------------------------------------------------------------
+
+void ScSolverDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if( pEdActive )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart(pEdActive);
+
+ String aStr;
+ ScAddress aAdr = rRef.aStart;
+ USHORT nFmt = ( aAdr.Tab() == nCurTab )
+ ? SCA_ABS
+ : SCA_ABS_3D;
+
+ aAdr.Format( aStr, nFmt, pDocP, pDocP->GetAddressConvention() );
+ pEdActive->SetRefString( aStr );
+
+ if ( pEdActive == &aEdFormulaCell )
+ theFormulaCell = aAdr;
+ else if ( pEdActive == &aEdVariableCell )
+ theVariableCell = aAdr;
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScSolverDlg::RaiseError( ScSolverErr eError )
+{
+ switch ( eError )
+ {
+ case SOLVERR_NOFORMULA:
+ ERRORBOX( errMsgNoFormula );
+ aEdFormulaCell.GrabFocus();
+ break;
+
+ case SOLVERR_INVALID_FORMULA:
+ ERRORBOX( errMsgInvalidForm );
+ aEdFormulaCell.GrabFocus();
+ break;
+
+ case SOLVERR_INVALID_VARIABLE:
+ ERRORBOX( errMsgInvalidVar );
+ aEdVariableCell.GrabFocus();
+ break;
+
+ case SOLVERR_INVALID_TARGETVALUE:
+ ERRORBOX( errMsgInvalidVal );
+ aEdTargetVal.GrabFocus();
+ break;
+ }
+}
+
+//----------------------------------------------------------------------------
+
+BOOL ScSolverDlg::IsRefInputMode() const
+{
+ return pEdActive != NULL;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScSolverDlg::CheckTargetValue( String& rStrVal )
+{
+ sal_uInt32 n1 = 0;
+ double n2;
+
+ return pDoc->GetFormatTable()->IsNumberFormat( rStrVal, n1, n2 );
+}
+
+//----------------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScSolverDlg, BtnHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &aBtnOk )
+ {
+ theTargetValStr = aEdTargetVal.GetText();
+
+ // Zu ueberpruefen:
+ // 1. enthalten die Strings korrekte Tabellenkoordinaten/def.Namen?
+ // 2. verweist die Formel-Koordinate wirklich auf eine Formelzelle?
+ // 3. wurde ein korrekter Zielwert eingegeben
+
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ USHORT nRes1 = theFormulaCell .Parse( aEdFormulaCell.GetText(), pDoc, eConv );
+ USHORT nRes2 = theVariableCell.Parse( aEdVariableCell.GetText(), pDoc, eConv );
+
+ if ( SCA_VALID == ( nRes1 & SCA_VALID ) )
+ {
+ if ( SCA_VALID == ( nRes2 & SCA_VALID ) )
+ {
+ if ( CheckTargetValue( theTargetValStr ) )
+ {
+ CellType eType;
+ pDoc->GetCellType( theFormulaCell.Col(),
+ theFormulaCell.Row(),
+ theFormulaCell.Tab(),
+ eType );
+
+ if ( CELLTYPE_FORMULA == eType )
+ {
+ ScSolveParam aOutParam( theFormulaCell,
+ theVariableCell,
+ theTargetValStr );
+ ScSolveItem aOutItem( SCITEM_SOLVEDATA, &aOutParam );
+
+ SetDispatcherLock( FALSE );
+
+ SwitchToDocument();
+ GetBindings().GetDispatcher()->Execute( SID_SOLVE,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ &aOutItem, 0L, 0L );
+ Close();
+ }
+ else RaiseError( SOLVERR_NOFORMULA );
+ }
+ else RaiseError( SOLVERR_INVALID_TARGETVALUE );
+ }
+ else RaiseError( SOLVERR_INVALID_VARIABLE );
+ }
+ else RaiseError( SOLVERR_INVALID_FORMULA );
+ }
+ else if ( pBtn == &aBtnCancel )
+ {
+ Close();
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScSolverDlg, GetFocusHdl, Control*, pCtrl )
+{
+ Edit* pEdit = NULL;
+ pEdActive = NULL;
+
+ if( (pCtrl == (Control*)&aEdFormulaCell) || (pCtrl == (Control*)&aRBFormulaCell) )
+ pEdit = pEdActive = &aEdFormulaCell;
+ else if( (pCtrl == (Control*)&aEdVariableCell) || (pCtrl == (Control*)&aRBVariableCell) )
+ pEdit = pEdActive = &aEdVariableCell;
+ else if( pCtrl == (Control*)&aEdTargetVal )
+ pEdit = &aEdTargetVal;
+
+ if( pEdit )
+ pEdit->SetSelection( Selection( 0, SELECTION_MAX ) );
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScSolverDlg, LoseFocusHdl, Control*, EMPTYARG )
+{
+ bDlgLostFocus = !IsActive();
+ return 0;
+}
+
+
+
+
diff --git a/sc/source/ui/miscdlgs/tabopdlg.cxx b/sc/source/ui/miscdlgs/tabopdlg.cxx
index f819579b7601..0409f94c3d35 100644
--- a/sc/source/ui/miscdlgs/tabopdlg.cxx
+++ b/sc/source/ui/miscdlgs/tabopdlg.cxx
@@ -1,374 +1,374 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: tabopdlg.cxx,v $
- * $Revision: 1.12 $
- *
- * 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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sc.hxx"
-
-
-
-//----------------------------------------------------------------------------
-
-#include "scitems.hxx"
-#include <sfx2/dispatch.hxx>
-#include <vcl/msgbox.hxx>
-
-#include "uiitems.hxx"
-#include "global.hxx"
-#include "document.hxx"
-#include "scresid.hxx"
-#include "sc.hrc"
-#include "reffact.hxx"
-#include "tabopdlg.hrc"
-
-#define _TABOPDLG_CXX
-#include "tabopdlg.hxx"
-
-
-//============================================================================
-// class ScTabOpDlg
-//----------------------------------------------------------------------------
-
-ScTabOpDlg::ScTabOpDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
- ScDocument* pDocument,
- const ScRefAddress& rCursorPos )
-
- : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_TABOP ),
- //
- aFlVariables ( this, ScResId( FL_VARIABLES ) ),
- aFtFormulaRange ( this, ScResId( FT_FORMULARANGE ) ),
- aEdFormulaRange ( this, ScResId( ED_FORMULARANGE ) ),
- aRBFormulaRange ( this, ScResId( RB_FORMULARANGE ), &aEdFormulaRange, this ),
- aFtRowCell ( this, ScResId( FT_ROWCELL ) ),
- aEdRowCell ( this, ScResId( ED_ROWCELL ) ),
- aRBRowCell ( this, ScResId( RB_ROWCELL ), &aEdRowCell, this ),
- aFtColCell ( this, ScResId( FT_COLCELL ) ),
- aEdColCell ( this, ScResId( ED_COLCELL ) ),
- aRBColCell ( this, ScResId( RB_COLCELL ), &aEdColCell, this ),
- aBtnOk ( this, ScResId( BTN_OK ) ),
- aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
- aBtnHelp ( this, ScResId( BTN_HELP ) ),
- //
- theFormulaCell ( rCursorPos ),
- pDoc ( pDocument ),
- nCurTab ( theFormulaCell.Tab() ),
- pEdActive ( NULL ),
- bDlgLostFocus ( FALSE ),
- errMsgNoFormula ( ScResId( STR_NOFORMULA ) ),
- errMsgNoColRow ( ScResId( STR_NOCOLROW ) ),
- errMsgWrongFormula ( ScResId( STR_WRONGFORMULA ) ),
- errMsgWrongRowCol ( ScResId( STR_WRONGROWCOL ) ),
- errMsgNoColFormula ( ScResId( STR_NOCOLFORMULA ) ),
- errMsgNoRowFormula ( ScResId( STR_NOROWFORMULA ) )
-{
- Init();
- FreeResource();
-}
-
-//----------------------------------------------------------------------------
-
-__EXPORT ScTabOpDlg::~ScTabOpDlg()
-{
- Hide();
-}
-
-//----------------------------------------------------------------------------
-
-void __EXPORT ScTabOpDlg::Init()
-{
- aBtnOk. SetClickHdl ( LINK( this, ScTabOpDlg, BtnHdl ) );
- aBtnCancel. SetClickHdl ( LINK( this, ScTabOpDlg, BtnHdl ) );
-
- Link aLink = LINK( this, ScTabOpDlg, GetFocusHdl );
- aEdFormulaRange.SetGetFocusHdl( aLink );
- aRBFormulaRange.SetGetFocusHdl( aLink );
- aEdRowCell. SetGetFocusHdl( aLink );
- aRBRowCell. SetGetFocusHdl( aLink );
- aEdColCell. SetGetFocusHdl( aLink );
- aRBColCell. SetGetFocusHdl( aLink );
-
- aLink = LINK( this, ScTabOpDlg, LoseFocusHdl );
- aEdFormulaRange.SetLoseFocusHdl( aLink );
- aRBFormulaRange.SetLoseFocusHdl( aLink );
- aEdRowCell. SetLoseFocusHdl( aLink );
- aRBRowCell. SetLoseFocusHdl( aLink );
- aEdColCell. SetLoseFocusHdl( aLink );
- aRBColCell. SetLoseFocusHdl( aLink );
-
- aEdFormulaRange.GrabFocus();
- pEdActive = &aEdFormulaRange;
-
- //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
- //SFX_APPWINDOW->Enable();
-}
-
-//----------------------------------------------------------------------------
-
-BOOL __EXPORT ScTabOpDlg::Close()
-{
- return DoClose( ScTabOpDlgWrapper::GetChildWindowId() );
-}
-
-//----------------------------------------------------------------------------
-
-void ScTabOpDlg::SetActive()
-{
- if ( bDlgLostFocus )
- {
- bDlgLostFocus = FALSE;
- if( pEdActive )
- pEdActive->GrabFocus();
- }
- else
- GrabFocus();
-
- RefInputDone();
-}
-
-//----------------------------------------------------------------------------
-
-void ScTabOpDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
-{
- if ( pEdActive )
- {
- ScAddress::Details aDetails(pDocP->GetAddressConvention(), 0, 0);
-
- if ( rRef.aStart != rRef.aEnd )
- RefInputStart(pEdActive);
-
- String aStr;
- USHORT nFmt = ( rRef.aStart.Tab() == nCurTab )
- ? SCR_ABS
- : SCR_ABS_3D;
-
- if ( pEdActive == &aEdFormulaRange )
- {
- theFormulaCell.Set( rRef.aStart, false, false, false);
- theFormulaEnd.Set( rRef.aEnd, false, false, false);
- rRef.Format( aStr, nFmt, pDocP, aDetails );
- }
- else if ( pEdActive == &aEdRowCell )
- {
- theRowCell.Set( rRef.aStart, false, false, false);
- rRef.aStart.Format( aStr, nFmt, pDocP, aDetails );
- }
- else if ( pEdActive == &aEdColCell )
- {
- theColCell.Set( rRef.aStart, false, false, false);
- rRef.aStart.Format( aStr, nFmt, pDocP, aDetails );
- }
-
- pEdActive->SetRefString( aStr );
- }
-}
-
-//----------------------------------------------------------------------------
-
-void ScTabOpDlg::RaiseError( ScTabOpErr eError )
-{
- const String* pMsg = &errMsgNoFormula;
- Edit* pEd = &aEdFormulaRange;
-
- switch ( eError )
- {
- case TABOPERR_NOFORMULA:
- pMsg = &errMsgNoFormula;
- pEd = &aEdFormulaRange;
- break;
-
- case TABOPERR_NOCOLROW:
- pMsg = &errMsgNoColRow;
- pEd = &aEdRowCell;
- break;
-
- case TABOPERR_WRONGFORMULA:
- pMsg = &errMsgWrongFormula;
- pEd = &aEdFormulaRange;
- break;
-
- case TABOPERR_WRONGROW:
- pMsg = &errMsgWrongRowCol;
- pEd = &aEdRowCell;
- break;
-
- case TABOPERR_NOCOLFORMULA:
- pMsg = &errMsgNoColFormula;
- pEd = &aEdFormulaRange;
- break;
-
- case TABOPERR_WRONGCOL:
- pMsg = &errMsgWrongRowCol;
- pEd = &aEdColCell;
- break;
-
- case TABOPERR_NOROWFORMULA:
- pMsg = &errMsgNoRowFormula;
- pEd = &aEdFormulaRange;
- break;
- }
-
- ErrorBox( this, WinBits( WB_OK_CANCEL | WB_DEF_OK), *pMsg ).Execute();
- pEd->GrabFocus();
-}
-
-//----------------------------------------------------------------------------
-
-BOOL lcl_Parse( const String& rString, ScDocument* pDoc, SCTAB nCurTab,
- ScRefAddress& rStart, ScRefAddress& rEnd )
-{
- BOOL bRet = FALSE;
- const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
- if ( rString.Search(':') != STRING_NOTFOUND )
- bRet = ConvertDoubleRef( pDoc, rString, nCurTab, rStart, rEnd, eConv );
- else
- {
- bRet = ConvertSingleRef( pDoc, rString, nCurTab, rStart, eConv );
- rEnd = rStart;
- }
- return bRet;
-}
-
-//----------------------------------------------------------------------------
-// Handler:
-
-IMPL_LINK( ScTabOpDlg, BtnHdl, PushButton*, pBtn )
-{
- if ( pBtn == &aBtnOk )
- {
- BYTE nMode = 3;
- USHORT nError = 0;
-
- // Zu ueberpruefen:
- // 1. enthalten die Strings korrekte Tabellenkoordinaten/def.Namen?
- // 2. IstFormelRang Zeile bei leerer Zeile bzw. Spalte bei leerer Spalte
- // bzw. Einfachreferenz bei beidem?
- // 3. Ist mindestens Zeile oder Spalte und Formel voll?
-
- if (aEdFormulaRange.GetText().Len() == 0)
- nError = TABOPERR_NOFORMULA;
- else if (aEdRowCell.GetText().Len() == 0 &&
- aEdColCell.GetText().Len() == 0)
- nError = TABOPERR_NOCOLROW;
- else if ( !lcl_Parse( aEdFormulaRange.GetText(), pDoc, nCurTab,
- theFormulaCell, theFormulaEnd ) )
- nError = TABOPERR_WRONGFORMULA;
- else
- {
- const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
- if (aEdRowCell.GetText().Len() > 0)
- {
- if (!ConvertSingleRef( pDoc, aEdRowCell.GetText(), nCurTab,
- theRowCell, eConv ))
- nError = TABOPERR_WRONGROW;
- else
- {
- if (aEdColCell.GetText().Len() == 0 &&
- theFormulaCell.Col() != theFormulaEnd.Col())
- nError = TABOPERR_NOCOLFORMULA;
- else
- nMode = 1;
- }
- }
- if (aEdColCell.GetText().Len() > 0)
- {
- if (!ConvertSingleRef( pDoc, aEdColCell.GetText(), nCurTab,
- theColCell, eConv ))
- nError = TABOPERR_WRONGCOL;
- else
- {
- if (nMode == 1) // beides
- {
- nMode = 2;
- ConvertSingleRef( pDoc, aEdFormulaRange.GetText(), nCurTab,
- theFormulaCell, eConv );
- }
- else if (theFormulaCell.Row() != theFormulaEnd.Row())
- nError = TABOPERR_NOROWFORMULA;
- else
- nMode = 0;
- }
- }
- }
-
- if (nError)
- RaiseError( (ScTabOpErr) nError );
- else
- {
- ScTabOpParam aOutParam( theFormulaCell,
- theFormulaEnd,
- theRowCell,
- theColCell,
- nMode );
- ScTabOpItem aOutItem( SID_TABOP, &aOutParam );
-
- SetDispatcherLock( FALSE );
- SwitchToDocument();
- GetBindings().GetDispatcher()->Execute( SID_TABOP,
- SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
- &aOutItem, 0L, 0L );
- Close();
- }
- }
- else if ( pBtn == &aBtnCancel )
- Close();
-
- return 0;
-}
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScTabOpDlg, GetFocusHdl, Control*, pCtrl )
-{
- if( (pCtrl == (Control*)&aEdFormulaRange) || (pCtrl == (Control*)&aRBFormulaRange) )
- pEdActive = &aEdFormulaRange;
- else if( (pCtrl == (Control*)&aEdRowCell) || (pCtrl == (Control*)&aRBRowCell) )
- pEdActive = &aEdRowCell;
- else if( (pCtrl == (Control*)&aEdColCell) || (pCtrl == (Control*)&aRBColCell) )
- pEdActive = &aEdColCell;
- else
- pEdActive = NULL;
-
- if( pEdActive )
- pEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
-
- return 0;
-}
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScTabOpDlg, LoseFocusHdl, Control*, EMPTYARG )
-{
- bDlgLostFocus = !IsActive();
- return 0;
-}
-
-
-
-
-
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: tabopdlg.cxx,v $
+ * $Revision: 1.12 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//----------------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <sfx2/dispatch.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "uiitems.hxx"
+#include "global.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "reffact.hxx"
+#include "tabopdlg.hrc"
+
+#define _TABOPDLG_CXX
+#include "tabopdlg.hxx"
+
+
+//============================================================================
+// class ScTabOpDlg
+//----------------------------------------------------------------------------
+
+ScTabOpDlg::ScTabOpDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScDocument* pDocument,
+ const ScRefAddress& rCursorPos )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_TABOP ),
+ //
+ aFlVariables ( this, ScResId( FL_VARIABLES ) ),
+ aFtFormulaRange ( this, ScResId( FT_FORMULARANGE ) ),
+ aEdFormulaRange ( this, ScResId( ED_FORMULARANGE ) ),
+ aRBFormulaRange ( this, ScResId( RB_FORMULARANGE ), &aEdFormulaRange, this ),
+ aFtRowCell ( this, ScResId( FT_ROWCELL ) ),
+ aEdRowCell ( this, ScResId( ED_ROWCELL ) ),
+ aRBRowCell ( this, ScResId( RB_ROWCELL ), &aEdRowCell, this ),
+ aFtColCell ( this, ScResId( FT_COLCELL ) ),
+ aEdColCell ( this, ScResId( ED_COLCELL ) ),
+ aRBColCell ( this, ScResId( RB_COLCELL ), &aEdColCell, this ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ //
+ theFormulaCell ( rCursorPos ),
+ pDoc ( pDocument ),
+ nCurTab ( theFormulaCell.Tab() ),
+ pEdActive ( NULL ),
+ bDlgLostFocus ( FALSE ),
+ errMsgNoFormula ( ScResId( STR_NOFORMULA ) ),
+ errMsgNoColRow ( ScResId( STR_NOCOLROW ) ),
+ errMsgWrongFormula ( ScResId( STR_WRONGFORMULA ) ),
+ errMsgWrongRowCol ( ScResId( STR_WRONGROWCOL ) ),
+ errMsgNoColFormula ( ScResId( STR_NOCOLFORMULA ) ),
+ errMsgNoRowFormula ( ScResId( STR_NOROWFORMULA ) )
+{
+ Init();
+ FreeResource();
+}
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScTabOpDlg::~ScTabOpDlg()
+{
+ Hide();
+}
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScTabOpDlg::Init()
+{
+ aBtnOk. SetClickHdl ( LINK( this, ScTabOpDlg, BtnHdl ) );
+ aBtnCancel. SetClickHdl ( LINK( this, ScTabOpDlg, BtnHdl ) );
+
+ Link aLink = LINK( this, ScTabOpDlg, GetFocusHdl );
+ aEdFormulaRange.SetGetFocusHdl( aLink );
+ aRBFormulaRange.SetGetFocusHdl( aLink );
+ aEdRowCell. SetGetFocusHdl( aLink );
+ aRBRowCell. SetGetFocusHdl( aLink );
+ aEdColCell. SetGetFocusHdl( aLink );
+ aRBColCell. SetGetFocusHdl( aLink );
+
+ aLink = LINK( this, ScTabOpDlg, LoseFocusHdl );
+ aEdFormulaRange.SetLoseFocusHdl( aLink );
+ aRBFormulaRange.SetLoseFocusHdl( aLink );
+ aEdRowCell. SetLoseFocusHdl( aLink );
+ aRBRowCell. SetLoseFocusHdl( aLink );
+ aEdColCell. SetLoseFocusHdl( aLink );
+ aRBColCell. SetLoseFocusHdl( aLink );
+
+ aEdFormulaRange.GrabFocus();
+ pEdActive = &aEdFormulaRange;
+
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable();
+}
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScTabOpDlg::Close()
+{
+ return DoClose( ScTabOpDlgWrapper::GetChildWindowId() );
+}
+
+//----------------------------------------------------------------------------
+
+void ScTabOpDlg::SetActive()
+{
+ if ( bDlgLostFocus )
+ {
+ bDlgLostFocus = FALSE;
+ if( pEdActive )
+ pEdActive->GrabFocus();
+ }
+ else
+ GrabFocus();
+
+ RefInputDone();
+}
+
+//----------------------------------------------------------------------------
+
+void ScTabOpDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( pEdActive )
+ {
+ ScAddress::Details aDetails(pDocP->GetAddressConvention(), 0, 0);
+
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart(pEdActive);
+
+ String aStr;
+ USHORT nFmt = ( rRef.aStart.Tab() == nCurTab )
+ ? SCR_ABS
+ : SCR_ABS_3D;
+
+ if ( pEdActive == &aEdFormulaRange )
+ {
+ theFormulaCell.Set( rRef.aStart, false, false, false);
+ theFormulaEnd.Set( rRef.aEnd, false, false, false);
+ rRef.Format( aStr, nFmt, pDocP, aDetails );
+ }
+ else if ( pEdActive == &aEdRowCell )
+ {
+ theRowCell.Set( rRef.aStart, false, false, false);
+ rRef.aStart.Format( aStr, nFmt, pDocP, aDetails );
+ }
+ else if ( pEdActive == &aEdColCell )
+ {
+ theColCell.Set( rRef.aStart, false, false, false);
+ rRef.aStart.Format( aStr, nFmt, pDocP, aDetails );
+ }
+
+ pEdActive->SetRefString( aStr );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScTabOpDlg::RaiseError( ScTabOpErr eError )
+{
+ const String* pMsg = &errMsgNoFormula;
+ Edit* pEd = &aEdFormulaRange;
+
+ switch ( eError )
+ {
+ case TABOPERR_NOFORMULA:
+ pMsg = &errMsgNoFormula;
+ pEd = &aEdFormulaRange;
+ break;
+
+ case TABOPERR_NOCOLROW:
+ pMsg = &errMsgNoColRow;
+ pEd = &aEdRowCell;
+ break;
+
+ case TABOPERR_WRONGFORMULA:
+ pMsg = &errMsgWrongFormula;
+ pEd = &aEdFormulaRange;
+ break;
+
+ case TABOPERR_WRONGROW:
+ pMsg = &errMsgWrongRowCol;
+ pEd = &aEdRowCell;
+ break;
+
+ case TABOPERR_NOCOLFORMULA:
+ pMsg = &errMsgNoColFormula;
+ pEd = &aEdFormulaRange;
+ break;
+
+ case TABOPERR_WRONGCOL:
+ pMsg = &errMsgWrongRowCol;
+ pEd = &aEdColCell;
+ break;
+
+ case TABOPERR_NOROWFORMULA:
+ pMsg = &errMsgNoRowFormula;
+ pEd = &aEdFormulaRange;
+ break;
+ }
+
+ ErrorBox( this, WinBits( WB_OK_CANCEL | WB_DEF_OK), *pMsg ).Execute();
+ pEd->GrabFocus();
+}
+
+//----------------------------------------------------------------------------
+
+BOOL lcl_Parse( const String& rString, ScDocument* pDoc, SCTAB nCurTab,
+ ScRefAddress& rStart, ScRefAddress& rEnd )
+{
+ BOOL bRet = FALSE;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ if ( rString.Search(':') != STRING_NOTFOUND )
+ bRet = ConvertDoubleRef( pDoc, rString, nCurTab, rStart, rEnd, eConv );
+ else
+ {
+ bRet = ConvertSingleRef( pDoc, rString, nCurTab, rStart, eConv );
+ rEnd = rStart;
+ }
+ return bRet;
+}
+
+//----------------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScTabOpDlg, BtnHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &aBtnOk )
+ {
+ BYTE nMode = 3;
+ USHORT nError = 0;
+
+ // Zu ueberpruefen:
+ // 1. enthalten die Strings korrekte Tabellenkoordinaten/def.Namen?
+ // 2. IstFormelRang Zeile bei leerer Zeile bzw. Spalte bei leerer Spalte
+ // bzw. Einfachreferenz bei beidem?
+ // 3. Ist mindestens Zeile oder Spalte und Formel voll?
+
+ if (aEdFormulaRange.GetText().Len() == 0)
+ nError = TABOPERR_NOFORMULA;
+ else if (aEdRowCell.GetText().Len() == 0 &&
+ aEdColCell.GetText().Len() == 0)
+ nError = TABOPERR_NOCOLROW;
+ else if ( !lcl_Parse( aEdFormulaRange.GetText(), pDoc, nCurTab,
+ theFormulaCell, theFormulaEnd ) )
+ nError = TABOPERR_WRONGFORMULA;
+ else
+ {
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ if (aEdRowCell.GetText().Len() > 0)
+ {
+ if (!ConvertSingleRef( pDoc, aEdRowCell.GetText(), nCurTab,
+ theRowCell, eConv ))
+ nError = TABOPERR_WRONGROW;
+ else
+ {
+ if (aEdColCell.GetText().Len() == 0 &&
+ theFormulaCell.Col() != theFormulaEnd.Col())
+ nError = TABOPERR_NOCOLFORMULA;
+ else
+ nMode = 1;
+ }
+ }
+ if (aEdColCell.GetText().Len() > 0)
+ {
+ if (!ConvertSingleRef( pDoc, aEdColCell.GetText(), nCurTab,
+ theColCell, eConv ))
+ nError = TABOPERR_WRONGCOL;
+ else
+ {
+ if (nMode == 1) // beides
+ {
+ nMode = 2;
+ ConvertSingleRef( pDoc, aEdFormulaRange.GetText(), nCurTab,
+ theFormulaCell, eConv );
+ }
+ else if (theFormulaCell.Row() != theFormulaEnd.Row())
+ nError = TABOPERR_NOROWFORMULA;
+ else
+ nMode = 0;
+ }
+ }
+ }
+
+ if (nError)
+ RaiseError( (ScTabOpErr) nError );
+ else
+ {
+ ScTabOpParam aOutParam( theFormulaCell,
+ theFormulaEnd,
+ theRowCell,
+ theColCell,
+ nMode );
+ ScTabOpItem aOutItem( SID_TABOP, &aOutParam );
+
+ SetDispatcherLock( FALSE );
+ SwitchToDocument();
+ GetBindings().GetDispatcher()->Execute( SID_TABOP,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ &aOutItem, 0L, 0L );
+ Close();
+ }
+ }
+ else if ( pBtn == &aBtnCancel )
+ Close();
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScTabOpDlg, GetFocusHdl, Control*, pCtrl )
+{
+ if( (pCtrl == (Control*)&aEdFormulaRange) || (pCtrl == (Control*)&aRBFormulaRange) )
+ pEdActive = &aEdFormulaRange;
+ else if( (pCtrl == (Control*)&aEdRowCell) || (pCtrl == (Control*)&aRBRowCell) )
+ pEdActive = &aEdRowCell;
+ else if( (pCtrl == (Control*)&aEdColCell) || (pCtrl == (Control*)&aRBColCell) )
+ pEdActive = &aEdColCell;
+ else
+ pEdActive = NULL;
+
+ if( pEdActive )
+ pEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScTabOpDlg, LoseFocusHdl, Control*, EMPTYARG )
+{
+ bDlgLostFocus = !IsActive();
+ return 0;
+}
+
+
+
+
+
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 0709a84ad085..dabc36222df1 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -1,652 +1,652 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: namedlg.cxx,v $
- * $Revision: 1.11 $
- *
- * 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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sc.hxx"
-
-// System - Includes ---------------------------------------------------------
-
-
-
-// INCLUDE -------------------------------------------------------------------
-
-#include "global.hxx"
-#include "reffact.hxx"
-#include "document.hxx"
-#include "docfunc.hxx"
-#include "scresid.hxx"
-#include "globstr.hrc"
-#include "namedlg.hrc"
-
-#define _NAMEDLG_CXX
-#include "namedlg.hxx"
-#undef _NAMEDLG_CXX
-#include <vcl/msgbox.hxx>
-
-
-
-// defines -------------------------------------------------------------------
-
-#define ABS_SREF SCA_VALID \
- | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
-#define ABS_DREF ABS_SREF \
- | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
-#define ABS_SREF3D ABS_SREF | SCA_TAB_3D
-#define ABS_DREF3D ABS_DREF | SCA_TAB_3D
-
-
-//============================================================================
-// Hilfsklasse: Merken der aktuellen Bereichsoptionen,
-// wenn ein Name in der ComboBox gefunden wird.
-
-struct SaveData
-{
- SaveData()
- : bCriteria(FALSE),bPrintArea(FALSE),
- bColHeader(FALSE),bRowHeader(FALSE),
- bDirty(FALSE) {}
-
- void Clear()
- {
- aStrSymbol.Erase();
- bCriteria = bPrintArea =
- bColHeader = bRowHeader = FALSE;
- bDirty = TRUE;
- }
-
- String aStrSymbol;
- BOOL bCriteria:1;
- BOOL bPrintArea:1;
- BOOL bColHeader:1;
- BOOL bRowHeader:1;
- BOOL bDirty:1;
-};
-
-static SaveData* pSaveObj = NULL;
-
-#define SAVE_DATA() \
- pSaveObj->aStrSymbol = aEdAssign.GetText(); \
- pSaveObj->bCriteria = aBtnCriteria.IsChecked(); \
- pSaveObj->bPrintArea = aBtnPrintArea.IsChecked(); \
- pSaveObj->bColHeader = aBtnColHeader.IsChecked(); \
- pSaveObj->bRowHeader = aBtnRowHeader.IsChecked(); \
- pSaveObj->bDirty = TRUE;
-
-#define RESTORE_DATA() \
- if ( pSaveObj->bDirty ) \
- { \
- aEdAssign.SetText( pSaveObj->aStrSymbol ); \
- aBtnCriteria.Check( pSaveObj->bCriteria ); \
- aBtnPrintArea.Check( pSaveObj->bPrintArea ); \
- aBtnColHeader.Check( pSaveObj->bColHeader ); \
- aBtnRowHeader.Check( pSaveObj->bRowHeader ); \
- pSaveObj->bDirty = FALSE; \
- }
-
-#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute();
-
-
-//============================================================================
-// class ScNameDlg
-
-//----------------------------------------------------------------------------
-
-ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
- ScViewData* ptrViewData,
- const ScAddress& aCursorPos )
-
- : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_NAMES ),
- //
- aFlName ( this, ScResId( FL_NAME ) ),
- aEdName ( this, ScResId( ED_NAME ) ),
- //
- aFlAssign ( this, ScResId( FL_ASSIGN ) ),
- aEdAssign ( this, ScResId( ED_ASSIGN ) ),
- aRbAssign ( this, ScResId( RB_ASSIGN ), &aEdAssign, this ),
- //
- aFlType ( this, ScResId( FL_TYPE ) ),
- aBtnPrintArea ( this, ScResId( BTN_PRINTAREA ) ),
- aBtnColHeader ( this, ScResId( BTN_COLHEADER ) ),
- aBtnCriteria ( this, ScResId( BTN_CRITERIA ) ),
- aBtnRowHeader ( this, ScResId( BTN_ROWHEADER ) ),
- //
- aBtnOk ( this, ScResId( BTN_OK ) ),
- aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
- aBtnHelp ( this, ScResId( BTN_HELP ) ),
- aBtnAdd ( this, ScResId( BTN_ADD ) ),
- aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
- aBtnMore ( this, ScResId( BTN_MORE ) ),
- //
- bSaved (FALSE),
- aStrAdd ( ScResId( STR_ADD ) ),
- aStrModify ( ScResId( STR_MODIFY ) ),
- errMsgInvalidSym( ScResId( STR_INVALIDSYMBOL ) ),
- //
- pViewData ( ptrViewData ),
- pDoc ( ptrViewData->GetDocument() ),
- aLocalRangeName ( *(pDoc->GetRangeName()) ),
- theCursorPos ( aCursorPos ) // zum Berechnen der Referenzen
-{
- pSaveObj = new SaveData;
- Init();
- FreeResource();
-}
-
-
-//----------------------------------------------------------------------------
-
-__EXPORT ScNameDlg::~ScNameDlg()
-{
- DELETEZ( pSaveObj );
-}
-
-
-//----------------------------------------------------------------------------
-
-void __EXPORT ScNameDlg::Init()
-{
- String aAreaStr;
- ScRange aRange;
-
- DBG_ASSERT( pViewData && pDoc, "ViewData oder Document nicht gefunden!" );
-
- aBtnOk.SetClickHdl ( LINK( this, ScNameDlg, OkBtnHdl ) );
- aBtnCancel.SetClickHdl ( LINK( this, ScNameDlg, CancelBtnHdl ) );
- aBtnAdd.SetClickHdl ( LINK( this, ScNameDlg, AddBtnHdl ) );
- aBtnRemove.SetClickHdl ( LINK( this, ScNameDlg, RemoveBtnHdl ) );
- aEdAssign.SetGetFocusHdl( LINK( this, ScNameDlg, AssignGetFocusHdl ) );
- aEdAssign.SetModifyHdl ( LINK( this, ScNameDlg, EdModifyHdl ) );
- aEdName.SetModifyHdl ( LINK( this, ScNameDlg, EdModifyHdl ) );
- aEdName.SetSelectHdl ( LINK( this, ScNameDlg, NameSelectHdl ) );
-
- aBtnCriteria .Hide();
- aBtnPrintArea.Hide();
- aBtnColHeader.Hide();
- aBtnRowHeader.Hide();
-
- aBtnMore.AddWindow( &aFlType );
- aBtnMore.AddWindow( &aBtnCriteria );
- aBtnMore.AddWindow( &aBtnPrintArea );
- aBtnMore.AddWindow( &aBtnColHeader );
- aBtnMore.AddWindow( &aBtnRowHeader );
-
- UpdateNames();
-
- pViewData->GetSimpleArea( aRange );
- aRange.Format( aAreaStr, ABS_DREF3D, pDoc,
- ScAddress::Details(pDoc->GetAddressConvention(), 0, 0) );
-
- theCurSel = Selection( 0, SELECTION_MAX );
- aEdAssign.GrabFocus();
- aEdAssign.SetText( aAreaStr );
- aEdAssign.SetSelection( theCurSel );
- aEdName.GrabFocus();
-
- aBtnAdd.Disable();
- aBtnRemove.Disable();
- if ( aEdName.GetEntryCount() > 0 )
- aBtnAdd.SetText( aStrAdd );
- UpdateChecks();
- EdModifyHdl( 0 );
-
- bSaved=TRUE;
- SAVE_DATA()
-
- //@BugID 54702
- //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
-}
-
-//----------------------------------------------------------------------------
-BOOL ScNameDlg::IsRefInputMode() const
-{
- return aEdAssign.IsEnabled();
-}
-
-void ScNameDlg::RefInputDone( BOOL bForced)
-{
- ScAnyRefDlg::RefInputDone(bForced);
- EdModifyHdl(&aEdAssign);
-}
-//----------------------------------------------------------------------------
-// Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
-// neue Selektion im Referenz-Edit angezeigt wird.
-
-
-void ScNameDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
-{
- if ( aEdAssign.IsEnabled() )
- {
- if ( rRef.aStart != rRef.aEnd )
- RefInputStart(&aEdAssign);
- String aRefStr;
- rRef.Format( aRefStr, ABS_DREF3D, pDocP,
- ScAddress::Details(pDocP->GetAddressConvention(), 0, 0) );
- aEdAssign.SetRefString( aRefStr );
- }
-}
-
-
-//----------------------------------------------------------------------------
-BOOL __EXPORT ScNameDlg::Close()
-{
- return DoClose( ScNameDlgWrapper::GetChildWindowId() );
-}
-
-
-//----------------------------------------------------------------------------
-
-void ScNameDlg::SetActive()
-{
- aEdAssign.GrabFocus();
- RefInputDone();
-}
-
-
-//----------------------------------------------------------------------------
-
-void __EXPORT ScNameDlg::UpdateChecks()
-{
- USHORT nCurPos=0;
-
- if(aLocalRangeName.SearchName( aEdName.GetText(), nCurPos))
- {
- ScRangeData* pData=(ScRangeData*)(aLocalRangeName.At( nCurPos ));
- aBtnCriteria .Check( pData->HasType( RT_CRITERIA ) );
- aBtnPrintArea.Check( pData->HasType( RT_PRINTAREA ) );
- aBtnColHeader.Check( pData->HasType( RT_COLHEADER ) );
- aBtnRowHeader.Check( pData->HasType( RT_ROWHEADER ) );
- }
-
- // Falls Edit-Feld leer ist: Typ-CheckBoxen deaktivieren:
-
- if ( aEdName.GetText().Len() != 0 )
- {
- if ( !aFlType.IsEnabled() )
- {
- aFlType .Enable();
- aBtnCriteria .Enable();
- aBtnPrintArea.Enable();
- aBtnColHeader.Enable();
- aBtnRowHeader.Enable();
- aFlAssign .Enable();
- aEdAssign .Enable();
- aRbAssign .Enable();
- }
- }
- else if ( aFlType.IsEnabled() )
- {
- aFlType .Disable();
- aBtnCriteria .Disable();
- aBtnPrintArea.Disable();
- aBtnColHeader.Disable();
- aBtnRowHeader.Disable();
- aFlAssign .Disable();
- aEdAssign .Disable();
- aRbAssign .Disable();
- }
-}
-
-
-//----------------------------------------------------------------------------
-
-void __EXPORT ScNameDlg::UpdateNames()
-{
- USHORT nRangeCount = aLocalRangeName.GetCount();
-
- aEdName.SetUpdateMode( FALSE );
- //-----------------------------------------------------------
- USHORT nNamePos = aEdName.GetTopEntry();
- aEdName.Clear();
-
- aEdAssign.SetText( EMPTY_STRING );
-
- if ( nRangeCount > 0 )
- {
- ScRangeData* pRangeData = NULL;
- String aString;
-
- for ( USHORT i=0; i<nRangeCount; i++ )
- {
- pRangeData = (ScRangeData*)(aLocalRangeName.At( i ));
- if ( pRangeData )
- {
- if ( !pRangeData->HasType( RT_DATABASE )
- && !pRangeData->HasType( RT_SHARED ) )
- {
- pRangeData->GetName( aString );
- aEdName.InsertEntry( aString );
- }
- }
- }
- }
- else
- {
- aBtnAdd.SetText( aStrAdd );
- aBtnAdd.Disable();
- aBtnRemove.Disable();
- }
- //-----------------------------------------------------------
- aEdName.SetUpdateMode( TRUE );
- aEdName.SetTopEntry(nNamePos);
- aEdName.Invalidate();
-}
-
-
-//----------------------------------------------------------------------------
-
-void __EXPORT ScNameDlg::CalcCurTableAssign( String& aAssign, USHORT nCurPos )
-{
- ScRangeData* pRangeData = (ScRangeData*)(aLocalRangeName.At( nCurPos ));
-
- if ( pRangeData )
- {
- rtl::OUStringBuffer sBuffer;
- pRangeData->UpdateSymbol( sBuffer, theCursorPos );
- aAssign = sBuffer;
- }
- else
- {
- aAssign.Erase();
- }
-}
-
-
-//----------------------------------------------------------------------------
-// Handler:
-// ========
-
-IMPL_LINK( ScNameDlg, OkBtnHdl, void *, EMPTYARG )
-{
- if ( aBtnAdd.IsEnabled() )
- AddBtnHdl( 0 );
-
- if ( !aBtnAdd.IsEnabled() && !aBtnRemove.IsEnabled() )
- {
- ScDocShell* pDocSh = pViewData->GetDocShell();
- ScDocFunc aFunc(*pDocSh);
- aFunc.ModifyRangeNames( aLocalRangeName, FALSE );
- Close();
- }
- return 0;
-}
-
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK_INLINE_START( ScNameDlg, CancelBtnHdl, void *, EMPTYARG )
-{
- Close();
- return 0;
-}
-IMPL_LINK_INLINE_END( ScNameDlg, CancelBtnHdl, void *, EMPTYARG )
-
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScNameDlg, AddBtnHdl, void *, EMPTYARG )
-{
- BOOL bAdded = FALSE;
- String aNewEntry = aEdName.GetText();
- USHORT nNamePos = aEdName.GetTopEntry();
- aNewEntry.EraseLeadingChars( ' ' );
- aNewEntry.EraseTrailingChars( ' ' );
-
- if ( aNewEntry.Len() > 0 )
- {
- if ( ScRangeData::IsNameValid( aNewEntry, pDoc ) )
- {
- if ( pDoc )
- {
- ScRangeData* pNewEntry = NULL;
- RangeType nType = RT_NAME;
- USHORT nFoundAt = 0;
- String theSymbol = aEdAssign.GetText();
- String aStrPos;
- String aStrArea;
-
- pNewEntry = new ScRangeData( pDoc,
- aNewEntry,
- theSymbol,
- theCursorPos,
- nType );
- if (pNewEntry)
- {
- nType = nType
- | (aBtnRowHeader .IsChecked() ? RT_ROWHEADER : RangeType(0))
- | (aBtnColHeader .IsChecked() ? RT_COLHEADER : RangeType(0))
- | (aBtnPrintArea .IsChecked() ? RT_PRINTAREA : RangeType(0))
- | (aBtnCriteria .IsChecked() ? RT_CRITERIA : RangeType(0));
- pNewEntry->AddType(nType);
- }
-
- // theSymbol gueltig?
- // (= konnte theSymbol im ScRangeData-Ctor
- // in ein Token-Array uebersetzt werden?)
- if ( 0 == pNewEntry->GetErrCode() )
- {
- // Eintrag bereits vorhanden? Dann vorher entfernen (=Aendern)
- if ( aLocalRangeName.SearchName( aNewEntry, nFoundAt ) )
- { // alten Index uebernehmen
- pNewEntry->SetIndex(
- ((ScRangeData*)(aLocalRangeName.At(nFoundAt)))->GetIndex() );
- aLocalRangeName.AtFree( nFoundAt );
- }
- else
- pSaveObj->Clear();
-
- if ( !aLocalRangeName.Insert( pNewEntry ) )
- delete pNewEntry;
-
- UpdateNames();
- bSaved=FALSE;
- RESTORE_DATA()
- aEdName.SetText(EMPTY_STRING);
- aEdName.GrabFocus();
- UpdateChecks();
- aBtnAdd.SetText( aStrAdd );
- aBtnAdd.Disable();
- aBtnRemove.Disable();
-
- //@BugID 54702 raus mit dem Sch.
- //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
-
- bAdded = TRUE;
- }
- else // theSymbol ungueltig
- {
- delete pNewEntry;
- ERRORBOX( errMsgInvalidSym );
- theCurSel = Selection( 0, SELECTION_MAX );
- aEdAssign.GrabFocus();
- }
- }
- }
- else
- {
- ERRORBOX( ScGlobal::GetRscString(STR_INVALIDNAME) );
- aEdName.SetSelection( Selection( 0, SELECTION_MAX ) );
- aEdName.GrabFocus();
- }
- }
-
- aEdName.SetTopEntry(nNamePos);
- return bAdded;
-}
-
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScNameDlg, RemoveBtnHdl, void *, EMPTYARG )
-{
- USHORT nRemoveAt = 0;
- const String aStrEntry = aEdName.GetText();
-
- if ( aLocalRangeName.SearchName( aStrEntry, nRemoveAt ) )
- {
- String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY );
- String aMsg = aStrDelMsg.GetToken( 0, '#' );
-
- aMsg += aStrEntry;
- aMsg += aStrDelMsg.GetToken( 1, '#' );
-
- if ( RET_YES ==
- QueryBox( this, WinBits( WB_YES_NO | WB_DEF_YES ), aMsg ).Execute() )
- {
- aLocalRangeName.AtFree( nRemoveAt );
- UpdateNames();
- UpdateChecks();
- bSaved=FALSE;
- RESTORE_DATA()
- theCurSel = Selection( 0, SELECTION_MAX );
- aBtnAdd.SetText( aStrAdd );
- aBtnAdd.Disable();
- aBtnRemove.Disable();
- }
- }
- return 0;
-}
-
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScNameDlg, NameSelectHdl, void *, EMPTYARG )
-{
- USHORT nAtPos;
-
- if ( aLocalRangeName.SearchName( aEdName.GetText(), nAtPos ) )
- {
- String aSymbol;
- ScRangeData* pData = (ScRangeData*)(aLocalRangeName.At( nAtPos ));
-
- if ( pData )
- {
- pData->GetSymbol( aSymbol );
- CalcCurTableAssign( aSymbol, nAtPos );
- aEdAssign.SetText( aSymbol );
- aBtnAdd.SetText( aStrModify );
- theCurSel = Selection( 0, SELECTION_MAX );
- }
- }
- UpdateChecks();
- return 0;
-}
-
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScNameDlg, EdModifyHdl, Edit *, pEd )
-{
- String theName = aEdName.GetText();
- String theSymbol = aEdAssign.GetText();
- BOOL bNameFound = (COMBOBOX_ENTRY_NOTFOUND
- != aEdName.GetEntryPos( theName ));
-
- if ( pEd == &aEdName )
- {
- if ( theName.Len() == 0 )
- {
- if ( aBtnAdd.GetText() != aStrAdd )
- aBtnAdd.SetText( aStrAdd );
- aBtnAdd.Disable();
- aBtnRemove.Disable();
- aFlAssign.Disable();
- aEdAssign.Disable();
- aRbAssign.Disable();
- //@BugID 54702 raus mit dem Sch.
- //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
- }
- else
- {
- if ( bNameFound )
- {
- if ( aBtnAdd.GetText() != aStrModify )
- aBtnAdd.SetText( aStrModify );
-
- aBtnRemove.Enable();
-
- if(!bSaved)
- {
- bSaved=TRUE;
- SAVE_DATA()
- }
- NameSelectHdl( 0 );
- }
- else
- {
- if ( aBtnAdd.GetText() != aStrAdd )
- aBtnAdd.SetText( aStrAdd );
- aBtnRemove.Disable();
-
- bSaved=FALSE;
- RESTORE_DATA()
- }
- theSymbol = aEdAssign.GetText();
-
- if ( theSymbol.Len() > 0 )
- aBtnAdd.Enable();
- else
- aBtnAdd.Disable();
-
- aFlAssign.Enable();
- aEdAssign.Enable();
- aRbAssign.Enable();
- //@BugID 54702 raus mit dem Sch.
- //SFX_APPWINDOW->Enable();
- }
- UpdateChecks();
- theCurSel = Selection( 0, SELECTION_MAX );
- }
- else if ( pEd == &aEdAssign )
- {
- if ( (theName.Len()>0) && (theSymbol.Len()>0) )
- {
- aBtnAdd.Enable();
- if ( bNameFound )
- aBtnRemove.Enable();
- }
- else
- {
- aBtnAdd.Disable();
- aBtnRemove.Disable();
- }
- }
- return 0;
-}
-
-//------------------------------------------------------------------------
-
-IMPL_LINK_INLINE_START( ScNameDlg, AssignGetFocusHdl, void *, EMPTYARG )
-{
- EdModifyHdl( &aEdAssign );
- return 0;
-}
-IMPL_LINK_INLINE_END( ScNameDlg, AssignGetFocusHdl, void *, EMPTYARG )
-
-
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: namedlg.cxx,v $
+ * $Revision: 1.11 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+// INCLUDE -------------------------------------------------------------------
+
+#include "global.hxx"
+#include "reffact.hxx"
+#include "document.hxx"
+#include "docfunc.hxx"
+#include "scresid.hxx"
+#include "globstr.hrc"
+#include "namedlg.hrc"
+
+#define _NAMEDLG_CXX
+#include "namedlg.hxx"
+#undef _NAMEDLG_CXX
+#include <vcl/msgbox.hxx>
+
+
+
+// defines -------------------------------------------------------------------
+
+#define ABS_SREF SCA_VALID \
+ | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
+#define ABS_DREF ABS_SREF \
+ | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
+#define ABS_SREF3D ABS_SREF | SCA_TAB_3D
+#define ABS_DREF3D ABS_DREF | SCA_TAB_3D
+
+
+//============================================================================
+// Hilfsklasse: Merken der aktuellen Bereichsoptionen,
+// wenn ein Name in der ComboBox gefunden wird.
+
+struct SaveData
+{
+ SaveData()
+ : bCriteria(FALSE),bPrintArea(FALSE),
+ bColHeader(FALSE),bRowHeader(FALSE),
+ bDirty(FALSE) {}
+
+ void Clear()
+ {
+ aStrSymbol.Erase();
+ bCriteria = bPrintArea =
+ bColHeader = bRowHeader = FALSE;
+ bDirty = TRUE;
+ }
+
+ String aStrSymbol;
+ BOOL bCriteria:1;
+ BOOL bPrintArea:1;
+ BOOL bColHeader:1;
+ BOOL bRowHeader:1;
+ BOOL bDirty:1;
+};
+
+static SaveData* pSaveObj = NULL;
+
+#define SAVE_DATA() \
+ pSaveObj->aStrSymbol = aEdAssign.GetText(); \
+ pSaveObj->bCriteria = aBtnCriteria.IsChecked(); \
+ pSaveObj->bPrintArea = aBtnPrintArea.IsChecked(); \
+ pSaveObj->bColHeader = aBtnColHeader.IsChecked(); \
+ pSaveObj->bRowHeader = aBtnRowHeader.IsChecked(); \
+ pSaveObj->bDirty = TRUE;
+
+#define RESTORE_DATA() \
+ if ( pSaveObj->bDirty ) \
+ { \
+ aEdAssign.SetText( pSaveObj->aStrSymbol ); \
+ aBtnCriteria.Check( pSaveObj->bCriteria ); \
+ aBtnPrintArea.Check( pSaveObj->bPrintArea ); \
+ aBtnColHeader.Check( pSaveObj->bColHeader ); \
+ aBtnRowHeader.Check( pSaveObj->bRowHeader ); \
+ pSaveObj->bDirty = FALSE; \
+ }
+
+#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute();
+
+
+//============================================================================
+// class ScNameDlg
+
+//----------------------------------------------------------------------------
+
+ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScViewData* ptrViewData,
+ const ScAddress& aCursorPos )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_NAMES ),
+ //
+ aFlName ( this, ScResId( FL_NAME ) ),
+ aEdName ( this, ScResId( ED_NAME ) ),
+ //
+ aFlAssign ( this, ScResId( FL_ASSIGN ) ),
+ aEdAssign ( this, ScResId( ED_ASSIGN ) ),
+ aRbAssign ( this, ScResId( RB_ASSIGN ), &aEdAssign, this ),
+ //
+ aFlType ( this, ScResId( FL_TYPE ) ),
+ aBtnPrintArea ( this, ScResId( BTN_PRINTAREA ) ),
+ aBtnColHeader ( this, ScResId( BTN_COLHEADER ) ),
+ aBtnCriteria ( this, ScResId( BTN_CRITERIA ) ),
+ aBtnRowHeader ( this, ScResId( BTN_ROWHEADER ) ),
+ //
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnAdd ( this, ScResId( BTN_ADD ) ),
+ aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
+ aBtnMore ( this, ScResId( BTN_MORE ) ),
+ //
+ bSaved (FALSE),
+ aStrAdd ( ScResId( STR_ADD ) ),
+ aStrModify ( ScResId( STR_MODIFY ) ),
+ errMsgInvalidSym( ScResId( STR_INVALIDSYMBOL ) ),
+ //
+ pViewData ( ptrViewData ),
+ pDoc ( ptrViewData->GetDocument() ),
+ aLocalRangeName ( *(pDoc->GetRangeName()) ),
+ theCursorPos ( aCursorPos ) // zum Berechnen der Referenzen
+{
+ pSaveObj = new SaveData;
+ Init();
+ FreeResource();
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScNameDlg::~ScNameDlg()
+{
+ DELETEZ( pSaveObj );
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScNameDlg::Init()
+{
+ String aAreaStr;
+ ScRange aRange;
+
+ DBG_ASSERT( pViewData && pDoc, "ViewData oder Document nicht gefunden!" );
+
+ aBtnOk.SetClickHdl ( LINK( this, ScNameDlg, OkBtnHdl ) );
+ aBtnCancel.SetClickHdl ( LINK( this, ScNameDlg, CancelBtnHdl ) );
+ aBtnAdd.SetClickHdl ( LINK( this, ScNameDlg, AddBtnHdl ) );
+ aBtnRemove.SetClickHdl ( LINK( this, ScNameDlg, RemoveBtnHdl ) );
+ aEdAssign.SetGetFocusHdl( LINK( this, ScNameDlg, AssignGetFocusHdl ) );
+ aEdAssign.SetModifyHdl ( LINK( this, ScNameDlg, EdModifyHdl ) );
+ aEdName.SetModifyHdl ( LINK( this, ScNameDlg, EdModifyHdl ) );
+ aEdName.SetSelectHdl ( LINK( this, ScNameDlg, NameSelectHdl ) );
+
+ aBtnCriteria .Hide();
+ aBtnPrintArea.Hide();
+ aBtnColHeader.Hide();
+ aBtnRowHeader.Hide();
+
+ aBtnMore.AddWindow( &aFlType );
+ aBtnMore.AddWindow( &aBtnCriteria );
+ aBtnMore.AddWindow( &aBtnPrintArea );
+ aBtnMore.AddWindow( &aBtnColHeader );
+ aBtnMore.AddWindow( &aBtnRowHeader );
+
+ UpdateNames();
+
+ pViewData->GetSimpleArea( aRange );
+ aRange.Format( aAreaStr, ABS_DREF3D, pDoc,
+ ScAddress::Details(pDoc->GetAddressConvention(), 0, 0) );
+
+ theCurSel = Selection( 0, SELECTION_MAX );
+ aEdAssign.GrabFocus();
+ aEdAssign.SetText( aAreaStr );
+ aEdAssign.SetSelection( theCurSel );
+ aEdName.GrabFocus();
+
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ if ( aEdName.GetEntryCount() > 0 )
+ aBtnAdd.SetText( aStrAdd );
+ UpdateChecks();
+ EdModifyHdl( 0 );
+
+ bSaved=TRUE;
+ SAVE_DATA()
+
+ //@BugID 54702
+ //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+}
+
+//----------------------------------------------------------------------------
+BOOL ScNameDlg::IsRefInputMode() const
+{
+ return aEdAssign.IsEnabled();
+}
+
+void ScNameDlg::RefInputDone( BOOL bForced)
+{
+ ScAnyRefDlg::RefInputDone(bForced);
+ EdModifyHdl(&aEdAssign);
+}
+//----------------------------------------------------------------------------
+// Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
+// neue Selektion im Referenz-Edit angezeigt wird.
+
+
+void ScNameDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( aEdAssign.IsEnabled() )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart(&aEdAssign);
+ String aRefStr;
+ rRef.Format( aRefStr, ABS_DREF3D, pDocP,
+ ScAddress::Details(pDocP->GetAddressConvention(), 0, 0) );
+ aEdAssign.SetRefString( aRefStr );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+BOOL __EXPORT ScNameDlg::Close()
+{
+ return DoClose( ScNameDlgWrapper::GetChildWindowId() );
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScNameDlg::SetActive()
+{
+ aEdAssign.GrabFocus();
+ RefInputDone();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScNameDlg::UpdateChecks()
+{
+ USHORT nCurPos=0;
+
+ if(aLocalRangeName.SearchName( aEdName.GetText(), nCurPos))
+ {
+ ScRangeData* pData=(ScRangeData*)(aLocalRangeName.At( nCurPos ));
+ aBtnCriteria .Check( pData->HasType( RT_CRITERIA ) );
+ aBtnPrintArea.Check( pData->HasType( RT_PRINTAREA ) );
+ aBtnColHeader.Check( pData->HasType( RT_COLHEADER ) );
+ aBtnRowHeader.Check( pData->HasType( RT_ROWHEADER ) );
+ }
+
+ // Falls Edit-Feld leer ist: Typ-CheckBoxen deaktivieren:
+
+ if ( aEdName.GetText().Len() != 0 )
+ {
+ if ( !aFlType.IsEnabled() )
+ {
+ aFlType .Enable();
+ aBtnCriteria .Enable();
+ aBtnPrintArea.Enable();
+ aBtnColHeader.Enable();
+ aBtnRowHeader.Enable();
+ aFlAssign .Enable();
+ aEdAssign .Enable();
+ aRbAssign .Enable();
+ }
+ }
+ else if ( aFlType.IsEnabled() )
+ {
+ aFlType .Disable();
+ aBtnCriteria .Disable();
+ aBtnPrintArea.Disable();
+ aBtnColHeader.Disable();
+ aBtnRowHeader.Disable();
+ aFlAssign .Disable();
+ aEdAssign .Disable();
+ aRbAssign .Disable();
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScNameDlg::UpdateNames()
+{
+ USHORT nRangeCount = aLocalRangeName.GetCount();
+
+ aEdName.SetUpdateMode( FALSE );
+ //-----------------------------------------------------------
+ USHORT nNamePos = aEdName.GetTopEntry();
+ aEdName.Clear();
+
+ aEdAssign.SetText( EMPTY_STRING );
+
+ if ( nRangeCount > 0 )
+ {
+ ScRangeData* pRangeData = NULL;
+ String aString;
+
+ for ( USHORT i=0; i<nRangeCount; i++ )
+ {
+ pRangeData = (ScRangeData*)(aLocalRangeName.At( i ));
+ if ( pRangeData )
+ {
+ if ( !pRangeData->HasType( RT_DATABASE )
+ && !pRangeData->HasType( RT_SHARED ) )
+ {
+ pRangeData->GetName( aString );
+ aEdName.InsertEntry( aString );
+ }
+ }
+ }
+ }
+ else
+ {
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ }
+ //-----------------------------------------------------------
+ aEdName.SetUpdateMode( TRUE );
+ aEdName.SetTopEntry(nNamePos);
+ aEdName.Invalidate();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScNameDlg::CalcCurTableAssign( String& aAssign, USHORT nCurPos )
+{
+ ScRangeData* pRangeData = (ScRangeData*)(aLocalRangeName.At( nCurPos ));
+
+ if ( pRangeData )
+ {
+ rtl::OUStringBuffer sBuffer;
+ pRangeData->UpdateSymbol( sBuffer, theCursorPos );
+ aAssign = sBuffer;
+ }
+ else
+ {
+ aAssign.Erase();
+ }
+}
+
+
+//----------------------------------------------------------------------------
+// Handler:
+// ========
+
+IMPL_LINK( ScNameDlg, OkBtnHdl, void *, EMPTYARG )
+{
+ if ( aBtnAdd.IsEnabled() )
+ AddBtnHdl( 0 );
+
+ if ( !aBtnAdd.IsEnabled() && !aBtnRemove.IsEnabled() )
+ {
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ ScDocFunc aFunc(*pDocSh);
+ aFunc.ModifyRangeNames( aLocalRangeName, FALSE );
+ Close();
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScNameDlg, CancelBtnHdl, void *, EMPTYARG )
+{
+ Close();
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScNameDlg, CancelBtnHdl, void *, EMPTYARG )
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScNameDlg, AddBtnHdl, void *, EMPTYARG )
+{
+ BOOL bAdded = FALSE;
+ String aNewEntry = aEdName.GetText();
+ USHORT nNamePos = aEdName.GetTopEntry();
+ aNewEntry.EraseLeadingChars( ' ' );
+ aNewEntry.EraseTrailingChars( ' ' );
+
+ if ( aNewEntry.Len() > 0 )
+ {
+ if ( ScRangeData::IsNameValid( aNewEntry, pDoc ) )
+ {
+ if ( pDoc )
+ {
+ ScRangeData* pNewEntry = NULL;
+ RangeType nType = RT_NAME;
+ USHORT nFoundAt = 0;
+ String theSymbol = aEdAssign.GetText();
+ String aStrPos;
+ String aStrArea;
+
+ pNewEntry = new ScRangeData( pDoc,
+ aNewEntry,
+ theSymbol,
+ theCursorPos,
+ nType );
+ if (pNewEntry)
+ {
+ nType = nType
+ | (aBtnRowHeader .IsChecked() ? RT_ROWHEADER : RangeType(0))
+ | (aBtnColHeader .IsChecked() ? RT_COLHEADER : RangeType(0))
+ | (aBtnPrintArea .IsChecked() ? RT_PRINTAREA : RangeType(0))
+ | (aBtnCriteria .IsChecked() ? RT_CRITERIA : RangeType(0));
+ pNewEntry->AddType(nType);
+ }
+
+ // theSymbol gueltig?
+ // (= konnte theSymbol im ScRangeData-Ctor
+ // in ein Token-Array uebersetzt werden?)
+ if ( 0 == pNewEntry->GetErrCode() )
+ {
+ // Eintrag bereits vorhanden? Dann vorher entfernen (=Aendern)
+ if ( aLocalRangeName.SearchName( aNewEntry, nFoundAt ) )
+ { // alten Index uebernehmen
+ pNewEntry->SetIndex(
+ ((ScRangeData*)(aLocalRangeName.At(nFoundAt)))->GetIndex() );
+ aLocalRangeName.AtFree( nFoundAt );
+ }
+ else
+ pSaveObj->Clear();
+
+ if ( !aLocalRangeName.Insert( pNewEntry ) )
+ delete pNewEntry;
+
+ UpdateNames();
+ bSaved=FALSE;
+ RESTORE_DATA()
+ aEdName.SetText(EMPTY_STRING);
+ aEdName.GrabFocus();
+ UpdateChecks();
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+
+ //@BugID 54702 raus mit dem Sch.
+ //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+
+ bAdded = TRUE;
+ }
+ else // theSymbol ungueltig
+ {
+ delete pNewEntry;
+ ERRORBOX( errMsgInvalidSym );
+ theCurSel = Selection( 0, SELECTION_MAX );
+ aEdAssign.GrabFocus();
+ }
+ }
+ }
+ else
+ {
+ ERRORBOX( ScGlobal::GetRscString(STR_INVALIDNAME) );
+ aEdName.SetSelection( Selection( 0, SELECTION_MAX ) );
+ aEdName.GrabFocus();
+ }
+ }
+
+ aEdName.SetTopEntry(nNamePos);
+ return bAdded;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScNameDlg, RemoveBtnHdl, void *, EMPTYARG )
+{
+ USHORT nRemoveAt = 0;
+ const String aStrEntry = aEdName.GetText();
+
+ if ( aLocalRangeName.SearchName( aStrEntry, nRemoveAt ) )
+ {
+ String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY );
+ String aMsg = aStrDelMsg.GetToken( 0, '#' );
+
+ aMsg += aStrEntry;
+ aMsg += aStrDelMsg.GetToken( 1, '#' );
+
+ if ( RET_YES ==
+ QueryBox( this, WinBits( WB_YES_NO | WB_DEF_YES ), aMsg ).Execute() )
+ {
+ aLocalRangeName.AtFree( nRemoveAt );
+ UpdateNames();
+ UpdateChecks();
+ bSaved=FALSE;
+ RESTORE_DATA()
+ theCurSel = Selection( 0, SELECTION_MAX );
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ }
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScNameDlg, NameSelectHdl, void *, EMPTYARG )
+{
+ USHORT nAtPos;
+
+ if ( aLocalRangeName.SearchName( aEdName.GetText(), nAtPos ) )
+ {
+ String aSymbol;
+ ScRangeData* pData = (ScRangeData*)(aLocalRangeName.At( nAtPos ));
+
+ if ( pData )
+ {
+ pData->GetSymbol( aSymbol );
+ CalcCurTableAssign( aSymbol, nAtPos );
+ aEdAssign.SetText( aSymbol );
+ aBtnAdd.SetText( aStrModify );
+ theCurSel = Selection( 0, SELECTION_MAX );
+ }
+ }
+ UpdateChecks();
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScNameDlg, EdModifyHdl, Edit *, pEd )
+{
+ String theName = aEdName.GetText();
+ String theSymbol = aEdAssign.GetText();
+ BOOL bNameFound = (COMBOBOX_ENTRY_NOTFOUND
+ != aEdName.GetEntryPos( theName ));
+
+ if ( pEd == &aEdName )
+ {
+ if ( theName.Len() == 0 )
+ {
+ if ( aBtnAdd.GetText() != aStrAdd )
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ aFlAssign.Disable();
+ aEdAssign.Disable();
+ aRbAssign.Disable();
+ //@BugID 54702 raus mit dem Sch.
+ //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+ }
+ else
+ {
+ if ( bNameFound )
+ {
+ if ( aBtnAdd.GetText() != aStrModify )
+ aBtnAdd.SetText( aStrModify );
+
+ aBtnRemove.Enable();
+
+ if(!bSaved)
+ {
+ bSaved=TRUE;
+ SAVE_DATA()
+ }
+ NameSelectHdl( 0 );
+ }
+ else
+ {
+ if ( aBtnAdd.GetText() != aStrAdd )
+ aBtnAdd.SetText( aStrAdd );
+ aBtnRemove.Disable();
+
+ bSaved=FALSE;
+ RESTORE_DATA()
+ }
+ theSymbol = aEdAssign.GetText();
+
+ if ( theSymbol.Len() > 0 )
+ aBtnAdd.Enable();
+ else
+ aBtnAdd.Disable();
+
+ aFlAssign.Enable();
+ aEdAssign.Enable();
+ aRbAssign.Enable();
+ //@BugID 54702 raus mit dem Sch.
+ //SFX_APPWINDOW->Enable();
+ }
+ UpdateChecks();
+ theCurSel = Selection( 0, SELECTION_MAX );
+ }
+ else if ( pEd == &aEdAssign )
+ {
+ if ( (theName.Len()>0) && (theSymbol.Len()>0) )
+ {
+ aBtnAdd.Enable();
+ if ( bNameFound )
+ aBtnRemove.Enable();
+ }
+ else
+ {
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ }
+ }
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScNameDlg, AssignGetFocusHdl, void *, EMPTYARG )
+{
+ EdModifyHdl( &aEdAssign );
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScNameDlg, AssignGetFocusHdl, void *, EMPTYARG )
+
+
diff --git a/sc/source/ui/pagedlg/areasdlg.cxx b/sc/source/ui/pagedlg/areasdlg.cxx
index bce864c71b11..2f7ac75019e0 100644
--- a/sc/source/ui/pagedlg/areasdlg.cxx
+++ b/sc/source/ui/pagedlg/areasdlg.cxx
@@ -1,909 +1,909 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: areasdlg.cxx,v $
- * $Revision: 1.18 $
- *
- * 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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sc.hxx"
-
-
-
-//----------------------------------------------------------------------------
-#include <rangelst.hxx>
-
-#include <sfx2/dispatch.hxx>
-#include <svtools/stritem.hxx>
-#include <vcl/msgbox.hxx>
-#include <unotools/charclass.hxx>
-#include <stdlib.h>
-
-#define _AREASDLG_CXX
-#include "areasdlg.hxx"
-#undef _AREASDLG_CXX
-
-#include "scresid.hxx"
-#include "rangenam.hxx"
-#include "reffact.hxx"
-#include "tabvwsh.hxx"
-#include "docsh.hxx"
-#include "globstr.hrc"
-#include "pagedlg.hrc"
-#include "compiler.hxx"
-
-// STATIC DATA ---------------------------------------------------------------
-
-// List box positions for print range (PR)
-const USHORT SC_AREASDLG_PR_NONE = 0;
-const USHORT SC_AREASDLG_PR_ENTIRE = 1;
-const USHORT SC_AREASDLG_PR_USER = 2;
-const USHORT SC_AREASDLG_PR_SELECT = 3;
-const USHORT SC_AREASDLG_PR_OFFSET = 4;
-
-// List box positions for repeat ranges (RR)
-const USHORT SC_AREASDLG_RR_NONE = 0;
-const USHORT SC_AREASDLG_RR_USER = 1;
-const USHORT SC_AREASDLG_RR_OFFSET = 2;
-
-//============================================================================
-
-#define HDL(hdl) LINK( this, ScPrintAreasDlg, hdl )
-#define ERRORBOX(nId) ErrorBox( this, WinBits(WB_OK|WB_DEF_OK), \
- ScGlobal::GetRscString( nId ) ).Execute()
-#define SWAP(x1,x2) { int n=x1; x1=x2; x2=n; }
-
-// globale Funktionen (->am Ende der Datei):
-
-bool lcl_CheckRepeatString( const String& rStr, ScDocument* pDoc, bool bIsRow, ScRange* pRange );
-void lcl_GetRepeatRangeString( const ScRange* pRange, ScDocument* pDoc, bool bIsRow, String& rStr );
-
-#if 0
-static void printAddressFlags(USHORT nFlag)
-{
- if ((nFlag & SCA_COL_ABSOLUTE ) == SCA_COL_ABSOLUTE ) printf("SCA_COL_ABSOLUTE \n");
- if ((nFlag & SCA_ROW_ABSOLUTE ) == SCA_ROW_ABSOLUTE ) printf("SCA_ROW_ABSOLUTE \n");
- if ((nFlag & SCA_TAB_ABSOLUTE ) == SCA_TAB_ABSOLUTE ) printf("SCA_TAB_ABSOLUTE \n");
- if ((nFlag & SCA_TAB_3D ) == SCA_TAB_3D ) printf("SCA_TAB_3D \n");
- if ((nFlag & SCA_COL2_ABSOLUTE ) == SCA_COL2_ABSOLUTE ) printf("SCA_COL2_ABSOLUTE\n");
- if ((nFlag & SCA_ROW2_ABSOLUTE ) == SCA_ROW2_ABSOLUTE ) printf("SCA_ROW2_ABSOLUTE\n");
- if ((nFlag & SCA_TAB2_ABSOLUTE ) == SCA_TAB2_ABSOLUTE ) printf("SCA_TAB2_ABSOLUTE\n");
- if ((nFlag & SCA_TAB2_3D ) == SCA_TAB2_3D ) printf("SCA_TAB2_3D \n");
- if ((nFlag & SCA_VALID_ROW ) == SCA_VALID_ROW ) printf("SCA_VALID_ROW \n");
- if ((nFlag & SCA_VALID_COL ) == SCA_VALID_COL ) printf("SCA_VALID_COL \n");
- if ((nFlag & SCA_VALID_TAB ) == SCA_VALID_TAB ) printf("SCA_VALID_TAB \n");
- if ((nFlag & SCA_FORCE_DOC ) == SCA_FORCE_DOC ) printf("SCA_FORCE_DOC \n");
- if ((nFlag & SCA_VALID_ROW2 ) == SCA_VALID_ROW2 ) printf("SCA_VALID_ROW2 \n");
- if ((nFlag & SCA_VALID_COL2 ) == SCA_VALID_COL2 ) printf("SCA_VALID_COL2 \n");
- if ((nFlag & SCA_VALID_TAB2 ) == SCA_VALID_TAB2 ) printf("SCA_VALID_TAB2 \n");
- if ((nFlag & SCA_VALID ) == SCA_VALID ) printf("SCA_VALID \n");
- if ((nFlag & SCA_ABS ) == SCA_ABS ) printf("SCA_ABS \n");
- if ((nFlag & SCR_ABS ) == SCR_ABS ) printf("SCR_ABS \n");
- if ((nFlag & SCA_ABS_3D ) == SCA_ABS_3D ) printf("SCA_ABS_3D \n");
- if ((nFlag & SCR_ABS_3D ) == SCR_ABS_3D ) printf("SCR_ABS_3D \n");
-}
-#endif
-
-//============================================================================
-// class ScPrintAreasDlg
-
-//----------------------------------------------------------------------------
-
-ScPrintAreasDlg::ScPrintAreasDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent )
- : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_AREAS),
- //
- aLbPrintArea ( this, ScResId( LB_PRINTAREA ) ),
- aFlPrintArea ( this, ScResId( FL_PRINTAREA ) ),
- aEdPrintArea ( this, ScResId( ED_PRINTAREA ) ),
- aRbPrintArea ( this, ScResId( RB_PRINTAREA ), &aEdPrintArea, this ),
- //
- aLbRepeatRow ( this, ScResId( LB_REPEATROW ) ),
- aFlRepeatRow ( this, ScResId( FL_REPEATROW ) ),
- aEdRepeatRow ( this, ScResId( ED_REPEATROW ) ),
- aRbRepeatRow ( this, ScResId( RB_REPEATROW ), &aEdRepeatRow, this ),
- //
- aLbRepeatCol ( this, ScResId( LB_REPEATCOL ) ),
- aFlRepeatCol ( this, ScResId( FL_REPEATCOL ) ),
- aEdRepeatCol ( this, ScResId( ED_REPEATCOL ) ),
- aRbRepeatCol ( this, ScResId( RB_REPEATCOL ), &aEdRepeatCol, this ),
- //
- aBtnOk ( this, ScResId( BTN_OK ) ),
- aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
- aBtnHelp ( this, ScResId( BTN_HELP ) ),
- //
- bDlgLostFocus ( FALSE ),
- pRefInputEdit ( &aEdPrintArea ),
- pDoc ( NULL ),
- pViewData ( NULL ),
- nCurTab ( 0 )
-{
- ScTabViewShell* pScViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
- ScDocShell* pScDocSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
-
- DBG_ASSERT( pScDocSh, "Current DocumentShell not found :-(" );
-
- pDoc = pScDocSh->GetDocument();
-
- if ( pScViewSh )
- {
- pViewData = pScViewSh->GetViewData();
- nCurTab = pViewData->GetTabNo();
- }
-
- Impl_Reset();
-
- //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
- //SFX_APPWINDOW->Enable();
-
- FreeResource();
-}
-
-
-//----------------------------------------------------------------------------
-
-ScPrintAreasDlg::~ScPrintAreasDlg()
-{
- // Extra-Data an ListBox-Entries abraeumen
- ListBox* pLb[3] = { &aLbPrintArea, &aLbRepeatRow, &aLbRepeatCol };
-
- for ( USHORT i=0; i<3; i++ )
- {
- USHORT nCount = pLb[i]->GetEntryCount();
- for ( USHORT j=0; j<nCount; j++ )
- delete (String*)pLb[i]->GetEntryData(j);
- }
-}
-
-
-//----------------------------------------------------------------------------
-
-BOOL ScPrintAreasDlg::Close()
-{
- return DoClose( ScPrintAreasDlgWrapper::GetChildWindowId() );
-}
-
-
-//----------------------------------------------------------------------------
-
-BOOL ScPrintAreasDlg::IsTableLocked() const
-{
- // Druckbereiche gelten pro Tabelle, darum macht es keinen Sinn,
- // bei der Eingabe die Tabelle umzuschalten
-
- return TRUE;
-}
-
-
-//----------------------------------------------------------------------------
-
-void ScPrintAreasDlg::SetReference( const ScRange& rRef, ScDocument* /* pDoc */ )
-{
- if ( pRefInputEdit )
- {
- if ( rRef.aStart != rRef.aEnd )
- RefInputStart( pRefInputEdit );
-
- String aStr;
- const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
-
- if ( &aEdPrintArea == pRefInputEdit )
- {
- rRef.Format( aStr, SCR_ABS, pDoc, eConv );
-
-// aEdPrintArea.ReplaceSelected( aStr );
-
- String aVal = aEdPrintArea.GetText();
- Selection aSel = aEdPrintArea.GetSelection();
- aSel.Justify();
- aVal.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() );
- aVal.Insert( aStr, (xub_StrLen)aSel.Min() );
- Selection aNewSel( aSel.Min(), aSel.Min()+aStr.Len() );
- aEdPrintArea.SetRefString( aVal );
- aEdPrintArea.SetSelection( aNewSel );
- }
- else
- {
- BOOL bRow = ( &aEdRepeatRow == pRefInputEdit );
- lcl_GetRepeatRangeString(&rRef, pDoc, bRow, aStr);
- pRefInputEdit->SetRefString( aStr );
- }
- }
-
- Impl_ModifyHdl( pRefInputEdit );
-}
-
-
-//----------------------------------------------------------------------------
-
-void ScPrintAreasDlg::AddRefEntry()
-{
- if ( pRefInputEdit == &aEdPrintArea )
- {
- const sal_Unicode sep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
- String aVal = aEdPrintArea.GetText();
- aVal += sep;
- aEdPrintArea.SetText(aVal);
-
- xub_StrLen nLen = aVal.Len();
- aEdPrintArea.SetSelection( Selection( nLen, nLen ) );
-
- Impl_ModifyHdl( &aEdPrintArea );
- }
-}
-
-
-//----------------------------------------------------------------------------
-
-void ScPrintAreasDlg::Deactivate()
-{
- bDlgLostFocus = TRUE;
-}
-
-
-//----------------------------------------------------------------------------
-
-void ScPrintAreasDlg::SetActive()
-{
- if ( bDlgLostFocus )
- {
- bDlgLostFocus = FALSE;
-
- if ( pRefInputEdit )
- {
- pRefInputEdit->GrabFocus();
- Impl_ModifyHdl( pRefInputEdit );
- }
- }
- else
- GrabFocus();
-
- RefInputDone();
-}
-
-
-//----------------------------------------------------------------------------
-
-void ScPrintAreasDlg::Impl_Reset()
-{
- String aStrRange;
- const ScRange* pRepeatColRange = pDoc->GetRepeatColRange( nCurTab );
- const ScRange* pRepeatRowRange = pDoc->GetRepeatRowRange( nCurTab );
-
- aEdPrintArea.SetModifyHdl ( HDL(Impl_ModifyHdl) );
- aEdRepeatRow.SetModifyHdl ( HDL(Impl_ModifyHdl) );
- aEdRepeatCol.SetModifyHdl ( HDL(Impl_ModifyHdl) );
- aEdPrintArea.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
- aEdRepeatRow.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
- aEdRepeatCol.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
- aLbPrintArea.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
- aLbRepeatRow.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
- aLbRepeatCol.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
- aLbPrintArea.SetSelectHdl ( HDL(Impl_SelectHdl) );
- aLbRepeatRow.SetSelectHdl ( HDL(Impl_SelectHdl) );
- aLbRepeatCol.SetSelectHdl ( HDL(Impl_SelectHdl) );
- aBtnOk .SetClickHdl ( HDL(Impl_BtnHdl) );
- aBtnCancel .SetClickHdl ( HDL(Impl_BtnHdl) );
-
- Impl_FillLists();
-
- //-------------------------
- // Druckbereich
- //-------------------------
- aStrRange.Erase();
- String aOne;
- const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
- const sal_Unicode sep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
- USHORT nRangeCount = pDoc->GetPrintRangeCount( nCurTab );
- for (USHORT i=0; i<nRangeCount; i++)
- {
- const ScRange* pPrintRange = pDoc->GetPrintRange( nCurTab, i );
- if (pPrintRange)
- {
- if ( aStrRange.Len() )
- aStrRange += sep;
- pPrintRange->Format( aOne, SCR_ABS, pDoc, eConv );
- aStrRange += aOne;
- }
- }
- aEdPrintArea.SetText( aStrRange );
-
- //-------------------------------
- // Wiederholungszeile
- //-------------------------------
- lcl_GetRepeatRangeString(pRepeatRowRange, pDoc, true, aStrRange);
- aEdRepeatRow.SetText( aStrRange );
-
- //--------------------------------
- // Wiederholungsspalte
- //--------------------------------
- lcl_GetRepeatRangeString(pRepeatColRange, pDoc, false, aStrRange);
- aEdRepeatCol.SetText( aStrRange );
-
- Impl_ModifyHdl( &aEdPrintArea );
- Impl_ModifyHdl( &aEdRepeatRow );
- Impl_ModifyHdl( &aEdRepeatCol );
- if( pDoc->IsPrintEntireSheet( nCurTab ) )
- aLbPrintArea.SelectEntryPos( SC_AREASDLG_PR_ENTIRE );
-
- aEdPrintArea.SaveValue(); // fuer FillItemSet() merken:
- aEdRepeatRow.SaveValue();
- aEdRepeatCol.SaveValue();
-}
-
-
-//----------------------------------------------------------------------------
-
-BOOL ScPrintAreasDlg::Impl_GetItem( Edit* pEd, SfxStringItem& rItem )
-{
- String aRangeStr = pEd->GetText();
- BOOL bDataChanged = (pEd->GetSavedValue() != aRangeStr);
-
- if ( (aRangeStr.Len() > 0) && &aEdPrintArea != pEd )
- {
- ScRange aRange;
- const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
- lcl_CheckRepeatString(aRangeStr, pDoc, &aEdRepeatRow == pEd, &aRange);
- aRange.Format(aRangeStr, SCR_ABS, pDoc, eConv);
- }
-
- rItem.SetValue( aRangeStr );
-
- return bDataChanged;
-}
-
-
-//----------------------------------------------------------------------------
-
-BOOL ScPrintAreasDlg::Impl_CheckRefStrings()
-{
- BOOL bOk = FALSE;
- String aStrPrintArea = aEdPrintArea.GetText();
- String aStrRepeatRow = aEdRepeatRow.GetText();
- String aStrRepeatCol = aEdRepeatCol.GetText();
-
- BOOL bPrintAreaOk = TRUE;
- if ( aStrPrintArea.Len() )
- {
- const USHORT nValidAddr = SCA_VALID | SCA_VALID_ROW | SCA_VALID_COL;
- const USHORT nValidRange = nValidAddr | SCA_VALID_ROW2 | SCA_VALID_COL2;
- const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
- const sal_Unicode sep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
- // const sal_Unicode rsep = ScCompiler::GetNativeSymbol(ocRange).GetChar(0);
-
- ScAddress aAddr;
- ScRange aRange;
- xub_StrLen nSepCount = aStrPrintArea.GetTokenCount(sep);
- for ( xub_StrLen i = 0; i < nSepCount && bPrintAreaOk; ++i )
- {
- String aOne = aStrPrintArea.GetToken(i, sep);
- USHORT nResult = aRange.Parse( aOne, pDoc, eConv );
- if ((nResult & nValidRange) != nValidRange)
- {
- USHORT nAddrResult = aAddr.Parse( aOne, pDoc, eConv );
- if ((nAddrResult & nValidAddr) != nValidAddr)
- bPrintAreaOk = FALSE;
- }
- }
- }
-
- BOOL bRepeatRowOk = (aStrRepeatRow.Len() == 0);
- if ( !bRepeatRowOk )
- bRepeatRowOk = lcl_CheckRepeatString(aStrRepeatRow, pDoc, true, NULL);
-
- BOOL bRepeatColOk = (aStrRepeatCol.Len() == 0);
- if ( !bRepeatColOk )
- bRepeatColOk = lcl_CheckRepeatString(aStrRepeatCol, pDoc, false, NULL);
-
- // Fehlermeldungen
-
- bOk = (bPrintAreaOk && bRepeatRowOk && bRepeatColOk);
-
- if ( !bOk )
- {
- Edit* pEd = NULL;
-
- if ( !bPrintAreaOk ) pEd = &aEdPrintArea;
- else if ( !bRepeatRowOk ) pEd = &aEdRepeatRow;
- else if ( !bRepeatColOk ) pEd = &aEdRepeatCol;
-
- ERRORBOX( STR_INVALID_TABREF );
- pEd->GrabFocus();
- }
-
- return bOk;
-}
-
-
-//----------------------------------------------------------------------------
-
-void ScPrintAreasDlg::Impl_FillLists()
-{
- //------------------------------------------------------
- // Selektion holen und String in PrintArea-ListBox merken
- //------------------------------------------------------
- ScRange aRange;
- String aStrRange;
- BOOL bSimple = TRUE;
-
- if ( pViewData )
- bSimple = (pViewData->GetSimpleArea( aRange ) == SC_MARK_SIMPLE);
-
- formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
-
- if ( bSimple )
- aRange.Format( aStrRange, SCR_ABS, pDoc, eConv );
- else
- {
- ScRangeListRef aList( new ScRangeList );
- pViewData->GetMarkData().FillRangeListWithMarks( aList, FALSE );
- aList->Format( aStrRange, SCR_ABS, pDoc, eConv );
- }
-
- aLbPrintArea.SetEntryData( SC_AREASDLG_PR_SELECT, new String( aStrRange ) );
-
- //------------------------------------------------------
- // Ranges holen und in ListBoxen merken
- //------------------------------------------------------
- ScRangeName* pRangeNames = pDoc->GetRangeName();
- const USHORT nCount = pRangeNames ? pRangeNames->GetCount() : 0;
-
- if ( nCount > 0 )
- {
- String aName;
- String aSymbol;
-// ScRange aRange;
- ScRangeData* pData = NULL;
-
- for ( USHORT i=0; i<nCount; i++ )
- {
- pData = (ScRangeData*)(pRangeNames->At( i ));
- if ( pData )
- {
- if ( pData->HasType( RT_ABSAREA )
- || pData->HasType( RT_REFAREA )
- || pData->HasType( RT_ABSPOS ) )
- {
- pData->GetName( aName );
- pData->GetSymbol( aSymbol );
- if ( aRange.ParseAny( aSymbol, pDoc, eConv ) & SCA_VALID )
- {
- if ( pData->HasType( RT_PRINTAREA ) )
- {
- aRange.Format( aSymbol, SCR_ABS, pDoc, eConv );
- aLbPrintArea.SetEntryData(
- aLbPrintArea.InsertEntry( aName ),
- new String( aSymbol ) );
- }
-
- if ( pData->HasType( RT_ROWHEADER ) )
- {
- lcl_GetRepeatRangeString(&aRange, pDoc, true, aSymbol);
- aLbRepeatRow.SetEntryData(
- aLbRepeatRow.InsertEntry( aName ),
- new String( aSymbol ) );
- }
-
- if ( pData->HasType( RT_COLHEADER ) )
- {
- lcl_GetRepeatRangeString(&aRange, pDoc, false, aSymbol);
- aLbRepeatCol.SetEntryData(
- aLbRepeatCol.InsertEntry( aName ),
- new String( aSymbol ) );
- }
- }
- }
- }
- }
- }
-}
-
-
-//----------------------------------------------------------------------------
-// Handler:
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScPrintAreasDlg, Impl_BtnHdl, PushButton*, pBtn )
-{
- if ( &aBtnOk == pBtn )
- {
- if ( Impl_CheckRefStrings() )
- {
- BOOL bDataChanged = FALSE;
- String aStr;
- SfxStringItem aPrintArea( SID_CHANGE_PRINTAREA, aStr );
- SfxStringItem aRepeatRow( FN_PARAM_2, aStr );
- SfxStringItem aRepeatCol( FN_PARAM_3, aStr );
-
- //-------------------------
- // Druckbereich veraendert?
- //-------------------------
-
- // first try the list box, if "Entite sheet" is selected
- BOOL bEntireSheet = (aLbPrintArea.GetSelectEntryPos() == SC_AREASDLG_PR_ENTIRE);
- SfxBoolItem aEntireSheet( FN_PARAM_4, bEntireSheet );
-
- bDataChanged = bEntireSheet != pDoc->IsPrintEntireSheet( nCurTab );
- if( !bEntireSheet )
- {
- // if new list box selection is not "Entire sheet", get the edit field contents
- bDataChanged |= Impl_GetItem( &aEdPrintArea, aPrintArea );
- }
-
- //-------------------------------
- // Wiederholungszeile veraendert?
- //-------------------------------
- bDataChanged |= Impl_GetItem( &aEdRepeatRow, aRepeatRow );
-
- //--------------------------------
- // Wiederholungsspalte veraendert?
- //--------------------------------
- bDataChanged |= Impl_GetItem( &aEdRepeatCol, aRepeatCol );
-
- if ( bDataChanged )
- {
- SetDispatcherLock( FALSE );
- SwitchToDocument();
- GetBindings().GetDispatcher()->Execute( SID_CHANGE_PRINTAREA,
- SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
- &aPrintArea, &aRepeatRow, &aRepeatCol, &aEntireSheet, 0L );
- }
-
- Close();
- }
- }
- else if ( &aBtnCancel == pBtn )
- Close();
-
- return 0;
-}
-
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScPrintAreasDlg, Impl_GetFocusHdl, Control*, pCtr )
-{
- if ( pCtr ==(Control *) &aEdPrintArea ||
- pCtr ==(Control *) &aEdRepeatRow ||
- pCtr ==(Control *) &aEdRepeatCol)
- {
- pRefInputEdit = (formula::RefEdit*) pCtr;
- }
- else if ( pCtr ==(Control *) &aLbPrintArea)
- {
- pRefInputEdit = &aEdPrintArea;
- }
- else if ( pCtr ==(Control *) &aLbRepeatRow)
- {
- pRefInputEdit = &aEdRepeatRow;
- }
- else if ( pCtr ==(Control *) &aLbRepeatCol)
- {
- pRefInputEdit = &aEdRepeatCol;
- }
-
- return 0;
-}
-
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScPrintAreasDlg, Impl_SelectHdl, ListBox*, pLb )
-{
- USHORT nSelPos = pLb->GetSelectEntryPos();
- Edit* pEd = NULL;
-
- // list box positions of specific entries, default to "repeat row/column" list boxes
- USHORT nAllSheetPos = SC_AREASDLG_RR_NONE;
- USHORT nUserDefPos = SC_AREASDLG_RR_USER;
- USHORT nFirstCustomPos = SC_AREASDLG_RR_OFFSET;
-
- // find edit field for list box, and list box positions
- if( pLb == &aLbPrintArea )
- {
- pEd = &aEdPrintArea;
- nAllSheetPos = SC_AREASDLG_PR_ENTIRE;
- nUserDefPos = SC_AREASDLG_PR_USER;
- nFirstCustomPos = SC_AREASDLG_PR_SELECT; // "Selection" and following
- }
- else if( pLb == &aLbRepeatCol )
- pEd = &aEdRepeatCol;
- else if( pLb == &aLbRepeatRow )
- pEd = &aEdRepeatRow;
- else
- return 0;
-
- // fill edit field according to list box selection
- if( (nSelPos == 0) || (nSelPos == nAllSheetPos) )
- pEd->SetText( EMPTY_STRING );
- else if( nSelPos == nUserDefPos && !pLb->IsTravelSelect() && pEd->GetText().Len() == 0 )
- pLb->SelectEntryPos( 0 );
- else if( nSelPos >= nFirstCustomPos )
- pEd->SetText( *static_cast< String* >( pLb->GetEntryData( nSelPos ) ) );
-
- return 0;
-}
-
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScPrintAreasDlg, Impl_ModifyHdl, formula::RefEdit*, pEd )
-{
- ListBox* pLb = NULL;
-
- // list box positions of specific entries, default to "repeat row/column" list boxes
- USHORT nUserDefPos = SC_AREASDLG_RR_USER;
- USHORT nFirstCustomPos = SC_AREASDLG_RR_OFFSET;
-
- if( pEd == &aEdPrintArea )
- {
- pLb = &aLbPrintArea;
- nUserDefPos = SC_AREASDLG_PR_USER;
- nFirstCustomPos = SC_AREASDLG_PR_SELECT; // "Selection" and following
- }
- else if( pEd == &aEdRepeatCol )
- pLb = &aLbRepeatCol;
- else if( pEd == &aEdRepeatRow )
- pLb = &aLbRepeatRow;
- else
- return 0;
-
- // set list box selection according to edit field
- USHORT nEntryCount = pLb->GetEntryCount();
- String aStrEd( pEd->GetText() );
- String aEdUpper = aStrEd;
- aEdUpper.ToUpperAscii();
-
- if ( (nEntryCount > nFirstCustomPos) && aStrEd.Len() > 0 )
- {
- BOOL bFound = FALSE;
- String* pSymbol = NULL;
- USHORT i;
-
- for ( i=nFirstCustomPos; i<nEntryCount && !bFound; i++ )
- {
- pSymbol = (String*)pLb->GetEntryData( i );
- bFound = ( (*pSymbol == aStrEd) || (*pSymbol == aEdUpper) );
- }
-
- pLb->SelectEntryPos( bFound ? i-1 : nUserDefPos );
- }
- else
- pLb->SelectEntryPos( aStrEd.Len() ? nUserDefPos : 0 );
-
- return 0;
-}
-
-
-//============================================================================
-// globale Funktionen:
-
-// ----------------------------------------------------------------------------
-
-// TODO: It might make sense to move these functions to address.?xx. -kohei
-
-bool lcl_CheckOne_OOO( const String& rStr, bool bIsRow, SCCOLROW& rVal )
-{
- // Zulaessige Syntax fuer rStr:
- // Row: [$]1-MAXTAB
- // Col: [$]A-IV
-
- String aStr = rStr;
- xub_StrLen nLen = aStr.Len();
- SCCOLROW nNum = 0;
- BOOL bStrOk = ( nLen > 0 ) && ( bIsRow ? ( nLen < 6 ) : ( nLen < 4 ) );
-
- if ( bStrOk )
- {
- if ( '$' == aStr.GetChar(0) )
- aStr.Erase( 0, 1 );
-
- if ( bIsRow )
- {
- bStrOk = CharClass::isAsciiNumeric(aStr);
-
- if ( bStrOk )
- {
- sal_Int32 n = aStr.ToInt32();
-
- if ( ( bStrOk = (n > 0) && ( n <= MAXROWCOUNT ) ) != FALSE )
- nNum = static_cast<SCCOLROW>(n - 1);
- }
- }
- else
- {
- SCCOL nCol = 0;
- bStrOk = ::AlphaToCol( nCol, aStr);
- nNum = nCol;
- }
- }
-
- if ( bStrOk )
- rVal = nNum;
-
- return bStrOk;
-}
-
-bool lcl_CheckOne_XL_A1( const String& rStr, bool bIsRow, SCCOLROW& rVal )
-{
- // XL A1 style is identical to OOO one for print range formats.
- return lcl_CheckOne_OOO(rStr, bIsRow, rVal);
-}
-
-bool lcl_CheckOne_XL_R1C1( const String& rStr, bool bIsRow, SCCOLROW& rVal )
-{
- xub_StrLen nLen = rStr.Len();
- if (nLen <= 1)
- // There must be at least two characters.
- return false;
-
- const sal_Unicode preUpper = bIsRow ? 'R' : 'C';
- const sal_Unicode preLower = bIsRow ? 'r' : 'c';
- if (rStr.GetChar(0) != preUpper && rStr.GetChar(0) != preLower)
- return false;
-
- String aNumStr = rStr.Copy(1);
- if (!CharClass::isAsciiNumeric(aNumStr))
- return false;
-
- sal_Int32 nNum = aNumStr.ToInt32();
-
- if (nNum <= 0)
- return false;
-
- if ((bIsRow && nNum > MAXROWCOUNT) || (!bIsRow && nNum > MAXCOLCOUNT))
- return false;
-
- rVal = static_cast<SCCOLROW>(nNum-1);
- return true;
-}
-
-bool lcl_CheckRepeatOne( const String& rStr, formula::FormulaGrammar::AddressConvention eConv, bool bIsRow, SCCOLROW& rVal )
-{
- switch (eConv)
- {
- case formula::FormulaGrammar::CONV_OOO:
- return lcl_CheckOne_OOO(rStr, bIsRow, rVal);
- case formula::FormulaGrammar::CONV_XL_A1:
- return lcl_CheckOne_XL_A1(rStr, bIsRow, rVal);
- case formula::FormulaGrammar::CONV_XL_R1C1:
- return lcl_CheckOne_XL_R1C1(rStr, bIsRow, rVal);
- default:
- {
- // added to avoid warnings
- }
- }
- return false;
-}
-
-bool lcl_CheckRepeatString( const String& rStr, ScDocument* pDoc, bool bIsRow, ScRange* pRange )
-{
- // Row: [valid row] rsep [valid row]
- // Col: [valid col] rsep [valid col]
-
- const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
- const sal_Unicode rsep = ScCompiler::GetNativeSymbol(ocRange).GetChar(0);
-
- if (pRange)
- {
- // initialize the range value.
- pRange->aStart.SetCol(0);
- pRange->aStart.SetRow(0);
- pRange->aEnd.SetCol(0);
- pRange->aEnd.SetRow(0);
- }
-
- String aBuf;
- SCCOLROW nVal = 0;
- xub_StrLen nLen = rStr.Len();
- bool bEndPos = false;
- for (xub_StrLen i = 0; i < nLen; ++i)
- {
- const sal_Unicode c = rStr.GetChar(i);
- if (c == rsep)
- {
- if (bEndPos)
- // We aren't supposed to have more than one range separator.
- return false;
-
- // range separator
- if (aBuf.Len() == 0)
- return false;
-
- bool bRes = lcl_CheckRepeatOne(aBuf, eConv, bIsRow, nVal);
- if (!bRes)
- return false;
-
- if (pRange)
- {
- if (bIsRow)
- {
- pRange->aStart.SetRow(static_cast<SCROW>(nVal));
- pRange->aEnd.SetRow(static_cast<SCROW>(nVal));
- }
- else
- {
- pRange->aStart.SetCol(static_cast<SCCOL>(nVal));
- pRange->aEnd.SetCol(static_cast<SCCOL>(nVal));
- }
- }
-
- aBuf.Erase();
- bEndPos = true;
- }
- else
- aBuf.Append(c);
- }
-
- if (aBuf.Len() > 0)
- {
- bool bRes = lcl_CheckRepeatOne(aBuf, eConv, bIsRow, nVal);
- if (!bRes)
- return false;
-
- if (pRange)
- {
- if (bIsRow)
- {
- if (!bEndPos)
- pRange->aStart.SetRow(static_cast<SCROW>(nVal));
- pRange->aEnd.SetRow(static_cast<SCROW>(nVal));
- }
- else
- {
- if (!bEndPos)
- pRange->aStart.SetCol(static_cast<SCCOL>(nVal));
- pRange->aEnd.SetCol(static_cast<SCCOL>(nVal));
- }
- }
- }
-
- return true;
-}
-
-// ----------------------------------------------------------------------------
-
-void lcl_GetRepeatRangeString( const ScRange* pRange, ScDocument* pDoc, bool bIsRow, String& rStr )
-{
- rStr.Erase();
- if (!pRange)
- return;
-
- const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
- const ScAddress& rStart = pRange->aStart;
- const ScAddress& rEnd = pRange->aEnd;
-
- const USHORT nFmt = bIsRow ? (SCA_VALID_ROW | SCA_ROW_ABSOLUTE) : (SCA_VALID_COL | SCA_COL_ABSOLUTE);
- String aTmpStr;
- rStart.Format(aTmpStr, nFmt, pDoc, eConv);
- rStr += aTmpStr;
- if ((bIsRow && rStart.Row() != rEnd.Row()) || (!bIsRow && rStart.Col() != rEnd.Col()))
- {
- rStr += ScCompiler::GetNativeSymbol(ocRange);
- rEnd.Format(aTmpStr, nFmt, pDoc, eConv);
- rStr += aTmpStr;
- }
-}
-
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: areasdlg.cxx,v $
+ * $Revision: 1.18 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//----------------------------------------------------------------------------
+#include <rangelst.hxx>
+
+#include <sfx2/dispatch.hxx>
+#include <svtools/stritem.hxx>
+#include <vcl/msgbox.hxx>
+#include <unotools/charclass.hxx>
+#include <stdlib.h>
+
+#define _AREASDLG_CXX
+#include "areasdlg.hxx"
+#undef _AREASDLG_CXX
+
+#include "scresid.hxx"
+#include "rangenam.hxx"
+#include "reffact.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "globstr.hrc"
+#include "pagedlg.hrc"
+#include "compiler.hxx"
+
+// STATIC DATA ---------------------------------------------------------------
+
+// List box positions for print range (PR)
+const USHORT SC_AREASDLG_PR_NONE = 0;
+const USHORT SC_AREASDLG_PR_ENTIRE = 1;
+const USHORT SC_AREASDLG_PR_USER = 2;
+const USHORT SC_AREASDLG_PR_SELECT = 3;
+const USHORT SC_AREASDLG_PR_OFFSET = 4;
+
+// List box positions for repeat ranges (RR)
+const USHORT SC_AREASDLG_RR_NONE = 0;
+const USHORT SC_AREASDLG_RR_USER = 1;
+const USHORT SC_AREASDLG_RR_OFFSET = 2;
+
+//============================================================================
+
+#define HDL(hdl) LINK( this, ScPrintAreasDlg, hdl )
+#define ERRORBOX(nId) ErrorBox( this, WinBits(WB_OK|WB_DEF_OK), \
+ ScGlobal::GetRscString( nId ) ).Execute()
+#define SWAP(x1,x2) { int n=x1; x1=x2; x2=n; }
+
+// globale Funktionen (->am Ende der Datei):
+
+bool lcl_CheckRepeatString( const String& rStr, ScDocument* pDoc, bool bIsRow, ScRange* pRange );
+void lcl_GetRepeatRangeString( const ScRange* pRange, ScDocument* pDoc, bool bIsRow, String& rStr );
+
+#if 0
+static void printAddressFlags(USHORT nFlag)
+{
+ if ((nFlag & SCA_COL_ABSOLUTE ) == SCA_COL_ABSOLUTE ) printf("SCA_COL_ABSOLUTE \n");
+ if ((nFlag & SCA_ROW_ABSOLUTE ) == SCA_ROW_ABSOLUTE ) printf("SCA_ROW_ABSOLUTE \n");
+ if ((nFlag & SCA_TAB_ABSOLUTE ) == SCA_TAB_ABSOLUTE ) printf("SCA_TAB_ABSOLUTE \n");
+ if ((nFlag & SCA_TAB_3D ) == SCA_TAB_3D ) printf("SCA_TAB_3D \n");
+ if ((nFlag & SCA_COL2_ABSOLUTE ) == SCA_COL2_ABSOLUTE ) printf("SCA_COL2_ABSOLUTE\n");
+ if ((nFlag & SCA_ROW2_ABSOLUTE ) == SCA_ROW2_ABSOLUTE ) printf("SCA_ROW2_ABSOLUTE\n");
+ if ((nFlag & SCA_TAB2_ABSOLUTE ) == SCA_TAB2_ABSOLUTE ) printf("SCA_TAB2_ABSOLUTE\n");
+ if ((nFlag & SCA_TAB2_3D ) == SCA_TAB2_3D ) printf("SCA_TAB2_3D \n");
+ if ((nFlag & SCA_VALID_ROW ) == SCA_VALID_ROW ) printf("SCA_VALID_ROW \n");
+ if ((nFlag & SCA_VALID_COL ) == SCA_VALID_COL ) printf("SCA_VALID_COL \n");
+ if ((nFlag & SCA_VALID_TAB ) == SCA_VALID_TAB ) printf("SCA_VALID_TAB \n");
+ if ((nFlag & SCA_FORCE_DOC ) == SCA_FORCE_DOC ) printf("SCA_FORCE_DOC \n");
+ if ((nFlag & SCA_VALID_ROW2 ) == SCA_VALID_ROW2 ) printf("SCA_VALID_ROW2 \n");
+ if ((nFlag & SCA_VALID_COL2 ) == SCA_VALID_COL2 ) printf("SCA_VALID_COL2 \n");
+ if ((nFlag & SCA_VALID_TAB2 ) == SCA_VALID_TAB2 ) printf("SCA_VALID_TAB2 \n");
+ if ((nFlag & SCA_VALID ) == SCA_VALID ) printf("SCA_VALID \n");
+ if ((nFlag & SCA_ABS ) == SCA_ABS ) printf("SCA_ABS \n");
+ if ((nFlag & SCR_ABS ) == SCR_ABS ) printf("SCR_ABS \n");
+ if ((nFlag & SCA_ABS_3D ) == SCA_ABS_3D ) printf("SCA_ABS_3D \n");
+ if ((nFlag & SCR_ABS_3D ) == SCR_ABS_3D ) printf("SCR_ABS_3D \n");
+}
+#endif
+
+//============================================================================
+// class ScPrintAreasDlg
+
+//----------------------------------------------------------------------------
+
+ScPrintAreasDlg::ScPrintAreasDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent )
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_AREAS),
+ //
+ aLbPrintArea ( this, ScResId( LB_PRINTAREA ) ),
+ aFlPrintArea ( this, ScResId( FL_PRINTAREA ) ),
+ aEdPrintArea ( this, ScResId( ED_PRINTAREA ) ),
+ aRbPrintArea ( this, ScResId( RB_PRINTAREA ), &aEdPrintArea, this ),
+ //
+ aLbRepeatRow ( this, ScResId( LB_REPEATROW ) ),
+ aFlRepeatRow ( this, ScResId( FL_REPEATROW ) ),
+ aEdRepeatRow ( this, ScResId( ED_REPEATROW ) ),
+ aRbRepeatRow ( this, ScResId( RB_REPEATROW ), &aEdRepeatRow, this ),
+ //
+ aLbRepeatCol ( this, ScResId( LB_REPEATCOL ) ),
+ aFlRepeatCol ( this, ScResId( FL_REPEATCOL ) ),
+ aEdRepeatCol ( this, ScResId( ED_REPEATCOL ) ),
+ aRbRepeatCol ( this, ScResId( RB_REPEATCOL ), &aEdRepeatCol, this ),
+ //
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ //
+ bDlgLostFocus ( FALSE ),
+ pRefInputEdit ( &aEdPrintArea ),
+ pDoc ( NULL ),
+ pViewData ( NULL ),
+ nCurTab ( 0 )
+{
+ ScTabViewShell* pScViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
+ ScDocShell* pScDocSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
+
+ DBG_ASSERT( pScDocSh, "Current DocumentShell not found :-(" );
+
+ pDoc = pScDocSh->GetDocument();
+
+ if ( pScViewSh )
+ {
+ pViewData = pScViewSh->GetViewData();
+ nCurTab = pViewData->GetTabNo();
+ }
+
+ Impl_Reset();
+
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable();
+
+ FreeResource();
+}
+
+
+//----------------------------------------------------------------------------
+
+ScPrintAreasDlg::~ScPrintAreasDlg()
+{
+ // Extra-Data an ListBox-Entries abraeumen
+ ListBox* pLb[3] = { &aLbPrintArea, &aLbRepeatRow, &aLbRepeatCol };
+
+ for ( USHORT i=0; i<3; i++ )
+ {
+ USHORT nCount = pLb[i]->GetEntryCount();
+ for ( USHORT j=0; j<nCount; j++ )
+ delete (String*)pLb[i]->GetEntryData(j);
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScPrintAreasDlg::Close()
+{
+ return DoClose( ScPrintAreasDlgWrapper::GetChildWindowId() );
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScPrintAreasDlg::IsTableLocked() const
+{
+ // Druckbereiche gelten pro Tabelle, darum macht es keinen Sinn,
+ // bei der Eingabe die Tabelle umzuschalten
+
+ return TRUE;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScPrintAreasDlg::SetReference( const ScRange& rRef, ScDocument* /* pDoc */ )
+{
+ if ( pRefInputEdit )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart( pRefInputEdit );
+
+ String aStr;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+
+ if ( &aEdPrintArea == pRefInputEdit )
+ {
+ rRef.Format( aStr, SCR_ABS, pDoc, eConv );
+
+// aEdPrintArea.ReplaceSelected( aStr );
+
+ String aVal = aEdPrintArea.GetText();
+ Selection aSel = aEdPrintArea.GetSelection();
+ aSel.Justify();
+ aVal.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() );
+ aVal.Insert( aStr, (xub_StrLen)aSel.Min() );
+ Selection aNewSel( aSel.Min(), aSel.Min()+aStr.Len() );
+ aEdPrintArea.SetRefString( aVal );
+ aEdPrintArea.SetSelection( aNewSel );
+ }
+ else
+ {
+ BOOL bRow = ( &aEdRepeatRow == pRefInputEdit );
+ lcl_GetRepeatRangeString(&rRef, pDoc, bRow, aStr);
+ pRefInputEdit->SetRefString( aStr );
+ }
+ }
+
+ Impl_ModifyHdl( pRefInputEdit );
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScPrintAreasDlg::AddRefEntry()
+{
+ if ( pRefInputEdit == &aEdPrintArea )
+ {
+ const sal_Unicode sep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ String aVal = aEdPrintArea.GetText();
+ aVal += sep;
+ aEdPrintArea.SetText(aVal);
+
+ xub_StrLen nLen = aVal.Len();
+ aEdPrintArea.SetSelection( Selection( nLen, nLen ) );
+
+ Impl_ModifyHdl( &aEdPrintArea );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScPrintAreasDlg::Deactivate()
+{
+ bDlgLostFocus = TRUE;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScPrintAreasDlg::SetActive()
+{
+ if ( bDlgLostFocus )
+ {
+ bDlgLostFocus = FALSE;
+
+ if ( pRefInputEdit )
+ {
+ pRefInputEdit->GrabFocus();
+ Impl_ModifyHdl( pRefInputEdit );
+ }
+ }
+ else
+ GrabFocus();
+
+ RefInputDone();
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScPrintAreasDlg::Impl_Reset()
+{
+ String aStrRange;
+ const ScRange* pRepeatColRange = pDoc->GetRepeatColRange( nCurTab );
+ const ScRange* pRepeatRowRange = pDoc->GetRepeatRowRange( nCurTab );
+
+ aEdPrintArea.SetModifyHdl ( HDL(Impl_ModifyHdl) );
+ aEdRepeatRow.SetModifyHdl ( HDL(Impl_ModifyHdl) );
+ aEdRepeatCol.SetModifyHdl ( HDL(Impl_ModifyHdl) );
+ aEdPrintArea.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
+ aEdRepeatRow.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
+ aEdRepeatCol.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
+ aLbPrintArea.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
+ aLbRepeatRow.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
+ aLbRepeatCol.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
+ aLbPrintArea.SetSelectHdl ( HDL(Impl_SelectHdl) );
+ aLbRepeatRow.SetSelectHdl ( HDL(Impl_SelectHdl) );
+ aLbRepeatCol.SetSelectHdl ( HDL(Impl_SelectHdl) );
+ aBtnOk .SetClickHdl ( HDL(Impl_BtnHdl) );
+ aBtnCancel .SetClickHdl ( HDL(Impl_BtnHdl) );
+
+ Impl_FillLists();
+
+ //-------------------------
+ // Druckbereich
+ //-------------------------
+ aStrRange.Erase();
+ String aOne;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ const sal_Unicode sep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ USHORT nRangeCount = pDoc->GetPrintRangeCount( nCurTab );
+ for (USHORT i=0; i<nRangeCount; i++)
+ {
+ const ScRange* pPrintRange = pDoc->GetPrintRange( nCurTab, i );
+ if (pPrintRange)
+ {
+ if ( aStrRange.Len() )
+ aStrRange += sep;
+ pPrintRange->Format( aOne, SCR_ABS, pDoc, eConv );
+ aStrRange += aOne;
+ }
+ }
+ aEdPrintArea.SetText( aStrRange );
+
+ //-------------------------------
+ // Wiederholungszeile
+ //-------------------------------
+ lcl_GetRepeatRangeString(pRepeatRowRange, pDoc, true, aStrRange);
+ aEdRepeatRow.SetText( aStrRange );
+
+ //--------------------------------
+ // Wiederholungsspalte
+ //--------------------------------
+ lcl_GetRepeatRangeString(pRepeatColRange, pDoc, false, aStrRange);
+ aEdRepeatCol.SetText( aStrRange );
+
+ Impl_ModifyHdl( &aEdPrintArea );
+ Impl_ModifyHdl( &aEdRepeatRow );
+ Impl_ModifyHdl( &aEdRepeatCol );
+ if( pDoc->IsPrintEntireSheet( nCurTab ) )
+ aLbPrintArea.SelectEntryPos( SC_AREASDLG_PR_ENTIRE );
+
+ aEdPrintArea.SaveValue(); // fuer FillItemSet() merken:
+ aEdRepeatRow.SaveValue();
+ aEdRepeatCol.SaveValue();
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScPrintAreasDlg::Impl_GetItem( Edit* pEd, SfxStringItem& rItem )
+{
+ String aRangeStr = pEd->GetText();
+ BOOL bDataChanged = (pEd->GetSavedValue() != aRangeStr);
+
+ if ( (aRangeStr.Len() > 0) && &aEdPrintArea != pEd )
+ {
+ ScRange aRange;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ lcl_CheckRepeatString(aRangeStr, pDoc, &aEdRepeatRow == pEd, &aRange);
+ aRange.Format(aRangeStr, SCR_ABS, pDoc, eConv);
+ }
+
+ rItem.SetValue( aRangeStr );
+
+ return bDataChanged;
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScPrintAreasDlg::Impl_CheckRefStrings()
+{
+ BOOL bOk = FALSE;
+ String aStrPrintArea = aEdPrintArea.GetText();
+ String aStrRepeatRow = aEdRepeatRow.GetText();
+ String aStrRepeatCol = aEdRepeatCol.GetText();
+
+ BOOL bPrintAreaOk = TRUE;
+ if ( aStrPrintArea.Len() )
+ {
+ const USHORT nValidAddr = SCA_VALID | SCA_VALID_ROW | SCA_VALID_COL;
+ const USHORT nValidRange = nValidAddr | SCA_VALID_ROW2 | SCA_VALID_COL2;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ const sal_Unicode sep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ // const sal_Unicode rsep = ScCompiler::GetNativeSymbol(ocRange).GetChar(0);
+
+ ScAddress aAddr;
+ ScRange aRange;
+ xub_StrLen nSepCount = aStrPrintArea.GetTokenCount(sep);
+ for ( xub_StrLen i = 0; i < nSepCount && bPrintAreaOk; ++i )
+ {
+ String aOne = aStrPrintArea.GetToken(i, sep);
+ USHORT nResult = aRange.Parse( aOne, pDoc, eConv );
+ if ((nResult & nValidRange) != nValidRange)
+ {
+ USHORT nAddrResult = aAddr.Parse( aOne, pDoc, eConv );
+ if ((nAddrResult & nValidAddr) != nValidAddr)
+ bPrintAreaOk = FALSE;
+ }
+ }
+ }
+
+ BOOL bRepeatRowOk = (aStrRepeatRow.Len() == 0);
+ if ( !bRepeatRowOk )
+ bRepeatRowOk = lcl_CheckRepeatString(aStrRepeatRow, pDoc, true, NULL);
+
+ BOOL bRepeatColOk = (aStrRepeatCol.Len() == 0);
+ if ( !bRepeatColOk )
+ bRepeatColOk = lcl_CheckRepeatString(aStrRepeatCol, pDoc, false, NULL);
+
+ // Fehlermeldungen
+
+ bOk = (bPrintAreaOk && bRepeatRowOk && bRepeatColOk);
+
+ if ( !bOk )
+ {
+ Edit* pEd = NULL;
+
+ if ( !bPrintAreaOk ) pEd = &aEdPrintArea;
+ else if ( !bRepeatRowOk ) pEd = &aEdRepeatRow;
+ else if ( !bRepeatColOk ) pEd = &aEdRepeatCol;
+
+ ERRORBOX( STR_INVALID_TABREF );
+ pEd->GrabFocus();
+ }
+
+ return bOk;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScPrintAreasDlg::Impl_FillLists()
+{
+ //------------------------------------------------------
+ // Selektion holen und String in PrintArea-ListBox merken
+ //------------------------------------------------------
+ ScRange aRange;
+ String aStrRange;
+ BOOL bSimple = TRUE;
+
+ if ( pViewData )
+ bSimple = (pViewData->GetSimpleArea( aRange ) == SC_MARK_SIMPLE);
+
+ formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+
+ if ( bSimple )
+ aRange.Format( aStrRange, SCR_ABS, pDoc, eConv );
+ else
+ {
+ ScRangeListRef aList( new ScRangeList );
+ pViewData->GetMarkData().FillRangeListWithMarks( aList, FALSE );
+ aList->Format( aStrRange, SCR_ABS, pDoc, eConv );
+ }
+
+ aLbPrintArea.SetEntryData( SC_AREASDLG_PR_SELECT, new String( aStrRange ) );
+
+ //------------------------------------------------------
+ // Ranges holen und in ListBoxen merken
+ //------------------------------------------------------
+ ScRangeName* pRangeNames = pDoc->GetRangeName();
+ const USHORT nCount = pRangeNames ? pRangeNames->GetCount() : 0;
+
+ if ( nCount > 0 )
+ {
+ String aName;
+ String aSymbol;
+// ScRange aRange;
+ ScRangeData* pData = NULL;
+
+ for ( USHORT i=0; i<nCount; i++ )
+ {
+ pData = (ScRangeData*)(pRangeNames->At( i ));
+ if ( pData )
+ {
+ if ( pData->HasType( RT_ABSAREA )
+ || pData->HasType( RT_REFAREA )
+ || pData->HasType( RT_ABSPOS ) )
+ {
+ pData->GetName( aName );
+ pData->GetSymbol( aSymbol );
+ if ( aRange.ParseAny( aSymbol, pDoc, eConv ) & SCA_VALID )
+ {
+ if ( pData->HasType( RT_PRINTAREA ) )
+ {
+ aRange.Format( aSymbol, SCR_ABS, pDoc, eConv );
+ aLbPrintArea.SetEntryData(
+ aLbPrintArea.InsertEntry( aName ),
+ new String( aSymbol ) );
+ }
+
+ if ( pData->HasType( RT_ROWHEADER ) )
+ {
+ lcl_GetRepeatRangeString(&aRange, pDoc, true, aSymbol);
+ aLbRepeatRow.SetEntryData(
+ aLbRepeatRow.InsertEntry( aName ),
+ new String( aSymbol ) );
+ }
+
+ if ( pData->HasType( RT_COLHEADER ) )
+ {
+ lcl_GetRepeatRangeString(&aRange, pDoc, false, aSymbol);
+ aLbRepeatCol.SetEntryData(
+ aLbRepeatCol.InsertEntry( aName ),
+ new String( aSymbol ) );
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------
+// Handler:
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScPrintAreasDlg, Impl_BtnHdl, PushButton*, pBtn )
+{
+ if ( &aBtnOk == pBtn )
+ {
+ if ( Impl_CheckRefStrings() )
+ {
+ BOOL bDataChanged = FALSE;
+ String aStr;
+ SfxStringItem aPrintArea( SID_CHANGE_PRINTAREA, aStr );
+ SfxStringItem aRepeatRow( FN_PARAM_2, aStr );
+ SfxStringItem aRepeatCol( FN_PARAM_3, aStr );
+
+ //-------------------------
+ // Druckbereich veraendert?
+ //-------------------------
+
+ // first try the list box, if "Entite sheet" is selected
+ BOOL bEntireSheet = (aLbPrintArea.GetSelectEntryPos() == SC_AREASDLG_PR_ENTIRE);
+ SfxBoolItem aEntireSheet( FN_PARAM_4, bEntireSheet );
+
+ bDataChanged = bEntireSheet != pDoc->IsPrintEntireSheet( nCurTab );
+ if( !bEntireSheet )
+ {
+ // if new list box selection is not "Entire sheet", get the edit field contents
+ bDataChanged |= Impl_GetItem( &aEdPrintArea, aPrintArea );
+ }
+
+ //-------------------------------
+ // Wiederholungszeile veraendert?
+ //-------------------------------
+ bDataChanged |= Impl_GetItem( &aEdRepeatRow, aRepeatRow );
+
+ //--------------------------------
+ // Wiederholungsspalte veraendert?
+ //--------------------------------
+ bDataChanged |= Impl_GetItem( &aEdRepeatCol, aRepeatCol );
+
+ if ( bDataChanged )
+ {
+ SetDispatcherLock( FALSE );
+ SwitchToDocument();
+ GetBindings().GetDispatcher()->Execute( SID_CHANGE_PRINTAREA,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ &aPrintArea, &aRepeatRow, &aRepeatCol, &aEntireSheet, 0L );
+ }
+
+ Close();
+ }
+ }
+ else if ( &aBtnCancel == pBtn )
+ Close();
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScPrintAreasDlg, Impl_GetFocusHdl, Control*, pCtr )
+{
+ if ( pCtr ==(Control *) &aEdPrintArea ||
+ pCtr ==(Control *) &aEdRepeatRow ||
+ pCtr ==(Control *) &aEdRepeatCol)
+ {
+ pRefInputEdit = (formula::RefEdit*) pCtr;
+ }
+ else if ( pCtr ==(Control *) &aLbPrintArea)
+ {
+ pRefInputEdit = &aEdPrintArea;
+ }
+ else if ( pCtr ==(Control *) &aLbRepeatRow)
+ {
+ pRefInputEdit = &aEdRepeatRow;
+ }
+ else if ( pCtr ==(Control *) &aLbRepeatCol)
+ {
+ pRefInputEdit = &aEdRepeatCol;
+ }
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScPrintAreasDlg, Impl_SelectHdl, ListBox*, pLb )
+{
+ USHORT nSelPos = pLb->GetSelectEntryPos();
+ Edit* pEd = NULL;
+
+ // list box positions of specific entries, default to "repeat row/column" list boxes
+ USHORT nAllSheetPos = SC_AREASDLG_RR_NONE;
+ USHORT nUserDefPos = SC_AREASDLG_RR_USER;
+ USHORT nFirstCustomPos = SC_AREASDLG_RR_OFFSET;
+
+ // find edit field for list box, and list box positions
+ if( pLb == &aLbPrintArea )
+ {
+ pEd = &aEdPrintArea;
+ nAllSheetPos = SC_AREASDLG_PR_ENTIRE;
+ nUserDefPos = SC_AREASDLG_PR_USER;
+ nFirstCustomPos = SC_AREASDLG_PR_SELECT; // "Selection" and following
+ }
+ else if( pLb == &aLbRepeatCol )
+ pEd = &aEdRepeatCol;
+ else if( pLb == &aLbRepeatRow )
+ pEd = &aEdRepeatRow;
+ else
+ return 0;
+
+ // fill edit field according to list box selection
+ if( (nSelPos == 0) || (nSelPos == nAllSheetPos) )
+ pEd->SetText( EMPTY_STRING );
+ else if( nSelPos == nUserDefPos && !pLb->IsTravelSelect() && pEd->GetText().Len() == 0 )
+ pLb->SelectEntryPos( 0 );
+ else if( nSelPos >= nFirstCustomPos )
+ pEd->SetText( *static_cast< String* >( pLb->GetEntryData( nSelPos ) ) );
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScPrintAreasDlg, Impl_ModifyHdl, formula::RefEdit*, pEd )
+{
+ ListBox* pLb = NULL;
+
+ // list box positions of specific entries, default to "repeat row/column" list boxes
+ USHORT nUserDefPos = SC_AREASDLG_RR_USER;
+ USHORT nFirstCustomPos = SC_AREASDLG_RR_OFFSET;
+
+ if( pEd == &aEdPrintArea )
+ {
+ pLb = &aLbPrintArea;
+ nUserDefPos = SC_AREASDLG_PR_USER;
+ nFirstCustomPos = SC_AREASDLG_PR_SELECT; // "Selection" and following
+ }
+ else if( pEd == &aEdRepeatCol )
+ pLb = &aLbRepeatCol;
+ else if( pEd == &aEdRepeatRow )
+ pLb = &aLbRepeatRow;
+ else
+ return 0;
+
+ // set list box selection according to edit field
+ USHORT nEntryCount = pLb->GetEntryCount();
+ String aStrEd( pEd->GetText() );
+ String aEdUpper = aStrEd;
+ aEdUpper.ToUpperAscii();
+
+ if ( (nEntryCount > nFirstCustomPos) && aStrEd.Len() > 0 )
+ {
+ BOOL bFound = FALSE;
+ String* pSymbol = NULL;
+ USHORT i;
+
+ for ( i=nFirstCustomPos; i<nEntryCount && !bFound; i++ )
+ {
+ pSymbol = (String*)pLb->GetEntryData( i );
+ bFound = ( (*pSymbol == aStrEd) || (*pSymbol == aEdUpper) );
+ }
+
+ pLb->SelectEntryPos( bFound ? i-1 : nUserDefPos );
+ }
+ else
+ pLb->SelectEntryPos( aStrEd.Len() ? nUserDefPos : 0 );
+
+ return 0;
+}
+
+
+//============================================================================
+// globale Funktionen:
+
+// ----------------------------------------------------------------------------
+
+// TODO: It might make sense to move these functions to address.?xx. -kohei
+
+bool lcl_CheckOne_OOO( const String& rStr, bool bIsRow, SCCOLROW& rVal )
+{
+ // Zulaessige Syntax fuer rStr:
+ // Row: [$]1-MAXTAB
+ // Col: [$]A-IV
+
+ String aStr = rStr;
+ xub_StrLen nLen = aStr.Len();
+ SCCOLROW nNum = 0;
+ BOOL bStrOk = ( nLen > 0 ) && ( bIsRow ? ( nLen < 6 ) : ( nLen < 4 ) );
+
+ if ( bStrOk )
+ {
+ if ( '$' == aStr.GetChar(0) )
+ aStr.Erase( 0, 1 );
+
+ if ( bIsRow )
+ {
+ bStrOk = CharClass::isAsciiNumeric(aStr);
+
+ if ( bStrOk )
+ {
+ sal_Int32 n = aStr.ToInt32();
+
+ if ( ( bStrOk = (n > 0) && ( n <= MAXROWCOUNT ) ) != FALSE )
+ nNum = static_cast<SCCOLROW>(n - 1);
+ }
+ }
+ else
+ {
+ SCCOL nCol = 0;
+ bStrOk = ::AlphaToCol( nCol, aStr);
+ nNum = nCol;
+ }
+ }
+
+ if ( bStrOk )
+ rVal = nNum;
+
+ return bStrOk;
+}
+
+bool lcl_CheckOne_XL_A1( const String& rStr, bool bIsRow, SCCOLROW& rVal )
+{
+ // XL A1 style is identical to OOO one for print range formats.
+ return lcl_CheckOne_OOO(rStr, bIsRow, rVal);
+}
+
+bool lcl_CheckOne_XL_R1C1( const String& rStr, bool bIsRow, SCCOLROW& rVal )
+{
+ xub_StrLen nLen = rStr.Len();
+ if (nLen <= 1)
+ // There must be at least two characters.
+ return false;
+
+ const sal_Unicode preUpper = bIsRow ? 'R' : 'C';
+ const sal_Unicode preLower = bIsRow ? 'r' : 'c';
+ if (rStr.GetChar(0) != preUpper && rStr.GetChar(0) != preLower)
+ return false;
+
+ String aNumStr = rStr.Copy(1);
+ if (!CharClass::isAsciiNumeric(aNumStr))
+ return false;
+
+ sal_Int32 nNum = aNumStr.ToInt32();
+
+ if (nNum <= 0)
+ return false;
+
+ if ((bIsRow && nNum > MAXROWCOUNT) || (!bIsRow && nNum > MAXCOLCOUNT))
+ return false;
+
+ rVal = static_cast<SCCOLROW>(nNum-1);
+ return true;
+}
+
+bool lcl_CheckRepeatOne( const String& rStr, formula::FormulaGrammar::AddressConvention eConv, bool bIsRow, SCCOLROW& rVal )
+{
+ switch (eConv)
+ {
+ case formula::FormulaGrammar::CONV_OOO:
+ return lcl_CheckOne_OOO(rStr, bIsRow, rVal);
+ case formula::FormulaGrammar::CONV_XL_A1:
+ return lcl_CheckOne_XL_A1(rStr, bIsRow, rVal);
+ case formula::FormulaGrammar::CONV_XL_R1C1:
+ return lcl_CheckOne_XL_R1C1(rStr, bIsRow, rVal);
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ return false;
+}
+
+bool lcl_CheckRepeatString( const String& rStr, ScDocument* pDoc, bool bIsRow, ScRange* pRange )
+{
+ // Row: [valid row] rsep [valid row]
+ // Col: [valid col] rsep [valid col]
+
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ const sal_Unicode rsep = ScCompiler::GetNativeSymbol(ocRange).GetChar(0);
+
+ if (pRange)
+ {
+ // initialize the range value.
+ pRange->aStart.SetCol(0);
+ pRange->aStart.SetRow(0);
+ pRange->aEnd.SetCol(0);
+ pRange->aEnd.SetRow(0);
+ }
+
+ String aBuf;
+ SCCOLROW nVal = 0;
+ xub_StrLen nLen = rStr.Len();
+ bool bEndPos = false;
+ for (xub_StrLen i = 0; i < nLen; ++i)
+ {
+ const sal_Unicode c = rStr.GetChar(i);
+ if (c == rsep)
+ {
+ if (bEndPos)
+ // We aren't supposed to have more than one range separator.
+ return false;
+
+ // range separator
+ if (aBuf.Len() == 0)
+ return false;
+
+ bool bRes = lcl_CheckRepeatOne(aBuf, eConv, bIsRow, nVal);
+ if (!bRes)
+ return false;
+
+ if (pRange)
+ {
+ if (bIsRow)
+ {
+ pRange->aStart.SetRow(static_cast<SCROW>(nVal));
+ pRange->aEnd.SetRow(static_cast<SCROW>(nVal));
+ }
+ else
+ {
+ pRange->aStart.SetCol(static_cast<SCCOL>(nVal));
+ pRange->aEnd.SetCol(static_cast<SCCOL>(nVal));
+ }
+ }
+
+ aBuf.Erase();
+ bEndPos = true;
+ }
+ else
+ aBuf.Append(c);
+ }
+
+ if (aBuf.Len() > 0)
+ {
+ bool bRes = lcl_CheckRepeatOne(aBuf, eConv, bIsRow, nVal);
+ if (!bRes)
+ return false;
+
+ if (pRange)
+ {
+ if (bIsRow)
+ {
+ if (!bEndPos)
+ pRange->aStart.SetRow(static_cast<SCROW>(nVal));
+ pRange->aEnd.SetRow(static_cast<SCROW>(nVal));
+ }
+ else
+ {
+ if (!bEndPos)
+ pRange->aStart.SetCol(static_cast<SCCOL>(nVal));
+ pRange->aEnd.SetCol(static_cast<SCCOL>(nVal));
+ }
+ }
+ }
+
+ return true;
+}
+
+// ----------------------------------------------------------------------------
+
+void lcl_GetRepeatRangeString( const ScRange* pRange, ScDocument* pDoc, bool bIsRow, String& rStr )
+{
+ rStr.Erase();
+ if (!pRange)
+ return;
+
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ const ScAddress& rStart = pRange->aStart;
+ const ScAddress& rEnd = pRange->aEnd;
+
+ const USHORT nFmt = bIsRow ? (SCA_VALID_ROW | SCA_ROW_ABSOLUTE) : (SCA_VALID_COL | SCA_COL_ABSOLUTE);
+ String aTmpStr;
+ rStart.Format(aTmpStr, nFmt, pDoc, eConv);
+ rStr += aTmpStr;
+ if ((bIsRow && rStart.Row() != rEnd.Row()) || (!bIsRow && rStart.Col() != rEnd.Col()))
+ {
+ rStr += ScCompiler::GetNativeSymbol(ocRange);
+ rEnd.Format(aTmpStr, nFmt, pDoc, eConv);
+ rStr += aTmpStr;
+ }
+}
+