Files
libreoffice/sc/source/ui/drawfunc/futext3.cxx

186 lines
7.5 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by Herbert Duerr i#118735 prevent endless loop if vlookup/hlookup doesn't find anything http://svn.apache.org/viewvc?view=revision&revision=1239673 Patches contributed by Andre Fischer remove lp_solver http://svn.apache.org/viewvc?view=revision&revision=1199180 i#118160: Added external CoinMP library. http://svn.apache.org/viewvc?view=revision&revision=1233909 Patches contributed by Armin Le-Grand i#118485 - Styles for OLEs are not saved. http://svn.apache.org/viewvc?view=revision&revision=1182166 i#118524: apply patch, followup fixes to 118485 http://svn.apache.org/viewvc?view=revision&revision=1186077 Patches contributed by lihuiibm i#108860 - Fix range validation. http://svn.apache.org/viewvc?view=revision&revision=1242846 i#118954 Chart data will lost after copy to different file http://svn.apache.org/viewvc?view=revision&revision=1301345 Patches contributed by Ariel Constenla-Haile Fix Linux build breaker: extra qualification on member http://svn.apache.org/viewvc?view=revision&revision=1301591 i#118696 - i#118697 - Fix some Sheet Tab Color API issues http://svn.apache.org/viewvc?view=revision&revision=1225428 i#118697 - Fix uninitialized variable http://svn.apache.org/viewvc?view=revision&revision=1225859 i#118771 - ScUndoImportTab should preserve tab background color http://svn.apache.org/viewvc?view=revision&revision=1230356 i#118921 - Repaint linked sheet tab background color after updating link http://svn.apache.org/viewvc?view=revision&revision=1245177 i#118927 - Undo/Redo "Update Link" does not reset sheet tab color http://svn.apache.org/viewvc?view=revision&revision=1245241 i#118747 - Copy tab color when transferring sheets across documents http://svn.apache.org/viewvc?view=revision&revision=1230355 Patch contributed by Oliver Rainer-Wittman i#118012 - methods <ScBroadcastAreaSlot::AreaBroadcast(..)> and <ScBroadcastAreaSlot::AreaBroadcastInRange(..)> adapt stl-container iteration in order to avoid destroyed iterators during iteration. http://svn.apache.org/viewvc?view=revision&revision=1297916 Patches contributed by Mathias Bauer gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 Patch contributed by Daniel Rentz calc69: #i116936# fix VBA symbol Cells http://svn.apache.org/viewvc?view=revision&revision=1172135 Patches contributed by leiw: i#118546 CPU 100% on switched off AutoCalculate with Conditional Formatting on date values http://svn.apache.org/viewvc?view=revision&revision=1301380 Re-add new function documentation. Many various cleanups. Add missing calc66: #o11817313# also look at formula result number format, remove redundant binaries.
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
#include <editeng/editeng.hxx>
#include <editeng/outlobj.hxx>
2000-09-18 16:07:07 +00:00
#include <svx/svdocapt.hxx>
#include <svx/svdpage.hxx>
#include <svx/svdundo.hxx>
#include <svx/svdview.hxx>
#include <editeng/editobj.hxx>
2000-09-18 16:07:07 +00:00
#include <vcl/cursor.hxx>
#include <sfx2/objsh.hxx>
#include <editeng/writingmodeitem.hxx>
2000-09-18 16:07:07 +00:00
#include "global.hxx"
#include "drwlayer.hxx"
#include "userdat.hxx"
#include "tabvwsh.hxx"
2000-09-18 16:07:07 +00:00
#include "document.hxx"
#include "editutil.hxx"
#include "futext.hxx"
#include "docsh.hxx"
#include "postit.hxx"
2000-09-18 16:07:07 +00:00
#include "globstr.hrc"
#include "attrib.hxx"
#include "scitems.hxx"
#include "drawview.hxx"
#include "undocell.hxx"
2000-09-18 16:07:07 +00:00
// Editieren von Notiz-Legendenobjekten muss immer ueber StopEditMode beendet werden,
// damit die Aenderungen ins Dokument uebernommen werden!
// (Fontwork-Execute in drawsh und drtxtob passiert nicht fuer Legendenobjekte)
// bTextDirection=sal_True means that this function is called from SID_TEXTDIRECTION_XXX(drtxtob.cxx).
void FuText::StopEditMode(bool /*bTextDirection*/)
2000-09-18 16:07:07 +00:00
{
SdrObject* pObject = pView->GetTextEditObject();
if( !pObject ) return;
2000-09-18 16:07:07 +00:00
// relock the internal layer that has been unlocked in FuText::SetInEditMode()
if ( pObject->GetLayer() == SC_LAYER_INTERN )
pView->LockInternalLayer();
2000-09-18 16:07:07 +00:00
ScViewData& rViewData = pViewShell->GetViewData();
ScDocument& rDoc = *rViewData.GetDocument();
ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
OSL_ENSURE( pDrawLayer && (pDrawLayer == pDrDoc), "FuText::StopEditMode - missing or different drawing layers" );
ScAddress aNotePos;
ScPostIt* pNote = 0;
if( const ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObject, rViewData.GetTabNo() ) )
2000-09-18 16:07:07 +00:00
{
aNotePos = pCaptData->maStart;
pNote = rDoc.GetNote( aNotePos );
OSL_ENSURE( pNote && (pNote->GetCaption() == pObject), "FuText::StopEditMode - missing or invalid cell note" );
}
2000-09-18 16:07:07 +00:00
ScDocShell* pDocShell = rViewData.GetDocShell();
::svl::IUndoManager* pUndoMgr = rDoc.IsUndoEnabled() ? pDocShell->GetUndoManager() : 0;
bool bNewNote = false;
if( pNote && pUndoMgr )
{
/* Put all undo actions already collected (e.g. create caption object)
and all following undo actions (text changed) together into a ListAction. */
SdrUndoGroup* pCalcUndo = pDrawLayer->GetCalcUndo();
if(pCalcUndo)
{
const OUString aUndoStr = ScGlobal::GetRscString( STR_UNDO_EDITNOTE );
pUndoMgr->EnterListAction( aUndoStr, aUndoStr );
/* Note has been created before editing, if first undo action is
an insert action. Needed below to decide whether to drop the
undo if editing a new note has been cancelled. */
bNewNote = (pCalcUndo->GetActionCount() > 0) && pCalcUndo->GetAction( 0 )->ISA( SdrUndoNewObj );
// create a "insert note" undo action if needed
if( bNewNote )
pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, aNotePos, pNote->GetNoteData(), true, pCalcUndo ) );
else
pUndoMgr->AddUndoAction( pCalcUndo );
}
2000-09-18 16:07:07 +00:00
}
CWS-TOOLING: integrate CWS calcsheetdata 2009-08-13 16:18:48 +0200 nn r274950 : #i102616# shared/remote files, better handling of formula results 2009-08-12 11:17:30 +0200 nn r274884 : CWS-TOOLING: rebase CWS calcsheetdata to trunk@274622 (milestone: DEV300:m54) 2009-08-12 10:30:47 +0200 nn r274881 : #i102616# some clean-up 2009-08-11 19:01:18 +0200 nn r274876 : #i102616# store loaded namespaces, so prefixes remain valid 2009-08-11 19:00:49 +0200 nn r274875 : #i102616# store loaded namespaces, so prefixes remain valid 2009-08-10 19:12:04 +0200 nn r274835 : #i102616# detective, notes, encoding, error handling 2009-08-07 11:18:46 +0200 nn r274751 : #i102616# use new method SvXMLAutoStylePoolP::AddNamed 2009-08-07 11:18:15 +0200 nn r274750 : #i102616# new method SvXMLAutoStylePoolP::AddNamed 2009-08-06 18:02:42 +0200 nn r274740 : #i102616# modification: shapes, notes, pending row heights; skip sheets in export iterator 2009-08-05 18:41:59 +0200 nn r274694 : #i102616# handle text styles in notes 2009-08-03 18:55:59 +0200 nn r274594 : #i102616# handle text styles in cells 2009-07-31 19:00:06 +0200 nn r274548 : #i102616# handle styles for notes 2009-07-28 16:46:20 +0200 nn r274414 : missed a conflict 2009-07-28 14:01:56 +0200 nn r274404 : CWS-TOOLING: rebase CWS calcsheetdata to trunk@274203 (milestone: DEV300:m53) 2009-07-23 18:28:47 +0200 nn r274278 : #i102616# handle table styles 2009-07-22 15:40:24 +0200 nn r274244 : #i102616# handle row styles 2009-07-21 20:09:37 +0200 nn r274211 : #i102616# handle column styles 2009-07-16 13:00:18 +0200 nn r274043 : #i102616# invalidate all stream positions when inserting/deleting sheets 2009-07-15 17:41:15 +0200 nn r274021 : #i102616# don't collect cell styles twice for copied sheets 2009-07-14 18:36:11 +0200 nn r273985 : #i102616# allow to query stream position, clear buffer 2009-07-14 18:32:10 +0200 nn r273984 : #i102616# allow to specify a name for an autostyle 2009-07-09 22:01:23 +0200 nn r273870 : #i102616# copy stream for unchanged sheets 2009-07-08 18:11:42 +0200 nn r273844 : #i102616# store stream positions of sheets 2009-06-24 19:08:18 +0200 nn r273363 : #i102616# detect changed sheets since loading 2009-06-09 15:53:32 +0200 nn r272774 : #i102616# store automatic cell style information after loading
2009-09-07 15:38:19 +00:00
if( pNote )
rDoc.LockStreamValid(true); // only the affected sheet is invalidated below
/* SdrObjEditView::SdrEndTextEdit() may try to delete the entire drawing
object, if it does not contain text and has invisible border and fill.
This must not happen for note caption objects. They will be removed
below together with the cell note if the text is empty (independent of
border and area formatting). It is possible to prevent automatic
deletion by passing sal_True to this function. The return value changes
from SDRENDTEXTEDIT_DELETED to SDRENDTEXTEDIT_SHOULDBEDELETED in this
case. */
/*SdrEndTextEditKind eResult =*/ pView->SdrEndTextEdit( pNote != 0 );
// or ScEndTextEdit (with drawview.hxx)
pViewShell->SetDrawTextUndo( 0 );
2000-09-18 16:07:07 +00:00
vcl::Cursor* pCur = pWindow->GetCursor();
if( pCur && pCur->IsVisible() )
2000-09-18 16:07:07 +00:00
pCur->Hide();
if( pNote )
2000-09-18 16:07:07 +00:00
{
// hide the caption object if it is in hidden state
CWS-TOOLING: integrate CWS dr70 2009-06-09 13:52:02 +0200 dr r272770 : #i101930# SXC import broken 2009-06-05 11:50:16 +0200 dr r272675 : #i10000# compiler warning 2009-06-05 11:24:39 +0200 dr r272674 : #i10000# compiler warning 2009-06-05 10:35:22 +0200 dr r272668 : #i10000# compiler warning 2009-06-04 16:53:32 +0200 dr r272646 : CWS-TOOLING: rebase CWS dr70 to trunk@272291 (milestone: DEV300:m49) 2009-06-04 14:50:45 +0200 dr r272633 : #i10000# compiler warning 2009-06-03 18:50:57 +0200 dr r272603 : #i101930# fix ODS export of uninit'ed notes, do not craete note captions in UpdatePendingRowHeights 2009-05-28 11:11:17 +0200 dr r272384 : #i101930# note captions must be created before changing row/column size 2009-05-27 15:48:44 +0200 iha r272356 : #i101925# metafile creation is requested superfluously during inplace editing 2009-05-27 15:46:44 +0200 iha r272355 : #i101925# metafile creation is requested superfluously during inplace editing 2009-05-27 15:06:58 +0200 iha r272349 : #i101928# superfluous paint calls while entering and editing charts 2009-05-27 15:01:08 +0200 iha r272348 : #i101928# superfluous paint calls while entering and editing charts 2009-05-26 14:43:39 +0200 dr r272303 : #i101930# import performance: invisible cell notes cache caption data 2009-05-22 18:44:19 +0200 dr r272205 : #i101930# preparations for uninitialized notes (performance), adapted ODF import filter 2009-05-14 19:50:43 +0200 dr r271918 : #i101930# 'recycle' the shapes already created while loading cell notes 2009-05-06 16:07:45 +0200 dr r271598 : #i100827# improve performance of HTML query filter, patch by mmeeks, slightly modified 2009-05-06 11:02:38 +0200 dr r271577 : #i100827# improve performance of HTML query filter, patch by mmeeks 2009-05-06 10:50:13 +0200 dr r271575 : #i86650# improve performance of HTML query filter 2009-05-05 10:09:44 +0200 nn r271502 : #i101428# better handling of non-existing view data 2009-04-29 16:42:57 +0200 nn r271384 : #i101428# after loading, update row heights per sheet on demand
2009-07-03 12:42:53 +00:00
pNote->ShowCaptionTemp( aNotePos, false );
2000-09-18 16:07:07 +00:00
// update author and date
pNote->AutoStamp();
2000-09-18 16:07:07 +00:00
/* If the entire text has been cleared, the cell note and its caption
object have to be removed. */
SdrTextObj* pTextObject = dynamic_cast< SdrTextObj* >( pObject );
bool bDeleteNote = !pTextObject || !pTextObject->HasText();
if( bDeleteNote )
2000-09-18 16:07:07 +00:00
{
if( pUndoMgr )
2000-09-18 16:07:07 +00:00
{
// collect the "remove object" drawing undo action created by DeleteNote()
pDrawLayer->BeginCalcUndo(false);
// rescue note data before deletion
ScNoteData aNoteData( pNote->GetNoteData() );
// delete note from document (removes caption, but does not delete it)
rDoc.ReleaseNote(aNotePos);
// create undo action for removed note
pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, aNotePos, aNoteData, false, pDrawLayer->GetCalcUndo() ) );
2000-09-18 16:07:07 +00:00
}
else
{
rDoc.ReleaseNote(aNotePos);
}
// ScDocument::DeleteNote has deleted the note that pNote points to
pNote = 0;
}
2000-09-18 16:07:07 +00:00
// finalize the undo list action
if( pUndoMgr )
{
pUndoMgr->LeaveListAction();
/* #i94039# Update the default name "Edit Note" of the undo action
if the note has been created before editing or is deleted due
to deleted text. If the note has been created *and* is deleted,
the last undo action can be removed completely. Note: The
function LeaveListAction() removes the last action by itself,
if it is empty (when result is SDRENDTEXTEDIT_UNCHANGED). */
if( bNewNote && bDeleteNote )
2000-09-18 16:07:07 +00:00
{
pUndoMgr->RemoveLastUndoAction();
}
else if( bNewNote || bDeleteNote )
{
SfxListUndoAction* pAction = dynamic_cast< SfxListUndoAction* >( pUndoMgr->GetUndoAction() );
OSL_ENSURE( pAction, "FuText::StopEditMode - list undo action expected" );
if( pAction )
pAction->SetComment( ScGlobal::GetRscString( bNewNote ? STR_UNDO_INSERTNOTE : STR_UNDO_DELETENOTE ) );
2000-09-18 16:07:07 +00:00
}
}
CWS-TOOLING: integrate CWS calcsheetdata 2009-08-13 16:18:48 +0200 nn r274950 : #i102616# shared/remote files, better handling of formula results 2009-08-12 11:17:30 +0200 nn r274884 : CWS-TOOLING: rebase CWS calcsheetdata to trunk@274622 (milestone: DEV300:m54) 2009-08-12 10:30:47 +0200 nn r274881 : #i102616# some clean-up 2009-08-11 19:01:18 +0200 nn r274876 : #i102616# store loaded namespaces, so prefixes remain valid 2009-08-11 19:00:49 +0200 nn r274875 : #i102616# store loaded namespaces, so prefixes remain valid 2009-08-10 19:12:04 +0200 nn r274835 : #i102616# detective, notes, encoding, error handling 2009-08-07 11:18:46 +0200 nn r274751 : #i102616# use new method SvXMLAutoStylePoolP::AddNamed 2009-08-07 11:18:15 +0200 nn r274750 : #i102616# new method SvXMLAutoStylePoolP::AddNamed 2009-08-06 18:02:42 +0200 nn r274740 : #i102616# modification: shapes, notes, pending row heights; skip sheets in export iterator 2009-08-05 18:41:59 +0200 nn r274694 : #i102616# handle text styles in notes 2009-08-03 18:55:59 +0200 nn r274594 : #i102616# handle text styles in cells 2009-07-31 19:00:06 +0200 nn r274548 : #i102616# handle styles for notes 2009-07-28 16:46:20 +0200 nn r274414 : missed a conflict 2009-07-28 14:01:56 +0200 nn r274404 : CWS-TOOLING: rebase CWS calcsheetdata to trunk@274203 (milestone: DEV300:m53) 2009-07-23 18:28:47 +0200 nn r274278 : #i102616# handle table styles 2009-07-22 15:40:24 +0200 nn r274244 : #i102616# handle row styles 2009-07-21 20:09:37 +0200 nn r274211 : #i102616# handle column styles 2009-07-16 13:00:18 +0200 nn r274043 : #i102616# invalidate all stream positions when inserting/deleting sheets 2009-07-15 17:41:15 +0200 nn r274021 : #i102616# don't collect cell styles twice for copied sheets 2009-07-14 18:36:11 +0200 nn r273985 : #i102616# allow to query stream position, clear buffer 2009-07-14 18:32:10 +0200 nn r273984 : #i102616# allow to specify a name for an autostyle 2009-07-09 22:01:23 +0200 nn r273870 : #i102616# copy stream for unchanged sheets 2009-07-08 18:11:42 +0200 nn r273844 : #i102616# store stream positions of sheets 2009-06-24 19:08:18 +0200 nn r273363 : #i102616# detect changed sheets since loading 2009-06-09 15:53:32 +0200 nn r272774 : #i102616# store automatic cell style information after loading
2009-09-07 15:38:19 +00:00
// invalidate stream positions only for the affected sheet
rDoc.LockStreamValid(false);
if (rDoc.IsStreamValid(aNotePos.Tab()))
rDoc.SetStreamValid(aNotePos.Tab(), false);
2000-09-18 16:07:07 +00:00
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */