2010-10-12 15:59:00 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-30 12:23:25 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2009-11-20 14:02:34 +00:00
|
|
|
#include <algorithm>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#include "scitems.hxx"
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/eeitem.hxx>
|
2007-05-10 15:53:59 +00:00
|
|
|
|
2006-05-02 14:46:23 +00:00
|
|
|
#include <sfx2/app.hxx>
|
2013-02-12 13:41:53 -05:00
|
|
|
#include <editeng/adjustitem.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/editview.hxx>
|
|
|
|
#include <editeng/editstat.hxx>
|
|
|
|
#include <editeng/frmdiritem.hxx>
|
|
|
|
#include <editeng/lspcitem.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <sfx2/bindings.hxx>
|
2004-10-04 19:13:06 +00:00
|
|
|
#include <sfx2/viewfrm.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <sfx2/dispatch.hxx>
|
|
|
|
#include <sfx2/event.hxx>
|
|
|
|
#include <sfx2/imgmgr.hxx>
|
2013-10-22 15:58:57 +03:00
|
|
|
#include <stdlib.h>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/scriptspaceitem.hxx>
|
|
|
|
#include <editeng/scripttypeitem.hxx>
|
2004-07-05 13:01:39 +00:00
|
|
|
#include <vcl/cursor.hxx>
|
|
|
|
#include <vcl/help.hxx>
|
2014-01-02 23:52:37 +01:00
|
|
|
#include <vcl/settings.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/stritem.hxx>
|
2011-08-15 15:46:02 -04:00
|
|
|
#include <stdio.h>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#include "inputwin.hxx"
|
|
|
|
#include "scmod.hxx"
|
|
|
|
#include "uiitems.hxx"
|
|
|
|
#include "global.hxx"
|
|
|
|
#include "scresid.hxx"
|
|
|
|
#include "sc.hrc"
|
|
|
|
#include "globstr.hrc"
|
2011-09-26 00:34:14 +02:00
|
|
|
#include "reffact.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "editutil.hxx"
|
|
|
|
#include "inputhdl.hxx"
|
|
|
|
#include "tabvwsh.hxx"
|
|
|
|
#include "document.hxx"
|
|
|
|
#include "docsh.hxx"
|
|
|
|
#include "appoptio.hxx"
|
|
|
|
#include "rangenam.hxx"
|
CWS-TOOLING: integrate CWS frmdlg
2008-12-18 09:13:09 +0100 oj r265667 : merge from odff05
2008-12-18 07:58:16 +0100 oj r265658 : #i94555# patch from <regina>, ODFF:
Add GAMMA, CHISQDIST, CHISQINV.
Make the 'cumulative' parameter of GAMMADIST optional.
Adapt the domain of CHIDIST to allow negative x.
Remove the constraint "degrees of freedom < 1.0E5" from CHIDIST and CHIINV.
Plus a mechanism to write the now optional parameter of GAMMADIST to PODF and
ODFF if omitted, for backwards compatibility.
2008-12-15 14:06:11 +0100 oj r265490 : CWS-TOOLING: rebase CWS frmdlg to trunk@264807 (milestone: DEV300:m37)
2008-12-15 13:55:28 +0100 oj r265488 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:55:07 +0100 oj r265487 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:48 +0100 oj r265486 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:36 +0100 oj r265485 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:24 +0100 oj r265484 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:48:11 +0100 oj r265483 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:31:12 +0100 oj r265479 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:13:58 +0100 oj r265477 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:10:09 +0100 oj r265476 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:05:11 +0100 oj r265475 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:47:17 +0100 oj r265467 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:46:19 +0100 oj r265466 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:45:47 +0100 oj r265465 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 07:35:07 +0100 oj r265458 : add dependency to formula
2008-12-15 07:34:24 +0100 oj r265457 : add dependency to formula
2008-12-12 13:22:00 +0100 msc r265413 : #i97089#
2008-12-12 13:20:25 +0100 msc r265412 : #i97089#
2008-12-12 12:35:12 +0100 msc r265406 : #i97089#
2008-12-12 12:34:16 +0100 msc r265405 : #i97089#
2008-12-12 12:33:05 +0100 msc r265404 : #i97089#
2008-12-12 12:31:11 +0100 msc r265403 : #i97089#
2008-12-08 11:59:10 +0100 oj r264981 : insert RTL_LOG
2008-12-08 11:50:17 +0100 oj r264980 : some small changes
2008-12-05 12:57:57 +0100 oj r264902 : eof changed
2008-12-05 12:56:46 +0100 oj r264901 : eof changed
2008-12-05 12:28:47 +0100 oj r264899 : wrong var used
2008-12-05 10:08:57 +0100 oj r264890 : token order reversed
2008-12-04 13:49:22 +0100 oc r264843 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:45:27 +0100 oc r264842 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:42:54 +0100 oc r264841 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:37:41 +0100 oc r264840 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:34:11 +0100 oc r264839 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 12:35:31 +0100 oj r264835 : new help ids for struct and function tabpage
2008-12-04 12:00:35 +0100 oj r264828 : set explicit help id
2008-12-03 14:53:27 +0100 oj r264786 : #i96845# change ref button
2008-12-03 14:51:49 +0100 oj r264785 : #i96845# change ref button
2008-12-03 08:51:57 +0100 oj r264746 : convert dos to unix lineends
2008-12-03 08:50:45 +0100 oj r264745 : convert dos to unix lineends
2008-12-03 08:50:05 +0100 oj r264744 : convert dos to unix lineends
2008-12-02 12:28:33 +0100 oj r264686 : clear help text when new helpid is set
2008-12-02 12:28:02 +0100 oj r264685 : set help id for listbox category
2008-12-02 07:15:56 +0100 oj r264655 : remove define to auto generate help ids
2008-12-01 14:36:43 +0100 oj r264604 : use temp var
2008-12-01 14:18:31 +0100 oj r264601 : moved ScJumpToken to formula
2008-12-01 14:18:11 +0100 oj r264600 : moved ScJumpToken to formula
2008-12-01 14:14:35 +0100 oj r264599 : moved ScJumpToken from sc
2008-12-01 10:48:51 +0100 oj r264589 : change quickhelptext from Shrink to Select
2008-12-01 10:28:41 +0100 oj r264588 : fix opcode data, has to be Any.Void
2008-11-28 11:16:48 +0100 oj r264532 : add help ids
2008-11-28 10:16:56 +0100 oj r264529 : set help id
2008-11-28 10:16:43 +0100 oj r264528 : set help id
2008-11-26 13:55:04 +0100 oj r264381 : #94535# use of optional instead of deleting a string myself and some small changes
2008-11-26 09:53:20 +0100 oj r264346 : compile error with debug/without debug
2008-11-25 07:41:28 +0100 oj r264271 : put static into the method which make use of them
2008-11-24 08:16:07 +0100 oj r264196 : removed not needed classes for op code
2008-11-24 08:13:44 +0100 oj r264195 : removed not needed classes for op code
2008-11-21 14:05:53 +0100 oj r264135 : make GetOpCode inline
2008-11-21 12:35:27 +0100 oj r264124 : hold symbols
2008-11-20 09:27:27 +0100 oj r264028 : merged code from DEV300_m35 which got lost
2008-11-19 20:42:12 +0100 oj r264022 : more changes for formula dialog remove
2008-11-19 20:37:41 +0100 oj r264021 : removed unused var
2008-11-19 20:35:35 +0100 oj r264020 : some more changes at token
2008-11-19 10:59:47 +0100 oj r263967 : deleted
2008-11-19 10:58:24 +0100 oj r263966 : add forui and for res files
2008-11-18 15:27:36 +0100 oj r263777 : unused para removed
2008-11-18 15:23:23 +0100 oj r263775 : add insert button to add field dlg
2008-11-18 13:39:53 +0100 oj r263764 : enable the formula dialog as well for conditional print as for conditional formatting
2008-11-18 12:03:25 +0100 oj r263760 : rename isRef in IsRef
2008-11-17 11:46:16 +0100 oj r263711 : patches for function handling
2008-11-17 11:36:22 +0100 oj r263710 : add new for forui and res file
2008-11-17 09:21:12 +0100 oj r263704 : patches for some resource for libformula
2008-11-15 12:45:30 +0100 oj r263701 : changes for formula editor extraction
2008-11-07 08:23:27 +0100 oj r263416 : merge from DEV300:m35
2008-11-07 08:22:35 +0100 oj r263415 : merge from DEV300:m35
2008-11-07 08:22:16 +0100 oj r263414 : merge from DEV300:m35
2008-11-07 08:21:41 +0100 oj r263413 : merge from DEV300:m35
2008-11-07 08:21:31 +0100 oj r263412 : merge from DEV300:m35
2008-11-07 08:20:38 +0100 oj r263411 : merge from DEV300:m35
2008-11-07 08:20:00 +0100 oj r263410 : merge from DEV300:m35
2008-11-07 08:18:50 +0100 oj r263409 : merge from DEV300:m35
2008-11-07 08:18:19 +0100 oj r263408 : merge from DEV300:m35
2008-11-07 08:10:27 +0100 oj r263407 : merge from DEV300:m35
2008-10-21 07:43:46 +0200 oj r262560 : some compile errors resolved
2008-10-17 16:40:01 +0200 oj r262291 : dep for 1st target
2008-10-07 10:08:39 +0200 oj r262077 : copy
2008-10-07 09:45:31 +0200 oj r262076 : #i94535#
2008-10-07 09:44:26 +0200 oj r262075 : #i94535# new base class
2008-10-07 09:43:21 +0200 oj r262074 : moved to formula
2008-10-07 09:41:51 +0200 oj r262073 : new images
2008-10-07 09:03:01 +0200 oj r262072 : new ids for formula
2008-10-02 08:46:27 +0200 oj r262024 : #i94535# move the formula compiler to formula
2008-10-02 08:08:54 +0200 oj r262023 : #i94535#
2008-10-02 08:06:28 +0200 oj r262022 : #i94535#
2008-10-02 08:05:52 +0200 oj r262021 : #i94535#
2008-10-01 17:15:29 +0200 oj r262014 : #i94535#
2008-10-01 17:12:40 +0200 oj r262013 : new module formula
2008-10-01 17:04:55 +0200 oj r262012 : #i94535#
2008-10-01 16:49:03 +0200 oj r262010 : #i94535#
2008-10-01 16:46:59 +0200 oj r262009 : #i94535#
2009-01-08 10:47:13 +00:00
|
|
|
#include <formula/compiler.hrc>
|
2011-05-13 23:11:42 -04:00
|
|
|
#include "dbdata.hxx"
|
2004-07-05 13:01:39 +00:00
|
|
|
#include "rangeutl.hxx"
|
|
|
|
#include "docfunc.hxx"
|
2008-03-07 10:19:00 +00:00
|
|
|
#include "funcdesc.hxx"
|
2011-11-23 21:32:01 -05:00
|
|
|
#include "markdata.hxx"
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/fontitem.hxx>
|
2003-04-24 16:13:03 +00:00
|
|
|
#include <com/sun/star/accessibility/XAccessible.hpp>
|
2002-06-10 13:56:35 +00:00
|
|
|
#include "AccessibleEditObject.hxx"
|
2002-06-11 14:52:05 +00:00
|
|
|
#include "AccessibleText.hxx"
|
2011-07-05 09:41:08 +01:00
|
|
|
#include <svtools/miscopt.hxx>
|
2011-08-15 17:57:35 -04:00
|
|
|
#include <comphelper/string.hxx>
|
2011-11-16 16:38:31 +00:00
|
|
|
#include <com/sun/star/frame/XLayoutManager.hpp>
|
|
|
|
#include <com/sun/star/frame/XModel.hpp>
|
|
|
|
#include <com/sun/star/frame/XController.hpp>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
#define THESIZE 1000000 // Should be more than enough!
|
|
|
|
#define TBX_WINDOW_HEIGHT 22 // in pixel - TODO: The same on all systems?
|
2011-08-15 15:46:02 -04:00
|
|
|
#define LEFT_OFFSET 5
|
2011-11-23 16:27:17 +00:00
|
|
|
#define INPUTWIN_MULTILINES 6
|
2012-08-22 18:39:04 +02:00
|
|
|
const long BUTTON_OFFSET = 2; ///< space between input line and the button to expand / collapse
|
|
|
|
const long ADDITIONAL_BORDER = 1; ///< height of the line at the bottom
|
|
|
|
const long ADDITIONAL_SPACE = 4; ///< additional vertical space when the multiline edit has more lines
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-11-16 16:38:31 +00:00
|
|
|
using com::sun::star::uno::Reference;
|
|
|
|
using com::sun::star::uno::UNO_QUERY;
|
|
|
|
|
|
|
|
using com::sun::star::frame::XLayoutManager;
|
|
|
|
using com::sun::star::frame::XModel;
|
|
|
|
using com::sun::star::frame::XFrame;
|
|
|
|
using com::sun::star::frame::XController;
|
|
|
|
using com::sun::star::beans::XPropertySet;
|
|
|
|
|
2004-07-05 13:01:39 +00:00
|
|
|
enum ScNameInputType
|
|
|
|
{
|
|
|
|
SC_NAME_INPUT_CELL,
|
|
|
|
SC_NAME_INPUT_RANGE,
|
|
|
|
SC_NAME_INPUT_NAMEDRANGE,
|
|
|
|
SC_NAME_INPUT_DATABASE,
|
|
|
|
SC_NAME_INPUT_ROW,
|
|
|
|
SC_NAME_INPUT_SHEET,
|
|
|
|
SC_NAME_INPUT_DEFINE,
|
|
|
|
SC_NAME_INPUT_BAD_NAME,
|
2011-09-26 00:34:14 +02:00
|
|
|
SC_NAME_INPUT_BAD_SELECTION,
|
|
|
|
SC_MANAGE_NAMES
|
2004-07-05 13:01:39 +00:00
|
|
|
};
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
ScTextWndBase::ScTextWndBase( vcl::Window* pParent, WinBits nStyle )
|
2012-05-28 09:07:11 +02:00
|
|
|
: Window ( pParent, nStyle )
|
|
|
|
{
|
|
|
|
if ( IsNativeControlSupported( CTRL_EDITBOX, PART_ENTIRE_CONTROL ) )
|
|
|
|
{
|
2012-06-13 14:08:28 +02:00
|
|
|
SetType( WINDOW_CALCINPUTLINE );
|
2014-10-20 09:10:45 +02:00
|
|
|
SetBorderStyle( WindowBorderStyle::NWF );
|
2012-05-28 09:07:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// class ScInputWindowWrapper
|
2014-02-25 19:58:48 +01:00
|
|
|
|
2012-06-16 14:12:33 +01:00
|
|
|
SFX_IMPL_CHILDWINDOW_WITHID(ScInputWindowWrapper,FID_INPUTLINE_STATUS)
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
ScInputWindowWrapper::ScInputWindowWrapper( vcl::Window* pParentP,
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nId,
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxBindings* pBindings,
|
2007-02-27 11:58:02 +00:00
|
|
|
SfxChildWinInfo* /* pInfo */ )
|
|
|
|
: SfxChildWindow( pParentP, nId )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-02-27 11:58:02 +00:00
|
|
|
ScInputWindow* pWin=new ScInputWindow( pParentP, pBindings );
|
2000-09-18 16:07:07 +00:00
|
|
|
pWindow = pWin;
|
|
|
|
|
|
|
|
pWin->Show();
|
|
|
|
|
|
|
|
pWin->SetSizePixel( pWin->CalcWindowSizePixel() );
|
|
|
|
|
|
|
|
eChildAlignment = SFX_ALIGN_LOWESTTOP;
|
|
|
|
pBindings->Invalidate( FID_TOGGLEINPUTLINE );
|
|
|
|
}
|
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
/**
|
|
|
|
* GetInfo is disposed of if there's a SFX_IMPL_TOOLBOX!
|
|
|
|
*/
|
2010-12-11 23:25:30 +01:00
|
|
|
SfxChildWinInfo ScInputWindowWrapper::GetInfo() const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
|
|
|
|
return aInfo;
|
|
|
|
}
|
|
|
|
|
2010-11-22 16:59:17 -08:00
|
|
|
#define IMAGE(id) pImgMgr->SeekImage(id)
|
2012-10-12 13:26:46 +02:00
|
|
|
static bool lcl_isExperimentalMode()
|
2011-07-05 09:41:08 +01:00
|
|
|
{
|
2011-12-05 09:48:31 +00:00
|
|
|
// make inputbar feature on by default, leave the switch for the
|
|
|
|
// moment in case we need to back it out easily
|
|
|
|
return true;
|
2011-07-05 09:41:08 +01:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// class ScInputWindow
|
2014-02-25 19:58:48 +01:00
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
static ScTextWndBase* lcl_chooseRuntimeImpl( vcl::Window* pParent, SfxBindings* pBind )
|
2011-07-05 09:41:08 +01:00
|
|
|
{
|
2011-12-13 00:08:41 -05:00
|
|
|
ScTabViewShell* pViewSh = NULL;
|
|
|
|
SfxDispatcher* pDisp = pBind->GetDispatcher();
|
|
|
|
if ( pDisp )
|
|
|
|
{
|
|
|
|
SfxViewFrame* pViewFrm = pDisp->GetFrame();
|
|
|
|
if ( pViewFrm )
|
|
|
|
pViewSh = PTR_CAST( ScTabViewShell, pViewFrm->GetViewShell() );
|
|
|
|
}
|
|
|
|
|
2011-07-05 09:41:08 +01:00
|
|
|
if ( !lcl_isExperimentalMode() )
|
2011-12-13 00:08:41 -05:00
|
|
|
return new ScTextWnd( pParent, pViewSh );
|
|
|
|
return new ScInputBarGroup( pParent, pViewSh );
|
2011-07-05 09:41:08 +01:00
|
|
|
}
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
ScInputWindow::ScInputWindow( vcl::Window* pParent, SfxBindings* pBind ) :
|
2014-06-19 21:11:48 +02:00
|
|
|
// With WB_CLIPCHILDREN otherwise we get flickering
|
2012-08-22 18:39:04 +02:00
|
|
|
ToolBox ( pParent, WinBits(WB_CLIPCHILDREN) ),
|
2000-09-18 16:07:07 +00:00
|
|
|
aWndPos ( this ),
|
2011-12-13 00:08:41 -05:00
|
|
|
pRuntimeWindow ( lcl_chooseRuntimeImpl( this, pBind ) ),
|
2011-07-05 09:41:08 +01:00
|
|
|
aTextWindow ( *pRuntimeWindow ),
|
2007-02-27 11:58:02 +00:00
|
|
|
pInputHdl ( NULL ),
|
2014-06-19 21:11:48 +02:00
|
|
|
aTextOk ( ScResId( SCSTR_QHELP_BTNOK ) ), // Not always new as a Resource
|
2000-09-18 16:07:07 +00:00
|
|
|
aTextCancel ( ScResId( SCSTR_QHELP_BTNCANCEL ) ),
|
|
|
|
aTextSum ( ScResId( SCSTR_QHELP_BTNSUM ) ),
|
|
|
|
aTextEqual ( ScResId( SCSTR_QHELP_BTNEQUAL ) ),
|
2011-11-24 19:45:09 +00:00
|
|
|
mnMaxY (0),
|
2011-08-15 15:46:02 -04:00
|
|
|
bIsOkCancelMode ( false ),
|
2011-11-30 18:49:40 +00:00
|
|
|
bInResize ( false ),
|
|
|
|
mbIsMultiLine ( lcl_isExperimentalMode() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ScModule* pScMod = SC_MOD();
|
2014-11-24 13:38:32 +00:00
|
|
|
SfxImageManager* pImgMgr = SfxImageManager::GetImageManager(*pScMod);
|
2007-01-25 10:06:47 +00:00
|
|
|
|
|
|
|
// #i73615# don't rely on SfxViewShell::Current while constructing the input line
|
|
|
|
// (also for GetInputHdl below)
|
|
|
|
ScTabViewShell* pViewSh = NULL;
|
|
|
|
SfxDispatcher* pDisp = pBind->GetDispatcher();
|
|
|
|
if ( pDisp )
|
|
|
|
{
|
|
|
|
SfxViewFrame* pViewFrm = pDisp->GetFrame();
|
|
|
|
if ( pViewFrm )
|
|
|
|
pViewSh = PTR_CAST( ScTabViewShell, pViewFrm->GetViewShell() );
|
|
|
|
}
|
2011-05-21 15:04:26 +02:00
|
|
|
OSL_ENSURE( pViewSh, "no view shell for input window" );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-08-15 15:46:02 -04:00
|
|
|
// Position window, 3 buttons, input window
|
2014-10-18 20:16:11 +02:00
|
|
|
InsertWindow ( 1, &aWndPos, ToolBoxItemBits::NONE, 0 );
|
2000-09-18 16:07:07 +00:00
|
|
|
InsertSeparator ( 1 );
|
2014-10-18 20:16:11 +02:00
|
|
|
InsertItem ( SID_INPUT_FUNCTION, IMAGE( SID_INPUT_FUNCTION ), ToolBoxItemBits::NONE, 2 );
|
|
|
|
InsertItem ( SID_INPUT_SUM, IMAGE( SID_INPUT_SUM ), ToolBoxItemBits::NONE, 3 );
|
|
|
|
InsertItem ( SID_INPUT_EQUAL, IMAGE( SID_INPUT_EQUAL ), ToolBoxItemBits::NONE, 4 );
|
2000-09-18 16:07:07 +00:00
|
|
|
InsertSeparator ( 5 );
|
2014-10-18 20:16:11 +02:00
|
|
|
InsertWindow ( 7, &aTextWindow, ToolBoxItemBits::NONE, 6 );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
aWndPos .SetQuickHelpText( ScResId( SCSTR_QHELP_POSWND ) );
|
|
|
|
aWndPos .SetHelpId ( HID_INSWIN_POS );
|
|
|
|
aTextWindow.SetQuickHelpText( ScResId( SCSTR_QHELP_INPUTWND ) );
|
|
|
|
aTextWindow.SetHelpId ( HID_INSWIN_INPUT );
|
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
// No SetHelpText: the helptexts come from the Help
|
2000-09-18 16:07:07 +00:00
|
|
|
SetItemText ( SID_INPUT_FUNCTION, ScResId( SCSTR_QHELP_BTNCALC ) );
|
|
|
|
SetHelpId ( SID_INPUT_FUNCTION, HID_INSWIN_CALC );
|
|
|
|
|
|
|
|
SetItemText ( SID_INPUT_SUM, aTextSum );
|
|
|
|
SetHelpId ( SID_INPUT_SUM, HID_INSWIN_SUMME );
|
|
|
|
|
|
|
|
SetItemText ( SID_INPUT_EQUAL, aTextEqual );
|
|
|
|
SetHelpId ( SID_INPUT_EQUAL, HID_INSWIN_FUNC );
|
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
SetHelpId( HID_SC_INPUTWIN ); // For the whole input row
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
aWndPos .Show();
|
2011-07-05 09:41:08 +01:00
|
|
|
aTextWindow.Show();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
pInputHdl = SC_MOD()->GetInputHdl( pViewSh, false ); // use own handler even if ref-handler is set
|
2000-09-18 16:07:07 +00:00
|
|
|
if (pInputHdl)
|
|
|
|
pInputHdl->SetInputWindow( this );
|
|
|
|
|
2012-02-08 23:00:59 -05:00
|
|
|
if (pInputHdl && !pInputHdl->GetFormString().isEmpty())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-06-19 21:11:48 +02:00
|
|
|
// Switch over while the Function AutoPilot is active
|
|
|
|
// -> show content of the Function AutoPilot again
|
|
|
|
// Also show selection (remember at the InputHdl)
|
2000-09-18 16:07:07 +00:00
|
|
|
aTextWindow.SetTextString( pInputHdl->GetFormString() );
|
|
|
|
}
|
|
|
|
else if ( pInputHdl && pInputHdl->IsInputMode() )
|
|
|
|
{
|
2014-06-19 21:11:48 +02:00
|
|
|
// If the input row was hidden while editing (e.g. when editing a formula
|
|
|
|
// and then switching to another document or the help), display the text
|
|
|
|
// we just edited from the InputHandler
|
|
|
|
aTextWindow.SetTextString( pInputHdl->GetEditString() ); // Dispaly text
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pInputHdl->IsTopMode() )
|
2014-06-19 21:11:48 +02:00
|
|
|
pInputHdl->SetMode( SC_INPUT_TABLE ); // Focus ends up at the bottom anyways
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else if ( pViewSh )
|
2014-06-19 21:11:48 +02:00
|
|
|
pViewSh->UpdateInputHandler( true ); // Absolutely necessary update
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-11-19 10:15:17 +00:00
|
|
|
pImgMgr->RegisterToolBox( this );
|
2011-01-20 16:34:26 +01:00
|
|
|
SetAccessibleName(ScResId(STR_ACC_TOOLBAR_FORMULA));
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2010-12-11 23:25:30 +01:00
|
|
|
ScInputWindow::~ScInputWindow()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-06-19 21:11:48 +02:00
|
|
|
bool bDown = ( ScGlobal::pSysLocale == NULL ); // after Clear?
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// if any view's input handler has a pointer to this input window, reset it
|
|
|
|
// (may be several ones, #74522#)
|
|
|
|
// member pInputHdl is not used here
|
|
|
|
|
|
|
|
if ( !bDown )
|
|
|
|
{
|
|
|
|
TypeId aScType = TYPE(ScTabViewShell);
|
|
|
|
SfxViewShell* pSh = SfxViewShell::GetFirst( &aScType );
|
|
|
|
while ( pSh )
|
|
|
|
{
|
2014-10-23 08:57:36 +02:00
|
|
|
ScInputHandler* pHdl = static_cast<ScTabViewShell*>(pSh)->GetInputHandler();
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pHdl && pHdl->GetInputWindow() == this )
|
2006-01-13 16:02:49 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
pHdl->SetInputWindow( NULL );
|
2011-03-10 16:55:21 -05:00
|
|
|
pHdl->StopInputWinEngine( false ); // reset pTopView pointer
|
2006-01-13 16:02:49 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
pSh = SfxViewShell::GetNext( *pSh, &aScType );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-24 13:38:32 +00:00
|
|
|
SfxImageManager::GetImageManager( *SC_MOD() )->ReleaseToolBox( this );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScInputWindow::SetInputHandler( ScInputHandler* pNew )
|
|
|
|
{
|
2014-06-19 21:11:48 +02:00
|
|
|
// Is called in the Activate of the View ...
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pNew != pInputHdl )
|
|
|
|
{
|
2014-06-19 21:11:48 +02:00
|
|
|
// On Reload (last version) the pInputHdl is the InputHandler of the old, deleted
|
|
|
|
// ViewShell: so don't touch it here!
|
2000-09-18 16:07:07 +00:00
|
|
|
pInputHdl = pNew;
|
|
|
|
if (pInputHdl)
|
|
|
|
pInputHdl->SetInputWindow( this );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-12 16:26:26 -04:00
|
|
|
bool ScInputWindow::UseSubTotal(ScRangeList* pRangeList) const
|
2002-11-19 14:07:16 +00:00
|
|
|
{
|
2011-05-12 16:26:26 -04:00
|
|
|
bool bSubTotal = false;
|
2002-11-19 14:07:16 +00:00
|
|
|
ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
|
|
|
|
if ( pViewSh )
|
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
ScDocument* pDoc = pViewSh->GetViewData().GetDocument();
|
2010-12-08 22:38:24 -08:00
|
|
|
size_t nRangeCount (pRangeList->size());
|
|
|
|
size_t nRangeIndex (0);
|
2002-11-19 14:07:16 +00:00
|
|
|
while (!bSubTotal && nRangeIndex < nRangeCount)
|
|
|
|
{
|
2010-12-10 16:07:50 -05:00
|
|
|
const ScRange* pRange = (*pRangeList)[nRangeIndex];
|
2002-11-19 14:07:16 +00:00
|
|
|
if( pRange )
|
|
|
|
{
|
2004-06-04 10:18:14 +00:00
|
|
|
SCTAB nTabEnd(pRange->aEnd.Tab());
|
|
|
|
SCTAB nTab(pRange->aStart.Tab());
|
2002-11-19 14:07:16 +00:00
|
|
|
while (!bSubTotal && nTab <= nTabEnd)
|
|
|
|
{
|
2004-06-04 10:18:14 +00:00
|
|
|
SCROW nRowEnd(pRange->aEnd.Row());
|
|
|
|
SCROW nRow(pRange->aStart.Row());
|
2002-11-19 14:07:16 +00:00
|
|
|
while (!bSubTotal && nRow <= nRowEnd)
|
|
|
|
{
|
2010-06-23 13:38:34 +02:00
|
|
|
if (pDoc->RowFiltered(nRow, nTab))
|
2011-05-12 16:26:26 -04:00
|
|
|
bSubTotal = true;
|
2002-11-19 14:07:16 +00:00
|
|
|
else
|
|
|
|
++nRow;
|
|
|
|
}
|
|
|
|
++nTab;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++nRangeIndex;
|
|
|
|
}
|
|
|
|
|
2011-05-12 16:26:26 -04:00
|
|
|
const ScDBCollection::NamedDBs& rDBs = pDoc->GetDBCollection()->getNamedDBs();
|
|
|
|
ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end();
|
|
|
|
for (; !bSubTotal && itr != itrEnd; ++itr)
|
2002-11-19 14:07:16 +00:00
|
|
|
{
|
2011-05-12 16:26:26 -04:00
|
|
|
const ScDBData& rDB = *itr;
|
|
|
|
if (!rDB.HasAutoFilter())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
nRangeIndex = 0;
|
|
|
|
while (!bSubTotal && nRangeIndex < nRangeCount)
|
2002-11-19 14:07:16 +00:00
|
|
|
{
|
2011-05-12 16:26:26 -04:00
|
|
|
const ScRange* pRange = (*pRangeList)[nRangeIndex];
|
|
|
|
if( pRange )
|
2002-11-19 14:07:16 +00:00
|
|
|
{
|
2011-05-12 16:26:26 -04:00
|
|
|
ScRange aDBArea;
|
|
|
|
rDB.GetArea(aDBArea);
|
|
|
|
if (aDBArea.Intersects(*pRange))
|
|
|
|
bSubTotal = true;
|
2002-11-19 14:07:16 +00:00
|
|
|
}
|
2011-05-12 16:26:26 -04:00
|
|
|
++nRangeIndex;
|
2002-11-19 14:07:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bSubTotal;
|
|
|
|
}
|
|
|
|
|
2010-12-11 23:25:30 +01:00
|
|
|
void ScInputWindow::Select()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ScModule* pScMod = SC_MOD();
|
|
|
|
ToolBox::Select();
|
|
|
|
|
|
|
|
switch ( GetCurItemId() )
|
|
|
|
{
|
|
|
|
case SID_INPUT_FUNCTION:
|
|
|
|
{
|
|
|
|
//! new method at ScModule to query if function autopilot is open
|
|
|
|
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
|
|
|
|
if ( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) )
|
|
|
|
{
|
2000-09-22 17:57:10 +00:00
|
|
|
pViewFrm->GetDispatcher()->Execute( SID_OPENDLG_FUNCTION,
|
2014-10-11 16:01:26 +02:00
|
|
|
SfxCallMode::SYNCHRON | SfxCallMode::RECORD );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
// The Toolbox will be disabled anyways, so we don't need to switch here,
|
|
|
|
// regardless whether it succeeded or not!
|
2000-09-18 16:07:07 +00:00
|
|
|
// SetOkCancelMode();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SID_INPUT_CANCEL:
|
|
|
|
pScMod->InputCancelHandler();
|
|
|
|
SetSumAssignMode();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SID_INPUT_OK:
|
|
|
|
pScMod->InputEnterHandler();
|
|
|
|
SetSumAssignMode();
|
2014-06-19 21:11:48 +02:00
|
|
|
aTextWindow.Invalidate(); // Or else the Selection remains
|
2000-09-18 16:07:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SID_INPUT_SUM:
|
|
|
|
{
|
|
|
|
ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
|
|
|
|
if ( pViewSh )
|
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
const ScMarkData& rMark = pViewSh->GetViewData().GetMarkData();
|
2007-06-20 12:32:39 +00:00
|
|
|
if ( rMark.IsMarked() || rMark.IsMultiMarked() )
|
|
|
|
{
|
2007-07-31 15:36:58 +00:00
|
|
|
ScRangeList aMarkRangeList;
|
2011-03-10 16:55:21 -05:00
|
|
|
rMark.FillRangeListWithMarks( &aMarkRangeList, false );
|
2014-06-18 12:14:29 +02:00
|
|
|
ScDocument* pDoc = pViewSh->GetViewData().GetDocument();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2007-06-20 12:32:39 +00:00
|
|
|
// check if one of the marked ranges is empty
|
|
|
|
bool bEmpty = false;
|
2010-12-08 22:38:24 -08:00
|
|
|
const size_t nCount = aMarkRangeList.size();
|
|
|
|
for ( size_t i = 0; i < nCount; ++i )
|
2007-06-20 12:32:39 +00:00
|
|
|
{
|
2010-12-10 16:07:50 -05:00
|
|
|
const ScRange aRange( *aMarkRangeList[i] );
|
2007-06-20 12:32:39 +00:00
|
|
|
if ( pDoc->IsBlockEmpty( aRange.aStart.Tab(),
|
|
|
|
aRange.aStart.Col(), aRange.aStart.Row(),
|
|
|
|
aRange.aEnd.Col(), aRange.aEnd.Row() ) )
|
|
|
|
{
|
|
|
|
bEmpty = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-11-19 14:07:16 +00:00
|
|
|
|
2007-06-20 12:32:39 +00:00
|
|
|
if ( bEmpty )
|
|
|
|
{
|
2007-07-31 15:36:58 +00:00
|
|
|
ScRangeList aRangeList;
|
2014-04-23 11:08:48 +02:00
|
|
|
const bool bDataFound = pViewSh->GetAutoSumArea( aRangeList );
|
2007-06-20 12:32:39 +00:00
|
|
|
if ( bDataFound )
|
|
|
|
{
|
2010-12-08 22:38:24 -08:00
|
|
|
ScAddress aAddr = aRangeList.back()->aEnd;
|
2010-10-04 14:52:20 -04:00
|
|
|
aAddr.IncRow();
|
2014-04-23 11:08:48 +02:00
|
|
|
const bool bSubTotal( UseSubTotal( &aRangeList ) );
|
2010-10-04 14:52:20 -04:00
|
|
|
pViewSh->EnterAutoSum( aRangeList, bSubTotal, aAddr );
|
2007-06-20 12:32:39 +00:00
|
|
|
}
|
|
|
|
}
|
2002-11-19 14:07:16 +00:00
|
|
|
else
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-04-23 11:08:48 +02:00
|
|
|
const bool bSubTotal( UseSubTotal( &aMarkRangeList ) );
|
2010-12-08 22:38:24 -08:00
|
|
|
for ( size_t i = 0; i < nCount; ++i )
|
2007-06-20 12:32:39 +00:00
|
|
|
{
|
2010-12-10 16:07:50 -05:00
|
|
|
const ScRange aRange( *aMarkRangeList[i] );
|
2014-05-02 15:42:25 +02:00
|
|
|
const bool bSetCursor = ( i == nCount - 1 );
|
|
|
|
const bool bContinue = ( i != 0 );
|
2007-06-20 12:32:39 +00:00
|
|
|
if ( !pViewSh->AutoSum( aRange, bSubTotal, bSetCursor, bContinue ) )
|
|
|
|
{
|
2011-03-10 16:55:21 -05:00
|
|
|
pViewSh->MarkRange( aRange, false, false );
|
2007-07-31 15:36:58 +00:00
|
|
|
pViewSh->SetCursor( aRange.aEnd.Col(), aRange.aEnd.Row() );
|
|
|
|
const ScRangeList aRangeList;
|
2010-10-04 14:52:20 -04:00
|
|
|
ScAddress aAddr = aRange.aEnd;
|
|
|
|
aAddr.IncRow();
|
2013-10-07 14:40:24 +02:00
|
|
|
const OUString aFormula = pViewSh->GetAutoSumFormula(
|
2010-10-04 14:52:20 -04:00
|
|
|
aRangeList, bSubTotal, aAddr );
|
2007-07-31 15:36:58 +00:00
|
|
|
SetFuncString( aFormula );
|
2007-06-20 12:32:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2007-06-20 12:32:39 +00:00
|
|
|
}
|
2014-06-19 21:11:48 +02:00
|
|
|
else // Only insert into input row
|
2007-06-20 12:32:39 +00:00
|
|
|
{
|
2007-07-31 15:36:58 +00:00
|
|
|
ScRangeList aRangeList;
|
2014-04-23 11:08:48 +02:00
|
|
|
const bool bDataFound = pViewSh->GetAutoSumArea( aRangeList );
|
|
|
|
const bool bSubTotal( UseSubTotal( &aRangeList ) );
|
2014-06-18 12:14:29 +02:00
|
|
|
ScAddress aAddr = pViewSh->GetViewData().GetCurPos();
|
2013-10-07 14:40:24 +02:00
|
|
|
const OUString aFormula = pViewSh->GetAutoSumFormula( aRangeList, bSubTotal, aAddr );
|
2000-09-18 16:07:07 +00:00
|
|
|
SetFuncString( aFormula );
|
|
|
|
|
|
|
|
if ( bDataFound && pScMod->IsEditMode() )
|
|
|
|
{
|
|
|
|
ScInputHandler* pHdl = pScMod->GetInputHdl( pViewSh );
|
|
|
|
if ( pHdl )
|
|
|
|
{
|
|
|
|
pHdl->InitRangeFinder( aFormula );
|
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
//! SetSelection at the InputHandler?
|
|
|
|
//! Set bSelIsRef?
|
2013-10-07 14:40:24 +02:00
|
|
|
const sal_Int32 nOpen = aFormula.indexOf('(');
|
2014-02-02 22:16:48 -06:00
|
|
|
const sal_Int32 nLen = aFormula.getLength();
|
2013-10-07 14:40:24 +02:00
|
|
|
if ( nOpen != -1 && nLen > nOpen )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-11-19 14:07:16 +00:00
|
|
|
sal_uInt8 nAdd(1);
|
|
|
|
if (bSubTotal)
|
|
|
|
nAdd = 3;
|
|
|
|
ESelection aSel(0,nOpen+nAdd,0,nLen-1);
|
2000-09-18 16:07:07 +00:00
|
|
|
EditView* pTableView = pHdl->GetTableView();
|
|
|
|
if (pTableView)
|
|
|
|
pTableView->SetSelection(aSel);
|
|
|
|
EditView* pTopView = pHdl->GetTopView();
|
|
|
|
if (pTopView)
|
|
|
|
pTopView->SetSelection(aSel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SID_INPUT_EQUAL:
|
|
|
|
{
|
|
|
|
aTextWindow.StartEditEngine();
|
2014-06-19 21:11:48 +02:00
|
|
|
if ( pScMod->IsEditMode() ) // Isn't if e.g. protected
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-08-15 15:46:02 -04:00
|
|
|
aTextWindow.StartEditEngine();
|
2014-01-10 11:47:19 +00:00
|
|
|
|
|
|
|
sal_Int32 nStartPos = 1;
|
|
|
|
sal_Int32 nEndPos = 1;
|
|
|
|
|
|
|
|
ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
|
|
|
|
if ( pViewSh )
|
|
|
|
{
|
|
|
|
const OUString& rString = aTextWindow.GetTextString();
|
|
|
|
const sal_Int32 nLen = rString.getLength();
|
|
|
|
|
2014-06-18 12:14:29 +02:00
|
|
|
ScDocument* pDoc = pViewSh->GetViewData().GetDocument();
|
|
|
|
CellType eCellType = pDoc->GetCellType( pViewSh->GetViewData().GetCurPos() );
|
2014-01-10 11:47:19 +00:00
|
|
|
switch ( eCellType )
|
|
|
|
{
|
|
|
|
case CELLTYPE_VALUE:
|
|
|
|
{
|
|
|
|
nEndPos = nLen + 1;
|
|
|
|
aTextWindow.SetTextString("=" + rString);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CELLTYPE_STRING:
|
|
|
|
case CELLTYPE_EDIT:
|
|
|
|
nStartPos = 0;
|
|
|
|
nEndPos = nLen;
|
|
|
|
break;
|
|
|
|
case CELLTYPE_FORMULA:
|
|
|
|
nEndPos = nLen;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aTextWindow.SetTextString("=");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
EditView* pView = aTextWindow.GetEditView();
|
|
|
|
if (pView)
|
|
|
|
{
|
2014-01-10 11:47:19 +00:00
|
|
|
pView->SetSelection( ESelection(0, nStartPos, 0, nEndPos) );
|
2000-09-18 16:07:07 +00:00
|
|
|
pScMod->InputChanged(pView);
|
|
|
|
SetOkCancelMode();
|
2014-02-20 11:55:27 +02:00
|
|
|
pView->SetEditEngineUpdateMode(true);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-22 18:39:04 +02:00
|
|
|
void ScInputWindow::Paint( const Rectangle& rRect )
|
|
|
|
{
|
|
|
|
ToolBox::Paint( rRect );
|
|
|
|
|
|
|
|
// draw a line at the bottom to distinguish that from the grid
|
|
|
|
// (we have space for that thanks to ADDITIONAL_BORDER)
|
|
|
|
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
|
|
|
|
SetLineColor( rStyleSettings.GetShadowColor() );
|
|
|
|
|
|
|
|
Size aSize = GetSizePixel();
|
|
|
|
DrawLine( Point( 0, aSize.Height() - 1 ), Point( aSize.Width() - 1, aSize.Height() - 1 ) );
|
|
|
|
}
|
|
|
|
|
2010-12-11 23:25:30 +01:00
|
|
|
void ScInputWindow::Resize()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-11-23 16:27:17 +00:00
|
|
|
ToolBox::Resize();
|
2011-11-30 18:49:40 +00:00
|
|
|
if ( mbIsMultiLine )
|
2011-07-05 09:41:08 +01:00
|
|
|
{
|
2011-11-22 16:21:20 +00:00
|
|
|
aTextWindow.Resize();
|
2011-11-28 10:58:31 +00:00
|
|
|
Size aSize = GetSizePixel();
|
2012-08-22 18:39:04 +02:00
|
|
|
aSize.Height() = CalcWindowSizePixel().Height() + ADDITIONAL_BORDER;
|
2011-12-14 10:49:10 +00:00
|
|
|
ScInputBarGroup* pGroupBar = dynamic_cast< ScInputBarGroup* > ( pRuntimeWindow.get() );
|
|
|
|
if ( pGroupBar )
|
|
|
|
{
|
|
|
|
// To ensure smooth display and prevent the items in the toolbar being
|
|
|
|
// repositioned ( vertically ) we lock the vertical positioning of the toolbox
|
|
|
|
// items when we are displaying > 1 line.
|
|
|
|
// So, we need to adjust the height of the toolbox accordingly. If we don't
|
|
|
|
// then the largest item ( e.g. the GroupBar window ) will actually be
|
|
|
|
// positioned such that the toolbar will cut off the bottom of that item
|
|
|
|
if ( pGroupBar->GetNumLines() > 1 )
|
2012-08-22 18:39:04 +02:00
|
|
|
aSize.Height() += pGroupBar->GetVertOffset() + ADDITIONAL_SPACE;
|
2011-12-14 10:49:10 +00:00
|
|
|
}
|
2011-08-15 15:46:02 -04:00
|
|
|
SetSizePixel(aSize);
|
2011-08-20 23:09:40 +05:30
|
|
|
Invalidate();
|
2011-07-05 09:41:08 +01:00
|
|
|
}
|
2011-08-15 15:46:02 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
long nWidth = GetSizePixel().Width();
|
|
|
|
long nLeft = aTextWindow.GetPosPixel().X();
|
|
|
|
Size aSize = aTextWindow.GetSizePixel();
|
|
|
|
|
2013-04-11 00:21:40 -03:00
|
|
|
aSize.Width() = std::max( ((long)(nWidth - nLeft - 5)), (long)0 );
|
2011-08-15 15:46:02 -04:00
|
|
|
|
|
|
|
aTextWindow.SetSizePixel( aSize );
|
|
|
|
aTextWindow.Invalidate();
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-02-18 13:30:53 +02:00
|
|
|
void ScInputWindow::SetFuncString( const OUString& rString, bool bDoEdit )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
//! new method at ScModule to query if function autopilot is open
|
|
|
|
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
|
|
|
|
EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) );
|
|
|
|
aTextWindow.StartEditEngine();
|
|
|
|
|
|
|
|
ScModule* pScMod = SC_MOD();
|
|
|
|
if ( pScMod->IsEditMode() )
|
|
|
|
{
|
2001-07-05 13:25:41 +00:00
|
|
|
if ( bDoEdit )
|
|
|
|
aTextWindow.GrabFocus();
|
2000-09-18 16:07:07 +00:00
|
|
|
aTextWindow.SetTextString( rString );
|
|
|
|
EditView* pView = aTextWindow.GetEditView();
|
|
|
|
if (pView)
|
|
|
|
{
|
2013-09-26 16:45:16 +02:00
|
|
|
sal_Int32 nLen = rString.getLength();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( nLen > 0 )
|
|
|
|
{
|
|
|
|
nLen--;
|
|
|
|
pView->SetSelection( ESelection( 0, nLen, 0, nLen ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
pScMod->InputChanged(pView);
|
|
|
|
if ( bDoEdit )
|
2014-06-19 21:11:48 +02:00
|
|
|
SetOkCancelMode(); // Not the case if immediately followed by Enter/Cancel
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-02-20 11:55:27 +02:00
|
|
|
pView->SetEditEngineUpdateMode(true);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-26 16:45:16 +02:00
|
|
|
void ScInputWindow::SetPosString( const OUString& rStr )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
aWndPos.SetPos( rStr );
|
|
|
|
}
|
|
|
|
|
2013-09-26 16:45:16 +02:00
|
|
|
void ScInputWindow::SetTextString( const OUString& rString )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-09-26 16:45:16 +02:00
|
|
|
if (rString.getLength() <= 32767)
|
2000-09-18 16:07:07 +00:00
|
|
|
aTextWindow.SetTextString(rString);
|
|
|
|
else
|
2013-10-08 13:31:42 +01:00
|
|
|
aTextWindow.SetTextString(rString.copy(0, 32767));
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScInputWindow::SetOkCancelMode()
|
|
|
|
{
|
|
|
|
//! new method at ScModule to query if function autopilot is open
|
|
|
|
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
|
|
|
|
EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) );
|
|
|
|
|
|
|
|
ScModule* pScMod = SC_MOD();
|
2014-11-24 13:38:32 +00:00
|
|
|
SfxImageManager* pImgMgr = SfxImageManager::GetImageManager(*pScMod);
|
2000-09-18 16:07:07 +00:00
|
|
|
if (!bIsOkCancelMode)
|
|
|
|
{
|
2014-06-19 21:11:48 +02:00
|
|
|
RemoveItem( 3 ); // Remove SID_INPUT_SUM and SID_INPUT_EQUAL
|
2000-09-18 16:07:07 +00:00
|
|
|
RemoveItem( 3 );
|
2014-10-18 20:16:11 +02:00
|
|
|
InsertItem( SID_INPUT_CANCEL, IMAGE( SID_INPUT_CANCEL ), ToolBoxItemBits::NONE, 3 );
|
|
|
|
InsertItem( SID_INPUT_OK, IMAGE( SID_INPUT_OK ), ToolBoxItemBits::NONE, 4 );
|
2000-09-18 16:07:07 +00:00
|
|
|
SetItemText ( SID_INPUT_CANCEL, aTextCancel );
|
|
|
|
SetHelpId ( SID_INPUT_CANCEL, HID_INSWIN_CANCEL );
|
|
|
|
SetItemText ( SID_INPUT_OK, aTextOk );
|
|
|
|
SetHelpId ( SID_INPUT_OK, HID_INSWIN_OK );
|
2014-02-18 13:30:53 +02:00
|
|
|
bIsOkCancelMode = true;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScInputWindow::SetSumAssignMode()
|
|
|
|
{
|
|
|
|
//! new method at ScModule to query if function autopilot is open
|
|
|
|
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
|
|
|
|
EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) );
|
|
|
|
|
|
|
|
ScModule* pScMod = SC_MOD();
|
2014-11-24 13:38:32 +00:00
|
|
|
SfxImageManager* pImgMgr = SfxImageManager::GetImageManager(*pScMod);
|
2000-09-18 16:07:07 +00:00
|
|
|
if (bIsOkCancelMode)
|
|
|
|
{
|
2014-06-19 21:11:48 +02:00
|
|
|
// Remove SID_INPUT_CANCEL, and SID_INPUT_OK
|
2000-09-18 16:07:07 +00:00
|
|
|
RemoveItem( 3 );
|
|
|
|
RemoveItem( 3 );
|
2014-10-18 20:16:11 +02:00
|
|
|
InsertItem( SID_INPUT_SUM, IMAGE( SID_INPUT_SUM ), ToolBoxItemBits::NONE, 3 );
|
|
|
|
InsertItem( SID_INPUT_EQUAL, IMAGE( SID_INPUT_EQUAL ), ToolBoxItemBits::NONE, 4 );
|
2000-09-18 16:07:07 +00:00
|
|
|
SetItemText ( SID_INPUT_SUM, aTextSum );
|
|
|
|
SetHelpId ( SID_INPUT_SUM, HID_INSWIN_SUMME );
|
|
|
|
SetItemText ( SID_INPUT_EQUAL, aTextEqual );
|
|
|
|
SetHelpId ( SID_INPUT_EQUAL, HID_INSWIN_FUNC );
|
2011-03-10 16:55:21 -05:00
|
|
|
bIsOkCancelMode = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
SetFormulaMode(false); // No editing -> no formula
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-18 13:30:53 +02:00
|
|
|
void ScInputWindow::SetFormulaMode( bool bSet )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
aWndPos.SetFormulaMode(bSet);
|
|
|
|
aTextWindow.SetFormulaMode(bSet);
|
|
|
|
}
|
|
|
|
|
2013-01-21 14:32:09 +01:00
|
|
|
void ScInputWindow::SetText( const OUString& rString )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ToolBox::SetText(rString);
|
|
|
|
}
|
|
|
|
|
2013-01-21 14:32:09 +01:00
|
|
|
OUString ScInputWindow::GetText() const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return ToolBox::GetText();
|
|
|
|
}
|
|
|
|
|
2014-02-18 13:30:53 +02:00
|
|
|
bool ScInputWindow::IsInputActive()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-02-27 11:58:02 +00:00
|
|
|
return aTextWindow.IsInputActive();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EditView* ScInputWindow::GetEditView()
|
|
|
|
{
|
|
|
|
return aTextWindow.GetEditView();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScInputWindow::MakeDialogEditView()
|
|
|
|
{
|
|
|
|
aTextWindow.MakeDialogEditView();
|
|
|
|
}
|
|
|
|
|
2014-02-18 13:30:53 +02:00
|
|
|
void ScInputWindow::StopEditEngine( bool bAll )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-03-23 12:52:19 +00:00
|
|
|
aTextWindow.StopEditEngine( bAll );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScInputWindow::TextGrabFocus()
|
|
|
|
{
|
2012-02-07 15:36:29 +00:00
|
|
|
aTextWindow.TextGrabFocus();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScInputWindow::TextInvalidate()
|
|
|
|
{
|
|
|
|
aTextWindow.Invalidate();
|
|
|
|
}
|
|
|
|
|
2002-04-10 14:43:17 +00:00
|
|
|
void ScInputWindow::SwitchToTextWin()
|
|
|
|
{
|
|
|
|
// used for shift-ctrl-F2
|
|
|
|
|
|
|
|
aTextWindow.StartEditEngine();
|
|
|
|
if ( SC_MOD()->IsEditMode() )
|
|
|
|
{
|
2012-02-07 15:36:29 +00:00
|
|
|
aTextWindow.TextGrabFocus();
|
2002-04-10 14:43:17 +00:00
|
|
|
EditView* pView = aTextWindow.GetEditView();
|
|
|
|
if (pView)
|
|
|
|
{
|
2013-05-08 18:12:32 +02:00
|
|
|
sal_Int32 nPara = pView->GetEditEngine()->GetParagraphCount() ? ( pView->GetEditEngine()->GetParagraphCount() - 1 ) : 0;
|
2014-02-02 22:16:48 -06:00
|
|
|
sal_Int32 nLen = pView->GetEditEngine()->GetTextLen( nPara );
|
2012-02-07 15:36:29 +00:00
|
|
|
ESelection aSel( nPara, nLen, nPara, nLen );
|
2014-06-19 21:11:48 +02:00
|
|
|
pView->SetSelection( aSel ); // set cursor to end of text
|
2002-04-10 14:43:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void ScInputWindow::PosGrabFocus()
|
|
|
|
{
|
|
|
|
aWndPos.GrabFocus();
|
|
|
|
}
|
|
|
|
|
2014-02-18 13:30:53 +02:00
|
|
|
void ScInputWindow::EnableButtons( bool bEnable )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-07-05 13:25:41 +00:00
|
|
|
// when enabling buttons, always also enable the input window itself
|
|
|
|
if ( bEnable && !IsEnabled() )
|
|
|
|
Enable();
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
EnableItem( SID_INPUT_FUNCTION, bEnable );
|
|
|
|
EnableItem( bIsOkCancelMode ? SID_INPUT_CANCEL : SID_INPUT_SUM, bEnable );
|
|
|
|
EnableItem( bIsOkCancelMode ? SID_INPUT_OK : SID_INPUT_EQUAL, bEnable );
|
|
|
|
// Invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScInputWindow::StateChanged( StateChangedType nType )
|
|
|
|
{
|
|
|
|
ToolBox::StateChanged( nType );
|
|
|
|
|
2014-10-07 16:08:25 +02:00
|
|
|
if ( nType == StateChangedType::INITSHOW ) Resize();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2002-05-30 12:24:57 +00:00
|
|
|
|
|
|
|
void ScInputWindow::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
2015-01-12 12:55:32 +02:00
|
|
|
if ( rDCEvt.GetType() == DataChangedEventType::SETTINGS && (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
|
2002-05-30 12:24:57 +00:00
|
|
|
{
|
|
|
|
// update item images
|
|
|
|
ScModule* pScMod = SC_MOD();
|
2014-11-24 13:38:32 +00:00
|
|
|
SfxImageManager* pImgMgr = SfxImageManager::GetImageManager(*pScMod);
|
2002-05-30 12:24:57 +00:00
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
// IMAGE macro uses pScMod, pImgMg
|
2002-05-30 12:24:57 +00:00
|
|
|
SetItemImage( SID_INPUT_FUNCTION, IMAGE( SID_INPUT_FUNCTION ) );
|
|
|
|
if ( bIsOkCancelMode )
|
|
|
|
{
|
|
|
|
SetItemImage( SID_INPUT_CANCEL, IMAGE( SID_INPUT_CANCEL ) );
|
|
|
|
SetItemImage( SID_INPUT_OK, IMAGE( SID_INPUT_OK ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetItemImage( SID_INPUT_SUM, IMAGE( SID_INPUT_SUM ) );
|
|
|
|
SetItemImage( SID_INPUT_EQUAL, IMAGE( SID_INPUT_EQUAL ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ToolBox::DataChanged( rDCEvt );
|
|
|
|
}
|
|
|
|
|
2011-11-24 19:45:09 +00:00
|
|
|
bool ScInputWindow::IsPointerAtResizePos()
|
|
|
|
{
|
|
|
|
if ( GetOutputSizePixel().Height() - GetPointerPosPixel().Y() <= 4 )
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-11-23 16:27:17 +00:00
|
|
|
void ScInputWindow::MouseMove( const MouseEvent& rMEvt )
|
2011-08-15 15:46:02 -04:00
|
|
|
{
|
2011-11-30 18:49:40 +00:00
|
|
|
if ( mbIsMultiLine )
|
2011-11-23 16:27:17 +00:00
|
|
|
{
|
|
|
|
Point aPosPixel = GetPointerPosPixel();
|
|
|
|
|
|
|
|
ScInputBarGroup* pGroupBar = dynamic_cast< ScInputBarGroup* > ( pRuntimeWindow.get() );
|
2011-11-24 19:45:09 +00:00
|
|
|
|
|
|
|
if ( bInResize || IsPointerAtResizePos() )
|
2011-11-23 16:27:17 +00:00
|
|
|
SetPointer( Pointer( POINTER_WINDOW_SSIZE ) );
|
2011-11-24 19:45:09 +00:00
|
|
|
else
|
|
|
|
SetPointer( Pointer( POINTER_ARROW ) );
|
2011-11-23 16:27:17 +00:00
|
|
|
|
2011-11-24 19:45:09 +00:00
|
|
|
if ( bInResize )
|
|
|
|
{
|
|
|
|
// detect direction
|
|
|
|
long nResizeThreshold = ( (long)TBX_WINDOW_HEIGHT * 0.7 );
|
|
|
|
bool bResetPointerPos = false;
|
|
|
|
|
|
|
|
// Detect attempt to expand toolbar too much
|
|
|
|
if ( aPosPixel.Y() >= mnMaxY )
|
2011-11-23 16:27:17 +00:00
|
|
|
{
|
2011-11-24 19:45:09 +00:00
|
|
|
bResetPointerPos = true;
|
|
|
|
aPosPixel.Y() = mnMaxY;
|
|
|
|
} // or expanding down
|
|
|
|
else if ( GetOutputSizePixel().Height() - aPosPixel.Y() < -nResizeThreshold )
|
|
|
|
{
|
|
|
|
pGroupBar->IncrementVerticalSize();
|
|
|
|
bResetPointerPos = true;
|
|
|
|
} // or shrinking up
|
|
|
|
else if ( ( GetOutputSizePixel().Height() - aPosPixel.Y() ) > nResizeThreshold )
|
2011-11-23 16:27:17 +00:00
|
|
|
{
|
2011-11-24 19:45:09 +00:00
|
|
|
bResetPointerPos = true;
|
|
|
|
pGroupBar->DecrementVerticalSize();
|
2011-11-23 16:27:17 +00:00
|
|
|
}
|
|
|
|
|
2011-11-24 19:45:09 +00:00
|
|
|
if ( bResetPointerPos )
|
2011-11-23 16:27:17 +00:00
|
|
|
{
|
2011-11-24 19:45:09 +00:00
|
|
|
aPosPixel.Y() = GetOutputSizePixel().Height();
|
|
|
|
SetPointerPosPixel( aPosPixel );
|
2011-11-23 16:27:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ToolBox::MouseMove( rMEvt );
|
2011-08-15 15:46:02 -04:00
|
|
|
}
|
|
|
|
|
2011-11-24 19:45:09 +00:00
|
|
|
void ScInputWindow::MouseButtonDown( const MouseEvent& rMEvt )
|
|
|
|
{
|
2011-11-30 18:49:40 +00:00
|
|
|
if ( mbIsMultiLine )
|
2011-11-24 19:45:09 +00:00
|
|
|
{
|
|
|
|
if ( rMEvt.IsLeft() )
|
|
|
|
{
|
|
|
|
if ( IsPointerAtResizePos() )
|
|
|
|
{
|
|
|
|
// Don't leave the mouse pointer leave *this* window
|
|
|
|
CaptureMouse();
|
|
|
|
bInResize = true;
|
2014-06-19 21:11:48 +02:00
|
|
|
|
2011-11-24 19:45:09 +00:00
|
|
|
// find the height of the gridwin, we don't wan't to be
|
|
|
|
// able to expand the toolbar too far so we need to
|
2015-02-21 13:53:17 +01:00
|
|
|
// calculate an upper limit
|
2011-11-24 19:45:09 +00:00
|
|
|
// I'd prefer to leave at least a single column header and a
|
|
|
|
// row but I don't know how to get that value in pixels.
|
|
|
|
// Use TBX_WINDOW_HEIGHT for the moment
|
|
|
|
ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
|
|
|
|
mnMaxY = GetOutputSizePixel().Height() + ( pViewSh->GetGridHeight(SC_SPLIT_TOP) + pViewSh->GetGridHeight(SC_SPLIT_BOTTOM) ) - TBX_WINDOW_HEIGHT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ToolBox::MouseButtonDown( rMEvt );
|
|
|
|
}
|
2011-11-23 16:27:17 +00:00
|
|
|
void ScInputWindow::MouseButtonUp( const MouseEvent& rMEvt )
|
2011-08-15 15:46:02 -04:00
|
|
|
{
|
2011-11-30 18:49:40 +00:00
|
|
|
if ( mbIsMultiLine )
|
2011-11-23 16:27:17 +00:00
|
|
|
{
|
|
|
|
ReleaseMouse();
|
|
|
|
if ( rMEvt.IsLeft() )
|
2011-11-24 19:45:09 +00:00
|
|
|
{
|
2011-11-23 16:27:17 +00:00
|
|
|
bInResize = false;
|
2011-11-24 19:45:09 +00:00
|
|
|
mnMaxY = 0;
|
|
|
|
}
|
2011-11-23 16:27:17 +00:00
|
|
|
}
|
|
|
|
ToolBox::MouseButtonUp( rMEvt );
|
2011-08-15 15:46:02 -04:00
|
|
|
}
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
ScInputBarGroup::ScInputBarGroup(vcl::Window* pParent, ScTabViewShell* pViewSh)
|
2011-11-24 19:45:09 +00:00
|
|
|
: ScTextWndBase ( pParent, WinBits(WB_HIDE | WB_TABSTOP ) ),
|
2011-12-13 00:08:41 -05:00
|
|
|
aMultiTextWnd ( this, pViewSh ),
|
2012-05-28 09:07:11 +02:00
|
|
|
aButton ( this, WB_TABSTOP | WB_RECTSTYLE | WB_SMALLSTYLE ),
|
2011-12-14 10:49:10 +00:00
|
|
|
aScrollBar ( this, WB_TABSTOP | WB_VERT | WB_DRAG ),
|
|
|
|
nVertOffset ( 0 )
|
2011-07-05 09:41:08 +01:00
|
|
|
{
|
2011-08-15 15:46:02 -04:00
|
|
|
aMultiTextWnd.Show();
|
|
|
|
aMultiTextWnd.SetQuickHelpText( ScResId( SCSTR_QHELP_INPUTWND ) );
|
2012-05-28 09:07:11 +02:00
|
|
|
aMultiTextWnd.SetHelpId( HID_INSWIN_INPUT );
|
|
|
|
|
|
|
|
Size aSize( GetSettings().GetStyleSettings().GetScrollBarSize(), aMultiTextWnd.GetPixelHeightForLines(1) );
|
|
|
|
|
|
|
|
aButton.SetClickHdl( LINK( this, ScInputBarGroup, ClickHdl ) );
|
|
|
|
aButton.SetSizePixel( aSize );
|
2011-08-15 15:46:02 -04:00
|
|
|
aButton.Enable();
|
2014-10-14 09:36:33 +02:00
|
|
|
aButton.SetSymbol( SymbolType::SPIN_DOWN );
|
2011-11-23 16:27:17 +00:00
|
|
|
aButton.SetQuickHelpText( ScResId( SCSTR_QHELP_EXPAND_FORMULA ) );
|
2011-08-20 23:09:40 +05:30
|
|
|
aButton.Show();
|
2012-05-28 09:07:11 +02:00
|
|
|
|
|
|
|
aScrollBar.SetSizePixel( aSize );
|
2011-11-22 16:21:20 +00:00
|
|
|
aScrollBar.SetScrollHdl( LINK( this, ScInputBarGroup, Impl_ScrollHdl ) );
|
2011-07-05 09:41:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ScInputBarGroup::~ScInputBarGroup()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ScInputBarGroup::InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData )
|
|
|
|
{
|
2011-08-15 15:46:02 -04:00
|
|
|
aMultiTextWnd.InsertAccessibleTextData( rTextData );
|
2011-07-05 09:41:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ScInputBarGroup::RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData )
|
|
|
|
{
|
2011-08-15 15:46:02 -04:00
|
|
|
aMultiTextWnd.RemoveAccessibleTextData( rTextData );
|
2011-07-05 09:41:08 +01:00
|
|
|
}
|
|
|
|
|
2013-09-26 16:45:16 +02:00
|
|
|
const OUString&
|
2011-07-05 09:41:08 +01:00
|
|
|
ScInputBarGroup::GetTextString() const
|
|
|
|
{
|
2011-08-15 15:46:02 -04:00
|
|
|
return aMultiTextWnd.GetTextString();
|
2011-07-05 09:41:08 +01:00
|
|
|
}
|
|
|
|
|
2013-09-26 16:45:16 +02:00
|
|
|
void ScInputBarGroup::SetTextString( const OUString& rString )
|
2011-07-05 09:41:08 +01:00
|
|
|
{
|
2011-08-15 15:46:02 -04:00
|
|
|
aMultiTextWnd.SetTextString(rString);
|
2011-07-05 09:41:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScInputBarGroup::Resize()
|
|
|
|
{
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window *w=GetParent();
|
2011-08-15 15:46:02 -04:00
|
|
|
ScInputWindow *pParent;
|
|
|
|
pParent=dynamic_cast<ScInputWindow*>(w);
|
2011-07-05 09:41:08 +01:00
|
|
|
|
2011-08-15 15:46:02 -04:00
|
|
|
if(pParent==NULL)
|
|
|
|
{
|
|
|
|
OSL_FAIL("The parent window pointer pParent is null");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
long nWidth = pParent->GetSizePixel().Width();
|
2011-08-20 23:09:40 +05:30
|
|
|
long nLeft = GetPosPixel().X();
|
|
|
|
|
2011-08-15 15:46:02 -04:00
|
|
|
Size aSize = GetSizePixel();
|
2013-04-11 00:21:40 -03:00
|
|
|
aSize.Width() = std::max( ((long)(nWidth - nLeft - LEFT_OFFSET)), (long)0 );
|
2011-08-15 15:46:02 -04:00
|
|
|
|
2012-05-28 09:07:11 +02:00
|
|
|
aScrollBar.SetPosPixel(Point( aSize.Width() - aButton.GetSizePixel().Width(), aButton.GetSizePixel().Height() ) );
|
2011-11-22 16:21:20 +00:00
|
|
|
|
|
|
|
Size aTmpSize( aSize );
|
2012-05-28 09:07:11 +02:00
|
|
|
aTmpSize.Width() = aTmpSize.Width() - aButton.GetSizePixel().Width() - BUTTON_OFFSET;
|
2011-11-22 16:21:20 +00:00
|
|
|
aMultiTextWnd.SetSizePixel(aTmpSize);
|
|
|
|
|
|
|
|
aMultiTextWnd.Resize();
|
|
|
|
|
|
|
|
aSize.Height() = aMultiTextWnd.GetSizePixel().Height();
|
|
|
|
|
|
|
|
SetSizePixel(aSize);
|
|
|
|
|
2011-11-23 16:27:17 +00:00
|
|
|
if( aMultiTextWnd.GetNumLines() > 1 )
|
2011-08-15 15:46:02 -04:00
|
|
|
{
|
2014-10-14 09:36:33 +02:00
|
|
|
aButton.SetSymbol( SymbolType::SPIN_UP );
|
2011-11-23 16:27:17 +00:00
|
|
|
aButton.SetQuickHelpText( ScResId( SCSTR_QHELP_COLLAPSE_FORMULA ) );
|
2011-11-22 16:21:20 +00:00
|
|
|
Size scrollSize = aButton.GetSizePixel();
|
|
|
|
scrollSize.Height() = aMultiTextWnd.GetSizePixel().Height() - aButton.GetSizePixel().Height();
|
|
|
|
aScrollBar.SetSizePixel( scrollSize );
|
|
|
|
|
|
|
|
Size aOutSz = aMultiTextWnd.GetOutputSize();
|
|
|
|
|
|
|
|
aScrollBar.SetVisibleSize( aOutSz.Height() );
|
|
|
|
aScrollBar.SetPageSize( aOutSz.Height() );
|
|
|
|
aScrollBar.SetLineSize( aMultiTextWnd.GetTextHeight() );
|
|
|
|
aScrollBar.SetRange( Range( 0, aMultiTextWnd.GetEditEngTxtHeight() ) );
|
|
|
|
|
|
|
|
aScrollBar.Resize();
|
|
|
|
aScrollBar.Show();
|
2011-08-15 15:46:02 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-10-14 09:36:33 +02:00
|
|
|
aButton.SetSymbol( SymbolType::SPIN_DOWN );
|
2011-11-23 16:27:17 +00:00
|
|
|
aButton.SetQuickHelpText( ScResId( SCSTR_QHELP_EXPAND_FORMULA ) );
|
2011-11-22 16:21:20 +00:00
|
|
|
aScrollBar.Hide();
|
2011-08-15 15:46:02 -04:00
|
|
|
}
|
|
|
|
|
2012-05-28 09:07:11 +02:00
|
|
|
aButton.SetPosPixel(Point(aSize.Width() - aButton.GetSizePixel().Width(), 0));
|
2011-08-15 15:46:02 -04:00
|
|
|
|
2011-08-20 23:09:40 +05:30
|
|
|
Invalidate();
|
2011-07-05 09:41:08 +01:00
|
|
|
}
|
|
|
|
|
2014-02-18 13:30:53 +02:00
|
|
|
void ScInputBarGroup::StopEditEngine( bool bAll )
|
2011-07-05 09:41:08 +01:00
|
|
|
{
|
2011-08-15 15:46:02 -04:00
|
|
|
aMultiTextWnd.StopEditEngine( bAll );
|
2011-07-05 09:41:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScInputBarGroup::StartEditEngine()
|
|
|
|
{
|
2011-08-15 15:46:02 -04:00
|
|
|
aMultiTextWnd.StartEditEngine();
|
2011-07-05 09:41:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScInputBarGroup::MakeDialogEditView()
|
|
|
|
{
|
2011-08-15 15:46:02 -04:00
|
|
|
aMultiTextWnd.MakeDialogEditView();
|
2011-07-05 09:41:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
EditView* ScInputBarGroup::GetEditView()
|
|
|
|
{
|
2011-08-15 15:46:02 -04:00
|
|
|
return aMultiTextWnd.GetEditView();
|
2011-07-05 09:41:08 +01:00
|
|
|
}
|
|
|
|
|
2014-02-18 13:30:53 +02:00
|
|
|
bool ScInputBarGroup::IsInputActive()
|
2011-07-05 09:41:08 +01:00
|
|
|
{
|
2011-08-15 15:46:02 -04:00
|
|
|
return aMultiTextWnd.IsInputActive();
|
2011-07-05 09:41:08 +01:00
|
|
|
}
|
|
|
|
|
2014-02-18 13:30:53 +02:00
|
|
|
void ScInputBarGroup::SetFormulaMode(bool bSet)
|
2011-07-05 09:41:08 +01:00
|
|
|
{
|
2011-08-15 15:46:02 -04:00
|
|
|
aMultiTextWnd.SetFormulaMode(bSet);
|
|
|
|
}
|
|
|
|
|
2011-11-23 16:27:17 +00:00
|
|
|
void ScInputBarGroup::IncrementVerticalSize()
|
|
|
|
{
|
|
|
|
aMultiTextWnd.SetNumLines( aMultiTextWnd.GetNumLines() + 1 );
|
|
|
|
TriggerToolboxLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScInputBarGroup::DecrementVerticalSize()
|
|
|
|
{
|
|
|
|
if ( aMultiTextWnd.GetNumLines() > 1 )
|
|
|
|
{
|
|
|
|
aMultiTextWnd.SetNumLines( aMultiTextWnd.GetNumLines() - 1 );
|
|
|
|
TriggerToolboxLayout();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(ScInputBarGroup, ClickHdl)
|
2011-08-15 15:46:02 -04:00
|
|
|
{
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window *w=GetParent();
|
2011-08-15 15:46:02 -04:00
|
|
|
ScInputWindow *pParent;
|
|
|
|
pParent=dynamic_cast<ScInputWindow*>(w);
|
|
|
|
|
|
|
|
if(pParent==NULL)
|
|
|
|
{
|
|
|
|
OSL_FAIL("The parent window pointer pParent is null");
|
|
|
|
return 1;
|
|
|
|
}
|
2011-11-23 16:27:17 +00:00
|
|
|
if( aMultiTextWnd.GetNumLines() > 1 )
|
2011-08-15 15:46:02 -04:00
|
|
|
{
|
2011-11-23 16:27:17 +00:00
|
|
|
aMultiTextWnd.SetNumLines( 1 );
|
2011-08-15 15:46:02 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-23 16:27:17 +00:00
|
|
|
aMultiTextWnd.SetNumLines( aMultiTextWnd.GetLastNumExpandedLines() );
|
2011-08-15 15:46:02 -04:00
|
|
|
}
|
2011-11-23 16:27:17 +00:00
|
|
|
TriggerToolboxLayout();
|
2014-06-19 21:11:48 +02:00
|
|
|
|
2011-12-14 12:49:28 +00:00
|
|
|
// Restore focus to input line(s) if necessary
|
|
|
|
if ( SC_MOD()->GetInputHdl()->IsTopMode() )
|
|
|
|
aMultiTextWnd.GrabFocus();
|
2011-11-23 16:27:17 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2011-11-22 16:21:20 +00:00
|
|
|
|
2011-11-23 16:27:17 +00:00
|
|
|
void ScInputBarGroup::TriggerToolboxLayout()
|
|
|
|
{
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window *w=GetParent();
|
2014-06-06 10:48:35 +01:00
|
|
|
ScInputWindow &rParent = dynamic_cast<ScInputWindow&>(*w);
|
2011-11-16 16:38:31 +00:00
|
|
|
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
|
2011-12-14 10:49:10 +00:00
|
|
|
|
|
|
|
// Capture the vertical position of this window in the toolbar, when we increase
|
2014-11-10 15:05:25 +01:00
|
|
|
// the size of the toolbar to accommodate expanded line input we need to take this
|
2011-12-14 10:49:10 +00:00
|
|
|
// into account
|
|
|
|
if ( !nVertOffset )
|
2014-06-06 10:48:35 +01:00
|
|
|
nVertOffset = rParent.GetItemPosRect( rParent.GetItemCount() - 1 ).Top();
|
2011-12-14 10:49:10 +00:00
|
|
|
|
2011-11-16 16:38:31 +00:00
|
|
|
if ( pViewFrm )
|
|
|
|
{
|
|
|
|
Reference< com::sun::star::beans::XPropertySet > xPropSet( pViewFrm->GetFrame().GetFrameInterface(), UNO_QUERY );
|
|
|
|
Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
|
|
|
|
|
|
|
|
if ( xPropSet.is() )
|
|
|
|
{
|
2013-06-29 21:24:12 +02:00
|
|
|
com::sun::star::uno::Any aValue = xPropSet->getPropertyValue("LayoutManager");
|
2011-11-16 16:38:31 +00:00
|
|
|
aValue >>= xLayoutManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( xLayoutManager.is() )
|
|
|
|
{
|
2011-11-24 19:45:09 +00:00
|
|
|
if ( aMultiTextWnd.GetNumLines() > 1)
|
2014-06-06 10:48:35 +01:00
|
|
|
rParent.SetToolbarLayoutMode( TBX_LAYOUT_LOCKVERT );
|
2011-11-24 19:45:09 +00:00
|
|
|
else
|
2014-06-06 10:48:35 +01:00
|
|
|
rParent.SetToolbarLayoutMode( TBX_LAYOUT_NORMAL );
|
2011-11-22 16:21:20 +00:00
|
|
|
xLayoutManager->lock();
|
2015-01-12 12:55:32 +02:00
|
|
|
DataChangedEvent aFakeUpdate( DataChangedEventType::SETTINGS, NULL, AllSettingsFlags::STYLE );
|
2014-06-19 21:11:48 +02:00
|
|
|
|
2011-11-16 16:38:31 +00:00
|
|
|
// this basically will trigger the reposititioning of the
|
|
|
|
// items in the toolbar from ImplFormat ( which is controlled by
|
|
|
|
// mnWinHeight ) which in turn is updated in ImplCalcItem which is
|
|
|
|
// controlled by mbCalc. Additionally the ImplFormat above is
|
|
|
|
// controlled via mbFormat. It seems the easiest way to get these
|
|
|
|
// booleans set is to send in the fake event below.
|
2014-06-06 10:48:35 +01:00
|
|
|
rParent.DataChanged( aFakeUpdate);
|
2014-06-19 21:11:48 +02:00
|
|
|
|
2011-11-28 10:58:31 +00:00
|
|
|
// highest item in toolbar will have been calculated via the
|
|
|
|
// event above. Call resize on InputBar to pick up the height
|
|
|
|
// change
|
2014-06-06 10:48:35 +01:00
|
|
|
rParent.Resize();
|
2014-06-19 21:11:48 +02:00
|
|
|
|
2011-11-16 16:38:31 +00:00
|
|
|
// unlock relayouts the toolbars in the 4 quadrants
|
|
|
|
xLayoutManager->unlock();
|
|
|
|
}
|
|
|
|
}
|
2011-07-05 09:41:08 +01:00
|
|
|
}
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(ScInputBarGroup, Impl_ScrollHdl)
|
2011-08-20 23:09:40 +05:30
|
|
|
{
|
2011-11-23 16:27:17 +00:00
|
|
|
aMultiTextWnd.DoScroll();
|
2011-09-07 13:26:36 -04:00
|
|
|
return 0;
|
2011-08-20 23:09:40 +05:30
|
|
|
}
|
|
|
|
|
2012-02-07 15:36:29 +00:00
|
|
|
void ScInputBarGroup::TextGrabFocus()
|
|
|
|
{
|
|
|
|
aMultiTextWnd.TextGrabFocus();
|
|
|
|
}
|
2011-08-20 23:09:40 +05:30
|
|
|
|
2011-12-13 00:08:41 -05:00
|
|
|
ScMultiTextWnd::ScMultiTextWnd( ScInputBarGroup* pParen, ScTabViewShell* pViewSh )
|
2011-12-09 00:27:17 +01:00
|
|
|
:
|
2011-12-13 00:08:41 -05:00
|
|
|
ScTextWnd( pParen, pViewSh ),
|
2011-12-09 00:27:17 +01:00
|
|
|
mrGroupBar(* pParen ),
|
|
|
|
mnLines( 1 ),
|
2012-01-24 11:14:38 +00:00
|
|
|
mnLastExpandedLines( INPUTWIN_MULTILINES ),
|
|
|
|
mbInvalidate( false )
|
2011-07-05 09:41:08 +01:00
|
|
|
{
|
2012-01-25 12:36:17 +00:00
|
|
|
Size aBorder;
|
|
|
|
aBorder = CalcWindowSize( aBorder);
|
|
|
|
mnBorderHeight = aBorder.Height();
|
2011-12-09 00:27:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ScMultiTextWnd::~ScMultiTextWnd()
|
|
|
|
{
|
2011-07-05 09:41:08 +01:00
|
|
|
}
|
|
|
|
|
2013-03-12 09:46:46 +02:00
|
|
|
void ScMultiTextWnd::Paint( const Rectangle& rRect )
|
2011-12-12 14:53:58 -05:00
|
|
|
{
|
|
|
|
EditView* pView = GetEditView();
|
|
|
|
if ( pView )
|
2012-01-24 11:14:38 +00:00
|
|
|
{
|
|
|
|
if ( mbInvalidate )
|
|
|
|
{
|
|
|
|
pView->Invalidate();
|
|
|
|
mbInvalidate = false;
|
|
|
|
}
|
2013-03-12 09:46:46 +02:00
|
|
|
pEditView->Paint( rRect );
|
2012-01-24 11:14:38 +00:00
|
|
|
}
|
2011-12-12 14:53:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
EditView* ScMultiTextWnd::GetEditView()
|
2011-07-05 09:41:08 +01:00
|
|
|
{
|
2011-12-11 16:40:52 +00:00
|
|
|
if ( !pEditView )
|
2011-12-13 00:08:41 -05:00
|
|
|
InitEditEngine();
|
2011-12-12 14:53:58 -05:00
|
|
|
return pEditView;
|
2011-07-05 09:41:08 +01:00
|
|
|
}
|
|
|
|
|
2011-12-07 15:40:28 +00:00
|
|
|
long ScMultiTextWnd::GetPixelHeightForLines( long nLines )
|
2011-07-05 09:41:08 +01:00
|
|
|
{
|
2012-01-25 12:36:17 +00:00
|
|
|
// add padding ( for the borders of the window )
|
2012-05-30 17:03:12 +02:00
|
|
|
return ( nLines * LogicToPixel( Size( 0, GetTextHeight() ) ).Height() ) + mnBorderHeight;
|
2011-11-22 16:21:20 +00:00
|
|
|
}
|
2011-08-15 15:46:02 -04:00
|
|
|
|
2011-11-22 16:21:20 +00:00
|
|
|
void ScMultiTextWnd::SetNumLines( long nLines )
|
|
|
|
{
|
|
|
|
mnLines = nLines;
|
2011-11-23 16:27:17 +00:00
|
|
|
if ( nLines > 1 )
|
2011-11-28 10:58:31 +00:00
|
|
|
{
|
2011-11-23 16:27:17 +00:00
|
|
|
mnLastExpandedLines = nLines;
|
2011-11-28 10:58:31 +00:00
|
|
|
Resize();
|
|
|
|
}
|
2011-11-22 16:21:20 +00:00
|
|
|
}
|
2011-08-20 23:09:40 +05:30
|
|
|
|
2011-11-22 16:21:20 +00:00
|
|
|
void ScMultiTextWnd::Resize()
|
|
|
|
{
|
|
|
|
// Only Height is recalculated here, Width is applied from
|
|
|
|
// parent/container window
|
2012-05-28 09:07:11 +02:00
|
|
|
Size aTextBoxSize = GetSizePixel();
|
2011-08-15 15:46:02 -04:00
|
|
|
|
2012-05-28 09:07:11 +02:00
|
|
|
aTextBoxSize.Height() = GetPixelHeightForLines( mnLines );
|
|
|
|
SetSizePixel( aTextBoxSize );
|
2011-11-22 16:21:20 +00:00
|
|
|
|
|
|
|
if(pEditView)
|
2011-08-15 15:46:02 -04:00
|
|
|
{
|
2011-11-22 16:21:20 +00:00
|
|
|
Size aOutputSize = GetOutputSizePixel();
|
2012-08-04 17:26:59 +04:00
|
|
|
Rectangle aOutputArea = PixelToLogic( Rectangle( Point(), aOutputSize ));
|
|
|
|
pEditView->SetOutputArea( aOutputArea );
|
|
|
|
|
|
|
|
// Don't leave an empty area at the bottom if we can move the text down.
|
|
|
|
long nMaxVisAreaTop = pEditEngine->GetTextHeight() - aOutputArea.GetHeight();
|
|
|
|
if (pEditView->GetVisArea().Top() > nMaxVisAreaTop)
|
|
|
|
{
|
|
|
|
pEditView->Scroll(0, pEditView->GetVisArea().Top() - nMaxVisAreaTop);
|
|
|
|
}
|
2011-08-15 15:46:02 -04:00
|
|
|
|
2012-05-28 09:07:11 +02:00
|
|
|
pEditEngine->SetPaperSize( PixelToLogic( Size( aOutputSize.Width(), 10000 ) ) );
|
2011-11-22 16:21:20 +00:00
|
|
|
}
|
2011-11-28 10:58:31 +00:00
|
|
|
|
2011-11-23 16:27:17 +00:00
|
|
|
SetScrollBarRange();
|
2011-11-22 16:21:20 +00:00
|
|
|
}
|
2011-08-15 15:46:02 -04:00
|
|
|
|
2011-11-22 16:21:20 +00:00
|
|
|
IMPL_LINK(ScMultiTextWnd, ModifyHdl, EENotify*, pNotify)
|
|
|
|
{
|
|
|
|
ScTextWnd::NotifyHdl( pNotify );
|
|
|
|
return 0;
|
|
|
|
}
|
2011-08-15 15:46:02 -04:00
|
|
|
|
2011-11-22 16:21:20 +00:00
|
|
|
IMPL_LINK(ScMultiTextWnd, NotifyHdl, EENotify*, pNotify)
|
|
|
|
{
|
|
|
|
// need to process EE_NOTIFY_TEXTVIEWSCROLLED here
|
2011-11-30 18:49:40 +00:00
|
|
|
// sometimes we don't seem to get EE_NOTIFY_TEXTVIEWSCROLLED e.g. when
|
2013-02-23 19:17:03 +01:00
|
|
|
// we insert text at the beginning of the text so the cursor never moves
|
2011-11-30 18:49:40 +00:00
|
|
|
// down to generate a scroll event
|
|
|
|
|
2011-11-29 15:58:48 +00:00
|
|
|
if ( pNotify && ( pNotify->eNotificationType == EE_NOTIFY_TEXTVIEWSCROLLED
|
2011-11-30 18:49:40 +00:00
|
|
|
|| pNotify->eNotificationType == EE_NOTIFY_TEXTHEIGHTCHANGED ) )
|
2011-11-22 16:21:20 +00:00
|
|
|
SetScrollBarRange();
|
|
|
|
return 0;
|
|
|
|
}
|
2011-08-23 20:19:39 +05:30
|
|
|
|
2011-11-22 16:21:20 +00:00
|
|
|
long ScMultiTextWnd::GetEditEngTxtHeight()
|
|
|
|
{
|
2011-11-30 18:49:40 +00:00
|
|
|
return pEditView ? pEditView->GetEditEngine()->GetTextHeight() : 0;
|
2011-11-22 16:21:20 +00:00
|
|
|
}
|
2011-08-15 15:46:02 -04:00
|
|
|
|
2011-11-22 16:21:20 +00:00
|
|
|
void ScMultiTextWnd::SetScrollBarRange()
|
|
|
|
{
|
2011-11-23 16:27:17 +00:00
|
|
|
if ( pEditView )
|
2011-11-22 16:21:20 +00:00
|
|
|
{
|
2011-11-23 16:27:17 +00:00
|
|
|
ScrollBar& rVBar = mrGroupBar.GetScrollBar();
|
2011-11-22 16:21:20 +00:00
|
|
|
rVBar.SetRange( Range( 0, GetEditEngTxtHeight() ) );
|
|
|
|
long currentDocPos = pEditView->GetVisArea().TopLeft().Y();
|
|
|
|
rVBar.SetThumbPos( currentDocPos );
|
2011-08-15 15:46:02 -04:00
|
|
|
}
|
2011-11-22 16:21:20 +00:00
|
|
|
}
|
2011-08-15 15:46:02 -04:00
|
|
|
|
2011-11-22 16:21:20 +00:00
|
|
|
void
|
2011-11-23 16:27:17 +00:00
|
|
|
ScMultiTextWnd::DoScroll()
|
2011-11-22 16:21:20 +00:00
|
|
|
{
|
|
|
|
if ( pEditView )
|
2011-08-15 15:46:02 -04:00
|
|
|
{
|
2011-11-23 16:27:17 +00:00
|
|
|
ScrollBar& rVBar = mrGroupBar.GetScrollBar();
|
|
|
|
long currentDocPos = pEditView->GetVisArea().TopLeft().Y();
|
|
|
|
long nDiff = currentDocPos - rVBar.GetThumbPos();
|
|
|
|
pEditView->Scroll( 0, nDiff );
|
|
|
|
currentDocPos = pEditView->GetVisArea().TopLeft().Y();
|
|
|
|
rVBar.SetThumbPos( currentDocPos );
|
2011-08-15 15:46:02 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScMultiTextWnd::StartEditEngine()
|
|
|
|
{
|
2014-06-19 21:11:48 +02:00
|
|
|
// Don't activate if we're a modal dialog ourselves (Doc-modal dialog)
|
2011-08-15 15:46:02 -04:00
|
|
|
SfxObjectShell* pObjSh = SfxObjectShell::Current();
|
|
|
|
if ( pObjSh && pObjSh->IsInModalMode() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( !pEditView || !pEditEngine )
|
|
|
|
{
|
2011-12-13 00:08:41 -05:00
|
|
|
InitEditEngine();
|
2011-08-15 15:46:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
SC_MOD()->SetInputMode( SC_INPUT_TOP );
|
|
|
|
|
|
|
|
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
|
|
|
|
if (pViewFrm)
|
|
|
|
pViewFrm->GetBindings().Invalidate( SID_ATTR_INSERT );
|
|
|
|
}
|
|
|
|
|
2012-10-12 13:26:46 +02:00
|
|
|
static void lcl_ExtendEditFontAttribs( SfxItemSet& rSet )
|
2011-08-15 15:46:02 -04:00
|
|
|
{
|
|
|
|
const SfxPoolItem& rFontItem = rSet.Get( EE_CHAR_FONTINFO );
|
|
|
|
rSet.Put( rFontItem, EE_CHAR_FONTINFO_CJK );
|
|
|
|
rSet.Put( rFontItem, EE_CHAR_FONTINFO_CTL );
|
|
|
|
const SfxPoolItem& rHeightItem = rSet.Get( EE_CHAR_FONTHEIGHT );
|
|
|
|
rSet.Put( rHeightItem, EE_CHAR_FONTHEIGHT_CJK );
|
|
|
|
rSet.Put( rHeightItem, EE_CHAR_FONTHEIGHT_CTL );
|
|
|
|
const SfxPoolItem& rWeightItem = rSet.Get( EE_CHAR_WEIGHT );
|
|
|
|
rSet.Put( rWeightItem, EE_CHAR_WEIGHT_CJK );
|
|
|
|
rSet.Put( rWeightItem, EE_CHAR_WEIGHT_CTL );
|
|
|
|
const SfxPoolItem& rItalicItem = rSet.Get( EE_CHAR_ITALIC );
|
|
|
|
rSet.Put( rItalicItem, EE_CHAR_ITALIC_CJK );
|
|
|
|
rSet.Put( rItalicItem, EE_CHAR_ITALIC_CTL );
|
|
|
|
const SfxPoolItem& rLangItem = rSet.Get( EE_CHAR_LANGUAGE );
|
|
|
|
rSet.Put( rLangItem, EE_CHAR_LANGUAGE_CJK );
|
|
|
|
rSet.Put( rLangItem, EE_CHAR_LANGUAGE_CTL );
|
|
|
|
}
|
|
|
|
|
2012-10-12 13:26:46 +02:00
|
|
|
static void lcl_ModifyRTLDefaults( SfxItemSet& rSet )
|
2011-08-15 15:46:02 -04:00
|
|
|
{
|
|
|
|
rSet.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
|
|
|
|
|
|
|
|
// always using rtl writing direction would break formulas
|
|
|
|
//rSet.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP, EE_PARA_WRITINGDIR ) );
|
|
|
|
|
|
|
|
// PaperSize width is limited to USHRT_MAX in RTL mode (because of EditEngine's
|
|
|
|
// sal_uInt16 values in EditLine), so the text may be wrapped and line spacing must be
|
|
|
|
// increased to not see the beginning of the next line.
|
|
|
|
SvxLineSpacingItem aItem( SVX_LINESPACE_TWO_LINES, EE_PARA_SBL );
|
|
|
|
aItem.SetPropLineSpace( 200 );
|
|
|
|
rSet.Put( aItem );
|
|
|
|
}
|
|
|
|
|
2012-10-12 13:26:46 +02:00
|
|
|
static void lcl_ModifyRTLVisArea( EditView* pEditView )
|
2011-08-15 15:46:02 -04:00
|
|
|
{
|
|
|
|
Rectangle aVisArea = pEditView->GetVisArea();
|
|
|
|
Size aPaper = pEditView->GetEditEngine()->GetPaperSize();
|
|
|
|
long nDiff = aPaper.Width() - aVisArea.Right();
|
|
|
|
aVisArea.Left() += nDiff;
|
|
|
|
aVisArea.Right() += nDiff;
|
|
|
|
pEditView->SetVisArea(aVisArea);
|
|
|
|
}
|
|
|
|
|
2011-12-13 00:08:41 -05:00
|
|
|
void ScMultiTextWnd::InitEditEngine()
|
2011-08-15 15:46:02 -04:00
|
|
|
{
|
|
|
|
ScFieldEditEngine* pNew;
|
2011-12-13 00:08:41 -05:00
|
|
|
ScTabViewShell* pViewSh = GetViewShell();
|
|
|
|
ScDocShell* pDocSh = NULL;
|
2011-08-15 15:46:02 -04:00
|
|
|
if ( pViewSh )
|
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
pDocSh = pViewSh->GetViewData().GetDocShell();
|
|
|
|
ScDocument* pDoc = pViewSh->GetViewData().GetDocument();
|
2012-04-20 00:46:19 -04:00
|
|
|
pNew = new ScFieldEditEngine(pDoc, pDoc->GetEnginePool(), pDoc->GetEditPool());
|
2011-08-15 15:46:02 -04:00
|
|
|
}
|
|
|
|
else
|
2012-04-20 00:46:19 -04:00
|
|
|
pNew = new ScFieldEditEngine(NULL, EditEngine::CreatePool(), NULL, true);
|
2011-08-15 15:46:02 -04:00
|
|
|
pNew->SetExecuteURL( false );
|
|
|
|
pEditEngine = pNew;
|
|
|
|
|
2011-08-20 23:09:40 +05:30
|
|
|
Size barSize=GetSizePixel();
|
2011-08-15 15:46:02 -04:00
|
|
|
pEditEngine->SetUpdateMode( false );
|
2011-08-23 20:19:39 +05:30
|
|
|
pEditEngine->SetPaperSize( PixelToLogic(Size(barSize.Width(),10000)) );
|
2011-08-15 15:46:02 -04:00
|
|
|
pEditEngine->SetWordDelimiters(
|
|
|
|
ScEditUtil::ModifyDelimiters( pEditEngine->GetWordDelimiters() ) );
|
|
|
|
|
|
|
|
UpdateAutoCorrFlag();
|
|
|
|
|
|
|
|
{
|
|
|
|
SfxItemSet* pSet = new SfxItemSet( pEditEngine->GetEmptyItemSet() );
|
2014-06-13 17:51:14 +02:00
|
|
|
EditEngine::SetFontInfoInItemSet( *pSet, aTextFont );
|
2011-08-15 15:46:02 -04:00
|
|
|
lcl_ExtendEditFontAttribs( *pSet );
|
|
|
|
// turn off script spacing to match DrawText output
|
|
|
|
pSet->Put( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING ) );
|
|
|
|
if ( bIsRTL )
|
|
|
|
lcl_ModifyRTLDefaults( *pSet );
|
|
|
|
pEditEngine->SetDefaults( pSet );
|
2011-07-05 09:41:08 +01:00
|
|
|
}
|
2011-08-15 15:46:02 -04:00
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
// If the Cell contains URLFields, they need to be taken over into the entry row,
|
|
|
|
// or else the position is not correct anymore
|
2014-04-23 11:08:48 +02:00
|
|
|
bool bFilled = false;
|
2011-08-15 15:46:02 -04:00
|
|
|
ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
|
2014-06-19 21:11:48 +02:00
|
|
|
if ( pHdl ) //! Test if it's the right InputHdl?
|
2011-08-15 15:46:02 -04:00
|
|
|
bFilled = pHdl->GetTextAndFields( *pEditEngine );
|
|
|
|
|
2014-02-20 14:17:27 +02:00
|
|
|
pEditEngine->SetUpdateMode( true );
|
2011-08-15 15:46:02 -04:00
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
// aString is the truth ...
|
2013-01-21 21:42:46 +01:00
|
|
|
if (bFilled && pEditEngine->GetText() == aString)
|
2014-06-19 21:11:48 +02:00
|
|
|
Invalidate(); // Repaint for (filled) Field
|
2011-08-15 15:46:02 -04:00
|
|
|
else
|
2014-06-19 21:11:48 +02:00
|
|
|
pEditEngine->SetText(aString); // At least the right text then
|
2011-08-15 15:46:02 -04:00
|
|
|
|
|
|
|
pEditView = new EditView( pEditEngine, this );
|
|
|
|
pEditView->SetInsertMode(bIsInsertMode);
|
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
// Text from Clipboard is taken over as ASCII in a single row
|
2011-08-15 15:46:02 -04:00
|
|
|
sal_uLong n = pEditView->GetControlWord();
|
2014-06-19 21:11:48 +02:00
|
|
|
pEditView->SetControlWord( n | EV_CNTRL_SINGLELINEPASTE );
|
2011-08-15 15:46:02 -04:00
|
|
|
|
|
|
|
pEditEngine->InsertView( pEditView, EE_APPEND );
|
|
|
|
|
|
|
|
Resize();
|
|
|
|
|
|
|
|
if ( bIsRTL )
|
|
|
|
lcl_ModifyRTLVisArea( pEditView );
|
|
|
|
|
2011-11-22 16:21:20 +00:00
|
|
|
pEditEngine->SetModifyHdl(LINK(this, ScMultiTextWnd, ModifyHdl));
|
|
|
|
pEditEngine->SetNotifyHdl(LINK(this, ScMultiTextWnd, NotifyHdl));
|
2011-08-15 15:46:02 -04:00
|
|
|
|
|
|
|
if (!maAccTextDatas.empty())
|
|
|
|
maAccTextDatas.back()->StartEdit();
|
|
|
|
|
|
|
|
// as long as EditEngine and DrawText sometimes differ for CTL text,
|
|
|
|
// repaint now to have the EditEngine's version visible
|
2011-12-13 00:08:41 -05:00
|
|
|
if (pDocSh)
|
2011-08-15 15:46:02 -04:00
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
ScDocument& rDoc = pDocSh->GetDocument(); // any document
|
|
|
|
sal_uInt8 nScript = rDoc.GetStringScriptType( aString );
|
2011-08-15 15:46:02 -04:00
|
|
|
if ( nScript & SCRIPTTYPE_COMPLEX )
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-18 13:30:53 +02:00
|
|
|
void ScMultiTextWnd::StopEditEngine( bool bAll )
|
2011-08-15 15:46:02 -04:00
|
|
|
{
|
2011-12-11 16:40:52 +00:00
|
|
|
if ( pEditEngine )
|
|
|
|
pEditEngine->SetNotifyHdl(Link());
|
2011-11-29 15:58:48 +00:00
|
|
|
ScTextWnd::StopEditEngine( bAll );
|
2011-07-05 09:41:08 +01:00
|
|
|
}
|
|
|
|
|
2013-09-26 16:45:16 +02:00
|
|
|
void ScMultiTextWnd::SetTextString( const OUString& rNewString )
|
2011-11-22 16:21:20 +00:00
|
|
|
{
|
2011-12-11 16:40:52 +00:00
|
|
|
// Ideally it would be best to create on demand the EditEngine/EditView here, but... for
|
|
|
|
// the initialisation scenario where a cell is first clicked on we end up with the text in the
|
|
|
|
// inputbar window scrolled to the bottom if we do that here ( because the tableview and topview
|
|
|
|
// are synced I guess ).
|
|
|
|
// should fix that I suppose :-/ need to look a bit further into that
|
2012-01-24 11:14:38 +00:00
|
|
|
mbInvalidate = true; // ensure next Paint ( that uses editengine ) call will call Invalidate first
|
2011-11-22 16:21:20 +00:00
|
|
|
ScTextWnd::SetTextString( rNewString );
|
|
|
|
SetScrollBarRange();
|
2011-11-23 16:27:17 +00:00
|
|
|
DoScroll();
|
2011-11-22 16:21:20 +00:00
|
|
|
}
|
2014-02-25 19:58:48 +01:00
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
ScTextWnd::ScTextWnd( vcl::Window* pParent, ScTabViewShell* pViewSh )
|
2011-07-05 09:41:08 +01:00
|
|
|
: ScTextWndBase ( pParent, WinBits(WB_HIDE | WB_BORDER) ),
|
2001-04-03 16:44:46 +00:00
|
|
|
DragSourceHelper( this ),
|
2000-09-18 16:07:07 +00:00
|
|
|
pEditEngine ( NULL ),
|
|
|
|
pEditView ( NULL ),
|
2014-02-18 13:30:53 +02:00
|
|
|
bIsInsertMode( true ),
|
2011-03-10 16:55:21 -05:00
|
|
|
bFormulaMode ( false ),
|
2011-07-05 09:41:08 +01:00
|
|
|
bInputMode ( false ),
|
2011-12-13 00:08:41 -05:00
|
|
|
mpViewShell(pViewSh)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-06-19 21:11:48 +02:00
|
|
|
EnableRTL( false ); // EditEngine can't be used with VCL EnableRTL
|
2003-03-26 17:07:02 +00:00
|
|
|
|
|
|
|
bIsRTL = GetSettings().GetLayoutRTL();
|
|
|
|
|
2011-03-01 14:29:24 +01:00
|
|
|
// always use application font, so a font with cjk chars can be installed
|
2014-09-16 10:09:58 +02:00
|
|
|
vcl::Font aAppFont = GetFont();
|
2000-09-18 16:07:07 +00:00
|
|
|
aTextFont = aAppFont;
|
2014-06-19 21:11:48 +02:00
|
|
|
aTextFont.SetSize( PixelToLogic( aAppFont.GetSize(), MAP_TWIP ) ); // AppFont is in pixels
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
|
|
|
|
|
|
|
|
Color aBgColor= rStyleSettings.GetWindowColor();
|
|
|
|
Color aTxtColor= rStyleSettings.GetWindowTextColor();
|
|
|
|
|
2014-02-21 12:53:51 +01:00
|
|
|
aTextFont.SetTransparent ( true );
|
2000-09-18 16:07:07 +00:00
|
|
|
aTextFont.SetFillColor ( aBgColor );
|
|
|
|
//aTextFont.SetColor ( COL_FIELDTEXT );
|
|
|
|
aTextFont.SetColor (aTxtColor);
|
|
|
|
aTextFont.SetWeight ( WEIGHT_NORMAL );
|
|
|
|
|
2010-07-08 19:03:59 +02:00
|
|
|
Size aSize(1,TBX_WINDOW_HEIGHT);
|
|
|
|
Size aMinEditSize( Edit::GetMinimumEditSize() );
|
|
|
|
if( aMinEditSize.Height() > aSize.Height() )
|
|
|
|
aSize.Height() = aMinEditSize.Height();
|
|
|
|
SetSizePixel ( aSize );
|
2000-09-18 16:07:07 +00:00
|
|
|
SetBackground ( aBgColor );
|
|
|
|
SetLineColor ( COL_BLACK );
|
|
|
|
SetMapMode ( MAP_TWIP );
|
|
|
|
SetPointer ( POINTER_TEXT );
|
2012-05-30 17:03:12 +02:00
|
|
|
SetFont( aTextFont );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2010-12-11 23:25:30 +01:00
|
|
|
ScTextWnd::~ScTextWnd()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2010-02-22 10:34:02 +01:00
|
|
|
while (!maAccTextDatas.empty()) {
|
|
|
|
maAccTextDatas.back()->Dispose();
|
|
|
|
}
|
2010-10-11 12:50:51 +01:00
|
|
|
delete pEditView;
|
|
|
|
delete pEditEngine;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2013-03-12 09:46:46 +02:00
|
|
|
void ScTextWnd::Paint( const Rectangle& rRect )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (pEditView)
|
2013-03-12 09:46:46 +02:00
|
|
|
pEditView->Paint( rRect );
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
SetFont( aTextFont );
|
|
|
|
|
|
|
|
long nDiff = GetOutputSizePixel().Height()
|
|
|
|
- LogicToPixel( Size( 0, GetTextHeight() ) ).Height();
|
2014-06-19 21:11:48 +02:00
|
|
|
// if (nDiff<2) nDiff=2; // At least 1 pixel
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-05-28 09:07:11 +02:00
|
|
|
long nStartPos = 0;
|
2003-03-26 17:07:02 +00:00
|
|
|
if ( bIsRTL )
|
|
|
|
{
|
|
|
|
// right-align
|
2012-05-28 09:07:11 +02:00
|
|
|
nStartPos += GetOutputSizePixel().Width() -
|
2003-03-26 17:07:02 +00:00
|
|
|
LogicToPixel( Size( GetTextWidth( aString ), 0 ) ).Width();
|
|
|
|
|
|
|
|
// LayoutMode isn't changed as long as ModifyRTLDefaults doesn't include SvxFrameDirectionItem
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawText( PixelToLogic( Point( nStartPos, nDiff/2 ) ), aString );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-11 23:25:30 +01:00
|
|
|
void ScTextWnd::Resize()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (pEditView)
|
|
|
|
{
|
|
|
|
Size aSize = GetOutputSizePixel();
|
|
|
|
long nDiff = aSize.Height()
|
|
|
|
- LogicToPixel( Size( 0, GetTextHeight() ) ).Height();
|
|
|
|
|
|
|
|
pEditView->SetOutputArea(
|
2012-05-28 09:07:11 +02:00
|
|
|
PixelToLogic( Rectangle( Point( 0, (nDiff > 0) ? nDiff/2 : 1 ),
|
2000-09-18 16:07:07 +00:00
|
|
|
aSize ) ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-11 23:25:30 +01:00
|
|
|
void ScTextWnd::MouseMove( const MouseEvent& rMEvt )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (pEditView)
|
|
|
|
pEditView->MouseMove( rMEvt );
|
|
|
|
}
|
|
|
|
|
2010-12-11 23:25:30 +01:00
|
|
|
void ScTextWnd::MouseButtonDown( const MouseEvent& rMEvt )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (!HasFocus())
|
|
|
|
{
|
|
|
|
StartEditEngine();
|
|
|
|
if ( SC_MOD()->IsEditMode() )
|
|
|
|
GrabFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pEditView)
|
|
|
|
{
|
2014-02-20 11:55:27 +02:00
|
|
|
pEditView->SetEditEngineUpdateMode( true );
|
2000-09-18 16:07:07 +00:00
|
|
|
pEditView->MouseButtonDown( rMEvt );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-11 23:25:30 +01:00
|
|
|
void ScTextWnd::MouseButtonUp( const MouseEvent& rMEvt )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (pEditView)
|
|
|
|
if (pEditView->MouseButtonUp( rMEvt ))
|
2001-10-02 17:32:43 +00:00
|
|
|
{
|
|
|
|
if ( rMEvt.IsMiddle() &&
|
|
|
|
GetSettings().GetMouseSettings().GetMiddleButtonAction() == MOUSE_MIDDLE_PASTESELECTION )
|
|
|
|
{
|
|
|
|
// EditView may have pasted from selection
|
|
|
|
SC_MOD()->InputChanged( pEditView );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SC_MOD()->InputSelection( pEditView );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2010-12-11 23:25:30 +01:00
|
|
|
void ScTextWnd::Command( const CommandEvent& rCEvt )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-02-18 13:30:53 +02:00
|
|
|
bInputMode = true;
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nCommand = rCEvt.GetCommand();
|
2013-02-28 00:11:15 +02:00
|
|
|
if ( pEditView /* && nCommand == COMMAND_STARTDRAG */ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ScModule* pScMod = SC_MOD();
|
|
|
|
ScTabViewShell* pStartViewSh = ScTabViewShell::GetActiveViewShell();
|
|
|
|
|
2011-03-01 14:29:24 +01:00
|
|
|
// don't modify the font defaults here - the right defaults are
|
2003-06-04 11:36:47 +00:00
|
|
|
// already set in StartEditEngine when the EditEngine is created
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
// Prevent that the EditView is lost when switching between Views
|
2011-03-10 16:55:21 -05:00
|
|
|
pScMod->SetInEditCommand( true );
|
2000-09-18 16:07:07 +00:00
|
|
|
pEditView->Command( rCEvt );
|
2011-03-10 16:55:21 -05:00
|
|
|
pScMod->SetInEditCommand( false );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
// COMMAND_STARTDRAG does not mean by far that the content was actually changed,
|
|
|
|
// so don't trigger an InputChanged.
|
|
|
|
//! Detect if dragged with Move or forbid Drag&Move somehow
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( nCommand == COMMAND_STARTDRAG )
|
|
|
|
{
|
2014-06-19 21:11:48 +02:00
|
|
|
// Is dragged onto another View?
|
2000-09-18 16:07:07 +00:00
|
|
|
ScTabViewShell* pEndViewSh = ScTabViewShell::GetActiveViewShell();
|
|
|
|
if ( pEndViewSh != pStartViewSh && pStartViewSh != NULL )
|
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
ScViewData& rViewData = pStartViewSh->GetViewData();
|
2000-09-18 16:07:07 +00:00
|
|
|
ScInputHandler* pHdl = pScMod->GetInputHdl( pStartViewSh );
|
2014-06-18 12:14:29 +02:00
|
|
|
if ( pHdl && rViewData.HasEditView( rViewData.GetActivePart() ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
pHdl->CancelHandler();
|
2014-06-18 12:14:29 +02:00
|
|
|
rViewData.GetView()->ShowCursor(); // Missing for KillEditView, due to being inactive
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-08-03 14:50:05 +00:00
|
|
|
else if ( nCommand == COMMAND_CURSORPOS )
|
|
|
|
{
|
|
|
|
// don't call InputChanged for COMMAND_CURSORPOS
|
|
|
|
}
|
2005-11-16 09:13:20 +00:00
|
|
|
else if ( nCommand == COMMAND_INPUTLANGUAGECHANGE )
|
|
|
|
{
|
|
|
|
// #i55929# Font and font size state depends on input language if nothing is selected,
|
|
|
|
// so the slots have to be invalidated when the input language is changed.
|
|
|
|
|
|
|
|
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
|
|
|
|
if (pViewFrm)
|
|
|
|
{
|
|
|
|
SfxBindings& rBindings = pViewFrm->GetBindings();
|
|
|
|
rBindings.Invalidate( SID_ATTR_CHAR_FONT );
|
|
|
|
rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
|
|
|
|
}
|
|
|
|
}
|
2012-03-06 01:16:43 +01:00
|
|
|
else if ( nCommand == COMMAND_WHEEL )
|
|
|
|
{
|
|
|
|
//don't call InputChanged for COMMAND_WHEEL
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
|
|
|
SC_MOD()->InputChanged( pEditView );
|
|
|
|
}
|
|
|
|
else
|
2014-06-19 21:11:48 +02:00
|
|
|
Window::Command(rCEvt); // Or else let the base class handle it...
|
2002-10-22 14:36:32 +00:00
|
|
|
|
2011-03-10 16:55:21 -05:00
|
|
|
bInputMode = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2007-02-27 11:58:02 +00:00
|
|
|
void ScTextWnd::StartDrag( sal_Int8 /* nAction */, const Point& rPosPixel )
|
2001-04-03 16:44:46 +00:00
|
|
|
{
|
|
|
|
if ( pEditView )
|
|
|
|
{
|
2014-01-28 20:00:32 +01:00
|
|
|
CommandEvent aDragEvent( rPosPixel, COMMAND_STARTDRAG, true );
|
2001-04-03 16:44:46 +00:00
|
|
|
pEditView->Command( aDragEvent );
|
|
|
|
|
|
|
|
// handling of d&d to different view (CancelHandler) can't be done here,
|
|
|
|
// because the call returns before d&d is complete.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-11 23:25:30 +01:00
|
|
|
void ScTextWnd::KeyInput(const KeyEvent& rKEvt)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-02-18 13:30:53 +02:00
|
|
|
bInputMode = true;
|
2000-09-18 16:07:07 +00:00
|
|
|
if (!SC_MOD()->InputKeyEvent( rKEvt ))
|
|
|
|
{
|
2014-04-23 11:08:48 +02:00
|
|
|
bool bUsed = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
|
|
|
|
if ( pViewSh )
|
2014-06-19 21:11:48 +02:00
|
|
|
bUsed = pViewSh->SfxKeyInput(rKEvt); // Only accelerators, no input
|
2000-09-18 16:07:07 +00:00
|
|
|
if (!bUsed)
|
|
|
|
Window::KeyInput( rKEvt );
|
|
|
|
}
|
2011-03-10 16:55:21 -05:00
|
|
|
bInputMode = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2010-12-11 23:25:30 +01:00
|
|
|
void ScTextWnd::GetFocus()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-05-07 14:57:40 +00:00
|
|
|
ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
|
|
|
|
if ( pViewSh )
|
2014-06-19 21:11:48 +02:00
|
|
|
pViewSh->SetFormShellAtTop( false ); // focus in input line -> FormShell no longer on top
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2010-12-11 23:25:30 +01:00
|
|
|
void ScTextWnd::LoseFocus()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-01-21 14:32:09 +01:00
|
|
|
OUString ScTextWnd::GetText() const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-01-08 23:08:34 +01:00
|
|
|
// Override to get the text via the testtool
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pEditEngine )
|
|
|
|
return pEditEngine->GetText();
|
|
|
|
else
|
|
|
|
return GetTextString();
|
|
|
|
}
|
|
|
|
|
2014-02-18 13:30:53 +02:00
|
|
|
void ScTextWnd::SetFormulaMode( bool bSet )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( bSet != bFormulaMode )
|
|
|
|
{
|
|
|
|
bFormulaMode = bSet;
|
|
|
|
UpdateAutoCorrFlag();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScTextWnd::UpdateAutoCorrFlag()
|
|
|
|
{
|
|
|
|
if ( pEditEngine )
|
|
|
|
{
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uLong nControl = pEditEngine->GetControlWord();
|
|
|
|
sal_uLong nOld = nControl;
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( bFormulaMode )
|
2014-06-19 21:11:48 +02:00
|
|
|
nControl &= ~EE_CNTRL_AUTOCORRECT; // No AutoCorrect in Formulas
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2014-06-19 21:11:48 +02:00
|
|
|
nControl |= EE_CNTRL_AUTOCORRECT; // Else do enable it
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( nControl != nOld )
|
|
|
|
pEditEngine->SetControlWord( nControl );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScTextWnd::StartEditEngine()
|
|
|
|
{
|
2014-06-19 21:11:48 +02:00
|
|
|
// Don't activate if we're a modal ourselves (Doc modal Dialog)
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxObjectShell* pObjSh = SfxObjectShell::Current();
|
|
|
|
if ( pObjSh && pObjSh->IsInModalMode() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( !pEditView || !pEditEngine )
|
|
|
|
{
|
|
|
|
ScFieldEditEngine* pNew;
|
|
|
|
ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
|
|
|
|
if ( pViewSh )
|
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
ScDocument* pDoc = pViewSh->GetViewData().GetDocument();
|
2012-04-20 00:46:19 -04:00
|
|
|
pNew = new ScFieldEditEngine(pDoc, pDoc->GetEnginePool(), pDoc->GetEditPool());
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
2012-04-20 00:46:19 -04:00
|
|
|
pNew = new ScFieldEditEngine(NULL, EditEngine::CreatePool(), NULL, true);
|
2011-03-10 16:55:21 -05:00
|
|
|
pNew->SetExecuteURL( false );
|
2000-09-18 16:07:07 +00:00
|
|
|
pEditEngine = pNew;
|
|
|
|
|
2011-03-10 16:55:21 -05:00
|
|
|
pEditEngine->SetUpdateMode( false );
|
2003-03-26 17:07:02 +00:00
|
|
|
pEditEngine->SetPaperSize( Size( bIsRTL ? USHRT_MAX : THESIZE, 300 ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
pEditEngine->SetWordDelimiters(
|
|
|
|
ScEditUtil::ModifyDelimiters( pEditEngine->GetWordDelimiters() ) );
|
|
|
|
|
|
|
|
UpdateAutoCorrFlag();
|
|
|
|
|
|
|
|
{
|
|
|
|
SfxItemSet* pSet = new SfxItemSet( pEditEngine->GetEmptyItemSet() );
|
2014-06-13 17:51:14 +02:00
|
|
|
EditEngine::SetFontInfoInItemSet( *pSet, aTextFont );
|
2000-11-29 19:59:10 +00:00
|
|
|
lcl_ExtendEditFontAttribs( *pSet );
|
2014-06-19 21:11:48 +02:00
|
|
|
|
2001-06-29 15:19:38 +00:00
|
|
|
// turn off script spacing to match DrawText output
|
2011-03-10 16:55:21 -05:00
|
|
|
pSet->Put( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING ) );
|
2003-03-26 17:07:02 +00:00
|
|
|
if ( bIsRTL )
|
|
|
|
lcl_ModifyRTLDefaults( *pSet );
|
2000-09-18 16:07:07 +00:00
|
|
|
pEditEngine->SetDefaults( pSet );
|
|
|
|
}
|
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
// If the Cell contains URLFields, they need to be taken over into the entry row,
|
|
|
|
// or else the position is not correct anymore
|
2014-04-23 11:08:48 +02:00
|
|
|
bool bFilled = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
|
2014-06-19 21:11:48 +02:00
|
|
|
if ( pHdl ) //! Check if it's the right InputHdl?
|
2000-09-18 16:07:07 +00:00
|
|
|
bFilled = pHdl->GetTextAndFields( *pEditEngine );
|
|
|
|
|
2014-02-20 14:17:27 +02:00
|
|
|
pEditEngine->SetUpdateMode( true );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
// aString is the truth...
|
2013-01-21 21:42:46 +01:00
|
|
|
if (bFilled && pEditEngine->GetText() == aString)
|
2014-06-19 21:11:48 +02:00
|
|
|
Invalidate(); // Repaint for (filled) Fields
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2014-06-19 21:11:48 +02:00
|
|
|
pEditEngine->SetText(aString); // At least the right text then
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
pEditView = new EditView( pEditEngine, this );
|
|
|
|
pEditView->SetInsertMode(bIsInsertMode);
|
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
// The text from the Clipboard is taken over as ASCII in a single row
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uLong n = pEditView->GetControlWord();
|
2000-09-18 16:07:07 +00:00
|
|
|
pEditView->SetControlWord( n | EV_CNTRL_SINGLELINEPASTE );
|
|
|
|
|
|
|
|
pEditEngine->InsertView( pEditView, EE_APPEND );
|
|
|
|
|
|
|
|
Resize();
|
2002-06-24 12:33:31 +00:00
|
|
|
|
2003-03-26 17:07:02 +00:00
|
|
|
if ( bIsRTL )
|
|
|
|
lcl_ModifyRTLVisArea( pEditView );
|
|
|
|
|
2002-10-22 14:36:32 +00:00
|
|
|
pEditEngine->SetModifyHdl(LINK(this, ScTextWnd, NotifyHdl));
|
|
|
|
|
2009-11-20 14:02:34 +00:00
|
|
|
if (!maAccTextDatas.empty())
|
|
|
|
maAccTextDatas.back()->StartEdit();
|
2003-03-26 17:07:02 +00:00
|
|
|
|
|
|
|
// as long as EditEngine and DrawText sometimes differ for CTL text,
|
|
|
|
// repaint now to have the EditEngine's version visible
|
2007-02-27 11:58:02 +00:00
|
|
|
// SfxObjectShell* pObjSh = SfxObjectShell::Current();
|
2003-03-26 17:07:02 +00:00
|
|
|
if ( pObjSh && pObjSh->ISA(ScDocShell) )
|
|
|
|
{
|
2014-10-23 08:57:36 +02:00
|
|
|
ScDocument& rDoc = static_cast<ScDocShell*>(pObjSh)->GetDocument(); // any document
|
2014-06-18 12:14:29 +02:00
|
|
|
sal_uInt8 nScript = rDoc.GetStringScriptType( aString );
|
2003-03-26 17:07:02 +00:00
|
|
|
if ( nScript & SCRIPTTYPE_COMPLEX )
|
|
|
|
Invalidate();
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SC_MOD()->SetInputMode( SC_INPUT_TOP );
|
2000-09-22 17:57:10 +00:00
|
|
|
|
|
|
|
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
|
|
|
|
if (pViewFrm)
|
|
|
|
pViewFrm->GetBindings().Invalidate( SID_ATTR_INSERT );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(ScTextWnd, NotifyHdl)
|
2002-10-22 14:36:32 +00:00
|
|
|
{
|
|
|
|
if (pEditView && !bInputMode)
|
2002-11-21 14:00:03 +00:00
|
|
|
{
|
|
|
|
ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
|
|
|
|
|
2011-03-01 14:29:24 +01:00
|
|
|
// Use the InputHandler's InOwnChange flag to prevent calling InputChanged
|
2002-11-21 14:00:03 +00:00
|
|
|
// while an InputHandler method is modifying the EditEngine content
|
|
|
|
|
|
|
|
if ( pHdl && !pHdl->IsInOwnChange() )
|
2014-01-28 20:00:32 +01:00
|
|
|
pHdl->InputChanged( pEditView, true ); // #i20282# InputChanged must know if called from modify handler
|
2002-11-21 14:00:03 +00:00
|
|
|
}
|
2002-10-22 14:36:32 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-02-18 13:30:53 +02:00
|
|
|
void ScTextWnd::StopEditEngine( bool bAll )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (pEditView)
|
|
|
|
{
|
2009-11-20 14:02:34 +00:00
|
|
|
if (!maAccTextDatas.empty())
|
|
|
|
maAccTextDatas.back()->EndEdit();
|
2002-06-24 12:33:31 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
ScModule* pScMod = SC_MOD();
|
|
|
|
|
2001-03-23 12:52:19 +00:00
|
|
|
if (!bAll)
|
|
|
|
pScMod->InputSelection( pEditView );
|
2000-09-18 16:07:07 +00:00
|
|
|
aString = pEditEngine->GetText();
|
|
|
|
bIsInsertMode = pEditView->IsInsertMode();
|
2014-04-23 11:08:48 +02:00
|
|
|
bool bSelection = pEditView->HasSelection();
|
2002-10-22 14:36:32 +00:00
|
|
|
pEditEngine->SetModifyHdl(Link());
|
2000-09-18 16:07:07 +00:00
|
|
|
DELETEZ(pEditView);
|
|
|
|
DELETEZ(pEditEngine);
|
|
|
|
|
2001-03-23 12:52:19 +00:00
|
|
|
if ( pScMod->IsEditMode() && !bAll )
|
2000-09-18 16:07:07 +00:00
|
|
|
pScMod->SetInputMode(SC_INPUT_TABLE);
|
|
|
|
|
2000-09-22 17:57:10 +00:00
|
|
|
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
|
|
|
|
if (pViewFrm)
|
|
|
|
pViewFrm->GetBindings().Invalidate( SID_ATTR_INSERT );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (bSelection)
|
2014-06-19 21:11:48 +02:00
|
|
|
Invalidate(); // So that the Selection is not left there
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-17 09:13:09 +02:00
|
|
|
static sal_Int32 findFirstNonMatchingChar(const OUString& rStr1, const OUString& rStr2)
|
2013-09-26 16:45:16 +02:00
|
|
|
{
|
|
|
|
// Search the string for unmatching chars
|
|
|
|
const sal_Unicode* pStr1 = rStr1.getStr();
|
|
|
|
const sal_Unicode* pStr2 = rStr2.getStr();
|
|
|
|
sal_Int32 i = 0;
|
|
|
|
while ( i < rStr1.getLength() )
|
|
|
|
{
|
|
|
|
// Abort on the first unmatching char
|
|
|
|
if ( *pStr1 != *pStr2 )
|
|
|
|
return i;
|
|
|
|
++pStr1,
|
|
|
|
++pStr2,
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScTextWnd::SetTextString( const OUString& rNewString )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( rNewString != aString )
|
|
|
|
{
|
2014-02-18 13:30:53 +02:00
|
|
|
bInputMode = true;
|
2002-11-29 12:46:47 +00:00
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
// Find position of the change, only paint the rest
|
2000-09-18 16:07:07 +00:00
|
|
|
if (!pEditEngine)
|
|
|
|
{
|
2014-04-23 11:08:48 +02:00
|
|
|
bool bPaintAll;
|
2003-03-26 17:07:02 +00:00
|
|
|
if ( bIsRTL )
|
2014-04-23 11:08:48 +02:00
|
|
|
bPaintAll = true;
|
2003-03-26 17:07:02 +00:00
|
|
|
else
|
2002-09-09 13:00:39 +00:00
|
|
|
{
|
2003-03-26 17:07:02 +00:00
|
|
|
// test if CTL script type is involved
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt8 nOldScript = 0;
|
|
|
|
sal_uInt8 nNewScript = 0;
|
2003-03-26 17:07:02 +00:00
|
|
|
SfxObjectShell* pObjSh = SfxObjectShell::Current();
|
|
|
|
if ( pObjSh && pObjSh->ISA(ScDocShell) )
|
|
|
|
{
|
|
|
|
// any document can be used (used only for its break iterator)
|
2014-10-23 08:57:36 +02:00
|
|
|
ScDocument& rDoc = static_cast<ScDocShell*>(pObjSh)->GetDocument();
|
2014-06-18 12:14:29 +02:00
|
|
|
nOldScript = rDoc.GetStringScriptType( aString );
|
|
|
|
nNewScript = rDoc.GetStringScriptType( rNewString );
|
2003-03-26 17:07:02 +00:00
|
|
|
}
|
|
|
|
bPaintAll = ( nOldScript & SCRIPTTYPE_COMPLEX ) || ( nNewScript & SCRIPTTYPE_COMPLEX );
|
2002-09-09 13:00:39 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2003-03-26 17:07:02 +00:00
|
|
|
if ( bPaintAll )
|
2002-09-09 13:00:39 +00:00
|
|
|
{
|
|
|
|
// if CTL is involved, the whole text has to be redrawn
|
|
|
|
Invalidate();
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2002-09-09 13:00:39 +00:00
|
|
|
{
|
2011-01-04 13:24:15 +00:00
|
|
|
long nTextSize = 0;
|
2013-09-26 16:45:16 +02:00
|
|
|
sal_Int32 nDifPos;
|
|
|
|
if (rNewString.getLength() > aString.getLength())
|
|
|
|
nDifPos = findFirstNonMatchingChar(rNewString, aString);
|
2002-09-09 13:00:39 +00:00
|
|
|
else
|
2013-09-26 16:45:16 +02:00
|
|
|
nDifPos = findFirstNonMatchingChar(aString, rNewString);
|
2002-09-09 13:00:39 +00:00
|
|
|
|
|
|
|
long nSize1 = GetTextWidth(aString);
|
|
|
|
long nSize2 = GetTextWidth(rNewString);
|
|
|
|
if ( nSize1>0 && nSize2>0 )
|
2013-04-11 00:21:40 -03:00
|
|
|
nTextSize = std::max( nSize1, nSize2 );
|
2002-09-09 13:00:39 +00:00
|
|
|
else
|
2014-06-19 21:11:48 +02:00
|
|
|
nTextSize = GetOutputSize().Width(); // Overflow
|
2002-09-09 13:00:39 +00:00
|
|
|
|
2012-05-28 09:07:11 +02:00
|
|
|
Point aLogicStart = PixelToLogic(Point(0,0));
|
2011-01-04 13:24:15 +00:00
|
|
|
long nStartPos = aLogicStart.X();
|
|
|
|
long nInvPos = nStartPos;
|
2002-09-09 13:00:39 +00:00
|
|
|
if (nDifPos)
|
|
|
|
nInvPos += GetTextWidth(aString,0,nDifPos);
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nFlags = 0;
|
2014-06-19 21:11:48 +02:00
|
|
|
if ( nDifPos == aString.getLength() ) // only new characters appended
|
|
|
|
nFlags = INVALIDATE_NOERASE; // then background is already clear
|
|
|
|
|
|
|
|
Invalidate( Rectangle( nInvPos, 0, nStartPos+nTextSize, GetOutputSize().Height()-1 ), nFlags );
|
2002-09-09 13:00:39 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pEditEngine->SetText(rNewString);
|
|
|
|
}
|
|
|
|
|
|
|
|
aString = rNewString;
|
2002-06-11 14:52:05 +00:00
|
|
|
|
2009-11-20 14:02:34 +00:00
|
|
|
if (!maAccTextDatas.empty())
|
|
|
|
maAccTextDatas.back()->TextChanged();
|
2002-11-29 12:46:47 +00:00
|
|
|
|
2011-03-10 16:55:21 -05:00
|
|
|
bInputMode = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-26 16:45:16 +02:00
|
|
|
const OUString& ScTextWnd::GetTextString() const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return aString;
|
|
|
|
}
|
|
|
|
|
2014-02-18 13:30:53 +02:00
|
|
|
bool ScTextWnd::IsInputActive()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return HasFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
EditView* ScTextWnd::GetEditView()
|
|
|
|
{
|
|
|
|
return pEditView;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScTextWnd::MakeDialogEditView()
|
|
|
|
{
|
|
|
|
if ( pEditView ) return;
|
|
|
|
|
|
|
|
ScFieldEditEngine* pNew;
|
|
|
|
ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
|
|
|
|
if ( pViewSh )
|
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
ScDocument* pDoc = pViewSh->GetViewData().GetDocument();
|
2012-04-20 00:46:19 -04:00
|
|
|
pNew = new ScFieldEditEngine(pDoc, pDoc->GetEnginePool(), pDoc->GetEditPool());
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
2012-04-20 00:46:19 -04:00
|
|
|
pNew = new ScFieldEditEngine(NULL, EditEngine::CreatePool(), NULL, true);
|
2011-03-10 16:55:21 -05:00
|
|
|
pNew->SetExecuteURL( false );
|
2000-09-18 16:07:07 +00:00
|
|
|
pEditEngine = pNew;
|
|
|
|
|
2011-03-10 16:55:21 -05:00
|
|
|
pEditEngine->SetUpdateMode( false );
|
2013-08-11 21:36:15 +04:00
|
|
|
pEditEngine->SetWordDelimiters( pEditEngine->GetWordDelimiters() + "=" );
|
2003-03-26 17:07:02 +00:00
|
|
|
pEditEngine->SetPaperSize( Size( bIsRTL ? USHRT_MAX : THESIZE, 300 ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
SfxItemSet* pSet = new SfxItemSet( pEditEngine->GetEmptyItemSet() );
|
2014-06-13 17:51:14 +02:00
|
|
|
EditEngine::SetFontInfoInItemSet( *pSet, aTextFont );
|
2000-11-29 19:59:10 +00:00
|
|
|
lcl_ExtendEditFontAttribs( *pSet );
|
2003-03-26 17:07:02 +00:00
|
|
|
if ( bIsRTL )
|
|
|
|
lcl_ModifyRTLDefaults( *pSet );
|
2000-09-18 16:07:07 +00:00
|
|
|
pEditEngine->SetDefaults( pSet );
|
2014-02-20 14:17:27 +02:00
|
|
|
pEditEngine->SetUpdateMode( true );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
pEditView = new EditView( pEditEngine, this );
|
|
|
|
pEditEngine->InsertView( pEditView, EE_APPEND );
|
|
|
|
|
|
|
|
Resize();
|
2002-06-24 12:33:31 +00:00
|
|
|
|
2003-03-26 17:07:02 +00:00
|
|
|
if ( bIsRTL )
|
|
|
|
lcl_ModifyRTLVisArea( pEditView );
|
|
|
|
|
2009-11-20 14:02:34 +00:00
|
|
|
if (!maAccTextDatas.empty())
|
|
|
|
maAccTextDatas.back()->StartEdit();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScTextWnd::ImplInitSettings()
|
|
|
|
{
|
2003-03-26 17:07:02 +00:00
|
|
|
bIsRTL = GetSettings().GetLayoutRTL();
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
|
|
|
|
|
|
|
|
Color aBgColor= rStyleSettings.GetWindowColor();
|
|
|
|
Color aTxtColor= rStyleSettings.GetWindowTextColor();
|
|
|
|
|
|
|
|
aTextFont.SetFillColor ( aBgColor );
|
|
|
|
aTextFont.SetColor (aTxtColor);
|
|
|
|
SetBackground ( aBgColor );
|
|
|
|
Invalidate();
|
|
|
|
}
|
2002-06-10 13:56:35 +00:00
|
|
|
|
2003-04-24 16:13:03 +00:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ScTextWnd::CreateAccessible()
|
2002-06-10 13:56:35 +00:00
|
|
|
{
|
2002-08-08 12:18:38 +00:00
|
|
|
return new ScAccessibleEditObject(GetAccessibleParentWindow()->GetAccessible(), NULL, this,
|
2013-10-16 14:27:58 +02:00
|
|
|
OUString(ScResId(STR_ACC_EDITLINE_NAME)),
|
|
|
|
OUString(ScResId(STR_ACC_EDITLINE_DESCR)), ScAccessibleEditObject::EditLine);
|
2002-06-10 13:56:35 +00:00
|
|
|
}
|
|
|
|
|
2009-11-20 14:02:34 +00:00
|
|
|
void ScTextWnd::InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData )
|
|
|
|
{
|
|
|
|
OSL_ENSURE( ::std::find( maAccTextDatas.begin(), maAccTextDatas.end(), &rTextData ) == maAccTextDatas.end(),
|
|
|
|
"ScTextWnd::InsertAccessibleTextData - passed object already registered" );
|
|
|
|
maAccTextDatas.push_back( &rTextData );
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScTextWnd::RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData )
|
|
|
|
{
|
|
|
|
AccTextDataVector::iterator aEnd = maAccTextDatas.end();
|
|
|
|
AccTextDataVector::iterator aIt = ::std::find( maAccTextDatas.begin(), aEnd, &rTextData );
|
|
|
|
OSL_ENSURE( aIt != aEnd, "ScTextWnd::RemoveAccessibleTextData - passed object not registered" );
|
|
|
|
if( aIt != aEnd )
|
|
|
|
maAccTextDatas.erase( aIt );
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void ScTextWnd::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
2015-01-09 16:29:43 +02:00
|
|
|
if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
|
2015-01-12 12:55:32 +02:00
|
|
|
(rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ImplInitSettings();
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Window::DataChanged( rDCEvt );
|
|
|
|
}
|
|
|
|
|
2012-02-07 15:36:29 +00:00
|
|
|
void ScTextWnd::TextGrabFocus()
|
|
|
|
{
|
|
|
|
GrabFocus();
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
// Position window
|
2014-02-25 19:58:48 +01:00
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
ScPosWnd::ScPosWnd( vcl::Window* pParent ) :
|
2000-09-18 16:07:07 +00:00
|
|
|
ComboBox ( pParent, WinBits(WB_HIDE | WB_DROPDOWN) ),
|
|
|
|
pAccel ( NULL ),
|
2004-07-05 13:01:39 +00:00
|
|
|
nTipVisible ( 0 ),
|
2011-03-10 16:55:21 -05:00
|
|
|
bFormulaMode( false )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
Size aSize( GetTextWidth( OUString("GW99999:GW99999") ),
|
2000-09-18 16:07:07 +00:00
|
|
|
GetTextHeight() );
|
2014-06-19 21:11:48 +02:00
|
|
|
aSize.Width() += 25; // FIXME: ??
|
|
|
|
aSize.Height() = CalcWindowSizePixel(11); // Functions: 10 MRU + "others..."
|
2000-09-18 16:07:07 +00:00
|
|
|
SetSizePixel( aSize );
|
|
|
|
|
|
|
|
FillRangeNames();
|
|
|
|
|
2014-06-27 10:26:55 +02:00
|
|
|
StartListening( *SfxGetpApp() ); // For Navigator rangename updates
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2010-12-11 23:25:30 +01:00
|
|
|
ScPosWnd::~ScPosWnd()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-06-27 10:26:55 +02:00
|
|
|
EndListening( *SfxGetpApp() );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-07-05 13:01:39 +00:00
|
|
|
HideTip();
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
delete pAccel;
|
|
|
|
}
|
|
|
|
|
2014-02-18 13:30:53 +02:00
|
|
|
void ScPosWnd::SetFormulaMode( bool bSet )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( bSet != bFormulaMode )
|
|
|
|
{
|
|
|
|
bFormulaMode = bSet;
|
|
|
|
|
|
|
|
if ( bSet )
|
|
|
|
FillFunctions();
|
|
|
|
else
|
|
|
|
FillRangeNames();
|
2004-07-05 13:01:39 +00:00
|
|
|
|
|
|
|
HideTip();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-26 16:45:16 +02:00
|
|
|
void ScPosWnd::SetPos( const OUString& rPosStr )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( aPosStr != rPosStr )
|
|
|
|
{
|
|
|
|
aPosStr = rPosStr;
|
|
|
|
SetText(aPosStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-24 15:48:01 +02:00
|
|
|
namespace {
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString createLocalRangeName(const OUString& rName, const OUString& rTableName)
|
2011-09-24 15:48:01 +02:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUStringBuffer aString (rName);
|
2013-12-13 11:10:10 +02:00
|
|
|
aString.append(" (");
|
2011-09-24 15:48:01 +02:00
|
|
|
aString.append(rTableName);
|
2013-12-13 11:10:10 +02:00
|
|
|
aString.append(")");
|
2011-09-24 15:48:01 +02:00
|
|
|
return aString.makeStringAndClear();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void ScPosWnd::FillRangeNames()
|
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
|
|
|
|
SfxObjectShell* pObjSh = SfxObjectShell::Current();
|
|
|
|
if ( pObjSh && pObjSh->ISA(ScDocShell) )
|
|
|
|
{
|
2014-10-23 08:57:36 +02:00
|
|
|
ScDocument& rDoc = static_cast<ScDocShell*>(pObjSh)->GetDocument();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-09-26 00:34:14 +02:00
|
|
|
InsertEntry(ScGlobal::GetRscString( STR_MANAGE_NAMES ));
|
|
|
|
SetSeparatorPos(0);
|
|
|
|
|
2011-09-24 15:48:01 +02:00
|
|
|
ScRange aDummy;
|
2013-04-07 12:06:47 +02:00
|
|
|
std::set<OUString> aSet;
|
2014-06-18 12:14:29 +02:00
|
|
|
ScRangeName* pRangeNames = rDoc.GetRangeName();
|
2011-03-04 23:48:33 -05:00
|
|
|
if (!pRangeNames->empty())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-09-24 15:48:01 +02:00
|
|
|
ScRangeName::const_iterator itrBeg = pRangeNames->begin(), itrEnd = pRangeNames->end();
|
|
|
|
for (ScRangeName::const_iterator itr = itrBeg; itr != itrEnd; ++itr)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-11-24 07:48:41 +01:00
|
|
|
if (itr->second->IsValidReference(aDummy))
|
|
|
|
aSet.insert(itr->second->GetName());
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2011-09-24 15:48:01 +02:00
|
|
|
}
|
2014-06-18 12:14:29 +02:00
|
|
|
for (SCTAB i = 0; i < rDoc.GetTableCount(); ++i)
|
2011-09-24 15:48:01 +02:00
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
ScRangeName* pLocalRangeName = rDoc.GetRangeName(i);
|
2011-09-24 15:48:01 +02:00
|
|
|
if (pLocalRangeName && !pLocalRangeName->empty())
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aTableName;
|
2014-06-18 12:14:29 +02:00
|
|
|
rDoc.GetName(i, aTableName);
|
2011-09-24 15:48:01 +02:00
|
|
|
for (ScRangeName::const_iterator itr = pLocalRangeName->begin(); itr != pLocalRangeName->end(); ++itr)
|
|
|
|
{
|
2011-11-24 07:48:41 +01:00
|
|
|
if (itr->second->IsValidReference(aDummy))
|
|
|
|
aSet.insert(createLocalRangeName(itr->second->GetName(), aTableName));
|
2011-09-24 15:48:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-03-04 23:48:33 -05:00
|
|
|
|
2011-09-24 15:48:01 +02:00
|
|
|
if (!aSet.empty())
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
for (std::set<OUString>::iterator itr = aSet.begin();
|
2011-09-24 15:48:01 +02:00
|
|
|
itr != aSet.end(); ++itr)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-09-24 15:48:01 +02:00
|
|
|
InsertEntry(*itr);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetText(aPosStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScPosWnd::FillFunctions()
|
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
|
2013-10-07 14:40:24 +02:00
|
|
|
OUString aFirstName;
|
2000-09-18 16:07:07 +00:00
|
|
|
const ScAppOptions& rOpt = SC_MOD()->GetAppOptions();
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nMRUCount = rOpt.GetLRUFuncListCount();
|
|
|
|
const sal_uInt16* pMRUList = rOpt.GetLRUFuncList();
|
2000-09-18 16:07:07 +00:00
|
|
|
if (pMRUList)
|
|
|
|
{
|
|
|
|
const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uLong nListCount = pFuncList->GetCount();
|
|
|
|
for (sal_uInt16 i=0; i<nMRUCount; i++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nId = pMRUList[i];
|
|
|
|
for (sal_uLong j=0; j<nListCount; j++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
const ScFuncDesc* pDesc = pFuncList->GetFunction( j );
|
|
|
|
if ( pDesc->nFIndex == nId && pDesc->pFuncName )
|
|
|
|
{
|
|
|
|
InsertEntry( *pDesc->pFuncName );
|
2013-10-07 14:40:24 +02:00
|
|
|
if (aFirstName.isEmpty())
|
2000-09-18 16:07:07 +00:00
|
|
|
aFirstName = *pDesc->pFuncName;
|
2014-06-19 21:11:48 +02:00
|
|
|
break; // Stop searching
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
//! Re-add entry "Other..." for Function AutoPilot if it can work with text that
|
|
|
|
// has been entered so far
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
// InsertEntry( ScGlobal::GetRscString(STR_FUNCTIONLIST_MORE) );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
SetText(aFirstName);
|
|
|
|
}
|
|
|
|
|
2010-11-10 15:51:56 -05:00
|
|
|
void ScPosWnd::Notify( SfxBroadcaster&, const SfxHint& rHint )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( !bFormulaMode )
|
|
|
|
{
|
2014-06-19 21:11:48 +02:00
|
|
|
// Does the list of range names need updating?
|
2014-08-27 16:57:21 +02:00
|
|
|
const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
|
|
|
|
if ( pSimpleHint )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-08-27 16:57:21 +02:00
|
|
|
sal_uLong nHintId = pSimpleHint->GetId();
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( nHintId == SC_HINT_AREAS_CHANGED || nHintId == SC_HINT_NAVIGATOR_UPDATEALL)
|
|
|
|
FillRangeNames();
|
|
|
|
}
|
2014-08-27 16:57:21 +02:00
|
|
|
else if ( dynamic_cast<const SfxEventHint*>(&rHint) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-08-27 16:57:21 +02:00
|
|
|
sal_uLong nEventId = static_cast<const SfxEventHint*>(&rHint)->GetEventId();
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( nEventId == SFX_EVENT_ACTIVATEDOC )
|
|
|
|
FillRangeNames();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-05 13:01:39 +00:00
|
|
|
void ScPosWnd::HideTip()
|
|
|
|
{
|
|
|
|
if ( nTipVisible )
|
|
|
|
{
|
|
|
|
Help::HideTip( nTipVisible );
|
|
|
|
nTipVisible = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-07 14:40:24 +02:00
|
|
|
static ScNameInputType lcl_GetInputType( const OUString& rText )
|
2004-07-05 13:01:39 +00:00
|
|
|
{
|
|
|
|
ScNameInputType eRet = SC_NAME_INPUT_BAD_NAME; // the more general error
|
|
|
|
|
|
|
|
ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
|
|
|
|
if ( pViewSh )
|
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
ScViewData& rViewData = pViewSh->GetViewData();
|
|
|
|
ScDocument* pDoc = rViewData.GetDocument();
|
|
|
|
SCTAB nTab = rViewData.GetTabNo();
|
CWS-TOOLING: integrate CWS frmdlg
2008-12-18 09:13:09 +0100 oj r265667 : merge from odff05
2008-12-18 07:58:16 +0100 oj r265658 : #i94555# patch from <regina>, ODFF:
Add GAMMA, CHISQDIST, CHISQINV.
Make the 'cumulative' parameter of GAMMADIST optional.
Adapt the domain of CHIDIST to allow negative x.
Remove the constraint "degrees of freedom < 1.0E5" from CHIDIST and CHIINV.
Plus a mechanism to write the now optional parameter of GAMMADIST to PODF and
ODFF if omitted, for backwards compatibility.
2008-12-15 14:06:11 +0100 oj r265490 : CWS-TOOLING: rebase CWS frmdlg to trunk@264807 (milestone: DEV300:m37)
2008-12-15 13:55:28 +0100 oj r265488 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:55:07 +0100 oj r265487 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:48 +0100 oj r265486 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:36 +0100 oj r265485 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:24 +0100 oj r265484 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:48:11 +0100 oj r265483 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:31:12 +0100 oj r265479 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:13:58 +0100 oj r265477 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:10:09 +0100 oj r265476 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:05:11 +0100 oj r265475 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:47:17 +0100 oj r265467 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:46:19 +0100 oj r265466 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:45:47 +0100 oj r265465 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 07:35:07 +0100 oj r265458 : add dependency to formula
2008-12-15 07:34:24 +0100 oj r265457 : add dependency to formula
2008-12-12 13:22:00 +0100 msc r265413 : #i97089#
2008-12-12 13:20:25 +0100 msc r265412 : #i97089#
2008-12-12 12:35:12 +0100 msc r265406 : #i97089#
2008-12-12 12:34:16 +0100 msc r265405 : #i97089#
2008-12-12 12:33:05 +0100 msc r265404 : #i97089#
2008-12-12 12:31:11 +0100 msc r265403 : #i97089#
2008-12-08 11:59:10 +0100 oj r264981 : insert RTL_LOG
2008-12-08 11:50:17 +0100 oj r264980 : some small changes
2008-12-05 12:57:57 +0100 oj r264902 : eof changed
2008-12-05 12:56:46 +0100 oj r264901 : eof changed
2008-12-05 12:28:47 +0100 oj r264899 : wrong var used
2008-12-05 10:08:57 +0100 oj r264890 : token order reversed
2008-12-04 13:49:22 +0100 oc r264843 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:45:27 +0100 oc r264842 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:42:54 +0100 oc r264841 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:37:41 +0100 oc r264840 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:34:11 +0100 oc r264839 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 12:35:31 +0100 oj r264835 : new help ids for struct and function tabpage
2008-12-04 12:00:35 +0100 oj r264828 : set explicit help id
2008-12-03 14:53:27 +0100 oj r264786 : #i96845# change ref button
2008-12-03 14:51:49 +0100 oj r264785 : #i96845# change ref button
2008-12-03 08:51:57 +0100 oj r264746 : convert dos to unix lineends
2008-12-03 08:50:45 +0100 oj r264745 : convert dos to unix lineends
2008-12-03 08:50:05 +0100 oj r264744 : convert dos to unix lineends
2008-12-02 12:28:33 +0100 oj r264686 : clear help text when new helpid is set
2008-12-02 12:28:02 +0100 oj r264685 : set help id for listbox category
2008-12-02 07:15:56 +0100 oj r264655 : remove define to auto generate help ids
2008-12-01 14:36:43 +0100 oj r264604 : use temp var
2008-12-01 14:18:31 +0100 oj r264601 : moved ScJumpToken to formula
2008-12-01 14:18:11 +0100 oj r264600 : moved ScJumpToken to formula
2008-12-01 14:14:35 +0100 oj r264599 : moved ScJumpToken from sc
2008-12-01 10:48:51 +0100 oj r264589 : change quickhelptext from Shrink to Select
2008-12-01 10:28:41 +0100 oj r264588 : fix opcode data, has to be Any.Void
2008-11-28 11:16:48 +0100 oj r264532 : add help ids
2008-11-28 10:16:56 +0100 oj r264529 : set help id
2008-11-28 10:16:43 +0100 oj r264528 : set help id
2008-11-26 13:55:04 +0100 oj r264381 : #94535# use of optional instead of deleting a string myself and some small changes
2008-11-26 09:53:20 +0100 oj r264346 : compile error with debug/without debug
2008-11-25 07:41:28 +0100 oj r264271 : put static into the method which make use of them
2008-11-24 08:16:07 +0100 oj r264196 : removed not needed classes for op code
2008-11-24 08:13:44 +0100 oj r264195 : removed not needed classes for op code
2008-11-21 14:05:53 +0100 oj r264135 : make GetOpCode inline
2008-11-21 12:35:27 +0100 oj r264124 : hold symbols
2008-11-20 09:27:27 +0100 oj r264028 : merged code from DEV300_m35 which got lost
2008-11-19 20:42:12 +0100 oj r264022 : more changes for formula dialog remove
2008-11-19 20:37:41 +0100 oj r264021 : removed unused var
2008-11-19 20:35:35 +0100 oj r264020 : some more changes at token
2008-11-19 10:59:47 +0100 oj r263967 : deleted
2008-11-19 10:58:24 +0100 oj r263966 : add forui and for res files
2008-11-18 15:27:36 +0100 oj r263777 : unused para removed
2008-11-18 15:23:23 +0100 oj r263775 : add insert button to add field dlg
2008-11-18 13:39:53 +0100 oj r263764 : enable the formula dialog as well for conditional print as for conditional formatting
2008-11-18 12:03:25 +0100 oj r263760 : rename isRef in IsRef
2008-11-17 11:46:16 +0100 oj r263711 : patches for function handling
2008-11-17 11:36:22 +0100 oj r263710 : add new for forui and res file
2008-11-17 09:21:12 +0100 oj r263704 : patches for some resource for libformula
2008-11-15 12:45:30 +0100 oj r263701 : changes for formula editor extraction
2008-11-07 08:23:27 +0100 oj r263416 : merge from DEV300:m35
2008-11-07 08:22:35 +0100 oj r263415 : merge from DEV300:m35
2008-11-07 08:22:16 +0100 oj r263414 : merge from DEV300:m35
2008-11-07 08:21:41 +0100 oj r263413 : merge from DEV300:m35
2008-11-07 08:21:31 +0100 oj r263412 : merge from DEV300:m35
2008-11-07 08:20:38 +0100 oj r263411 : merge from DEV300:m35
2008-11-07 08:20:00 +0100 oj r263410 : merge from DEV300:m35
2008-11-07 08:18:50 +0100 oj r263409 : merge from DEV300:m35
2008-11-07 08:18:19 +0100 oj r263408 : merge from DEV300:m35
2008-11-07 08:10:27 +0100 oj r263407 : merge from DEV300:m35
2008-10-21 07:43:46 +0200 oj r262560 : some compile errors resolved
2008-10-17 16:40:01 +0200 oj r262291 : dep for 1st target
2008-10-07 10:08:39 +0200 oj r262077 : copy
2008-10-07 09:45:31 +0200 oj r262076 : #i94535#
2008-10-07 09:44:26 +0200 oj r262075 : #i94535# new base class
2008-10-07 09:43:21 +0200 oj r262074 : moved to formula
2008-10-07 09:41:51 +0200 oj r262073 : new images
2008-10-07 09:03:01 +0200 oj r262072 : new ids for formula
2008-10-02 08:46:27 +0200 oj r262024 : #i94535# move the formula compiler to formula
2008-10-02 08:08:54 +0200 oj r262023 : #i94535#
2008-10-02 08:06:28 +0200 oj r262022 : #i94535#
2008-10-02 08:05:52 +0200 oj r262021 : #i94535#
2008-10-01 17:15:29 +0200 oj r262014 : #i94535#
2008-10-01 17:12:40 +0200 oj r262013 : new module formula
2008-10-01 17:04:55 +0200 oj r262012 : #i94535#
2008-10-01 16:49:03 +0200 oj r262010 : #i94535#
2008-10-01 16:46:59 +0200 oj r262009 : #i94535#
2009-01-08 10:47:13 +00:00
|
|
|
formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
|
2004-07-05 13:01:39 +00:00
|
|
|
|
|
|
|
// test in same order as in SID_CURRENTCELL execute
|
|
|
|
|
|
|
|
ScRange aRange;
|
|
|
|
ScAddress aAddress;
|
|
|
|
ScRangeUtil aRangeUtil;
|
|
|
|
SCTAB nNameTab;
|
|
|
|
sal_Int32 nNumeric;
|
|
|
|
|
2011-09-26 00:34:14 +02:00
|
|
|
if (rText == ScGlobal::GetRscString(STR_MANAGE_NAMES))
|
|
|
|
eRet = SC_MANAGE_NAMES;
|
|
|
|
else if ( aRange.Parse( rText, pDoc, eConv ) & SCA_VALID )
|
2011-05-04 19:37:28 -04:00
|
|
|
eRet = SC_NAME_INPUT_RANGE;
|
2008-05-14 08:54:16 +00:00
|
|
|
else if ( aAddress.Parse( rText, pDoc, eConv ) & SCA_VALID )
|
2004-07-05 13:01:39 +00:00
|
|
|
eRet = SC_NAME_INPUT_CELL;
|
2008-05-14 08:54:16 +00:00
|
|
|
else if ( aRangeUtil.MakeRangeFromName( rText, pDoc, nTab, aRange, RUTL_NAMES, eConv ) )
|
2004-07-05 13:01:39 +00:00
|
|
|
eRet = SC_NAME_INPUT_NAMEDRANGE;
|
2008-05-14 08:54:16 +00:00
|
|
|
else if ( aRangeUtil.MakeRangeFromName( rText, pDoc, nTab, aRange, RUTL_DBASE, eConv ) )
|
2004-07-05 13:01:39 +00:00
|
|
|
eRet = SC_NAME_INPUT_DATABASE;
|
2011-08-28 01:03:37 +01:00
|
|
|
else if ( comphelper::string::isdigitAsciiString( rText ) &&
|
2013-10-07 14:40:24 +02:00
|
|
|
( nNumeric = rText.toInt32() ) > 0 && nNumeric <= MAXROW+1 )
|
2004-07-05 13:01:39 +00:00
|
|
|
eRet = SC_NAME_INPUT_ROW;
|
|
|
|
else if ( pDoc->GetTable( rText, nNameTab ) )
|
|
|
|
eRet = SC_NAME_INPUT_SHEET;
|
|
|
|
else if ( ScRangeData::IsNameValid( rText, pDoc ) ) // nothing found, create new range?
|
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
if ( rViewData.GetSimpleArea( aRange ) == SC_MARK_SIMPLE )
|
2004-07-05 13:01:39 +00:00
|
|
|
eRet = SC_NAME_INPUT_DEFINE;
|
|
|
|
else
|
|
|
|
eRet = SC_NAME_INPUT_BAD_SELECTION;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
eRet = SC_NAME_INPUT_BAD_NAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
return eRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScPosWnd::Modify()
|
|
|
|
{
|
|
|
|
ComboBox::Modify();
|
|
|
|
|
|
|
|
HideTip();
|
|
|
|
|
|
|
|
if ( !IsTravelSelect() && !bFormulaMode )
|
|
|
|
{
|
|
|
|
// determine the action that would be taken for the current input
|
|
|
|
|
|
|
|
ScNameInputType eType = lcl_GetInputType( GetText() ); // uses current view
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nStrId = 0;
|
2004-07-05 13:01:39 +00:00
|
|
|
switch ( eType )
|
|
|
|
{
|
|
|
|
case SC_NAME_INPUT_CELL:
|
|
|
|
nStrId = STR_NAME_INPUT_CELL;
|
|
|
|
break;
|
|
|
|
case SC_NAME_INPUT_RANGE:
|
|
|
|
case SC_NAME_INPUT_NAMEDRANGE:
|
|
|
|
nStrId = STR_NAME_INPUT_RANGE; // named range or range reference
|
|
|
|
break;
|
|
|
|
case SC_NAME_INPUT_DATABASE:
|
|
|
|
nStrId = STR_NAME_INPUT_DBRANGE;
|
|
|
|
break;
|
|
|
|
case SC_NAME_INPUT_ROW:
|
|
|
|
nStrId = STR_NAME_INPUT_ROW;
|
|
|
|
break;
|
|
|
|
case SC_NAME_INPUT_SHEET:
|
|
|
|
nStrId = STR_NAME_INPUT_SHEET;
|
|
|
|
break;
|
|
|
|
case SC_NAME_INPUT_DEFINE:
|
|
|
|
nStrId = STR_NAME_INPUT_DEFINE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// other cases (error): no tip help
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( nStrId )
|
|
|
|
{
|
|
|
|
// show the help tip at the text cursor position
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window* pWin = GetSubEdit();
|
2004-07-05 13:01:39 +00:00
|
|
|
if (!pWin)
|
|
|
|
pWin = this;
|
|
|
|
Point aPos;
|
2014-08-23 18:33:43 +03:00
|
|
|
vcl::Cursor* pCur = pWin->GetCursor();
|
2004-07-05 13:01:39 +00:00
|
|
|
if (pCur)
|
|
|
|
aPos = pWin->LogicToPixel( pCur->GetPos() );
|
|
|
|
aPos = pWin->OutputToScreenPixel( aPos );
|
|
|
|
Rectangle aRect( aPos, aPos );
|
|
|
|
|
2013-10-07 14:40:24 +02:00
|
|
|
OUString aText = ScGlobal::GetRscString( nStrId );
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nAlign = QUICKHELP_LEFT|QUICKHELP_BOTTOM;
|
2004-07-05 13:01:39 +00:00
|
|
|
nTipVisible = Help::ShowTip(pWin, aRect, aText, nAlign);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-11 23:25:30 +01:00
|
|
|
void ScPosWnd::Select()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-06-19 21:11:48 +02:00
|
|
|
ComboBox::Select(); // In VCL GetText() only return the selected entry afterwards
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-07-05 13:01:39 +00:00
|
|
|
HideTip();
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if (!IsTravelSelect())
|
|
|
|
DoEnter();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScPosWnd::DoEnter()
|
|
|
|
{
|
2013-10-07 14:40:24 +02:00
|
|
|
OUString aText = GetText();
|
|
|
|
if ( !aText.isEmpty() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( bFormulaMode )
|
|
|
|
{
|
|
|
|
ScModule* pScMod = SC_MOD();
|
|
|
|
if ( aText == ScGlobal::GetRscString(STR_FUNCTIONLIST_MORE) )
|
|
|
|
{
|
2014-06-19 21:11:48 +02:00
|
|
|
// Function AutoPilot
|
|
|
|
//! Continue working with the text entered so far
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
//! new method at ScModule to query if function autopilot is open
|
|
|
|
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
|
|
|
|
if ( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) )
|
2000-09-22 17:57:10 +00:00
|
|
|
pViewFrm->GetDispatcher()->Execute( SID_OPENDLG_FUNCTION,
|
2014-10-11 16:01:26 +02:00
|
|
|
SfxCallMode::SYNCHRON | SfxCallMode::RECORD );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
|
|
|
|
ScInputHandler* pHdl = pScMod->GetInputHdl( pViewSh );
|
|
|
|
if (pHdl)
|
|
|
|
pHdl->InsertFunction( aText );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-07-05 13:01:39 +00:00
|
|
|
// depending on the input, select something or create a new named range
|
|
|
|
|
|
|
|
ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
|
|
|
|
if ( pViewSh )
|
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
ScViewData& rViewData = pViewSh->GetViewData();
|
|
|
|
ScDocShell* pDocShell = rViewData.GetDocShell();
|
|
|
|
ScDocument& rDoc = pDocShell->GetDocument();
|
2011-04-22 11:57:36 -04:00
|
|
|
|
2004-07-05 13:01:39 +00:00
|
|
|
ScNameInputType eType = lcl_GetInputType( aText );
|
|
|
|
if ( eType == SC_NAME_INPUT_BAD_NAME || eType == SC_NAME_INPUT_BAD_SELECTION )
|
|
|
|
{
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nId = ( eType == SC_NAME_INPUT_BAD_NAME ) ? STR_NAME_ERROR_NAME : STR_NAME_ERROR_SELECTION;
|
2004-07-05 13:01:39 +00:00
|
|
|
pViewSh->ErrorMessage( nId );
|
|
|
|
}
|
|
|
|
else if ( eType == SC_NAME_INPUT_DEFINE )
|
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
ScRangeName* pNames = rDoc.GetRangeName();
|
2004-07-05 13:01:39 +00:00
|
|
|
ScRange aSelection;
|
2012-01-06 23:00:40 +00:00
|
|
|
if ( pNames && !pNames->findByUpperName(ScGlobal::pCharClass->uppercase(aText)) &&
|
2014-06-18 12:14:29 +02:00
|
|
|
(rViewData.GetSimpleArea( aSelection ) == SC_MARK_SIMPLE) )
|
2004-07-05 13:01:39 +00:00
|
|
|
{
|
|
|
|
ScRangeName aNewRanges( *pNames );
|
2014-06-18 12:14:29 +02:00
|
|
|
ScAddress aCursor( rViewData.GetCurX(), rViewData.GetCurY(), rViewData.GetTabNo() );
|
|
|
|
OUString aContent(aSelection.Format(SCR_ABS_3D, &rDoc, rDoc.GetAddressConvention()));
|
|
|
|
ScRangeData* pNew = new ScRangeData( &rDoc, aText, aContent, aCursor );
|
2011-03-05 14:07:14 -05:00
|
|
|
if ( aNewRanges.insert(pNew) )
|
2004-07-05 13:01:39 +00:00
|
|
|
{
|
2012-04-02 16:50:15 +01:00
|
|
|
pDocShell->GetDocFunc().ModifyRangeNames( aNewRanges );
|
2011-03-10 16:55:21 -05:00
|
|
|
pViewSh->UpdateInputHandler(true);
|
2004-07-05 13:01:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-09-26 00:34:14 +02:00
|
|
|
else if (eType == SC_MANAGE_NAMES)
|
|
|
|
{
|
|
|
|
sal_uInt16 nId = ScNameDlgWrapper::GetChildWindowId();
|
|
|
|
SfxViewFrame* pViewFrm = pViewSh->GetViewFrame();
|
|
|
|
SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
|
|
|
|
|
|
|
|
SC_MOD()->SetRefDialog( nId, pWnd ? false : sal_True );
|
|
|
|
}
|
2004-07-05 13:01:39 +00:00
|
|
|
else
|
|
|
|
{
|
2014-11-10 15:05:25 +01:00
|
|
|
// for all selection types, execute the SID_CURRENTCELL slot.
|
2011-05-04 19:37:28 -04:00
|
|
|
if (eType == SC_NAME_INPUT_CELL || eType == SC_NAME_INPUT_RANGE)
|
|
|
|
{
|
|
|
|
// Note that SID_CURRENTCELL always expects address to
|
|
|
|
// be in Calc A1 format. Convert the text.
|
2014-06-18 12:14:29 +02:00
|
|
|
ScRange aRange(0,0, rViewData.GetTabNo());
|
|
|
|
aRange.ParseAny(aText, &rDoc, rDoc.GetAddressConvention());
|
|
|
|
aText = aRange.Format(SCR_ABS_3D, &rDoc, ::formula::FormulaGrammar::CONV_OOO);
|
2011-05-04 19:37:28 -04:00
|
|
|
}
|
2004-07-05 13:01:39 +00:00
|
|
|
|
|
|
|
SfxStringItem aPosItem( SID_CURRENTCELL, aText );
|
2014-01-28 20:00:32 +01:00
|
|
|
SfxBoolItem aUnmarkItem( FN_PARAM_1, true ); // remove existing selection
|
2004-07-05 13:01:39 +00:00
|
|
|
|
2014-06-18 12:14:29 +02:00
|
|
|
pViewSh->GetViewData().GetDispatcher().Execute( SID_CURRENTCELL,
|
2014-10-11 16:01:26 +02:00
|
|
|
SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
|
2004-07-05 13:01:39 +00:00
|
|
|
&aPosItem, &aUnmarkItem, 0L );
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SetText( aPosStr );
|
|
|
|
|
|
|
|
ReleaseFocus_Impl();
|
|
|
|
}
|
|
|
|
|
2014-01-17 16:40:50 +01:00
|
|
|
bool ScPosWnd::Notify( NotifyEvent& rNEvt )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-03-10 12:08:45 -04:00
|
|
|
bool bHandled = true;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-03-10 12:08:45 -04:00
|
|
|
switch (rNEvt.GetType())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-11-26 14:53:25 +00:00
|
|
|
case MouseNotifyEvent::KEYINPUT:
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-03-10 12:08:45 -04:00
|
|
|
const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-03-10 12:08:45 -04:00
|
|
|
switch ( pKEvt->GetKeyCode().GetCode() )
|
|
|
|
{
|
|
|
|
case KEY_RETURN:
|
|
|
|
DoEnter();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_ESCAPE:
|
|
|
|
if (nTipVisible)
|
|
|
|
{
|
|
|
|
// escape when the tip help is shown: only hide the tip
|
|
|
|
HideTip();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!bFormulaMode)
|
|
|
|
SetText( aPosStr );
|
|
|
|
ReleaseFocus_Impl();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2014-03-10 12:08:45 -04:00
|
|
|
break;
|
2014-11-26 14:53:25 +00:00
|
|
|
case MouseNotifyEvent::GETFOCUS:
|
2014-03-10 12:08:45 -04:00
|
|
|
{
|
|
|
|
// Select the whole text upon focus.
|
|
|
|
OUString aStr = GetText();
|
|
|
|
SetSelection(Selection(0, aStr.getLength()));
|
|
|
|
}
|
|
|
|
break;
|
2014-11-26 14:53:25 +00:00
|
|
|
case MouseNotifyEvent::LOSEFOCUS:
|
2014-03-10 12:08:45 -04:00
|
|
|
HideTip();
|
|
|
|
bHandled = false;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
bHandled = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2001-11-26 19:45:09 +00:00
|
|
|
|
2014-03-10 12:08:45 -04:00
|
|
|
if (!bHandled)
|
|
|
|
bHandled = ComboBox::Notify(rNEvt);
|
2004-07-05 13:01:39 +00:00
|
|
|
|
2014-03-10 12:08:45 -04:00
|
|
|
return bHandled;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScPosWnd::ReleaseFocus_Impl()
|
|
|
|
{
|
2004-07-05 13:01:39 +00:00
|
|
|
HideTip();
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxViewShell* pCurSh = SfxViewShell::Current();
|
|
|
|
ScInputHandler* pHdl = SC_MOD()->GetInputHdl( PTR_CAST( ScTabViewShell, pCurSh ) );
|
|
|
|
if ( pHdl && pHdl->IsTopMode() )
|
|
|
|
{
|
2014-06-19 21:11:48 +02:00
|
|
|
// Focus back in input row?
|
2000-09-18 16:07:07 +00:00
|
|
|
ScInputWindow* pInputWin = pHdl->GetInputWindow();
|
|
|
|
if (pInputWin)
|
|
|
|
{
|
|
|
|
pInputWin->TextGrabFocus();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-19 21:11:48 +02:00
|
|
|
// Set focus to active View
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pCurSh )
|
|
|
|
{
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window* pShellWnd = pCurSh->GetWindow();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( pShellWnd )
|
|
|
|
pShellWnd->GrabFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-12 15:59:00 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|