diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 16:07:07 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 16:07:07 +0000 |
commit | 9ae5a91f7955e44d3b24a3f7741f9bca02ac7f24 (patch) | |
tree | 13c111a6380728f470fa177e679b80089a01efc4 /sc/source/ui/view |
initial import
Diffstat (limited to 'sc/source/ui/view')
79 files changed, 64124 insertions, 0 deletions
diff --git a/sc/source/ui/view/auditsh.cxx b/sc/source/ui/view/auditsh.cxx new file mode 100644 index 000000000000..cd330264e3b2 --- /dev/null +++ b/sc/source/ui/view/auditsh.cxx @@ -0,0 +1,242 @@ +/************************************************************************* + * + * $RCSfile: auditsh.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +#include "scitems.hxx" +#include <svx/srchitem.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/objface.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/request.hxx> + +#define GLOBALOVERFLOW +#include "segmentc.hxx" + +#include "auditsh.hxx" +#include "tabvwsh.hxx" +#include "scresid.hxx" +#include "sc.hrc" + +//------------------------------------------------------------------------ + +#define ScAuditingShell +#include "scslots.hxx" + +//------------------------------------------------------------------------ + +SEG_EOFGLOBALS() + +//------------------------------------------------------------------------ + +#pragma SEG_SEGCLASS(SFXMACROS_SEG,STARTWORK_CODE) + + +TYPEINIT1( ScAuditingShell, SfxShell ); + +SFX_IMPL_INTERFACE(ScAuditingShell, SfxShell, ScResId(SCSTR_AUDITSHELL)) +{ + SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_AUDIT) ); +} + + +//------------------------------------------------------------------------ +#pragma SEG_FUNCDEF(auditsh_01) + +ScAuditingShell::ScAuditingShell(ScViewData* pData) : + SfxShell(pData->GetViewShell()), + pViewData( pData ), + nFunction( SID_FILL_ADD_PRED ) +{ + SetPool( &pViewData->GetViewShell()->GetPool() ); + SetUndoManager( pViewData->GetSfxDocShell()->GetUndoManager() ); + SetHelpId( HID_SCSHELL_AUDIT ); + SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Auditing"))); +} + +//------------------------------------------------------------------------ +#pragma SEG_FUNCDEF(auditsh_02) + +ScAuditingShell::~ScAuditingShell() +{ +} + +//------------------------------------------------------------------------ +#pragma SEG_FUNCDEF(auditsh_03) + +void ScAuditingShell::Execute( SfxRequest& rReq ) +{ + SfxBindings& rBindings = SFX_BINDINGS(); + USHORT nSlot = rReq.GetSlot(); + switch ( nSlot ) + { + case SID_FILL_ADD_PRED: + case SID_FILL_DEL_PRED: + case SID_FILL_ADD_SUCC: + case SID_FILL_DEL_SUCC: + nFunction = nSlot; + rBindings.Invalidate( SID_FILL_ADD_PRED ); + rBindings.Invalidate( SID_FILL_DEL_PRED ); + rBindings.Invalidate( SID_FILL_ADD_SUCC ); + rBindings.Invalidate( SID_FILL_DEL_SUCC ); + break; + case SID_CANCEL: // Escape + case SID_FILL_NONE: + pViewData->GetViewShell()->SetAuditShell( FALSE ); + break; + + case SID_FILL_SELECT: + { + const SfxItemSet* pReqArgs = rReq.GetArgs(); + if ( pReqArgs ) + { + const SfxPoolItem* pXItem; + const SfxPoolItem* pYItem; + if ( pReqArgs->GetItemState( SID_RANGE_COL, TRUE, &pXItem ) == SFX_ITEM_SET + && pReqArgs->GetItemState( SID_RANGE_ROW, TRUE, &pYItem ) == SFX_ITEM_SET ) + { + DBG_ASSERT( pXItem->ISA(SfxInt16Item) && pYItem->ISA(SfxInt16Item), + "falsche Items" ); + short nCol = ((const SfxInt16Item*) pXItem)->GetValue(); + short nRow = ((const SfxInt16Item*) pYItem)->GetValue(); + ScViewFunc* pView = pViewData->GetView(); + pView->MoveCursorAbs( nCol, nRow, SC_FOLLOW_LINE, FALSE, FALSE ); + switch ( nFunction ) + { + case SID_FILL_ADD_PRED: + pView->DetectiveAddPred(); + break; + case SID_FILL_DEL_PRED: + pView->DetectiveDelPred(); + break; + case SID_FILL_ADD_SUCC: + pView->DetectiveAddSucc(); + break; + case SID_FILL_DEL_SUCC: + pView->DetectiveDelSucc(); + break; + } + } + } + } + break; + } +} + +//------------------------------------------------------------------------ +#pragma SEG_FUNCDEF(auditsh_04) + +void ScAuditingShell::GetState( SfxItemSet& rSet ) +{ + rSet.Put( SfxBoolItem( nFunction, TRUE ) ); // aktive Funktion markieren +} + +/*------------------------------------------------------------------------ + + $Log: not supported by cvs2svn $ + Revision 1.11 2000/09/17 14:09:30 willem.vandorp + OpenOffice header added. + + Revision 1.10 2000/08/31 16:38:44 willem.vandorp + Header and footer replaced + + Revision 1.9 2000/05/09 18:30:15 nn + use IMPL_INTERFACE macro without IDL + + Revision 1.8 2000/04/14 08:31:36 nn + unicode changes + + Revision 1.7 1999/06/02 19:40:56 ANK + #66547# SubShells + + + Rev 1.6 02 Jun 1999 21:40:56 ANK + #66547# SubShells + + Rev 1.5 24 Nov 1997 20:04:54 NN + includes + + Rev 1.4 04 Sep 1997 19:51:46 RG + change header + + Rev 1.3 05 Aug 1997 14:33:14 TJ + include svx/srchitem.hxx + + Rev 1.2 29 Oct 1996 13:35:32 NN + ueberall ScResId statt ResId + + Rev 1.1 09 Aug 1996 20:34:22 NN + Svx-Includes aus scitems.hxx raus + + Rev 1.0 29 May 1996 19:41:46 NN + Initial revision. + +------------------------------------------------------------------------*/ + +#pragma SEG_EOFMODULE + + diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx new file mode 100644 index 000000000000..d28b42385a3e --- /dev/null +++ b/sc/source/ui/view/cellsh.cxx @@ -0,0 +1,794 @@ +/************************************************************************* + * + * $RCSfile: cellsh.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +#include "scitems.hxx" + +#include <svtools/slstitm.hxx> +#include <svtools/stritem.hxx> +#include <svtools/whiter.hxx> +#include <offmgr/sbasltid.hrc> +#include <sot/formats.hxx> +#include <svx/hlnkitem.hxx> +#include <sfx2/app.hxx> +//#include <sfx2/objitem.hxx> +#include <svx/langitem.hxx> +#include <vcl/system.hxx> + +#include "cellsh.hxx" +#include "sc.hrc" +#include "docsh.hxx" +#include "attrib.hxx" +#include "scresid.hxx" +#include "tabvwsh.hxx" +#include "impex.hxx" +#include "cell.hxx" +#include "scmod.hxx" +#include "globstr.hrc" + +//------------------------------------------------------------------ + +#define ScCellShell +#define CellMovement +#include "scslots.hxx" + +#define SearchSettings +#include <svx/svxslots.hxx> + +TYPEINIT1( ScCellShell, ScFormatShell ); + +SFX_IMPL_INTERFACE(ScCellShell, ScFormatShell , ScResId(SCSTR_CELLSHELL) ) +{ + SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD | + SFX_VISIBILITY_SERVER, + ScResId(RID_OBJECTBAR_FORMAT)); + SFX_OBJECTMENU_REGISTRATION(SID_OBJECTMENU0, ScResId(RID_OBJECTMENU_CELLS)); + SFX_POPUPMENU_REGISTRATION(ScResId(RID_POPUP_CELLS)); +} + + +ScCellShell::ScCellShell(ScViewData* pData) : + ScFormatShell(pData) +{ + SetHelpId(HID_SCSHELL_CELLSH); + SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Cell"))); +} + +ScCellShell::~ScCellShell() +{ +} + +//------------------------------------------------------------------ + +//! move this function elsewhere +LanguageType lcl_GetEffLanguage( ScDocument* pDoc, const ScAddress& rPos ) +{ + const SfxPoolItem* pItem = pDoc->GetAttr( + rPos.Col(), rPos.Row(), rPos.Tab(), ATTR_FONT_LANGUAGE); + SvxLanguageItem* pLangIt = PTR_CAST( SvxLanguageItem, pItem ); + LanguageType eLnge; + if (pLangIt) + { + eLnge = (LanguageType) pLangIt->GetValue(); + if (eLnge == LANGUAGE_DONTKNOW) //! can this happen? + eLnge = pDoc->GetLanguage(); + } + else + eLnge = LANGUAGE_ENGLISH_US; + if ( eLnge == LANGUAGE_SYSTEM ) + eLnge = System::GetLanguage(); // never use SYSTEM for spelling + + return eLnge; +} + +//------------------------------------------------------------------ + +void ScCellShell::GetBlockState( SfxItemSet& rSet ) +{ + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + ScRange aMarkRange; + BOOL bSimpleArea = GetViewData()->GetSimpleArea( aMarkRange, TRUE ); //! macht TRUE aerger ? + BOOL bOnlyNotBecauseOfMatrix; + BOOL bEditable = pTabViewShell->SelectionEditable( &bOnlyNotBecauseOfMatrix ); + ScDocument* pDoc = GetViewData()->GetDocument(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + USHORT nCol1, nCol2, nRow1, nRow2; + nCol1 = aMarkRange.aStart.Col(); + nRow1 = aMarkRange.aStart.Row(); + nCol2 = aMarkRange.aEnd.Col(); + nRow2 = aMarkRange.aEnd.Row(); + + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + while ( nWhich ) + { + BOOL bDisable = FALSE; + BOOL bNeedEdit = TRUE; // muss Selektion editierbar sein? + switch ( nWhich ) + { + case FID_FILL_TO_BOTTOM: // Fuellen oben/unten + case FID_FILL_TO_TOP: // mind. 2 Zeilen markiert? + bDisable = (!bSimpleArea) || (nRow1 == nRow2); + if ( !bDisable && bEditable ) + { // Matrix nicht zerreissen + if ( nWhich == FID_FILL_TO_BOTTOM ) + bDisable = pDoc->HasSelectedBlockMatrixFragment( + nCol1, nRow1, nCol2, nRow1, rMark ); // erste Zeile + else + bDisable = pDoc->HasSelectedBlockMatrixFragment( + nCol1, nRow2, nCol2, nRow2, rMark ); // letzte Zeile + } + break; + + case FID_FILL_TO_RIGHT: // Fuellen links/rechts + case FID_FILL_TO_LEFT: // mind. 2 Spalten markiert? + bDisable = (!bSimpleArea) || (nCol1 == nCol2); + if ( !bDisable && bEditable ) + { // Matrix nicht zerreissen + if ( nWhich == FID_FILL_TO_RIGHT ) + bDisable = pDoc->HasSelectedBlockMatrixFragment( + nCol1, nRow1, nCol1, nRow2, rMark ); // erste Spalte + else + bDisable = pDoc->HasSelectedBlockMatrixFragment( + nCol2, nRow1, nCol2, nRow2, rMark ); // letzte Spalte + } + break; + + case FID_FILL_SERIES: // Block fuellen + case SID_OPENDLG_TABOP: // Mehrfachoperationen, mind. 2 Zellen markiert? + if (pDoc->GetChangeTrack()!=NULL &&nWhich ==SID_OPENDLG_TABOP) + bDisable = TRUE; + else + bDisable = (!bSimpleArea) || (nCol1 == nCol2 && nRow1 == nRow2); + + if ( !bDisable && bEditable && nWhich == FID_FILL_SERIES ) + { // Matrix nicht zerreissen + bDisable = pDoc->HasSelectedBlockMatrixFragment( + nCol1, nRow1, nCol2, nRow1, rMark ) // erste Zeile + || pDoc->HasSelectedBlockMatrixFragment( + nCol1, nRow2, nCol2, nRow2, rMark ) // letzte Zeile + || pDoc->HasSelectedBlockMatrixFragment( + nCol1, nRow1, nCol1, nRow2, rMark ) // erste Spalte + || pDoc->HasSelectedBlockMatrixFragment( + nCol2, nRow1, nCol2, nRow2, rMark ); // letzte Spalte + } + break; + + case SID_CUT: // Ausschneiden, + case FID_INS_ROW: // Zeilen einfuegen + case FID_INS_COLUMN: // Spalten einfuegen + case FID_INS_CELL: // Zellen einfuegen, nur einf. Selektion + case FID_INS_CELLSDOWN: + case FID_INS_CELLSRIGHT: + bDisable = (!bSimpleArea); + break; + + case SID_COPY: // Kopieren + bDisable = (!bSimpleArea); + // nur wegen Matrix nicht editierbar? Matrix nicht zerreissen + //! schlaegt nicht zu, wenn geschuetzt UND Matrix, aber damit + //! muss man leben.. wird in Copy-Routine abgefangen, sonst + //! muesste hier nochmal Aufwand getrieben werden + if ( !(!bEditable && bOnlyNotBecauseOfMatrix) ) + bNeedEdit = FALSE; // erlaubt, wenn geschuetzt/ReadOnly + break; + + case SID_AUTOFORMAT: // Autoformat, mind. 3x3 selektiert + bDisable = (!bSimpleArea) + || ((nCol2 - nCol1) < 2) || ((nRow2 - nRow1) < 2); + break; + + case SID_OPENDLG_CONDFRMT : + case FID_CONDITIONAL_FORMAT : + case SID_CELL_FORMAT_RESET : + case FID_CELL_FORMAT : + // nur wegen Matrix nicht editierbar? Attribute trotzdem ok + if ( !bEditable && bOnlyNotBecauseOfMatrix ) + bNeedEdit = FALSE; + break; + } + if (!bDisable && bNeedEdit && !bEditable) + bDisable = TRUE; + + if (bDisable) + rSet.DisableItem(nWhich); + nWhich = aIter.NextWhich(); + } +} + +// Funktionen, die je nach Cursorposition disabled sind +// Default: +// SID_INSERT_POSTIT, SID_CHARMAP, SID_OPENDLG_FUNCTION + +void ScCellShell::GetCellState( SfxItemSet& rSet ) +{ + ScDocument* pDoc = GetViewData()->GetDocShell()->GetDocument(); + ScAddress aCursor( GetViewData()->GetCurX(), GetViewData()->GetCurY(), + GetViewData()->GetTabNo() ); + + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + while ( nWhich ) + { + BOOL bDisable = FALSE; + BOOL bNeedEdit = TRUE; // muss Cursorposition editierbar sein? + switch ( nWhich ) + { + case SID_THESAURUS: + { + CellType eType = pDoc->GetCellType( aCursor ); + bDisable = ( eType != CELLTYPE_STRING && eType != CELLTYPE_EDIT); + if (!bDisable) + { + // test for available languages + USHORT nLang = lcl_GetEffLanguage( pDoc, aCursor ); + bDisable = !ScModule::HasThesaurusLanguage( nLang ); + } + } + break; + case SID_OPENDLG_FUNCTION: + { + ScMarkData aMarkData=GetViewData()->GetMarkData(); + ScRange aRange; + aMarkData.GetMarkArea(aRange); + if(aMarkData.IsMarked()) + { + if (!pDoc->IsBlockEditable( aCursor.Tab(), aRange.aStart.Col(),aRange.aStart.Row(), + aRange.aEnd.Col(),aRange.aEnd.Row() )) + { + bDisable = TRUE; + } + bNeedEdit=FALSE; + } + + } + break; + } + if (!bDisable && bNeedEdit) + if (!pDoc->IsBlockEditable( aCursor.Tab(), aCursor.Col(),aCursor.Row(), + aCursor.Col(),aCursor.Row() )) + bDisable = TRUE; + if (bDisable) + rSet.DisableItem(nWhich); + nWhich = aIter.NextWhich(); + } +} + +// Einfuegen, Inhalte einfuegen + +void __EXPORT ScCellShell::GetClipState( SfxItemSet& rSet ) +{ + BOOL bDisable = TRUE; + +// SID_PASTE +// FID_PASTE_CONTENTS + + if ( ScGlobal::IsClipCaptured() || ScGlobal::IsClipDraw() ) + bDisable = FALSE; + else + { + SvDataObjectRef pClipObj = SvDataObject::PasteClipboard(); + if (pClipObj.Is()) + { + const SvDataTypeList& rTypeLst = pClipObj->GetTypeList(); + + if( rTypeLst.Get( FORMAT_BITMAP ) || + rTypeLst.Get( FORMAT_GDIMETAFILE ) || + rTypeLst.Get( SOT_FORMATSTR_ID_SVXB ) || + rTypeLst.Get( FORMAT_PRIVATE ) || + rTypeLst.Get( FORMAT_RTF ) || + rTypeLst.Get( SOT_FORMATSTR_ID_EMBED_SOURCE ) || + rTypeLst.Get( SOT_FORMATSTR_ID_LINK_SOURCE ) || + rTypeLst.Get( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ) || + rTypeLst.Get( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ) || + ScImportExport::IsFormatSupported( pClipObj ) ) + bDisable = FALSE; + } + } + + // Zellschutz / Multiselektion + + if (!bDisable) + { + USHORT nCol = GetViewData()->GetCurX(); + USHORT nRow = GetViewData()->GetCurY(); + USHORT nTab = GetViewData()->GetTabNo(); + ScDocument* pDoc = GetViewData()->GetDocShell()->GetDocument(); + if (!pDoc->IsBlockEditable( nTab, nCol,nRow, nCol,nRow )) + bDisable = TRUE; + ScMarkData& rMark = GetViewData()->GetMarkData(); + if (rMark.IsMultiMarked()) + bDisable = TRUE; + } + + if (bDisable) + { + rSet.DisableItem( SID_PASTE ); + rSet.DisableItem( FID_PASTE_CONTENTS ); + } +} + +// only SID_HYPERLINK_GETLINK: + +void ScCellShell::GetHLinkState( SfxItemSet& rSet ) +{ + // always return an item (or inserting will be disabled) + // if the cell at the cursor contains only a link, return that link + + SvxHyperlinkItem aHLinkItem; + if ( !GetViewData()->GetView()->HasBookmarkAtCursor( &aHLinkItem ) ) + { + //! put selected text into item? + } + + rSet.Put(aHLinkItem); +} + +void ScCellShell::GetState(SfxItemSet &rSet) +{ + // removed: SID_BORDER_OBJECT (old Basic) + + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + BOOL bOle = pTabViewShell->GetViewFrame()->ISA(SfxInPlaceFrame); + BOOL bTabProt = GetViewData()->GetDocument()->IsTabProtected(GetViewData()->GetTabNo()); + SfxApplication* pSfxApp = SFX_APP(); + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScViewData* pViewData = GetViewData(); + ScDocument* pDoc = pViewData->GetDocument(); + ScMarkData& rMark = pViewData->GetMarkData(); + USHORT nPosX = pViewData->GetCurX(); + USHORT nPosY = pViewData->GetCurY(); + USHORT nTab = pViewData->GetTabNo(); + USHORT nMyId = 0; + + USHORT nTabCount = pDoc->GetTableCount(); + USHORT nTabSelCount = rMark.GetSelectCount(); + + + + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + while ( nWhich ) + { + switch ( nWhich ) + { + case SID_OPENDLG_CHART: + if ( bOle || bTabProt || !pSfxApp->HasFeature(SFX_FEATURE_SCHART) ) + rSet.DisableItem( nWhich ); + break; + + case SID_DETECTIVE_REFRESH: + if (!pDoc->HasDetectiveOperations()) + rSet.DisableItem( nWhich ); + break; + + case SID_RANGE_ADDRESS: + { + ScRange aRange; + if ( pViewData->GetSimpleArea( aRange, TRUE ) ) + { + String aStr; + USHORT nFlags = SCA_VALID | SCA_TAB_3D; + aRange.Format(aStr,nFlags,pDoc); + rSet.Put( SfxStringItem( nWhich, aStr ) ); + } + } + break; + + case SID_RANGE_NOTETEXT: + { + USHORT nNoteCol, nNoteRow, nNoteTab; + + // #43343# immer Cursorposition +#if 0 + ScRange aRange; + if (GetViewData()->GetSimpleArea(aRange,TRUE)) + { + nNoteCol = aRange.aStart.Col(); + nNoteRow = aRange.aStart.Row(); + nNoteTab = aRange.aStart.Tab(); + } + else // Cursor bei Mehrfachselektion +#endif + { + nNoteCol = nPosX; + nNoteRow = nPosY; + nNoteTab = nTab; + } + + String aNoteText; + ScPostIt aNote; + if ( pDoc->GetNote( nNoteCol, nNoteRow, nNoteTab, aNote ) ) + aNoteText = aNote.GetText(); + + rSet.Put( SfxStringItem( nWhich, aNoteText ) ); + } + break; + + case SID_RANGE_ROW: + rSet.Put( SfxUInt16Item( nWhich, nPosY+1 ) ); + break; + + case SID_RANGE_COL: + rSet.Put( SfxUInt16Item( nWhich, nPosX+1 ) ); + break; + + case SID_RANGE_TABLE: + rSet.Put( SfxUInt16Item( nWhich, nTab+1 ) ); + break; + + case SID_RANGE_VALUE: + { + double nValue; + pDoc->GetValue( nPosX, nPosY, nTab, nValue ); + rSet.Put( ScDoubleItem( nWhich, nValue ) ); + } + break; + + case SID_RANGE_FORMULA: + { + String aString; + pDoc->GetFormula( nPosX, nPosY, nTab, aString ); + if( aString.Len() == 0 ) + { + pDoc->GetInputString( nPosX, nPosY, nTab, aString ); + } + rSet.Put( SfxStringItem( nWhich, aString ) ); + } + break; + + case SID_RANGE_TEXTVALUE: + { + String aString; + pDoc->GetString( nPosX, nPosY, nTab, aString ); + rSet.Put( SfxStringItem( nWhich, aString ) ); + } + break; + + case SID_STATUS_SELMODE: + { + /* 0: STD Click hebt Sel auf + * 1: ER Click erweitert Selektion + * 2: ERG Click definiert weitere Selektion + */ + USHORT nMode = pTabViewShell->GetLockedModifiers(); + + switch ( nMode ) + { + case KEY_SHIFT: nMode = 1; break; + case KEY_MOD1: nMode = 2; break; // Control-Taste + case 0: + default: + nMode = 0; + } + + rSet.Put( SfxUInt16Item( nWhich, nMode ) ); + } + break; + + case SID_STATUS_DOCPOS: + { + String aStr( ScGlobal::GetRscString( STR_TABLE ) ); + + aStr += ' '; + aStr += String::CreateFromInt32( nTab + 1 ); + aStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " / " )); + aStr += String::CreateFromInt32( nTabCount ); + rSet.Put( SfxStringItem( nWhich, aStr ) ); + } + break; + + // Summe etc. mit Datum/Zeit/Fehler/Pos&Groesse zusammengefasst + + case SID_TABLE_CELL: + case SID_ATTR_POSITION: + case SID_ATTR_SIZE: + { + // Testen, ob Fehler unter Cursor + // (nicht pDoc->GetErrCode, um keine zirkulaeren Referenzen auszuloesen) + + // In interpreter may happen via rescheduled Basic + if ( pDoc->IsInInterpreter() ) + rSet.Put( SfxStringItem( nWhich, + String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("...")) ) ); + else + { + USHORT nErrCode = 0; + ScBaseCell* pCell; + pDoc->GetCell( nPosX, nPosY, nTab, pCell ); + if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA ) + { + ScFormulaCell* pFCell = (ScFormulaCell*) pCell; + if (!pFCell->IsRunning()) + nErrCode = pFCell->GetErrCode(); + } + + if ( nErrCode > 0 ) + rSet.Put( SfxStringItem( nWhich, + ScGlobal::GetLongErrorString( nErrCode ) ) ); + else + { + String aFuncStr; + if ( pTabViewShell->GetFunction( aFuncStr ) ) + rSet.Put( SfxStringItem( nWhich, aFuncStr ) ); + } + } + } + break; + + case SID_DATA_SELECT: + // ab 506f wird die ganze Spalte angesehen + if ( !pDoc->HasStringCells(ScRange(nPosX,0,nTab, nPosX,MAXROW,nTab)) ) + rSet.DisableItem( nWhich ); + break; + + case SID_STATUS_SUM: + { + String aFuncStr; + if ( pTabViewShell->GetFunction( aFuncStr ) ) + rSet.Put( SfxStringItem( nWhich, aFuncStr ) ); + } + break; + + case FID_MERGE_ON: + if ( pDoc->GetChangeTrack() || !pTabViewShell->TestMergeCells() ) + rSet.DisableItem( nWhich ); + break; + + case FID_MERGE_OFF: + if ( pDoc->GetChangeTrack() || !pTabViewShell->TestRemoveMerge() ) + rSet.DisableItem( nWhich ); + break; + + case FID_INS_ROWBRK: + if ( nPosY==0 || (pDoc->GetRowFlags(nPosY,nTab) & CR_MANUALBREAK) ) + rSet.DisableItem( nWhich ); + break; + + case FID_INS_COLBRK: + if ( nPosX==0 || (pDoc->GetColFlags(nPosX,nTab) & CR_MANUALBREAK) ) + rSet.DisableItem( nWhich ); + break; + + case FID_DEL_ROWBRK: + if ( nPosY==0 || (pDoc->GetRowFlags(nPosY,nTab) & CR_MANUALBREAK)==0 ) + rSet.DisableItem( nWhich ); + break; + + case FID_DEL_COLBRK: + if ( nPosX==0 || (pDoc->GetColFlags(nPosX,nTab) & CR_MANUALBREAK)==0 ) + rSet.DisableItem( nWhich ); + break; + + case FID_FILL_TAB: + if ( nTabSelCount < 2 ) + rSet.DisableItem( nWhich ); + break; + + case SID_SELECT_SCENARIO: + { + ScDocument* pDoc = GetViewData()->GetDocument(); + USHORT nTab = GetViewData()->GetTabNo(); + List aList; + + Color aDummyCol; + USHORT nDummyFlags; + + if ( !pDoc->IsScenario(nTab) ) + { + String aStr; + USHORT nScTab = nTab + 1; + + while ( pDoc->IsScenario(nScTab) ) + { + pDoc->GetName( nScTab, aStr ); + aList.Insert( new String( aStr ), LIST_APPEND ); + pDoc->GetScenarioData( nScTab, aStr, aDummyCol, nDummyFlags ); + aList.Insert( new String( aStr ), LIST_APPEND ); + ++nScTab; + } + } + else + { + String aComment; + pDoc->GetScenarioData( nTab, aComment, aDummyCol, nDummyFlags ); + DBG_ASSERT( aList.Count() == 0, "List not empty!" ); + aList.Insert( new String( aComment ) ); + } + + rSet.Put( SfxStringListItem( nWhich, &aList ) ); + + ULONG nCount = aList.Count(); + for ( ULONG i=0; i<nCount; i++ ) + delete (String*) aList.GetObject(i); + } + break; + + case FID_ROW_HIDE: + case FID_ROW_SHOW: + case FID_COL_HIDE: + case FID_COL_SHOW: + case FID_COL_OPT_WIDTH: + case FID_ROW_OPT_HEIGHT: + case SID_DEL_ROWS: + case SID_DEL_COLS: + case FID_DELETE_CELL: + if ( pDoc->IsTabProtected(nTab) || pDocSh->IsReadOnly()) + rSet.DisableItem( nWhich ); + break; + +/* Zellschutz bei selektierten Zellen wird bei anderen Funktionen auch nicht abgefragt... + case SID_DELETE: + { + if ( pDoc->IsTabProtected(nTab) ) + { + const SfxItemSet& rAttrSet = GetSelectionPattern()->GetItemSet(); + const ScProtectionAttr& rProtAttr = (const ScProtectionAttr&)rAttrSet.Get( ATTR_PROTECTION, TRUE ); + if ( rProtAttr.GetProtection() ) + rSet.DisableItem( nWhich ); + } + } + break; +*/ + case SID_OUTLINE_MAKE: + { + ScMarkData& rMark = GetViewData()->GetMarkData(); + + if (pDoc->GetChangeTrack()!=NULL || rMark.IsMultiMarked()) + { + rSet.DisableItem( nWhich ); + } + } + break; + case SID_OUTLINE_SHOW: + if (!pTabViewShell->OutlinePossible(FALSE)) + rSet.DisableItem( nWhich ); + break; + + case SID_OUTLINE_HIDE: + if (!pTabViewShell->OutlinePossible(TRUE)) + rSet.DisableItem( nWhich ); + break; + + case SID_OUTLINE_REMOVE: + { + BOOL bCol, bRow; + pTabViewShell->TestRemoveOutline( bCol, bRow ); + if ( !bCol && !bRow ) + rSet.DisableItem( nWhich ); + } + break; + + case FID_COL_WIDTH: + { + //GetViewData()->GetCurX(); + SfxUInt16Item aWidthItem( FID_COL_WIDTH, pDoc->GetColWidth( nPosX , nTab) ); + rSet.Put( aWidthItem ); + if ( pDocSh->IsReadOnly()) + rSet.DisableItem( nWhich ); + + //XXX Disablen wenn nicht eindeutig + } + break; + + case FID_ROW_HEIGHT: + { + //GetViewData()->GetCurY(); + SfxUInt16Item aHeightItem( FID_ROW_HEIGHT, pDoc->GetRowHeight( nPosY , nTab) ); + rSet.Put( aHeightItem ); + //XXX Disablen wenn nicht eindeutig + if ( pDocSh->IsReadOnly()) + rSet.DisableItem( nWhich ); + } + break; + + case SID_DETECTIVE_FILLMODE: + rSet.Put(SfxBoolItem( nWhich, pTabViewShell->IsAuditShell() )); + break; + + case FID_INPUTLINE_STATUS: + DBG_ERROR( "Old update method. Use ScTabViewShell::UpdateInputHandler()." ); + break; + + case SID_SCENARIOS: // Szenarios: + if (!(rMark.IsMarked() || rMark.IsMultiMarked())) // nur, wenn etwas selektiert + rSet.DisableItem( nWhich ); + break; + + case FID_NOTE_VISIBLE: + { + ScPostIt aNote; + if ( pDoc->IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) && + pDoc->GetNote( nPosX, nPosY, nTab, aNote ) ) + { + BOOL bShown = aNote.IsShown() && + pDoc->HasNoteObject( nPosX, nPosY, nTab ); + rSet.Put( SfxBoolItem( nWhich, bShown ) ); + } + else + rSet.DisableItem( nWhich ); + } + break; + + case SID_OPENDLG_CONSOLIDATE: + case SCITEM_CONSOLIDATEDATA: + { + if(pDoc->GetChangeTrack()!=NULL) + rSet.DisableItem( nWhich); + } + break; + + } // switch ( nWitch ) + nWhich = aIter.NextWhich(); + } // while ( nWitch ) +} + +//------------------------------------------------------------------ + + + diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx new file mode 100644 index 000000000000..d9510d0fce88 --- /dev/null +++ b/sc/source/ui/view/cellsh1.cxx @@ -0,0 +1,1790 @@ +/************************************************************************* + * + * $RCSfile: cellsh1.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +//svdraw.hxx +#define _SDR_NOITEMS +#define _SDR_NOTOUCH +#define _SDR_NOTRANSFORM +#define _SI_NOSBXCONTROLS +#define _VCONT_HXX +#define _SI_NOOTHERFORMS +#define _VCTRLS_HXX +#define _SI_NOCONTROL +#define _SETBRW_HXX +#define _VCBRW_HXX +#define _SI_NOSBXCONTROLS + +//------------------------------------------------------------------ + +#include "scitems.hxx" +#include <sfx2/viewfrm.hxx> + +#define _ZFORLIST_DECLARE_TABLE +#include <svtools/stritem.hxx> +#include <svtools/whiter.hxx> +#include <svtools/zforlist.hxx> +#include <svtools/zformat.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/request.hxx> +#include <vcl/msgbox.hxx> +#include <so3/pastedlg.hxx> +#include <sot/formats.hxx> +#include <vcl/clip.hxx> +#include <svx/postattr.hxx> +#include <svx/fontitem.hxx> +#include <svx/charmap.hxx> +#include <sfx2/passwd.hxx> +#include <svx/hlnkitem.hxx> +#include <svtools/sbxcore.hxx> +#include <vcl/waitobj.hxx> + +#include "cellsh.hxx" +#include "sc.hrc" +#include "document.hxx" +#include "patattr.hxx" +#include "scmod.hxx" +#include "scresid.hxx" +#include "tabvwsh.hxx" +#include "inscldlg.hxx" +#include "inscodlg.hxx" +#include "delcldlg.hxx" +#include "delcodlg.hxx" +#include "filldlg.hxx" +#include "groupdlg.hxx" +#include "impex.hxx" +#include "reffind.hxx" +#include "namecrea.hxx" +#include "uiitems.hxx" +#include "reffact.hxx" +#include "namepast.hxx" +#include "inputhdl.hxx" + +#include "globstr.hrc" + + +#define IS_AVAILABLE(WhichId,ppItem) \ + (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET) + +//------------------------------------------------------------------ +void ScCellShell::ExecuteEdit( SfxRequest& rReq ) +{ + ScModule* pScMod = SC_MOD(); + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings(); + const SfxItemSet* pReqArgs = rReq.GetArgs(); + USHORT nSlot = rReq.GetSlot(); + + pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox + + // Eingabe beenden + if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) ) + { + switch ( nSlot ) + { + case FID_DEFINE_NAME: + case FID_USE_NAME: + case FID_INSERT_NAME: + case SID_SPELLING: + + pScMod->InputEnterHandler(); + pTabViewShell->UpdateInputHandler(); + break; + + default: + break; + } + } + + switch ( nSlot ) + { + // + // Einfuegen / Loeschen von Zellen / Zeilen / Spalten + // + + case FID_INS_ROW: + pTabViewShell->InsertCells(INS_INSROWS); + rReq.Done(); + break; + + case FID_INS_COLUMN: + pTabViewShell->InsertCells(INS_INSCOLS); + rReq.Done(); + break; + + case FID_INS_CELLSDOWN: + pTabViewShell->InsertCells(INS_CELLSDOWN); + rReq.Done(); + break; + + case FID_INS_CELLSRIGHT: + pTabViewShell->InsertCells(INS_CELLSRIGHT); + rReq.Done(); + break; + + case SID_DEL_ROWS: + pTabViewShell->DeleteCells( DEL_DELROWS ); + rReq.Done(); + break; + + case SID_DEL_COLS: + pTabViewShell->DeleteCells( DEL_DELCOLS ); + rReq.Done(); + break; + + case FID_INS_CELL: + { + InsCellCmd eCmd=INS_NONE; + + if ( pReqArgs ) + { + const SfxPoolItem* pItem; + String aFlags; + + if( IS_AVAILABLE( FID_INS_CELL, &pItem ) ) + aFlags = ((const SfxStringItem*)pItem)->GetValue(); + if( aFlags.Len() ) + { + switch( aFlags.GetChar(0) ) + { + case 'V': eCmd = INS_CELLSDOWN ;break; + case '>': eCmd = INS_CELLSRIGHT ;break; + case 'R': eCmd = INS_INSROWS ;break; + case 'C': eCmd = INS_INSCOLS ;break; + } + } + } + else + { + if ( GetViewData()->SimpleColMarked() ) + eCmd = INS_INSCOLS; + else if ( GetViewData()->SimpleRowMarked() ) + eCmd = INS_INSROWS; + else + { + ScDocument* pDoc = GetViewData()->GetDocument(); + BOOL bTheFlag=(pDoc->GetChangeTrack()!=NULL); + + ScInsertCellDlg* pDlg = new ScInsertCellDlg( pTabViewShell->GetDialogParent(), + bTheFlag); + if (pDlg->Execute() == RET_OK) + eCmd = pDlg->GetInsCellCmd(); + delete pDlg; + } + } + + if (eCmd!=INS_NONE) + { + pTabViewShell->InsertCells( eCmd ); + + if( ! rReq.IsAPI() ) + { + String aParam; + + switch( eCmd ) + { + case INS_CELLSDOWN: aParam='V'; break; + case INS_CELLSRIGHT: aParam='>'; break; + case INS_INSROWS: aParam='R'; break; + case INS_INSCOLS: aParam='C'; break; + } + rReq.AppendItem( SfxStringItem( FID_INS_CELL, aParam ) ); + rReq.Done(); + } + } + } + break; + + case FID_DELETE_CELL: + { + DelCellCmd eCmd = DEL_NONE; + + if ( pReqArgs ) + { + const SfxPoolItem* pItem; + String aFlags; + + if( IS_AVAILABLE( FID_DELETE_CELL, &pItem ) ) + aFlags = ((const SfxStringItem*)pItem)->GetValue(); + if( aFlags.Len() ) + { + switch( aFlags.GetChar(0) ) + { + case 'U': eCmd = DEL_CELLSUP ;break; + case 'L': eCmd = DEL_CELLSLEFT ;break; + case 'R': eCmd = DEL_DELROWS ;break; + case 'C': eCmd = DEL_DELCOLS ;break; + } + } + } + else + { + if ( GetViewData()->SimpleColMarked() ) + eCmd = DEL_DELCOLS; + else if ( GetViewData()->SimpleRowMarked() ) + eCmd = DEL_DELROWS; + else + { + ScDocument* pDoc = GetViewData()->GetDocument(); + BOOL bTheFlag=GetViewData()->GetMarkData().IsMultiMarked() || + (pDoc->GetChangeTrack()!=NULL); + + ScDeleteCellDlg* pDlg = new ScDeleteCellDlg( + pTabViewShell->GetDialogParent(),bTheFlag); + + if (pDlg->Execute() == RET_OK) + eCmd = pDlg->GetDelCellCmd(); + delete pDlg; + } + } + + if (eCmd != DEL_NONE ) + { + pTabViewShell->DeleteCells( eCmd ); + + if( ! rReq.IsAPI() ) + { + String aParam; + + switch( eCmd ) + { + case DEL_CELLSUP: aParam='U'; break; + case DEL_CELLSLEFT: aParam='L'; break; + case DEL_DELROWS: aParam='R'; break; + case DEL_DELCOLS: aParam='C'; break; + } + rReq.AppendItem( SfxStringItem( FID_DELETE_CELL, aParam ) ); + rReq.Done(); + } + } + } + break; + + // + // Inhalte von Zellen loeschen + // + + case SID_DELETE_CONTENTS: + pTabViewShell->DeleteContents( IDF_CONTENTS ); + rReq.Done(); + break; + + case SID_DELETE: + { + USHORT nFlags = IDF_NONE; + + if ( pReqArgs!=NULL && pTabViewShell->SelectionEditable() ) + { + const SfxPoolItem* pItem; + String aFlags = 'A'; + + if( IS_AVAILABLE( SID_DELETE, &pItem ) ) + aFlags = ((const SfxStringItem*)pItem)->GetValue(); + + aFlags.ToUpperAscii(); + BOOL bCont = TRUE; + + for( xub_StrLen i=0 ; bCont && i<aFlags.Len() ; i++ ) + { + switch( aFlags.GetChar(i) ) + { + case 'A': // Alle + nFlags |= IDF_ALL; + bCont = FALSE; // nicht mehr weitermachen! + break; + case 'S': nFlags |= IDF_STRING; break; + case 'V': nFlags |= IDF_VALUE; break; + case 'D': nFlags |= IDF_DATETIME; break; + case 'F': nFlags |= IDF_FORMULA; break; + case 'N': nFlags |= IDF_NOTE; break; + case 'T': nFlags |= IDF_ATTRIB; break; + case 'O': nFlags |= IDF_OBJECTS; break; + } + } + } + else + { + if (pTabViewShell->SelectionEditable()) + { + ScDeleteContentsDlg* pDlg = new ScDeleteContentsDlg( pTabViewShell->GetDialogParent() ); + ScDocument* pDoc = GetViewData()->GetDocument(); + USHORT nTab = GetViewData()->GetTabNo(); + if ( pDoc->IsTabProtected(nTab) ) + pDlg->DisableObjects(); + if (pDlg->Execute() == RET_OK) + { + nFlags = pDlg->GetDelContentsCmdBits(); + } + delete pDlg; + } + else + pTabViewShell->ErrorMessage(STR_PROTECTIONERR); + } + + if( nFlags != IDF_NONE ) + { + pTabViewShell->DeleteContents( nFlags ); + + if( ! rReq.IsAPI() ) + { + String aFlags; + + if( nFlags == IDF_ALL ) + { + aFlags += 'A'; + } + else + { + if( nFlags & IDF_STRING ) aFlags += 'S'; + if( nFlags & IDF_VALUE ) aFlags += 'V'; + if( nFlags & IDF_DATETIME ) aFlags += 'D'; + if( nFlags & IDF_FORMULA ) aFlags += 'F'; + if( nFlags & IDF_NOTE ) aFlags += 'N'; + if( nFlags & IDF_ATTRIB ) aFlags += 'T'; + if( nFlags & IDF_OBJECTS ) aFlags += 'O'; + } + + rReq.AppendItem( SfxStringItem( SID_DELETE, aFlags ) ); + rReq.Done(); + } + } + } + break; + + // + // Ausfuellen... + // + + case FID_FILL_TO_BOTTOM: + pTabViewShell->FillSimple( FILL_TO_BOTTOM ); + rReq.Done(); + break; + + case FID_FILL_TO_RIGHT: + pTabViewShell->FillSimple( FILL_TO_RIGHT ); + rReq.Done(); + break; + + case FID_FILL_TO_TOP: + pTabViewShell->FillSimple( FILL_TO_TOP ); + rReq.Done(); + break; + + case FID_FILL_TO_LEFT: + pTabViewShell->FillSimple( FILL_TO_LEFT ); + rReq.Done(); + break; + + case FID_FILL_TAB: + { + USHORT nFlags = IDF_NONE; + USHORT nFunction = PASTE_NOFUNC; + BOOL bSkipEmpty = FALSE; + BOOL bAsLink = FALSE; + + if ( pReqArgs!=NULL && pTabViewShell->SelectionEditable() ) + { + const SfxPoolItem* pItem; + String aFlags = 'A'; + + if( IS_AVAILABLE( FID_FILL_TAB, &pItem ) ) + aFlags = ((const SfxStringItem*)pItem)->GetValue(); + + aFlags.ToUpperAscii(); + BOOL bCont = TRUE; + + for( xub_StrLen i=0 ; bCont && i<aFlags.Len() ; i++ ) + { + switch( aFlags.GetChar(i) ) + { + case 'A': // Alle + nFlags |= IDF_ALL; + bCont = FALSE; // nicht mehr weitermachen! + break; + case 'S': nFlags |= IDF_STRING; break; + case 'V': nFlags |= IDF_VALUE; break; + case 'D': nFlags |= IDF_DATETIME; break; + case 'F': nFlags |= IDF_FORMULA; break; + case 'N': nFlags |= IDF_NOTE; break; + case 'T': nFlags |= IDF_ATTRIB; break; + } + } + } + else + { + ScInsertContentsDlg* pDlg = + new ScInsertContentsDlg(pTabViewShell->GetDialogParent(), + 0, /* nCheckDefaults */ + &ScGlobal::GetRscString(STR_FILL_TAB) ); + pDlg->SetFillMode(TRUE); + + if (pDlg->Execute() == RET_OK) + { + nFlags = pDlg->GetInsContentsCmdBits(); + nFunction = pDlg->GetFormulaCmdBits(); + bSkipEmpty = pDlg->IsSkipEmptyCells(); + bAsLink = pDlg->IsLink(); + // MoveMode gibt's bei Tabelle fuellen nicht + } + delete pDlg; + } + + if( nFlags != IDF_NONE ) + { + pTabViewShell->FillTab( nFlags, nFunction, bSkipEmpty, bAsLink ); + + if( ! rReq.IsAPI() ) + { + String aFlags; + + if( nFlags == IDF_ALL ) + { + aFlags += 'A'; + } + else + { + if( nFlags & IDF_STRING ) aFlags += 'S'; + if( nFlags & IDF_VALUE ) aFlags += 'V'; + if( nFlags & IDF_DATETIME ) aFlags += 'D'; + if( nFlags & IDF_FORMULA ) aFlags += 'F'; + if( nFlags & IDF_NOTE ) aFlags += 'N'; + if( nFlags & IDF_ATTRIB ) aFlags += 'T'; + } + + rReq.AppendItem( SfxStringItem( FID_FILL_TAB, aFlags ) ); + rReq.Done(); + } + } + } + break; + + case FID_FILL_SERIES: + { + USHORT nStartCol; + USHORT nStartRow; + USHORT nStartTab; + USHORT nEndCol; + USHORT nEndRow; + USHORT nEndTab; + USHORT nPossDir = FDS_OPT_NONE; + FillDir eFillDir = FILL_TO_BOTTOM; + FillCmd eFillCmd = FILL_LINEAR; + FillDateCmd eFillDateCmd = FILL_DAY; + double fStartVal = MAXDOUBLE; + double fIncVal = 1; + double fMaxVal = MAXDOUBLE; + BOOL bDoIt = FALSE; + + GetViewData()->GetSimpleArea( nStartCol, nStartRow, nStartTab, + nEndCol, nEndRow, nEndTab ); + + if( nStartCol!=nEndCol ) + { + nPossDir |= FDS_OPT_HORZ; + eFillDir=FILL_TO_RIGHT; + } + + if( nStartRow!=nEndRow ) + { + nPossDir |= FDS_OPT_VERT; + eFillDir=FILL_TO_BOTTOM; + } + + ScDocument* pDoc = GetViewData()->GetDocument(); + SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + + if( pReqArgs ) + { + const SfxPoolItem* pItem; + String aFillDir, aFillCmd, aFillDateCmd; + String aFillStep, aFillStart, aFillMax; + ULONG nKey; + double fTmpVal; + + bDoIt=FALSE; + + if( IS_AVAILABLE( FID_FILL_SERIES, &pItem ) ) + aFillDir = ((const SfxStringItem*)pItem)->GetValue(); + if( IS_AVAILABLE( FN_PARAM_1, &pItem ) ) + aFillCmd = ((const SfxStringItem*)pItem)->GetValue(); + if( IS_AVAILABLE( FN_PARAM_2, &pItem ) ) + aFillDateCmd = ((const SfxStringItem*)pItem)->GetValue(); + if( IS_AVAILABLE( FN_PARAM_3, &pItem ) ) + aFillStep = ((const SfxStringItem*)pItem)->GetValue(); + if( IS_AVAILABLE( FN_PARAM_4, &pItem ) ) + aFillStart = ((const SfxStringItem*)pItem)->GetValue(); + if( IS_AVAILABLE( FN_PARAM_5, &pItem ) ) + aFillMax = ((const SfxStringItem*)pItem)->GetValue(); + + if( aFillDir.Len() ) + switch( aFillDir.GetChar(0) ) + { + case 'B': case 'b': eFillDir=FILL_TO_BOTTOM; break; + case 'R': case 'r': eFillDir=FILL_TO_RIGHT; break; + case 'T': case 't': eFillDir=FILL_TO_TOP; break; + case 'L': case 'l': eFillDir=FILL_TO_LEFT; break; + } + + if( aFillCmd.Len() ) + switch( aFillCmd.GetChar(0) ) + { + case 'S': case 's': eFillCmd=FILL_SIMPLE; break; + case 'L': case 'l': eFillCmd=FILL_LINEAR; break; + case 'G': case 'g': eFillCmd=FILL_GROWTH; break; + case 'D': case 'd': eFillCmd=FILL_DATE; break; + case 'A': case 'a': eFillCmd=FILL_AUTO; break; + } + + if( aFillDateCmd.Len() ) + switch( aFillDateCmd.GetChar(0) ) + { + case 'D': case 'd': eFillDateCmd=FILL_DAY; break; + case 'W': case 'w': eFillDateCmd=FILL_WEEKDAY; break; + case 'M': case 'm': eFillDateCmd=FILL_MONTH; break; + case 'Y': case 'y': eFillDateCmd=FILL_YEAR; break; + } + + nKey = 0; + if( pFormatter->IsNumberFormat( aFillStart, nKey, fTmpVal )) + fStartVal = fTmpVal; + + nKey = 0; + if( pFormatter->IsNumberFormat( aFillStep, nKey, fTmpVal )) + fIncVal = fTmpVal; + + nKey = 0; + if( pFormatter->IsNumberFormat( aFillMax, nKey, fTmpVal )) + fMaxVal = fTmpVal; + + bDoIt = TRUE; + + } + else // (pReqArgs == NULL) => Dialog hochziehen + { + // + ULONG nPrivFormat; + CellType eCellType; + pDoc->GetNumberFormat( nStartCol, nStartRow, nStartTab, nPrivFormat ); + pDoc->GetCellType( nStartCol, nStartRow, nStartTab,eCellType ); + const SvNumberformat* pPrivEntry = pFormatter->GetEntry( nPrivFormat ); + if (!pPrivEntry) + { + DBG_ERROR("Zahlformat nicht gefunden !!!"); + } + else + { + short nPrivType = pPrivEntry->GetType(); + if ( ( nPrivType & NUMBERFORMAT_DATE)>0) + { + eFillCmd=FILL_DATE; + } + else if(eCellType==CELLTYPE_STRING) + { + eFillCmd=FILL_AUTO; + } + } + + // + String aStartStr; + + // Startwert nur vorbelegen, wenn nur 1 Zeile oder Spalte: + if ( nStartCol == nEndCol || nStartRow == nEndRow ) + { + double fInputEndVal; + String aEndStr; + + pDoc->GetInputString( nStartCol, nStartRow, nStartTab, aStartStr); + pDoc->GetValue( nStartCol, nStartRow, nStartTab, fStartVal ); + + + if(eFillDir==FILL_TO_BOTTOM && nStartRow < nEndRow ) + { + pDoc->GetInputString( nStartCol, nStartRow+1, nStartTab, aEndStr); + if(aEndStr.Len()>0) + { + pDoc->GetValue( nStartCol, nStartRow+1, nStartTab, fInputEndVal); + fIncVal=fInputEndVal-fStartVal; + } + } + else + { + if(nStartCol < nEndCol) + { + pDoc->GetInputString( nStartCol+1, nStartRow, nStartTab, aEndStr); + if(aEndStr.Len()>0) + { + pDoc->GetValue( nStartCol+1, nStartRow, nStartTab, fInputEndVal); + fIncVal=fInputEndVal-fStartVal; + } + } + } + if(eFillCmd==FILL_DATE) + { + Date aNullDate = *pDoc->GetFormatTable()->GetNullDate(); + Date aStartDate = aNullDate; + aStartDate+= (long)fStartVal; + Date aEndDate = aNullDate; + aEndDate+= (long)fInputEndVal; + double fTempDate=0; + + if(aStartDate.GetYear()!=aEndDate.GetYear()) + { + eFillDateCmd = FILL_YEAR; + fTempDate=aEndDate.GetYear()-aStartDate.GetYear(); + } + if(aStartDate.GetMonth()!=aEndDate.GetMonth()) + { + eFillDateCmd = FILL_MONTH; + fTempDate=fTempDate*12+aEndDate.GetMonth()-aStartDate.GetMonth(); + } + if(aStartDate.GetDay()==aEndDate.GetDay()) + { + fIncVal=fTempDate; + } + } + } + ScFillSeriesDlg* pDlg = new ScFillSeriesDlg( + pTabViewShell->GetDialogParent(), *pDoc, + eFillDir, eFillCmd, eFillDateCmd, + aStartStr, fIncVal, fMaxVal, + nPossDir); + + if ( nStartCol != nEndCol && nStartRow != nEndRow ) + { + pDlg->SetEdStartValEnabled(FALSE); + } + + if ( pDlg->Execute() == RET_OK ) + { + eFillDir = pDlg->GetFillDir(); + eFillCmd = pDlg->GetFillCmd(); + eFillDateCmd = pDlg->GetFillDateCmd(); + + if(eFillCmd==FILL_AUTO) + { + String aStr=pDlg->GetStartStr(); + if(aStr.Len()>0) + pTabViewShell->EnterData( nStartCol, nStartRow, nStartTab, aStr ); + } + fStartVal = pDlg->GetStart(); + fIncVal = pDlg->GetStep(); + fMaxVal = pDlg->GetMax(); + bDoIt = TRUE; + } + delete pDlg; + } + + if( bDoIt ) + { + //nScFillModeMouseModifier = 0; // kein Ctrl/Copy + pTabViewShell->FillSeries( eFillDir, eFillCmd, eFillDateCmd, fStartVal, fIncVal, fMaxVal ); + + if( ! rReq.IsAPI() ) + { + String aPara; + Color* pColor=0; + + switch( eFillDir ) + { + case FILL_TO_BOTTOM: aPara = 'B'; break; + case FILL_TO_RIGHT: aPara = 'R'; break; + case FILL_TO_TOP: aPara = 'T'; break; + case FILL_TO_LEFT: aPara = 'L'; break; + default: aPara.Erase(); break; + } + rReq.AppendItem( SfxStringItem( FID_FILL_SERIES, aPara ) ); + + switch( eFillCmd ) + { + case FILL_SIMPLE: aPara = 'S'; break; + case FILL_LINEAR: aPara = 'L'; break; + case FILL_GROWTH: aPara = 'G'; break; + case FILL_DATE: aPara = 'D'; break; + case FILL_AUTO: aPara = 'A'; break; + default: aPara.Erase(); break; + } + rReq.AppendItem( SfxStringItem( FN_PARAM_1, aPara ) ); + + switch( eFillDateCmd ) + { + case FILL_DAY: aPara = 'D'; break; + case FILL_WEEKDAY: aPara = 'W'; break; + case FILL_MONTH: aPara = 'M'; break; + case FILL_YEAR: aPara = 'Y'; break; + default: aPara.Erase(); break; + } + rReq.AppendItem( SfxStringItem( FN_PARAM_2, aPara ) ); + + ULONG nFormatKey = pFormatter->GetStandardFormat(NUMBERFORMAT_NUMBER, + ScGlobal::eLnge ); + + pFormatter->GetOutputString( fIncVal, nFormatKey, aPara, &pColor ); + rReq.AppendItem( SfxStringItem( FN_PARAM_3, aPara ) ); + + pFormatter->GetOutputString( fStartVal, nFormatKey, aPara, &pColor ); + rReq.AppendItem( SfxStringItem( FN_PARAM_4, aPara ) ); + + pFormatter->GetOutputString( fMaxVal, nFormatKey, aPara, &pColor ); + rReq.AppendItem( SfxStringItem( FN_PARAM_5, aPara ) ); + + rReq.Done(); + } + } + } + break; + + case FID_FILL_AUTO: + { + USHORT nStartCol; + USHORT nStartRow; + USHORT nEndCol; + USHORT nEndRow; + USHORT nStartTab, nEndTab; + + GetViewData()->GetFillData( nStartCol, nStartRow, nEndCol, nEndRow ); + USHORT nFillCol = GetViewData()->GetRefEndX(); + USHORT nFillRow = GetViewData()->GetRefEndY(); + + if( pReqArgs != NULL ) + { + const SfxPoolItem* pItem; + + if( IS_AVAILABLE( FID_FILL_AUTO, &pItem ) ) + { + ScAddress aScAddress; + String aArg = ((const SfxStringItem*)pItem)->GetValue(); + + if( aScAddress.Parse( aArg ) & SCA_VALID ) + { + nFillRow = aScAddress.Row(); + nFillCol = aScAddress.Col(); + } + } + + GetViewData()->GetSimpleArea( nStartCol,nStartRow,nStartTab, + nEndCol,nEndRow,nEndTab ); + } + else // Aufruf per Maus + { + // #55284# nicht innerhalb einer zusammengefassten Zelle + + if ( nStartCol == nEndCol && nStartRow == nEndRow ) + { + USHORT nMergeCol = nStartCol; + USHORT nMergeRow = nStartRow; + if ( GetViewData()->GetDocument()->ExtendMerge( + nStartCol, nStartRow, nMergeCol, nMergeRow, + GetViewData()->GetTabNo() ) ) + { + if ( nFillCol <= nMergeCol && nFillRow == nStartRow ) + nFillCol = nStartCol; + if ( nFillRow <= nMergeRow && nFillCol == nStartCol ) + nFillRow = nStartRow; + } + } + } + + if ( nFillCol != nEndCol || nFillRow != nEndRow ) + { + if ( nFillCol==nEndCol || nFillRow==nEndRow ) + { + FillDir eDir; + USHORT nCount = 0; + + if ( nFillCol==nEndCol ) + { + if ( nFillRow > nEndRow ) + { + eDir = FILL_TO_BOTTOM; + nCount = nFillRow - nEndRow; + } + else if ( nFillRow < nStartRow ) + { + eDir = FILL_TO_TOP; + nCount = nStartRow - nFillRow; + } + } + else + { + if ( nFillCol > nEndCol ) + { + eDir = FILL_TO_RIGHT; + nCount = nFillCol - nEndCol; + } + else if ( nFillCol < nStartCol ) + { + eDir = FILL_TO_LEFT; + nCount = nStartCol - nFillCol; + } + } + + if ( nCount ) + { + pTabViewShell->FillAuto( eDir, nStartCol, nStartRow, nEndCol, nEndRow, nCount ); + + if( ! rReq.IsAPI() ) + { + String aAdrStr; + ScAddress aAdr( nFillCol, nFillRow, 0 ); + aAdr.Format( aAdrStr, SCR_ABS, GetViewData()->GetDocument() ); + + rReq.AppendItem( SfxStringItem( FID_FILL_AUTO, aAdrStr ) ); + rReq.Done(); + } + } + + } + else + DBG_ERROR( "Richtung nicht eindeutig fuer AutoFill" ); + } + } + break; + + // + // Gliederung (Outlines) + // SID_AUTO_OUTLINE, SID_OUTLINE_DELETEALL in Execute (in docsh.idl) + // + + case SID_OUTLINE_HIDE: + pTabViewShell->HideMarkedOutlines(); + rReq.Done(); + break; + + case SID_OUTLINE_SHOW: + pTabViewShell->ShowMarkedOutlines(); + rReq.Done(); + break; + + case SID_OUTLINE_MAKE: + { + BOOL bColumns; + BOOL bOk = TRUE; + + if( pReqArgs != NULL ) + { + const SfxPoolItem* pItem; + bOk = FALSE; + + if( IS_AVAILABLE( SID_OUTLINE_MAKE, &pItem ) ) + { + String aCol = ((const SfxStringItem*)pItem)->GetValue(); + aCol.ToUpperAscii(); + + switch( aCol.GetChar(0) ) + { + case 'R': bColumns=FALSE; bOk = TRUE;break; + case 'C': bColumns=TRUE; bOk = TRUE;break; + } + } + } + else // Dialog, wenn nicht ganze Zeilen/Spalten markiert + { + if ( GetViewData()->SimpleColMarked() && !GetViewData()->SimpleRowMarked() ) + bColumns = TRUE; + else if ( !GetViewData()->SimpleColMarked() && GetViewData()->SimpleRowMarked() ) + bColumns = FALSE; + else + { + ScGroupDlg* pDlg = new ScGroupDlg(pTabViewShell->GetDialogParent(), + RID_SCDLG_GRP_MAKE, FALSE ); + if ( pDlg->Execute() == RET_OK ) + bColumns = pDlg->GetColsChecked(); + else + bOk = FALSE; + delete pDlg; + } + } + if (bOk) + { + pTabViewShell->MakeOutline( bColumns ); + + if( ! rReq.IsAPI() ) + { + String aCol = bColumns ? 'C' : 'R'; + rReq.AppendItem( SfxStringItem( SID_OUTLINE_MAKE, aCol ) ); + rReq.Done(); + } + } + } + break; + + case SID_OUTLINE_REMOVE: + { + BOOL bColumns; + BOOL bOk = TRUE; + + if( pReqArgs != NULL ) + { + const SfxPoolItem* pItem; + bOk = FALSE; + + if( IS_AVAILABLE( SID_OUTLINE_REMOVE, &pItem ) ) + { + String aCol = ((const SfxStringItem*)pItem)->GetValue(); + aCol.ToUpperAscii(); + + switch( aCol.GetChar(0) ) + { + case 'R': bColumns=FALSE; bOk = TRUE;break; + case 'C': bColumns=TRUE; bOk = TRUE;break; + } + } + } + else // Dialog nur, wenn Aufheben fuer Zeilen und Spalten moeglich + { + BOOL bColPoss, bRowPoss; + pTabViewShell->TestRemoveOutline( bColPoss, bRowPoss ); + if ( bColPoss && bRowPoss ) + { + ScGroupDlg* pDlg = new ScGroupDlg( pTabViewShell->GetDialogParent(), + RID_SCDLG_GRP_KILL, TRUE ); + if ( pDlg->Execute() == RET_OK ) + bColumns = pDlg->GetColsChecked(); + else + bOk = FALSE; + delete pDlg; + } + else if ( bColPoss ) + bColumns = TRUE; + else if ( bRowPoss ) + bColumns = FALSE; + else + bOk = FALSE; + } + if (bOk) + { + pTabViewShell->RemoveOutline( bColumns ); + + if( ! rReq.IsAPI() ) + { + String aCol = bColumns ? 'C' : 'R'; + rReq.AppendItem( SfxStringItem( SID_OUTLINE_REMOVE, aCol ) ); + rReq.Done(); + } + } + } + break; + + // + // Clipboard + // + + case SID_COPY: // fuer Grafiken in DrawShell + { + WaitObject aWait( GetViewData()->GetDialogParent() ); + pTabViewShell->CopyToClip(); + rReq.Done(); + } + break; + + case SID_CUT: // fuer Grafiken in DrawShell + { + WaitObject aWait( GetViewData()->GetDialogParent() ); + pTabViewShell->CutToClip(); + rReq.Done(); + } + break; + + case SID_PASTE: + { + WaitObject aWait( GetViewData()->GetDialogParent() ); + pTabViewShell->PasteFromSystem(); + rReq.Done(); + } + pTabViewShell->CellContentChanged(); // => PasteFromSystem() ??? + break; + + case FID_INS_CELL_CONTENTS: + { + USHORT nFlags = IDF_NONE; + USHORT nFunction = PASTE_NOFUNC; + BOOL bSkipEmpty = FALSE; + BOOL bTranspose = FALSE; + BOOL bAsLink = FALSE; + InsCellCmd eMoveMode = INS_NONE; + + ScDocument* pDoc = GetViewData()->GetDocument(); + BOOL bOtherDoc = !pDoc->IsClipboardSource(); + + if ( pReqArgs!=NULL && pTabViewShell->SelectionEditable() ) + { + const SfxPoolItem* pItem; + String aFlags = 'A'; + + if( IS_AVAILABLE( FID_INS_CELL_CONTENTS, &pItem ) ) + aFlags = ((const SfxStringItem*)pItem)->GetValue(); + + aFlags.ToUpperAscii(); + BOOL bCont = TRUE; + + for( xub_StrLen i=0 ; bCont && i<aFlags.Len() ; i++ ) + { + switch( aFlags.GetChar(i) ) + { + case 'A': // Alle + nFlags |= IDF_ALL; + bCont = FALSE; // nicht mehr weitermachen! + break; + case 'S': nFlags |= IDF_STRING; break; + case 'V': nFlags |= IDF_VALUE; break; + case 'D': nFlags |= IDF_DATETIME; break; + case 'F': nFlags |= IDF_FORMULA; break; + case 'N': nFlags |= IDF_NOTE; break; + case 'T': nFlags |= IDF_ATTRIB; break; + } + } + } + else + { + if (pTabViewShell->SelectionEditable()) + { + ScInsertContentsDlg* pDlg = new ScInsertContentsDlg( pTabViewShell->GetDialogParent() ); + pDlg->SetOtherDoc( bOtherDoc ); + // #53661# bei ChangeTrack MoveMode disablen + pDlg->SetChangeTrack( pDoc->GetChangeTrack() != NULL ); + // #72930# cut/move references may disable shift + // directions if source and destination ranges intersect + if ( !bOtherDoc ) + { + ScDocument* pClipDoc = ScGlobal::GetClipDoc(); + if ( pClipDoc->IsCutMode() ) + { + ScViewData* pViewData = GetViewData(); + if ( pViewData->GetMarkData().GetTableSelect( + pViewData->GetTabNo() ) ) + { + USHORT nPosX = pViewData->GetCurX(); + USHORT nPosY = pViewData->GetCurY(); + USHORT nClipStartX, nClipStartY, nClipSizeX, nClipSizeY; + pClipDoc->GetClipStart( nClipStartX, nClipStartY ); + pClipDoc->GetClipArea( nClipSizeX, nClipSizeY ); + int nDisableShift = 0; + if ( nClipStartX <= nPosX + nClipSizeX && + nPosX <= nClipStartX + nClipSizeX ) + nDisableShift |= SC_CELL_SHIFT_DISABLE_DOWN; + if ( nClipStartY <= nPosY + nClipSizeY && + nPosY <= nClipStartY + nClipSizeY ) + nDisableShift |= SC_CELL_SHIFT_DISABLE_RIGHT; + if ( nDisableShift ) + pDlg->SetCellShiftDisabled( nDisableShift ); + } + } + } + if (pDlg->Execute() == RET_OK) + { + nFlags = pDlg->GetInsContentsCmdBits(); + nFunction = pDlg->GetFormulaCmdBits(); + bSkipEmpty = pDlg->IsSkipEmptyCells(); + bTranspose = pDlg->IsTranspose(); + bAsLink = pDlg->IsLink(); + eMoveMode = pDlg->GetMoveMode(); + } + delete pDlg; + } + else + pTabViewShell->ErrorMessage(STR_PROTECTIONERR); + } + + if( nFlags != IDF_NONE ) + { + { + WaitObject aWait( GetViewData()->GetDialogParent() ); + if ( bAsLink && bOtherDoc ) + pTabViewShell->PasteFromSystem(SOT_FORMATSTR_ID_LINK); // DDE einfuegen + else + pTabViewShell->PasteFromClip( nFlags, NULL, + nFunction, bSkipEmpty, bTranspose, bAsLink, + eMoveMode ); + } + + if( ! rReq.IsAPI() ) + { + String aFlags; + + if( nFlags == IDF_ALL ) + { + aFlags += 'A'; + } + else + { + if( nFlags & IDF_STRING ) aFlags += 'S'; + if( nFlags & IDF_VALUE ) aFlags += 'V'; + if( nFlags & IDF_DATETIME ) aFlags += 'D'; + if( nFlags & IDF_FORMULA ) aFlags += 'F'; + if( nFlags & IDF_NOTE ) aFlags += 'N'; + if( nFlags & IDF_ATTRIB ) aFlags += 'T'; + } + + rReq.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS, aFlags ) ); + rReq.Done(); + } + } + } + pTabViewShell->CellContentChanged(); // => PasteFromXXX ??? + break; + + case FID_PASTE_CONTENTS: + // Unterscheidung, ob eigene oder fremde Daten, + // dadurch FID_INS_CELL_CONTENTS ueberfluessig + { + // Clipboard-ID als Parameter angegeben? Basic "PasteSpecial(Format)" + const SfxPoolItem* pItem; + if ( pReqArgs && + pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET && + pItem->ISA(SfxUInt32Item) ) + { + ULONG nFormat = ((const SfxUInt32Item*)pItem)->GetValue(); + BOOL bRet; + { + WaitObject aWait( GetViewData()->GetDialogParent() ); + bRet = pTabViewShell->PasteFromSystem(nFormat, TRUE); // TRUE: keine Fehlermeldungen + } + rReq.SetReturnValue(SfxInt16Item(nSlot, bRet)); // 1 = Erfolg, 0 = Fehler + rReq.Done(); + } + else if ( ScGlobal::IsClipCaptured() ) // eigene Tabellen-Daten + { + rReq.SetSlot( FID_INS_CELL_CONTENTS ); + ExecuteSlot( rReq, GetInterface() ); + rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = Erfolg + } + else // Zeichenobjekte oder fremde Daten + { + BOOL bDraw = ScGlobal::IsClipDraw(); + + SvDataObjectRef pClipObj = SvDataObject::PasteClipboard(); + if (pClipObj.Is()) + { + SvPasteObjectDialog* pDlg = new SvPasteObjectDialog; + // nOle ist special, stellvertretend fuer alle vier ?!? + ULONG nOle = SOT_FORMATSTR_ID_EMBED_SOURCE; + ULONG nSdr = SOT_FORMATSTR_ID_DRAWING; + pDlg->Insert( nSdr, Clipboard::GetFormatName( nSdr ) ); + pDlg->Insert( SOT_FORMATSTR_ID_SVXB,Clipboard::GetFormatName( SOT_FORMATSTR_ID_SVXB ) ); + pDlg->Insert( FORMAT_GDIMETAFILE, Clipboard::GetFormatName( FORMAT_GDIMETAFILE ) ); + pDlg->Insert( FORMAT_BITMAP, Clipboard::GetFormatName( FORMAT_BITMAP ) ); + pDlg->Insert( nOle, String('*') ); + if (!bDraw) + { + ULONG nBiff = Exchange::RegisterFormatName( + String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Biff5"))); + pDlg->Insert( SOT_FORMATSTR_ID_LINK,ScResId( SCSTR_CLIP_DDE ) ); + pDlg->Insert( FORMAT_STRING, ScResId( SCSTR_CLIP_STRING ) ); + pDlg->Insert( SOT_FORMATSTR_ID_DIF, ScResId( SCSTR_CLIP_DIF ) ); + pDlg->Insert( FORMAT_RTF, ScResId( SCSTR_CLIP_RTF ) ); + pDlg->Insert( SOT_FORMATSTR_ID_HTML,Clipboard::GetFormatName( SOT_FORMATSTR_ID_HTML ) ); + pDlg->Insert( SOT_FORMATSTR_ID_HTML_SIMPLE,Clipboard::GetFormatName( SOT_FORMATSTR_ID_HTML_SIMPLE ) ); + pDlg->Insert( nBiff, Clipboard::GetFormatName( nBiff ) ); + } + + ULONG nFormat = pDlg->Execute( pTabViewShell->GetDialogParent(), pClipObj ); + if (nFormat > 0) + { + { + WaitObject aWait( GetViewData()->GetDialogParent() ); + if ( bDraw && nFormat == nOle ) + pTabViewShell->PasteDraw(); + else + pTabViewShell->PasteFromSystem(nFormat); + } + rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = Erfolg + rReq.Done(); + } + else + rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = Fehler + delete pDlg; + } + else + rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = Fehler + } + } + pTabViewShell->CellContentChanged(); // => PasteFromSystem() ??? + break; + + // Clipboard-Abfrage-Slots wie im Writer (da auch an der Selection) + + case SID_GET_CLPBRD_FORMAT_COUNT: + rReq.SetReturnValue( SfxUInt16Item( nSlot, Clipboard::GetFormatCount() ) ); + break; + + case SID_GET_CLPBRD_FORMAT_BY_IDX: + if (pReqArgs) + { + const SfxPoolItem* pItem; + if ( pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET && + pItem->ISA(SfxUInt16Item) ) + { + USHORT nCount = Clipboard::GetFormatCount(); + USHORT nPos = ((const SfxUInt16Item*)pItem)->GetValue(); // 1-based + if ( nPos && nPos <= nCount ) + rReq.SetReturnValue( SfxUInt32Item( nSlot, Clipboard::GetFormat(--nPos) ) ); + } + } + break; + + case SID_GET_CLPBRD_FORMAT_NAME: + if (pReqArgs) + { + const SfxPoolItem* pItem; + if ( pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET && + pItem->ISA(SfxUInt32Item) ) + { + String aName = Exchange::GetFormatName( + ((const SfxUInt32Item*)pItem)->GetValue() ); + rReq.SetReturnValue( SfxStringItem( nSlot, aName ) ); + } + } + break; + + // + // sonstiges + // + + case FID_INS_ROWBRK: + pTabViewShell->InsertPageBreak( FALSE ); + rReq.Done(); + break; + + case FID_INS_COLBRK: + pTabViewShell->InsertPageBreak( TRUE ); + rReq.Done(); + break; + + case FID_DEL_ROWBRK: + pTabViewShell->DeletePageBreak( FALSE ); + rReq.Done(); + break; + + case FID_DEL_COLBRK: + pTabViewShell->DeletePageBreak( TRUE ); + rReq.Done(); + break; + + case SID_DETECTIVE_ADD_PRED: + pTabViewShell->DetectiveAddPred(); + rReq.Done(); + break; + + case SID_DETECTIVE_DEL_PRED: + pTabViewShell->DetectiveDelPred(); + rReq.Done(); + break; + + case SID_DETECTIVE_ADD_SUCC: + pTabViewShell->DetectiveAddSucc(); + rReq.Done(); + break; + + case SID_DETECTIVE_DEL_SUCC: + pTabViewShell->DetectiveDelSucc(); + rReq.Done(); + break; + + case SID_DETECTIVE_ADD_ERR: + pTabViewShell->DetectiveAddError(); + rReq.Done(); + break; + + case SID_DETECTIVE_INVALID: + pTabViewShell->DetectiveMarkInvalid(); + rReq.Done(); + break; + + case SID_DETECTIVE_REFRESH: + pTabViewShell->DetectiveRefresh(); + rReq.Done(); + break; + + case SID_SPELLING: + pTabViewShell->DoSpellingChecker(); + break; + + case SID_THESAURUS: + pTabViewShell->DoThesaurus(); + break; + + case SID_TOGGLE_REL: + { + BOOL bOk = FALSE; + USHORT nCol = GetViewData()->GetCurX(); + USHORT nRow = GetViewData()->GetCurY(); + USHORT nTab = GetViewData()->GetTabNo(); + ScDocument* pDoc = GetViewData()->GetDocument(); + CellType eType; + pDoc->GetCellType( nCol, nRow, nTab, eType ); + if (eType == CELLTYPE_FORMULA) + { + String aOld; + pDoc->GetFormula( nCol, nRow, nTab, aOld ); + xub_StrLen nLen = aOld.Len(); + ScRefFinder aFinder( aOld, pDoc ); + aFinder.ToggleRel( 0, nLen ); + if (aFinder.GetFound()) + { + String aNew = aFinder.GetText(); + pTabViewShell->EnterData( nCol, nRow, nTab, aNew ); + pTabViewShell->UpdateInputHandler(); + bOk = TRUE; + } + } + if (!bOk) + pTabViewShell->ErrorMessage(STR_ERR_NOREF); + } + break; + + case SID_DEC_INDENT: + pTabViewShell->ChangeIndent( FALSE ); + break; + case SID_INC_INDENT: + pTabViewShell->ChangeIndent( TRUE ); + break; + + case FID_USE_NAME: + { + USHORT nFlags = pTabViewShell->GetCreateNameFlags(); + + ScNameCreateDlg* pDlg = new ScNameCreateDlg( pTabViewShell->GetDialogParent(), nFlags ); + + if( pDlg->Execute() ) + { + nFlags = pDlg->GetFlags(); + pTabViewShell->CreateNames(nFlags); + rReq.Done(); + } + delete pDlg; + } + break; + + case SID_CONSOLIDATE: + { + const SfxPoolItem* pItem; + if ( pReqArgs && SFX_ITEM_SET == + pReqArgs->GetItemState( SCITEM_CONSOLIDATEDATA, TRUE, &pItem ) ) + { + const ScConsolidateParam& rParam = + ((const ScConsolidateItem*)pItem)->GetData(); + + pTabViewShell->Consolidate( rParam ); + GetViewData()->GetDocument()->SetConsolidateDlgData( &rParam ); + + rReq.Done(); + } + else if (rReq.IsAPI()) + SbxBase::SetError(SbxERR_BAD_PARAMETER); + } + break; + + case SID_INS_FUNCTION: + { + const SfxBoolItem* pOkItem = (const SfxBoolItem*)&pReqArgs->Get( SID_DLG_RETOK ); + +// pScMod->SetFunctionDlg( NULL ); + + if ( pOkItem->GetValue() ) // OK + { + String aFormula; + const SfxStringItem* pSItem = (const SfxStringItem*)&pReqArgs->Get( SCITEM_STRING ); + const SfxBoolItem* pMatrixItem = (const SfxBoolItem*) &pReqArgs->Get( SID_DLG_MATRIX ); + + aFormula += pSItem->GetValue(); + pScMod->ActivateInputWindow( &aFormula, pMatrixItem->GetValue() ); + } + else // CANCEL + { + pScMod->ActivateInputWindow( NULL ); + } + rReq.Done(); + } + break; + + case FID_DEFINE_NAME: + if ( pReqArgs ) + { + const SfxPoolItem* pItem; + String aName, aSymbol, aAttrib; + + if( IS_AVAILABLE( FID_DEFINE_NAME, &pItem ) ) + aName = ((const SfxStringItem*)pItem)->GetValue(); + + if( IS_AVAILABLE( FN_PARAM_1, &pItem ) ) + aSymbol = ((const SfxStringItem*)pItem)->GetValue(); + + if( IS_AVAILABLE( FN_PARAM_2, &pItem ) ) + aAttrib = ((const SfxStringItem*)pItem)->GetValue(); + + if ( aName.Len() && aSymbol.Len() ) + { + if (pTabViewShell->InsertName( aName, aSymbol, aAttrib )) + rReq.Done(); + else + SbxBase::SetError( SbxERR_BAD_PARAMETER ); // Basic-Fehler + } + } + else + { + USHORT nId = ScNameDlgWrapper::GetChildWindowId(); + SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); + SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); + + pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE ); + } + break; + + case SID_DEFINE_COLROWNAMERANGES: + { + + USHORT nId = ScColRowNameRangesDlgWrapper::GetChildWindowId(); + SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); + SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); + + pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE ); + + } + break; + + case SID_UPDATECHART: + { + BOOL bAll = FALSE; + + if( pReqArgs ) + { + const SfxPoolItem* pItem; + + if( IS_AVAILABLE( SID_UPDATECHART, &pItem ) ) + bAll = ((const SfxBoolItem*)pItem)->GetValue(); + } + + pTabViewShell->UpdateCharts( bAll ); + + if( ! rReq.IsAPI() ) + { + rReq.AppendItem( SfxBoolItem( SID_UPDATECHART, bAll ) ); + rReq.Done(); + } + } + break; + + + case SID_TABOP: + { + const SfxItemSet* pOutSet = rReq.GetArgs(); + const ScTabOpItem& rItem = + (const ScTabOpItem&) + pOutSet->Get( SID_TABOP ); + + pTabViewShell->TabOp( rItem.GetData() ); + + rReq.Done( *pOutSet ); + } + break; + + case SID_SOLVE: + { + const SfxItemSet* pOutSet = rReq.GetArgs(); + const ScSolveItem& rItem = + (const ScSolveItem&) + pOutSet->Get( SCITEM_SOLVEDATA ); + + pTabViewShell->Solve( rItem.GetData() ); + + rReq.Done( *pOutSet ); + } + break; + + case FID_INSERT_NAME: + { + ScDocument* pDoc = GetViewData()->GetDocument(); + ScNamePasteDlg* pDlg = new ScNamePasteDlg( pTabViewShell->GetDialogParent(), pDoc->GetRangeName() ); + + switch( pDlg->Execute() ) + { + case BTN_PASTE_LIST: + pTabViewShell->InsertNameList(); + break; + case BTN_PASTE_NAME: + { + ScInputHandler* pHdl = pScMod->GetInputHdl( pTabViewShell ); + if (pHdl) + { + // das "=" per Key-Event, schaltet in den Eingabe-Modus + pScMod->InputKeyEvent( KeyEvent('=',KeyCode()) ); + + String aName = pDlg->GetSelectedName(); + pHdl->InsertFunction( aName, FALSE ); // ohne "()" + } + } + break; + } + delete pDlg; + } + break; + + case SID_RANGE_NOTETEXT: + if (pReqArgs) + { + String aNoteStr = ((const SfxStringItem&)pReqArgs-> + Get( SID_RANGE_NOTETEXT )).GetValue(); + String aDateStr = ScGlobal::pScInternational->GetDate( Date() ); + String aAuthorStr = SFX_INIMANAGER()->Get(SFX_KEY_USER_ID); + ScPostIt aNote( aNoteStr, aDateStr, aAuthorStr ); + + USHORT nCol, nRow, nTab; + + // #43343# immer Cursorposition + nCol = GetViewData()->GetCurX(); + nRow = GetViewData()->GetCurY(); + nTab = GetViewData()->GetTabNo(); + + pTabViewShell->SetNote( nCol, nRow, nTab, aNote ); + rReq.Done(); + } + break; + + case SID_INSERT_POSTIT: + { + ScDocument* pDoc = GetViewData()->GetDocument(); + USHORT nCol = GetViewData()->GetCurX(); + USHORT nRow = GetViewData()->GetCurY(); + USHORT nTab = GetViewData()->GetTabNo(); + ScPostIt aNote; + + if ( pReqArgs ) + { + const SvxPostItAuthorItem& rAuthorItem = (const SvxPostItAuthorItem&)pReqArgs->Get( SID_ATTR_POSTIT_AUTHOR ); + const SvxPostItDateItem& rDateItem = (const SvxPostItDateItem&) pReqArgs->Get( SID_ATTR_POSTIT_DATE ); + const SvxPostItTextItem& rTextItem = (const SvxPostItTextItem&) pReqArgs->Get( SID_ATTR_POSTIT_TEXT ); + aNote.SetText( rTextItem.GetValue() ); + aNote.SetDate( rDateItem.GetValue() ); + aNote.SetAuthor( rAuthorItem.GetValue() ); + + pTabViewShell->SetNote( nCol, nRow, nTab, aNote ); + rReq.Done(); + } + else + { + pTabViewShell->EditNote(); // Zeichenobjekt zum Editieren + } + } + break; + + case FID_NOTE_VISIBLE: + { + ScDocument* pDoc = GetViewData()->GetDocument(); + USHORT nCol = GetViewData()->GetCurX(); + USHORT nRow = GetViewData()->GetCurY(); + USHORT nTab = GetViewData()->GetTabNo(); + ScPostIt aNote; + + if ( pDoc->GetNote( nCol, nRow, nTab, aNote ) ) + { + BOOL bShow; + const SfxPoolItem* pItem; + if ( pReqArgs && pReqArgs->GetItemState( + FID_NOTE_VISIBLE, TRUE, &pItem ) == SFX_ITEM_SET ) + bShow = ((const SfxBoolItem*) pItem)->GetValue(); + else + bShow = !pDoc->HasNoteObject( nCol, nRow, nTab ); + + if ( bShow ) + pTabViewShell->ShowNote(); + else + pTabViewShell->HideNote(); + + if (!pReqArgs) + rReq.AppendItem( SfxBoolItem( FID_NOTE_VISIBLE, bShow ) ); + + rReq.Done(); + rBindings.Invalidate( FID_NOTE_VISIBLE ); + } + else + rReq.Ignore(); + } + break; + + case SID_CHARMAP: + if( pReqArgs != NULL ) + { + const SvxFontItem& rFontItem = (const SvxFontItem&) rReq.GetArgs()->Get(SID_CHARMAP); + const SfxStringItem& rStringItem = (const SfxStringItem&) rReq.GetArgs()->Get(SID_ATTR_SECIALCHAR); + Font aFont; + + aFont.SetName( rFontItem.GetFamilyName() ); + aFont.SetStyleName( rFontItem.GetStyleName() ); + aFont.SetFamily( rFontItem.GetFamily() ); + aFont.SetPitch( rFontItem.GetPitch() ); + aFont.SetCharSet( rFontItem.GetCharSet() ); + + pTabViewShell->InsertSpecialChar( rStringItem.GetValue(), aFont ); + if( ! rReq.IsAPI() ) + rReq.Done(); + } + else + { + SvxCharacterMap* pDlg = new SvxCharacterMap( pTabViewShell->GetDialogParent(), FALSE ); + Font aCurFont; + + pTabViewShell->GetSelectionPattern()->GetFont( aCurFont ); + pDlg->SetCharFont( aCurFont ); + + if ( pDlg->Execute() == RET_OK ) + { + Font aNewFont( pDlg->GetCharFont() ); + + pTabViewShell->InsertSpecialChar( pDlg->GetCharacters(), aNewFont ); + + SfxStringItem aStringItem( SID_ATTR_SECIALCHAR, + pDlg->GetCharacters() ); + SvxFontItem aFontItem( aNewFont.GetFamily(), + aNewFont.GetName(), + aNewFont.GetStyleName(), + aNewFont.GetPitch(), + aNewFont.GetCharSet(), + SID_CHARMAP ); + + rReq.AppendItem( aFontItem ); + rReq.AppendItem( aStringItem ); + rReq.Done(); + } + delete pDlg; + } + break; + + case SID_SELECT_SCENARIO: + { + // Testing + + if ( pReqArgs ) + { + const SfxStringItem* pItem = + (const SfxStringItem*)&pReqArgs->Get( SID_SELECT_SCENARIO ); + + if( pItem ) + { + pTabViewShell->UseScenario( pItem->GetValue() ); + //! wofuer soll der Return-Wert gut sein?!?! + rReq.SetReturnValue( SfxStringItem( SID_SELECT_SCENARIO, pItem->GetValue() ) ); + rReq.Done(); + } + else + DBG_ERROR("NULL"); + } + } + break; + + case SID_HYPERLINK_SETLINK: + if( pReqArgs ) + { + const SfxPoolItem* pItem; + if( IS_AVAILABLE( SID_HYPERLINK_SETLINK, &pItem ) ) + { + const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem; + const String& rName = pHyper->GetName(); + const String& rURL = pHyper->GetURL(); + const String& rTarget = pHyper->GetTargetFrame(); + USHORT nType = (USHORT) pHyper->GetInsertMode(); + + pTabViewShell->InsertURL( rName, rURL, rTarget, nType ); + } + } + break; + + case FID_CONDITIONAL_FORMAT: + if( pReqArgs ) + { + const SfxPoolItem* pItem; + if( IS_AVAILABLE( FID_CONDITIONAL_FORMAT, &pItem ) ) + { + // Wenn RefInput auf andere Tabelle als Datentabelle umgeschaltet + // hat wieder zurueckschalten: + if ( GetViewData()->GetTabNo() != GetViewData()->GetRefTabNo() ) + { + pTabViewShell->SetTabNo( GetViewData()->GetRefTabNo() ); + pTabViewShell->PaintExtras(); + } + + const ScCondFrmtItem* pCndFmtItem = (const ScCondFrmtItem*) pItem; + pTabViewShell->SetConditionalFormat( pCndFmtItem->GetData() ); + rReq.Done(); + } + } + break; + + // + // + // + + default: + DBG_ERROR("falscher Slot bei ExecuteEdit"); + break; + } +} + + + + + diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx new file mode 100644 index 000000000000..7156dd6e8c1f --- /dev/null +++ b/sc/source/ui/view/cellsh2.cxx @@ -0,0 +1,1234 @@ +/************************************************************************* + * + * $RCSfile: cellsh2.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +#define _BIGINT_HXX +//#define _BASEDLGS_HXX *** +#define _CACHESTR_HXX +//#define _CLIP_HXX +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _DLGCFG_HXX +#define _DYNARR_HXX +#define _EXTATTR_HXX +//#define _FILTER_HXX +#define _FONTDLG_HXX +#define _MACRODLG_HXX +#define _MODALDLG_HXX +#define _MOREBUTTON_HXX +#define _OUTLINER_HXX +#define _PASSWD_HXX +//#define _PRNDLG_HXX +#define _POLY_HXX +#define _PRVWIN_HXX +#define _QUEUE_HXX +//#define _RULER_HXX +#define _SCRWIN_HXX +#define _SOUND_HXX +#define _STACK_HXX +//#define _STATUS_HXX *** +#define _STDMENU_HXX +#define _TABBAR_HXX +//#define _TREELIST_HXX +#define _SFXBASIC_HXX +#define _SFX_DOCFILE_HXX +//#define _SFX_DOCFILT_HXX +#define _SFX_DOCINF_HXX +#define _SFX_DOCSH_HXX +#define _SFX_TEMPLDLG_HXX +#define _SFXSTBMGR_HXX +#define _SFXTBXMGR_HXX +#define _SFXIMGMGR_HXX +#define _SFXFILEDLG_HXX +#define _SFXIMGMGR_HXX +#define _SFXIPFRM_HXX +#define _SFX_MACRO_HXX +#define _SFXMNUITEM_HXX +#define _SFXMNUMGR_HXX +#define _SFXMULTISEL_HXX +#define _SFXSTBITEM_HXX +#define _SFXTBXCTRL_HXX + +#define _SI_DLL_HXX +#define _SIDLL_HXX +#define _SI_NOITEMS +#define _SI_NOOTHERFORMS +#define _SI_NOSBXCONTROLS +#define _SINOSBXCONTROLS +#define _SI_NODRW // +#define _SI_NOCONTROL + +#define _SVBOXITM_HXX +//#define _SVCONTNR_HXX +#define _SVDATTR_HXX +#define _SVDXOUT_HXX +#define _SVDEC_HXX +#define _SVDIO_HXX +#define _SVDLAYER_HXX +#define _SVDRAG_HXX +#define _SVINCVW_HXX +#define _SV_MULTISEL_HXX +#define _SVRTV_HXX +#define _SVTABBX_HXX + + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_THESDLG_HXX + + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <sfx2/request.hxx> +#include <svtools/aeitem.hxx> +#include <svtools/sbxcore.hxx> +#include <svtools/whiter.hxx> +#include <svtools/zforlist.hxx> +#include <offmgr/sbaitems.hxx> +#include <offmgr/sbasltid.hrc> +#include <vcl/msgbox.hxx> + +#include "cellsh.hxx" +#include "tabvwsh.hxx" +#include "sc.hrc" +#include "globstr.hrc" +#include "global.hxx" +#include "scmod.hxx" +#include "docsh.hxx" +#include "document.hxx" +#include "uiitems.hxx" +#include "dbfunc.hxx" +#include "dbdocfun.hxx" +#include "lbseldlg.hxx" +#include "sortdlg.hxx" +#include "filtdlg.hxx" +#include "dbnamdlg.hxx" +#include "subtdlg.hxx" +#include "reffact.hxx" +#include "pvlaydlg.hxx" +#include "validat.hxx" +#include "scresid.hxx" +#include "validate.hxx" +#include "pivot.hxx" +#include "dpobject.hxx" +#include "dapitype.hxx" +#include "dapidata.hxx" +#include "dpsdbtab.hxx" // ScImportSourceDesc +#include "dpshttab.hxx" // ScSheetSourceDesc + +using namespace com::sun::star; + +//#include "strindlg.hxx" //! Test !!!!! + +//static ScArea aPivotSource; //! wohin? (ueber den Dialog retten) + + +#define IS_AVAILABLE(WhichId,ppItem) \ + (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET) + +//------------------------------------------------------------------ + +void ScCellShell::ExecuteDB( SfxRequest& rReq ) +{ + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + USHORT nSlotId = rReq.GetSlot(); + const SfxItemSet* pReqArgs = rReq.GetArgs(); + SfxApplication* pSfxApp = SFX_APP(); + ScModule* pScMod = SC_MOD(); + + pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox + + switch ( nSlotId ) + { + case SID_IMPORT_DATA: + { + //! was wird mit dem Adressbuch? +#if 0 + if( pScApp->GetSbaObject()->IsAddrPIOpen() ) + { + SFX_DISPATCHER().Execute( SID_SBA_ADDRPI, + SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD ); + } +#endif + + if( pReqArgs ) + { + const SfxPoolItem* pItem; + if( IS_AVAILABLE( SID_IMPORT_DATA, &pItem ) ) + { + String aDBName, aSQLCommand; + + aDBName = ((const SfxStringItem*)pItem)->GetValue(); + + if( IS_AVAILABLE( FN_PARAM_1, &pItem ) ) + aSQLCommand = ((const SfxStringItem*)pItem)->GetValue(); + + + ScImportParam aImportParam; + ScDBData* pDBData = pTabViewShell->GetDBData(TRUE,SC_DB_IMPORT); // Namen vergeben + pDBData->GetImportParam( aImportParam ); + aImportParam.aDBName = aDBName; + aImportParam.aStatement = aSQLCommand; + aImportParam.bSql = TRUE; // kein Name, sondern Sql + aImportParam.bImport = TRUE; + + pTabViewShell->ImportData( aImportParam ); + pDBData->SetImportParam( aImportParam ); + + rReq.Done(); + } + else + { + rReq.Ignore(); + } + } + else // DB-Browser anzeigen + { + ScImportParam aImportParam; + ScDBData* pDBData = pTabViewShell->GetDBData(TRUE,SC_DB_OLD); // nicht neu anlegen + if (pDBData) + pDBData->GetImportParam( aImportParam ); + + pTabViewShell->StartQuerySh( aImportParam ); + } + } + break; + + case SID_REIMPORT_DATA: + { + BOOL bOk = FALSE; + ScDBData* pDBData = pTabViewShell->GetDBData(TRUE,SC_DB_OLD); + if (pDBData) + { + ScImportParam aImportParam; + pDBData->GetImportParam( aImportParam ); + if (aImportParam.bImport && !pDBData->HasImportSelection()) + { + pTabViewShell->ImportData( aImportParam ); + pDBData->SetImportParam( aImportParam ); //! Undo ?? + bOk = TRUE; + } + } + + if (!bOk && ! rReq.IsAPI() ) + pTabViewShell->ErrorMessage(STR_REIMPORT_EMPTY); + + if( bOk ) + rReq.Done(); + } + break; + + case SID_REFRESH_DBAREA: + { + ScDBData* pDBData = pTabViewShell->GetDBData(TRUE,SC_DB_OLD); + if (pDBData) + { + // Import wiederholen wie SID_REIMPORT_DATA + + BOOL bContinue = TRUE; + ScImportParam aImportParam; + pDBData->GetImportParam( aImportParam ); + if (aImportParam.bImport && !pDBData->HasImportSelection()) + { + bContinue = pTabViewShell->ImportData( aImportParam ); + pDBData->SetImportParam( aImportParam ); //! Undo ?? + + // markieren (Groesse kann sich geaendert haben) + ScRange aNewRange; + pDBData->GetArea(aNewRange); + pTabViewShell->MarkRange(aNewRange); + } + + if ( bContinue ) // #41905# Fehler beim Import -> Abbruch + { + // interne Operationen, wenn welche gespeichert + + if ( pDBData->HasQueryParam() || pDBData->HasSortParam() || + pDBData->HasSubTotalParam() ) + pTabViewShell->RepeatDB(); + + // Pivottabellen die den Bereich als Quelldaten haben + + ScRange aRange; + pDBData->GetArea(aRange); + GetViewData()->GetDocShell()->RefreshPivotTables(aRange); + } + } + rReq.Done(); + } + break; + + case SID_SBA_BRW_INSERT: + { + if (pReqArgs) + { + const SfxStringItem &rDBNameItem = (const SfxStringItem&) + pReqArgs->Get(SID_ATTR_SBA_DATABASE); + const SfxStringItem &rStatementItem = (const SfxStringItem&) + pReqArgs->Get(SID_ATTR_SBA_STATEMENT); + const SbaSelectionItem &rSelectionItem = (const SbaSelectionItem&) + pReqArgs->Get(SID_ATTR_SBA_SELECTION); + + DBG_ASSERT( rDBNameItem.ISA(SfxStringItem), "invalid argument type" ); + DBG_ASSERT( rStatementItem.ISA(SfxStringItem), "invalid argument type" ); + DBG_ASSERT( rSelectionItem.ISA(SbaSelectionItem), "invalid argument type" ); + + ScViewData* pViewData = GetViewData(); + ScImportParam aImParam; + aImParam.nCol1 = aImParam.nCol2 = pViewData->GetCurX(); + aImParam.nRow1 = aImParam.nRow2 = pViewData->GetCurY(); + aImParam.bImport = TRUE; + aImParam.aDBName = rDBNameItem.GetValue(); + aImParam.aStatement = rStatementItem.GetValue(); + + ScDBDocFunc( *pViewData->GetDocShell() ). + DoImport( pViewData->GetTabNo(), aImParam, + rSelectionItem.GetSelectionList(), TRUE, TRUE ); + rReq.Done(); + } + else + DBG_ERROR( "arguments expected" ); + } + break; + + case SID_SUBTOTALS: + { + const SfxItemSet* pArgs = rReq.GetArgs(); + if ( pArgs ) + { + pTabViewShell->DoSubTotals( ((const ScSubTotalItem&) pArgs->Get( SCITEM_SUBTDATA )). + GetSubTotalData() ); + rReq.Done(); + } + else + { + ScSubTotalDlg* pDlg = NULL; + ScSubTotalParam aSubTotalParam; + SfxItemSet aArgSet( GetPool(), SCITEM_SUBTDATA, SCITEM_SUBTDATA ); + + ScDBData* pDBData = pTabViewShell->GetDBData(); + pDBData->GetSubTotalParam( aSubTotalParam ); + aSubTotalParam.bRemoveOnly = FALSE; + + aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA, GetViewData(), &aSubTotalParam ) ); + pDlg = new ScSubTotalDlg( pTabViewShell->GetDialogParent(), &aArgSet ); + pDlg->SetCurPageId(1); + + short bResult = pDlg->Execute(); + + if ( (bResult == RET_OK) || (bResult == SCRET_REMOVE) ) + { + const SfxItemSet* pOutSet = NULL; + + if ( bResult == RET_OK ) + { + pOutSet = pDlg->GetOutputItemSet(); + aSubTotalParam = + ((const ScSubTotalItem&) + pOutSet->Get( SCITEM_SUBTDATA )). + GetSubTotalData(); + } + else // if (bResult == SCRET_REMOVE) + { + pOutSet = &aArgSet; + aSubTotalParam.bRemoveOnly = TRUE; + aSubTotalParam.bReplace = TRUE; + aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA, + GetViewData(), + &aSubTotalParam ) ); + } + + pTabViewShell->DoSubTotals( aSubTotalParam ); + rReq.Done( *pOutSet ); + } + delete pDlg; + } + } + break; + + case SID_SORT_DESCENDING: + case SID_SORT_ASCENDING: + { + SfxItemSet aArgSet( GetPool(), SCITEM_SORTDATA, SCITEM_SORTDATA ); + ScSortParam aSortParam; + ScDBData* pDBData = pTabViewShell->GetDBData(); + + pDBData->GetSortParam( aSortParam ); + aSortParam.bHasHeader = FALSE; + aSortParam.bByRow = TRUE; + aSortParam.bCaseSens = FALSE; + aSortParam.bIncludePattern = FALSE; + aSortParam.bInplace = TRUE; + aSortParam.bDoSort[0] = TRUE; + aSortParam.nField[0] = aSortParam.nCol1; + aSortParam.bAscending[0] = (nSlotId == SID_SORT_ASCENDING); + + for ( USHORT i=1; i<MAXSORT; i++ ) + aSortParam.bDoSort[i] = FALSE; + + aArgSet.Put( ScSortItem( SCITEM_SORTDATA, GetViewData(), &aSortParam ) ); + + pTabViewShell->UISort( aSortParam ); // Teilergebnisse bei Bedarf neu + + rReq.Done( aArgSet ); + } + break; + + case SID_SORT: + { + const SfxItemSet* pArgs = rReq.GetArgs(); + + if ( pArgs ) // Basic + { + ScSortParam aSortParam; + ScDBData* pDBData = pTabViewShell->GetDBData(); + pDBData->GetSortParam( aSortParam ); + aSortParam.bInplace = TRUE; // von Basic immer + + const SfxPoolItem* pItem; + if ( pArgs->GetItemState( SID_SORT_BYROW, TRUE, &pItem ) == SFX_ITEM_SET ) + aSortParam.bByRow = ((const SfxBoolItem*)pItem)->GetValue(); + if ( pArgs->GetItemState( SID_SORT_HASHEADER, TRUE, &pItem ) == SFX_ITEM_SET ) + aSortParam.bHasHeader = ((const SfxBoolItem*)pItem)->GetValue(); + if ( pArgs->GetItemState( SID_SORT_CASESENS, TRUE, &pItem ) == SFX_ITEM_SET ) + aSortParam.bCaseSens = ((const SfxBoolItem*)pItem)->GetValue(); + if ( pArgs->GetItemState( SID_SORT_ATTRIBS, TRUE, &pItem ) == SFX_ITEM_SET ) + aSortParam.bIncludePattern = ((const SfxBoolItem*)pItem)->GetValue(); + if ( pArgs->GetItemState( SID_SORT_USERDEF, TRUE, &pItem ) == SFX_ITEM_SET ) + { + USHORT nUserIndex = ((const SfxUInt16Item*)pItem)->GetValue(); + aSortParam.bUserDef = ( nUserIndex != 0 ); + if ( nUserIndex ) + aSortParam.nUserIndex = nUserIndex - 1; // Basic: 1-basiert + } + + USHORT nField0 = 0; + if ( pArgs->GetItemState( FN_PARAM_1, TRUE, &pItem ) == SFX_ITEM_SET ) + nField0 = ((const SfxUInt16Item*)pItem)->GetValue(); + aSortParam.bDoSort[0] = ( nField0 != 0 ); + aSortParam.nField[0] = nField0 ? (nField0-1) : 0; + if ( pArgs->GetItemState( FN_PARAM_2, TRUE, &pItem ) == SFX_ITEM_SET ) + aSortParam.bAscending[0] = ((const SfxBoolItem*)pItem)->GetValue(); + USHORT nField1 = 0; + if ( pArgs->GetItemState( FN_PARAM_3, TRUE, &pItem ) == SFX_ITEM_SET ) + nField1 = ((const SfxUInt16Item*)pItem)->GetValue(); + aSortParam.bDoSort[1] = ( nField1 != 0 ); + aSortParam.nField[1] = nField1 ? (nField1-1) : 0; + if ( pArgs->GetItemState( FN_PARAM_4, TRUE, &pItem ) == SFX_ITEM_SET ) + aSortParam.bAscending[1] = ((const SfxBoolItem*)pItem)->GetValue(); + USHORT nField2 = 0; + if ( pArgs->GetItemState( FN_PARAM_5, TRUE, &pItem ) == SFX_ITEM_SET ) + nField2 = ((const SfxUInt16Item*)pItem)->GetValue(); + aSortParam.bDoSort[2] = ( nField2 != 0 ); + aSortParam.nField[2] = nField2 ? (nField2-1) : 0; + if ( pArgs->GetItemState( FN_PARAM_6, TRUE, &pItem ) == SFX_ITEM_SET ) + aSortParam.bAscending[2] = ((const SfxBoolItem*)pItem)->GetValue(); + + // Teilergebnisse bei Bedarf neu + pTabViewShell->UISort( aSortParam ); + rReq.Done(); + } + else + { + ScSortDlg* pDlg = NULL; + ScSortParam aSortParam; + SfxItemSet aArgSet( GetPool(), SCITEM_SORTDATA, SCITEM_SORTDATA ); + + ScDBData* pDBData = pTabViewShell->GetDBData(); + pDBData->GetSortParam( aSortParam ); + + aArgSet.Put( ScSortItem( SCITEM_SORTDATA, GetViewData(), &aSortParam ) ); + pDlg = new ScSortDlg( pTabViewShell->GetDialogParent(), &aArgSet ); + pDlg->SetCurPageId(1); + + if ( pDlg->Execute() == RET_OK ) + { + const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); + const ScSortParam& rOutParam = ((const ScSortItem&) + pOutSet->Get( SCITEM_SORTDATA )).GetSortData(); + + // Teilergebnisse bei Bedarf neu + pTabViewShell->UISort( rOutParam ); + + if ( rOutParam.bInplace ) + { + rReq.AppendItem( SfxBoolItem( SID_SORT_BYROW, + rOutParam.bByRow ) ); + rReq.AppendItem( SfxBoolItem( SID_SORT_HASHEADER, + rOutParam.bHasHeader ) ); + rReq.AppendItem( SfxBoolItem( SID_SORT_CASESENS, + rOutParam.bCaseSens ) ); + rReq.AppendItem( SfxBoolItem( SID_SORT_ATTRIBS, + rOutParam.bIncludePattern ) ); + USHORT nUser = rOutParam.bUserDef ? ( rOutParam.nUserIndex + 1 ) : 0; + rReq.AppendItem( SfxUInt16Item( SID_SORT_USERDEF, nUser ) ); + if ( rOutParam.bDoSort[0] ) + { + rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, + rOutParam.nField[0] + 1 ) ); + rReq.AppendItem( SfxBoolItem( FN_PARAM_2, + rOutParam.bAscending[0] ) ); + } + if ( rOutParam.bDoSort[1] ) + { + rReq.AppendItem( SfxUInt16Item( FN_PARAM_3, + rOutParam.nField[1] + 1 ) ); + rReq.AppendItem( SfxBoolItem( FN_PARAM_4, + rOutParam.bAscending[1] ) ); + } + if ( rOutParam.bDoSort[2] ) + { + rReq.AppendItem( SfxUInt16Item( FN_PARAM_5, + rOutParam.nField[2] + 1 ) ); + rReq.AppendItem( SfxBoolItem( FN_PARAM_6, + rOutParam.bAscending[2] ) ); + } + } + + rReq.Done(); + } + + delete pDlg; + } + } + break; + +/* + { + + USHORT nId = ScPivotLayoutWrapper::GetChildWindowId(); + SfxChildWindow* pWnd = pSfxApp->GetChildWindow( nId ); + + pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE ); + + } + break; +*/ + + case SID_FILTER: + { + const SfxItemSet* pArgs = rReq.GetArgs(); + if ( pArgs ) + { + DBG_ERROR("SID_FILTER with arguments?"); + pTabViewShell->Query( ((const ScQueryItem&) + pArgs->Get( SCITEM_QUERYDATA )).GetQueryData(), NULL, TRUE ); + rReq.Done(); + } + else + { + USHORT nId = ScFilterDlgWrapper::GetChildWindowId(); + SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); + SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); + + pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE ); + } + } + break; + + case SID_SPECIAL_FILTER: + { + const SfxItemSet* pArgs = rReq.GetArgs(); + if ( pArgs ) + { + DBG_ERROR("SID_SPECIAL_FILTER with arguments?"); + pTabViewShell->Query( ((const ScQueryItem&) + pArgs->Get( SCITEM_QUERYDATA )).GetQueryData(), NULL, TRUE ); + rReq.Done(); + } + else + { + USHORT nId = ScSpecialFilterDlgWrapper::GetChildWindowId(); + SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); + SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); + + pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE ); + } + } + break; + + case FID_FILTER_OK: + { + const SfxItemSet* pOutSet = rReq.GetArgs(); + const ScQueryItem& rItem = (const ScQueryItem&) + pOutSet->Get( SCITEM_QUERYDATA ); + + USHORT nCurTab = GetViewData()->GetTabNo(); + USHORT nRefTab = GetViewData()->GetRefTabNo(); + + // Wenn RefInput auf andere Tabelle als Datentabelle umgeschaltet + // hat wieder zurueckschalten: + + if ( nCurTab != nRefTab ) + { + pTabViewShell->SetTabNo( nRefTab ); + pTabViewShell->PaintExtras(); + } + + ScRange aAdvSource; + if (rItem.GetAdvancedQuerySource(aAdvSource)) + pTabViewShell->Query( rItem.GetQueryData(), &aAdvSource, TRUE ); + else + pTabViewShell->Query( rItem.GetQueryData(), NULL, TRUE ); + rReq.Done( *pOutSet ); + } + break; + + case SID_UNFILTER: + { + ScQueryParam aParam; + ScDBData* pDBData = pTabViewShell->GetDBData(); + + pDBData->GetQueryParam( aParam ); + USHORT nEC = aParam.GetEntryCount(); + for (USHORT i=0; i<nEC; i++) + aParam.GetEntry(i).bDoQuery = FALSE; + aParam.bDuplicate = TRUE; + pTabViewShell->Query( aParam, NULL, TRUE ); + rReq.Done(); + } + break; + + case SID_AUTO_FILTER: + pTabViewShell->ToggleAutoFilter(); + rReq.Done(); + break; + + case SID_AUTOFILTER_HIDE: + pTabViewShell->HideAutoFilter(); + rReq.Done(); + break; + + case SID_PIVOT_TABLE: + { + const SfxPoolItem* pItem; + if ( pReqArgs && SFX_ITEM_SET == + pReqArgs->GetItemState( SCITEM_PIVOTDATA, TRUE, &pItem ) ) + { + USHORT nCurTab = GetViewData()->GetTabNo(); + USHORT nRefTab = GetViewData()->GetRefTabNo(); + + // Wenn RefInput auf andere Tabelle als Datentabelle umgeschaltet + // hat wieder zurueckschalten: + + if ( nCurTab != nRefTab ) + { + pTabViewShell->SetTabNo( nRefTab ); + pTabViewShell->PaintExtras(); + } + + const ScDPObject* pDPObject = pTabViewShell->GetDialogDPObject(); + if ( pDPObject ) + { + const ScPivotItem* pPItem = (const ScPivotItem*)pItem; + pTabViewShell->MakePivotTable( + pPItem->GetData(), + pPItem->GetDestRange(), + pPItem->IsNewSheet(), + *pDPObject ); + } + rReq.Done(); + } + else if (rReq.IsAPI()) + SbxBase::SetError(SbxERR_BAD_PARAMETER); + } + break; + + case SID_OPENDLG_PIVOTTABLE: + { + ScViewData* pViewData = GetViewData(); + ScDocument* pDoc = pViewData->GetDocument(); + + ScDPObject* pNewDPObject = NULL; + + // ScPivot is no longer used... + ScDPObject* pDPObj = pDoc->GetDPAtCursor( + pViewData->GetCurX(), pViewData->GetCurY(), + pViewData->GetTabNo() ); + if ( pDPObj ) // on an existing table? + { + pNewDPObject = new ScDPObject( *pDPObj ); + } + else // create new table + { + // select database range or data + pTabViewShell->GetDBData( TRUE, SC_DB_OLD ); + if ( !GetViewData()->GetMarkData().IsMarked() ) + pTabViewShell->MarkDataArea( FALSE ); + + // output to cursor position for non-sheet data + ScAddress aDestPos( pViewData->GetCurX(), pViewData->GetCurY(), + pViewData->GetTabNo() ); + + // first select type of source data + + BOOL bEnableExt = ScDPObject::HasRegisteredSources(); + ScDataPilotSourceTypeDlg* pTypeDlg = new ScDataPilotSourceTypeDlg( + pTabViewShell->GetDialogParent(), bEnableExt ); + if ( pTypeDlg->Execute() == RET_OK ) + { + if ( pTypeDlg->IsExternal() ) + { + uno::Sequence<rtl::OUString> aSources = ScDPObject::GetRegisteredSources(); + ScDataPilotServiceDlg* pServDlg = new ScDataPilotServiceDlg( + pTabViewShell->GetDialogParent(), aSources ); + if ( pServDlg->Execute() == RET_OK ) + { + ScDPServiceDesc aServDesc( + pServDlg->GetServiceName(), + pServDlg->GetParSource(), + pServDlg->GetParName(), + pServDlg->GetParUser(), + pServDlg->GetParPass() ); + pNewDPObject = new ScDPObject( pDoc ); + pNewDPObject->SetServiceData( aServDesc ); + } + delete pServDlg; + } + else if ( pTypeDlg->IsDatabase() ) + { + ScDataPilotDatabaseDlg* pDataDlg = new ScDataPilotDatabaseDlg( + pTabViewShell->GetDialogParent() ); + if ( pDataDlg->Execute() == RET_OK ) + { + ScImportSourceDesc aImpDesc; + pDataDlg->GetValues( aImpDesc ); + pNewDPObject = new ScDPObject( pDoc ); + pNewDPObject->SetImportDesc( aImpDesc ); + } + delete pDataDlg; + } + else // selection + { + //! use database ranges (select before type dialog?) + ScRange aRange; + if ( GetViewData()->GetSimpleArea( aRange ) ) + { + ScSheetSourceDesc aShtDesc; + aShtDesc.aSourceRange = aRange; + pNewDPObject = new ScDPObject( pDoc ); + pNewDPObject->SetSheetDesc( aShtDesc ); + + // output below source data + if ( aRange.aEnd.Row()+2 <= MAXROW - 4 ) + aDestPos = ScAddress( aRange.aStart.Col(), + aRange.aEnd.Row()+2, + aRange.aStart.Tab() ); + } + } + } + delete pTypeDlg; + + if ( pNewDPObject ) + pNewDPObject->SetOutRange( aDestPos ); + +#if 0 + ScDBData* pDBData = pTabViewShell->GetDBData(); + String aErrMsg; + + pDBData->GetArea( nTab, nCol1, nRow1, nCol2, nRow2 ); + + bAreaOk = TRUE; + if ( nRow2-nRow1 < 1 ) + { + // "mindestens eine Datenzeile" + pTabViewShell->ErrorMessage(STR_PIVOT_INVALID_DBAREA); + bAreaOk = FALSE; + } + else if (!pDBData->HasHeader()) + { + if ( MessBox( pTabViewShell->GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES), + ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), // "StarCalc" + ScGlobal::GetRscString( STR_MSSG_MAKEAUTOFILTER_0 ) // Koepfe aus erster Zeile? + ).Execute() == RET_YES ) + { + pDBData->SetHeader( TRUE ); //! Undo ?? + } + else + bAreaOk = FALSE; + } +#endif + } + + pTabViewShell->SetDialogDPObject( pNewDPObject ); // is copied + if ( pNewDPObject ) + { + // start layout dialog + + USHORT nId = ScPivotLayoutWrapper::GetChildWindowId(); + SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); + SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); + pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE ); + } + delete pNewDPObject; + } + break; + + case SID_DEFINE_DBNAME: + { + + USHORT nId = ScDbNameDlgWrapper::GetChildWindowId(); + SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); + SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); + + pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE ); + + } + break; + + case SID_SELECT_DB: + { + if ( pReqArgs ) + { + const SfxStringItem* pItem = + (const SfxStringItem*)&pReqArgs->Get( SID_SELECT_DB ); + + if( pItem ) + { + pTabViewShell->GotoDBArea( pItem->GetValue() ); + rReq.Done(); + } + else + DBG_ERROR("NULL"); + } + else + { + ScDocument* pDoc = GetViewData()->GetDocument(); + ScDBCollection* pDBCol = pDoc->GetDBCollection(); + + if ( pDBCol ) + { + const String aStrNoName( ScGlobal::GetRscString(STR_DB_NONAME) ); + List aList; + USHORT nDBCount = pDBCol->GetCount(); + ScDBData* pDbData = NULL; + String* pDBName = NULL; + + for ( USHORT i=0; i < nDBCount; i++ ) + { + pDbData = (ScDBData*)(pDBCol->At( i )); + if ( pDbData ) + { + pDBName = new String; + pDbData->GetName( *pDBName ); + + if ( *pDBName != aStrNoName ) + aList.Insert( pDBName ); + else + DELETEZ(pDBName); + } + } + + ScSelEntryDlg* pDlg = + new ScSelEntryDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_SELECTDB, + String(ScResId(SCSTR_SELECTDB)), + String(ScResId(SCSTR_AREAS)), + aList ); + + if ( pDlg->Execute() == RET_OK ) + { + pTabViewShell->GotoDBArea( pDlg->GetSelectEntry() ); + rReq.Done(); + } + + delete pDlg; + + void* pEntry = aList.First(); + while ( pEntry ) + { + delete (String*) aList.Remove( pEntry ); + pEntry = aList.Next(); + } + } + } + } + break; + + case FID_VALIDATION: + { + const SfxPoolItem* pItem; + const SfxItemSet* pArgs = rReq.GetArgs(); + if ( pArgs ) + { + DBG_ERROR("spaeter..."); + } + else + { + SfxItemSet aArgSet( GetPool(), FID_VALID_MODE, FID_VALID_ERRTEXT ); + + ScValidationMode eMode = SC_VALID_ANY; + ScConditionMode eOper = SC_COND_EQUAL; + String aExpr1, aExpr2; + BOOL bBlank = TRUE; + BOOL bShowHelp = FALSE; + String aHelpTitle, aHelpText; + BOOL bShowError = FALSE; + ScValidErrorStyle eErrStyle = SC_VALERR_STOP; + String aErrTitle, aErrText; + + ScDocument* pDoc = GetViewData()->GetDocument(); + USHORT nCurX = GetViewData()->GetCurX(); + USHORT nCurY = GetViewData()->GetCurY(); + USHORT nTab = GetViewData()->GetTabNo(); + ScAddress aCursorPos( nCurX, nCurY, nTab ); + ULONG nIndex = ((SfxUInt32Item*)pDoc->GetAttr( + nCurX, nCurY, nTab, ATTR_VALIDDATA ))->GetValue(); + if ( nIndex ) + { + const ScValidationData* pOldData = pDoc->GetValidationEntry( nIndex ); + if ( pOldData ) + { + eMode = pOldData->GetDataMode(); + eOper = pOldData->GetOperation(); + ULONG nNumFmt = 0; + if ( eMode == SC_VALID_DATE || eMode == SC_VALID_TIME ) + { + short nType = ( eMode == SC_VALID_DATE ) ? NUMBERFORMAT_DATE + : NUMBERFORMAT_TIME; + nNumFmt = pDoc->GetFormatTable()->GetStandardFormat( + nType, ScGlobal::eLnge ); + } + aExpr1 = pOldData->GetExpression( aCursorPos, 0, nNumFmt ); + aExpr2 = pOldData->GetExpression( aCursorPos, 1, nNumFmt ); + bBlank = pOldData->IsIgnoreBlank(); + + bShowHelp = pOldData->GetInput( aHelpTitle, aHelpText ); + bShowError = pOldData->GetErrMsg( aErrTitle, aErrText, eErrStyle ); + + aArgSet.Put( SfxAllEnumItem( FID_VALID_MODE, eMode ) ); + aArgSet.Put( SfxAllEnumItem( FID_VALID_CONDMODE, eOper ) ); + aArgSet.Put( SfxStringItem( FID_VALID_VALUE1, aExpr1 ) ); + aArgSet.Put( SfxStringItem( FID_VALID_VALUE2, aExpr2 ) ); + aArgSet.Put( SfxBoolItem( FID_VALID_BLANK, bBlank ) ); + aArgSet.Put( SfxBoolItem( FID_VALID_SHOWHELP, bShowHelp ) ); + aArgSet.Put( SfxStringItem( FID_VALID_HELPTITLE, aHelpTitle ) ); + aArgSet.Put( SfxStringItem( FID_VALID_HELPTEXT, aHelpText ) ); + aArgSet.Put( SfxBoolItem( FID_VALID_SHOWERR, bShowError ) ); + aArgSet.Put( SfxAllEnumItem( FID_VALID_ERRSTYLE, eErrStyle ) ); + aArgSet.Put( SfxStringItem( FID_VALID_ERRTITLE, aErrTitle ) ); + aArgSet.Put( SfxStringItem( FID_VALID_ERRTEXT, aErrText ) ); + } + } + + ScValidationDlg* pDlg = new ScValidationDlg( NULL, &aArgSet ); + if ( pDlg->Execute() == RET_OK ) + { + const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); + + if ( pOutSet->GetItemState( FID_VALID_MODE, TRUE, &pItem ) == SFX_ITEM_SET ) + eMode = (ScValidationMode) ((const SfxAllEnumItem*)pItem)->GetValue(); + if ( pOutSet->GetItemState( FID_VALID_CONDMODE, TRUE, &pItem ) == SFX_ITEM_SET ) + eOper = (ScConditionMode) ((const SfxAllEnumItem*)pItem)->GetValue(); + if ( pOutSet->GetItemState( FID_VALID_VALUE1, TRUE, &pItem ) == SFX_ITEM_SET ) + aExpr1 = ((const SfxStringItem*)pItem)->GetValue(); + if ( pOutSet->GetItemState( FID_VALID_VALUE2, TRUE, &pItem ) == SFX_ITEM_SET ) + aExpr2 = ((const SfxStringItem*)pItem)->GetValue(); + if ( pOutSet->GetItemState( FID_VALID_BLANK, TRUE, &pItem ) == SFX_ITEM_SET ) + bBlank = ((const SfxBoolItem*)pItem)->GetValue(); + + if ( pOutSet->GetItemState( FID_VALID_SHOWHELP, TRUE, &pItem ) == SFX_ITEM_SET ) + bShowHelp = ((const SfxBoolItem*)pItem)->GetValue(); + if ( pOutSet->GetItemState( FID_VALID_HELPTITLE, TRUE, &pItem ) == SFX_ITEM_SET ) + aHelpTitle = ((const SfxStringItem*)pItem)->GetValue(); + if ( pOutSet->GetItemState( FID_VALID_HELPTEXT, TRUE, &pItem ) == SFX_ITEM_SET ) + aHelpText = ((const SfxStringItem*)pItem)->GetValue(); + + if ( pOutSet->GetItemState( FID_VALID_SHOWERR, TRUE, &pItem ) == SFX_ITEM_SET ) + bShowError = ((const SfxBoolItem*)pItem)->GetValue(); + if ( pOutSet->GetItemState( FID_VALID_ERRSTYLE, TRUE, &pItem ) == SFX_ITEM_SET ) + eErrStyle = (ScValidErrorStyle) ((const SfxAllEnumItem*)pItem)->GetValue(); + if ( pOutSet->GetItemState( FID_VALID_ERRTITLE, TRUE, &pItem ) == SFX_ITEM_SET ) + aErrTitle = ((const SfxStringItem*)pItem)->GetValue(); + if ( pOutSet->GetItemState( FID_VALID_ERRTEXT, TRUE, &pItem ) == SFX_ITEM_SET ) + aErrText = ((const SfxStringItem*)pItem)->GetValue(); + + USHORT nTab = GetViewData()->GetTabNo(); + ScValidationData aData( eMode, eOper, aExpr1, aExpr2, pDoc, aCursorPos ); + aData.SetIgnoreBlank( bBlank ); + if (bShowHelp) + aData.SetInput(aHelpTitle, aHelpText); + else + aData.ResetInput(); + if (bShowError) + aData.SetError(aErrTitle, aErrText, eErrStyle); + else + aData.ResetError(); + + pTabViewShell->SetValidation( aData ); + rReq.Done( *pOutSet ); + } + delete pDlg; + } + } + break; + } +} + +void __EXPORT ScCellShell::GetDBState( SfxItemSet& rSet ) +{ + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + ScViewData* pViewData = GetViewData(); + ScDocShell* pDocSh = pViewData->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + USHORT nPosX = pViewData->GetCurX(); + USHORT nPosY = pViewData->GetCurY(); + USHORT nTab = pViewData->GetTabNo(); + + BOOL bAutoFilter; + BOOL bAutoFilterTested = FALSE; + + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + while (nWhich) + { + switch (nWhich) + { + case SID_REFRESH_DBAREA: + { + // importierte Daten ohne Selektion + // oder Filter,Sortierung,Teilergebis (auch ohne Import) + BOOL bOk = FALSE; + ScDBData* pDBData = pTabViewShell->GetDBData(FALSE,SC_DB_OLD); + if (pDBData && pDoc->GetChangeTrack() == NULL) + { + if ( pDBData->HasImportParam() ) + bOk = !pDBData->HasImportSelection(); + else + { + bOk = pDBData->HasQueryParam() || + pDBData->HasSortParam() || + pDBData->HasSubTotalParam(); + if (!bOk) + { + // Pivottabelle mit den Daten als Quellbereich ? + ScRange aDataRange; + pDBData->GetArea(aDataRange); + ScPivotCollection* pPivotCollection = pDoc->GetPivotCollection(); + USHORT nCount = pPivotCollection ? pPivotCollection->GetCount() : 0; + for (USHORT i=0; i<nCount; i++) + { + ScPivot* pTemp = (*pPivotCollection)[i]; + if ( pTemp && pTemp->GetSrcArea().Intersects( aDataRange ) ) + bOk = TRUE; + } + } + } + } + if (!bOk) + rSet.DisableItem( nWhich ); + } + break; + + case SID_FILTER: + case SID_SPECIAL_FILTER: + { + ScMarkData& rMark = GetViewData()->GetMarkData(); + + if (rMark.IsMultiMarked()) + { + rSet.DisableItem( nWhich ); + } + } + break; + + + //Bei Redlining und Multiselektion Disablen + case SID_SORT_ASCENDING: + case SID_SORT_DESCENDING: + case SCITEM_SORTDATA: + case SCITEM_SUBTDATA: + case SID_OPENDLG_PIVOTTABLE: + { + //! move ReadOnly check to idl flags + + ScMarkData& rMark = GetViewData()->GetMarkData(); + if ( pDocSh->IsReadOnly() || pDoc->GetChangeTrack()!=NULL || + rMark.IsMultiMarked() ) + { + rSet.DisableItem( nWhich ); + } + } + break; + + case SID_REIMPORT_DATA: + { + // nur importierte Daten ohne Selektion + ScDBData* pDBData = pTabViewShell->GetDBData(FALSE,SC_DB_OLD); + if (!pDBData || !pDBData->HasImportParam() || pDBData->HasImportSelection() || + pDoc->GetChangeTrack()!=NULL) + { + rSet.DisableItem( nWhich ); + } + } + break; + + case SID_IMPORT_DATA: + { + if(pDoc->GetChangeTrack()!=NULL) + rSet.DisableItem( nWhich ); +/* Import (F4) ist immer moeglich, Default ist Adressbuch + + // importierte Daten auch mit Selektion + ScDBData* pDBData = GetDBData(FALSE,SC_DB_OLD); + if (!pDBData || !pDBData->HasImportParam()) + rSet.DisableItem( nWhich ); +*/ + } + break; + case SID_SBA_BRW_INSERT: + { + // SBA will ein BOOL-Item, damit ueberhaupt enabled + + BOOL bEnable = TRUE; + rSet.Put(SfxBoolItem(nWhich, bEnable)); + } + break; + + case SID_AUTO_FILTER: + case SID_AUTOFILTER_HIDE: + { + if (!bAutoFilterTested) + { + bAutoFilter = pDoc->HasAutoFilter( nPosX, nPosY, nTab ); + bAutoFilterTested = TRUE; + } + if ( nWhich == SID_AUTO_FILTER ) + { + ScMarkData& rMark = GetViewData()->GetMarkData(); + + if (rMark.IsMultiMarked()) + { + rSet.DisableItem( nWhich ); + } + else + rSet.Put( SfxBoolItem( nWhich, bAutoFilter ) ); + } + else + if (!bAutoFilter) + rSet.DisableItem( nWhich ); + } + break; + + case SID_UNFILTER: + { + USHORT nStartCol, nStartRow, nStartTab; + USHORT nEndCol, nEndRow, nEndTab; + BOOL bAnyQuery = FALSE; + + ScMarkData& rMark = GetViewData()->GetMarkData(); + BOOL bSelected = rMark.IsMarked(); + + if ( bSelected ) + { + GetViewData()->GetSimpleArea( nStartCol, nStartRow, nStartTab, + nEndCol, nEndRow, nEndTab ); + if (nStartCol==nEndCol && nStartRow==nEndRow) + bSelected = FALSE; + } + else + { + nStartCol = GetViewData()->GetCurX(); + nStartRow = GetViewData()->GetCurY(); + nStartTab = GetViewData()->GetTabNo(); + } + + ScDBData* pDBData = bSelected + ? pDoc->GetDBAtArea( nStartTab, nStartCol, nStartRow, nEndCol, nEndRow ) + : pDoc->GetDBAtCursor( nStartCol, nStartRow, nStartTab ); + + if ( pDBData ) + { + ScQueryParam aParam; + pDBData->GetQueryParam( aParam ); + if ( aParam.GetEntry(0).bDoQuery ) + bAnyQuery = TRUE; + } + + if ( !bAnyQuery ) + rSet.DisableItem( nWhich ); + } + break; + } + nWhich = aIter.NextWhich(); + } +} + + + diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx new file mode 100644 index 000000000000..78226b58a0ee --- /dev/null +++ b/sc/source/ui/view/cellsh3.cxx @@ -0,0 +1,870 @@ +/************************************************************************* + * + * $RCSfile: cellsh3.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/request.hxx> +#include <svtools/stritem.hxx> +#include <vcl/msgbox.hxx> + +#include "globstr.hrc" +#include "scmod.hxx" +#include "appoptio.hxx" +#include "tabvwsh.hxx" +#include "document.hxx" +#include "sc.hrc" +#include "docsh.hxx" +#include "reffact.hxx" +#include "uiitems.hxx" +#include "scendlg.hxx" +#include "mtrindlg.hxx" +#include "autoform.hxx" +#include "autofmt.hxx" +#include "cellsh.hxx" + +#define IS_EDITMODE() GetViewData()->HasEditView( GetViewData()->GetActivePart() ) + +//------------------------------------------------------------------ + +void ScCellShell::Execute( SfxRequest& rReq ) +{ + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings(); + SfxApplication* pSfxApp = SFX_APP(); + ScModule* pScMod = SC_MOD(); + const SfxItemSet* pReqArgs = rReq.GetArgs(); + USHORT nSlot = rReq.GetSlot(); + + if (nSlot != SID_CURRENTCELL) // der kommt beim MouseButtonUp + pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox + + if ( IS_EDITMODE() ) + { + switch ( nSlot ) + { + // beim Oeffnen eines Referenz-Dialogs darf die SubShell nicht umgeschaltet werden + // (beim Schliessen des Dialogs wird StopEditShell gerufen) + case SID_OPENDLG_FUNCTION: + case SID_OPENDLG_CHART: + // #53318# inplace macht die EditShell Aerger... + //! kann nicht immer umgeschaltet werden ???? + if (!pTabViewShell->GetViewFrame()->ISA(SfxInPlaceFrame)) + pTabViewShell->SetDontSwitch(TRUE); // EditShell nicht abschalten + // kein break + + case FID_CELL_FORMAT: + case SID_DATA_SELECT: + case SID_OPENDLG_CONSOLIDATE: + case SID_OPENDLG_SOLVE: + + pScMod->InputEnterHandler(); + pTabViewShell->UpdateInputHandler(); + + pTabViewShell->SetDontSwitch(FALSE); + + break; + + default: + break; + } + } + + switch ( nSlot ) + { + + + + case SID_ATTR_SIZE://XXX ??? + break; + + case SID_STATUS_SELMODE: + if ( pReqArgs ) + { + /* 0: STD Click hebt Sel auf + * 1: ER Click erweitert Selektion + * 2: ERG Click definiert weitere Selektion + */ + UINT16 nMode = ((const SfxUInt16Item&)pReqArgs->Get( nSlot )).GetValue(); + + switch ( nMode ) + { + case 1: nMode = KEY_SHIFT; break; + case 2: nMode = KEY_MOD1; break; // Control-Taste + case 0: + default: + nMode = 0; + } + + pTabViewShell->LockModifiers( nMode ); + rBindings.Invalidate( SID_STATUS_SELMODE ); + + rReq.Done(); + } + break; + + // SID_STATUS_SELMODE_NORM wird nicht benutzt ??? + + case SID_STATUS_SELMODE_NORM: + pTabViewShell->LockModifiers( 0 ); + rBindings.Invalidate( SID_STATUS_SELMODE ); + break; + + // SID_STATUS_SELMODE_ERG / SID_STATUS_SELMODE_ERW als Toggles: + + case SID_STATUS_SELMODE_ERG: + if ( pTabViewShell->GetLockedModifiers() & KEY_MOD1 ) + pTabViewShell->LockModifiers( 0 ); + else + pTabViewShell->LockModifiers( KEY_MOD1 ); + rBindings.Invalidate( SID_STATUS_SELMODE ); + break; + + case SID_STATUS_SELMODE_ERW: + if ( pTabViewShell->GetLockedModifiers() & KEY_SHIFT ) + pTabViewShell->LockModifiers( 0 ); + else + pTabViewShell->LockModifiers( KEY_SHIFT ); + rBindings.Invalidate( SID_STATUS_SELMODE ); + break; + + case SID_ENTER_STRING: + { + if ( pReqArgs ) + { + String aStr( ((const SfxStringItem&)pReqArgs-> + Get( SID_ENTER_STRING )).GetValue() ); + + pTabViewShell->EnterData( GetViewData()->GetCurX(), + GetViewData()->GetCurY(), + GetViewData()->GetTabNo(), + aStr ); + + rReq.Done(); + + // hier kein GrabFocus, weil sonst auf dem Mac die Tabelle vor die + // Seitenansicht springt, wenn die Eingabe nicht abgeschlossen war + // (GrabFocus passiert in KillEditView) + } + } + break; + + case SID_INSERT_MATRIX: + { + if ( pReqArgs ) + { + String aStr = ((const SfxStringItem&)pReqArgs-> + Get( SID_INSERT_MATRIX )).GetValue(); + pTabViewShell->EnterMatrix( aStr ); + rReq.Done(); + } + } + break; + + case FID_INPUTLINE_ENTER: + case FID_INPUTLINE_BLOCK: + case FID_INPUTLINE_MATRIX: + { + if( pReqArgs == 0 ) //XXX vorlaufiger HACK um GPF zu vermeiden + break; + + const ScInputStatusItem* pStatusItem + = (const ScInputStatusItem*)&pReqArgs-> + Get( FID_INPUTLINE_STATUS ); + + ScAddress aCursorPos = pStatusItem->GetPos(); + const EditTextObject* pData = pStatusItem->GetEditData(); + if (pData) + { + if (nSlot == FID_INPUTLINE_BLOCK) + pTabViewShell->EnterBlock( String(), pData ); + else + pTabViewShell->EnterData( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(), pData ); + } + else + { + String aString = pStatusItem->GetString(); + if (nSlot == FID_INPUTLINE_ENTER) + { + if ( + aCursorPos.Col() == GetViewData()->GetCurX() && + aCursorPos.Row() == GetViewData()->GetCurY() && + aCursorPos.Tab() == GetViewData()->GetTabNo() + ) + { + SfxStringItem aItem( SID_ENTER_STRING, aString ); + + SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings(); + const SfxPoolItem* aArgs[2]; + aArgs[0] = &aItem; + aArgs[1] = NULL; + rBindings.Execute( SID_ENTER_STRING, aArgs ); + } + else + { + pTabViewShell->EnterData( aCursorPos.Col(), + aCursorPos.Row(), + aCursorPos.Tab(), + aString ); + rReq.Done(); + } + } + else if (nSlot == FID_INPUTLINE_BLOCK) + { + pTabViewShell->EnterBlock( aString, NULL ); + rReq.Done(); + } + else + { + pTabViewShell->EnterMatrix( aString ); + rReq.Done(); + } + + } + + // hier kein GrabFocus, weil sonst auf dem Mac die Tabelle vor die + // Seitenansicht springt, wenn die Eingabe nicht abgeschlossen war + // (GrabFocus passiert in KillEditView) + } + break; + + + case SID_OPENDLG_CHART: + { + BOOL bChartDlgIsEdit = ( nSlot == SID_OPENDLG_MODCHART ); + pTabViewShell->SetChartDlgEdit(bChartDlgIsEdit); + + if (bChartDlgIsEdit) + { + pTabViewShell->SetEditChartName(pTabViewShell->GetSelectedChartName()); + pTabViewShell->DrawDeselectAll(); // flackert sonst bei Ref-Input + } + + pTabViewShell->ResetChartArea(); + + USHORT nId = ScChartDlgWrapper::GetChildWindowId(); + SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); + SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); + + pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE ); + } + break; + + case SID_OPENDLG_FUNCTION: + { + USHORT nId = SID_OPENDLG_FUNCTION; + SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); + SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); + + pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE ); + } + break; + + case SID_OPENDLG_CONSOLIDATE: + { + USHORT nId = ScConsolidateDlgWrapper::GetChildWindowId(); + SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); + SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); + + pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE ); + } + break; + + case FID_CELL_FORMAT: + { + if ( pReqArgs != NULL ) + { + //---------------------------------- + // Zellattribute ohne Dialog setzen: + //---------------------------------- + SfxItemSet* pEmptySet = + new SfxItemSet( *pReqArgs->GetPool(), + ATTR_PATTERN_START, + ATTR_PATTERN_END ); + + SfxItemSet* pNewSet = + new SfxItemSet( *pReqArgs->GetPool(), + ATTR_PATTERN_START, + ATTR_PATTERN_END ); + + const SfxPoolItem* pAttr = NULL; + USHORT nWhich = 0; + + for ( nWhich=ATTR_PATTERN_START; nWhich<=ATTR_PATTERN_END; nWhich++ ) + if ( pReqArgs->GetItemState( nWhich, TRUE, &pAttr ) == SFX_ITEM_SET ) + pNewSet->Put( *pAttr ); + + pTabViewShell->ApplyAttributes( pNewSet, pEmptySet ); + + delete pNewSet; + delete pEmptySet; + + rReq.Done(); + } + else if ( pReqArgs == NULL ) + { + pTabViewShell->ExecuteCellFormatDlg( rReq ); + } + } + break; + + case SID_OPENDLG_SOLVE: + { + USHORT nId = ScSolverDlgWrapper::GetChildWindowId(); + SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); + SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); + + pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE ); + } + break; + + case SID_OPENDLG_TABOP: + { + USHORT nId = ScTabOpDlgWrapper::GetChildWindowId(); + SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); + SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); + + pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE ); + } + break; + + case SID_SCENARIOS: + { + ScDocument* pDoc = GetViewData()->GetDocument(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + USHORT nTab = GetViewData()->GetTabNo(); + + if ( pDoc->IsScenario(nTab) ) + { + rMark.MarkToMulti(); + if ( rMark.IsMultiMarked() ) + { + if ( rReq.IsAPI() + || RET_YES == + QueryBox( pTabViewShell->GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES), + ScGlobal::GetRscString(STR_UPDATE_SCENARIO) ). + Execute() ) + { + pTabViewShell->ExtendScenario(); + rReq.Done(); + } + } + else if( ! rReq.IsAPI() ) + { + ErrorBox aErrorBox( pTabViewShell->GetDialogParent(), WinBits(WB_OK | WB_DEF_OK), + ScGlobal::GetRscString(STR_NOAREASELECTED) ); + aErrorBox.Execute(); + } + } + else + { + rMark.MarkToMulti(); + if ( rMark.IsMultiMarked() ) + { + USHORT i=1; + String aBaseName; + String aName; + String aComment; + Color aColor; + USHORT nFlags; + + pDoc->GetName( nTab, aBaseName ); + aBaseName += '_'; + aBaseName += ScGlobal::GetRscString(STR_SCENARIO); + aBaseName += '_'; + + // vorneweg testen, ob der Prefix als gueltig erkannt wird + // wenn nicht, nur doppelte vermeiden + BOOL bPrefix = pDoc->ValidTabName( aBaseName ); + DBG_ASSERT(bPrefix, "ungueltiger Tabellenname"); + + while ( pDoc->IsScenario(nTab+i) ) + i++; + + BOOL bValid; + USHORT nDummy; + do + { + aName = aBaseName; + aName += String::CreateFromInt32( i ); + if (bPrefix) + bValid = pDoc->ValidNewTabName( aName ); + else + bValid = !pDoc->GetTable( aName, nDummy ); + ++i; + } + while ( !bValid && i <= 2*MAXTAB ); + + if ( pReqArgs != NULL ) + { + String aName; + String aComment; + const SfxPoolItem* pItem; + if ( pReqArgs->GetItemState( SID_SCENARIOS, TRUE, &pItem ) == SFX_ITEM_SET ) + aName = ((const SfxStringItem*)pItem)->GetValue(); + if ( pReqArgs->GetItemState( SID_NEW_TABLENAME, TRUE, &pItem ) == SFX_ITEM_SET ) + aComment = ((const SfxStringItem*)pItem)->GetValue(); + + aColor = Color( COL_LIGHTGRAY ); // Default + nFlags = 0; // nicht-TwoWay + + pTabViewShell->MakeScenario( aName, aComment, aColor, nFlags ); + if( ! rReq.IsAPI() ) + rReq.Done(); + } + else + { + ScNewScenarioDlg* pNewDlg = + new ScNewScenarioDlg( pTabViewShell->GetDialogParent(), aName ); + + if ( pNewDlg->Execute() == RET_OK ) + { + pNewDlg->GetScenarioData( aName, aComment, aColor, nFlags ); + pTabViewShell->MakeScenario( aName, aComment, aColor, nFlags ); + + rReq.AppendItem( SfxStringItem( SID_SCENARIOS, aName ) ); + rReq.AppendItem( SfxStringItem( SID_NEW_TABLENAME, aComment ) ); + rReq.Done(); + } + delete pNewDlg; + } + } + else if( ! rReq.IsAPI() ) + { + pTabViewShell->ErrorMessage(STR_ERR_NEWSCENARIO); + } + } + } + break; + + + case SID_SELECTALL: + { + pTabViewShell->SelectAll(); + rReq.Done(); + } + break; + + //---------------------------------------------------------------- + + case FID_ROW_HEIGHT: + { + if ( pReqArgs ) + { + const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_ROW_HEIGHT ); + + pTabViewShell->SetMarkedWidthOrHeight( FALSE, SC_SIZE_DIRECT, rUInt16Item.GetValue() ); + if( ! rReq.IsAPI() ) + rReq.Done(); + } + else + { + ScViewData* pViewData = GetViewData(); + FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric(); + USHORT nCurHeight = pViewData->GetDocument()-> + GetRowHeight( pViewData->GetCurY(), + pViewData->GetTabNo() ); + ScMetricInputDlg* pDlg = + new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_MAN, + nCurHeight, + ScGlobal::nStdRowHeight, + eMetric, + 2, + MAX_COL_HEIGHT ); + + if ( pDlg->Execute() == RET_OK ) + { + long nVal = pDlg->GetInputValue(); + pTabViewShell->SetMarkedWidthOrHeight( FALSE, SC_SIZE_DIRECT, (USHORT)nVal ); + + rReq.AppendItem( SfxUInt16Item( FID_ROW_HEIGHT, (USHORT)nVal ) ); + rReq.Done(); + + } + delete pDlg; + } + } + break; + + case FID_ROW_OPT_HEIGHT: + { + if ( pReqArgs ) + { + const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_ROW_OPT_HEIGHT ); + + pTabViewShell->SetMarkedWidthOrHeight( FALSE, SC_SIZE_OPTIMAL, rUInt16Item.GetValue() ); + ScGlobal::nLastRowHeightExtra = rUInt16Item.GetValue(); + + if( ! rReq.IsAPI() ) + rReq.Done(); + } + else + { + FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric(); + + ScMetricInputDlg* pDlg = + new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_OPT, + ScGlobal::nLastRowHeightExtra, + 0, + eMetric, + 1, + MAX_EXTRA_HEIGHT ); + + if ( pDlg->Execute() == RET_OK ) + { + long nVal = pDlg->GetInputValue(); + pTabViewShell->SetMarkedWidthOrHeight( FALSE, SC_SIZE_OPTIMAL, (USHORT)nVal ); + ScGlobal::nLastRowHeightExtra = nVal; + + rReq.AppendItem( SfxUInt16Item( FID_ROW_OPT_HEIGHT, (USHORT)nVal ) ); + rReq.Done(); + + } + delete pDlg; + } + } + break; + + case FID_COL_WIDTH: + { + if ( pReqArgs ) + { + const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_COL_WIDTH ); + + pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_DIRECT, rUInt16Item.GetValue() ); + if( ! rReq.IsAPI() ) + rReq.Done(); + } + else + { + FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric(); + ScViewData* pViewData = GetViewData(); + USHORT nCurHeight = pViewData->GetDocument()-> + GetColWidth( pViewData->GetCurX(), + pViewData->GetTabNo() ); + ScMetricInputDlg* pDlg = + new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_MAN, + nCurHeight, + STD_COL_WIDTH, + eMetric, + 2, + MAX_COL_WIDTH ); + + if ( pDlg->Execute() == RET_OK ) + { + long nVal = pDlg->GetInputValue(); + pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_DIRECT, (USHORT)nVal ); + + rReq.AppendItem( SfxUInt16Item( FID_COL_WIDTH, (USHORT)nVal) ); + rReq.Done(); + + } + delete pDlg; + } + } + break; + + case FID_COL_OPT_WIDTH: + { + if ( pReqArgs ) + { + const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_COL_OPT_WIDTH ); + + pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_OPTIMAL, rUInt16Item.GetValue() ); + ScGlobal::nLastColWidthExtra = rUInt16Item.GetValue(); + + if( ! rReq.IsAPI() ) + rReq.Done(); + } + else + { + FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric(); + + ScMetricInputDlg* pDlg = + new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_OPT, + ScGlobal::nLastColWidthExtra, + STD_EXTRA_WIDTH, + eMetric, + 1, + MAX_EXTRA_WIDTH ); + + if ( pDlg->Execute() == RET_OK ) + { + long nVal = pDlg->GetInputValue(); + pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_OPTIMAL, (USHORT)nVal ); + ScGlobal::nLastColWidthExtra = nVal; + + rReq.AppendItem( SfxUInt16Item( FID_COL_OPT_WIDTH, (USHORT)nVal ) ); + rReq.Done(); + } + delete pDlg; + } + } + break; + + case FID_COL_OPT_DIRECT: + pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH ); + rReq.Done(); + break; + + case FID_ROW_HIDE: + pTabViewShell->SetMarkedWidthOrHeight( FALSE, SC_SIZE_DIRECT, 0 ); + rReq.Done(); + break; + case FID_ROW_SHOW: + pTabViewShell->SetMarkedWidthOrHeight( FALSE, SC_SIZE_SHOW, 0 ); + rReq.Done(); + break; + case FID_COL_HIDE: + pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_DIRECT, 0 ); + rReq.Done(); + break; + case FID_COL_SHOW: + pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_SHOW, 0 ); + rReq.Done(); + break; + + //---------------------------------------------------------------- + + + case SID_CELL_FORMAT_RESET: + { + pTabViewShell->DeleteContents( IDF_HARDATTR | IDF_EDITATTR ); + rReq.Done(); + } + break; + + case FID_MERGE_ON: + { + if ( !GetViewData()->GetDocument()->GetChangeTrack() ) + { + BOOL bMoveContents = FALSE; + BOOL bApi = rReq.IsAPI(); + const SfxPoolItem* pItem; + if ( pReqArgs && + pReqArgs->GetItemState(FID_MERGE_ON, TRUE, &pItem) == SFX_ITEM_SET ) + { + DBG_ASSERT(pItem && pItem->ISA(SfxBoolItem), "falsches Item"); + bMoveContents = ((const SfxBoolItem*)pItem)->GetValue(); + } + + if (pTabViewShell->MergeCells( bApi, bMoveContents )) + { + if (!bApi && bMoveContents) // "ja" im Dialog geklickt + { + rReq.AppendItem( SfxBoolItem( FID_MERGE_ON, bMoveContents ) ); + } + rReq.Done(); + } + } + } + break; + case FID_MERGE_OFF: + if ( !GetViewData()->GetDocument()->GetChangeTrack() ) + { + if (pTabViewShell->RemoveMerge()) + rReq.Done(); + } + break; + + case SID_AUTOFORMAT: + { + Window* pDlgParent = pTabViewShell->GetDialogParent(); + USHORT nStartCol; + USHORT nStartRow; + USHORT nStartTab; + USHORT nEndCol; + USHORT nEndRow; + USHORT nEndTab; + + if ( !GetViewData()->GetMarkData().IsMarked() ) + pTabViewShell->MarkDataArea( TRUE ); + + GetViewData()->GetSimpleArea( nStartCol,nStartRow,nStartTab, + nEndCol,nEndRow,nEndTab ); + + if ( ( Abs((short)nEndCol-(short)nStartCol) > 1 ) + && ( Abs((short)nEndRow-(short)nStartRow) > 1 ) ) + { + if ( pReqArgs ) + { + const SfxStringItem& rNameItem = (const SfxStringItem&)pReqArgs->Get( SID_AUTOFORMAT ); + ScAutoFormat* pFormat = ScGlobal::GetAutoFormat(); + USHORT nIndex = pFormat->FindIndexPerName( rNameItem.GetValue() ); + + pTabViewShell->AutoFormat( nIndex ); + + if( ! rReq.IsAPI() ) + rReq.Done(); + } + else + { + ScGlobal::ClearAutoFormat(); + ScAutoFormatData* pNewEntry = pTabViewShell->CreateAutoFormatData(); + ScAutoFormatDlg* pDlg = new ScAutoFormatDlg( + pDlgParent, + ScGlobal::GetAutoFormat(), + pNewEntry ); + + if ( pDlg->Execute() == RET_OK ) + { + if ( !pTabViewShell->SelectionEditable() ) + { + pTabViewShell->ErrorMessage(STR_PROTECTIONERR); + } + else + { + pTabViewShell->AutoFormat( pDlg->GetIndex() ); + + rReq.AppendItem( SfxStringItem( SID_AUTOFORMAT, pDlg->GetCurrFormatName() ) ); + rReq.Done(); + } + } + delete pDlg; + delete pNewEntry; + } + } + else + ErrorBox( pDlgParent, WinBits( WB_OK | WB_DEF_OK ), + ScGlobal::GetRscString(STR_INVALID_AFAREA) ).Execute(); + } + break; + + case SID_CANCEL: + { + if (GetViewData()->HasEditView(GetViewData()->GetActivePart())) + pScMod->InputCancelHandler(); + else if (pTabViewShell->HasHintWindow()) + pTabViewShell->RemoveHintWindow(); // Eingabemeldung abschalten + else + { + SfxObjectShell* pObjSh = GetViewData()->GetSfxDocShell(); + if (pObjSh->GetInPlaceObject() && + pObjSh->GetInPlaceObject()->GetIPClient()) + { + GetViewData()->GetDocShell()-> + DoInPlaceActivate(FALSE); // OLE beenden + } + } + +// SetSumAssignMode(); //ScInputWindow + } + break; + + case SID_DATA_SELECT: + pTabViewShell->StartDataSelect(); + break; + + case SID_DETECTIVE_FILLMODE: + { + BOOL bOldMode = pTabViewShell->IsAuditShell(); + pTabViewShell->SetAuditShell( !bOldMode ); + pTabViewShell->Invalidate( nSlot ); + } + break; + + case SID_OPENDLG_CONDFRMT: + { + USHORT nId = ScCondFormatDlgWrapper::GetChildWindowId(); + SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); + SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); + + pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE ); + } + break; + + // ---------------------------------------------------------------- + + case FID_INPUTLINE_STATUS: + DBG_ERROR("Execute von InputLine-Status"); + break; + + + case SID_STATUS_DOCPOS: + { + //! Navigator an-/ausschalten (wie im Writer) ??? + //!SFX_DISPATCHER().Execute( SID_NAVIGATOR, + //! SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD ); + } + break; + + + case SID_MARKAREA: + // called from Basic at the hidden view to select a range in the visible view + DBG_ERROR("old slot SID_MARKAREA"); + break; + + default: + DBG_ERROR("Unbekannter Slot bei ScCellShell::Execute"); + break; + } +} + + + diff --git a/sc/source/ui/view/cellsh4.cxx b/sc/source/ui/view/cellsh4.cxx new file mode 100644 index 000000000000..9319b3bc2245 --- /dev/null +++ b/sc/source/ui/view/cellsh4.cxx @@ -0,0 +1,359 @@ +/************************************************************************* + * + * $RCSfile: cellsh4.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +#ifdef WNT +#pragma optimize ("", off) +#endif + +// INCLUDE --------------------------------------------------------------- + +#include <sfx2/request.hxx> + +#include "cellsh.hxx" +#include "tabvwsh.hxx" +#include "global.hxx" +#include "scmod.hxx" +#include "sc.hrc" + + +//------------------------------------------------------------------ + +#define IS_AVAILABLE(WhichId,ppItem) \ + (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET) + + +void ScCellShell::ExecuteCursor( SfxRequest& rReq ) +{ + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + const SfxItemSet* pReqArgs = rReq.GetArgs(); + USHORT nSlotId = rReq.GetSlot(); + short nRepeat = 1; + BOOL bSel = FALSE; + + if ( pReqArgs != NULL ) + { + const SfxPoolItem* pItem; + if( IS_AVAILABLE( FN_PARAM_1, &pItem ) ) + nRepeat = ((const SfxInt16Item*)pItem)->GetValue(); + if( IS_AVAILABLE( FN_PARAM_2, &pItem ) ) + bSel = ((const SfxBoolItem*)pItem)->GetValue(); + } + + // einmal extra, damit der Cursor bei ExecuteInputDirect nicht zuoft gemalt wird: + pTabViewShell->HideAllCursors(); + + //OS: einmal fuer alle wird doch reichen! + pTabViewShell->ExecuteInputDirect(); + switch ( nSlotId ) + { + case SID_CURSORDOWN: + pTabViewShell->MoveCursorRel( 0, nRepeat, SC_FOLLOW_LINE, bSel ); + break; + + case SID_CURSORBLKDOWN: + pTabViewShell->MoveCursorArea( 0, nRepeat, SC_FOLLOW_JUMP, bSel ); + break; + + case SID_CURSORUP: + pTabViewShell->MoveCursorRel( 0, -nRepeat, SC_FOLLOW_LINE, bSel ); + break; + + case SID_CURSORBLKUP: + pTabViewShell->MoveCursorArea( 0, -nRepeat, SC_FOLLOW_JUMP, bSel ); + break; + + case SID_CURSORLEFT: + pTabViewShell->MoveCursorRel( -nRepeat, 0, SC_FOLLOW_LINE, bSel ); + break; + + case SID_CURSORBLKLEFT: + pTabViewShell->MoveCursorArea( -nRepeat, 0, SC_FOLLOW_JUMP, bSel ); + break; + + case SID_CURSORRIGHT: + pTabViewShell->MoveCursorRel( nRepeat, 0, SC_FOLLOW_LINE, bSel ); + break; + + case SID_CURSORBLKRIGHT: + pTabViewShell->MoveCursorArea( nRepeat, 0, SC_FOLLOW_JUMP, bSel ); + break; + + case SID_CURSORPAGEDOWN: + pTabViewShell->MoveCursorPage( 0, nRepeat, SC_FOLLOW_FIX, bSel ); + break; + + case SID_CURSORPAGEUP: + pTabViewShell->MoveCursorPage( 0, -nRepeat, SC_FOLLOW_FIX, bSel ); + break; + + case SID_CURSORPAGERIGHT_: //XXX !!! + pTabViewShell->MoveCursorPage( nRepeat, 0, SC_FOLLOW_FIX, bSel ); + break; + + case SID_CURSORPAGELEFT_: //XXX !!! + pTabViewShell->MoveCursorPage( -nRepeat, 0, SC_FOLLOW_FIX, bSel ); + break; + + default: + DBG_ERROR("Unbekannte Message bei ViewShell (Cursor)"); + return; + } + + pTabViewShell->ShowAllCursors(); + + rReq.AppendItem( SfxInt16Item(FN_PARAM_1, nRepeat) ); + rReq.AppendItem( SfxBoolItem(FN_PARAM_2, bSel) ); + rReq.Done(); +} + +void ScCellShell::GetStateCursor( SfxItemSet& rSet ) +{ +} + +void ScCellShell::ExecuteCursorSel( SfxRequest& rReq ) +{ + const SfxItemSet* pReqArgs = rReq.GetArgs(); + USHORT nSlotId = rReq.GetSlot(); + short nRepeat = 1; + + if ( pReqArgs != NULL ) + { + const SfxPoolItem* pItem; + if( IS_AVAILABLE( FN_PARAM_1, &pItem ) ) + nRepeat = ((const SfxInt16Item*)pItem)->GetValue(); + } + + switch ( nSlotId ) + { + case SID_CURSORDOWN_SEL: rReq.SetSlot( SID_CURSORDOWN ); break; + case SID_CURSORBLKDOWN_SEL: rReq.SetSlot( SID_CURSORBLKDOWN ); break; + case SID_CURSORUP_SEL: rReq.SetSlot( SID_CURSORUP ); break; + case SID_CURSORBLKUP_SEL: rReq.SetSlot( SID_CURSORBLKUP ); break; + case SID_CURSORLEFT_SEL: rReq.SetSlot( SID_CURSORLEFT ); break; + case SID_CURSORBLKLEFT_SEL: rReq.SetSlot( SID_CURSORBLKLEFT ); break; + case SID_CURSORRIGHT_SEL: rReq.SetSlot( SID_CURSORRIGHT ); break; + case SID_CURSORBLKRIGHT_SEL: rReq.SetSlot( SID_CURSORBLKRIGHT ); break; + case SID_CURSORPAGEDOWN_SEL: rReq.SetSlot( SID_CURSORPAGEDOWN ); break; + case SID_CURSORPAGEUP_SEL: rReq.SetSlot( SID_CURSORPAGEUP ); break; + case SID_CURSORPAGERIGHT_SEL: rReq.SetSlot( SID_CURSORPAGERIGHT_ ); break; + case SID_CURSORPAGELEFT_SEL: rReq.SetSlot( SID_CURSORPAGELEFT_ ); break; + default: + DBG_ERROR("Unbekannte Message bei ViewShell (CursorSel)"); + return; + } + rReq.AppendItem( SfxInt16Item(FN_PARAM_1, nRepeat ) ); + rReq.AppendItem( SfxBoolItem(FN_PARAM_2, TRUE) ); + ExecuteSlot( rReq, GetInterface() ); +} + +void ScCellShell::ExecuteMove( SfxRequest& rReq ) +{ + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + USHORT nSlotId = rReq.GetSlot(); + + if(nSlotId != SID_CURSORTOPOFSCREEN && nSlotId != SID_CURSORENDOFSCREEN) + pTabViewShell->ExecuteInputDirect(); + switch ( nSlotId ) + { + case SID_NEXT_TABLE: + pTabViewShell->SelectNextTab( 1 ); + break; + + case SID_PREV_TABLE: + pTabViewShell->SelectNextTab( -1 ); + break; + + // Cursorbewegungen in Bloecken gehen nicht von Basic aus, + // weil das ScSbxRange-Objekt bei Eingaben die Markierung veraendert + + case SID_NEXT_UNPROTECT: + pTabViewShell->FindNextUnprot( FALSE, !rReq.IsAPI() ); + break; + + case SID_PREV_UNPROTECT: + pTabViewShell->FindNextUnprot( TRUE, !rReq.IsAPI() ); + break; + + case SID_CURSORENTERUP: + if (rReq.IsAPI()) + pTabViewShell->MoveCursorRel( 0, -1, SC_FOLLOW_LINE, FALSE ); + else + pTabViewShell->MoveCursorEnter( TRUE ); + break; + + case SID_CURSORENTERDOWN: + if (rReq.IsAPI()) + pTabViewShell->MoveCursorRel( 0, 1, SC_FOLLOW_LINE, FALSE ); + else + pTabViewShell->MoveCursorEnter( FALSE ); + break; + + case SID_SELECT_COL: + pTabViewShell->MarkColumns(); + break; + + case SID_SELECT_ROW: + pTabViewShell->MarkRows(); + break; + + case SID_SELECT_NONE: + pTabViewShell->Unmark(); + break; + + case SID_ALIGNCURSOR: + pTabViewShell->AlignToCursor( GetViewData()->GetCurX(), GetViewData()->GetCurY(), SC_FOLLOW_JUMP ); + break; + + case SID_MARKDATAAREA: + pTabViewShell->MarkDataArea(); + break; + + case SID_SETINPUTMODE: + SC_MOD()->SetInputMode( SC_INPUT_TABLE ); + break; + + case SID_CURSORTOPOFSCREEN: + pTabViewShell->MoveCursorScreen( 0, -1, SC_FOLLOW_LINE, FALSE ); + break; + + case SID_CURSORENDOFSCREEN: + pTabViewShell->MoveCursorScreen( 0, 1, SC_FOLLOW_LINE, FALSE ); + break; + + default: + DBG_ERROR("Unbekannte Message bei ViewShell (Cursor)"); + return; + } + + rReq.Done(); +} + +void ScCellShell::ExecutePageSel( SfxRequest& rReq ) +{ + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + USHORT nSlotId = rReq.GetSlot(); + switch ( nSlotId ) + { + case SID_CURSORHOME_SEL: rReq.SetSlot( SID_CURSORHOME ); break; + case SID_CURSOREND_SEL: rReq.SetSlot( SID_CURSOREND ); break; + case SID_CURSORTOPOFFILE_SEL: rReq.SetSlot( SID_CURSORTOPOFFILE ); break; + case SID_CURSORENDOFFILE_SEL: rReq.SetSlot( SID_CURSORENDOFFILE ); break; + default: + DBG_ERROR("Unbekannte Message bei ViewShell (ExecutePageSel)"); + return; + } + rReq.AppendItem( SfxBoolItem(FN_PARAM_2, TRUE) ); + ExecuteSlot( rReq, GetInterface() ); +} + +void ScCellShell::ExecutePage( SfxRequest& rReq ) +{ + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + const SfxItemSet* pReqArgs = rReq.GetArgs(); + USHORT nSlotId = rReq.GetSlot(); + BOOL bSel = FALSE; + + if ( pReqArgs != NULL ) + { + const SfxPoolItem* pItem; + if( IS_AVAILABLE( FN_PARAM_2, &pItem ) ) + bSel = ((const SfxBoolItem*)pItem)->GetValue(); + } + + pTabViewShell->ExecuteInputDirect(); + switch ( nSlotId ) + { + case SID_CURSORHOME: + pTabViewShell->MoveCursorEnd( -1, 0, SC_FOLLOW_LINE, bSel ); + break; + + case SID_CURSOREND: + pTabViewShell->MoveCursorEnd( 1, 0, SC_FOLLOW_JUMP, bSel ); + break; + + case SID_CURSORTOPOFFILE: + pTabViewShell->MoveCursorEnd( -1, -1, SC_FOLLOW_LINE, bSel ); + break; + + case SID_CURSORENDOFFILE: + pTabViewShell->MoveCursorEnd( 1, 1, SC_FOLLOW_JUMP, bSel ); + break; + + default: + DBG_ERROR("Unbekannte Message bei ViewShell (ExecutePage)"); + return; + } + + rReq.AppendItem( SfxBoolItem(FN_PARAM_2, bSel) ); + rReq.Done(); +} + + + + diff --git a/sc/source/ui/view/colrowba.cxx b/sc/source/ui/view/colrowba.cxx new file mode 100644 index 000000000000..2c658013cc3f --- /dev/null +++ b/sc/source/ui/view/colrowba.cxx @@ -0,0 +1,716 @@ +/************************************************************************* + * + * $RCSfile: colrowba.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +// TOOLS +#define _BIGINT_HXX +#define _SFXMULTISEL_HXX +#define _STACK_HXX +#define _QUEUE_HXX +#define _DYNARR_HXX +#define _TREELIST_HXX +#define _CACHESTR_HXX +#define _NEW_HXX +//#define _SHL_HXX +//#define _LINK_HXX +//#define _ERRCODE_HXX +//#define _GEN_HXX +//#define _FRACT_HXX +//#define _STRING_HXX +//#define _MTF_HXX +//#define _CONTNR_HXX +//#define _LIST_HXX +//#define _TABLE_HXX +#define _DYNARY_HXX +//#define _UNQIDX_HXX +#define _SVMEMPOOL_HXX +//#define _UNQID_HXX +//#define _DEBUG_HXX +//#define _DATE_HXX +//#define _TIME_HXX +//#define _DATETIME_HXX +//#define _INTN_HXX +//#define _WLDCRD_HXX +//#define _FSYS_HXX +//#define _STREAM_HXX +#define _CACHESTR_HXX +#define _SV_MULTISEL_HXX + +//SV +//#define _CLIP_HXX +//#define _CONFIG_HXX +#define _CURSOR_HXX +#define _FONTDLG_HXX +#define _PRVWIN_HXX +//#define _COLOR_HXX +//#define _PAL_HXX +//#define _BITMAP_HXX +//#define _GDIOBJ_HXX +//#define _POINTR_HXX +//#define _ICON_HXX +//#define _IMAGE_HXX +//#define _KEYCOD_HXX +//#define _EVENT_HXX +#define _HELP_HXX +//#define _APP_HXX +//#define _MDIAPP_HXX +//#define _TIMER_HXX +//#define _METRIC_HXX +//#define _REGION_HXX +//#define _OUTDEV_HXX +//#define _SYSTEM_HXX +//#define _VIRDEV_HXX +//#define _JOBSET_HXX +//#define _PRINT_HXX +//#define _WINDOW_HXX +//#define _SYSWIN_HXX +//#define _WRKWIN_HXX +#define _MDIWIN_HXX +//#define _FLOATWIN_HXX +//#define _DOCKWIN_HXX +//#define _CTRL_HXX +//#define _SCRBAR_HXX +//#define _BUTTON_HXX +//#define _IMAGEBTN_HXX +//#define _FIXED_HXX +//#define _GROUP_HXX +//#define _EDIT_HXX +//#define _COMBOBOX_HXX +//#define _LSTBOX_HXX +//#define _SPLIT_HXX +#define _SPIN_HXX +//#define _FIELD_HXX +#define _MOREBTN_HXX +//#define _TOOLBOX_HXX +//#define _STATUS_HXX +//#define _DIALOG_HXX +//#define _MSGBOX_HXX +//#define _SYSDLG_HXX +//#define _PRNDLG_HXX +#define _COLDLG_HXX +//#define _GDIMTF_HXX +//#define _POLY_HXX +//#define _ACCEL_HXX +//#define _GRAPH_HXX +#define _SOUND_HXX + +//svtools +#define _SCRWIN_HXX +#define _RULER_HXX +//#define _TABBAR_HXX +//#define _VALUESET_HXX +#define _STDMENU_HXX +//#define _STDCTRL_HXX +//#define _CTRLBOX_HXX +#define _CTRLTOOL_HXX +#define _EXTATTR_HXX +#define _FRM3D_HXX +#define _EXTATTR_HXX + +//SVTOOLS +#define _SVTREELIST_HXX +#define _FILTER_HXX +#define _SVLBOXITM_HXX +#define _SVTREEBOX_HXX +#define _SVICNVW_HXX +#define _SVTABBX_HXX + +//sfxcore.hxx +#define _SFXINIMGR_HXX +//#define _SFXCFGITEM_HXX +//#define _SFX_PRINTER_HXX +#define _SFXGENLINK_HXX +#define _SFXHINTPOST_HXX +//#define _SFXDOCINF_HXX +#define _SFXLINKHDL_HXX +//#define _SFX_PROGRESS_HXX + +//sfxsh.hxx +//#define _SFX_SHELL_HXX +//#define _SFXAPP_HXX +//#define _SFX_BINDINGS_HXX +//#define _SFXDISPATCH_HXX +//#define _SFXMSG_HXX +#define _SFXOBJFACE_HXX +//#define _SFXREQUEST_HXX +#define _SFXMACRO_HXX + +// SFX +#define _SFXAPPWIN_HXX +#define _SFX_SAVEOPT_HXX +//#define _SFX_CHILDWIN_HXX +//#define _SFXCTRLITEM_HXX +#define _SFXPRNMON_HXX +#define _INTRO_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFXFILEDLG_HXX +#define _PASSWD_HXX +#define _SFXTBXCTRL_HXX +#define _SFXSTBITEM_HXX +#define _SFXMNUITEM_HXX +#define _SFXIMGMGR_HXX +#define _SFXTBXMGR_HXX +#define _SFXSTBMGR_HXX +#define _SFX_MINFITEM_HXX +#define _SFXEVENT_HXX + + +//sfxdoc.hxx +//#define _SFX_OBJSH_HXX +//#define _SFX_CLIENTSH_HXX +//#define _SFXDOCINF_HXX +//#define _SFX_OBJFAC_HXX +//#define _SFX_DOCFILT_HXX +#define _SFXDOCFILE_HXX +//define _VIEWFAC_HXX +//#define _SFXVIEWFRM_HXX +//#define _SFXVIEWSH_HXX +#define _MDIFRM_HXX +#define _SFX_IPFRM_HXX +//#define _SFX_INTERNO_HXX + +//sfxdlg.hxx +//#define _SFXTABDLG_HXX +#define _BASEDLGS_HXX +#define _SFX_DINFDLG_HXX +#define _SFXDINFEDT_HXX +#define _SFX_MGETEMPL_HXX +#define _SFX_TPLPITEM_HXX +//#define _SFX_STYLEDLG_HXX +#define _NEWSTYLE_HXX +#define _SFXDOCTEMPL_HXX +#define _SFXDOCTDLG_HXX +#define _SFX_TEMPLDLG_HXX +#define _SFXNEW_HXX +#define _SFXDOCMAN_HXX +//#define _SFXDOCKWIN_HXX + + +//sfxitems.hxx +#define _SFX_WHMAP_HXX +#define _ARGS_HXX +//#define _SFXPOOLITEM_HXX +//#define _SFXINTITEM_HXX +//#define _SFXENUMITEM_HXX +#define _SFXFLAGITEM_HXX +//#define _SFXSTRITEM_HXX +#define _SFXPTITEM_HXX +#define _SFXRECTITEM_HXX +//#define _SFXITEMPOOL_HXX +//#define _SFXITEMSET_HXX +#define _SFXITEMITER_HXX +#define _SFX_WHITER_HXX +#define _SFXPOOLCACH_HXX +//#define _AEITEM_HXX +#define _SFXRNGITEM_HXX +//#define _SFXSLSTITM_HXX +#define _SFXSTYLE_HXX //* + +//xout.hxx +//#define _XENUM_HXX +//#define _XPOLY_HXX +//#define _XATTR_HXX +//#define _XOUTX_HXX +//#define _XPOOL_HXX +//#define _XTABLE_HXX + +//svdraw.hxx +//#define _SVDRAW_HXX +#define _SDR_NOITEMS +#define _SDR_NOTOUCH +#define _SDR_NOTRANSFORM +#define _SDR_NOVIEWMARKER +#define _SDR_NODRAGMETHODS +//#define _SDR_NOUNDO +#define _SDR_NOXOUTDEV +//#define _SDR_NOOBJECTS +//#define _SDR_NOVIEWS + +//#define SI_NOITEMS +//#define SI_NODRW +#define _SI_NOSBXCONTROLS +//#define _VCATTR_HXX +#define _VCONT_HXX +//#define _VCSBX_HXX +#define _SI_NOOTHERFORMS +#define _VCTRLS_HXX +//#define _VCDRWOBJ_HXX +#define _SI_NOCONTROL +#define _SETBRW_HXX +#define _VCBRW_HXX +#define _SI_NOSBXCONTROLS +#define _SIDLL_HXX + +//svdraw.hxx +#define _SDR_NOTRANSFORM // Transformationen, selten verwendet +#define _SDR_NOTOUCH // Hit-Tests, selten verwendet + +#define _SDR_NOEXTDEV // ExtOutputDevice +//#define _SDR_NOUNDO // Undo-Objekte +#define _SDR_NOSURROGATEOBJ // SdrObjSurrogate +#define _SDR_NOPAGEOBJ // SdrPageObj +#define _SDR_NOVIRTOBJ // SdrVirtObj +#define _SDR_NOGROUPOBJ // SdrGroupObj +//#define _SDR_NOTEXTOBJ // SdrTextObj +#define _SDR_NOPATHOBJ // SdrPathObj +#define _SDR_NOEDGEOBJ // SdrEdgeObj +//#define _SDR_NORECTOBJ // SdrRectObj +#define _SDR_NOCAPTIONOBJ // SdrCaptionObj +#define _SDR_NOCIRCLEOBJ // SdrCircleObj +#define _SDR_NOGRAFOBJ // SdrGrafObj +//#define _SDR_NOOLE2OBJ // SdrOle2Obj +//#define _SVDLAYER_HXX +//#define _SVDATTR_HXX +//#define _SVDIO_HXX +#define _SVBOXITM_HXX +#define _SVDEC_HXX +#define _SVDXOUT_HXX + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_THESDLG_HXX + +// INCLUDE --------------------------------------------------------------- + +#include <svx/svdtrans.hxx> + +#include "colrowba.hxx" +#include "document.hxx" +#include "scmod.hxx" +#include "tabvwsh.hxx" +#include "appoptio.hxx" +#include "globstr.hrc" + +// STATIC DATA ----------------------------------------------------------- + +//================================================================== + +String lcl_MetricString( long nTwips, const String& rText ) +{ + if ( nTwips <= 0 ) + return ScGlobal::GetRscString(STR_TIP_HIDE); + else + { + FieldUnit eUserMet = SC_MOD()->GetAppOptions().GetAppMetric(); + + long nUserVal = MetricField::ConvertValue( nTwips*100, 1, 2, FUNIT_TWIP, eUserMet ); + String aNum = ScGlobal::pScInternational->GetNum( nUserVal, 2 ); + + String aStr = rText; + aStr += ' '; + aStr += aNum; + aStr += ' '; + aStr += SdrFormatter::GetUnitStr(eUserMet); + + return aStr; + } +} + +//================================================================== + +ScColBar::ScColBar( Window* pParent, ScViewData* pData, ScHSplitPos eWhichPos, + ScHeaderFunctionSet* pFunc, ScHeaderSelectionEngine* pEng ) : + ScHeaderControl( pParent, pEng, MAXCOL+1, HDR_HORIZONTAL ), + pViewData( pData ), + eWhich( eWhichPos ), + pFuncSet( pFunc ), + pSelEngine( pEng ) +{ + Show(); +} + +ScColBar::~ScColBar() +{ +} + +USHORT ScColBar::GetPos() +{ + return pViewData->GetPosX(eWhich); +} + +USHORT ScColBar::GetEntrySize( USHORT nEntryNo ) +{ + ScDocument* pDoc = pViewData->GetDocument(); + USHORT nTab = pViewData->GetTabNo(); + if ( pDoc->GetColFlags( nEntryNo, nTab ) & CR_HIDDEN ) + return 0; + else + return (USHORT) ( pDoc->GetColWidth( nEntryNo, nTab ) * pViewData->GetPPTX() ); +} + +String ScColBar::GetEntryText( USHORT nEntryNo ) +{ + return ColToAlpha( nEntryNo ); +} + +void ScColBar::SetEntrySize( USHORT nPos, USHORT nNewSize ) +{ + USHORT nSizeTwips; + ScSizeMode eMode = SC_SIZE_DIRECT; + if (nNewSize>0 && nNewSize<10) nNewSize=10; // (Pixel) + + if ( nNewSize == HDR_SIZE_OPTIMUM ) + { + nSizeTwips = STD_EXTRA_WIDTH; + eMode = SC_SIZE_OPTIMAL; + } + else + nSizeTwips = (USHORT) ( nNewSize / pViewData->GetPPTX() ); + + ScMarkData& rMark = pViewData->GetMarkData(); +// USHORT nTab = pViewData->GetTabNo(); + + USHORT* pRanges = new USHORT[MAXCOL+1]; + USHORT nRangeCnt = 0; + if ( rMark.IsColumnMarked( nPos ) ) + { + USHORT nStart = 0; + while (nStart<=MAXCOL) + { + while (nStart<MAXCOL && !rMark.IsColumnMarked(nStart)) + ++nStart; + if (rMark.IsColumnMarked(nStart)) + { + USHORT nEnd = nStart; + while (nEnd<MAXCOL && rMark.IsColumnMarked(nEnd)) + ++nEnd; + if (!rMark.IsColumnMarked(nEnd)) + --nEnd; + pRanges[2*nRangeCnt ] = nStart; + pRanges[2*nRangeCnt+1] = nEnd; + ++nRangeCnt; + nStart = nEnd+1; + } + else + nStart = MAXCOL+1; + } + } + else + { + pRanges[0] = nPos; + pRanges[1] = nPos; + nRangeCnt = 1; + } + + pViewData->GetView()->SetWidthOrHeight( TRUE, nRangeCnt, pRanges, eMode, nSizeTwips ); + delete[] pRanges; +} + +void ScColBar::HideEntries( USHORT nStart, USHORT nEnd ) +{ + USHORT nRange[2]; + nRange[0] = nStart; + nRange[1] = nEnd; + pViewData->GetView()->SetWidthOrHeight( TRUE, 1, nRange, SC_SIZE_DIRECT, 0 ); +} + +void ScColBar::SetMarking( BOOL bSet ) +{ + pViewData->GetMarkData().SetMarking( bSet ); + if (!bSet) + { + pFuncSet->SetAnchorFlag(FALSE); + pViewData->GetView()->UpdateAutoFillMark(); + } +} + +void ScColBar::SelectWindow() +{ + ScTabViewShell* pViewSh = pViewData->GetViewShell(); + + pViewSh->SetActive(); // Appear und SetViewFrame + pViewSh->DrawDeselectAll(); + + ScSplitPos eActive = pViewData->GetActivePart(); + if (eWhich==SC_SPLIT_LEFT) + { + if (eActive==SC_SPLIT_TOPRIGHT) eActive=SC_SPLIT_TOPLEFT; + if (eActive==SC_SPLIT_BOTTOMRIGHT) eActive=SC_SPLIT_BOTTOMLEFT; + } + else + { + if (eActive==SC_SPLIT_TOPLEFT) eActive=SC_SPLIT_TOPRIGHT; + if (eActive==SC_SPLIT_BOTTOMLEFT) eActive=SC_SPLIT_BOTTOMRIGHT; + } + pViewSh->ActivatePart( eActive ); + + pFuncSet->SetColumn( TRUE ); + pFuncSet->SetWhich( eActive ); + + pViewSh->ActiveGrabFocus(); +} + +BOOL ScColBar::IsDisabled() +{ + ScModule* pScMod = SC_MOD(); + return pScMod->IsFormulaMode() || pScMod->IsModalMode(); +} + +BOOL ScColBar::ResizeAllowed() +{ + return !pViewData->HasEditView( pViewData->GetActivePart() ); +} + +void ScColBar::DrawInvert( long nDragPos ) +{ + Rectangle aRect( nDragPos,0, nDragPos+HDR_SLIDERSIZE-1,GetOutputSizePixel().Width()-1 ); + Update(); + Invert(aRect); + + pViewData->GetView()->InvertVertical(eWhich,nDragPos); +} + +String ScColBar::GetDragHelp( long nVal ) +{ + long nTwips = (long) ( nVal / pViewData->GetPPTX() ); + return lcl_MetricString( nTwips, ScGlobal::GetRscString(STR_TIP_WIDTH) ); +} + +//================================================================== + +ScRowBar::ScRowBar( Window* pParent, ScViewData* pData, ScVSplitPos eWhichPos, + ScHeaderFunctionSet* pFunc, ScHeaderSelectionEngine* pEng ) : + ScHeaderControl( pParent, pEng, MAXROW+1, HDR_VERTICAL ), + pViewData( pData ), + eWhich( eWhichPos ), + pFuncSet( pFunc ), + pSelEngine( pEng ) +{ + Show(); +} + +ScRowBar::~ScRowBar() +{ +} + +USHORT ScRowBar::GetPos() +{ + return pViewData->GetPosY(eWhich); +} + +USHORT ScRowBar::GetEntrySize( USHORT nEntryNo ) +{ + ScDocument* pDoc = pViewData->GetDocument(); + USHORT nTab = pViewData->GetTabNo(); + if ( pDoc->GetRowFlags( nEntryNo, nTab ) & CR_HIDDEN ) + return 0; + else + return (USHORT) ( pDoc->GetRowHeight( nEntryNo, nTab ) * pViewData->GetPPTY() ); +} + +String ScRowBar::GetEntryText( USHORT nEntryNo ) +{ + return String::CreateFromInt32( nEntryNo + 1 ); +} + +void ScRowBar::SetEntrySize( USHORT nPos, USHORT nNewSize ) +{ + USHORT nSizeTwips; + ScSizeMode eMode = SC_SIZE_DIRECT; + if (nNewSize>0 && nNewSize<10) nNewSize=10; // (Pixel) + + if ( nNewSize == HDR_SIZE_OPTIMUM ) + { + nSizeTwips = 0; + eMode = SC_SIZE_OPTIMAL; + } + else + nSizeTwips = (USHORT) ( nNewSize / pViewData->GetPPTY() ); + + ScMarkData& rMark = pViewData->GetMarkData(); +// USHORT nTab = pViewData->GetTabNo(); + + USHORT* pRanges = new USHORT[MAXROW+1]; + USHORT nRangeCnt = 0; + if ( rMark.IsRowMarked( nPos ) ) + { + USHORT nStart = 0; + while (nStart<=MAXROW) + { + while (nStart<MAXROW && !rMark.IsRowMarked(nStart)) + ++nStart; + if (rMark.IsRowMarked(nStart)) + { + USHORT nEnd = nStart; + while (nEnd<MAXROW && rMark.IsRowMarked(nEnd)) + ++nEnd; + if (!rMark.IsRowMarked(nEnd)) + --nEnd; + pRanges[2*nRangeCnt ] = nStart; + pRanges[2*nRangeCnt+1] = nEnd; + ++nRangeCnt; + nStart = nEnd+1; + } + else + nStart = MAXROW+1; + } + } + else + { + pRanges[0] = nPos; + pRanges[1] = nPos; + nRangeCnt = 1; + } + + pViewData->GetView()->SetWidthOrHeight( FALSE, nRangeCnt, pRanges, eMode, nSizeTwips ); + delete[] pRanges; +} + +void ScRowBar::HideEntries( USHORT nStart, USHORT nEnd ) +{ + USHORT nRange[2]; + nRange[0] = nStart; + nRange[1] = nEnd; + pViewData->GetView()->SetWidthOrHeight( FALSE, 1, nRange, SC_SIZE_DIRECT, 0 ); +} + +void ScRowBar::SetMarking( BOOL bSet ) +{ + pViewData->GetMarkData().SetMarking( bSet ); + if (!bSet) + { + pFuncSet->SetAnchorFlag(FALSE); + pViewData->GetView()->UpdateAutoFillMark(); + } +} + +void ScRowBar::SelectWindow() +{ + ScTabViewShell* pViewSh = pViewData->GetViewShell(); + + pViewSh->SetActive(); // Appear und SetViewFrame + pViewSh->DrawDeselectAll(); + + ScSplitPos eActive = pViewData->GetActivePart(); + if (eWhich==SC_SPLIT_TOP) + { + if (eActive==SC_SPLIT_BOTTOMLEFT) eActive=SC_SPLIT_TOPLEFT; + if (eActive==SC_SPLIT_BOTTOMRIGHT) eActive=SC_SPLIT_TOPRIGHT; + } + else + { + if (eActive==SC_SPLIT_TOPLEFT) eActive=SC_SPLIT_BOTTOMLEFT; + if (eActive==SC_SPLIT_TOPRIGHT) eActive=SC_SPLIT_BOTTOMRIGHT; + } + pViewSh->ActivatePart( eActive ); + + pFuncSet->SetColumn( FALSE ); + pFuncSet->SetWhich( eActive ); + + pViewSh->ActiveGrabFocus(); +} + +BOOL ScRowBar::IsDisabled() +{ + ScModule* pScMod = SC_MOD(); + return pScMod->IsFormulaMode() || pScMod->IsModalMode(); +} + +BOOL ScRowBar::ResizeAllowed() +{ + return !pViewData->HasEditView( pViewData->GetActivePart() ); +} + +void ScRowBar::DrawInvert( long nDragPos ) +{ + Rectangle aRect( 0,nDragPos, GetOutputSizePixel().Width()-1,nDragPos+HDR_SLIDERSIZE-1 ); + Update(); + Invert(aRect); + + pViewData->GetView()->InvertHorizontal(eWhich,nDragPos); +} + +String ScRowBar::GetDragHelp( long nVal ) +{ + long nTwips = (long) ( nVal / pViewData->GetPPTY() ); + return lcl_MetricString( nTwips, ScGlobal::GetRscString(STR_TIP_HEIGHT) ); +} + +// GetHiddenCount ist nur fuer Zeilen ueberladen + +USHORT ScRowBar::GetHiddenCount( USHORT nEntryNo ) +{ + ScDocument* pDoc = pViewData->GetDocument(); + USHORT nTab = pViewData->GetTabNo(); + return pDoc->GetHiddenRowCount( nEntryNo, nTab ); +} + + + diff --git a/sc/source/ui/view/dbfunc.cxx b/sc/source/ui/view/dbfunc.cxx new file mode 100644 index 000000000000..1cf910eba94e --- /dev/null +++ b/sc/source/ui/view/dbfunc.cxx @@ -0,0 +1,505 @@ +/************************************************************************* + * + * $RCSfile: dbfunc.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <offmgr/app.hxx> +#include <offmgr/sbaobj.hxx> +#include <offmgr/sbadb.hxx> +#include <sfx2/bindings.hxx> +#include <vcl/msgbox.hxx> + +#include "dbfunc.hxx" +#include "tabvwsh.hxx" +#include "docsh.hxx" +#include "attrib.hxx" +#include "patattr.hxx" +#include "sc.hrc" +#include "undodat.hxx" +#include "dbcolect.hxx" +#include "globstr.hrc" +#include "global.hxx" +#include "dbdocfun.hxx" + +#ifndef _SV_WAITOBJ_HXX //autogen +#include <vcl/waitobj.hxx> +#endif + +// STATIC DATA ----------------------------------------------------------- + +//================================================================== + +ScDBFunc::ScDBFunc( Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell ) : + ScViewFunc( pParent, rDocSh, pViewShell ) +{ +} + +ScDBFunc::ScDBFunc( Window* pParent, const ScDBFunc& rDBFunc, ScTabViewShell* pViewShell ) : + ScViewFunc( pParent, rDBFunc, pViewShell ) +{ +} + +ScDBFunc::~ScDBFunc() +{ +} + +// +// Hilfsfunktionen +// + +void ScDBFunc::GotoDBArea( const String& rDBName ) +{ + ScDocument* pDoc = GetViewData()->GetDocument(); + ScDBCollection* pDBCol = pDoc->GetDBCollection(); + + USHORT nFoundAt = 0; + if ( pDBCol->SearchName( rDBName, nFoundAt ) ) + { + ScDBData* pData = (*pDBCol)[nFoundAt]; + DBG_ASSERT( pData, "GotoDBArea: Datenbankbereich nicht gefunden!" ); + + if ( pData ) + { + USHORT nTab = 0; + USHORT nStartCol = 0; + USHORT nStartRow = 0; + USHORT nEndCol = 0; + USHORT nEndRow = 0; + + pData->GetArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow ); + SetTabNo( nTab ); + + MoveCursorAbs( nStartCol, nStartRow, ScFollowMode( SC_FOLLOW_JUMP ), + FALSE, FALSE ); // bShift,bControl + DoneBlockMode(); + InitBlockMode( nStartCol, nStartRow, nTab ); + MarkCursor( nEndCol, nEndRow, nTab ); + SelectionChanged(); + } + } +} + +// aktuellen Datenbereich fuer Sortieren / Filtern suchen + +ScDBData* ScDBFunc::GetDBData( BOOL bMark, ScGetDBMode eMode ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDBData* pData = NULL; + ScRange aRange; + if ( GetViewData()->GetSimpleArea(aRange) ) + pData = pDocSh->GetDBData( aRange, eMode, FALSE ); + else if ( eMode != SC_DB_OLD ) + pData = pDocSh->GetDBData( + ScRange( GetViewData()->GetCurX(), GetViewData()->GetCurY(), + GetViewData()->GetTabNo() ), + eMode, FALSE ); + + if ( pData && bMark ) + { + ScRange aFound; + pData->GetArea(aFound); + MarkRange( aFound, FALSE ); + } + return pData; +} + +// Datenbankbereiche aendern (Dialog) + +void ScDBFunc::NotifyCloseDbNameDlg( const ScDBCollection& rNewColl, const List& rDelAreaList ) +{ + const BOOL bRecord = TRUE; + + ScDocShell* pDocShell = GetViewData()->GetDocShell(); + ScDocShellModificator aModificator( *pDocShell ); + ScDocument* pDoc = pDocShell->GetDocument(); + ScDBCollection* pOldColl = pDoc->GetDBCollection(); + ScDBCollection* pUndoColl = NULL; + ScDBCollection* pRedoColl = NULL; + + long nDelCount = rDelAreaList.Count(); + for (long nDelPos=0; nDelPos<nDelCount; nDelPos++) + { + ScRange* pEntry = (ScRange*) rDelAreaList.GetObject(nDelPos); + + if ( pEntry ) + { + ScAddress& rStart = pEntry->aStart; + ScAddress& rEnd = pEntry->aEnd; + pDocShell->DBAreaDeleted( rStart.Tab(), + rStart.Col(), rStart.Row(), + rEnd.Col(), rEnd.Row() ); + + // Targets am SBA abmelden nicht mehr noetig + } + } + + if (bRecord) + pUndoColl = new ScDBCollection( *pOldColl ); + + // neue Targets am SBA anmelden nicht mehr noetig + + pDoc->CompileDBFormula( TRUE ); // CreateFormulaString + pDoc->SetDBCollection( new ScDBCollection( rNewColl ) ); + pDoc->CompileDBFormula( FALSE ); // CompileFormulaString + pOldColl = NULL; + pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID ); + aModificator.SetDocumentModified(); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) ); + + if (bRecord) + { + pRedoColl = new ScDBCollection( rNewColl ); + pDocShell->GetUndoManager()->AddUndoAction( + new ScUndoDBData( pDocShell, pUndoColl, pRedoColl ) ); + } +} + +// +// wirkliche Funktionen +// + +// Sortieren + +void ScDBFunc::UISort( const ScSortParam& rSortParam, BOOL bRecord ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + USHORT nTab = GetViewData()->GetTabNo(); + ScDBData* pDBData = pDoc->GetDBAtArea( nTab, rSortParam.nCol1, rSortParam.nRow1, + rSortParam.nCol2, rSortParam.nRow2 ); + if (!pDBData) + { + DBG_ERROR( "Sort: keine DBData" ); + return; + } + + ScSubTotalParam aSubTotalParam; + pDBData->GetSubTotalParam( aSubTotalParam ); + if (aSubTotalParam.bGroupActive[0] && !aSubTotalParam.bRemoveOnly) + { + // Subtotals wiederholen, mit neuer Sortierung + + ScSubTotalParam aSubTotalParam; + pDBData->GetSubTotalParam( aSubTotalParam ); + DoSubTotals( aSubTotalParam, bRecord, &rSortParam ); + } + else + { + Sort( rSortParam, bRecord ); // nur sortieren + } +} + +void ScDBFunc::Sort( const ScSortParam& rSortParam, BOOL bRecord, BOOL bPaint ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + USHORT nTab = GetViewData()->GetTabNo(); + ScDBDocFunc aDBDocFunc( *pDocSh ); + BOOL bSuccess = aDBDocFunc.Sort( nTab, rSortParam, bRecord, bPaint, FALSE ); + if ( bSuccess && !rSortParam.bInplace ) + { + // Ziel markieren + ScRange aDestRange( rSortParam.nDestCol, rSortParam.nDestRow, rSortParam.nDestTab, + rSortParam.nDestCol + rSortParam.nCol2 - rSortParam.nCol1, + rSortParam.nDestRow + rSortParam.nRow2 - rSortParam.nRow1, + rSortParam.nDestTab ); + MarkRange( aDestRange ); + } +} + +// Filtern + +void ScDBFunc::Query( const ScQueryParam& rQueryParam, const ScRange* pAdvSource, BOOL bRecord ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + USHORT nTab = GetViewData()->GetTabNo(); + ScDBDocFunc aDBDocFunc( *pDocSh ); + BOOL bSuccess = aDBDocFunc.Query( nTab, rQueryParam, pAdvSource, bRecord, FALSE ); + + if (bSuccess) + { + BOOL bCopy = !rQueryParam.bInplace; + if (bCopy) + { + // Zielbereich markieren (DB-Bereich wurde ggf. angelegt) + ScDocument* pDoc = pDocSh->GetDocument(); + ScDBData* pDestData = pDoc->GetDBAtCursor( + rQueryParam.nDestCol, rQueryParam.nDestRow, + rQueryParam.nDestTab, TRUE ); + if (pDestData) + { + ScRange aDestRange; + pDestData->GetArea(aDestRange); + MarkRange( aDestRange ); + } + } + + if (!bCopy) + UpdateScrollBars(); + + GetViewData()->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_UNFILTER ); + } +} + +// Autofilter-Knoepfe ein-/ausblenden + +void ScDBFunc::ToggleAutoFilter() +{ + ScDocShellModificator aModificator( *(GetViewData()->GetDocShell()) ); + + ScQueryParam aParam; + ScDocument* pDoc = GetViewData()->GetDocument(); + ScDBData* pDBData = GetDBData( FALSE ); + + pDBData->SetByRow( TRUE ); //! Undo, vorher abfragen ?? + pDBData->GetQueryParam( aParam ); + + + USHORT nCol; + USHORT nRow = aParam.nRow1; + USHORT nTab = GetViewData()->GetTabNo(); + INT16 nFlag; + BOOL bHasAuto = TRUE; + BOOL bHeader = pDBData->HasHeader(); + BOOL bPaint = FALSE; + + //! stattdessen aus DB-Bereich abfragen? + + for (nCol=aParam.nCol1; nCol<=aParam.nCol2 && bHasAuto; nCol++) + { + nFlag = ((ScMergeFlagAttr*) pDoc-> + GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue(); + + if ( (nFlag & SC_MF_AUTO) == 0 ) + bHasAuto = FALSE; + } + + if (bHasAuto) // aufheben + { + // Filterknoepfe ausblenden + + for (nCol=aParam.nCol1; nCol<=aParam.nCol2; nCol++) + { + nFlag = ((ScMergeFlagAttr*) pDoc-> + GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue(); + pDoc->ApplyAttr( nCol, nRow, nTab, ScMergeFlagAttr( nFlag & ~SC_MF_AUTO ) ); + } + + pDBData->SetAutoFilter(FALSE); + + // Filter aufheben (incl. Paint / Undo) + + USHORT nEC = aParam.GetEntryCount(); + for (USHORT i=0; i<nEC; i++) + aParam.GetEntry(i).bDoQuery = FALSE; + aParam.bDuplicate = TRUE; + Query( aParam, NULL, TRUE ); + + bPaint = TRUE; + } + else // Filterknoepfe einblenden + { + if ( !pDoc->IsBlockEmpty( nTab, + aParam.nCol1, aParam.nRow1, + aParam.nCol2, aParam.nRow2 ) ) + { + if (!bHeader) + { + if ( MessBox( GetViewData()->GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES), + ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), // "StarCalc" + ScGlobal::GetRscString( STR_MSSG_MAKEAUTOFILTER_0 ) // Koepfe aus erster Zeile? + ).Execute() == RET_YES ) + { + pDBData->SetHeader( TRUE ); //! Undo ?? + bHeader = TRUE; + } + } + + pDBData->SetAutoFilter(TRUE); + + for (nCol=aParam.nCol1; nCol<=aParam.nCol2; nCol++) + { + nFlag = ((ScMergeFlagAttr*) pDoc-> + GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue(); + pDoc->ApplyAttr( nCol, nRow, nTab, ScMergeFlagAttr( nFlag | SC_MF_AUTO ) ); + } + GetViewData()->GetDocShell()->PostPaint( aParam.nCol1, nRow, nTab, + aParam.nCol2, nRow, nTab, + PAINT_GRID ); + bPaint = TRUE; + } + else + { + ErrorBox aErrorBox( GetViewData()->GetDialogParent(), WinBits( WB_OK | WB_DEF_OK ), + ScGlobal::GetRscString( STR_ERR_AUTOFILTER ) ); + aErrorBox.Execute(); + } + } + + if ( bPaint ) + { + aModificator.SetDocumentModified(); + + SfxBindings& rBindings = GetViewData()->GetViewShell()-> + GetViewFrame()->GetBindings(); + rBindings.Invalidate( SID_AUTO_FILTER ); + rBindings.Invalidate( SID_AUTOFILTER_HIDE ); + } +} + +// nur ausblenden, keine Daten veraendern + +void ScDBFunc::HideAutoFilter() +{ + ScDocument* pDoc = GetViewData()->GetDocument(); + + ScQueryParam aParam; + ScDBData* pDBData = GetDBData( FALSE ); + + USHORT nTab, nCol1, nRow1, nCol2, nRow2; + pDBData->GetArea(nTab, nCol1, nRow1, nCol2, nRow2); + + for (USHORT nCol=nCol1; nCol<=nCol2; nCol++) + { + INT16 nFlag = ((ScMergeFlagAttr*) pDoc-> + GetAttr( nCol, nRow1, nTab, ATTR_MERGE_FLAG ))->GetValue(); + pDoc->ApplyAttr( nCol, nRow1, nTab, ScMergeFlagAttr( nFlag & ~SC_MF_AUTO ) ); + } + + pDBData->SetAutoFilter(FALSE); + + GetViewData()->GetDocShell()->PostPaint( nCol1,nRow1,nTab, nCol2,nRow1,nTab, PAINT_GRID ); + + SfxBindings& rBindings = SFX_BINDINGS(); + rBindings.Invalidate( SID_AUTO_FILTER ); + rBindings.Invalidate( SID_AUTOFILTER_HIDE ); +} + +// +// Datenbank - Import +// + +void ScDBFunc::StartQuerySh( const ScImportParam& rParam ) +{ + SbaObject* pSbaObject = OFF_APP()->GetSbaObject(); + DBG_ASSERT(pSbaObject != NULL,"ScDBFunc::StartQuerySh: pSbaObject == NULL"); + + String aDBName; + String aLogicName; // Tabellen-/Query-Name + String aStatement; // SQL-String + BOOL bSql = FALSE; + BOOL bNative = FALSE; + DBObject eObj = dbTable; + + if (rParam.bImport) // alte Abfrage wieder anzeigen + { + aDBName = rParam.aDBName; +//! bNative = rParam.bNative; //! Native gibt momentan Aerger ??!??!?! + bSql = rParam.bSql; + if ( bSql ) + aStatement = rParam.aStatement; // Statement direkt + else + aLogicName = rParam.aStatement; // Name (Tabelle/Abfrage) + + eObj = (DBObject) rParam.nType; // Unterscheidung Tabelle/Abfrage + } + else // war nix im Parameter -> Adressbuch + { + aDBName = pSbaObject->GetAddrDBName(); + aLogicName = pSbaObject->GetAddrTableName(); + } + + SbaDatabaseRef pDatabase = pSbaObject->GetDatabase(aDBName, TRUE); // TRUE: Fehlermeldungen + if (pDatabase.Is()) + { + if ( bSql ) + pDatabase->ShowStatement(aStatement, bNative); + else + pDatabase->ShowDBDef(eObj, aLogicName); + } +} + +// Re-Import + +BOOL ScDBFunc::ImportData( const ScImportParam& rParam, BOOL bRecord ) +{ + BOOL bSuccess = FALSE; + + ScDocument* pDoc = GetViewData()->GetDocument(); + if ( !pDoc->IsBlockEditable( GetViewData()->GetTabNo(), rParam.nCol1,rParam.nRow1, + rParam.nCol2,rParam.nRow2 ) ) + { + ErrorMessage(STR_PROTECTIONERR); + return FALSE; + } + + ScDBDocFunc aDBDocFunc( *GetViewData()->GetDocShell() ); + return aDBDocFunc.DoImport( GetViewData()->GetTabNo(), rParam, NULL, bRecord ); +} + + + diff --git a/sc/source/ui/view/dbfunc2.cxx b/sc/source/ui/view/dbfunc2.cxx new file mode 100644 index 000000000000..70ecbb5977b0 --- /dev/null +++ b/sc/source/ui/view/dbfunc2.cxx @@ -0,0 +1,118 @@ +/************************************************************************* + * + * $RCSfile: dbfunc2.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + + +#include "dbfunc.hxx" +#include "docsh.hxx" +#include "global.hxx" +#include "document.hxx" +#include "sc.hrc" +#include "globstr.hrc" + + +// STATIC DATA ----------------------------------------------------------- + + +#ifdef WNT +#pragma optimize ( "", off ) +#endif + +//================================================================== + +class ScDrawLayer; +class ScChartCollection; + +// wg. CLOOKs in dbfunc4: +USHORT DoUpdateCharts( ScAddress aPos, ScDocument* pDoc, + Window* pActiveWin, BOOL bAllCharts ); + + +void ScDBFunc::UpdateCharts( BOOL bAllCharts ) +{ + USHORT nFound = 0; + ScViewData* pViewData = GetViewData(); + ScDocument* pDoc = pViewData->GetDocument(); + + if ( pDoc->GetDrawLayer() ) + nFound = DoUpdateCharts( ScAddress( pViewData->GetCurX(), + pViewData->GetCurY(), + pViewData->GetTabNo()), + pDoc, + GetActiveWin(), + bAllCharts ); + + if ( !nFound && !bAllCharts ) + ErrorMessage(STR_NOCHARTATCURSOR); +} + + + + + + diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx new file mode 100644 index 000000000000..64f96ca22ba5 --- /dev/null +++ b/sc/source/ui/view/dbfunc3.cxx @@ -0,0 +1,851 @@ +/************************************************************************* + * + * $RCSfile: dbfunc3.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <sfx2/bindings.hxx> +#include <vcl/svapp.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/sound.hxx> +#include <vcl/waitobj.hxx> + +#include "dbfunc.hxx" +#include "global.hxx" +#include "globstr.hrc" +#include "sc.hrc" +#include "undotab.hxx" +#include "undodat.hxx" +#include "dbcolect.hxx" +#include "rangenam.hxx" +#include "rangeutl.hxx" +#include "docsh.hxx" +#include "olinetab.hxx" +#include "consoli.hxx" +#include "olinefun.hxx" +#include "dpobject.hxx" +#include "dpsave.hxx" +#include "dbdocfun.hxx" + +// STATIC DATA ----------------------------------------------------------- + + +//================================================================== + +// +// Outliner +// + +void lcl_InvalidateOutliner() +{ + SfxBindings& rBindings = SFX_BINDINGS(); + rBindings.Invalidate( SID_OUTLINE_SHOW ); + rBindings.Invalidate( SID_OUTLINE_HIDE ); + rBindings.Invalidate( SID_OUTLINE_REMOVE ); + + rBindings.Invalidate( SID_STATUS_SUM ); // wegen ein-/ausblenden + rBindings.Invalidate( SID_ATTR_SIZE ); +} + +// Outline-Gruppierung erzeugen + +void ScDBFunc::MakeOutline( BOOL bColumns, BOOL bRecord ) +{ + ScRange aRange; + if (GetViewData()->GetSimpleArea(aRange)) + { + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScOutlineDocFunc aFunc(*pDocSh); + aFunc.MakeOutline( aRange, bColumns, bRecord, FALSE ); + } + else + ErrorMessage(STR_NOMULTISELECT); +} + +// Outline-Gruppierung loeschen + +void ScDBFunc::RemoveOutline( BOOL bColumns, BOOL bRecord ) +{ + ScRange aRange; + if (GetViewData()->GetSimpleArea(aRange)) + { + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScOutlineDocFunc aFunc(*pDocSh); + aFunc.RemoveOutline( aRange, bColumns, bRecord, FALSE ); + } + else + ErrorMessage(STR_NOMULTISELECT); +} + +// Menue-Status: Outlines loeschen + +void ScDBFunc::TestRemoveOutline( BOOL& rCol, BOOL& rRow ) +{ + BOOL bColFound = FALSE; + BOOL bRowFound = FALSE; + + USHORT nStartCol, nStartRow, nStartTab; + USHORT nEndCol, nEndRow, nEndTab; + if (GetViewData()->GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab)) + { + USHORT nTab = nStartTab; + ScDocument* pDoc = GetViewData()->GetDocument(); + ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab ); + if (pTable) + { + ScOutlineArray* pArray; + ScOutlineEntry* pEntry; + USHORT nStart; + USHORT nEnd; + BOOL bColMarked = ( nStartRow == 0 && nEndRow == MAXROW ); + BOOL bRowMarked = ( nStartCol == 0 && nEndCol == MAXCOL ); + + // Spalten + + if ( !bRowMarked || bColMarked ) // nicht wenn ganze Zeilen markiert + { + pArray = pTable->GetColArray(); + ScSubOutlineIterator aColIter( pArray ); + while ((pEntry=aColIter.GetNext()) != NULL && !bColFound) + { + nStart = pEntry->GetStart(); + nEnd = pEntry->GetEnd(); + if ( nStartCol<=nEnd && nEndCol>=nStart ) + bColFound = TRUE; + } + } + + // Zeilen + + if ( !bColMarked || bRowMarked ) // nicht wenn ganze Spalten markiert + { + pArray = pTable->GetRowArray(); + ScSubOutlineIterator aRowIter( pArray ); + while ((pEntry=aRowIter.GetNext()) != NULL && !bRowFound) + { + nStart = pEntry->GetStart(); + nEnd = pEntry->GetEnd(); + if ( nStartRow<=nEnd && nEndRow>=nStart ) + bRowFound = TRUE; + } + } + } + } + + rCol = bColFound; + rRow = bRowFound; +} + +void ScDBFunc::RemoveAllOutlines( BOOL bRecord ) +{ + USHORT nTab = GetViewData()->GetTabNo(); + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScOutlineDocFunc aFunc(*pDocSh); + + HideCursor(); + BOOL bOk = aFunc.RemoveAllOutlines( nTab, bRecord, FALSE ); + ShowCursor(); + + if (bOk) + UpdateScrollBars(); +} + +// Auto-Outlines + +void ScDBFunc::AutoOutline( BOOL bRecord ) +{ + USHORT nTab = GetViewData()->GetTabNo(); + ScRange aRange( 0,0,nTab, MAXCOL,MAXROW,nTab ); // ganze Tabelle, wenn nichts markiert + ScMarkData& rMark = GetViewData()->GetMarkData(); + if ( rMark.IsMarked() || rMark.IsMultiMarked() ) + { + rMark.MarkToMulti(); + rMark.GetMultiMarkArea( aRange ); + } + + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScOutlineDocFunc aFunc(*pDocSh); + aFunc.AutoOutline( aRange, bRecord, FALSE ); +} + +// Outline-Ebene auswaehlen + +void ScDBFunc::SelectLevel( BOOL bColumns, USHORT nLevel, BOOL bRecord, BOOL bPaint ) +{ + USHORT nTab = GetViewData()->GetTabNo(); + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScOutlineDocFunc aFunc(*pDocSh); + + HideCursor(); + BOOL bOk = aFunc.SelectLevel( nTab, bColumns, nLevel, bRecord, bPaint, FALSE ); + ShowCursor(); + + if (bOk) + UpdateScrollBars(); +} + +// einzelne Outline-Gruppe einblenden + +void ScDBFunc::ShowOutline( BOOL bColumns, USHORT nLevel, USHORT nEntry, BOOL bRecord, BOOL bPaint ) +{ + USHORT nTab = GetViewData()->GetTabNo(); + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScOutlineDocFunc aFunc(*pDocSh); + + HideCursor(); + BOOL bOk = aFunc.ShowOutline( nTab, bColumns, nLevel, nEntry, bRecord, bPaint, FALSE ); + ShowCursor(); + + if ( bOk && bPaint ) + UpdateScrollBars(); +} + +// einzelne Outline-Gruppe ausblenden + +void ScDBFunc::HideOutline( BOOL bColumns, USHORT nLevel, USHORT nEntry, BOOL bRecord, BOOL bPaint ) +{ + USHORT nTab = GetViewData()->GetTabNo(); + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScOutlineDocFunc aFunc(*pDocSh); + + HideCursor(); + BOOL bOk = aFunc.HideOutline( nTab, bColumns, nLevel, nEntry, bRecord, bPaint, FALSE ); + ShowCursor(); + + if ( bOk && bPaint ) + UpdateScrollBars(); +} + +// Menue-Status: markierten Bereich ein-/ausblenden + +BOOL ScDBFunc::OutlinePossible(BOOL bHide) +{ + BOOL bEnable = FALSE; + + USHORT nStartCol; + USHORT nStartRow; + USHORT nStartTab; + USHORT nEndCol; + USHORT nEndRow; + USHORT nEndTab; + + if (GetViewData()->GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab)) + { + ScDocument* pDoc = GetViewData()->GetDocument(); + USHORT nTab = GetViewData()->GetTabNo(); + ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab ); + if (pTable) + { + ScOutlineArray* pArray; + ScOutlineEntry* pEntry; + USHORT nStart; + USHORT nEnd; + + // Spalten + + pArray = pTable->GetColArray(); + ScSubOutlineIterator aColIter( pArray ); + while ((pEntry=aColIter.GetNext()) != NULL && !bEnable) + { + nStart = pEntry->GetStart(); + nEnd = pEntry->GetEnd(); + if ( bHide ) + { + if ( nStartCol<=nEnd && nEndCol>=nStart ) + if (!pEntry->IsHidden()) + bEnable = TRUE; + } + else + { + if ( nStart>=nStartCol && nEnd<=nEndCol ) + if (pEntry->IsHidden()) + bEnable = TRUE; + } + } + + // Zeilen + + pArray = pTable->GetRowArray(); + ScSubOutlineIterator aRowIter( pArray ); + while ((pEntry=aRowIter.GetNext()) != NULL) + { + nStart = pEntry->GetStart(); + nEnd = pEntry->GetEnd(); + if ( bHide ) + { + if ( nStartRow<=nEnd && nEndRow>=nStart ) + if (!pEntry->IsHidden()) + bEnable = TRUE; + } + else + { + if ( nStart>=nStartRow && nEnd<=nEndRow ) + if (pEntry->IsHidden()) + bEnable = TRUE; + } + } + } + } + + return bEnable; +} + +// markierten Bereich einblenden + +void ScDBFunc::ShowMarkedOutlines( BOOL bRecord ) +{ + ScRange aRange; + if (GetViewData()->GetSimpleArea(aRange)) + { + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScOutlineDocFunc aFunc(*pDocSh); + HideCursor(); + BOOL bDone = aFunc.ShowMarkedOutlines( aRange, bRecord, FALSE ); + ShowCursor(); + if (bDone) + UpdateScrollBars(); + } + else + ErrorMessage(STR_NOMULTISELECT); +} + +// markierten Bereich ausblenden + +void ScDBFunc::HideMarkedOutlines( BOOL bRecord ) +{ + ScRange aRange; + if (GetViewData()->GetSimpleArea(aRange)) + { + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScOutlineDocFunc aFunc(*pDocSh); + HideCursor(); + BOOL bDone = aFunc.HideMarkedOutlines( aRange, bRecord, FALSE ); + ShowCursor(); + if (bDone) + UpdateScrollBars(); + } + else + ErrorMessage(STR_NOMULTISELECT); +} + +// -------------------------------------------------------------------------- + +// +// Teilergebnisse +// + +void ScDBFunc::DoSubTotals( const ScSubTotalParam& rParam, BOOL bRecord, + const ScSortParam* pForceNewSort ) +{ + BOOL bDo = !rParam.bRemoveOnly; // FALSE = nur loeschen + + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + USHORT nTab = GetViewData()->GetTabNo(); + + ScDBData* pDBData = pDoc->GetDBAtArea( nTab, rParam.nCol1, rParam.nRow1, + rParam.nCol2, rParam.nRow2 ); + if (!pDBData) + { + DBG_ERROR( "SubTotals: keine DBData" ); + return; + } + + if (!pDoc->IsBlockEditable( nTab, 0,rParam.nRow1+1, MAXCOL,MAXROW )) + { + ErrorMessage(STR_PROTECTIONERR); + return; + } + + if (pDoc->HasAttrib( rParam.nCol1, rParam.nRow1+1, nTab, + rParam.nCol2, rParam.nRow2, nTab, HASATTR_MERGED | HASATTR_OVERLAPPED )) + { + ErrorMessage(STR_MSSG_INSERTCELLS_0); // nicht in zusammengefasste einfuegen + return; + } + + WaitObject aWait( GetViewData()->GetDialogParent() ); + BOOL bOk = TRUE; + BOOL bDelete = FALSE; + if (rParam.bReplace) + if (pDoc->TestRemoveSubTotals( nTab, rParam )) + { + bDelete = TRUE; + bOk = ( MessBox( GetViewData()->GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES), + // "StarCalc" "Daten loeschen?" + ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), + ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_1 ) ).Execute() + == RET_YES ); + } + + if (bOk) + { + ScDocShellModificator aModificator( *pDocSh ); + + ScSubTotalParam aNewParam( rParam ); // Bereichsende wird veraendert + ScDocument* pUndoDoc = NULL; + ScOutlineTable* pUndoTab = NULL; + ScRangeName* pUndoRange = NULL; + ScDBCollection* pUndoDB = NULL; + USHORT nTabCount = 0; // fuer Referenz-Undo + + if (bRecord) // alte Daten sichern + { + BOOL bOldFilter = bDo && rParam.bDoSort; + + nTabCount = pDoc->GetTableCount(); + pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab ); + if (pTable) + { + pUndoTab = new ScOutlineTable( *pTable ); + + USHORT nOutStartCol; // Zeilen/Spaltenstatus + USHORT nOutStartRow; + USHORT nOutEndCol; + USHORT nOutEndRow; + pTable->GetColArray()->GetRange( nOutStartCol, nOutEndCol ); + pTable->GetRowArray()->GetRange( nOutStartRow, nOutEndRow ); + + pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, TRUE ); + pDoc->CopyToDocument( nOutStartCol, 0, nTab, nOutEndCol, MAXROW, nTab, IDF_NONE, FALSE, pUndoDoc ); + pDoc->CopyToDocument( 0, nOutStartRow, nTab, MAXCOL, nOutEndRow, nTab, IDF_NONE, FALSE, pUndoDoc ); + } + else + pUndoDoc->InitUndo( pDoc, nTab, nTab, FALSE, bOldFilter ); + + // Datenbereich sichern - incl. Filter-Ergebnis + pDoc->CopyToDocument( 0,rParam.nRow1+1,nTab, MAXCOL,rParam.nRow2,nTab, + IDF_ALL, FALSE, pUndoDoc ); + + // alle Formeln wegen Referenzen + pDoc->CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTabCount-1, + IDF_FORMULA, FALSE, pUndoDoc ); + + // DB- und andere Bereiche + ScRangeName* pDocRange = pDoc->GetRangeName(); + if (pDocRange->GetCount()) + pUndoRange = new ScRangeName( *pDocRange ); + ScDBCollection* pDocDB = pDoc->GetDBCollection(); + if (pDocDB->GetCount()) + pUndoDB = new ScDBCollection( *pDocDB ); + } + +// pDoc->SetOutlineTable( nTab, NULL ); + ScOutlineTable* pOut = pDoc->GetOutlineTable( nTab ); + if (pOut) + pOut->GetRowArray()->RemoveAll(); // nur Zeilen-Outlines loeschen + + if (rParam.bReplace) + pDoc->RemoveSubTotals( nTab, aNewParam ); + BOOL bSuccess = TRUE; + if (bDo) + { + // Sortieren + if ( rParam.bDoSort || pForceNewSort ) + { + pDBData->SetArea( nTab, aNewParam.nCol1,aNewParam.nRow1, aNewParam.nCol2,aNewParam.nRow2 ); + + // Teilergebnis-Felder vor die Sortierung setzen + // (doppelte werden weggelassen, kann darum auch wieder aufgerufen werden) + + ScSortParam aOldSort; + pDBData->GetSortParam( aOldSort ); + ScSortParam aSortParam( aNewParam, pForceNewSort ? *pForceNewSort : aOldSort ); + Sort( aSortParam, FALSE, FALSE ); + } + + bSuccess = pDoc->DoSubTotals( nTab, aNewParam ); + } + ScRange aDirtyRange( aNewParam.nCol1, aNewParam.nRow1, nTab, + aNewParam.nCol2, aNewParam.nRow2, nTab ); + pDoc->SetDirty( aDirtyRange ); + + if (bRecord) + { +// ScDBData* pUndoDBData = pDBData ? new ScDBData( *pDBData ) : NULL; + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoSubTotals( pDocSh, nTab, + rParam, aNewParam.nRow2, + pUndoDoc, pUndoTab, // pUndoDBData, + pUndoRange, pUndoDB ) ); + } + + if (!bSuccess) + { + // "Kann keine Zeilen einfuegen" + ErrorMessage(STR_MSSG_DOSUBTOTALS_2); + } + + // merken + pDBData->SetSubTotalParam( aNewParam ); + pDBData->SetArea( nTab, aNewParam.nCol1,aNewParam.nRow1, aNewParam.nCol2,aNewParam.nRow2 ); + pDoc->CompileDBFormula(); + + DoneBlockMode(); + InitOwnBlockMode(); + rMark.SetMarkArea( ScRange( aNewParam.nCol1,aNewParam.nRow1,nTab, + aNewParam.nCol2,aNewParam.nRow2,nTab ) ); + + pDocSh->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, + PAINT_GRID | PAINT_LEFT | PAINT_TOP | PAINT_SIZE ); + + aModificator.SetDocumentModified(); + + SelectionChanged(); + } +} + +// +// Consolidate +// + +void ScDBFunc::Consolidate( const ScConsolidateParam& rParam, BOOL bRecord ) +{ + ScDocShell* pDocShell = GetViewData()->GetDocShell(); + pDocShell->DoConsolidate( rParam, bRecord ); + SetTabNo( rParam.nTab, TRUE ); +} + +// +// Pivot +// + +String lcl_MakePivotTabName( const String& rPrefix, USHORT nNumber ) +{ + String aName = rPrefix; + aName += String::CreateFromInt32( nNumber ); + return aName; +} + +void ScDBFunc::MakePivotTable( const ScDPSaveData& rData, const ScRange& rDest, BOOL bNewTable, + const ScDPObject& rSource, BOOL bApi ) +{ + // #70096# error message if no fields are set + // this must be removed when drag&drop of fields from a toolbox is available + + if ( rData.IsEmpty() && !bApi ) + { + ErrorMessage(STR_PIVOT_NODATA); + return; + } + + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = GetViewData()->GetDocument(); + + ScRange aDestRange = rDest; + if ( bNewTable ) + { + USHORT nSrcTab = GetViewData()->GetTabNo(); + + String aName( ScGlobal::GetRscString(STR_PIVOT_TABLE) ); + String aStr; + + pDoc->GetName( nSrcTab, aStr ); + aName += '_'; + aName += aStr; + aName += '_'; + + USHORT nNewTab = nSrcTab+1; + + USHORT i=1; + while ( !pDoc->InsertTab( nNewTab, lcl_MakePivotTabName( aName, i ) ) && i <= MAXTAB ) + i++; + + BOOL bAppend = ( nNewTab+1 == pDoc->GetTableCount() ); + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoInsertTab( pDocSh, nNewTab, bAppend, lcl_MakePivotTabName( aName, i ) )); + + GetViewData()->InsertTab( nNewTab ); + SetTabNo( nNewTab, TRUE ); + + aDestRange = ScRange( 0, 0, nNewTab ); + } + + ScDPObject* pDPObj = pDoc->GetDPAtCursor( + aDestRange.aStart.Col(), aDestRange.aStart.Row(), aDestRange.aStart.Tab() ); + + ScDPObject aObj( rSource ); + aObj.SetOutRange( aDestRange ); + aObj.SetSaveData( rData ); + + ScDBDocFunc aFunc( *pDocSh ); + aFunc.DataPilotUpdate( pDPObj, &aObj, TRUE, FALSE ); + + CursorPosChanged(); // shells may be switched + + if ( bNewTable ) + { + pDocSh->PostPaintExtras(); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); + } +} + +void ScDBFunc::DeletePivotTable() +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + ScDPObject* pDPObj = pDoc->GetDPAtCursor( GetViewData()->GetCurX(), + GetViewData()->GetCurY(), + GetViewData()->GetTabNo() ); + if ( pDPObj ) + { + ScDBDocFunc aFunc( *pDocSh ); + aFunc.DataPilotUpdate( pDPObj, NULL, TRUE, FALSE ); + CursorPosChanged(); // shells may be switched + } + else + ErrorMessage(STR_PIVOT_NOTFOUND); +} + +void ScDBFunc::RecalcPivotTable() +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = GetViewData()->GetDocument(); + + // old pivot not used any more + + ScDPObject* pDPObj = pDoc->GetDPAtCursor( GetViewData()->GetCurX(), + GetViewData()->GetCurY(), + GetViewData()->GetTabNo() ); + if ( pDPObj ) + { + ScDBDocFunc aFunc( *pDocSh ); + aFunc.DataPilotUpdate( pDPObj, pDPObj, TRUE, FALSE ); + CursorPosChanged(); // shells may be switched + } + else + ErrorMessage(STR_PIVOT_NOTFOUND); +} + + +// +// DB-Operationen (Sortieren, Filtern, Teilergebnisse) wiederholen +// + +void ScDBFunc::RepeatDB( BOOL bRecord ) +{ + USHORT nCurX = GetViewData()->GetCurX(); + USHORT nCurY = GetViewData()->GetCurY(); + USHORT nTab = GetViewData()->GetTabNo(); + ScDocument* pDoc = GetViewData()->GetDocument(); + ScDBData* pDBData = GetDBData(); + + ScQueryParam aQueryParam; + pDBData->GetQueryParam( aQueryParam ); + BOOL bQuery = aQueryParam.GetEntry(0).bDoQuery; + + ScSortParam aSortParam; + pDBData->GetSortParam( aSortParam ); + BOOL bSort = aSortParam.bDoSort[0]; + + ScSubTotalParam aSubTotalParam; + pDBData->GetSubTotalParam( aSubTotalParam ); + BOOL bSubTotal = aSubTotalParam.bGroupActive[0] && !aSubTotalParam.bRemoveOnly; + + if ( bQuery || bSort || bSubTotal ) + { + BOOL bQuerySize = FALSE; + ScRange aOldQuery; + ScRange aNewQuery; + if (bQuery && !aQueryParam.bInplace) + { + ScDBData* pDest = pDoc->GetDBAtCursor( aQueryParam.nDestCol, aQueryParam.nDestRow, + aQueryParam.nDestTab, TRUE ); + if (pDest && pDest->IsDoSize()) + { + pDest->GetArea( aOldQuery ); + bQuerySize = TRUE; + } + } + + USHORT nDummy; + USHORT nStartCol; + USHORT nStartRow; + USHORT nEndCol; + USHORT nEndRow; + pDBData->GetArea( nDummy, nStartCol, nStartRow, nEndCol, nEndRow ); + + //! Undo nur benoetigte Daten ? + + ScDocument* pUndoDoc = NULL; + ScOutlineTable* pUndoTab = NULL; + ScRangeName* pUndoRange = NULL; + ScDBCollection* pUndoDB = NULL; + + if (bRecord) + { + USHORT nTabCount = pDoc->GetTableCount(); + pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab ); + if (pTable) + { + pUndoTab = new ScOutlineTable( *pTable ); + + USHORT nOutStartCol; // Zeilen/Spaltenstatus + USHORT nOutStartRow; + USHORT nOutEndCol; + USHORT nOutEndRow; + pTable->GetColArray()->GetRange( nOutStartCol, nOutEndCol ); + pTable->GetRowArray()->GetRange( nOutStartRow, nOutEndRow ); + + pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, TRUE ); + pDoc->CopyToDocument( nOutStartCol, 0, nTab, nOutEndCol, MAXROW, nTab, IDF_NONE, FALSE, pUndoDoc ); + pDoc->CopyToDocument( 0, nOutStartRow, nTab, MAXCOL, nOutEndRow, nTab, IDF_NONE, FALSE, pUndoDoc ); + } + else + pUndoDoc->InitUndo( pDoc, nTab, nTab, FALSE, TRUE ); + + // Datenbereich sichern - incl. Filter-Ergebnis + pDoc->CopyToDocument( 0,nStartRow,nTab, MAXCOL,nEndRow,nTab, IDF_ALL, FALSE, pUndoDoc ); + + // alle Formeln wegen Referenzen + pDoc->CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTabCount-1, IDF_FORMULA, FALSE, pUndoDoc ); + + // DB- und andere Bereiche + ScRangeName* pDocRange = pDoc->GetRangeName(); + if (pDocRange->GetCount()) + pUndoRange = new ScRangeName( *pDocRange ); + ScDBCollection* pDocDB = pDoc->GetDBCollection(); + if (pDocDB->GetCount()) + pUndoDB = new ScDBCollection( *pDocDB ); + } + + if (bSort && bSubTotal) + { + // Sortieren ohne SubTotals + + aSubTotalParam.bRemoveOnly = TRUE; // wird unten wieder zurueckgesetzt + DoSubTotals( aSubTotalParam, FALSE ); + } + + if (bSort) + { + pDBData->GetSortParam( aSortParam ); // Bereich kann sich geaendert haben + Sort( aSortParam, FALSE, FALSE); + } + if (bQuery) + { + pDBData->GetQueryParam( aQueryParam ); // Bereich kann sich geaendert haben + ScRange aAdvSource; + if (pDBData->GetAdvancedQuerySource(aAdvSource)) + Query( aQueryParam, &aAdvSource, FALSE ); + else + Query( aQueryParam, NULL, FALSE ); + + // bei nicht-inplace kann die Tabelle umgestellt worden sein + if ( !aQueryParam.bInplace && aQueryParam.nDestTab != nTab ) + SetTabNo( nTab ); + } + if (bSubTotal) + { + pDBData->GetSubTotalParam( aSubTotalParam ); // Bereich kann sich geaendert haben + aSubTotalParam.bRemoveOnly = FALSE; + DoSubTotals( aSubTotalParam, FALSE ); + } + + if (bRecord) + { + USHORT nDummy; + USHORT nNewEndRow; + pDBData->GetArea( nDummy, nDummy,nDummy, nDummy,nNewEndRow ); + + const ScRange* pOld = NULL; + const ScRange* pNew = NULL; + if (bQuerySize) + { + ScDBData* pDest = pDoc->GetDBAtCursor( aQueryParam.nDestCol, aQueryParam.nDestRow, + aQueryParam.nDestTab, TRUE ); + if (pDest) + { + pDest->GetArea( aNewQuery ); + pOld = &aOldQuery; + pNew = &aNewQuery; + } + } + + GetViewData()->GetDocShell()->GetUndoManager()->AddUndoAction( + new ScUndoRepeatDB( GetViewData()->GetDocShell(), nTab, + nStartCol, nStartRow, nEndCol, nEndRow, + nNewEndRow, + nCurX, nCurY, + pUndoDoc, pUndoTab, + pUndoRange, pUndoDB, + pOld, pNew ) ); + } + + GetViewData()->GetDocShell()->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, + PAINT_GRID | PAINT_LEFT | PAINT_TOP | PAINT_SIZE ); + } + else // "Keine Operationen auszufuehren" + ErrorMessage(STR_MSSG_REPEATDB_0); +} + + + + diff --git a/sc/source/ui/view/dbfunc4.cxx b/sc/source/ui/view/dbfunc4.cxx new file mode 100644 index 000000000000..0e4b7dd6ed32 --- /dev/null +++ b/sc/source/ui/view/dbfunc4.cxx @@ -0,0 +1,435 @@ +/************************************************************************* + * + * $RCSfile: dbfunc4.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +// TOOLS +#define _BIGINT_HXX +#define _SFXMULTISEL_HXX +#define _STACK_HXX +#define _QUEUE_HXX +#define _DYNARR_HXX +#define _TREELIST_HXX +#define _CACHESTR_HXX +#define _NEW_HXX +//#define _SHL_HXX +//#define _LINK_HXX +//#define _ERRCODE_HXX +//#define _GEN_HXX +//#define _FRACT_HXX +//#define _STRING_HXX +//#define _MTF_HXX +//#define _CONTNR_HXX +//#define _LIST_HXX +//#define _TABLE_HXX +#define _DYNARY_HXX +//#define _UNQIDX_HXX +#define _SVMEMPOOL_HXX +//#define _UNQID_HXX +//#define _DEBUG_HXX +//#define _DATE_HXX +//#define _TIME_HXX +//#define _DATETIME_HXX +//#define _INTN_HXX +//#define _WLDCRD_HXX +//#define _FSYS_HXX +//#define _STREAM_HXX +#define _CACHESTR_HXX +#define _SV_MULTISEL_HXX + +//SV +#define _CLIP_HXX +//#define _CONFIG_HXX +#define _CURSOR_HXX +#define _FONTDLG_HXX +#define _PRVWIN_HXX +//#define _COLOR_HXX +//#define _PAL_HXX +//#define _BITMAP_HXX +//#define _GDIOBJ_HXX +//#define _POINTR_HXX +//#define _ICON_HXX +//#define _IMAGE_HXX +//#define _KEYCOD_HXX +//#define _EVENT_HXX +#define _HELP_HXX +//#define _APP_HXX +//#define _MDIAPP_HXX +//#define _TIMER_HXX +//#define _METRIC_HXX +//#define _REGION_HXX +//#define _OUTDEV_HXX +//#define _SYSTEM_HXX +//#define _VIRDEV_HXX +//#define _JOBSET_HXX +//#define _PRINT_HXX +//#define _WINDOW_HXX +//#define _SYSWIN_HXX +//#define _WRKWIN_HXX +#define _MDIWIN_HXX +//#define _FLOATWIN_HXX +//#define _DOCKWIN_HXX +//#define _CTRL_HXX +//#define _SCRBAR_HXX +//#define _BUTTON_HXX +//#define _IMAGEBTN_HXX +//#define _FIXED_HXX +//#define _GROUP_HXX +//#define _EDIT_HXX +//#define _COMBOBOX_HXX +//#define _LSTBOX_HXX +#define _SELENG_HXX +//#define _SPLIT_HXX +#define _SPIN_HXX +//#define _FIELD_HXX +#define _MOREBTN_HXX +//#define _TOOLBOX_HXX +#define _STATUS_HXX +//#define _DIALOG_HXX +//#define _MSGBOX_HXX +//#define _SYSDLG_HXX +#define _FILDLG_HXX +//#define _PRNDLG_HXX +#define _COLDLG_HXX +//#define _TABDLG_HXX +#ifdef WIN +#define _MENU_HXX +#endif +//#define _GDIMTF_HXX +//#define _POLY_HXX +//#define _ACCEL_HXX +//#define _GRAPH_HXX +#define _SOUND_HXX + +#if defined WIN +#define _MENUBTN_HXX +#endif + +//svtools +#define _SCRWIN_HXX +#define _RULER_HXX +//#define _TABBAR_HXX +//#define _VALUESET_HXX +#define _STDMENU_HXX +//#define _STDCTRL_HXX +//#define _CTRLBOX_HXX +#define _CTRLTOOL_HXX +#define _EXTATTR_HXX +#define _FRM3D_HXX +#define _EXTATTR_HXX + +//SVTOOLS +#define _SVTREELIST_HXX +#define _FILTER_HXX +#define _SVLBOXITM_HXX +#define _SVTREEBOX_HXX +#define _SVICNVW_HXX +#define _SVTABBX_HXX + +//sfxcore.hxx +#define _SFXINIMGR_HXX +//#define _SFXCFGITEM_HXX +//#define _SFX_PRINTER_HXX +#define _SFXGENLINK_HXX +#define _SFXHINTPOST_HXX +#define _SFXDOCINF_HXX +#define _SFXLINKHDL_HXX +//#define _SFX_PROGRESS_HXX + +//sfxsh.hxx +//#define _SFX_SHELL_HXX +//#define _SFXAPP_HXX +//#define _SFX_BINDINGS_HXX +//#define _SFXDISPATCH_HXX +//#define _SFXMSG_HXX +#define _SFXOBJFACE_HXX +//#define _SFXREQUEST_HXX +#define _SFXMACRO_HXX + +// SFX +#define _SFXAPPWIN_HXX +#define _SFX_SAVEOPT_HXX +//#define _SFX_CHILDWIN_HXX +//#define _SFXCTRLITEM_HXX +#define _SFXPRNMON_HXX +#define _INTRO_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFXFILEDLG_HXX +#define _PASSWD_HXX +#define _SFXTBXCTRL_HXX +#define _SFXSTBITEM_HXX +#define _SFXMNUITEM_HXX +#define _SFXIMGMGR_HXX +#define _SFXTBXMGR_HXX +#define _SFXSTBMGR_HXX +#define _SFX_MINFITEM_HXX +#define _SFXEVENT_HXX + +//sfxdoc.hxx +//#define _SFX_OBJSH_HXX +//#define _SFX_CLIENTSH_HXX +//#define _SFXDOCINF_HXX +//#define _SFX_OBJFAC_HXX +//#define _SFX_DOCFILT_HXX +#define _SFXDOCFILE_HXX +//define _VIEWFAC_HXX +//#define _SFXVIEWFRM_HXX +//#define _SFXVIEWSH_HXX +#define _MDIFRM_HXX +#define _SFX_IPFRM_HXX +//#define _SFX_INTERNO_HXX + +//sfxdlg.hxx +//#define _SFXTABDLG_HXX +#define _BASEDLGS_HXX +#define _SFX_DINFDLG_HXX +#define _SFXDINFEDT_HXX +#define _SFX_MGETEMPL_HXX +#define _SFX_TPLPITEM_HXX +//#define _SFX_STYLEDLG_HXX +#define _NEWSTYLE_HXX +#define _SFXDOCTEMPL_HXX +#define _SFXDOCTDLG_HXX +#define _SFX_TEMPLDLG_HXX +#define _SFXNEW_HXX +#define _SFXDOCMAN_HXX +#define _SFXDOCKWIN_HXX + +//sfxitems.hxx +#define _SFX_WHMAP_HXX +//#define _ARGS_HXX +//#define _SFXPOOLITEM_HXX +//#define _SFXINTITEM_HXX +//#define _SFXENUMITEM_HXX +#define _SFXFLAGITEM_HXX +//#define _SFXSTRITEM_HXX +#define _SFXPTITEM_HXX +#define _SFXRECTITEM_HXX +//#define _SFXITEMPOOL_HXX +//#define _SFXITEMSET_HXX +#define _SFXITEMITER_HXX +#define _SFX_WHITER_HXX +#define _SFXPOOLCACH_HXX +//#define _AEITEM_HXX +#define _SFXRNGITEM_HXX +//#define _SFXSLSTITM_HXX +//#define _SFXSTYLE_HXX + +//xout.hxx +//#define _XENUM_HXX +//#define _XPOLY_HXX +//#define _XATTR_HXX +//#define _XOUTX_HXX +//#define _XPOOL_HXX +//#define _XTABLE_HXX + +//svdraw.hxx +//#define _SVDRAW_HXX +#define _SDR_NOITEMS +#define _SDR_NOTOUCH +#define _SDR_NOTRANSFORM +#define _SDR_NOVIEWMARKER +#define _SDR_NODRAGMETHODS +//#define _SDR_NOUNDO +#define _SDR_NOXOUTDEV +//#define _SDR_NOOBJECTS +//#define _SDR_NOVIEWS + +//#define SI_NOITEMS +//#define SI_NODRW +#define _SI_NOSBXCONTROLS +//#define _VCATTR_HXX +#define _VCONT_HXX +//#define _VCSBX_HXX +#define _SI_NOOTHERFORMS +#define _VCTRLS_HXX +//#define _VCDRWOBJ_HXX +#define _SI_NOCONTROL +#define _SETBRW_HXX +#define _VCBRW_HXX +#define _SI_NOSBXCONTROLS +#define _SIDLL_HXX + +//svdraw.hxx +#define _SDR_NOTRANSFORM // Transformationen, selten verwendet +#define _SDR_NOTOUCH // Hit-Tests, selten verwendet + +#define _SDR_NOEXTDEV // ExtOutputDevice +//#define _SDR_NOUNDO // Undo-Objekte +#define _SDR_NOSURROGATEOBJ // SdrObjSurrogate +#define _SDR_NOPAGEOBJ // SdrPageObj +#define _SDR_NOVIRTOBJ // SdrVirtObj +#define _SDR_NOGROUPOBJ // SdrGroupObj +//#define _SDR_NOTEXTOBJ // SdrTextObj +#define _SDR_NOPATHOBJ // SdrPathObj +#define _SDR_NOEDGEOBJ // SdrEdgeObj +//#define _SDR_NORECTOBJ // SdrRectObj +#define _SDR_NOCAPTIONOBJ // SdrCaptionObj +#define _SDR_NOCIRCLEOBJ // SdrCircleObj +#define _SDR_NOGRAFOBJ // SdrGrafObj +//#define _SDR_NOOLE2OBJ // SdrOle2Obj +//#define _SVDLAYER_HXX +//#define _SVDATTR_HXX +//#define _SVDIO_HXX +#define _SVBOXITM_HXX +#define _SVDEC_HXX +#define _SVDXOUT_HXX + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_THESDLG_HXX + + +// INCLUDE --------------------------------------------------------------- + +#include <svx/svditer.hxx> +#include <svx/svdoole2.hxx> +#include <svx/svdpage.hxx> +#include <so3/ipobj.hxx> +#include <sch/schdll.hxx> +#include <sch/memchrt.hxx> + +#include "chartarr.hxx" +#include "drwlayer.hxx" +#include "document.hxx" + +// ----------------------------------------------------------------------- + +#ifdef WNT +#pragma optimize ( "", off ) +#endif + +//================================================================== + +USHORT DoUpdateCharts( ScAddress aPos, ScDocument* pDoc, + Window* pActiveWin, BOOL bAllCharts ) +{ + ScDrawLayer* pModel = pDoc->GetDrawLayer(); + if (!pModel) + return 0; + + USHORT nFound = 0; + + USHORT nPageCount = pModel->GetPageCount(); + for (USHORT nPageNo=0; nPageNo<nPageCount; nPageNo++) + { + SdrPage* pPage = pModel->GetPage(nPageNo); + DBG_ASSERT(pPage,"Page ?"); + + SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS ); + SdrObject* pObject = aIter.Next(); + while (pObject) + { + if ( pObject->GetObjIdentifier() == OBJ_OLE2 ) + { + SvInPlaceObjectRef aIPObj = ((SdrOle2Obj*)pObject)->GetObjRef(); + if (aIPObj.Is()) + { + const SchMemChart* pChartData = SchDLL::GetChartData(aIPObj); + if ( pChartData ) + { + ScChartArray aArray( pDoc, *pChartData ); + if (aArray.IsValid()) + { + if ( bAllCharts || aArray.IsAtCursor(aPos) ) + { + SchMemChart* pMemChart = aArray.CreateMemChart(); + ScChartArray::CopySettings( *pMemChart, *pChartData ); + + SchDLL::Update( aIPObj, pMemChart, pActiveWin ); + delete pMemChart; + ++nFound; + + pObject->SendRepaintBroadcast(); + } + } + } + } + } + pObject = aIter.Next(); + } + } + return nFound; +} + + + + + + diff --git a/sc/source/ui/view/drawattr.cxx b/sc/source/ui/view/drawattr.cxx new file mode 100644 index 000000000000..1d9c9c768fbd --- /dev/null +++ b/sc/source/ui/view/drawattr.cxx @@ -0,0 +1,118 @@ +/************************************************************************* + * + * $RCSfile: drawattr.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +#include "segmentc.hxx" +#include "drawattr.hxx" +#include "global.hxx" + +//------------------------------------------------------------------------ + +String __EXPORT SvxDrawToolItem::GetValueText() const +{ + return GetValueText(GetValue()); +} + +//------------------------------------------------------------------------ + +String __EXPORT SvxDrawToolItem::GetValueText( USHORT nVal ) const +{ + const sal_Char* p; + + switch (nVal) + { + case 0 : p = "SVX_SNAP_DRAW_SELECT" ; break; + // + case 1 : p = "SVX_SNAP_DRAW_LINE" ; break; + case 2 : p = "SVX_SNAP_DRAW_RECT" ; break; + case 3 : p = "SVX_SNAP_DRAW_ELLIPSE" ; break; + case 4 : p = "SVX_SNAP_DRAW_POLYGON" ; break; + case 5 : p = "SVX_SNAP_DRAW_ARC" ; break; + case 6 : p = "SVX_SNAP_DRAW_PIE" ; break; + case 7 : p = "SVX_SNAP_DRAW_CIRCLECUT" ; break; + case 8 : p = "SVX_SNAP_DRAW_TEXT" ; break; + default : return EMPTY_STRING; + } + return String::CreateFromAscii( p ); +} + +//------------------------------------------------------------------------ + +SfxPoolItem* __EXPORT SvxDrawToolItem::Clone( SfxItemPool * ) const +{ + return new SvxDrawToolItem(*this); +} + +//------------------------------------------------------------------------ + +SfxPoolItem* __EXPORT SvxDrawToolItem::Create( SvStream& rStream, USHORT nVer ) const +{ + USHORT nVal; + rStream >> nVal; + return new SvxDrawToolItem(nVal); +} + + + diff --git a/sc/source/ui/view/drawutil.cxx b/sc/source/ui/view/drawutil.cxx new file mode 100644 index 000000000000..cd7eb361d3e5 --- /dev/null +++ b/sc/source/ui/view/drawutil.cxx @@ -0,0 +1,126 @@ +/************************************************************************* + * + * $RCSfile: drawutil.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include <vcl/outdev.hxx> + +#include "drawutil.hxx" +#include "document.hxx" +#include "global.hxx" + +// STATIC DATA ----------------------------------------------------------- + +// ----------------------------------------------------------------------- + + +inline Fraction MakeFraction( long nA, long nB ) +{ + return ( nA && nB ) ? Fraction(nA,nB) : Fraction(1,1); +} + +void ScDrawUtil::CalcScale( ScDocument* pDoc, USHORT nTab, + USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow, + OutputDevice* pDev, + const Fraction& rZoomX, const Fraction& rZoomY, + double nPPTX, double nPPTY, + Fraction& rScaleX, Fraction& rScaleY ) +{ + USHORT i; + + long nPixelX = 0; + long nTwipsX = 0; + long nPixelY = 0; + long nTwipsY = 0; + for (i=nStartCol; i<nEndCol; i++) + { + long nWidth = (long) pDoc->GetColWidth(i,nTab); + nTwipsX += nWidth; + nPixelX += (long) ( nWidth * nPPTX ); + } + for (i=nStartRow; i<nEndRow; i++) + { + long nHeight = (long) pDoc->GetRowHeight(i,nTab); + nTwipsY += nHeight; + nPixelY += (long) ( nHeight * nPPTY ); + } + + MapMode aHMMMode( MAP_100TH_MM, Point(), rZoomX, rZoomY ); + Point aPixelLog = pDev->PixelToLogic( Point( nPixelX,nPixelY ), aHMMMode ); + + rScaleX = MakeFraction( aPixelLog.X() * rZoomX.GetNumerator(), + (long) ( nTwipsX * HMM_PER_TWIPS * rZoomX.GetDenominator() ) ); + rScaleY = MakeFraction( aPixelLog.Y() * rZoomY.GetNumerator(), + (long) ( nTwipsY * HMM_PER_TWIPS * rZoomY.GetDenominator() ) ); + + rScaleX.ReduceInaccurate( 14 ); + rScaleY.ReduceInaccurate( 14 ); +} + + + + diff --git a/sc/source/ui/view/drawvie2.cxx b/sc/source/ui/view/drawvie2.cxx new file mode 100644 index 000000000000..20f3dcdd2d6f --- /dev/null +++ b/sc/source/ui/view/drawvie2.cxx @@ -0,0 +1,97 @@ +/************************************************************************* + * + * $RCSfile: drawvie2.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "drawview.hxx" + +// STATIC DATA ----------------------------------------------------------- + +// ----------------------------------------------------------------------- + + +// UpdateBrowser in MarkListHasChanged gerufen + +void ScDrawView::UpdateBrowser() +{ + // VC's und den Browser dazu gibts nicht mehr... +} + +void ScDrawView::VCAddWin( Window* pWin ) +{ + // GetSbxForm gibt's nicht mehr, muss auch nichts mehr angemeldet werden +} + +void ScDrawView::VCRemoveWin( Window* pWin ) +{ + // GetSbxForm gibt's nicht mehr, muss auch nichts mehr angemeldet werden +} + + + + + diff --git a/sc/source/ui/view/drawvie3.cxx b/sc/source/ui/view/drawvie3.cxx new file mode 100644 index 000000000000..95b5a316e2c3 --- /dev/null +++ b/sc/source/ui/view/drawvie3.cxx @@ -0,0 +1,354 @@ +/************************************************************************* + * + * $RCSfile: drawvie3.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +//sfxitems.hxx +//#define _SFXINTITEM_HXX +//#define _SFXENUMITEM_HXX +#define _SFXFLAGITEM_HXX +//#define _SFXSTRITEM_HXX +#define _SFXPTITEM_HXX +#define _SFXRECTITEM_HXX +#define _AEITEM_HXX +#define _SFXRNGITEM_HXX +#define _SFXSLSTITM_HXX + +//sfx.hxx +//#define _SFX_HXX *** +#define _SFXAPPWIN_HXX +#define _SFX_SAVEOPT_HXX +//#define _SFX_CHILDWIN_HXX *** +#define _SFXCTRLITEM_HXX +#define _SFX_PRNMON_HXX +#define _INTRO_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFXFILEDLG_HXX +#define _PASSW_HXX +#define _SFXTBXCTRL_HXX +#define _SFXSTBITEM_HXX +#define _SFXMNUITEM_HXX +#define _SFXIMGMGR_HXX +#define _SFXTBXMGR_HXX +#define _SFXSTBMGR_HXX +#define _SFX_MINFITEM_HXX +#define _SFXEVENT_HXX + +//sfxdlg.hxx +//#define _SFXDLG_HXX *** +//#define _SFXTABDLG_HXX *** +#define _BASEDLGS_HXX +#define _DINFDLG_HXX +#define _SFXDINFEDT_HXX +#define _SFX_MGETEMPL_HXX +#define _SFX_TPLPITEM_HXX +#define _SFX_STYLEDLG_HXX +#define _NEWSTYLE_HXX +#define _SFXDOCTEMPL_HXX +#define _SFXDOCTDLG_HXX +//#define _SFXDOCKWIN_HXX +#define _SFX_TEMPLDLG_HXX +#define _SFXNEW_HXX +#define _SFXDOCMAN_HXX + +//sfxsh.hxx +//#define _SFXSH_HXX +//#define _SFX_SHELL_HXX +//#define _SFXAPP_HXX +//#define _SFX_BINDINGS_HXX +#define _SFXDISPATCH_HXX +#define _SFXMSG_HXX +#define _SFXOBJFACE_HXX +#define _SFXREQUEST_HXX +#define _SFXMACRO_HXX + +//sfxdoc.hxx +//#define _SFXDOC_HXX *** +//#define _SFX_OBJSH_HXX *** +//#define _SFX_CLIENTSH_HXX *** +#define _SFX_DOCFILT_HACK_HXX +#define _SFX_FCONTNR_HXX +#define _SFXDOCFILE_HXX +//#define _SFXFRAME_HXX *** +//#define _SFXVIEWFRM_HXX *** +//#define _SFXVIEWSH_HXX *** +#define _MDIFRM_HXX +#define _SFX_IPFRM_HXX +#define _SFX_INTERNO_HXX +#define _FSETOBJSH_HXX + +//si.hxx +//#define _SI_HXX *** +#define _SIDLL_HXX +#define _VCATTR_HXX +#define _VCONT_HXX +//#define _VCSBX_HXX ??? +//#define _SI_NOVCSBXFORM *** +#define SI_NOOTHERFORMS +#define _SI_NOVCSBXBUTTON +#define _SI_NOVCSBXCHECKBOX +#define _SI_NOVCSBXRADIOBUTTON +#define _SI_NOVCSBXPUSHBUTTON +#define _SI_NOVCSBXSPINBUTTON +#define _SI_NOVCSBXFIXEDTEXT +#define _SI_NOVCSBXGROUPBOX +#define _SI_NOVCSBXLISTBOX +#define _SI_NOVCSBXCOMBOBOX +#define _SI_NOVCSBXEDIT +//#define _SI_NOVCSBXSCROLLBAR *** +#define _SI_NOVCSBXHSCROLLBAR +#define _SI_BOVCSBXVSCROLLBAR +#define _SI_NOVCSBXPREVIEW +#define _SI_NOVCSBXURLBUTTON +#define _VCTRLS_HXX +//#define _VCDRWOBJ_HXX *** +//#define _SI_NOVCDRAWMODEL +#define _SI_NOVCDRAWPAGE +//#define _SI_NOVCDRAWVIEW *** +#define _VCBRW_HXX +#define _VCFORM_HXX + +//svdrwobt.hxx +//#define _SVDOATTR_HXX +//#define _SVDOTEXT_HXX +#define _SVDRAW_HXX + +//svdraw.hxx +#define _SVDRAW_HXX +#define _SDR_NOITEMS +#define _SDR_NOTOUCH +#define _SDR_NOTRANSFORM +#define _SDR_NOOBJECTS +#define _SDR_NOVIEWS +#define _SDR_NOVIEWMARKER +#define _SDR_NODRAGMETHODS +#define _SDR_NOUNDO +#define _SDR_NOXOUTDEV + +//svdrwobx.hxx +//#define _SVDRWOBX_HXX *** +#define _SVDOUKWN_HXX +//#define _SVDORECT_HXX *** +#define _SVDCAPT_HXX +#define _SVDOCIRC_HXX +//#define _SVDOEDGE_HXX +//#define _SVDOGRAF_HXX +#define _SVDOGRP_HXX +#define _SVDOMEAS_HXX +//#define _SVDOOLE2_HXX *** +#define _SVDOPAGE_HXX +#define _SVDOPATH_HXX + +// INCLUDE --------------------------------------------------------------- + +#include <svx/svdograf.hxx> +#include <svx/svdoole2.hxx> +#include <sfx2/app.hxx> +#include <sfx2/viewfrm.hxx> + +#include "drawview.hxx" +#include "drwlayer.hxx" +#include "viewdata.hxx" +#include "dbfunc.hxx" +#include "document.hxx" +#include "userdat.hxx" +#include "tabvwsh.hxx" + +void ScIMapDlgSet( const Graphic& rGraphic, const ImageMap* pImageMap, + const TargetList* pTargetList, void* pEditingObj ); // imapwrap +USHORT ScIMapChildWindowId(); + +// STATIC DATA ----------------------------------------------------------- + +ScDrawView::ScDrawView( OutputDevice* pOut, ScViewData* pData ) : + FmFormView( pData->GetDocument()->GetDrawLayer(), pOut ), + pViewData( pData ), + pDev( pOut ), + pDoc( pData->GetDocument() ), + nTab( pData->GetTabNo() ), + pDropMarker( NULL ), + pDropMarkObj( NULL ), + bDisableHdl( FALSE ), + bInConstruct( TRUE ) +{ + Construct(); +} + +ScDrawView::ScDrawView( OutputDevice* pOut, ScDocument* pDocument, USHORT nTable ) : + FmFormView( pDocument->GetDrawLayer(), pOut ), + pViewData( NULL ), + pDev( pOut ), + pDoc( pDocument ), + nTab( nTable ), + pDropMarker( NULL ), + pDropMarkObj( NULL ), + bDisableHdl( FALSE ), + bInConstruct( TRUE ) +{ + Construct(); +} + +// Verankerung setzen + +void ScDrawView::SetAnchor( ScAnchorType eType ) +{ + SdrObject* pObj = NULL; + if( HasMarkedObj() ) + { + const SdrMarkList* pMark = &GetMarkList(); + ULONG nCount = pMark->GetMarkCount(); + for( ULONG i=0; i<nCount; i++ ) + { + pObj = pMark->GetMark(i)->GetObj(); + ScDrawLayer::SetAnchor( pObj, eType ); + } + } +} + +ScAnchorType ScDrawView::GetAnchor() const +{ + BOOL bPage = FALSE; + BOOL bCell = FALSE; + const SdrObject* pObj = NULL; + if( HasMarkedObj() ) + { + const SdrMarkList* pMark = &GetMarkList(); + ULONG nCount = pMark->GetMarkCount(); + Point p0; + for( ULONG i=0; i<nCount; i++ ) + { + pObj = pMark->GetMark(i)->GetObj(); + if( ScDrawLayer::GetAnchor( pObj ) == SCA_CELL ) + bCell =TRUE; + else + bPage = TRUE; + } + } + if( bPage && !bCell ) + return SCA_PAGE; + if( !bPage && bCell ) + return SCA_CELL; + return SCA_DONTKNOW; +} + +void __EXPORT ScDrawView::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, + const SfxHint& rHint, const TypeId& rHintType ) +{ + if (rHint.ISA(ScTabDeletedHint)) // Tabelle geloescht + { + USHORT nDelTab = ((ScTabDeletedHint&)rHint).GetTab(); + if (nDelTab <= MAXTAB) + HidePagePgNum(nDelTab); + } + else if (rHint.ISA(ScTabSizeChangedHint)) // Groesse geaendert + { + if ( nTab == ((ScTabSizeChangedHint&)rHint).GetTab() ) + UpdateWorkArea(); + } + else + FmFormView::SFX_NOTIFY( rBC,rBCType,rHint,rHintType ); +} + +void ScDrawView::UpdateIMap( SdrObject* pObj ) +{ + if ( pViewData && + pViewData->GetViewShell()->GetViewFrame()->HasChildWindow( ScIMapChildWindowId() ) && + pObj && ( pObj->ISA(SdrGrafObj) || pObj->ISA(SdrOle2Obj) ) ) + { + Graphic aGraphic; + TargetList aTargetList; + ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo( pObj ); + const ImageMap* pImageMap = NULL; + if ( pIMapInfo ) + pImageMap = &pIMapInfo->GetImageMap(); + + // Target-Liste besorgen + pViewData->GetViewShell()->GetViewFrame()->GetTargetList( aTargetList ); + + // Grafik vom Objekt besorgen + if ( pObj->ISA( SdrGrafObj ) ) + aGraphic = ( (SdrGrafObj*) pObj )->GetGraphic(); + else + aGraphic = ScDrawLayer::GetGraphicFromOle2Obj( + (const SdrOle2Obj*) pObj ); + + ScIMapDlgSet( aGraphic, pImageMap, &aTargetList, pObj ); // aus imapwrap + + // TargetListe kann von uns wieder geloescht werden + String* pEntry = aTargetList.First(); + while( pEntry ) + { + delete pEntry; + pEntry = aTargetList.Next(); + } + } +} + + + + diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx new file mode 100644 index 000000000000..74270f2c5d43 --- /dev/null +++ b/sc/source/ui/view/drawvie4.cxx @@ -0,0 +1,684 @@ +/************************************************************************* + * + * $RCSfile: drawvie4.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +// TOOLS +#define _BIGINT_HXX +#define _SFXMULTISEL_HXX +#define _STACK_HXX +#define _QUEUE_HXX +#define _DYNARR_HXX +#define _TREELIST_HXX +#define _CACHESTR_HXX +#define _NEW_HXX +//#define _SHL_HXX +//#define _LINK_HXX +//#define _ERRCODE_HXX +//#define _GEN_HXX +//#define _FRACT_HXX +//#define _STRING_HXX +//#define _MTF_HXX +//#define _CONTNR_HXX +//#define _LIST_HXX +//#define _TABLE_HXX +#define _DYNARY_HXX +//#define _UNQIDX_HXX +#define _SVMEMPOOL_HXX +//#define _UNQID_HXX +//#define _DEBUG_HXX +//#define _DATE_HXX +//#define _TIME_HXX +//#define _DATETIME_HXX +//#define _INTN_HXX +//#define _WLDCRD_HXX +//#define _FSYS_HXX +//#define _STREAM_HXX +#define _CACHESTR_HXX +#define _SV_MULTISEL_HXX + +//SV +//#define _CLIP_HXX +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _FONTDLG_HXX +#define _PRVWIN_HXX +//#define _COLOR_HXX +//#define _PAL_HXX +//#define _BITMAP_HXX +//#define _GDIOBJ_HXX +//#define _POINTR_HXX +//#define _ICON_HXX +//#define _IMAGE_HXX +//#define _KEYCOD_HXX +//#define _EVENT_HXX +#define _HELP_HXX +//#define _APP_HXX +//#define _MDIAPP_HXX +//#define _TIMER_HXX +//#define _METRIC_HXX +//#define _REGION_HXX +//#define _OUTDEV_HXX +//#define _SYSTEM_HXX +//#define _VIRDEV_HXX +//#define _JOBSET_HXX +//#define _PRINT_HXX +//#define _WINDOW_HXX +//#define _SYSWIN_HXX +//#define _WRKWIN_HXX +#define _MDIWIN_HXX +//#define _FLOATWIN_HXX +//#define _DOCKWIN_HXX +//#define _CTRL_HXX +//#define _SCRBAR_HXX +//#define _BUTTON_HXX +//#define _IMAGEBTN_HXX +//#define _FIXED_HXX +//#define _GROUP_HXX +//#define _EDIT_HXX +//#define _COMBOBOX_HXX +//#define _LSTBOX_HXX +//#define _SELENG_HXX +//#define _SPLIT_HXX +#define _SPIN_HXX +//#define _FIELD_HXX +//#define _MOREBTN_HXX +//#define _TOOLBOX_HXX +//#define _STATUS_HXX +//#define _DIALOG_HXX +//#define _MSGBOX_HXX +//#define _SYSDLG_HXX +//#define _FILDLG_HXX +//#define _PRNDLG_HXX +#define _COLDLG_HXX +//#define _TABDLG_HXX +//#define _MENU_HXX +//#define _GDIMTF_HXX +//#define _POLY_HXX +//#define _ACCEL_HXX +//#define _GRAPH_HXX +#define _SOUND_HXX + +// ------------------------- +//svtools +#define _SCRWIN_HXX +#define _RULER_HXX +#define _TABBAR_HXX //* +#define _VALUESET_HXX //* +#define _STDMENU_HXX +#define _STDCTRL_HXX //* +#define _CTRLBOX_HXX //* +#define _CTRLTOOL_HXX +#define _EXTATTR_HXX +#define _FRM3D_HXX +#define _EXTATTR_HXX + +//SVTOOLS +//#define _SVTREELIST_HXX +#define _FILTER_HXX +//#define _SVLBOXITM_HXX +//#define _SVTREEBOX_HXX +#define _SVICNVW_HXX +#define _SVTABBX_HXX + +//sfxcore.hxx +//#define _SFXINIMGR_HXX +//#define _SFXCFGITEM_HXX +//#define _SFX_PRINTER_HXX +#define _SFXGENLINK_HXX +#define _SFXHINTPOST_HXX +//#define _SFXDOCINF_HXX +#define _SFXLINKHDL_HXX +//#define _SFX_PROGRESS_HXX + +//------------------------- + +//sfxsh.hxx +//#define _SFX_SHELL_HXX +//#define _SFXAPP_HXX +#define _SFX_BINDINGS_HXX //??? +#define _SFXDISPATCH_HXX //??? +//#define _SFXMSG_HXX +//#define _SFXOBJFACE_HXX +//#define _SFXREQUEST_HXX +#define _SFXMACRO_HXX + +// SFX +//#define _SFXAPPWIN_HXX +#define _SFX_SAVEOPT_HXX +//#define _SFX_CHILDWIN_HXX *** +//#define _SFXCTRLITEM_HXX +#define _SFXPRNMON_HXX +#define _INTRO_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFXFILEDLG_HXX +#define _PASSWD_HXX +#define _SFXTBXCTRL_HXX +#define _SFXSTBITEM_HXX +#define _SFXMNUITEM_HXX +#define _SFXIMGMGR_HXX +#define _SFXTBXMGR_HXX +#define _SFXSTBMGR_HXX +#define _SFX_MINFITEM_HXX +#define _SFXEVENT_HXX + +//sfxdoc.hxx +//#define _SFX_OBJSH_HXX +//#define _SFX_CLIENTSH_HXX +//#define _SFXDOCINF_HXX +//#define _SFX_OBJFAC_HXX +#define _SFX_DOCFILT_HXX +//#define _SFXDOCFILE_HXX +//define _VIEWFAC_HXX +//#define _SFXVIEWFRM_HXX +//#define _SFXVIEWSH_HXX +//#define _MDIFRM_HXX +//#define _SFX_IPFRM_HXX +//#define _SFX_INTERNO_HXX + +//sfxdlg.hxx +//#define _SFXTABDLG_HXX +//#define _BASEDLGS_HXX +#define _SFX_DINFDLG_HXX +#define _SFXDINFEDT_HXX +#define _SFX_MGETEMPL_HXX +#define _SFX_TPLPITEM_HXX +//#define _SFX_STYLEDLG_HXX +#define _NEWSTYLE_HXX +//#define _SFXDOCTEMPL_HXX +//#define _SFXDOCTDLG_HXX +//#define _SFX_TEMPLDLG_HXX +//#define _SFXNEW_HXX +#define _SFXDOCMAN_HXX +//#define _SFXDOCKWIN_HXX //* + +//sfxitems.hxx +#define _SFX_WHMAP_HXX +//#define _ARGS_HXX *** +//#define _SFXPOOLITEM_HXX +//#define _SFXINTITEM_HXX +//#define _SFXENUMITEM_HXX +#define _SFXFLAGITEM_HXX +//#define _SFXSTRITEM_HXX +#define _SFXPTITEM_HXX +#define _SFXRECTITEM_HXX +//#define _SFXITEMPOOL_HXX +//#define _SFXITEMSET_HXX +#define _SFXITEMITER_HXX +#define _SFX_WHITER_HXX +#define _SFXPOOLCACH_HXX +//#define _AEITEM_HXX +#define _SFXRNGITEM_HXX +//#define _SFXSLSTITM_HXX +#define _SFXSTYLE_HXX //??? + +//xout.hxx +//#define _XENUM_HXX +//#define _XPOLY_HXX +//#define _XATTR_HXX +//#define _XOUTX_HXX +//#define _XPOOL_HXX +//#define _XTABLE_HXX + +//svdraw.hxx +#define _SDR_NOITEMS +#define _SDR_NOTOUCH +#define _SDR_NOTRANSFORM +//#define _SDR_NOOBJECTS +//#define _SDR_NOVIEWS + +//#define SI_NOITEMS +//#define SI_NODRW +#define _SI_NOSBXCONTROLS +//#define _VCATTR_HXX +#define _VCONT_HXX +//#define _VCSBX_HXX +#define _SI_NOOTHERFORMS +#define _VCTRLS_HXX +//#define _VCDRWOBJ_HXX +#define _SI_NOCONTROL +#define _SETBRW_HXX +#define _VCBRW_HXX +#define _SI_NOSBXCONTROLS +//#define _SIDLL_HXX + + +#define _SV_NOXSOUND + +#ifdef WIN +#define _MENUBTN_HXX +#endif + +#define _BASE_DLGS_HXX +#define _BIGINT_HXX +#define _CACHESTR_HXX +#define _CONFIG_HXX +#define _CURSOR_HXX + +#define _SVBOXITM_HXX +#define _SVDRAG_HXX +#define _SVINCVW_HXX +#define _SV_MULTISEL_HXX +#define _SVRTV_HXX +#define _SVTABBX_HXX + +#define _SVX_FRMITEMS_HXX + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_THESDLG_HXX + +#define SI_NOITEMS +//#define SI_NODRW +#define _SI_NOSBXCONTROLS +#define _VCATTR_HXX +#define _VCONT_HXX +//#define _VCSBX_HXX +#define _SI_NOOTHERFORMS +#define _VCTRLS_HXX +//#define _VCDRWOBJ_HXX +#define _SI_NOCONTROL +#define _SETBRW_HXX +#define _VCBRW_HXX +#define _SI_NOSBXCONTROLS +#define _SIDLL_HXX + +//#define _SI_HXX +#define _SDR_NOTRANSFORM +#define _SDR_NOTOUCH +#define _SVDOPAGE_HXX // SdrPageObj +#define _SVDSURO_HXX // SdrObjSurrogate +#define _SVDOVIRT_HXX // SdrVirtObj +#define _SVDOGRP_HXX // SdrGroupObj +//#define _SVDOTEXT_HXX // SdrTextObj +#define _SVDOPATH_HXX // SdrPathObj +//#define _SVDOEDGE_HXX // SdrEdgeObj +//#define _SVDORECT_HXX // SdrRectObj (+SdrTextObj) +#define _SVDCAPT_HXX // SdrCaptionObj +#define _SVDOCIRC_HXX // SdrCircleObj +//#define _SVDOGRAF_HXX // SdrGrafObj (+SdrRectObj) +//#define _SVDOOLE2_HXX // SdrOle2Obj (+SdrRectObj) + + +//#define _SVDOATTR_HXX +//#define _SVDOTEXT_HXX + +#define _SVDOUKWN_HXX +//#define _SVDORECT_HXX +#define _SVDCAPT_HXX +#define _SVDOCIRC_HXX +//#define _SVDOEDGE_HXX +//#define _SVDOGRAF_HXX +#define _SVDRAW_HXX +#define _SVDOGRP_HXX +#define _SVDOMEAS_HXX +//#define _SVDOOLE2_HXX +#define _SVDOPAGE_HXX +#define _SVDOPATH_HXX + +// INCLUDE --------------------------------------------------------------- + +#include <svx/svdograf.hxx> +#include <svx/svdoole2.hxx> +#include <svx/svdundo.hxx> + +#include "drawview.hxx" +#include "global.hxx" +#include "drwlayer.hxx" +#include "viewdata.hxx" +#include "document.hxx" +#include "docsh.hxx" +#include "dataobj.hxx" +#include "drawutil.hxx" +#include "scmod.hxx" +#include "globstr.hrc" + + +// STATIC DATA ----------------------------------------------------------- + +Point aDragStartDiff; + +// ----------------------------------------------------------------------- + +//! welche Funktionen aus drawview/drawvie4 muessen wirklich ohne Optimierung sein? + +#ifdef WNT +#pragma optimize ( "", off ) +#endif + +// ----------------------------------------------------------------------- + +void lcl_InitMarks( SdrMarkView& rDest, const SdrMarkView& rSource, USHORT nTab ) +{ + rDest.ShowPagePgNum( nTab, Point() ); + SdrPageView* pDestPV = rDest.GetPageViewPvNum(0); + DBG_ASSERT(pDestPV,"PageView ??!?!"); + + const SdrMarkList& rMarkList = rSource.GetMarkList(); + ULONG nCount = rMarkList.GetMarkCount(); + for (ULONG i=0; i<nCount; i++) + { + SdrMark* pMark = rMarkList.GetMark(i); + SdrObject* pObj = pMark->GetObj(); + + rDest.MarkObj(pObj, pDestPV); + } +} + +void lcl_CheckOle( const SdrMarkList& rMarkList, BOOL& rAnyOle, BOOL& rOneOle ) +{ + rAnyOle = rOneOle = FALSE; + + ULONG nCount = rMarkList.GetMarkCount(); + if (nCount == 1) + { + SdrMark* pMark = rMarkList.GetMark(0); + SdrObject* pObj = pMark->GetObj(); + UINT16 nSdrObjKind = pObj->GetObjIdentifier(); + if (nSdrObjKind == OBJ_OLE2) + rAnyOle = rOneOle = TRUE; + } + else + for (ULONG i=0; i<nCount; i++) + { + SdrMark* pMark = rMarkList.GetMark(i); + SdrObject* pObj = pMark->GetObj(); + UINT16 nSdrObjKind = pObj->GetObjIdentifier(); + if (nSdrObjKind == OBJ_OLE2) + { + rAnyOle = TRUE; + break; + } + } +} + +BOOL ScDrawView::BeginDrag( Window* pWindow, const Point& rStartPos ) +{ + BOOL bReturn = FALSE; + + if ( HasMarkedObj() ) + { + ScModule* pScMod = SC_MOD(); + + BrkAction(); + + Rectangle aMarkedRect = GetAllMarkedRect(); + Region aRegion( aMarkedRect ); + + aDragStartDiff = rStartPos - aMarkedRect.TopLeft(); + + BOOL bAnyOle, bOneOle; + const SdrMarkList& rMarkList = GetMarkList(); + lcl_CheckOle( rMarkList, bAnyOle, bOneOle ); + +// PageView in MarkList nicht mehr gueltig, wenn Tabelle umgeschaltet !!! + SdrView aEditView( GetModel() ); + lcl_InitMarks( aEditView, *this, nTab ); + + BegUndo( ScGlobal::GetRscString( STR_UNDO_DRAGDROP ) ); + + //--------------------------------------------------------- + ScDocShellRef aDragShellRef; + if (bAnyOle) + { + aDragShellRef = new ScDocShell; // ohne Ref lebt die DocShell nicht !!! + aDragShellRef->DoInitNew(NULL); + } + //--------------------------------------------------------- + + ScDrawLayer::SetGlobalDrawPersist(aDragShellRef); + SdrModel* pDragModel = GetAllMarkedModel(); + ScDrawLayer::SetGlobalDrawPersist(NULL); + + SvDataObjectRef pDragServer = new ScDataObject(pDragModel, + pViewData->GetDocShell(), bOneOle); + pScMod->SetDragObject(pDragModel, &aEditView, 0); + DropAction eDropAction = pDragServer->ExecuteDrag(pWindow, + POINTER_MOVEDATA, POINTER_COPYDATA, POINTER_LINKDATA, + DRAG_ALL, &aRegion); + BOOL bIntern = pScMod->GetDragIntern(); + pScMod->ResetDragObject(); + pDragServer.Clear(); // enthaelt Referenzen auf pDragShell + + //--------------------------------------------------------- + + switch (eDropAction) + { + case DROP_MOVE: + case DROP_DISCARD: + if (!bIntern) + aEditView.DeleteMarked(); + break; + + case DROP_NONE: + case DROP_COPY: + case DROP_LINK: + case DROP_PRINT: + break; + + default: + break; + } + + if (eDropAction != DROP_NONE) + bReturn = TRUE; + + EndUndo(); + } + + return bReturn; +} + +void ScDrawView::DoCopy() +{ + { + SvDataObjectRef pDummyObj = new SvDataObject; + pDummyObj->CopyClipboard(); + } + + BOOL bAnyOle, bOneOle; + const SdrMarkList& rMarkList = GetMarkList(); + lcl_CheckOle( rMarkList, bAnyOle, bOneOle ); + + //--------------------------------------------------------- + delete ScGlobal::pDrawClipDocShellRef; + if (bAnyOle) + { + ScGlobal::pDrawClipDocShellRef = + new ScDocShellRef(new ScDocShell); // ohne Ref geht's nicht + (*ScGlobal::pDrawClipDocShellRef)->DoInitNew(NULL); + ScDrawLayer::SetGlobalDrawPersist(*ScGlobal::pDrawClipDocShellRef); + } + else + { + ScGlobal::pDrawClipDocShellRef = NULL; + ScDrawLayer::SetGlobalDrawPersist(NULL); + } + + SdrModel* pModel = GetAllMarkedModel(); + ScDrawLayer::SetGlobalDrawPersist(NULL); + + ScGlobal::SetClipDraw(pModel); + SvDataObjectRef pData = new ScDataObject( pModel, pViewData->GetDocShell(), bOneOle ); + pData->CopyClipboard(); +} + +// Korrektur fuer 100% berechnen, unabhaengig von momentanen Einstellungen + +void ScDrawView::CalcNormScale( Fraction& rFractX, Fraction& rFractY ) const +{ + Point aLogic = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP ); + double nPPTX = ScGlobal::nScreenPPTX; + double nPPTY = ScGlobal::nScreenPPTY; + + if (pViewData) + nPPTX /= pViewData->GetDocShell()->GetOutputFactor(); + + USHORT nEndCol = 0; + USHORT nEndRow = 0; + pDoc->GetTableArea( nTab, nEndCol, nEndRow ); + if (nEndCol<20) + nEndCol = 20; + if (nEndRow<20) + nEndRow = 20; + + Fraction aZoom(1,1); + ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, pDev, aZoom,aZoom, + nPPTX, nPPTY, rFractX,rFractY ); +} + +void ScDrawView::SetMarkedOriginalSize() +{ + SdrUndoGroup* pUndoGroup = new SdrUndoGroup(*GetModel()); + + const SdrMarkList& rMarkList = GetMarkList(); + long nDone = 0; + ULONG nCount = rMarkList.GetMarkCount(); + for (ULONG i=0; i<nCount; i++) + { + SdrObject* pObj = rMarkList.GetMark(i)->GetObj(); + USHORT nIdent = pObj->GetObjIdentifier(); + BOOL bDo = FALSE; + Size aOriginalSize; + if (nIdent == OBJ_OLE2) + { + SvInPlaceObjectRef xIPObj = ((SdrOle2Obj*)pObj)->GetObjRef(); + if (xIPObj.Is()) + { + aOriginalSize = OutputDevice::LogicToLogic( + xIPObj->GetVisArea().GetSize(), + xIPObj->GetMapUnit(), MAP_100TH_MM ); + bDo = TRUE; + } + } + else if (nIdent == OBJ_GRAF) + { + const Graphic& rGraphic = ((SdrGrafObj*)pObj)->GetGraphic(); + + MapMode aSourceMap = rGraphic.GetPrefMapMode(); + MapMode aDestMap( MAP_100TH_MM ); + if (aSourceMap.GetMapUnit() == MAP_PIXEL) + { + // Pixel-Korrektur beruecksichtigen, damit Bitmap auf dem Bildschirm stimmt + + Fraction aScaleX, aScaleY; + CalcNormScale( aScaleX, aScaleY ); + aDestMap.SetScaleX(aScaleX); + aDestMap.SetScaleY(aScaleY); + } + if (pViewData) + { + Window* pActWin = pViewData->GetActiveWin(); + if (pActWin) + { + aOriginalSize = pActWin->LogicToLogic( + rGraphic.GetPrefSize(), &aSourceMap, &aDestMap ); + bDo = TRUE; + } + } + } + + if ( bDo ) + { + Rectangle aDrawRect = pObj->GetLogicRect(); + + pUndoGroup->AddAction( new SdrUndoGeoObj( *pObj ) ); + pObj->Resize( aDrawRect.TopLeft(), Fraction( aOriginalSize.Width(), aDrawRect.GetWidth() ), + Fraction( aOriginalSize.Height(), aDrawRect.GetHeight() ) ); + ++nDone; + } + } + + if (nDone) + { + pUndoGroup->SetComment(ScGlobal::GetRscString( STR_UNDO_ORIGINALSIZE )); + pViewData->GetDocShell()->GetUndoManager()->AddUndoAction(pUndoGroup); + } + else + delete pUndoGroup; +} + + +#ifdef WNT +#pragma optimize ( "", on ) +#endif + + + + diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx new file mode 100644 index 000000000000..6524c7711084 --- /dev/null +++ b/sc/source/ui/view/drawview.cxx @@ -0,0 +1,745 @@ +/************************************************************************* + * + * $RCSfile: drawview.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include <svx/svditer.hxx> +#include <svx/svdograf.hxx> +#include <svx/svdogrp.hxx> +#include <svx/svdoole2.hxx> +#include <svx/svdouno.hxx> +#include <svx/svdpage.hxx> +#include <svx/svdvmark.hxx> +#include <svx/xoutx.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/ipfrm.hxx> +#include <so3/ipobj.hxx> +#include <so3/pseudo.hxx> + +#include "drawview.hxx" +#include "global.hxx" +#include "viewdata.hxx" +#include "document.hxx" +#include "drawutil.hxx" +#include "globstr.hrc" +#include "tabvwsh.hxx" +#include "client.hxx" +#include "scmod.hxx" +#include "drwlayer.hxx" + +#include "sc.hrc" + +// ----------------------------------------------------------------------- + +#define SC_HANDLESIZE_BIG 9 +#define SC_HANDLESIZE_SMALL 7 + +// ----------------------------------------------------------------------- + + +#ifdef WNT +#pragma optimize ( "", off ) +#endif + + +void ScDrawView::Construct() +{ + EnableExtendedKeyInputDispatcher(FALSE); + EnableExtendedMouseEventDispatcher(FALSE); + EnableExtendedCommandEventDispatcher(FALSE); + + SetFrameDragSingles(TRUE); +// SetSolidMarkHdl(TRUE); // einstellbar -> UpdateUserViewOptions + + SetMinMoveDistancePixel( 2 ); + SetHitTolerancePixel( 2 ); + + if (pViewData) + { + USHORT nTab = pViewData->GetTabNo(); + ShowPagePgNum( nTab, Point() ); + + BOOL bEx = pViewData->GetViewShell()->IsDrawSelMode(); + BOOL bProt = pDoc->IsTabProtected( nTab ) || + pViewData->GetSfxDocShell()->IsReadOnly(); + + SdrLayer* pLayer; + SdrLayerAdmin& rAdmin = GetModel()->GetLayerAdmin(); + pLayer = rAdmin.GetLayerPerID(SC_LAYER_BACK); + if (pLayer) + SetLayerLocked( pLayer->GetName(), bProt || !bEx ); + pLayer = rAdmin.GetLayerPerID(SC_LAYER_INTERN); + if (pLayer) + SetLayerLocked( pLayer->GetName(), TRUE ); + pLayer = rAdmin.GetLayerPerID(SC_LAYER_FRONT); + if (pLayer) + { + SetLayerLocked( pLayer->GetName(), bProt ); + SetActiveLayer( pLayer->GetName() ); // FRONT als aktiven Layer setzen + } + pLayer = rAdmin.GetLayerPerID(SC_LAYER_CONTROLS); + if (pLayer) + SetLayerLocked( pLayer->GetName(), bProt ); + + SetSwapAsynchron(TRUE); + } + else + ShowPagePgNum( nTab, Point() ); + + UpdateUserViewOptions(); + RecalcScale(); + UpdateWorkArea(); + + bInConstruct = FALSE; +} + +__EXPORT ScDrawView::~ScDrawView() +{ + delete pDropMarker; +} + +void ScDrawView::AddCustomHdl() +{ + const SdrMarkList &rMrkList = GetMarkList(); + UINT32 nCount = rMrkList.GetMarkCount(); + for(UINT32 nPos=0; nPos<nCount; nPos++ ) + { + const SdrObject* pObj = rMrkList.GetMark(nPos)->GetObj(); + if(ScDrawLayer::GetAnchor(pObj) == SCA_CELL) + { + const INT32 nDelta = 1; + + Point aPos = pObj->GetBoundRect().TopLeft(); + long nPosX = (long) (aPos.X() / HMM_PER_TWIPS) + nDelta; + long nPosY = (long) (aPos.Y() / HMM_PER_TWIPS) + nDelta; + + UINT16 nCol; + INT32 nWidth = 0; + + for(nCol=0; nCol<=MAXCOL && nWidth<=nPosX; nCol++) + nWidth += pDoc->GetColWidth(nCol,nTab); + + if(nCol) + --nCol; + + UINT16 nRow; + INT32 nHeight = 0; + + for(nRow=0; nRow<=MAXROW && nHeight<=nPosY; nRow++) + nHeight += pDoc->FastGetRowHeight(nRow,nTab); + + if(nRow) + --nRow; + + ScTabView* pView = pViewData->GetView(); + ScAddress aScAddress(nCol, nRow, nTab); + pView->CreateAnchorHandles(aHdl, aScAddress); + } + } +} + +void ScDrawView::InvalidateAttribs() +{ + SfxBindings& rBindings = SFX_BINDINGS(); + + // echte Statuswerte: + + rBindings.Invalidate( SID_ATTR_FILL_STYLE ); + rBindings.Invalidate( SID_ATTR_FILL_COLOR ); + + rBindings.Invalidate( SID_ATTR_LINE_STYLE ); + rBindings.Invalidate( SID_ATTR_LINE_WIDTH ); + rBindings.Invalidate( SID_ATTR_LINE_COLOR ); + + rBindings.Invalidate( SID_ANCHOR_PAGE ); + rBindings.Invalidate( SID_ANCHOR_CELL ); + + rBindings.Invalidate( SID_OLE_OBJECT ); + + rBindings.Invalidate( SID_HYPERLINK_GETLINK ); + + // Funktionen, die nicht immer moeglich sind: + + rBindings.Invalidate( SID_ATTRIBUTES_LINE ); + rBindings.Invalidate( SID_ATTRIBUTES_AREA ); + rBindings.Invalidate( SID_ATTR_LINEEND_STYLE ); // Tbx-Controller + + rBindings.Invalidate( SID_GROUP ); + rBindings.Invalidate( SID_UNGROUP ); + rBindings.Invalidate( SID_ENTER_GROUP ); + rBindings.Invalidate( SID_LEAVE_GROUP ); + rBindings.Invalidate( SID_MIRROR_HORIZONTAL ); + rBindings.Invalidate( SID_MIRROR_VERTICAL ); + + rBindings.Invalidate( SID_IMAP_EXEC ); + + rBindings.Invalidate( SID_FRAME_UP ); + rBindings.Invalidate( SID_FRAME_DOWN ); + rBindings.Invalidate( SID_FRAME_TO_TOP ); + rBindings.Invalidate( SID_FRAME_TO_BOTTOM ); + rBindings.Invalidate( SID_OBJECT_HEAVEN ); + rBindings.Invalidate( SID_OBJECT_HELL ); + + rBindings.Invalidate( SID_OBJECT_ALIGN_LEFT ); + rBindings.Invalidate( SID_OBJECT_ALIGN_CENTER ); + rBindings.Invalidate( SID_OBJECT_ALIGN_RIGHT ); + rBindings.Invalidate( SID_OBJECT_ALIGN_UP ); + rBindings.Invalidate( SID_OBJECT_ALIGN_MIDDLE ); + rBindings.Invalidate( SID_OBJECT_ALIGN_DOWN ); + + rBindings.Invalidate( SID_DELETE ); + rBindings.Invalidate( SID_DELETE_CONTENTS ); + rBindings.Invalidate( SID_CUT ); + rBindings.Invalidate( SID_COPY ); + + rBindings.Invalidate( SID_ANCHOR_TOGGLE ); + rBindings.Invalidate( SID_ORIGINALSIZE ); + + rBindings.Invalidate( SID_ATTR_TRANSFORM ); +} + +void ScDrawView::InvalidateDrawTextAttrs() +{ + SfxBindings& rBindings = SFX_BINDINGS(); + + rBindings.Invalidate( SID_ATTR_CHAR_FONT ); + rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT ); + rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT ); + rBindings.Invalidate( SID_ATTR_CHAR_POSTURE ); + rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE ); + rBindings.Invalidate( SID_ULINE_VAL_NONE ); + rBindings.Invalidate( SID_ULINE_VAL_SINGLE ); + rBindings.Invalidate( SID_ULINE_VAL_DOUBLE ); + rBindings.Invalidate( SID_ULINE_VAL_DOTTED ); + rBindings.Invalidate( SID_ATTR_CHAR_COLOR ); + rBindings.Invalidate( SID_ATTR_PARA_ADJUST_LEFT ); + rBindings.Invalidate( SID_ATTR_PARA_ADJUST_CENTER ); + rBindings.Invalidate( SID_ATTR_PARA_ADJUST_RIGHT ); + rBindings.Invalidate( SID_ATTR_PARA_ADJUST_BLOCK ); + rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_10 ); + rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_15 ); + rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_20 ); + rBindings.Invalidate( SID_SET_SUPER_SCRIPT ); + rBindings.Invalidate( SID_SET_SUB_SCRIPT ); +} + +void ScDrawView::DrawMarks( OutputDevice* pOut ) const +{ +// if (IsMarkHdlShown()) +// DrawMarkHdl(pOut,FALSE); + + USHORT nWinNum = ((ScDrawView*)this)->FindWin(pOut); //! DrawMarks nicht-const + if (nWinNum!=SDRVIEWWIN_NOTFOUND) + { + ((ScDrawView*)this)->AfterInitRedraw(nWinNum); //! DrawMarks nicht-const + + if (IsShownXorVisibleWinNum(nWinNum)) + ((ScDrawView*)this)->ToggleShownXor(pOut,NULL); //! DrawMarks nicht-const + } +} + +void ScDrawView::SetMarkedToLayer( BYTE nLayerNo ) +{ + // + //! Undo !!! + // + + if (HasMarkedObj()) + { + const SdrMarkList& rMark = GetMarkList(); + ULONG nCount = rMark.GetMarkCount(); + for (ULONG i=0; i<nCount; i++) + { + SdrObject* pObj = rMark.GetMark(i)->GetObj(); + if ( !pObj->ISA(SdrUnoObj) ) + pObj->SetLayer( nLayerNo ); + } + + // Paint passiert beim SetLayer + } +} + +BOOL ScDrawView::HasMarkedControl() const +{ + if (HasMarkedObj()) + { + const SdrMarkList& rMark = GetMarkList(); + ULONG nCount = rMark.GetMarkCount(); + for (ULONG i=0; i<nCount; i++) + { + SdrObject* pObj = rMark.GetMark(i)->GetObj(); + if ( pObj->ISA(SdrUnoObj) ) + return TRUE; + else if ( pObj->ISA(SdrObjGroup) ) + { + SdrObjListIter aIter( *pObj, IM_DEEPWITHGROUPS ); + SdrObject* pSubObj = aIter.Next(); + while (pSubObj) + { + if ( pSubObj->ISA(SdrUnoObj) ) + return TRUE; + pSubObj = aIter.Next(); + } + } + + } + } + return FALSE; // war nix +} + +void ScDrawView::UpdateWorkArea() +{ + SdrPage* pPage = GetModel()->GetPage(nTab); + if (pPage) + SetWorkArea( Rectangle( Point(), pPage->GetSize() ) ); + else + DBG_ERROR("Page nicht gefunden"); +} + +void ScDrawView::DoCut() +{ + DoCopy(); + BegUndo( ScGlobal::GetRscString( STR_UNDO_CUT ) ); + DeleteMarked(); // auf dieser View - von der 505f Umstellung nicht betroffen + EndUndo(); +} + +void ScDrawView::GetScale( Fraction& rFractX, Fraction& rFractY ) const +{ + rFractX = aScaleX; + rFractY = aScaleY; +} + +void ScDrawView::RecalcScale() +{ + double nPPTX; + double nPPTY; + Fraction aZoomX(1,1); + Fraction aZoomY(1,1); + + if (pViewData) + { + nTab = pViewData->GetTabNo(); + nPPTX = pViewData->GetPPTX(); + nPPTY = pViewData->GetPPTY(); + aZoomX = pViewData->GetZoomX(); + aZoomY = pViewData->GetZoomY(); + } + else + { + Point aLogic = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP ); + nPPTX = aLogic.X() / 1000.0; + nPPTY = aLogic.Y() / 1000.0; + //! Zoom uebergeben ??? + } + + USHORT nEndCol = 0; + USHORT nEndRow = 0; + pDoc->GetTableArea( nTab, nEndCol, nEndRow ); + if (nEndCol<20) + nEndCol = 20; + if (nEndRow<20) + nEndRow = 20; + + ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, pDev,aZoomX,aZoomY,nPPTX,nPPTY, + aScaleX,aScaleY ); +} + +void ScDrawView::PaintObject( SdrObject* pObject, OutputDevice* pDev ) const +{ + pXOut->SetOutDev( pDev ); + SdrPaintInfoRec aInfoRec; + pObject->Paint( *pXOut, aInfoRec ); +} + +void __EXPORT ScDrawView::MarkListHasChanged() +{ + FmFormView::MarkListHasChanged(); + + UpdateBrowser(); + + ScTabViewShell* pViewSh = pViewData->GetViewShell(); + + if (!bInConstruct) // nicht wenn die View gerade angelegt wird + { + pViewSh->Unmark(); // Selektion auff'm Doc entfernen + + // #65379# end cell edit mode if drawing objects are selected + if ( GetMarkList().GetMarkCount() ) + SC_MOD()->InputEnterHandler(); + } + + // IP deaktivieren + + ScClient* pClient = (ScClient*) pViewSh->GetIPClient(); + if ( pClient && pClient->IsInPlaceActive() ) + { + // #41730# beim ViewShell::Activate aus dem Reset2Open nicht die Handles anzeigen + bDisableHdl = TRUE; + + pClient->GetProtocol().Reset2Open(); + SFX_APP()->SetViewFrame(pViewSh->GetViewFrame()); + + bDisableHdl = FALSE; + + // Image-Ole wieder durch Grafik ersetzen passiert jetzt in ScClient::UIActivate + } + + // Ole-Objekt selektiert? + + SdrOle2Obj* pOle2Obj = NULL; + SdrGrafObj* pGrafObj = NULL; + + const SdrMarkList& rMarkList = GetMarkList(); + ULONG nMarkCount = rMarkList.GetMarkCount(); + + if ( nMarkCount == 0 && !pViewData->GetViewShell()->IsDrawSelMode() && !bInConstruct ) + { + // re-lock background layer if it was unlocked in SelectObject + SdrLayer* pLayer = GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_BACK); + if ( pLayer && !IsLayerLocked( pLayer->GetName() ) ) + SetLayerLocked( pLayer->GetName(), TRUE ); + } + + if (nMarkCount == 1) + { + SdrObject* pObj = rMarkList.GetMark(0)->GetObj(); + if (pObj->GetObjIdentifier() == OBJ_OLE2) + { + pOle2Obj = (SdrOle2Obj*) pObj; + if (!pDoc->IsChart(pObj) ) + pViewSh->SetOleObjectShell(TRUE); + else + pViewSh->SetChartShell(TRUE); + } + else if (pObj->GetObjIdentifier() == OBJ_GRAF) + { + pGrafObj = (SdrGrafObj*) pObj; + pViewSh->SetGraphicShell(TRUE); + } + else if (!pObj->GetObjIdentifier() == OBJ_TEXT // Verhindern, das beim Anlegen + || !pViewSh->IsDrawTextShell()) // eines TextObjekts auf die + { // DrawShell umgeschaltet wird. + pViewSh->SetDrawShell(TRUE); //@#70206# + } + } + + if (nMarkCount) // VC-Popup, wenn nur VCs markiert sind + { + BOOL bOnlyControls = TRUE; + for (ULONG i=0; i<nMarkCount; i++) + { + SdrObject* pObj = rMarkList.GetMark(i)->GetObj(); + if ( pObj->ISA( SdrObjGroup ) ) + { + const SdrObjList *pLst = ((SdrObjGroup*)pObj)->GetSubList(); + for ( USHORT j = 0; j < pLst->GetObjCount(); ++j ) + { + SdrObject *pSubObj = pLst->GetObj( j ); + + if(!pSubObj->ISA(SdrUnoObj)) + { + bOnlyControls = FALSE; + break; + } + } + + if(!bOnlyControls) break; + } + else if (!pObj->ISA(SdrUnoObj)) + { + bOnlyControls = FALSE; + break; + } + } + + if(bOnlyControls) + { + pViewSh->SetDrawFormShell(TRUE); // jetzt UNO-Controls + } + else if(nMarkCount>1) + { + pViewSh->SetDrawShell(TRUE); + } + } + + + + // Verben anpassen + + BOOL bOle = pViewSh->GetViewFrame()->ISA(SfxInPlaceFrame); + if ( pOle2Obj && !bOle ) + { + SvInPlaceObject* pIPObj = pOle2Obj->GetObjRef(); + if (pIPObj) + pViewSh->SetVerbs( &pIPObj->GetVerbList() ); + else + { + DBG_ERROR("SdrOle2Obj ohne ObjRef"); + pViewSh->SetVerbs( 0 ); + } + } + else if ( pGrafObj && !bOle && SFX_APP()->HasFeature(SFX_FEATURE_SIMAGE) ) + { + SvVerb aVerb( 0, ScGlobal::GetRscString( STR_UNDO_GRAFEDIT ) ); + SvVerbList aVerbList; + aVerbList.Append( aVerb ); + pViewSh->SetVerbs( &aVerbList ); + } + else + pViewSh->SetVerbs( 0 ); + + // Image-Map Editor + + if ( pOle2Obj ) + UpdateIMap( pOle2Obj ); + else if ( pGrafObj ) + UpdateIMap( pGrafObj ); + + InvalidateAttribs(); // nach dem IMap-Editor Update + InvalidateDrawTextAttrs(); + + USHORT nWinCount = GetWinCount(); + for (USHORT i=0; i<nWinCount; i++) + { + OutputDevice* pDev = GetWin(i); + if (pDev->GetOutDevType() == OUTDEV_WINDOW) + ((Window*)pDev)->Update(); + } +} + +void __EXPORT ScDrawView::ModelHasChanged() +{ + FmFormView::ModelHasChanged(); +} + +void __EXPORT ScDrawView::UpdateUserViewOptions() +{ + if (pViewData) + { + const ScViewOptions& rOpt = pViewData->GetOptions(); + const ScGridOptions& rGrid = rOpt.GetGridOptions(); + + BOOL bBigHdl = rOpt.GetOption( VOPT_BIGHANDLES ); + + SetDragStripes( rOpt.GetOption( VOPT_HELPLINES ) ); + SetSolidMarkHdl( rOpt.GetOption( VOPT_SOLIDHANDLES ) ); + SetMarkHdlSizePixel( bBigHdl ? SC_HANDLESIZE_BIG : SC_HANDLESIZE_SMALL ); + + SetGridVisible( rGrid.GetGridVisible() ); + SetSnapEnabled( rGrid.GetUseGridSnap() ); + SetGridSnap( rGrid.GetUseGridSnap() ); + SetSnapGrid( Size( rGrid.GetFldSnapX(), rGrid.GetFldSnapY() ) ); + + SetGridCoarse( Size( rGrid.GetFldDrawX(), rGrid.GetFldDrawY() ) ); + SetGridFine( Size( rGrid.GetFldDrawX() / (rGrid.GetFldDivisionX() + 1), + rGrid.GetFldDrawY() / (rGrid.GetFldDivisionY() + 1) ) ); + } +} + +#ifdef WNT +#pragma optimize ( "", on ) +#endif + +BOOL ScDrawView::SelectObject( const String& rName ) +{ + UnmarkAll(); + + USHORT nObjectTab = 0; + SdrObject* pFound = NULL; + + SfxObjectShell* pShell = pDoc->GetDocumentShell(); + if (pShell) + { + SdrModel* pDrawLayer = GetModel(); + USHORT nTabCount = pDoc->GetTableCount(); + for (USHORT i=0; i<nTabCount && !pFound; i++) + { + SdrPage* pPage = pDrawLayer->GetPage(i); + DBG_ASSERT(pPage,"Page ?"); + if (pPage) + { + SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS ); + SdrObject* pObject = aIter.Next(); + while (pObject && !pFound) + { + if (pObject->GetName() == rName) + { + pFound = pObject; + nObjectTab = i; + } + pObject = aIter.Next(); + } + } + } + } + + if ( pFound ) + { + ScTabView* pView = pViewData->GetView(); + if ( nObjectTab != nTab ) // Tabelle umschalten + pView->SetTabNo( nObjectTab ); + + DBG_ASSERT( nTab == nObjectTab, "Tabellen umschalten hat nicht geklappt" ); + + pView->ScrollToObject( pFound ); + + // #61585# to select an object on the background layer, the layer has to + // be unlocked even if exclusive drawing selection mode is not active + // (this is reversed in MarkListHasChanged when nothing is selected) + + if ( pFound->GetLayer() == SC_LAYER_BACK && + !pViewData->GetViewShell()->IsDrawSelMode() && + !pDoc->IsTabProtected( nTab ) && + !pViewData->GetSfxDocShell()->IsReadOnly() ) + { + SdrLayer* pLayer = GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_BACK); + if (pLayer) + SetLayerLocked( pLayer->GetName(), FALSE ); + } + + SdrPageView* pPV = GetPageViewPvNum(0); + MarkObj( pFound, pPV ); + } + + return ( pFound != NULL ); +} + +String ScDrawView::GetSelectedChartName() const +{ + const SdrMarkList& rMarkList = GetMarkList(); + if (rMarkList.GetMarkCount() == 1) + { + SdrObject* pObj = rMarkList.GetMark(0)->GetObj(); + if (pObj->GetObjIdentifier() == OBJ_OLE2) + if ( pDoc->IsChart(pObj) ) + return pObj->GetName(); + } + + return EMPTY_STRING; // nichts gefunden +} + +FASTBOOL ScDrawView::InsertObjectSafe(SdrObject* pObj, SdrPageView& rPV, ULONG nOptions) +{ + // Markierung nicht aendern, wenn Ole-Objekt aktiv + // (bei Drop aus Ole-Objekt wuerde sonst mitten im ExecuteDrag deaktiviert!) + + if (pViewData) + { + SfxInPlaceClient* pClient = pViewData->GetViewShell()->GetIPClient(); + if ( pClient && pClient->IsInPlaceActive() ) + nOptions |= SDRINSERT_DONTMARK; + } + + return InsertObject( pObj, rPV, nOptions ); +} + +void __EXPORT ScDrawView::MakeVisible( const Rectangle& rRect, Window& rWin ) +{ + //! rWin richtig auswerten + //! ggf Zoom aendern + + if ( pViewData && pViewData->GetActiveWin() == &rWin ) + pViewData->GetView()->MakeVisible( rRect ); +} + +SdrEndTextEditKind ScDrawView::ScEndTextEdit() +{ + BOOL bIsTextEdit = IsTextEdit(); + SdrEndTextEditKind eKind = EndTextEdit(); + + if ( bIsTextEdit && pViewData ) + pViewData->GetViewShell()->SetDrawTextUndo(NULL); // "normaler" Undo-Manager + + return eKind; +} + +void ScDrawView::MarkDropObj( SdrObject* pObj ) +{ + if ( pObj ) + { + if ( !pDropMarker ) + pDropMarker = new SdrViewUserMarker(this); + if ( pDropMarkObj != pObj ) + { + pDropMarkObj = pObj; + pDropMarker->SetXPolyPolygon(pDropMarkObj, GetPageViewPvNum(0)); + pDropMarker->Show(); + } + } + else // Markierung aufheben + { + if (pDropMarker) + { + pDropMarker->Hide(); + pDropMarkObj = NULL; + } + } +} + + + diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx new file mode 100644 index 000000000000..f19358c0c2f9 --- /dev/null +++ b/sc/source/ui/view/editsh.cxx @@ -0,0 +1,886 @@ +/************************************************************************* + * + * $RCSfile: editsh.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +#include "scitems.hxx" +#define ITEMID_FIELD EE_FEATURE_FIELD + +#include <svx/cntritem.hxx> +#include <svx/chardlg.hxx> +#include <svx/crsditem.hxx> +#include <svx/editeng.hxx> +#include <svx/editview.hxx> +#include <svx/eeitem.hxx> +#include <svx/escpitem.hxx> +#include <svx/flditem.hxx> +#include <svx/fontitem.hxx> +#include <svx/hlnkitem.hxx> +#include <svx/postitem.hxx> +#include <svx/shdditem.hxx> +#include <svx/srchitem.hxx> +#include <svx/udlnitem.hxx> +#include <svx/wghtitem.hxx> +#include <sfx2/basedlgs.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/msg.hxx> +#include <sfx2/objface.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/request.hxx> +#include <so3/pastedlg.hxx> +#include <sot/exchange.hxx> +#include <svtools/whiter.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/sound.hxx> + + +#define GLOBALOVERFLOW +#include <segmentc.hxx> + + +#define _EDITSH_CXX +#include "editsh.hxx" + +#include "scresid.hxx" +#include "global.hxx" +#include "sc.hrc" +#include "scmod.hxx" +#include "inputhdl.hxx" +#include "viewutil.hxx" +#include "viewdata.hxx" +#include "document.hxx" +#include "namepast.hxx" +#include "reffind.hxx" +#include "tabvwsh.hxx" + +#define ScEditShell +#include "scslots.hxx" + +SEG_EOFGLOBALS() + +#pragma SEG_SEGCLASS(SFXMACROS_SEG,STARTWORK_CODE) + +TYPEINIT1( ScEditShell, SfxShell ); +#pragma SEG_FUNCDEF(editsh_0a) + +SFX_IMPL_INTERFACE(ScEditShell, SfxShell, ScResId(SCSTR_EDITSHELL)) +{ + SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_EDIT) ); +} + + +#pragma SEG_FUNCDEF(editsh_01) + +ScEditShell::ScEditShell(EditView* pView, ScViewData* pData) : + pEditView (pView), + pViewData (pData), + bIsInsertMode (TRUE) +{ + SetPool( pEditView->GetEditEngine()->GetEmptyItemSet().GetPool() ); + SetUndoManager( &pEditView->GetEditEngine()->GetUndoManager() ); + SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("EditCell"))); +} + +#pragma SEG_FUNCDEF(editsh_02) + +ScEditShell::~ScEditShell() +{ +} + +#pragma SEG_FUNCDEF(editsh_08) + +void ScEditShell::SetEditView(EditView* pView) +{ + pEditView = pView; + pEditView->SetInsertMode( bIsInsertMode ); + SetPool( pEditView->GetEditEngine()->GetEmptyItemSet().GetPool() ); + SetUndoManager( &pEditView->GetEditEngine()->GetUndoManager() ); +} + +#pragma SEG_FUNCDEF(editsh_04) + +void ScEditShell::Execute( SfxRequest& rReq ) +{ + const SfxItemSet* pReqArgs = rReq.GetArgs(); + USHORT nSlot = rReq.GetSlot(); + SfxBindings& rBindings = SFX_BINDINGS(); + + ScInputHandler* pHdl = SC_MOD()->GetInputHdl(); + DBG_ASSERT(pHdl,"kein ScInputHandler"); + + EditView* pTopView = pHdl->GetTopView(); // hat Eingabezeile den Focus? + EditView* pTableView = pHdl->GetTableView(); + + DBG_ASSERT(pTableView,"keine EditView :-("); + + EditEngine* pEngine = pTableView->GetEditEngine(); + + pHdl->DataChanging(); + BOOL bSetSelIsRef = FALSE; + + switch ( nSlot ) + { + case FID_INS_CELL_CONTENTS: // Insert-Taste, weil als Acc definiert + bIsInsertMode = !pTableView->IsInsertMode(); + pTableView->SetInsertMode( bIsInsertMode ); + if (pTopView) + pTopView->SetInsertMode( bIsInsertMode ); + SFX_BINDINGS().Invalidate( SID_ATTR_INSERT ); + break; + + case SID_ATTR_INSERT: + if ( pReqArgs ) + { + bIsInsertMode = ((const SfxBoolItem&)pReqArgs->Get(nSlot)).GetValue(); + pTableView->SetInsertMode( bIsInsertMode ); + if (pTopView) + pTopView->SetInsertMode( bIsInsertMode ); + SFX_BINDINGS().Invalidate( SID_ATTR_INSERT ); + } + break; + + case SID_COPY: + pTableView->Copy(); + break; + + case SID_CUT: + pTableView->Cut(); + if (pTopView) + pTopView->DeleteSelected(); + break; + + case SID_PASTE: + pTableView->PasteSpecial(); + if (pTopView) + pTopView->Paste(); + break; + + case SID_DELETE: + pTableView->DeleteSelected(); + if (pTopView) + pTopView->DeleteSelected(); + break; + + case SID_CELL_FORMAT_RESET: // "Standard" + pTableView->RemoveAttribs(TRUE); // TRUE: auch Absatz-Attribute + if (pTopView) + pTopView->RemoveAttribs(TRUE); + break; + + case FID_PASTE_CONTENTS: + { + SvDataObjectRef pClipObj = SvDataObject::PasteClipboard(); + if (pClipObj.Is()) + { + SvPasteObjectDialog* pDlg = new SvPasteObjectDialog; + pDlg->Insert( FORMAT_STRING, ScResId( SCSTR_CLIP_STRING ) ); + pDlg->Insert( FORMAT_RTF, ScResId( SCSTR_CLIP_RTF ) ); + + ULONG nFormat = pDlg->Execute( pViewData->GetDialogParent(), pClipObj ); + DELETEZ(pDlg); + + // while the dialog was open, edit mode may have been stopped + if (!SC_MOD()->IsInputMode()) + { + Sound::Beep(); + return; + } + + if (nFormat > 0) + { + if (FORMAT_STRING == nFormat) + pTableView->Paste(); + else + pTableView->PasteSpecial(); + + if (pTopView) + pTopView->Paste(); + } + + if (pTopView) + pTopView->GetWindow()->GrabFocus(); + } + } + break; + + case SID_SELECTALL: + { + USHORT nPar = pEngine->GetParagraphCount(); + if (nPar) + { + xub_StrLen nLen = pEngine->GetTextLen(nPar-1); + pTableView->SetSelection(ESelection(0,0,nPar-1,nLen)); + if (pTopView) + pTopView->SetSelection(ESelection(0,0,nPar-1,nLen)); + } + } + break; + + case SID_CHARMAP: + { + const SvxFontItem& rItem = (const SvxFontItem&) + pTableView->GetAttribs().Get(EE_CHAR_FONTINFO); + + String aString; + SvxFontItem aNewItem( EE_CHAR_FONTINFO ); + + BOOL bOk = ScViewUtil::ExecuteCharMap( rItem, aNewItem, aString ); + + // while the dialog was open, edit mode may have been stopped + if (!SC_MOD()->IsInputMode()) + { + Sound::Beep(); + return; + } + + if (bOk) + { + SfxItemSet aSet( pTableView->GetEmptyItemSet() ); + aSet.Put( aNewItem ); + // SetAttribs an der View selektiert ein Wort, wenn nichts selektiert ist + pTableView->GetEditEngine()->QuickSetAttribs( aSet, pTableView->GetSelection() ); + pTableView->InsertText(aString); + if (pTopView) + pTopView->InsertText(aString); + } + + if (pTopView) + pTopView->GetWindow()->GrabFocus(); + } + break; + + case FID_INSERT_NAME: + { + ScDocument* pDoc = pViewData->GetDocument(); + ScNamePasteDlg* pDlg = new ScNamePasteDlg( pViewData->GetDialogParent(), + pDoc->GetRangeName(), FALSE ); + // "Liste" disablen + + short nRet = pDlg->Execute(); + // pDlg is needed below + + // while the dialog was open, edit mode may have been stopped + if (!SC_MOD()->IsInputMode()) + { + Sound::Beep(); + delete pDlg; + return; + } + + if ( nRet == BTN_PASTE_NAME ) + { + String aName = pDlg->GetSelectedName(); + pTableView->InsertText(aName); + if (pTopView) + pTopView->InsertText(aName); + } + delete pDlg; + + if (pTopView) + pTopView->GetWindow()->GrabFocus(); + } + break; + + case SID_CHAR_DLG: + { + SfxItemSet aAttrs( pTableView->GetAttribs() ); + + SfxObjectShell* pObjSh = pViewData->GetSfxDocShell(); + const SvxFontListItem* pFontListItem = + (const SvxFontListItem*) pObjSh->GetItem( SID_ATTR_CHAR_FONTLIST); + + SfxSingleTabDialog* pDlg + = new SfxSingleTabDialog( pViewData->GetViewShell()->GetViewFrame(), + pViewData->GetDialogParent(), + aAttrs, RID_SCDLG_EDITCHAR, FALSE ); + SfxTabPage* pPage = SvxCharStdPage::Create( pDlg, aAttrs ); + ((SvxCharStdPage*)pPage)->SetFontList( *pFontListItem ); + pDlg->SetTabPage( pPage ); + + short nRet = pDlg->Execute(); + // pDlg is needed below + + // while the dialog was open, edit mode may have been stopped + if (!SC_MOD()->IsInputMode()) + { + Sound::Beep(); + delete pDlg; + return; + } + + if ( nRet == RET_OK ) + { + const SfxItemSet* pOut = pDlg->GetOutputItemSet(); + pTableView->SetAttribs( *pOut ); + } + delete pDlg; + } + break; + + case SID_TOGGLE_REL: + { + BOOL bOk = FALSE; + if (pEngine->GetParagraphCount() == 1) + { + String aText = pEngine->GetText(); + ESelection aSel = pEditView->GetSelection(); // aktuelle View + + ScRefFinder aFinder( aText, pViewData->GetDocument() ); + aFinder.ToggleRel( aSel.nStartPos, aSel.nEndPos ); + if (aFinder.GetFound()) + { + String aNew = aFinder.GetText(); + ESelection aSel( 0,aFinder.GetSelStart(), 0,aFinder.GetSelEnd() ); + pEngine->SetText( aNew ); + pTableView->SetSelection( aSel ); + if ( pTopView ) + { + pTopView->GetEditEngine()->SetText( aNew ); + pTopView->SetSelection( aSel ); + } + bOk = TRUE; + + // Referenz wird selektiert -> beim Tippen nicht ueberschreiben + bSetSelIsRef = TRUE; + } + } + if (!bOk) + Sound::Beep(); // keine Referenzen oder mehrere Absätze + } + break; + + case SID_HYPERLINK_SETLINK: + if( pReqArgs ) + { + const SfxPoolItem* pItem; + if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, TRUE, &pItem ) == SFX_ITEM_SET ) + { + const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem; + const String& rName = pHyper->GetName(); + const String& rURL = pHyper->GetURL(); + const String& rTarget = pHyper->GetTargetFrame(); + SvxLinkInsertMode eMode = pHyper->GetInsertMode(); + + BOOL bDone = FALSE; + if ( eMode == HLINK_DEFAULT || eMode == HLINK_FIELD ) + { + const SvxURLField* pURLField = GetURLField(); + if ( pURLField ) + { + // altes Feld selektieren + + ESelection aSel = pTableView->GetSelection(); + aSel.Adjust(); + aSel.nEndPara = aSel.nStartPara; + aSel.nEndPos = aSel.nStartPos + 1; + pTableView->SetSelection( aSel ); + + // neues Feld einfuegen + + SvxURLField aURLField( rURL, rName, SVXURLFORMAT_REPR ); + aURLField.SetTargetFrame( rTarget ); + SvxFieldItem aURLItem( aURLField ); + pTableView->InsertField( aURLItem ); + pTableView->SetSelection( aSel ); // select inserted field + + // #57254# jetzt doch auch Felder in der Top-View + + if ( pTopView ) + { + aSel = pTopView->GetSelection(); + aSel.nEndPara = aSel.nStartPara; + aSel.nEndPos = aSel.nStartPos + 1; + pTopView->SetSelection( aSel ); + pTopView->InsertField( aURLItem ); + pTopView->SetSelection( aSel ); // select inserted field + } + + bDone = TRUE; + } + } + + if (!bDone) + { + pViewData->GetViewShell()-> + InsertURL( rName, rURL, rTarget, (USHORT) eMode ); + + // InsertURL an der ViewShell schaltet bei "Button" + // die EditShell ab, darum sofort return + + return; + } + } + } + break; + } + + pHdl->DataChanged(); + if (bSetSelIsRef) + pHdl->SetSelIsRef(TRUE); +} + +#pragma SEG_FUNCDEF(editsh_05) + +void __EXPORT ScEditShell::GetState( SfxItemSet& rSet ) +{ + ScInputHandler* pHdl = SC_MOD()->GetInputHdl(); + EditView* pActiveView = pHdl ? pHdl->GetActiveView() : pEditView; + + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + while (nWhich) + { + switch (nWhich) + { + case SID_ATTR_INSERT: // Statuszeile + { + if ( pActiveView ) + rSet.Put( SfxBoolItem( nWhich, pActiveView->IsInsertMode() ) ); + else + rSet.Put( SfxBoolItem( nWhich, 42 ) ); + } + break; + + case SID_HYPERLINK_GETLINK: + { + SvxHyperlinkItem aHLinkItem; + const SvxURLField* pURLField = GetURLField(); + if ( pURLField ) + { + aHLinkItem.SetName( pURLField->GetRepresentation() ); + aHLinkItem.SetURL( pURLField->GetURL() ); + aHLinkItem.SetTargetFrame( pURLField->GetTargetFrame() ); + } + else if ( pActiveView ) + { + // use selected text as name for urls + String sReturn = pActiveView->GetSelected(); + sReturn.Erase(255); + sReturn.EraseTrailingChars(); + aHLinkItem.SetName(sReturn); + } + rSet.Put(aHLinkItem); + } + break; + } + nWhich = aIter.NextWhich(); + } +} + +#pragma SEG_FUNCDEF(editsh_0c) + +const SvxURLField* ScEditShell::GetURLField() +{ + ScInputHandler* pHdl = SC_MOD()->GetInputHdl(); + EditView* pActiveView = pHdl ? pHdl->GetActiveView() : pEditView; + if ( pActiveView ) + { + const SvxFieldItem* pFieldItem = pActiveView->GetFieldAtSelection(); + if (pFieldItem) + { + const SvxFieldData* pField = pFieldItem->GetField(); + if ( pField && pField->ISA(SvxURLField) ) + return (const SvxURLField*)pField; + } + } + + return NULL; +} + +#pragma SEG_FUNCDEF(editsh_09) + +void __EXPORT ScEditShell::GetClipState( SfxItemSet& rSet ) +{ + BOOL bPaste = FALSE; + SvDataObjectRef pClipObj = SvDataObject::PasteClipboard(); + if (pClipObj.Is()) + { + const SvDataTypeList& rTypeLst = pClipObj->GetTypeList(); + + if( rTypeLst.Get( FORMAT_STRING ) || rTypeLst.Get( FORMAT_RTF ) ) + bPaste = TRUE; + } + + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + while (nWhich) + { + switch (nWhich) + { + case SID_PASTE: + case FID_PASTE_CONTENTS: + if( !bPaste ) + rSet.DisableItem( nWhich ); + break; + } + nWhich = aIter.NextWhich(); + } +} + +void lcl_InvalidateUnder( SfxBindings& rBindings ) +{ + rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE ); + rBindings.Invalidate( SID_ULINE_VAL_NONE ); + rBindings.Invalidate( SID_ULINE_VAL_SINGLE ); + rBindings.Invalidate( SID_ULINE_VAL_DOUBLE ); + rBindings.Invalidate( SID_ULINE_VAL_DOTTED ); +} + +#pragma SEG_FUNCDEF(editsh_06) + +void ScEditShell::ExecuteAttr(SfxRequest& rReq) +{ + SfxItemSet aSet( pEditView->GetEmptyItemSet() ); + SfxBindings& rBindings = SFX_BINDINGS(); + const SfxItemSet* pArgs = rReq.GetArgs(); + USHORT nSlot = rReq.GetSlot(); + + switch ( nSlot ) + { + case SID_ATTR_CHAR_FONTHEIGHT: + case SID_ATTR_CHAR_FONT: + case SID_ATTR_CHAR_COLOR: + { + if (pArgs) + { + aSet.Put( pArgs->Get( pArgs->GetPool()->GetWhich( nSlot ) ) ); + rBindings.Invalidate( nSlot ); + } + } + break; + + // Toggles + + case SID_ATTR_CHAR_WEIGHT: + { + BOOL bOld = ((const SvxWeightItem&)pEditView->GetAttribs(). + Get(EE_CHAR_WEIGHT)).GetValue() > WEIGHT_NORMAL; + aSet.Put( SvxWeightItem( bOld ? WEIGHT_NORMAL : WEIGHT_BOLD, EE_CHAR_WEIGHT ) ); + rBindings.Invalidate( nSlot ); + } + break; + + case SID_ATTR_CHAR_POSTURE: + { + BOOL bOld = ((const SvxPostureItem&)pEditView->GetAttribs(). + Get(EE_CHAR_ITALIC)).GetValue() != ITALIC_NONE; + aSet.Put( SvxPostureItem( bOld ? ITALIC_NONE : ITALIC_NORMAL, EE_CHAR_ITALIC ) ); + rBindings.Invalidate( nSlot ); + } + break; + + case SID_ULINE_VAL_NONE: + aSet.Put( SvxUnderlineItem( UNDERLINE_NONE, EE_CHAR_UNDERLINE ) ); + lcl_InvalidateUnder( rBindings ); + break; + + case SID_ATTR_CHAR_UNDERLINE: // Toggles + case SID_ULINE_VAL_SINGLE: + case SID_ULINE_VAL_DOUBLE: + case SID_ULINE_VAL_DOTTED: + { + FontUnderline eOld = ((const SvxUnderlineItem&) pEditView-> + GetAttribs().Get(EE_CHAR_UNDERLINE)).GetUnderline(); + FontUnderline eNew = eOld; + switch (nSlot) + { + case SID_ATTR_CHAR_UNDERLINE: + eNew = ( eOld != UNDERLINE_NONE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE; + break; + case SID_ULINE_VAL_SINGLE: + eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE; + break; + case SID_ULINE_VAL_DOUBLE: + eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE; + break; + case SID_ULINE_VAL_DOTTED: + eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED; + break; + } + aSet.Put( SvxUnderlineItem( eNew, EE_CHAR_UNDERLINE ) ); + lcl_InvalidateUnder( rBindings ); + } + break; + + case SID_ATTR_CHAR_STRIKEOUT: + { + BOOL bOld = ((const SvxCrossedOutItem&)pEditView->GetAttribs(). + Get(EE_CHAR_STRIKEOUT)).GetValue() != STRIKEOUT_NONE; + aSet.Put( SvxCrossedOutItem( bOld ? STRIKEOUT_NONE : STRIKEOUT_SINGLE, EE_CHAR_STRIKEOUT ) ); + rBindings.Invalidate( nSlot ); + } + break; + + case SID_ATTR_CHAR_SHADOWED: + { + BOOL bOld = ((const SvxShadowedItem&)pEditView->GetAttribs(). + Get(EE_CHAR_SHADOW)).GetValue(); + aSet.Put( SvxShadowedItem( !bOld, EE_CHAR_SHADOW ) ); + rBindings.Invalidate( nSlot ); + } + break; + + case SID_ATTR_CHAR_CONTOUR: + { + BOOL bOld = ((const SvxContourItem&)pEditView->GetAttribs(). + Get(EE_CHAR_OUTLINE)).GetValue(); + aSet.Put( SvxContourItem( !bOld, EE_CHAR_OUTLINE ) ); + rBindings.Invalidate( nSlot ); + } + break; + + case SID_SET_SUPER_SCRIPT: + { + SvxEscapement eOld = (SvxEscapement) ((const SvxEscapementItem&) + pEditView->GetAttribs().Get(EE_CHAR_ESCAPEMENT)).GetEnumValue(); + SvxEscapement eNew = (eOld == SVX_ESCAPEMENT_SUPERSCRIPT) ? + SVX_ESCAPEMENT_OFF : SVX_ESCAPEMENT_SUPERSCRIPT; + aSet.Put( SvxEscapementItem( eNew, EE_CHAR_ESCAPEMENT ) ); + rBindings.Invalidate( nSlot ); + } + break; + case SID_SET_SUB_SCRIPT: + { + SvxEscapement eOld = (SvxEscapement) ((const SvxEscapementItem&) + pEditView->GetAttribs().Get(EE_CHAR_ESCAPEMENT)).GetEnumValue(); + SvxEscapement eNew = (eOld == SVX_ESCAPEMENT_SUBSCRIPT) ? + SVX_ESCAPEMENT_OFF : SVX_ESCAPEMENT_SUBSCRIPT; + aSet.Put( SvxEscapementItem( eNew, EE_CHAR_ESCAPEMENT ) ); + rBindings.Invalidate( nSlot ); + } + break; + } + + // + // anwenden + // + + EditEngine* pEngine = pEditView->GetEditEngine(); + BOOL bOld = pEngine->GetUpdateMode(); + pEngine->SetUpdateMode(FALSE); + + pEditView->SetAttribs( aSet ); + + pEngine->SetUpdateMode(bOld); + pEditView->Invalidate(); + + ScInputHandler* pHdl = SC_MOD()->GetInputHdl(); + pHdl->SetModified(); + + rReq.Done(); +} + +#pragma SEG_FUNCDEF(editsh_07) + +void ScEditShell::GetAttrState(SfxItemSet &rSet) +{ + SfxItemSet aAttribs = pEditView->GetAttribs(); + rSet.Put( aAttribs ); + + // Unterstreichung + + SfxItemState eState = aAttribs.GetItemState( EE_CHAR_UNDERLINE, TRUE ); + if ( eState == SFX_ITEM_DONTCARE ) + { + rSet.InvalidateItem( SID_ULINE_VAL_NONE ); + rSet.InvalidateItem( SID_ULINE_VAL_SINGLE ); + rSet.InvalidateItem( SID_ULINE_VAL_DOUBLE ); + rSet.InvalidateItem( SID_ULINE_VAL_DOTTED ); + } + else + { + FontUnderline eUnderline = ((const SvxUnderlineItem&) + aAttribs.Get(EE_CHAR_UNDERLINE)).GetUnderline(); + USHORT nId = SID_ULINE_VAL_NONE; + switch (eUnderline) + { + case UNDERLINE_SINGLE: nId = SID_ULINE_VAL_SINGLE; break; + case UNDERLINE_DOUBLE: nId = SID_ULINE_VAL_DOUBLE; break; + case UNDERLINE_DOTTED: nId = SID_ULINE_VAL_DOTTED; break; + default: + break; + } + rSet.Put( SfxBoolItem( nId, TRUE ) ); + } + + //! Testen, ob Klammer-Hervorhebung aktiv ist !!!! + ScInputHandler* pHdl = SC_MOD()->GetInputHdl(); + if ( pHdl && pHdl->IsFormulaMode() ) + rSet.ClearItem( EE_CHAR_WEIGHT ); // hervorgehobene Klammern hier nicht +} + +#pragma SEG_FUNCDEF(editsh_0b) + +String ScEditShell::GetSelectionText( BOOL bWholeWord ) +{ + String aStrSelection; + + if ( bWholeWord ) + { + EditEngine* pEngine = pEditView->GetEditEngine(); + ESelection aSel = pEditView->GetSelection(); + String aStrCurrentDelimiters = pEngine->GetWordDelimiters(); + + pEngine->SetWordDelimiters( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(" .,;\"'")) ); + aStrSelection = pEngine->GetWord( aSel.nEndPara, aSel.nEndPos ); + pEngine->SetWordDelimiters( aStrCurrentDelimiters ); + } + else + { + aStrSelection = pEditView->GetSelected(); + } + + return aStrSelection; +} + +/*------------------------------------------------------------------------ + + $Log: not supported by cvs2svn $ + Revision 1.85 2000/09/17 14:09:31 willem.vandorp + OpenOffice header added. + + Revision 1.84 2000/08/31 16:38:45 willem.vandorp + Header and footer replaced + + Revision 1.83 2000/07/21 18:21:23 nn + select url field after inserting + + Revision 1.82 2000/07/21 10:35:15 nn + #75683# SID_HYPERLINK_GETLINK: use selection as text if no link selected + + Revision 1.81 2000/05/09 18:30:15 nn + use IMPL_INTERFACE macro without IDL + + Revision 1.80 2000/04/14 08:31:37 nn + unicode changes + + Revision 1.79 2000/03/31 17:27:08 nn + #74687# after executing dialogs, check for edit mode + + Revision 1.78 2000/02/11 12:37:23 hr + #70473# changes for unicode ( patched by automated patchtool ) + + Revision 1.77 1999/09/24 15:59:13 nn + hlnkitem.hxx moved to svx + + Revision 1.76 1999/06/02 19:41:34 ANK + #66547# SubShells + + + Rev 1.75 02 Jun 1999 21:41:34 ANK + #66547# SubShells + + Rev 1.74 14 Jan 1999 16:21:56 NN + #60725# SID_CHARMAP: SetAttribs an der EditEngine statt der View + + Rev 1.73 13 Jan 1999 17:05:52 NN + #60811# SID_HYPERLINK_SETLINK: Adjust an der Selektion rufen + + Rev 1.72 16 Nov 1998 20:48:28 NN + #57254# SID_HYPERLINK_SETLINK: auch TopView + + Rev 1.71 05 Dec 1997 19:21:52 NN + Includes + + Rev 1.70 02 Dec 1997 12:38:40 TJ + include + + Rev 1.69 24 Nov 1997 20:06:08 NN + includes + + Rev 1.68 11 Sep 1997 19:57:02 NN + Hyperlink ersetzen: Einfuegen auf Selektion + + Rev 1.67 04 Sep 1997 19:44:22 RG + change header + + Rev 1.66 27 Aug 1997 12:19:28 TRI + VCL Anpassung + + Rev 1.65 05 Aug 1997 14:29:22 TJ + include svx/srchitem.hxx + + Rev 1.64 01 Aug 1997 11:32:58 NN + #42327# RemoveAttribs(TRUE) + + Rev 1.63 30 Jul 1997 17:27:10 HJS + includes + + Rev 1.62 29 Jul 1997 21:23:02 MH + Syntax + + Rev 1.61 29 Jul 1997 09:55:14 OM + Hyperlink Statusmethode + + Rev 1.60 16 Jul 1997 21:04:26 NN + Hypo-Feature: Klammern hervorheben + +------------------------------------------------------------------------*/ + +#pragma SEG_EOFMODULE + + diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx new file mode 100644 index 000000000000..73d35153dc48 --- /dev/null +++ b/sc/source/ui/view/formatsh.cxx @@ -0,0 +1,1805 @@ +/************************************************************************* + * + * $RCSfile: formatsh.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +//svdraw.hxx +#define _SDR_NOITEMS +#define _SDR_NOTOUCH +#define _SDR_NOTRANSFORM +#define _SI_NOSBXCONTROLS +#define _VCONT_HXX +#define _SI_NOOTHERFORMS +#define _VCTRLS_HXX +#define _SI_NOCONTROL +#define _SETBRW_HXX +#define _VCBRW_HXX +#define _SI_NOSBXCONTROLS + +//------------------------------------------------------------------ + +#include "scitems.hxx" +#include <sfx2/request.hxx> +#include <svtools/whiter.hxx> +#include <vcl/msgbox.hxx> + +#define _ZFORLIST_DECLARE_TABLE +#include <svtools/stritem.hxx> +#include <svtools/zformat.hxx> +#include <svx/boxitem.hxx> +#include <svx/langitem.hxx> +#include <svx/numinf.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/templdlg.hxx> +#include <sfx2/tplpitem.hxx> +#include <svx/svxenum.hxx> +#include <svx/algitem.hxx> +#include <svx/wghtitem.hxx> +#include <svx/postitem.hxx> +#include <svx/udlnitem.hxx> +#include <svx/bolnitem.hxx> +#include <svx/colritem.hxx> +#include <svx/brshitem.hxx> + +#include "formatsh.hxx" +#include "sc.hrc" +#include "docsh.hxx" +#include "patattr.hxx" +#include "scmod.hxx" +#include "styledlg.hxx" +#include "attrdlg.hrc" +#include "stlpool.hxx" +#include "stlsheet.hxx" +#include "printfun.hxx" +#include "docpool.hxx" +#include "scresid.hxx" +#include "tabvwsh.hxx" +#include "undostyl.hxx" + + +#define ScFormatShell +#define TableFont +#define FormatForSelection +#include "scslots.hxx" + +#define Interior +#include <svx/svxslots.hxx> + + +TYPEINIT1( ScFormatShell, SfxShell ); + +SFX_IMPL_INTERFACE(ScFormatShell, SfxShell, ScResId(SCSTR_FORMATSHELL) ) +{ + SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD | + SFX_VISIBILITY_SERVER, + ScResId(RID_OBJECTBAR_FORMAT)); + +} + + +ScFormatShell::ScFormatShell(ScViewData* pData) : + SfxShell(pData->GetViewShell()), + pViewData(pData) +{ + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + + SetPool( &pTabViewShell->GetPool() ); + SetUndoManager( pViewData->GetSfxDocShell()->GetUndoManager() ); + SetHelpId(HID_SCSHELL_FORMATSH); + SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Format"))); +} + +ScFormatShell::~ScFormatShell() +{ +} + +//------------------------------------------------------------------ + +void __EXPORT ScFormatShell::GetStyleState( SfxItemSet& rSet ) +{ + ScDocument* pDoc = GetViewData()->GetDocument(); + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + SfxStyleSheetBasePool* pStylePool = pDoc->GetStyleSheetPool(); + SfxStyleSheetBase* pStyleSheet = NULL; + + BOOL bProtected = FALSE; + USHORT nTabCount = pDoc->GetTableCount(); + for (USHORT i=0; i<nTabCount; i++) + if (pDoc->IsTabProtected(i)) // ueberhaupt eine Tabelle geschuetzt? + bProtected = TRUE; + + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + USHORT nSlotId = 0; + + while ( nWhich ) + { + nSlotId = SfxItemPool::IsWhich( nWhich ) + ? GetPool().GetSlotId( nWhich ) + : nWhich; + + switch ( nSlotId ) + { + case SID_STYLE_APPLY: + if ( !pStylePool ) + rSet.DisableItem( nSlotId ); + break; + + case SID_STYLE_FAMILY2: // Zellvorlagen + { + SfxStyleSheet* pStyleSheet = (SfxStyleSheet*) + pTabViewShell->GetStyleSheetFromMarked(); + + if ( pStyleSheet ) + rSet.Put( SfxTemplateItem( nSlotId, pStyleSheet->GetName() ) ); + else + rSet.Put( SfxTemplateItem( nSlotId, String() ) ); + } + break; + + case SID_STYLE_FAMILY4: // Seitenvorlagen + { + USHORT nCurTab = GetViewData()->GetTabNo(); + String aPageStyle = pDoc->GetPageStyle( nCurTab ); + SfxStyleSheet* pStyleSheet = (SfxStyleSheet*)pStylePool-> + Find( aPageStyle, SFX_STYLE_FAMILY_PAGE ); + + if ( pStyleSheet ) + rSet.Put( SfxTemplateItem( nSlotId, aPageStyle ) ); + else + rSet.Put( SfxTemplateItem( nSlotId, String() ) ); + } + break; + + case SID_STYLE_WATERCAN: + { + rSet.Put( SfxBoolItem( nSlotId, SC_MOD()->GetIsWaterCan() ) ); + } + break; + + case SID_STYLE_UPDATE_BY_EXAMPLE: + { + ISfxTemplateCommon* pDesigner = SFX_APP()-> + GetCurrentTemplateCommon(pTabViewShell->GetViewFrame()->GetBindings()); + BOOL bPage = pDesigner && SFX_STYLE_FAMILY_PAGE == pDesigner->GetActualFamily(); + + if ( bProtected || bPage ) + rSet.DisableItem( nSlotId ); + } + break; + + case SID_STYLE_EDIT: + case SID_STYLE_DELETE: + { + ISfxTemplateCommon* pDesigner = SFX_APP()-> + GetCurrentTemplateCommon(pTabViewShell->GetViewFrame()->GetBindings()); + BOOL bPage = pDesigner && SFX_STYLE_FAMILY_PAGE == pDesigner->GetActualFamily(); + + if ( bProtected && !bPage ) + rSet.DisableItem( nSlotId ); + } + break; + + default: + break; + } + + nWhich = aIter.NextWhich(); + } +} + +//------------------------------------------------------------------ + +void __EXPORT ScFormatShell::ExecuteStyle( SfxRequest& rReq ) +{ + // Wenn ToolBar vertikal : + if ( !rReq.GetArgs() ) + { + SFX_DISPATCHER().Execute( SID_STYLE_DESIGNER, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD ); + return; + } + + //-------------------------------------------------------------------- + SfxBindings& rBindings = SFX_BINDINGS(); + const SfxItemSet* pArgs = rReq.GetArgs(); + const USHORT nSlotId = rReq.GetSlot(); + const USHORT nCurTab = GetViewData()->GetTabNo(); + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScTabViewShell* pTabViewShell= GetViewData()->GetViewShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + ScModule* pScMod = SC_MOD(); + String aRefName; + + if ( (nSlotId == SID_STYLE_NEW) + || (nSlotId == SID_STYLE_EDIT) + || (nSlotId == SID_STYLE_DELETE) + || (nSlotId == SID_STYLE_APPLY) + || (nSlotId == SID_STYLE_WATERCAN) + || (nSlotId == SID_STYLE_FAMILY) + || (nSlotId == SID_STYLE_NEW_BY_EXAMPLE) + || (nSlotId == SID_STYLE_UPDATE_BY_EXAMPLE) ) + { + SfxStyleSheetBasePool* pStylePool = pDoc->GetStyleSheetPool(); + SfxStyleSheetBase* pStyleSheet = NULL; + + BOOL bAddUndo = FALSE; // add ScUndoModifyStyle (style modified) + ScStyleSaveData aOldData; // for undo/redo + ScStyleSaveData aNewData; + + SfxStyleFamily eFamily = SFX_STYLE_FAMILY_PARA; + const SfxPoolItem* pFamItem; + if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILY, TRUE, &pFamItem ) ) + eFamily = (SfxStyleFamily)((const SfxUInt16Item*)pFamItem)->GetValue(); + + String aStyleName; + USHORT nRetMask = 0xffff; + BOOL bGrabFocus = ( SID_STYLE_APPLY == nSlotId ); + + pStylePool->SetSearchMask( eFamily, SFXSTYLEBIT_ALL ); + + switch ( nSlotId ) + { + case SID_STYLE_NEW: + { + const SfxPoolItem* pNameItem; + if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( nSlotId, TRUE, &pNameItem )) + aStyleName = ((const SfxStringItem*)pNameItem)->GetValue(); + + const SfxPoolItem* pRefItem=NULL; + if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_REFERENCE, TRUE, &pRefItem )) + { + if(pRefItem!=NULL) + aRefName = ((const SfxStringItem*)pRefItem)->GetValue(); + } + + pStyleSheet = &(pStylePool->Make( aStyleName, eFamily, + SFXSTYLEBIT_USERDEF ) ); + + if(pStyleSheet!=NULL) pStyleSheet->SetParent(aRefName); + } + break; + + case SID_STYLE_EDIT: + case SID_STYLE_DELETE: + case SID_STYLE_APPLY: + case SID_STYLE_NEW_BY_EXAMPLE: + { + const SfxPoolItem* pNameItem; + if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( nSlotId, TRUE, &pNameItem )) + aStyleName = ((const SfxStringItem*)pNameItem)->GetValue(); + pStyleSheet = pStylePool->Find( aStyleName, eFamily ); + + aOldData.InitFromStyle( pStyleSheet ); + } + break; + + case SID_STYLE_WATERCAN: + { + BOOL bWaterCan = pScMod->GetIsWaterCan(); + + if( !bWaterCan ) + { + const SfxPoolItem* pItem; + + if ( SFX_ITEM_SET == + pArgs->GetItemState( nSlotId, TRUE, &pItem ) ) + { + const SfxStringItem* pStrItem = PTR_CAST(SfxStringItem,pItem); + if ( pStrItem ) + { + aStyleName = pStrItem->GetValue(); + pStyleSheet = pStylePool->Find( aStyleName, eFamily ); + + if ( pStyleSheet ) + { + ((ScStyleSheetPool*)pStylePool)-> + SetActualStyleSheet( pStyleSheet ); + rReq.Done(); + } + } + } + } + + if ( !bWaterCan && pStyleSheet ) + { + pScMod->SetWaterCan( TRUE ); + pTabViewShell->SetActivePointer( Pointer(POINTER_FILL) ); + rReq.Done(); + } + else + { + pScMod->SetWaterCan( FALSE ); + pTabViewShell->SetActivePointer( Pointer(POINTER_ARROW) ); + rReq.Done(); + } + } + break; + + default: + break; + } + + // Neuen Style fuer WaterCan-Mode setzen + if ( nSlotId == SID_STYLE_APPLY && pScMod->GetIsWaterCan() && pStyleSheet ) + ((ScStyleSheetPool*)pStylePool)->SetActualStyleSheet( pStyleSheet ); + + switch ( eFamily ) + { + case SFX_STYLE_FAMILY_PARA: + { + switch ( nSlotId ) + { + case SID_STYLE_DELETE: + { + if ( pStyleSheet ) + { + pTabViewShell->RemoveStyleSheetInUse( (SfxStyleSheet*)pStyleSheet ); + pStylePool->Erase( pStyleSheet ); + pTabViewShell->InvalidateAttribs(); + nRetMask = TRUE; + bAddUndo = TRUE; + rReq.Done(); + } + else + nRetMask = FALSE; + } + break; + + case SID_STYLE_APPLY: + { + if ( pStyleSheet && !pScMod->GetIsWaterCan() ) + { + // Anwenden der Vorlage auf das Dokument + pTabViewShell->SetStyleSheetToMarked( (SfxStyleSheet*)pStyleSheet ); + pTabViewShell->InvalidateAttribs(); + rReq.Done(); + } + } + break; + + case SID_STYLE_NEW_BY_EXAMPLE: + case SID_STYLE_UPDATE_BY_EXAMPLE: + { + // Vorlage erzeugen/ersetzen durch Attribute + // an der Cursor-Position: + + const ScPatternAttr* pAttrItem = NULL; + + // Die Abfrage, ob markiert ist, war hier immer falsch, + // darum jetzt gar nicht mehr, und einfach vom Cursor. + // Wenn Attribute aus der Selektion genommen werden sollen, + // muss noch darauf geachtet werden, Items aus Vorlagen nicht + // zu uebernehmen (GetSelectionPattern sammelt auch Items aus + // Vorlagen zusammen) (#44748#) + // pAttrItem = GetSelectionPattern(); + + ScViewData* pViewData = GetViewData(); + USHORT nCol = pViewData->GetCurX(); + USHORT nRow = pViewData->GetCurY(); + pAttrItem = pDoc->GetPattern( nCol, nRow, nCurTab ); + + SfxItemSet aAttrSet = pAttrItem->GetItemSet(); + aAttrSet.ClearItem( ATTR_MERGE ); + aAttrSet.ClearItem( ATTR_MERGE_FLAG ); + // bedingte Formatierung und Gueltigkeit nicht uebernehmen, + // weil sie in der Vorlage nicht editiert werden koennen + aAttrSet.ClearItem( ATTR_VALIDDATA ); + aAttrSet.ClearItem( ATTR_CONDITIONAL ); + + if ( SID_STYLE_NEW_BY_EXAMPLE == nSlotId ) + { + BOOL bConvertBack = FALSE; + SfxStyleSheet* pSheetInUse = (SfxStyleSheet*) + pTabViewShell->GetStyleSheetFromMarked(); + + // wenn neuer Style vorhanden und in der Selektion + // verwendet wird, so darf der Parent nicht uebernommen + // werden: + + if ( pStyleSheet && pSheetInUse && pStyleSheet == pSheetInUse ) + pSheetInUse = NULL; + + // wenn bereits vorhanden, erstmal entfernen... + if ( pStyleSheet ) + { + // Style-Pointer zu Namen vor Erase, + // weil Zellen sonst ungueltige Pointer + // enthalten. + //!!! bei Gelenheit mal eine Methode, die + // das fuer einen bestimmten Style macht + pDoc->StylesToNames(); + bConvertBack = TRUE; + pStylePool->Erase(pStyleSheet); + } + + // ...und neu anlegen + pStyleSheet = &pStylePool->Make( aStyleName, eFamily, + SFXSTYLEBIT_USERDEF ); + + // wenn ein Style vorhanden ist, so wird dieser + // Parent der neuen Vorlage: + if ( pSheetInUse ) + pStyleSheet->SetParent( pSheetInUse->GetName() ); + + if ( bConvertBack ) + // Namen zu Style-Pointer + pDoc->UpdStlShtPtrsFrmNms(); + + // Attribute uebernehmen und Style anwenden + pStyleSheet->GetItemSet().Put( aAttrSet ); + pTabViewShell->UpdateStyleSheetInUse( (SfxStyleSheet*)pStyleSheet ); + pTabViewShell->SetStyleSheetToMarked( (SfxStyleSheet*)pStyleSheet ); + + pTabViewShell->InvalidateAttribs(); + } + else // ( nSlotId == SID_STYLE_UPDATE_BY_EXAMPLE ) + { + pStyleSheet = (SfxStyleSheet*)pTabViewShell->GetStyleSheetFromMarked(); + + if ( pStyleSheet ) + { + pStyleSheet->GetItemSet().Put( aAttrSet ); + pTabViewShell->UpdateStyleSheetInUse( (SfxStyleSheet*)pStyleSheet ); + pTabViewShell->SetStyleSheetToMarked( (SfxStyleSheet*)pStyleSheet ); + pTabViewShell->InvalidateAttribs(); + } + } + + aNewData.InitFromStyle( pStyleSheet ); + bAddUndo = TRUE; + rReq.Done(); + } + break; + + default: + break; + } + } // case SFX_STYLE_FAMILY_PARA: + break; + + case SFX_STYLE_FAMILY_PAGE: + { + switch ( nSlotId ) + { + case SID_STYLE_DELETE: + { + nRetMask = ( NULL != pStyleSheet ); + if ( pStyleSheet ) + { + if ( pDoc->RemovePageStyleInUse( pStyleSheet->GetName() ) ) + { + ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(), nCurTab ).UpdatePages(); + rBindings.Invalidate( SID_STATUS_PAGESTYLE ); + rBindings.Invalidate( FID_RESET_PRINTZOOM ); + } + pStylePool->Erase( pStyleSheet ); + rBindings.Invalidate( SID_STYLE_FAMILY4 ); + pDocSh->SetDocumentModified(); + bAddUndo = TRUE; + rReq.Done(); + } + } + break; + + case SID_STYLE_APPLY: + { + nRetMask = ( NULL != pStyleSheet ); + if ( pStyleSheet && !pScMod->GetIsWaterCan() ) + { + String aOldName = pDoc->GetPageStyle( nCurTab ); + if ( aOldName != aStyleName ) + { + pDoc->SetPageStyle( nCurTab, aStyleName ); + ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(), nCurTab ).UpdatePages(); + pDocSh->SetDocumentModified(); + rBindings.Invalidate( SID_STYLE_FAMILY4 ); + rBindings.Invalidate( SID_STATUS_PAGESTYLE ); + rBindings.Invalidate( FID_RESET_PRINTZOOM ); + + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoApplyPageStyle( pDocSh, + nCurTab, aOldName, aStyleName ) ); + } + rReq.Done(); + } + } + break; + + case SID_STYLE_NEW_BY_EXAMPLE: + { + const String& rStrCurStyle = pDoc->GetPageStyle( nCurTab ); + + if ( rStrCurStyle != aStyleName ) + { + SfxStyleSheetBase* pCurStyle = pStylePool->Find( rStrCurStyle, eFamily ); + SfxItemSet aAttrSet = pCurStyle->GetItemSet(); + USHORT nInTab; + BOOL bUsed = pDoc->IsPageStyleInUse( aStyleName, &nInTab ); + + // wenn bereits vorhanden, erstmal entfernen... + if ( pStyleSheet ) + pStylePool->Erase( pStyleSheet ); + + // ...und neu anlegen + pStyleSheet = &pStylePool->Make( aStyleName, eFamily, + SFXSTYLEBIT_USERDEF ); + + // Attribute uebernehmen + pStyleSheet->GetItemSet().Put( aAttrSet ); + pDocSh->SetDocumentModified(); + + // wenn in Verwendung -> Update + if ( bUsed ) + ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(), nInTab ).UpdatePages(); + + aNewData.InitFromStyle( pStyleSheet ); + bAddUndo = TRUE; + rReq.Done(); + nRetMask = TRUE; + } + } + break; + + default: + break; + } // switch ( nSlotId ) + } // case SFX_STYLE_FAMILY_PAGE: + break; + + default: + break; + } // switch ( eFamily ) + + // Neu anlegen oder bearbeiten ueber Dialog: + if ( nSlotId == SID_STYLE_NEW || nSlotId == SID_STYLE_EDIT ) + { + if ( pStyleSheet ) + { + SvxNumberInfoItem* pNumberInfoItem = NULL; + + SfxStyleFamily eFam = pStyleSheet->GetFamily(); + ScDocument* pDoc = GetViewData()->GetDocument(); + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScStyleDlg* pDlg = NULL; + USHORT nRsc = 0; + + // #37034#/#37245# alte Items aus der Vorlage merken + SfxItemSet aOldSet = pStyleSheet->GetItemSet(); + String aOldName = pStyleSheet->GetName(); + + switch ( eFam ) + { + case SFX_STYLE_FAMILY_PAGE: + nRsc = RID_SCDLG_STYLES_PAGE; + break; + + case SFX_STYLE_FAMILY_PARA: + default: + { + SfxItemSet& rSet = pStyleSheet->GetItemSet(); + + const SfxPoolItem* pItem; + if ( rSet.GetItemState( ATTR_VALUE_FORMAT, + FALSE, &pItem ) == SFX_ITEM_SET ) + { + // NumberFormat Value aus Value und Language + // erzeugen und eintueten + ULONG nFormat = + ((SfxUInt32Item*)pItem)->GetValue(); + LanguageType eLang = + ((SvxLanguageItem*)&rSet.Get( + ATTR_LANGUAGE_FORMAT ))->GetLanguage(); + ULONG nLangFormat = pDoc->GetFormatTable()-> + GetFormatForLanguageIfBuiltIn( nFormat, eLang ); + if ( nLangFormat != nFormat ) + { + SfxUInt32Item aNewItem( ATTR_VALUE_FORMAT, nLangFormat ); + rSet.Put( aNewItem ); + aOldSet.Put( aNewItem ); + // auch in aOldSet fuer Vergleich nach dem Dialog, + // sonst geht evtl. eine Aenderung der Sprache verloren + } + } + + pTabViewShell->MakeNumberInfoItem( pDoc, GetViewData(), &pNumberInfoItem ); + pDocSh->PutItem( *pNumberInfoItem ); + nRsc = RID_SCDLG_STYLES_PAR; + + // auf jeden Fall ein SvxBoxInfoItem mit Table = FALSE im Set: + // (wenn gar kein Item da ist, loescht der Dialog auch das + // BORDER_OUTER SvxBoxItem aus dem Vorlagen-Set) + + if ( rSet.GetItemState( ATTR_BORDER_INNER, FALSE ) != SFX_ITEM_SET ) + { + SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER ); + aBoxInfoItem.SetTable(FALSE); // keine inneren Linien + aBoxInfoItem.SetDist(FALSE); + aBoxInfoItem.SetMinDist(FALSE); + rSet.Put( aBoxInfoItem ); + } + } + break; + } + + // If GetDefDialogParent is a dialog, it must be used + // (style catalog) + + Window* pParent = Application::GetDefDialogParent(); + if ( !pParent || !pParent->IsDialog() ) + pParent = pTabViewShell->GetDialogParent(); + + pTabViewShell->SetInFormatDialog(TRUE); + + pDlg = new ScStyleDlg( pParent, *pStyleSheet, nRsc ); + short nResult = pDlg->Execute(); + pTabViewShell->SetInFormatDialog(FALSE); + + if ( nResult == RET_OK ) + { + const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); + + if ( pOutSet ) + { + nRetMask = pStyleSheet->GetMask(); + + // #37034#/#37245# Attribut-Vergleiche (frueher in ModifyStyleSheet) + // jetzt hier mit den alten Werten (Style ist schon veraendert) + + if ( SFX_STYLE_FAMILY_PARA == eFam ) + { +// pDoc->CellStyleChanged( *pStyleSheet, aOldSet ); + + SfxItemSet& rNewSet = pStyleSheet->GetItemSet(); + BOOL bNumFormatChanged; + if ( ScGlobal::CheckWidthInvalidate( + bNumFormatChanged, aOldSet, rNewSet ) ) + pDoc->InvalidateTextWidth( NULL, NULL, bNumFormatChanged ); + + ULONG nOldFormat = ((const SfxUInt32Item&)aOldSet. + Get( ATTR_VALUE_FORMAT )).GetValue(); + ULONG nNewFormat = ((const SfxUInt32Item&)rNewSet. + Get( ATTR_VALUE_FORMAT )).GetValue(); + if ( nNewFormat != nOldFormat ) + { + SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + const SvNumberformat* pOld = pFormatter->GetEntry( nOldFormat ); + const SvNumberformat* pNew = pFormatter->GetEntry( nNewFormat ); + if ( pOld && pNew && pOld->GetLanguage() != pNew->GetLanguage() ) + rNewSet.Put( SvxLanguageItem( + pNew->GetLanguage(), ATTR_LANGUAGE_FORMAT ) ); + } + } + else + { + //! auch fuer Seitenvorlagen die Abfragen hier + + String aNewName = pStyleSheet->GetName(); + if ( aNewName != aOldName && + pDoc->RenamePageStyleInUse( aOldName, aNewName ) ) + { + rBindings.Invalidate( SID_STATUS_PAGESTYLE ); + rBindings.Invalidate( FID_RESET_PRINTZOOM ); + } + + pDoc->ModifyStyleSheet( *pStyleSheet, *pOutSet ); + rBindings.Invalidate( FID_RESET_PRINTZOOM ); + } + + pDocSh->SetDocumentModified(); + + if ( SFX_STYLE_FAMILY_PARA == eFam ) + { + pTabViewShell->UpdateNumberFormatter( pDoc, + (const SvxNumberInfoItem&) + *(pDocSh->GetItem(SID_ATTR_NUMBERFORMAT_INFO)) ); + + pTabViewShell->UpdateStyleSheetInUse( (SfxStyleSheet*)pStyleSheet ); + pTabViewShell->InvalidateAttribs(); + } + + aNewData.InitFromStyle( pStyleSheet ); + bAddUndo = TRUE; + } + } + else + { + if ( nSlotId == SID_STYLE_NEW ) + pStylePool->Erase( pStyleSheet ); + else + { + // falls zwischendurch etwas mit dem temporaer geaenderten + // ItemSet gepainted wurde: + pDocSh->PostPaintGridAll(); + } + } + delete pDlg; + } + } + +// if ( nRetMask != 0xffff )// Irgendein Wert MUSS geliefert werden JN + rReq.SetReturnValue( SfxUInt16Item( nSlotId, nRetMask ) ); + + if ( bGrabFocus ) + pTabViewShell->GetActiveWin()->GrabFocus(); + + if ( bAddUndo ) + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoModifyStyle( pDocSh, eFamily, aOldData, aNewData ) ); + } + else + { + DBG_ERROR( "Unknown slot (ScViewShell::ExecuteStyle)" ); + } +} + +void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq ) +{ + ScModule* pScMod = SC_MOD(); + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings(); + const SfxItemSet* pReqArgs = rReq.GetArgs(); + USHORT nSlot = rReq.GetSlot(); + + pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox + + // Eingabe beenden + if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) ) + { + switch ( nSlot ) + { + case SID_NUMBER_TWODEC: + case SID_NUMBER_SCIENTIFIC: + case SID_NUMBER_DATE: + case SID_NUMBER_CURRENCY: + case SID_NUMBER_PERCENT: + case SID_NUMBER_STANDARD: + case SID_NUMBER_FORMAT: + case SID_NUMBER_INCDEC: + case SID_NUMBER_DECDEC: + case FID_DEFINE_NAME: + case FID_USE_NAME: + case FID_INSERT_NAME: + case SID_SPELLING: + + pScMod->InputEnterHandler(); + pTabViewShell->UpdateInputHandler(); + break; + + default: + break; + } + } + + switch ( nSlot ) + { + case SID_NUMBER_TWODEC: + pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER, 4 ); // Standard+4 = #.##0,00 + rReq.Done(); + break; + case SID_NUMBER_SCIENTIFIC: + pTabViewShell->SetNumberFormat( NUMBERFORMAT_SCIENTIFIC ); + rReq.Done(); + break; + case SID_NUMBER_DATE: + pTabViewShell->SetNumberFormat( NUMBERFORMAT_DATE ); + rReq.Done(); + break; + case SID_NUMBER_TIME: + pTabViewShell->SetNumberFormat( NUMBERFORMAT_TIME ); + rReq.Done(); + break; + case SID_NUMBER_CURRENCY: + pTabViewShell->SetNumberFormat( NUMBERFORMAT_CURRENCY ); + rReq.Done(); + break; + case SID_NUMBER_PERCENT: + pTabViewShell->SetNumberFormat( NUMBERFORMAT_PERCENT ); + rReq.Done(); + break; + case SID_NUMBER_STANDARD: + pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER ); + rReq.Done(); + break; + case SID_NUMBER_INCDEC: + pTabViewShell->ChangeNumFmtDecimals( TRUE ); + rReq.Done(); + break; + case SID_NUMBER_DECDEC: + pTabViewShell->ChangeNumFmtDecimals( FALSE ); + rReq.Done(); + break; + + case SID_NUMBER_FORMAT: + if ( pReqArgs ) + { + const SfxPoolItem* pItem; + if(pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET) + { + String aCode = ((const SfxStringItem*)pItem)->GetValue(); + pTabViewShell->SetNumFmtByStr( aCode ); + } + } + break; + + default: + DBG_ERROR("falscher Slot bei ExecuteEdit"); + break; + } +} + + +//------------------------------------------------------------------ + +#define APPLY_HOR_JUSTIFY(j) \ + { \ + if ( !pHorJustify || (eHorJustify != (j) ) ) \ + pTabViewShell->ApplyAttr( SvxHorJustifyItem( (j) ) ); \ + else \ + pTabViewShell->ApplyAttr( SvxHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD ) ); \ + } + +#define APPLY_VER_JUSTIFY(j) \ + { \ + if ( !pVerJustify || (eVerJustify != (j) ) ) \ + pTabViewShell->ApplyAttr( SvxVerJustifyItem( (j) ) ); \ + else \ + pTabViewShell->ApplyAttr( SvxVerJustifyItem( SVX_VER_JUSTIFY_STANDARD ) ); \ + } + +void ScFormatShell::ExecuteAlignment( SfxRequest& rReq ) +{ + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + SfxBindings& rBindings = SFX_BINDINGS(); + const SfxItemSet* pSet = rReq.GetArgs(); + USHORT nSlot = rReq.GetSlot(); + + pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox + + if( pSet ) + { + const SfxPoolItem* pItem = NULL; + if( pSet->GetItemState((nSlot), TRUE, &pItem ) == SFX_ITEM_SET ) + { + + switch ( nSlot ) + { + case SID_H_ALIGNCELL: + { + pTabViewShell->ApplyAttr( SvxHorJustifyItem( (SvxCellHorJustify)((const SvxHorJustifyItem*)pItem)->GetValue() ) ); + } + break; + case SID_V_ALIGNCELL: + { + pTabViewShell->ApplyAttr( SvxVerJustifyItem( (SvxCellVerJustify)((const SvxVerJustifyItem*)pItem)->GetValue() ) ); + } + break; + default: + DBG_ERROR( "ExecuteAlignment: invalid slot" ); + return; + } + + rBindings.Invalidate( SID_ALIGNLEFT ); + rBindings.Invalidate( SID_ALIGNRIGHT ); + rBindings.Invalidate( SID_ALIGNCENTERHOR ); + rBindings.Invalidate( SID_ALIGNBLOCK ); + rBindings.Invalidate( SID_ALIGNTOP ); + rBindings.Invalidate( SID_ALIGNBOTTOM ); + rBindings.Invalidate( SID_ALIGNCENTERVER ); + rBindings.Invalidate( SID_V_ALIGNCELL ); + rBindings.Invalidate( SID_H_ALIGNCELL ); + rBindings.Update(); + + if( ! rReq.IsAPI() ) + rReq.Done(); + } + } +} + +void ScFormatShell::ExecuteTextAttr( SfxRequest& rReq ) +{ + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + SfxBindings& rBindings = SFX_BINDINGS(); + const ScPatternAttr* pAttrs = pTabViewShell->GetSelectionPattern(); + const SfxItemSet* pSet = rReq.GetArgs(); + const SfxItemSet* pReqArgs = rReq.GetArgs(); + USHORT nSlot = rReq.GetSlot(); + SfxAllItemSet* pNewSet = 0; + + pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox + + if ( (nSlot == SID_ATTR_CHAR_WEIGHT) + ||(nSlot == SID_ATTR_CHAR_POSTURE) + ||(nSlot == SID_ATTR_CHAR_UNDERLINE) + ||(nSlot == SID_ULINE_VAL_NONE) + ||(nSlot == SID_ULINE_VAL_SINGLE) + ||(nSlot == SID_ULINE_VAL_DOUBLE) + ||(nSlot == SID_ULINE_VAL_DOTTED) ) + { + pNewSet = new SfxAllItemSet( GetPool() ); + + switch ( nSlot ) + { + case SID_ATTR_CHAR_WEIGHT: + { + FontWeight eWeight; + + if( pSet ) + { + const SvxWeightItem& rWeight = (const SvxWeightItem&)pSet->Get( ATTR_FONT_WEIGHT ); + + if( rWeight.ISA(SvxWeightItem) ) + { + pTabViewShell->ApplyAttr( rWeight ); + pNewSet->Put( rWeight,rWeight.Which() ); + } + } + else + { + SvxWeightItem aWeightItem( (const SvxWeightItem&) + pAttrs->GetItem( ATTR_FONT_WEIGHT ) ); + + eWeight = (WEIGHT_BOLD == aWeightItem.GetWeight()) + ? WEIGHT_NORMAL + : WEIGHT_BOLD; + + aWeightItem.SetWeight( eWeight ); + pTabViewShell->ApplyAttr( aWeightItem ); + pNewSet->Put( aWeightItem, aWeightItem.Which() ); + } + } + break; + + case SID_ATTR_CHAR_POSTURE: + { + FontItalic eItalic; + + if( pSet ) + { + const SvxPostureItem& rPosture = (const SvxPostureItem&)pSet->Get( ATTR_FONT_POSTURE ); + + if( rPosture.ISA(SvxPostureItem) ) + { + pTabViewShell->ApplyAttr( rPosture ); + pNewSet->Put( rPosture,rPosture.Which() ); + } + } + else + { + SvxPostureItem aPosture( (const SvxPostureItem&) + pAttrs->GetItem( ATTR_FONT_POSTURE ) ); + + eItalic = (ITALIC_NORMAL == aPosture.GetPosture()) + ? ITALIC_NONE + : ITALIC_NORMAL; + + aPosture.SetPosture( eItalic ); + pTabViewShell->ApplyAttr( aPosture ); + pNewSet->Put( aPosture,aPosture.Which() ); + } + } + break; + + case SID_ATTR_CHAR_UNDERLINE: + { + FontUnderline eUnderline; + + if( pSet ) + { + const SvxUnderlineItem& rUnderline = (const SvxUnderlineItem&)pSet->Get( ATTR_FONT_UNDERLINE ); + + if( rUnderline.ISA(SvxUnderlineItem) ) + { + pTabViewShell->ApplyAttr( rUnderline ); + pNewSet->Put( rUnderline,rUnderline.Which() ); + } + } + else + { + SvxUnderlineItem aUnderline( (const SvxUnderlineItem&) + pAttrs->GetItem( + ATTR_FONT_UNDERLINE ) ); + eUnderline = (UNDERLINE_NONE != aUnderline.GetUnderline()) + ? UNDERLINE_NONE + : UNDERLINE_SINGLE; + aUnderline.SetUnderline( eUnderline ); + pTabViewShell->ApplyAttr( aUnderline ); + pNewSet->Put( aUnderline,aUnderline.Which() ); + } + } + break; + + case SID_ULINE_VAL_NONE: + pTabViewShell->ApplyAttr( SvxUnderlineItem( UNDERLINE_NONE, ATTR_FONT_UNDERLINE ) ); + break; + case SID_ULINE_VAL_SINGLE: // Toggles + case SID_ULINE_VAL_DOUBLE: + case SID_ULINE_VAL_DOTTED: + { + FontUnderline eOld = ((const SvxUnderlineItem&) + pAttrs->GetItem(ATTR_FONT_UNDERLINE)).GetUnderline(); + FontUnderline eNew = eOld; + switch (nSlot) + { + case SID_ULINE_VAL_SINGLE: + eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE; + break; + case SID_ULINE_VAL_DOUBLE: + eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE; + break; + case SID_ULINE_VAL_DOTTED: + eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED; + break; + } + pTabViewShell->ApplyAttr( SvxUnderlineItem( eNew, ATTR_FONT_UNDERLINE ) ); + } + break; + + default: + break; + } + rBindings.Invalidate( nSlot ); + } + else + { + /* + * "Selbstgemachte" RadioButton-Funktionalitaet + * Beim Toggle gibt es den Standard-State, d.h. kein + * Button ist gedrueckt + */ + + const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); + const SfxPoolItem* pItem = NULL; + const SvxHorJustifyItem* pHorJustify = NULL; + const SvxVerJustifyItem* pVerJustify = NULL; + SvxCellHorJustify eHorJustify = SVX_HOR_JUSTIFY_STANDARD; + SvxCellVerJustify eVerJustify = SVX_VER_JUSTIFY_STANDARD; + + if (rAttrSet.GetItemState(ATTR_HOR_JUSTIFY, TRUE,&pItem ) == SFX_ITEM_SET) + { + pHorJustify = (const SvxHorJustifyItem*)pItem; + eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() ); + } + if (rAttrSet.GetItemState(ATTR_VER_JUSTIFY, TRUE,&pItem ) == SFX_ITEM_SET) + { + pVerJustify = (const SvxVerJustifyItem*)pItem; + eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() ); + } + + switch ( nSlot ) + { + case SID_ALIGNLEFT: + rReq.SetSlot( SID_H_ALIGNCELL ); + rReq.AppendItem( SvxHorJustifyItem( + !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_LEFT) ? + SVX_HOR_JUSTIFY_LEFT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) ); + ExecuteSlot( rReq, GetInterface() ); + return; +// APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_LEFT ); + break; + + case SID_ALIGNRIGHT: + rReq.SetSlot( SID_H_ALIGNCELL ); + rReq.AppendItem( SvxHorJustifyItem( + !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_RIGHT) ? + SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) ); + ExecuteSlot( rReq, GetInterface() ); + return; +// APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_RIGHT ); + break; + + case SID_ALIGNCENTERHOR: + rReq.SetSlot( SID_H_ALIGNCELL ); + rReq.AppendItem( SvxHorJustifyItem( + !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_CENTER) ? + SVX_HOR_JUSTIFY_CENTER : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) ); + ExecuteSlot( rReq, GetInterface() ); + return; +// APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_CENTER ); + break; + + case SID_ALIGNBLOCK: + rReq.SetSlot( SID_H_ALIGNCELL ); + rReq.AppendItem( SvxHorJustifyItem( + !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_BLOCK) ? + SVX_HOR_JUSTIFY_BLOCK : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) ); + ExecuteSlot( rReq, GetInterface() ); + return; +// APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_BLOCK ); + break; + + case SID_ALIGNTOP: + rReq.SetSlot( SID_V_ALIGNCELL ); + rReq.AppendItem( SvxVerJustifyItem( + !pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_TOP) ? + SVX_VER_JUSTIFY_TOP : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) ); + ExecuteSlot( rReq, GetInterface() ); + return; +// APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_TOP ); + break; + + case SID_ALIGNBOTTOM: + rReq.SetSlot( SID_V_ALIGNCELL ); + rReq.AppendItem( SvxVerJustifyItem( + !pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_BOTTOM) ? + SVX_VER_JUSTIFY_BOTTOM : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) ); + ExecuteSlot( rReq, GetInterface() ); + return; +// APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_BOTTOM ); + break; + + case SID_ALIGNCENTERVER: + rReq.SetSlot( SID_V_ALIGNCELL ); + rReq.AppendItem( SvxVerJustifyItem( + !pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_CENTER) ? + SVX_VER_JUSTIFY_CENTER : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) ); + ExecuteSlot( rReq, GetInterface() ); + return; +// APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_CENTER ); + break; + + default: + break; + } + + } + + rBindings.Update(); +// rReq.Done(); + + if( pNewSet ) + { + rReq.Done( *pNewSet ); + delete pNewSet; + } + else + { + rReq.Done(); + } + +} + +#undef APPLY_HOR_JUSTIFY +#undef APPLY_VER_JUSTIFY + +//------------------------------------------------------------------ + +void ScFormatShell::ExecuteAttr( SfxRequest& rReq ) +{ + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + SfxBindings& rBindings = SFX_BINDINGS(); + const SfxItemSet* pNewAttrs = rReq.GetArgs(); + + pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox + + if ( !pNewAttrs ) + { + USHORT nSlot = rReq.GetSlot(); + + switch ( nSlot ) + { + case SID_ATTR_CHAR_FONT: + case SID_ATTR_CHAR_FONTHEIGHT: + pTabViewShell->ExecuteCellFormatDlg( rReq, TP_FONT ); // wenn ToolBar vertikal + break; + + case SID_ATTR_ALIGN_LINEBREAK: // ohne Parameter als Toggle + { + const ScPatternAttr* pAttrs = pTabViewShell->GetSelectionPattern(); + BOOL bOld = ((const SfxBoolItem&)pAttrs->GetItem(ATTR_LINEBREAK)).GetValue(); + SfxBoolItem aBreakItem( ATTR_LINEBREAK, !bOld ); + pTabViewShell->ApplyAttr( aBreakItem ); + + SfxAllItemSet aNewSet( GetPool() ); + aNewSet.Put( aBreakItem,aBreakItem.Which() ); + rReq.Done( aNewSet ); + + rBindings.Invalidate( nSlot ); + } + break; + + case SID_BACKGROUND_COLOR: + { + // SID_BACKGROUND_COLOR without arguments -> set transparent background + + SvxBrushItem aBrushItem( (const SvxBrushItem&) + pTabViewShell->GetSelectionPattern()-> + GetItem( ATTR_BACKGROUND ) ); + + aBrushItem.SetColor( COL_TRANSPARENT ); + + pTabViewShell->ApplyAttr( aBrushItem ); + } + break; + } + } + else + { + USHORT nSlot = rReq.GetSlot(); + + switch ( nSlot ) + { + case SID_ATTR_ALIGN_LINEBREAK: + case SID_ATTR_CHAR_FONT: + case SID_ATTR_CHAR_FONTHEIGHT: + case SID_ATTR_CHAR_COLOR: + pTabViewShell->ApplyAttr( pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich( nSlot ) ) ); + rBindings.Invalidate( nSlot ); + rBindings.Update( nSlot ); + break; + + case SID_FRAME_LINESTYLE: + { + // Default-Linie aktualisieren + const SvxBorderLine* pLine = + ((const SvxLineItem&) + pNewAttrs->Get( SID_FRAME_LINESTYLE )). + GetLine(); + + if ( pLine ) + { + SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine(); + + if ( pDefLine ) + { + pDefLine->SetOutWidth( pLine->GetOutWidth() ); + pDefLine->SetInWidth ( pLine->GetInWidth() ); + pDefLine->SetDistance( pLine->GetDistance() ); + pTabViewShell->SetSelectionFrameLines( pDefLine, FALSE ); + } + else + { + pTabViewShell->SetDefaultFrameLine( pLine ); + pTabViewShell->GetDefaultFrameLine()->SetColor( COL_BLACK ); + pTabViewShell->SetSelectionFrameLines( pLine, FALSE ); + } + } + else + { + Color aColorBlack( COL_BLACK ); + SvxBorderLine aDefLine( &aColorBlack, 20, 0, 0 ); + pTabViewShell->SetDefaultFrameLine( &aDefLine ); + pTabViewShell->SetSelectionFrameLines( NULL, FALSE ); + } + } + break; + + case SID_FRAME_LINECOLOR: + { + SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine(); + const Color& rColor = ((const SvxColorItem&) + pNewAttrs->Get( SID_FRAME_LINECOLOR )). + GetValue(); + + // Default-Linie aktualisieren + if ( pDefLine ) + { + pDefLine->SetColor( rColor ); + pTabViewShell->SetSelectionFrameLines( pDefLine, TRUE ); + } + else + { + SvxBorderLine aDefLine( &rColor, 20, 0, 0 ); + pTabViewShell->SetDefaultFrameLine( &aDefLine ); + pTabViewShell->SetSelectionFrameLines( &aDefLine, FALSE ); + } + } + break; + + case SID_ATTR_BORDER_OUTER: + case SID_ATTR_BORDER: + { + SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine(); + const ScPatternAttr* pOldAttrs = pTabViewShell->GetSelectionPattern(); + ScDocument* pDoc = GetViewData()->GetDocument(); + SfxItemSet* pOldSet = + new SfxItemSet( + *(pDoc->GetPool()), + ATTR_PATTERN_START, + ATTR_PATTERN_END ); + SfxItemSet* pNewSet = + new SfxItemSet( + *(pDoc->GetPool()), + ATTR_PATTERN_START, + ATTR_PATTERN_END ); + const SfxPoolItem& rBorderAttr = + pOldAttrs->GetItemSet(). + Get( ATTR_BORDER ); + + // Border-Items vom Controller auswerten: + const SfxPoolItem* pItem = 0; + + if ( pNewAttrs->GetItemState( ATTR_BORDER, TRUE, &pItem ) + == SFX_ITEM_SET ) + { + SvxBoxItem aBoxItem ( *(const SvxBoxItem*)pItem ); + if ( aBoxItem.GetTop() ) + aBoxItem.SetLine( pDefLine, BOX_LINE_TOP ); + if ( aBoxItem.GetBottom() ) + aBoxItem.SetLine( pDefLine, BOX_LINE_BOTTOM ); + if ( aBoxItem.GetLeft() ) + aBoxItem.SetLine( pDefLine, BOX_LINE_LEFT ); + if ( aBoxItem.GetRight() ) + aBoxItem.SetLine( pDefLine, BOX_LINE_RIGHT ); + pNewSet->Put( aBoxItem ); + } + + if ( pNewAttrs->GetItemState( ATTR_BORDER_INNER, TRUE, &pItem ) + == SFX_ITEM_SET ) + { + SvxBoxInfoItem aBoxInfoItem( *(const SvxBoxInfoItem*)pItem ); + if ( aBoxInfoItem.GetHori() ) + aBoxInfoItem.SetLine( pDefLine, BOXINFO_LINE_HORI ); + if ( aBoxInfoItem.GetVert() ) + aBoxInfoItem.SetLine( pDefLine, BOXINFO_LINE_VERT ); + pNewSet->Put( aBoxInfoItem ); + } + else + { + SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER ); + aBoxInfoItem.SetLine( NULL, BOXINFO_LINE_HORI ); + aBoxInfoItem.SetLine( NULL, BOXINFO_LINE_VERT ); + pNewSet->Put( aBoxInfoItem ); + } + + pOldSet->Put( rBorderAttr ); + pTabViewShell->ApplyAttributes( pNewSet, pOldSet ); + + delete pOldSet; + delete pNewSet; + } + break; + + // ATTR_BACKGROUND (=SID_ATTR_BRUSH) muss ueber zwei IDs + // gesetzt werden: + case SID_BACKGROUND_COLOR: + { + const SvxColorItem rNewColorItem = (const SvxColorItem&) + pNewAttrs->Get( SID_BACKGROUND_COLOR ); + + SvxBrushItem aBrushItem( (const SvxBrushItem&) + pTabViewShell->GetSelectionPattern()-> + GetItem( ATTR_BACKGROUND ) ); + + aBrushItem.SetColor( rNewColorItem.GetValue() ); + + pTabViewShell->ApplyAttr( aBrushItem ); + } + break; + + case SID_ATTR_BRUSH: + { + SvxBrushItem aBrushItem( (const SvxBrushItem&) + pTabViewShell->GetSelectionPattern()-> + GetItem( ATTR_BACKGROUND ) ); + const SvxBrushItem& rNewBrushItem = (const SvxBrushItem&) + pNewAttrs->Get( GetPool().GetWhich(nSlot) ); + aBrushItem.SetColor(rNewBrushItem.GetColor()); + pTabViewShell->ApplyAttr( aBrushItem ); + } + break; + + default: + break; + } + + if( ! rReq.IsAPI() ) + if( ! rReq.IsDone() ) + rReq.Done(); + } +} + +void ScFormatShell::GetAttrState( SfxItemSet& rSet ) +{ + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); + const SfxItemSet* pParentSet = rAttrSet.GetParent(); + const SvxBorderLine* pLine = pTabViewShell->GetDefaultFrameLine(); + const SvxBrushItem& rBrushItem = (const SvxBrushItem&)rAttrSet.Get( ATTR_BACKGROUND ); + UINT8 nTrans = rBrushItem.GetColor().GetTransparency(); + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + + rSet.Put( rAttrSet, FALSE ); + + while ( nWhich ) + { + switch(nWhich) + { + case SID_BACKGROUND_COLOR: + { + Color aColor; + if ( nTrans == 255 ) + aColor = Application::GetSettings().GetStyleSettings().GetWindowColor(); + else + aColor = rBrushItem.GetColor(); + rSet.Put( SvxColorItem( aColor, SID_BACKGROUND_COLOR ) ); + } + break; + case SID_FRAME_LINECOLOR: + { + rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), + SID_FRAME_LINECOLOR ) ); + } + break; + case SID_ATTR_BRUSH: + { + rSet.Put( rBrushItem, GetPool().GetWhich(nWhich) ); + } + break; +/* case SID_ATTR_ALIGN_LINEBREAK: + { + const SfxBoolItem& rBreakItem = (const SfxBoolItem&)rAttrSet.Get( ATTR_LINEBREAK ); + rSet.Put( rBreakItem, GetPool().GetWhich(nWhich) ); + } + break; +*/ + } + nWhich = aIter.NextWhich(); + } +} + +//------------------------------------------------------------------ + +void ScFormatShell::GetTextAttrState( SfxItemSet& rSet ) +{ + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); + rSet.Put( rAttrSet, FALSE ); // ItemStates mitkopieren + + SfxItemState eState; +// const SfxPoolItem* pItem; + + //-------------------------------------------------------------------- + // eigene Kontrolle ueber RadioButton-Funktionalitaet: + //-------------------------------------------------------------------- + // Unterstreichung + //------------------------ + + eState = rAttrSet.GetItemState( ATTR_FONT_UNDERLINE, TRUE ); + if ( eState == SFX_ITEM_DONTCARE ) + { + rSet.InvalidateItem( SID_ULINE_VAL_NONE ); + rSet.InvalidateItem( SID_ULINE_VAL_SINGLE ); + rSet.InvalidateItem( SID_ULINE_VAL_DOUBLE ); + rSet.InvalidateItem( SID_ULINE_VAL_DOTTED ); + } + else + { + FontUnderline eUnderline = ((const SvxUnderlineItem&) + rAttrSet.Get(ATTR_FONT_UNDERLINE)).GetUnderline(); + USHORT nId = SID_ULINE_VAL_NONE; + switch (eUnderline) + { + case UNDERLINE_SINGLE: nId = SID_ULINE_VAL_SINGLE; break; + case UNDERLINE_DOUBLE: nId = SID_ULINE_VAL_DOUBLE; break; + case UNDERLINE_DOTTED: nId = SID_ULINE_VAL_DOTTED; break; + default: + break; + } + rSet.Put( SfxBoolItem( nId, TRUE ) ); + } + + //------------------------ + // horizontale Ausrichtung + //------------------------ + + const SvxHorJustifyItem* pHorJustify = NULL; + const SvxVerJustifyItem* pVerJustify = NULL; + SvxCellHorJustify eHorJustify = SVX_HOR_JUSTIFY_STANDARD; + SvxCellVerJustify eVerJustify = SVX_VER_JUSTIFY_STANDARD; + USHORT nWhich = 0; + BOOL bJustifyStd = FALSE; + SfxBoolItem aBoolItem ( 0, TRUE ); + + eState = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY, TRUE, + (const SfxPoolItem**)&pHorJustify ); + switch ( eState ) + { + case SFX_ITEM_SET: + { + eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() ); + + switch ( SvxCellHorJustify( pHorJustify->GetValue() ) ) + { + case SVX_HOR_JUSTIFY_STANDARD: + break; + + case SVX_HOR_JUSTIFY_LEFT: + nWhich = SID_ALIGNLEFT; + break; + + case SVX_HOR_JUSTIFY_RIGHT: + nWhich = SID_ALIGNRIGHT; + break; + + case SVX_HOR_JUSTIFY_CENTER: + nWhich = SID_ALIGNCENTERHOR; + break; + + case SVX_HOR_JUSTIFY_BLOCK: + nWhich = SID_ALIGNBLOCK; + break; + + case SVX_HOR_JUSTIFY_REPEAT: + default: + bJustifyStd = TRUE; + break; + } + } + break; + + case SFX_ITEM_DONTCARE: + rSet.InvalidateItem( SID_ALIGNLEFT ); + rSet.InvalidateItem( SID_ALIGNRIGHT ); + rSet.InvalidateItem( SID_ALIGNCENTERHOR ); + rSet.InvalidateItem( SID_ALIGNBLOCK ); + break; + + default: + bJustifyStd = TRUE; + break; + } + + if ( nWhich ) + { + aBoolItem.SetWhich( nWhich ); + rSet.Put( aBoolItem ); + } + else if ( bJustifyStd ) + { + aBoolItem.SetValue( FALSE ); + aBoolItem.SetWhich( SID_ALIGNLEFT ); rSet.Put( aBoolItem ); + aBoolItem.SetWhich( SID_ALIGNRIGHT ); rSet.Put( aBoolItem ); + aBoolItem.SetWhich( SID_ALIGNCENTERHOR ); rSet.Put( aBoolItem ); + aBoolItem.SetWhich( SID_ALIGNBLOCK ); rSet.Put( aBoolItem ); + bJustifyStd = FALSE; + } + + //------------------------ + // vertikale Ausrichtung + //------------------------ + + nWhich = 0; + aBoolItem.SetValue( TRUE ); + + eState = rAttrSet.GetItemState( ATTR_VER_JUSTIFY, TRUE, + (const SfxPoolItem**)&pVerJustify ); + + switch ( eState ) + { + case SFX_ITEM_SET: + { + eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() ); + + switch ( eVerJustify ) + { + case SVX_VER_JUSTIFY_TOP: + nWhich = SID_ALIGNTOP; + break; + + case SVX_VER_JUSTIFY_BOTTOM: + nWhich = SID_ALIGNBOTTOM; + break; + + case SVX_VER_JUSTIFY_CENTER: + nWhich = SID_ALIGNCENTERVER; + break; + + case SVX_VER_JUSTIFY_STANDARD: + default: + bJustifyStd = TRUE; + break; + } + } + break; + + case SFX_ITEM_DONTCARE: + rSet.InvalidateItem( SID_ALIGNTOP ); + rSet.InvalidateItem( SID_ALIGNBOTTOM ); + rSet.InvalidateItem( SID_ALIGNCENTERVER ); + break; + + default: + bJustifyStd = TRUE; + break; + } + + if ( nWhich ) + { + aBoolItem.SetWhich( nWhich ); + rSet.Put( aBoolItem ); + } + else if ( bJustifyStd ) + { + aBoolItem.SetValue( FALSE ); + aBoolItem.SetWhich( SID_ALIGNTOP ); rSet.Put( aBoolItem ); + aBoolItem.SetWhich( SID_ALIGNBOTTOM ); rSet.Put( aBoolItem ); + aBoolItem.SetWhich( SID_ALIGNCENTERVER ); rSet.Put( aBoolItem ); + } +} + + +//------------------------------------------------------------------ + +void ScFormatShell::GetBorderState( SfxItemSet& rSet ) +{ + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + SvxBoxItem aBoxItem( ATTR_BORDER ); + SvxBoxInfoItem aInfoItem( ATTR_BORDER_INNER ); + + pTabViewShell->GetSelectionFrame( aBoxItem, aInfoItem ); + + if ( rSet.GetItemState( ATTR_BORDER ) != SFX_ITEM_UNKNOWN ) + rSet.Put( aBoxItem ); + if ( rSet.GetItemState( ATTR_BORDER_INNER ) != SFX_ITEM_UNKNOWN ) + rSet.Put( aInfoItem ); +} + +//------------------------------------------------------------------ + +void ScFormatShell::GetAlignState( SfxItemSet& rSet ) +{ + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + SvxCellHorJustify eHorJustify = SVX_HOR_JUSTIFY_STANDARD; + SvxCellVerJustify eVerJustify = SVX_VER_JUSTIFY_STANDARD; + + + while ( nWhich ) + { + switch ( nWhich ) + { + case SID_H_ALIGNCELL: + { + if ( rAttrSet.GetItemState( ATTR_HOR_JUSTIFY ) != SFX_ITEM_DONTCARE ) + { + SvxCellHorJustify eHorJustify = (SvxCellHorJustify)((const SvxHorJustifyItem&) + rAttrSet.Get( ATTR_HOR_JUSTIFY )).GetValue(); + rSet.Put( SvxHorJustifyItem( eHorJustify, nWhich )); + } + } + break; + case SID_V_ALIGNCELL: + { + if ( rAttrSet.GetItemState( ATTR_VER_JUSTIFY ) != SFX_ITEM_DONTCARE ) + { + SvxCellVerJustify eVerJustify = (SvxCellVerJustify)((const SvxVerJustifyItem&) + rAttrSet.Get( ATTR_VER_JUSTIFY )).GetValue(); + rSet.Put( SvxVerJustifyItem( eVerJustify, nWhich )); + } + } + break; + } + nWhich = aIter.NextWhich(); + } +} + +void ScFormatShell::ExecBckCol( SfxRequest& rReq ) +{ + ExecuteAttr( rReq ); +} + +void ScFormatShell::GetBckColState( SfxItemSet& rSet ) +{ + GetAttrState( rSet ); +} +void ScFormatShell::GetNumFormatState( SfxItemSet& rSet ) +{ + ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); + BOOL bOle = pTabViewShell->GetViewFrame()->ISA(SfxInPlaceFrame); + BOOL bTabProt = GetViewData()->GetDocument()->IsTabProtected(GetViewData()->GetTabNo()); + SfxApplication* pSfxApp = SFX_APP(); + + ScViewData* pViewData = GetViewData(); + ScDocument* pDoc = pViewData->GetDocument(); + ScMarkData& rMark = pViewData->GetMarkData(); + USHORT nPosX = pViewData->GetCurX(); + USHORT nPosY = pViewData->GetCurY(); + USHORT nTab = pViewData->GetTabNo(); + USHORT nMyId = 0; + + USHORT nTabCount = pDoc->GetTableCount(); + USHORT nTabSelCount = rMark.GetSelectCount(); + + + + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + while ( nWhich ) + { + switch ( nWhich ) + { + case SID_NUMBER_FORMAT: + { + String aFormatCode; // bleibt leer, wenn dont-care + + const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); + if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) != SFX_ITEM_DONTCARE ) + { + ULONG nNumberFormat = ((const SfxUInt32Item&)rAttrSet.Get( + ATTR_VALUE_FORMAT )).GetValue(); + + SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat ); + if ( pFormatEntry ) + aFormatCode = pFormatEntry->GetFormatstring(); + } + + rSet.Put( SfxStringItem( nWhich, aFormatCode ) ); + } + break; + + } + nWhich = aIter.NextWhich(); + } +} + + + diff --git a/sc/source/ui/view/galwrap.cxx b/sc/source/ui/view/galwrap.cxx new file mode 100644 index 000000000000..2b14059826cf --- /dev/null +++ b/sc/source/ui/view/galwrap.cxx @@ -0,0 +1,114 @@ +/************************************************************************* + * + * $RCSfile: galwrap.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include <vcl/graph.hxx> +#include <svx/gallery.hxx> +#include <sfx2/app.hxx> +#include <sfx2/explorer.hxx> + +// ----------------------------------------------------------------------- + +Graphic GalleryGetGraphic() +{ + GalleryExplorer* pGal = SVX_GALLERY(); + DBG_ASSERT( pGal, "Wo ist die Gallery?" ); + return pGal->GetGraphic(); +} + +USHORT GallerySGA_FORMAT_GRAPHIC() +{ + return SGA_FORMAT_GRAPHIC; +} + +BOOL GalleryIsLinkage() +{ + GalleryExplorer* pGal = SVX_GALLERY(); + DBG_ASSERT( pGal, "Wo ist die Gallery?" ); + return pGal->IsLinkage(); +} + +String GalleryGetFullPath() +{ + GalleryExplorer* pGal = SVX_GALLERY(); + DBG_ASSERT( pGal, "Wo ist die Gallery?" ); +// return pGal->GetPath().GetFull(); + return pGal->GetURL().GetMainURL(); +} + +String GalleryGetFilterName() +{ + GalleryExplorer* pGal = SVX_GALLERY(); + DBG_ASSERT( pGal, "Wo ist die Gallery?" ); + return pGal->GetFilterName(); +} + + + + diff --git a/sc/source/ui/view/gridmerg.cxx b/sc/source/ui/view/gridmerg.cxx new file mode 100644 index 000000000000..cf065422f156 --- /dev/null +++ b/sc/source/ui/view/gridmerg.cxx @@ -0,0 +1,198 @@ +/************************************************************************* + * + * $RCSfile: gridmerg.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +#include <vcl/outdev.hxx> + +#include "gridmerg.hxx" + +//------------------------------------------------------------------ + +ScGridMerger::ScGridMerger( OutputDevice* pOutDev, long nOnePixelX, long nOnePixelY ) : + pDev( pOutDev ), + nOneX( nOnePixelX ), + nOneY( nOnePixelY ), + bVertical( FALSE ), + nCount( 0 ) +{ + // optimize (DrawGrid) only for pixel MapMode, + // to avoid rounding errors + + bOptimize = ( pDev->GetMapMode().GetMapUnit() == MAP_PIXEL ); +} + +ScGridMerger::~ScGridMerger() +{ + Flush(); +} + +void ScGridMerger::AddLine( long nStart, long nEnd, long nPos ) +{ + if ( nCount ) + { + // not first line - test fix position + // more than one previous line - test distance + + if ( nStart != nFixStart || nEnd != nFixEnd ) + { + if ( nCount == 1 && nPos == nVarStart && + ( nStart == nFixEnd || + nStart == nFixEnd + ( bVertical ? nOneY : nOneX ) ) ) + { + // additional optimization: extend connected lines + // keep nCount at 1 + nFixEnd = nEnd; + } + else + Flush(); + } + else if ( nCount == 1 ) + { + nVarDiff = nPos - nVarStart; + ++nCount; + } + else if ( nPos != nVarStart + nCount * nVarDiff ) //! keep VarEnd? + Flush(); + else + ++nCount; + } + + if ( !nCount ) + { + // first line (or flushed above) - just store + + nFixStart = nStart; + nFixEnd = nEnd; + nVarStart = nPos; + nVarDiff = 0; + nCount = 1; + } +} + +void ScGridMerger::AddHorLine( long nX1, long nX2, long nY ) +{ + if ( bOptimize ) + { + if ( bVertical ) + { + Flush(); + bVertical = FALSE; + } + AddLine( nX1, nX2, nY ); + } + else + pDev->DrawLine( Point( nX1, nY ), Point( nX2, nY ) ); +} + +void ScGridMerger::AddVerLine( long nX, long nY1, long nY2 ) +{ + if ( bOptimize ) + { + if ( !bVertical ) + { + Flush(); + bVertical = TRUE; + } + AddLine( nY1, nY2, nX ); + } + else + pDev->DrawLine( Point( nX, nY1 ), Point( nX, nY2 ) ); +} + +void ScGridMerger::Flush() +{ + if (nCount) + { + if (bVertical) + { + if ( nCount == 1 ) + pDev->DrawLine( Point( nVarStart, nFixStart ), Point( nVarStart, nFixEnd ) ); + else + { + long nVarEnd = nVarStart + ( nCount - 1 ) * nVarDiff; + pDev->DrawGrid( Rectangle( nVarStart, nFixStart, nVarEnd, nFixEnd ), + Size( nVarDiff, nFixEnd - nFixStart ), + GRID_VERTLINES ); + } + } + else + { + if ( nCount == 1 ) + pDev->DrawLine( Point( nFixStart, nVarStart ), Point( nFixEnd, nVarStart ) ); + else + { + long nVarEnd = nVarStart + ( nCount - 1 ) * nVarDiff; + pDev->DrawGrid( Rectangle( nFixStart, nVarStart, nFixEnd, nVarEnd ), + Size( nFixEnd - nFixStart, nVarDiff ), + GRID_HORZLINES ); + } + } + nCount = 0; + } +} + + + diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx new file mode 100644 index 000000000000..0d40b5551db2 --- /dev/null +++ b/sc/source/ui/view/gridwin.cxx @@ -0,0 +1,3686 @@ +/************************************************************************* + * + * $RCSfile: gridwin.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +//SV +//#define _CLIP_HXX +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _FONTDLG_HXX +#define _PRVWIN_HXX + +//svdraw.hxx +#define _SDR_NOITEMS +#define _SDR_NOTOUCH +#define _SDR_NOTRANSFORM +//#define _SDR_NOOBJECTS +//#define _SDR_NOVIEWS + + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#define ITEMID_FIELD EE_FEATURE_FIELD + +#include <svx/adjitem.hxx> +#include <svx/algitem.hxx> +#include <svx/dbexch.hrc> +#include <svx/editview.hxx> +#include <svx/editstat.hxx> +#include <svx/flditem.hxx> +#include <svx/svdetc.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/docfile.hxx> +#include <svtools/stritem.hxx> +#include <svtools/svlbox.hxx> +#include <svtools/svtabbx.hxx> +#include <svtools/urlbmk.hxx> +#include <tools/urlobj.hxx> +#include <vcl/sound.hxx> +#include <vcl/system.hxx> +#include <offmgr/app.hxx> +#include <vcl/exchange.hxx> +#include <vcl/graph.hxx> +#include <sot/formats.hxx> + +#include <svx/svdview.hxx> // fuer Command-Handler (COMMAND_INSERTTEXT) +#include <svx/outliner.hxx> // fuer Command-Handler (COMMAND_INSERTTEXT) + +#include <com/sun/star/sheet/MemberResultFlags.hpp> + +#include "gridwin.hxx" +#include "tabvwsh.hxx" +#include "docsh.hxx" +#include "viewdata.hxx" +#include "tabview.hxx" +#include "select.hxx" +#include "scmod.hxx" +#include "document.hxx" +#include "attrib.hxx" +#include "dbcolect.hxx" +#include "stlpool.hxx" +#include "printfun.hxx" +#include "cbutton.hxx" +#include "sc.hrc" +#include "globstr.hrc" +#include "editutil.hxx" +#include "scresid.hxx" +#include "inputhdl.hxx" +#include "uiitems.hxx" // Filter-Dialog - auslagern !!! +#include "filtdlg.hxx" +#include "impex.hxx" // Sylk-ID fuer CB +#include "cell.hxx" // fuer Edit-Felder +#include "patattr.hxx" +#include "notemark.hxx" +#include "rfindlst.hxx" +#include "docpool.hxx" +#include "output.hxx" +#include "docfunc.hxx" +#include "dbdocfun.hxx" +#ifdef AUTOFILTER_POPUP +#include <vcl/menu.hxx> +#endif +#include "dpobject.hxx" +#include "dpoutput.hxx" + +using namespace com::sun::star; + +#define SC_AUTOFILTER_ALL 0 +#define SC_AUTOFILTER_CUSTOM 1 +#define SC_AUTOFILTER_TOP10 2 + +// Modi fuer die FilterListBox +enum ScFilterBoxMode +{ + SC_FILTERBOX_FILTER, + SC_FILTERBOX_DATASELECT, + SC_FILTERBOX_SCENARIO +}; + +extern SfxViewShell* pScActiveViewShell; // global.cxx +extern USHORT nScClickMouseModifier; // global.cxx +extern USHORT nScFillModeMouseModifier; // global.cxx + +#define SC_FILTERLISTBOX_LINES 12 + +// STATIC DATA ----------------------------------------------------------- + +static long nFilterBoxTabs[] = + { 1, // Number of Tabs + 0 + }; + +//================================================================== + +/* + * Der Autofilter wird auf dem Mac per AutoFilterPopup realisiert. + * Die AutoFilterListBox wird trotzdem fuer die Auswahlliste gebraucht. + */ + +//================================================================== +class ScFilterListBox : public SvTabListBox +{ + ScGridWindow* pGridWin; + USHORT nCol; + USHORT nRow; + BOOL bButtonDown; + BOOL bInit; + BOOL bCancelled; + ULONG nSel; + ScFilterBoxMode eMode; + +protected: + virtual void LoseFocus(); + virtual void SelectHdl(); + +public: + ScFilterListBox( Window* pParent, ScGridWindow* pGrid, + USHORT nNewCol, USHORT nNewRow, ScFilterBoxMode eNewMode ); + ~ScFilterListBox(); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + + virtual void KeyInput( const KeyEvent& rKEvt ); + + USHORT GetCol() const { return nCol; } + USHORT GetRow() const { return nRow; } + ScFilterBoxMode GetMode() const { return eMode; } + BOOL IsDataSelect() const { return (eMode == SC_FILTERBOX_DATASELECT); } + void EndInit(); + void SetCancelled() { bCancelled = TRUE; } +}; + +//------------------------------------------------------------------- + +// ListBox in einem FloatingWindow (pParent) +ScFilterListBox::ScFilterListBox( Window* pParent, ScGridWindow* pGrid, + USHORT nNewCol, USHORT nNewRow, ScFilterBoxMode eNewMode ) : + SvTabListBox( pParent, WinBits(0) ), // ohne Border + pGridWin( pGrid ), + nCol( nNewCol ), + nRow( nNewRow ), + eMode( eNewMode ), + bButtonDown( FALSE ), + bInit( TRUE ), + bCancelled( FALSE ), + nSel( 0 ) +{ +} + +__EXPORT ScFilterListBox::~ScFilterListBox() +{ + if (IsMouseCaptured()) + ReleaseMouse(); +} + +void ScFilterListBox::EndInit() +{ + SvLBoxEntry* pEntry = FirstSelected(); + if (pEntry) + nSel = GetModel()->GetAbsPos( pEntry ); + else + nSel = 0; + + bInit = FALSE; +} + +void __EXPORT ScFilterListBox::LoseFocus() +{ +#ifndef UNX + Hide(); +#endif +} + +void __EXPORT ScFilterListBox::MouseButtonDown( const MouseEvent& rMEvt ) +{ + bButtonDown = TRUE; + SvTabListBox::MouseButtonDown( rMEvt ); +} + +void __EXPORT ScFilterListBox::MouseButtonUp( const MouseEvent& rMEvt ) +{ + bButtonDown = FALSE; + SvTabListBox::MouseButtonUp( rMEvt ); + + if (!bCancelled) + pGridWin->FilterSelect( nSel ); +} + +void __EXPORT ScFilterListBox::KeyInput( const KeyEvent& rKEvt ) +{ + KeyCode aCode = rKEvt.GetKeyCode(); + if ( !aCode.GetModifier() ) // ohne alle Modifiers + { + USHORT nKey = aCode.GetCode(); + if ( nKey == KEY_RETURN ) + { + SelectHdl(); // auswaehlen + return; + } + else if ( nKey == KEY_ESCAPE ) + { + pGridWin->ClickExtern(); // loescht die List-Box !!! + return; + } + } + + SvTabListBox::KeyInput( rKEvt ); +} + +void __EXPORT ScFilterListBox::SelectHdl() +{ + if ( !IsTravelSelect() && !bInit && !bCancelled ) + { + SvLBoxEntry* pEntry = FirstSelected(); + if (pEntry) + { + nSel = GetModel()->GetAbsPos( pEntry ); + if (!bButtonDown) + pGridWin->FilterSelect( nSel ); + } + } +} + +#ifdef AUTOFILTER_POPUP + +//================================================================== +class AutoFilterPopup : public PopupMenu +{ +public: + AutoFilterPopup( ScGridWindow* _pWin, USHORT _nCol, USHORT _nRow, BOOL bDatSel ) + : pWin( _pWin ), + nCol( _nCol ), + nRow( _nRow ), + bIsDataSelect( bDatSel ), + bSelected( FALSE ) {} + ~AutoFilterPopup(); + +protected: + virtual void Select(); + +private: + ScGridWindow* pWin; + USHORT nCol; + USHORT nRow; + BOOL bIsDataSelect; + BOOL bSelected; +}; + +//------------------------------------------------------------------- + +void __EXPORT AutoFilterPopup::Select() +{ + // Button vor dem ausfuehren wieder zeichnen + if ( !bIsDataSelect ) + { + pWin->HideCursor(); + pWin->aComboButton.Draw( FALSE ); + pWin->ShowCursor(); + } + bSelected = TRUE; + + USHORT nCurId = GetCurItemId(); + pWin->ReleaseMouse(); + String aStr = GetItemText( nCurId ); + if ( bIsDataSelect ) + pWin->ExecDataSelect( nCol, nRow, aStr ); + else + pWin->ExecFilter( nCurId-1, nCol, nRow, aStr ); +} + +AutoFilterPopup::~AutoFilterPopup() +{ + if ( !bIsDataSelect && !bSelected ) + { + pWin->HideCursor(); + pWin->aComboButton.Draw( FALSE ); + pWin->ShowCursor(); + } +} + +#endif // #ifdef AUTOFILTER_POPUP + +//================================================================== + +BOOL lcl_IsEditableMatrix( ScDocument* pDoc, const ScRange& rRange ) +{ + // wenn es ein editierbarer Bereich ist, und rechts unten eine Matrix-Zelle + // mit Origin links oben liegt, enthaelt der Bereich genau die Matrix. + //! Direkt die MatrixEdges Funktionen von der Column herausreichen ??? + + if ( !pDoc->IsBlockEditable( rRange.aStart.Tab(), rRange.aStart.Col(),rRange.aStart.Row(), + rRange.aEnd.Col(),rRange.aEnd.Row() ) ) + return FALSE; + + ScAddress aPos; + const ScBaseCell* pCell = pDoc->GetCell( rRange.aEnd ); + return ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA && + ((ScFormulaCell*)pCell)->GetMatrixOrigin(aPos) && aPos == rRange.aStart ); +} + +//================================================================== + +// WB_DIALOGCONTROL noetig fuer UNO-Controls +ScGridWindow::ScGridWindow( Window* pParent, ScViewData* pData, ScSplitPos eWhichPos ) : + Window( pParent, WB_CLIPCHILDREN | WB_DIALOGCONTROL ), + pViewData( pData ), + eWhich( eWhichPos ), + pNoteMarker( NULL ), + nCursorHideCount( 0 ), + bMarking( FALSE ), + bEEMouse( FALSE ), + nButtonDown( 0 ), + nMouseStatus( SC_GM_NONE ), + bPivotMouse( FALSE ), + bDPMouse( FALSE ), + bRFMouse( FALSE ), + nPagebreakMouse( SC_PD_NONE ), + bDragRect( FALSE ), + pFilterBox( NULL ), + pFilterFloat( NULL ), + nCurrentPointer( 0 ), + bIsInScroll( FALSE ), + bIsInPaint( FALSE ), + aComboButton( this ), + aCurMousePos( 0,0 ), + nPaintCount( 0 ), + bNeedsRepaint( FALSE ), + bAutoMarkVisible( FALSE ) +{ + switch(eWhich) + { + case SC_SPLIT_TOPLEFT: + eHWhich = SC_SPLIT_LEFT; + eVWhich = SC_SPLIT_TOP; + break; + case SC_SPLIT_TOPRIGHT: + eHWhich = SC_SPLIT_RIGHT; + eVWhich = SC_SPLIT_TOP; + break; + case SC_SPLIT_BOTTOMLEFT: + eHWhich = SC_SPLIT_LEFT; + eVWhich = SC_SPLIT_BOTTOM; + break; + case SC_SPLIT_BOTTOMRIGHT: + eHWhich = SC_SPLIT_RIGHT; + eVWhich = SC_SPLIT_BOTTOM; + break; + default: + DBG_ERROR("GridWindow: falsche Position"); + } + + SetBackground(); + + SetMapMode(pViewData->GetLogicMode(eWhich)); + EnableDrop(); + EnableChildTransparentMode(); + SetDialogControlFlags( WINDOW_DLGCTRL_RETURN | WINDOW_DLGCTRL_WANTFOCUS ); + + SetHelpId( HID_SC_WIN_GRIDWIN ); + SetUniqueId( HID_SC_WIN_GRIDWIN ); +} + +__EXPORT ScGridWindow::~ScGridWindow() +{ + delete pFilterBox; + if (pFilterFloat) + pFilterFloat->EndPopupMode(); + delete pFilterFloat; + delete pNoteMarker; +} + +void __EXPORT ScGridWindow::Resize( const Size& rSize ) +{ + // gar nix +} + +void ScGridWindow::ClickExtern() +{ + DELETEZ(pFilterBox); + if (pFilterFloat) + pFilterFloat->EndPopupMode(); + DELETEZ(pFilterFloat); +} + +IMPL_LINK( ScGridWindow, PopupModeEndHdl, FloatingWindow*, pFloat ) +{ + if (pFilterBox) + pFilterBox->SetCancelled(); // nicht mehr auswaehlen + GrabFocus(); + return 0; +} + +void ScGridWindow::DoScenarioMenue( const ScRange& rScenRange ) +{ + delete pFilterBox; + if (pFilterFloat) + pFilterFloat->EndPopupMode(); + delete pFilterFloat; + + USHORT nCol = rScenRange.aEnd.Col(); // Zelle unterhalb des Buttons + USHORT nRow = rScenRange.aStart.Row(); + if (nRow == 0) + { + nRow = rScenRange.aEnd.Row() + 1; // Bereich ganz oben -> Button unterhalb + if (nRow>MAXROW) nRow = MAXROW; + //! Texthoehe addieren (wenn sie an der View gespeichert ist...) + } + + USHORT i; + ScDocument* pDoc = pViewData->GetDocument(); + USHORT nTab = pViewData->GetTabNo(); + long nSizeX = 0; + long nSizeY = 0; + long nHeight = 0; + pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY ); + Point aPos = pViewData->GetScrPos( nCol, nRow, eWhich ); + Rectangle aCellRect( OutputToScreenPixel(aPos), Size(nSizeX,nSizeY) ); + aCellRect.Top() -= nSizeY; + aCellRect.Bottom() -= nSizeY - 1; + // Die ListBox direkt unter der schwarzen Linie auf dem Zellgitter + // (wenn die Linie verdeckt wird, sieht es komisch aus...) + + pFilterFloat = new FloatingWindow( this, WinBits(WB_BORDER) ); // nicht resizable etc. + pFilterFloat->SetPopupModeEndHdl( LINK( this, ScGridWindow, PopupModeEndHdl ) ); + pFilterBox = new ScFilterListBox( pFilterFloat, this, nCol, nRow, SC_FILTERBOX_SCENARIO ); + + nSizeX += 1; + + { + Font aOldFont = GetFont(); SetFont( pFilterBox->GetFont() ); + MapMode aOldMode = GetMapMode(); SetMapMode( MAP_PIXEL ); + + nHeight = GetTextHeight(); + nHeight *= SC_FILTERLISTBOX_LINES; + + SetMapMode( aOldMode ); + SetFont( aOldFont ); + } + + // SetSize spaeter + pFilterBox->SetSelectionMode( SINGLE_SELECTION ); + pFilterBox->SetTabs( nFilterBoxTabs, MapUnit( MAP_APPFONT )); + + + // ParentSize Abfrage fehlt + + Size aSize( nSizeX, nHeight ); + pFilterBox->SetSizePixel( aSize ); + pFilterBox->Show(); // Show muss vor SetUpdateMode kommen !!! + pFilterBox->SetUpdateMode(FALSE); + + // SetOutputSizePixel/StartPopupMode erst unten, wenn die Groesse feststeht + + // Listbox fuellen + + long nMaxText = 0; + String aCurrent; + String aTabName; + USHORT nTabCount = pDoc->GetTableCount(); + USHORT nEntryCount = 0; + for (i=nTab+1; i<nTabCount && pDoc->IsScenario(i); i++) + { + if (pDoc->HasScenarioRange( i, rScenRange )) + if (pDoc->GetName( i, aTabName )) + { + pFilterBox->InsertEntry( aTabName ); + if (pDoc->IsActiveScenario(i)) + aCurrent = aTabName; + long nTextWidth = pFilterBox->GetTextWidth( aTabName ); + if ( nTextWidth > nMaxText ) + nMaxText = nTextWidth; + ++nEntryCount; + } + } + if (nEntryCount > SC_FILTERLISTBOX_LINES) + nMaxText += GetSettings().GetStyleSettings().GetScrollBarSize(); + nMaxText += 4; // fuer Rand + if ( nMaxText > 300 ) + nMaxText = 300; // auch nicht uebertreiben (Pixel) + + if (nMaxText > nSizeX) // Groesse auf benoetigte Groesse anpassen + { + long nDiff = nMaxText - nSizeX; + aSize = Size( nMaxText, nHeight ); + pFilterBox->SetSizePixel( aSize ); + pFilterFloat->SetOutputSizePixel( aSize ); + + // auch Startposition verschieben + long nNewX = aCellRect.Left() - nDiff; + if ( nNewX < 0 ) + nNewX = 0; + aCellRect.Left() = nNewX; + } + + pFilterFloat->SetOutputSizePixel( aSize ); + pFilterFloat->StartPopupMode( aCellRect, FLOATWIN_POPUPMODE_DOWN ); + + pFilterBox->SetUpdateMode(TRUE); + pFilterBox->GrabFocus(); + + // Select erst nach GrabFocus, damit das Focus-Rechteck richtig landet + SvLBoxEntry* pSelect = NULL; + if (aCurrent.Len()) + { + ULONG nPos = pFilterBox->GetEntryPos( aCurrent ); + pSelect = pFilterBox->GetEntry( nPos ); + } + if (!pSelect) + pSelect = pFilterBox->GetEntry(0); // einer sollte immer selektiert sein + if (pSelect) + pFilterBox->Select(pSelect); + + pFilterBox->EndInit(); + + // Szenario-Auswahl kommt aus MouseButtonDown: + // der naechste MouseMove auf die Filterbox ist wie ein ButtonDown + + nMouseStatus = SC_GM_FILTER; + CaptureMouse(); +} + +void ScGridWindow::DoAutoFilterMenue( USHORT nCol, USHORT nRow, BOOL bDataSelect ) +{ + // bei AUTOFILTER_POPUP-define fuer AutoFilter das Popup nehmen +#ifdef AUTOFILTER_POPUP + if ( !bDataSelect ) + { + DoAutoFilterPopup( nCol, nRow, bDataSelect ); + return; + } +#endif + + /* + * Standard-Variante mit TreeListBox + */ + + delete pFilterBox; + if (pFilterFloat) + pFilterFloat->EndPopupMode(); + delete pFilterFloat; + + USHORT i; + ScDocument* pDoc = pViewData->GetDocument(); + USHORT nTab = pViewData->GetTabNo(); + long nSizeX = 0; + long nSizeY = 0; + long nHeight = 0; + pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY ); + Point aPos = pViewData->GetScrPos( nCol, nRow, eWhich ); + + Rectangle aCellRect( OutputToScreenPixel(aPos), Size(nSizeX,nSizeY) ); + + aPos.X() -= 1; + aPos.Y() += nSizeY - 1; + + pFilterFloat = new FloatingWindow( this, WinBits(WB_BORDER) ); // nicht resizable etc. + pFilterFloat->SetPopupModeEndHdl( LINK( this, ScGridWindow, PopupModeEndHdl ) ); + pFilterBox = new ScFilterListBox( pFilterFloat, this, nCol, nRow, + bDataSelect ? SC_FILTERBOX_DATASELECT : SC_FILTERBOX_FILTER ); + + nSizeX += 1; + + { + Font aOldFont = GetFont(); SetFont( pFilterBox->GetFont() ); + MapMode aOldMode = GetMapMode(); SetMapMode( MAP_PIXEL ); + + nHeight = GetTextHeight(); + nHeight *= SC_FILTERLISTBOX_LINES; + + SetMapMode( aOldMode ); + SetFont( aOldFont ); + } + + // SetSize spaeter + pFilterBox->SetSelectionMode( SINGLE_SELECTION ); + pFilterBox->SetTabs( nFilterBoxTabs, MapUnit( MAP_APPFONT )); + + BOOL bEmpty = FALSE; + TypedStrCollection aStrings( 128, 128 ); + if ( bDataSelect ) // Auswahl-Liste + { + // Liste fuellen + aStrings.SetCaseSensitive( TRUE ); + pDoc->GetDataEntries( nCol, nRow, nTab, aStrings ); + if ( aStrings.GetCount() == 0 ) + bEmpty = TRUE; + } + else // AutoFilter + { + //! wird der Titel ueberhaupt ausgewertet ??? + String aString; + pDoc->GetString( nCol, nRow, nTab, aString ); + pFilterBox->SetText( aString ); + + // Standard-Eintraege + pFilterBox->InsertEntry( String( ScResId( SCSTR_ALL ) ) ); + pFilterBox->InsertEntry( String( ScResId( SCSTR_STDFILTER ) ) ); + pFilterBox->InsertEntry( String( ScResId( SCSTR_TOP10FILTER ) ) ); + + // Liste fuellen + pDoc->GetFilterEntries( nCol, nRow, nTab, aStrings ); + } + + if (!bEmpty) + { + // Position und Groesse an Fenster anpassen + //! vorher Abfrage, ob die Eintraege hineinpassen (Breite) + + Size aParentSize = GetParent()->GetOutputSizePixel(); + Size aSize( nSizeX, nHeight ); + + if ( aSize.Height() > aParentSize.Height() ) + aSize.Height() = aParentSize.Height(); + if ( aPos.Y() + aSize.Height() > aParentSize.Height() ) + aPos.Y() = aParentSize.Height() - aSize.Height(); + + pFilterBox->SetSizePixel( aSize ); + pFilterBox->Show(); // Show muss vor SetUpdateMode kommen !!! + pFilterBox->SetUpdateMode(FALSE); + + pFilterFloat->SetOutputSizePixel( aSize ); + pFilterFloat->StartPopupMode( aCellRect, FLOATWIN_POPUPMODE_DOWN ); + + // Listbox fuellen + USHORT nCount = aStrings.GetCount(); + BOOL bWait = ( nCount > 100 ); + + if (bWait) + EnterWait(); + + for (i=0; i<nCount; i++) + pFilterBox->InsertEntry( aStrings[i]->GetString() ); + + if (bWait) + LeaveWait(); + + pFilterBox->SetUpdateMode(TRUE); + } + + SvLBoxEntry* pSelect = NULL; + + if (!bDataSelect) // AutoFilter: aktiven Eintrag selektieren + { + ScDBData* pDBData = pDoc->GetDBAtCursor( nCol, nRow, nTab ); + if (pDBData) + { + ScQueryParam aParam; + pDBData->GetQueryParam( aParam ); // kann nur MAXQUERY Eintraege ergeben + + BOOL bValid = TRUE; + for (i=0; i<MAXQUERY && bValid; i++) // bisherige Filter-Einstellungen + if (aParam.GetEntry(i).bDoQuery) + { + //! Abfrage mit DrawButtons zusammenfassen! + + ScQueryEntry& rEntry = aParam.GetEntry(i); + if (i>0) + if (rEntry.eConnect != SC_AND) + bValid = FALSE; + if (rEntry.nField == nCol) + { + if (rEntry.eOp == SC_EQUAL) + { + String* pStr = rEntry.pStr; + if (pStr) + { + ULONG nPos = pFilterBox->GetEntryPos( *pStr ); + pSelect = pFilterBox->GetEntry( nPos ); + } + } + else if (rEntry.eOp == SC_TOPVAL && rEntry.pStr && + rEntry.pStr->EqualsAscii("10")) + pSelect = pFilterBox->GetEntry( SC_AUTOFILTER_TOP10 ); + else + pSelect = pFilterBox->GetEntry( SC_AUTOFILTER_CUSTOM ); + } + } + + if (!bValid) + pSelect = pFilterBox->GetEntry( SC_AUTOFILTER_CUSTOM ); + } + } + + // neu (309): irgendwas muss immer selektiert sein: + if (!pSelect) + pSelect = pFilterBox->GetEntry(0); + + // keine leere Auswahl-Liste anzeigen: + + if ( bEmpty ) + { + DELETEZ(pFilterBox); // war nix + if (pFilterFloat) + pFilterFloat->EndPopupMode(); + DELETEZ(pFilterFloat); + Sound::Beep(); // bemerkbar machen + } + else + { +// pFilterBox->Show(); // schon vorne + pFilterBox->GrabFocus(); + + // Select erst nach GrabFocus, damit das Focus-Rechteck richtig landet + if (pSelect) + pFilterBox->Select(pSelect); + + pFilterBox->EndInit(); + + if (!bDataSelect) + { + // AutoFilter (aus MouseButtonDown): + // der naechste MouseMove auf die Filterbox ist wie ein ButtonDown + + nMouseStatus = SC_GM_FILTER; + CaptureMouse(); + } + } +} + +#ifdef AUTOFILTER_POPUP + + /* + * Macintosh-Variante mit Popup-Menue + */ + +void ScGridWindow::DoAutoFilterPopup( USHORT nCol, USHORT nRow, BOOL bDataSelect ) +{ + AutoFilterPopup* pPopupMenu = new AutoFilterPopup( this, nCol, nRow, bDataSelect ); + ScDocument* pDoc = pViewData->GetDocument(); + USHORT nTab = pViewData->GetTabNo(); + Point aPos = pViewData->GetScrPos( nCol, nRow, eWhich ); + BOOL bValid = TRUE; + String aStrSelect; + USHORT nSelPos = 0; + + TypedStrCollection aStrings( 128, 128 ); + USHORT nFirst = 1; + if ( bDataSelect ) // Auswahl-Liste + { + // Liste fuellen + aStrings.SetCaseSensitive( TRUE ); + pDoc->GetDataEntries( nCol, nRow, nTab, aStrings ); + + // nichts selektieren + bValid = FALSE; + } + else // AutoFilter + { + // Standard-Eintraege + pPopupMenu->InsertItem( 1, String( ScResId(SCSTR_ALL) ) ); + pPopupMenu->InsertItem( 2, String( ScResId(SCSTR_STDFILTER) ) ); + pPopupMenu->InsertItem( 3, String( ScResId(SCSTR_TOP10FILTER) ) ); + nFirst = 4; + + // Liste fuellen + pDoc->GetFilterEntries( nCol, nRow, nTab, aStrings ); + + // aktiven Eintrag suchen + ScDBData* pDBData = pDoc->GetDBAtCursor( nCol, nRow, nTab ); + if (pDBData) + { + ScQueryParam aParam; + pDBData->GetQueryParam( aParam ); + + for (USHORT i=0; i<MAXQUERY && bValid; i++) // bisherige Filter-Einstellungen + { + ScQueryEntry& rEntry = aParam.GetEntry(i); + if (rEntry.bDoQuery) + { + if (i>0) + if (rEntry.eConnect != SC_AND) + bValid = FALSE; + if (rEntry.nField == nCol) + { + if (rEntry.eOp == SC_EQUAL) + { + String* pStr = rEntry.pStr; + if (pStr) + aStrSelect = *pStr; + } + else if (rEntry.eOp == SC_TOPVAL && rEntry.pStr && + *rEntry.pStr == "10") + nSelPos = SC_AUTOFILTER_TOP10; + else + nSelPos = SC_AUTOFILTER_CUSTOM; + } + } + } + if (!bValid) + { + aStrSelect.Erase(); + nSelPos = 0; + } + } + } + + // Menue fuellen + + USHORT nCount = aStrings.GetCount(); + for ( USHORT i=0; i<nCount; i++ ) + { + const String& rStr = aStrings[i]->GetString(); + + if ( bValid && nSelPos == 0 ) + if ( aStrSelect == rStr ) + nSelPos = i+nFirst; + + pPopupMenu->InsertItem( i+nFirst, rStr ); + } + + if ( bValid ) + { + pPopupMenu->SetDefaultItem( nSelPos ); + pPopupMenu->CheckItem( nSelPos ); + } + + // ausfuehren nur, wenn ueberhaupt was drin ist (bei Auswahl-Liste) + if ( nCount+nFirst > 1 ) + pPopupMenu->Execute( OutputToScreenPixel( aPos ) ); + else + Sound::Beep(); + + delete pPopupMenu; +} + +#endif // #ifdef AUTOFILTER_POPUP + +void ScGridWindow::FilterSelect( ULONG nSel ) +{ + String aString; + SvLBoxEntry* pEntry = pFilterBox->GetEntry( nSel ); + if (pEntry) + { + SvLBoxString* pStringEntry = (SvLBoxString*) pEntry->GetFirstItem( SV_ITEM_ID_LBOXSTRING ); + if ( pStringEntry ) + aString = pStringEntry->GetText(); + } + + USHORT nCol = pFilterBox->GetCol(); + USHORT nRow = pFilterBox->GetRow(); + switch ( pFilterBox->GetMode() ) + { + case SC_FILTERBOX_DATASELECT: + ExecDataSelect( nCol, nRow, aString ); + break; + case SC_FILTERBOX_FILTER: + ExecFilter( nSel, nCol, nRow, aString ); + break; + case SC_FILTERBOX_SCENARIO: + pViewData->GetView()->UseScenario( aString ); + break; + } + + if (pFilterFloat) + pFilterFloat->EndPopupMode(); + + GrabFocus(); // unter OS/2 stimmt der Focus sonst nicht +} + +void ScGridWindow::ExecDataSelect( USHORT nCol, USHORT nRow, const String& rStr ) +{ + USHORT nTab = pViewData->GetTabNo(); + if ( rStr.Len() ) + pViewData->GetView()->EnterData( nCol, nRow, nTab, rStr ); +} + +void ScGridWindow::ExecFilter( ULONG nSel, + USHORT nCol, USHORT nRow, + const String& aValue ) +{ + USHORT nTab = pViewData->GetTabNo(); + ScDocument* pDoc = pViewData->GetDocument(); + + ScDBData* pDBData = pDoc->GetDBAtCursor( nCol, nRow, nTab ); + if (pDBData) + { + USHORT i; + ScQueryParam aParam; + pDBData->GetQueryParam( aParam ); // kann nur MAXQUERY Eintraege ergeben + + if (SC_AUTOFILTER_CUSTOM == nSel) + { +// lcl_StartFilterDialog( pViewData, aParam, Application::GetAppWindow() ); + pViewData->GetView()->SetCursor(nCol,nRow); //! auch ueber Slot ?? + SFX_DISPATCHER().Execute( SID_FILTER, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD ); + } + else + { + BOOL bDeleteOld = FALSE; + USHORT nQueryPos = 0; + BOOL bFound = FALSE; + if (!aParam.bInplace) + bDeleteOld = TRUE; + if (aParam.bRegExp) + bDeleteOld = TRUE; + for (i=0; i<MAXQUERY && !bDeleteOld; i++) // bisherige Filter-Einstellungen + if (aParam.GetEntry(i).bDoQuery) + { + //! Abfrage mit DrawButtons zusammenfassen! + + ScQueryEntry& rEntry = aParam.GetEntry(i); + if (i>0) + if (rEntry.eConnect != SC_AND) + bDeleteOld = TRUE; + + if (rEntry.nField == nCol) + { + if (bFound) // diese Spalte zweimal? + bDeleteOld = TRUE; + nQueryPos = i; + bFound = TRUE; + } + if (!bFound) + nQueryPos = i + 1; + } + + if (bDeleteOld) + { + USHORT nEC = aParam.GetEntryCount(); + for (USHORT i=0; i<nEC; i++) + aParam.GetEntry(i).bDoQuery = FALSE; + nQueryPos = 0; + aParam.bInplace = TRUE; + aParam.bRegExp = FALSE; + } + + if ( nQueryPos < MAXQUERY || SC_AUTOFILTER_ALL == nSel ) // loeschen geht immer + { + if (nSel) + { + ScQueryEntry& rNewEntry = aParam.GetEntry(nQueryPos); + + rNewEntry.bDoQuery = TRUE; + rNewEntry.bQueryByString = TRUE; + rNewEntry.nField = nCol; + if ( nSel == SC_AUTOFILTER_TOP10 ) + { + rNewEntry.eOp = SC_TOPVAL; + *rNewEntry.pStr = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("10")); + } + else + { + rNewEntry.eOp = SC_EQUAL; + *rNewEntry.pStr = aValue; + } + if (nQueryPos > 0) + rNewEntry.eConnect = SC_AND; + } + else + { + if (bFound) + aParam.DeleteQuery(nQueryPos); + } + + pViewData->GetView()->Query( aParam, NULL, TRUE ); + pDBData->SetQueryParam( aParam ); // speichern + } + else // "Zuviele Bedingungen" + pViewData->GetView()->ErrorMessage( STR_FILTER_TOOMANY ); + } + } + else + DBG_ERROR("Wo ist der Datenbankbereich?"); +} + +void ScGridWindow::SetPointer( const Pointer& rPointer ) +{ + nCurrentPointer = 0; + Window::SetPointer( rPointer ); +} + +void ScGridWindow::MoveMouseStatus( ScGridWindow& rDestWin ) +{ + if (nButtonDown) + { + rDestWin.nButtonDown = nButtonDown; + rDestWin.nMouseStatus = nMouseStatus; + } + + if (bRFMouse) + { + rDestWin.bRFMouse = bRFMouse; + rDestWin.bRFSize = bRFSize; + rDestWin.nRFIndex = nRFIndex; + rDestWin.nRFAddX = nRFAddX; + rDestWin.nRFAddY = nRFAddY; + bRFMouse = FALSE; + } + + if (nPagebreakMouse) + { + rDestWin.nPagebreakMouse = nPagebreakMouse; + rDestWin.nPagebreakBreak = nPagebreakBreak; + rDestWin.nPagebreakPrev = nPagebreakPrev; + rDestWin.aPagebreakSource = aPagebreakSource; + rDestWin.aPagebreakDrag = aPagebreakDrag; + nPagebreakMouse = SC_PD_NONE; + } +} + +BOOL ScGridWindow::TestMouse( const MouseEvent& rMEvt, BOOL bAction ) +{ + // MouseEvent buttons must only be checked if bAction==TRUE + // to allow changing the mouse pointer in MouseMove, + // but not start AutoFill with right button (#74229#). + // with bAction==TRUE, SetFillMode / SetDragMode is called + + if ( bAction && !rMEvt.IsLeft() ) + return FALSE; + + BOOL bNewPointer = FALSE; + + if (pViewData->IsActive()) + { + // Auto-Fill + + ScRange aMarkRange; + if (pViewData->GetSimpleArea( aMarkRange, FALSE )) + { + if ( aMarkRange.aStart.Tab() == pViewData->GetTabNo() ) + { + // Block-Ende wie in DrawAutoFillMark + USHORT nX = aMarkRange.aEnd.Col(); + USHORT nY = aMarkRange.aEnd.Row(); + + Point aFillPos = pViewData->GetScrPos( nX, nY, eWhich, TRUE ); + long nSizeXPix; + long nSizeYPix; + pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix ); + aFillPos.X() += nSizeXPix; + aFillPos.Y() += nSizeYPix; + + Point aMousePos = rMEvt.GetPosPixel(); + // Abfrage hier passend zu DrawAutoFillMark + // (ein Pixel mehr als markiert) + if ( aMousePos.X() >= aFillPos.X()-3 && aMousePos.X() <= aFillPos.X()+4 && + aMousePos.Y() >= aFillPos.Y()-3 && aMousePos.Y() <= aFillPos.Y()+4 ) + { + SetPointer( Pointer( POINTER_CROSS ) ); //! dickeres Kreuz ? + if (bAction) + { + if ( lcl_IsEditableMatrix( pViewData->GetDocument(), aMarkRange ) ) + pViewData->SetDragMode( + aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), nX, nY, SC_FILL_MATRIX ); + else + pViewData->SetFillMode( + aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), nX, nY ); + } + bNewPointer = TRUE; + } + } + } + + // Embedded-Rechteck + + ScDocument* pDoc = pViewData->GetDocument(); + if (pDoc->IsEmbedded()) + { + ScTripel aStart; + ScTripel aEnd; + pDoc->GetEmbedded( aStart, aEnd ); + if ( pViewData->GetTabNo() == aStart.GetTab() ) + { + Point aStartPos = pViewData->GetScrPos( aStart.GetCol(), aStart.GetRow(), eWhich ); + Point aEndPos = pViewData->GetScrPos( aEnd.GetCol()+1, aEnd.GetRow()+1, eWhich ); + Point aMousePos = rMEvt.GetPosPixel(); + BOOL bTop = ( aMousePos.X() >= aStartPos.X()-3 && aMousePos.X() <= aStartPos.X()+1 && + aMousePos.Y() >= aStartPos.Y()-3 && aMousePos.Y() <= aStartPos.Y()+1 ); + BOOL bBottom = ( aMousePos.X() >= aEndPos.X()-3 && aMousePos.X() <= aEndPos.X()+1 && + aMousePos.Y() >= aEndPos.Y()-3 && aMousePos.Y() <= aEndPos.Y()+1 ); + if ( bTop || bBottom ) + { + SetPointer( Pointer( POINTER_CROSS ) ); + if (bAction) + { + BYTE nMode = bTop ? SC_FILL_EMBED_LT : SC_FILL_EMBED_RB; + pViewData->SetDragMode( + aStart.GetCol(), aStart.GetRow(), + aEnd.GetCol(), aEnd.GetRow(), nMode ); + } + bNewPointer = TRUE; + } + } + } + } + + if (!bNewPointer && bAction) + { +// SetPointer( POINTER_ARROW ); // in Fu... + pViewData->ResetFillMode(); + } + + return bNewPointer; +} + +void __EXPORT ScGridWindow::MouseButtonDown( const MouseEvent& rMEvt ) +{ + aCurMousePos = rMEvt.GetPosPixel(); + + // Filter-Popup beendet sich mit eigenem Mausklick, nicht erst beim Klick + // in das GridWindow, darum ist die folgende Abfrage nicht mehr noetig: +#if 0 + // merken, dass FilterBox geloescht wird, damit sichergestellt + // ist, dass in diesem Handler nicht an gleicher Stelle wieder + // eine neue geoeffnet wird. + BOOL bWasFilterBox = ( pFilterBox != NULL && + ((Window*)pFilterBox)->IsVisible() && + !pFilterBox->IsDataSelect() ); + USHORT nOldColFBox = bWasFilterBox ? pFilterBox->GetCol() : 0; + USHORT nOldRowFBox = bWasFilterBox ? pFilterBox->GetRow() : 0; +#endif + + ClickExtern(); // loescht FilterBox, wenn vorhanden + + HideNoteMarker(); // Notiz-Anzeige + + bEEMouse = FALSE; + + ScModule* pScMod = SC_MOD(); + if (pScMod->IsModalMode(pViewData->GetSfxDocShell())) + { + Sound::Beep(); + return; + } + + pScActiveViewShell = pViewData->GetViewShell(); // falls auf Link geklickt wird + nScClickMouseModifier = rMEvt.GetModifier(); // um Control-Klick immer zu erkennen + + BOOL bDetective = pViewData->GetViewShell()->IsAuditShell(); + BOOL bRefMode = pViewData->IsRefMode(); // Referenz angefangen + BOOL bFormulaMode = pScMod->IsFormulaMode(); // naechster Klick -> Referenz + BOOL bEditMode = pViewData->HasEditView(eWhich); // auch bei Mode==SC_INPUT_TYPE + + // DeactivateIP passiert nur noch bei MarkListHasChanged + + // im GrabFocus Aufruf kann eine Fehlermeldung hochkommen + // (z.B. beim Umbenennen von Tabellen per Tab-Reiter) + + if (!nButtonDown) + nButtonDown = rMEvt.GetButtons(); // vorher, damit StopMarking klappt + +// pViewData->GetViewShell()->GetViewFrame()->GetWindow().GrabFocus(); + if (bEditMode || !bFormulaMode) + GrabFocus(); + + if ( nMouseStatus == SC_GM_IGNORE ) + { + nButtonDown = 0; + nMouseStatus = SC_GM_NONE; + return; + } + + if ( bDetective ) // Detektiv-Fuell-Modus + { + if ( rMEvt.IsLeft() && !rMEvt.GetModifier() ) + { + Point aPos = rMEvt.GetPosPixel(); + short nPosX; + short nPosY; + pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); + + SfxInt16Item aPosXItem( SID_RANGE_COL, nPosX ); + SfxInt16Item aPosYItem( SID_RANGE_ROW, nPosY ); + SFX_DISPATCHER().Execute( SID_FILL_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, + &aPosXItem, &aPosYItem, (void*)0L ); + + } + nButtonDown = 0; + nMouseStatus = SC_GM_NONE; + return; + } + + BOOL bDouble = (rMEvt.GetClicks() == 2); + if (!bDouble) + nMouseStatus = SC_GM_NONE; + + if (!bFormulaMode) + { + if ( pViewData->GetActivePart() != eWhich ) + pViewData->GetView()->ActivatePart( eWhich ); + } + else + { + ScViewSelectionEngine* pSelEng = pViewData->GetView()->GetSelEngine(); + pSelEng->SetWindow(this); + pSelEng->SetWhich(eWhich); + pSelEng->SetVisibleArea( Rectangle(Point(), GetOutputSizePixel()) ); + } + + if (bEditMode && (pViewData->GetRefTabNo() == pViewData->GetTabNo())) + { + Point aPos = rMEvt.GetPosPixel(); + short nPosX; + short nPosY; + pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); + + EditView* pEditView; + USHORT nEditCol; + USHORT nEditRow; + pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow ); + USHORT nEndCol = pViewData->GetEditEndCol(); + USHORT nEndRow = pViewData->GetEditEndRow(); + + if ( nPosX >= (short) nEditCol && nPosX <= (short) nEndCol && + nPosY >= (short) nEditRow && nPosY <= (short) nEndRow ) + { + // #53966# beim Klick in die Tabellen-EditView immer den Focus umsetzen + if (bFormulaMode) // sonst ist es oben schon passiert + GrabFocus(); + + pScMod->SetInputMode( SC_INPUT_TABLE ); + bEEMouse = TRUE; + bEditMode = pEditView->MouseButtonDown( rMEvt ); + return; + } + } + + if (pScMod->GetIsWaterCan()) + { + //! was is mit'm Mac ??? + if ( rMEvt.GetModifier() + rMEvt.GetButtons() == MOUSE_RIGHT ) + { + nMouseStatus = SC_GM_WATERUNDO; + return; + } + } + + // Reihenfolge passend zum angezeigten Cursor: + // RangeFinder, AutoFill, PageBreak, Drawing + + if ( HitRangeFinder( rMEvt.GetPosPixel(), bRFSize, &nRFIndex, &nRFAddX, &nRFAddY ) ) + { + bRFMouse = TRUE; // die anderen Variablen sind oben initialisiert + + if ( pViewData->GetActivePart() != eWhich ) + pViewData->GetView()->ActivatePart( eWhich ); //! schon oben immer ??? + + // CaptureMouse(); + StartTracking(); + return; + } + + BOOL bAutoFill = TestMouse( rMEvt, TRUE ); + if (bAutoFill) + pScMod->InputEnterHandler(); // Autofill etc. + + if (!bAutoFill) + { + nPagebreakMouse = HitPageBreak( rMEvt.GetPosPixel(), &aPagebreakSource, + &nPagebreakBreak, &nPagebreakPrev ); + if (nPagebreakMouse) + { + bPagebreakDrawn = FALSE; + // CaptureMouse(); + StartTracking(); + PagebreakMove( rMEvt, FALSE ); + return; + } + } + + if (!bFormulaMode && !bEditMode && rMEvt.IsLeft()) + { + if ( !bAutoFill && DrawMouseButtonDown(rMEvt) ) + { + //if (DrawHasMarkedObj()) + // pViewData->GetViewShell()->SetDrawShellOrSub(); // Draw-Objekt selektiert + return; + } + + pViewData->GetViewShell()->SetDrawShell( FALSE ); // kein Draw-Objekt selektiert + + // TestMouse schon oben passiert + } + + Point aPos = rMEvt.GetPosPixel(); + short nPosX; + short nPosY; + pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); + USHORT nTab = pViewData->GetTabNo(); + ScDocument* pDoc = pViewData->GetDocument(); + + + // + // Autofilter - Knoepfe + // + + if ( !bDouble && !bFormulaMode ) //! auf rechte Taste abfragen ??? + { + ScMergeFlagAttr* pAttr = (ScMergeFlagAttr*) + pDoc->GetAttr( nPosX, nPosY, nTab, ATTR_MERGE_FLAG ); + if (pAttr->HasAutoFilter()) + { + Point aScrPos = pViewData->GetScrPos(nPosX,nPosY,eWhich); + long nSizeX; + long nSizeY; + Point aDiffPix = aPos; + + aDiffPix -= aScrPos; + pViewData->GetMergeSizePixel( nPosX, nPosY, nSizeX, nSizeY ); + + // Breite des Buttons ist nicht von der Zellhoehe abhaengig + Size aButSize = aComboButton.GetSizePixel(); + long nButWidth = Min( aButSize.Width(), nSizeX ); + long nButHeight = Min( aButSize.Height(), nSizeY ); + + if ( aDiffPix.X() >= nSizeX - nButWidth && + aDiffPix.Y() >= nSizeY - nButHeight ) + { + BOOL bFilterActive = IsAutoFilterActive( nPosX, nPosY, + pViewData->GetTabNo() ); + Color aColor( bFilterActive ? COL_LIGHTBLUE : COL_BLACK ); + + aComboButton.SetOptSizePixel(); + aComboButton.SetColor( aColor ); + DrawComboButton( aScrPos, nSizeX, nSizeY, TRUE ); + +#if 0 + if ( bWasFilterBox + && (short)nOldColFBox == nPosX + && (short)nOldRowFBox == nPosY ) + { + // Verhindern, dass an gleicher Stelle eine + // FilterBox geoeffnet wird, wenn diese gerade + // geloescht wurde + + nMouseStatus = SC_GM_FILTER; // fuer ButtonDraw im MouseButtonUp(); + return; + } +#endif + DoAutoFilterMenue( nPosX, nPosY, FALSE ); + + return; + } + } + if (pAttr->HasButton()) + { + DoPushButton( nPosX, nPosY, rMEvt ); // setzt evtl. bPivotMouse / bDPMouse + return; + } + } + + // + // Szenario-Auswahl + // + + ScRange aScenRange; + if ( HasScenarioButton( aPos, aScenRange ) ) + { + DoScenarioMenue( aScenRange ); + return; + } + + // + // Doppelklick angefangen ? + // + + // StopMarking kann aus DrawMouseButtonDown gerufen werden + + if ( nMouseStatus != SC_GM_IGNORE && !bRefMode ) + { + if (bDouble) + { + if (nMouseStatus == SC_GM_TABDOWN) + nMouseStatus = SC_GM_DBLDOWN; + } + else + nMouseStatus = SC_GM_TABDOWN; + } + + // + // Links in Edit-Zellen + // + + BOOL bAlt = rMEvt.IsMod2(); + if ( !bAlt && rMEvt.IsLeft() && + GetEditUrl(rMEvt.GetPosPixel()) ) // Klick auf Link: Cursor nicht bewegen + { + SetPointer( Pointer( POINTER_REFHAND ) ); + nMouseStatus = SC_GM_URLDOWN; // auch nur dann beim ButtonUp ausfuehren + return; + } + + // + // Gridwin - SelectionEngine + // + + if ( rMEvt.IsLeft() ) + { + ScViewSelectionEngine* pSelEng = pViewData->GetView()->GetSelEngine(); + pSelEng->SetWindow(this); + pSelEng->SetWhich(eWhich); + pSelEng->SetVisibleArea( Rectangle(Point(), GetOutputSizePixel()) ); + + // SelMouseButtonDown an der View setzt noch das bMoveIsShift Flag + if ( pViewData->GetView()->SelMouseButtonDown( rMEvt ) ) + { + if (IsMouseCaptured()) + { + // Tracking statt CaptureMouse, damit sauber abgebrochen werden kann + //! Irgendwann sollte die SelectionEngine selber StartTracking rufen!?! + ReleaseMouse(); + StartTracking(); + } + pViewData->GetMarkData().SetMarking(TRUE); + return; + } + } +} + +void __EXPORT ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt ) +{ + aCurMousePos = rMEvt.GetPosPixel(); + ScDocument* pDoc = pViewData->GetDocument(); + ScMarkData& rMark = pViewData->GetMarkData(); + + if (nButtonDown != rMEvt.GetButtons()) + nMouseStatus = SC_GM_IGNORE; // reset und return + + nButtonDown = 0; + + if (nMouseStatus == SC_GM_IGNORE) + { + nMouseStatus = SC_GM_NONE; + // Selection-Engine: Markieren abbrechen + pViewData->GetView()->GetSelEngine()->Reset(); + rMark.SetMarking(FALSE); + if (pViewData->IsAnyFillMode()) + { + pViewData->GetView()->StopRefMode(); + pViewData->ResetFillMode(); + } + StopMarking(); + DrawEndAction(); // Markieren/Verschieben auf Drawing-Layer abbrechen + ReleaseMouse(); + return; + } + + if (nMouseStatus == SC_GM_FILTER) + { + if ( pFilterBox && pFilterBox->GetMode() == SC_FILTERBOX_FILTER ) + { + HideCursor(); + aComboButton.Draw( FALSE ); + ShowCursor(); + } + nMouseStatus = SC_GM_NONE; + ReleaseMouse(); + return; // da muss nix mehr passieren + } + + ScModule* pScMod = SC_MOD(); + if (pScMod->IsModalMode(pViewData->GetSfxDocShell())) + return; + + SfxBindings& rBindings = SFX_BINDINGS(); + if (bEEMouse) + { + EditView* pEditView; + USHORT nEditCol; + USHORT nEditRow; + pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow ); + pEditView->MouseButtonUp( rMEvt ); + pScMod->InputSelection( pEditView ); // fuer Klammern etc. + pViewData->GetView()->InvalidateAttribs(); + rBindings.Invalidate( SID_HYPERLINK_GETLINK ); + bEEMouse = FALSE; + return; + } + + if (bPivotMouse) + { + PivotMouseButtonUp( rMEvt ); + bPivotMouse = FALSE; + return; + } + + if (bDPMouse) + { + DPMouseButtonUp( rMEvt ); // resets bDPMouse + return; + } + + if (bRFMouse) + { + RFMouseMove( rMEvt, TRUE ); // Range wieder richtigherum + bRFMouse = FALSE; + SetPointer( Pointer( POINTER_ARROW ) ); + ReleaseMouse(); + return; + } + + if (nPagebreakMouse) + { + PagebreakMove( rMEvt, TRUE ); + nPagebreakMouse = SC_PD_NONE; + SetPointer( Pointer( POINTER_ARROW ) ); + ReleaseMouse(); + return; + } + + if (nMouseStatus == SC_GM_WATERUNDO) // Undo im Giesskannenmodus + { + SfxUndoManager* pMgr = pViewData->GetDocShell()->GetUndoManager(); + if ( pMgr->GetUndoActionCount() && pMgr->GetUndoActionId() == STR_UNDO_APPLYCELLSTYLE ) + pMgr->Undo(); + else + Sound::Beep(); + return; + } + + if (DrawMouseButtonUp(rMEvt)) + return; + + rMark.SetMarking(FALSE); + + SetPointer( Pointer( POINTER_ARROW ) ); + + if (pViewData->IsFillMode() || + ( pViewData->GetFillMode() == SC_FILL_MATRIX && rMEvt.IsMod1() )) + { + nScFillModeMouseModifier = rMEvt.GetModifier(); + USHORT nStartCol; + USHORT nStartRow; + USHORT nEndCol; + USHORT nEndRow; + pViewData->GetFillData( nStartCol, nStartRow, nEndCol, nEndRow ); +// DBG_ASSERT( nStartCol==pViewData->GetRefStartX() && nStartRow==pViewData->GetRefStartY(), +// "Block falsch fuer AutoFill" ); + ScRange aDelRange; + BOOL bIsDel = pViewData->GetDelMark( aDelRange ); + + ScViewFunc* pView = pViewData->GetView(); + pView->StopRefMode(); + pViewData->ResetFillMode(); + + if ( bIsDel ) + { + pView->MarkRange( aDelRange, FALSE ); + pView->DeleteContents( IDF_CONTENTS ); + USHORT nTab = pViewData->GetTabNo(); + ScRange aBlockRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab ); + if ( aBlockRange != aDelRange ) + { + if ( aDelRange.aStart.Row() == nStartRow ) + aBlockRange.aEnd.SetCol( aDelRange.aStart.Col() - 1 ); + else + aBlockRange.aEnd.SetRow( aDelRange.aStart.Row() - 1 ); + pView->MarkRange( aBlockRange, FALSE ); + } + } + else + SFX_DISPATCHER().Execute( FID_FILL_AUTO, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD ); + } + else if (pViewData->GetFillMode() == SC_FILL_MATRIX) + { + USHORT nTab = pViewData->GetTabNo(); + USHORT nStartCol; + USHORT nStartRow; + USHORT nEndCol; + USHORT nEndRow; + pViewData->GetFillData( nStartCol, nStartRow, nEndCol, nEndRow ); + ScRange aBlockRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab ); + USHORT nFillCol = pViewData->GetRefEndX(); + USHORT nFillRow = pViewData->GetRefEndY(); + ScAddress aEndPos( nFillCol, nFillRow, nTab ); + + pViewData->GetView()->StopRefMode(); + pViewData->ResetFillMode(); + + if ( aEndPos != aBlockRange.aEnd ) + { + pViewData->GetDocShell()->GetDocFunc().ResizeMatrix( aBlockRange, aEndPos, FALSE ); + pViewData->GetView()->MarkRange( ScRange( aBlockRange.aStart, aEndPos ) ); + } + } + else if (pViewData->IsAnyFillMode()) + { + // Embedded-Area veraendert + pViewData->GetView()->StopRefMode(); + pViewData->ResetFillMode(); + pViewData->GetDocShell()->UpdateOle(pViewData); + } + + BOOL bRefMode = pViewData->IsRefMode(); + if (bRefMode) + pScMod->EndReference(); + + // + // Giesskannen-Modus (Gestalter) + // + + if (pScMod->GetIsWaterCan()) + { + // Abfrage auf Undo schon oben + + ScStyleSheetPool* pStylePool = (ScStyleSheetPool*) + (pViewData->GetDocument()-> + GetStyleSheetPool()); + if ( pStylePool ) + { + SfxStyleSheet* pStyleSheet = (SfxStyleSheet*) + pStylePool->GetActualStyleSheet(); + + if ( pStyleSheet ) + { + SfxStyleFamily eFamily = pStyleSheet->GetFamily(); + + switch ( eFamily ) + { + case SFX_STYLE_FAMILY_PARA: + pViewData->GetView()->SetStyleSheetToMarked( pStyleSheet ); + pViewData->GetView()->DoneBlockMode(); + break; + + case SFX_STYLE_FAMILY_PAGE: + pViewData->GetDocument()->SetPageStyle( pViewData->GetTabNo(), + pStyleSheet->GetName() ); + + ScPrintFunc( pViewData->GetDocShell(), + pViewData->GetViewShell()->GetPrinter(), + pViewData->GetTabNo() ).UpdatePages(); + + rBindings.Invalidate( SID_STATUS_PAGESTYLE ); + break; + + default: + break; + } + } + } + } + + // + // double click (only left button) + // + + BOOL bDouble = ( rMEvt.GetClicks() == 2 && rMEvt.IsLeft() ); + if ( bDouble && !bRefMode && nMouseStatus == SC_GM_DBLDOWN && !pScMod->IsRefDialogOpen() ) + { + // data pilot table + Point aPos = rMEvt.GetPosPixel(); + short nPosX, nPosY; + pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); + ScDPObject* pDPObj = pDoc->GetDPAtCursor( nPosX, nPosY, pViewData->GetTabNo() ); + if (pDPObj) + { + ScAddress aPos( nPosX, nPosY, pViewData->GetTabNo() ); + ScDPPositionData aData; + pDPObj->GetPositionData( aData, aPos ); + + if ( ( aData.nFlags & sheet::MemberResultFlags::HASMEMBER ) && + ! ( aData.nFlags & sheet::MemberResultFlags::SUBTOTAL ) ) + { + ScDPObject aNewObj( *pDPObj ); + pDPObj->ToggleDetails( aData, &aNewObj ); + ScDBDocFunc aFunc( *pViewData->GetDocShell() ); + aFunc.DataPilotUpdate( pDPObj, &aNewObj, TRUE, FALSE ); + pViewData->GetView()->CursorPosChanged(); // shells may be switched + } + else + Sound::Beep(); // nothing to expand/collapse + + return; + } + + // edit cell contents + pViewData->GetViewShell()->UpdateInputHandler(); + pScMod->SetInputMode( SC_INPUT_TABLE ); + if (pViewData->HasEditView(eWhich)) + { + // Text-Cursor gleich an die geklickte Stelle setzen + EditView* pEditView = pViewData->GetEditView( eWhich ); + MouseEvent aEditEvt( rMEvt.GetPosPixel(), 1, MOUSE_SYNTHETIC, MOUSE_LEFT, 0 ); + pEditView->MouseButtonDown( aEditEvt ); + pEditView->MouseButtonUp( aEditEvt ); + } + } + + // + // Links in Edit-Zellen + // + + BOOL bAlt = rMEvt.IsMod2(); + if ( !bAlt && !bRefMode && !bDouble && nMouseStatus == SC_GM_URLDOWN ) + { + // beim ButtonUp nur ausfuehren, wenn ButtonDown auch ueber einer URL war + + String aName, aUrl, aTarget; + if ( GetEditUrl( rMEvt.GetPosPixel(), &aName, &aUrl, &aTarget ) ) + { + nMouseStatus = SC_GM_NONE; // keinen Doppelklick anfangen + ScGlobal::OpenURL( aUrl, aTarget ); + return; + } + } + + // + // Gridwin - SelectionEngine + // + + if ( pViewData->GetView()->GetSelEngine()->SelMouseButtonUp( rMEvt ) ) + { +// rMark.MarkToSimple(); + pViewData->GetView()->UpdateAutoFillMark(); + + SfxDispatcher* pDisp = pViewData->GetViewShell()->GetDispatcher(); + BOOL bRefMode = pScMod->IsFormulaMode(); + DBG_ASSERT( pDisp || bRefMode, "Cursor auf nicht aktiver View bewegen ?" ); + + if ( pDisp && !bRefMode ) // noch ein Execute fuer Basic + { + String aAddr; // CurrentCell + if( rMark.IsMarked() ) + { +// BOOL bKeep = rMark.IsMultiMarked(); //! wohin damit ??? + + ScRange aScRange; + rMark.GetMarkArea( aScRange ); + aScRange.Format( aAddr, SCR_ABS ); + + //! SID_MARKAREA gibts nicht mehr ??? + //! was passiert beim Markieren mit dem Cursor ??? + } + else // nur Cursor bewegen + { + ScAddress aScAddress( pViewData->GetCurX(), pViewData->GetCurY(), 0 ); + aScAddress.Format( aAddr, SCA_ABS ); + } + + SfxStringItem aPosItem( SID_CURRENTCELL, aAddr ); + pDisp->Execute( SID_CURRENTCELL, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, + &aPosItem, (void*)0L ); + + pViewData->GetView()->InvalidateAttribs(); + } + return; + } +} + +void ScGridWindow::FakeButtonUp() +{ + if ( nButtonDown ) + { + MouseEvent aEvent( aCurMousePos ); // nButtons = 0 -> ignore + MouseButtonUp( aEvent ); + } +} + +void __EXPORT ScGridWindow::MouseMove( const MouseEvent& rMEvt ) +{ + aCurMousePos = rMEvt.GetPosPixel(); + + if ( rMEvt.IsLeaveWindow() ) + HideNoteMarker(); + + ScModule* pScMod = SC_MOD(); + if (pScMod->IsModalMode(pViewData->GetSfxDocShell())) + return; + + // Ob aus dem Edit-Modus Drag&Drop gestartet wurde, bekommt man leider + // nicht anders mit: + + if (bEEMouse && nButtonDown && !rMEvt.GetButtons()) + { + bEEMouse = FALSE; + nButtonDown = 0; + nMouseStatus = SC_GM_NONE; + return; + } + + if (nMouseStatus == SC_GM_IGNORE) + return; + + if (nMouseStatus == SC_GM_WATERUNDO) // Undo im Giesskannenmodus -> nur auf Up warten + return; + + if ( pViewData->GetViewShell()->IsAuditShell() ) // Detektiv-Fuell-Modus + { + SetPointer( Pointer( POINTER_FILL ) ); + return; + } + + if (nMouseStatus == SC_GM_FILTER && pFilterBox) + { + Point aRelPos = pFilterBox->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ); + if ( Rectangle(Point(),pFilterBox->GetOutputSizePixel()).IsInside(aRelPos) ) + { + nButtonDown = 0; + nMouseStatus = SC_GM_NONE; + if ( pFilterBox->GetMode() == SC_FILTERBOX_FILTER ) + { + HideCursor(); + aComboButton.Draw( FALSE ); + ShowCursor(); + } + ReleaseMouse(); + pFilterBox->MouseButtonDown( MouseEvent( aRelPos, 1, MOUSE_SIMPLECLICK, MOUSE_LEFT ) ); + return; + } + } + + BOOL bRefMode = pViewData->IsRefMode(); // Referenz angefangen + BOOL bFormulaMode = pScMod->IsFormulaMode(); // naechster Klick -> Referenz + + if (bEEMouse) + { + EditView* pEditView; + USHORT nEditCol; + USHORT nEditRow; + pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow ); + pEditView->MouseMove( rMEvt ); + return; + } + + if (bPivotMouse) + { + PivotMouseMove( rMEvt ); + return; + } + + if (bDPMouse) + { + DPMouseMove( rMEvt ); + return; + } + + if (bRFMouse) + { + RFMouseMove( rMEvt, FALSE ); + return; + } + + if (nPagebreakMouse) + { + PagebreakMove( rMEvt, FALSE ); + return; + } + + // anderen Mauszeiger anzeigen? + + BOOL bEditMode = pViewData->HasEditView(eWhich); + + //! Testen ob RefMode-Dragging !!! + if ( bEditMode && (pViewData->GetRefTabNo() == pViewData->GetTabNo()) ) + { + Point aPos = rMEvt.GetPosPixel(); + short nPosX; + short nPosY; + pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); + + EditView* pEditView; + USHORT nEditCol; + USHORT nEditRow; + pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow ); + USHORT nEndCol = pViewData->GetEditEndCol(); + USHORT nEndRow = pViewData->GetEditEndRow(); + + if ( nPosX >= (short) nEditCol && nPosX <= (short) nEndCol && + nPosY >= (short) nEditRow && nPosY <= (short) nEndRow ) + { + // Field can only be URL field + BOOL bAlt = rMEvt.IsMod2(); + if ( !bAlt && !nButtonDown && pEditView && pEditView->GetFieldUnderMousePointer() ) + SetPointer( Pointer( POINTER_REFHAND ) ); + else + SetPointer( Pointer( POINTER_TEXT ) ); + return; + } + } + + BOOL bWater = SC_MOD()->GetIsWaterCan(); + if (bWater) + SetPointer( Pointer(POINTER_FILL) ); + + if (!bWater) + { + BOOL bCross = FALSE; + + // Range-Finder + + BOOL bCorner; + if ( HitRangeFinder( rMEvt.GetPosPixel(), bCorner ) ) + { + if (bCorner) + SetPointer( Pointer( POINTER_CROSS ) ); + else + SetPointer( Pointer( POINTER_HAND ) ); + bCross = TRUE; + } + + // Page-Break-Modus + + USHORT nBreakType; + if ( !nButtonDown && pViewData->IsPagebreakMode() && + ( nBreakType = HitPageBreak( rMEvt.GetPosPixel() ) ) ) + { + PointerStyle eNew = POINTER_ARROW; + switch ( nBreakType ) + { + case SC_PD_RANGE_L: + case SC_PD_RANGE_R: + case SC_PD_BREAK_H: + eNew = POINTER_ESIZE; + break; + case SC_PD_RANGE_T: + case SC_PD_RANGE_B: + case SC_PD_BREAK_V: + eNew = POINTER_SSIZE; + break; + case SC_PD_RANGE_TL: + case SC_PD_RANGE_BR: + eNew = POINTER_SESIZE; + break; + case SC_PD_RANGE_TR: + case SC_PD_RANGE_BL: + eNew = POINTER_NESIZE; + break; + } + SetPointer( Pointer( eNew ) ); + bCross = TRUE; + } + + // Fill-Cursor anzeigen ? + + if ( !bFormulaMode && !nButtonDown ) + if (TestMouse( rMEvt, FALSE )) + bCross = TRUE; + + if ( nButtonDown && pViewData->IsAnyFillMode() ) + { + SetPointer( Pointer( POINTER_CROSS ) ); + bCross = TRUE; + nScFillModeMouseModifier = rMEvt.GetModifier(); // ausgewertet bei AutoFill und Matrix + } + + if (!bCross) + { + BOOL bAlt = rMEvt.IsMod2(); + + if (bEditMode) // Edit-Mode muss zuerst kommen! + SetPointer( Pointer( POINTER_ARROW ) ); + else if ( !bAlt && !nButtonDown && + GetEditUrl(rMEvt.GetPosPixel()) ) + SetPointer( Pointer( POINTER_REFHAND ) ); + else if ( DrawMouseMove(rMEvt) ) // setzt Pointer um + return; + } + } + + if ( pViewData->GetView()->GetSelEngine()->SelMouseMove( rMEvt ) ) + return; +} + +void ScGridWindow::Tracking( const TrackingEvent& rTEvt ) +{ + // Weil die SelectionEngine kein Tracking kennt, die Events nur auf + // die verschiedenen MouseHandler verteilen... + + const MouseEvent& rMEvt = rTEvt.GetMouseEvent(); + + if ( rTEvt.IsTrackingCanceled() ) // alles abbrechen... + { + if (!pViewData->GetView()->IsInActivatePart()) + { + if (bPivotMouse) + bPivotMouse = FALSE; // gezeichnet wird per bDragRect + if (bDPMouse) + bDPMouse = FALSE; // gezeichnet wird per bDragRect + if (bDragRect) + { + pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich ); + bDragRect = FALSE; + } + if (bRFMouse) + { + RFMouseMove( rMEvt, TRUE ); // richtig abbrechen geht dabei nicht... + bRFMouse = FALSE; + } + if (nPagebreakMouse) + { + if (bPagebreakDrawn) + DrawDragRect( aPagebreakDrag.aStart.Col(), aPagebreakDrag.aStart.Row(), + aPagebreakDrag.aEnd.Col(), aPagebreakDrag.aEnd.Row(), FALSE ); + bPagebreakDrawn = FALSE; + nPagebreakMouse = SC_PD_NONE; + } + + SetPointer( Pointer( POINTER_ARROW ) ); + StopMarking(); + MouseButtonUp( rMEvt ); // mit Status SC_GM_IGNORE aus StopMarking + + BOOL bRefMode = pViewData->IsRefMode(); + if (bRefMode) + SC_MOD()->EndReference(); // #63148# Dialog nicht verkleinert lassen + } + } + else if ( rTEvt.IsTrackingEnded() ) + { + // MouseButtonUp immer mit passenden Buttons (z.B. wegen Testtool, #63148#) + // Schliesslich behauptet der Tracking-Event ja, dass normal beendet und nicht + // abgebrochen wurde. + + MouseEvent aUpEvt( rMEvt.GetPosPixel(), rMEvt.GetClicks(), + rMEvt.GetMode(), nButtonDown, rMEvt.GetModifier() ); + MouseButtonUp( aUpEvt ); + } + else + MouseMove( rMEvt ); +} + +void __EXPORT ScGridWindow::Command( const CommandEvent& rCEvt ) +{ + USHORT nCmd = rCEvt.GetCommand(); + ScModule* pScMod = SC_MOD(); + + if ( rCEvt.GetCommand() == COMMAND_STARTEXTTEXTINPUT || + rCEvt.GetCommand() == COMMAND_ENDEXTTEXTINPUT || + rCEvt.GetCommand() == COMMAND_EXTTEXTINPUT || + rCEvt.GetCommand() == COMMAND_EXTTEXTINPUTPOS ) + { + if (!pViewData->HasEditView( eWhich )) + { + pScMod->SetInputMode( SC_INPUT_TABLE ); + } + + ScInputHandler* pHdl = pScMod->GetInputHdl( pViewData->GetViewShell() ); + if ( pHdl && pViewData->HasEditView( eWhich ) ) + { + EditView* pEditView = pViewData->GetEditView( eWhich ); // ist dann nicht 0 + pHdl->DataChanging(); + pEditView->Command( rCEvt ); + pHdl->DataChanged(); + return; // erledigt + } + } + + if ( rCEvt.GetCommand() == COMMAND_VOICE ) + { + // Der Handler wird nur gerufen, wenn ein Text-Cursor aktiv ist, + // also muss es eine EditView oder ein editiertes Zeichenobjekt geben + + ScInputHandler* pHdl = pScMod->GetInputHdl( pViewData->GetViewShell() ); + if ( pHdl && pViewData->HasEditView( eWhich ) ) + { + EditView* pEditView = pViewData->GetEditView( eWhich ); // ist dann nicht 0 + pHdl->DataChanging(); + pEditView->Command( rCEvt ); + pHdl->DataChanged(); + return; // erledigt + } + SdrView* pSdrView = pViewData->GetView()->GetSdrView(); + if ( pSdrView ) + { + OutlinerView* pOlView = pSdrView->GetTextEditOutlinerView(); + if ( pOlView && pOlView->GetWindow() == this ) + { + pOlView->Command( rCEvt ); + return; // erledigt + } + } + Window::Command(rCEvt); // sonst soll sich die Basisklasse drum kuemmern... + return; + } + + BOOL bDisable = pScMod->IsFormulaMode() || + pScMod->IsModalMode(pViewData->GetSfxDocShell()); + if (bDisable) + return; + + if ( nCmd == COMMAND_WHEEL || nCmd == COMMAND_STARTAUTOSCROLL || nCmd == COMMAND_AUTOSCROLL ) + { + BOOL bDone = pViewData->GetView()->ScrollCommand( rCEvt, eWhich ); + if (!bDone) + Window::Command(rCEvt); + return; + } + + if ( nCmd == COMMAND_STARTDRAG && ( pFilterBox || nPagebreakMouse ) ) + return; + + if ( nCmd == COMMAND_CONTEXTMENU && !SC_MOD()->GetIsWaterCan() ) + { + if (pViewData->IsAnyFillMode()) + { + pViewData->GetView()->StopRefMode(); + pViewData->ResetFillMode(); + } + ReleaseMouse(); + StopMarking(); + + Point aPosPixel = rCEvt.GetMousePosPixel(); + BOOL bDone = FALSE; + BOOL bEdit = pViewData->HasEditView(eWhich); + if ( !bEdit ) + { + // Edit-Zelle mit Spelling-Errors ? + if ( GetEditUrlOrError( TRUE, aPosPixel ) ) + { + // GetEditUrlOrError hat den Cursor schon bewegt + + pScMod->SetInputMode( SC_INPUT_TABLE ); + bEdit = pViewData->HasEditView(eWhich); // hat's geklappt ? + + DBG_ASSERT( bEdit, "kann nicht in Edit-Modus schalten" ); + } + } + if ( bEdit ) + { + EditView* pEditView = pViewData->GetEditView( eWhich ); // ist dann nicht 0 + + // if edit mode was just started above, online spelling may be incomplete + pEditView->GetEditEngine()->CompleteOnlineSpelling(); + + if( pEditView->IsWrongSpelledWordAtPos( aPosPixel ) ) + { + // Wenn man unter OS/2 neben das Popupmenue klickt, kommt MouseButtonDown + // vor dem Ende des Menue-Execute, darum muss SetModified vorher kommen + // (Bug #40968#) + ScInputHandler* pHdl = pScMod->GetInputHdl(); + if (pHdl) + pHdl->SetModified(); + + pEditView->ExecuteSpellPopup( aPosPixel ); + + bDone = TRUE; + } + } + + if (!bDone) + { + SfxDispatcher::ExecutePopup(); + } + } + else + { + // #53414# Notiz-/Redlining-Tiphilfe wegnehmen + if ( nCmd == COMMAND_STARTDRAG ) + HideNoteMarker(); + + if (bEEMouse) + { + EditView* pEditView; + USHORT nEditCol; + USHORT nEditRow; + pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow ); + + // #63263# verhindern, dass die EditView beim View-Umschalten wegkommt + pScMod->SetInEditCommand( TRUE ); + + pEditView->Command( rCEvt ); + if ( nCmd == COMMAND_STARTDRAG ) + { + ScInputHandler* pHdl = pScMod->GetInputHdl(); + if (pHdl) + pHdl->DataChanged(); + } + + pScMod->SetInEditCommand( FALSE ); + if (!pViewData->IsActive()) // auf andere View gedroppt? + { + ScInputHandler* pHdl = pScMod->GetInputHdl( pViewData->GetViewShell() ); + if ( pHdl && pViewData->HasEditView( eWhich ) ) + { + pHdl->CancelHandler(); + ShowCursor(); // fehlt bei KillEditView + } + } + } + else + if ( !DrawCommand(rCEvt) ) + pViewData->GetView()->GetSelEngine()->Command( rCEvt ); + } +} + +void __EXPORT ScGridWindow::KeyInput(const KeyEvent& rKEvt) +{ + // wenn semi-Modeless-SfxChildWindow-Dialog oben, keine KeyInputs: + if ( !SC_MOD()->IsRefDialogOpen() && !pViewData->IsAnyFillMode() ) + { + ScTabViewShell* pViewSh = pViewData->GetViewShell(); + + if (pViewData->GetDocShell()->GetProgress()) + return; + + if (DrawKeyInput(rKEvt)) + return; + + if (!pViewData->GetView()->IsDrawSelMode() && !DrawHasMarkedObj()) // keine Eingaben im Zeichenmodus + { //! DrawShell abfragen !!! + if (pViewSh->TabKeyInput(rKEvt)) + return; + } + else + if (pViewSh->SfxViewShell::KeyInput(rKEvt)) // von SfxViewShell + return; + + KeyCode aCode = rKEvt.GetKeyCode(); + if ( aCode.GetCode() == KEY_ESCAPE && aCode.GetModifier() == 0 ) + { + pViewData->GetDocShell()->DoInPlaceActivate(FALSE); + return; + } + } + + Window::KeyInput(rKEvt); +} + +void ScGridWindow::StopMarking() +{ + DrawEndAction(); // Markieren/Verschieben auf Drawing-Layer abbrechen + + if (nButtonDown) + { + pViewData->GetMarkData().SetMarking(FALSE); + nMouseStatus = SC_GM_IGNORE; + } +} + +//-------------------------------------------------------- + +BOOL ScGridWindow::QueryDropPrivate( DropEvent& rEvt ) +{ + if (rEvt.IsLeaveWindow()) + { + if (bDragRect) + pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich ); + bDragRect = FALSE; + return TRUE; + } + + const ScDragData& rData = SC_MOD()->GetDragData(); + if ( rData.nSizeX != 0 && rData.nSizeY != 0 ) + { + Point aPos = rEvt.GetPosPixel(); + + ScDocument* pSourceDoc = rData.pDoc; + ScDocument* pThisDoc = pViewData->GetDocument(); + if (pSourceDoc == pThisDoc) + { + if ( pThisDoc->HasChartAtPoint(pViewData->GetTabNo(), PixelToLogic(aPos)) ) + { + if (bDragRect) // Rechteck loeschen + { + pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich ); + bDragRect = FALSE; + } + + //! Chart mit Rechteck markieren ? + + BOOL bOk = TRUE; + if ( rEvt.GetAction() == DROP_LINK ) + bOk = rEvt.SetAction( DROP_COPY ); // Link auf Chart geht nicht + return bOk; + } + } + else + if ( rEvt.GetAction() == DROP_MOVE ) + rEvt.SetAction( DROP_COPY ); // anderes Doc: Default=COPY + + + if ( rData.nFlags & SC_DROP_TABLE ) // ganze Tabelle ? + { + BOOL bOk = pThisDoc->IsDocEditable(); + return bOk; // keinen Rahmen zeichnen + } + + short nPosX; + short nPosY; + pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); + + short nNewDragX = nPosX-rData.nHandleX; + if (nNewDragX<0) nNewDragX=0; + if (nNewDragX+(rData.nSizeX-1) > MAXCOL) + nNewDragX = MAXCOL-(rData.nSizeX-1); + short nNewDragY = nPosY-rData.nHandleY; + if (nNewDragY<0) nNewDragY=0; + if (nNewDragY+(rData.nSizeY-1) > MAXROW) + nNewDragY = MAXROW-(rData.nSizeY-1); + + if ( nNewDragX != (short) nDragStartX || nNewDragY != (short) nDragStartY || !bDragRect ) + { + if (bDragRect) + pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich ); + + nDragStartX = nNewDragX; + nDragStartY = nNewDragY; + nDragEndX = nDragStartX+rData.nSizeX-1; + nDragEndY = nDragStartY+rData.nSizeY-1; + bDragRect = TRUE; + + pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich ); + + // Zielposition als Tip-Hilfe anzeigen +#if 0 + if (Help::IsQuickHelpEnabled()) + { + USHORT nTab = pViewData->GetTabNo(); + ScRange aRange( nDragStartX, nDragStartY, nTab, nDragEndX, nDragEndY, nTab ); + String aHelpStr; + aRange.Format( aHelpStr, SCA_VALID ); // nicht-3D + + Point aPos = Pointer::GetPosPixel(); + USHORT nAlign = QUICKHELP_BOTTOM|QUICKHELP_RIGHT; + Rectangle aRect( aPos, aPos ); + Help::ShowQuickHelp(aRect, aHelpStr, nAlign); + } +#endif + } + } + + return TRUE; +} + + // sensitiver Bereich (Pixel) +#define SCROLL_SENSITIVE 20 + +BOOL ScGridWindow::DropScroll( const Point& rMousePos ) +{ +/* doch auch auf nicht aktiven Views... + if ( !pViewData->IsActive() ) + return FALSE; +*/ + short nDx = 0; + short nDy = 0; + Size aSize = GetOutputSizePixel(); + + if (aSize.Width() > SCROLL_SENSITIVE * 3) + { + if ( rMousePos.X() < SCROLL_SENSITIVE && pViewData->GetPosX(WhichH(eWhich)) > 0 ) + nDx = -1; + if ( rMousePos.X() >= aSize.Width() - SCROLL_SENSITIVE + && pViewData->GetPosX(WhichH(eWhich)) < MAXCOL ) + nDx = 1; + } + if (aSize.Height() > SCROLL_SENSITIVE * 3) + { + if ( rMousePos.Y() < SCROLL_SENSITIVE && pViewData->GetPosY(WhichV(eWhich)) > 0 ) + nDy = -1; + if ( rMousePos.Y() >= aSize.Height() - SCROLL_SENSITIVE + && pViewData->GetPosY(WhichV(eWhich)) < MAXROW ) + nDy = 1; + } + + if ( nDx || nDy ) + { + if (bDragRect) + pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich ); + + if ( nDx ) + pViewData->GetView()->ScrollX( nDx, WhichH(eWhich) ); + if ( nDy ) + pViewData->GetView()->ScrollY( nDy, WhichV(eWhich) ); + + if (bDragRect) + pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich ); + } + + return FALSE; +} + +BOOL lcl_TestScenarioRedliningDrop( ScDocument* pDoc, const ScRange& aDragRange) +{ + // Testet, ob bei eingeschalteten RedLining, + // bei einem Drop ein Scenario betroffen ist. + + BOOL bReturn = FALSE; + USHORT nTab = aDragRange.aStart.Tab(); + USHORT nTabCount = pDoc->GetTableCount(); + + if(pDoc->GetChangeTrack()!=NULL) + { + if( pDoc->IsScenario(nTab) && pDoc->HasScenarioRange(nTab, aDragRange)) + { + bReturn = TRUE; + } + else + { + for(USHORT i=nTab+1; i<nTabCount && pDoc->IsScenario(i); i++) + { + if(pDoc->HasScenarioRange(i, aDragRange)) + { + bReturn = TRUE; + break; + } + } + } + } + return bReturn; +} + + +ScRange lcl_MakeDropRange(short nPosX, short nPosY,USHORT nTab, const ScDragData& rData) +{ + // Liefert den Range fuer einen Drop zurueck + + short nCol1 = nPosX-rData.nHandleX; + if (nCol1<0) nCol1=0; + if (nCol1+(rData.nSizeX-1) > MAXCOL) + nCol1 = MAXCOL-(rData.nSizeX-1); + short nRow1 = nPosY-rData.nHandleY; + if (nRow1<0) nRow1=0; + if (nRow1+(rData.nSizeY-1) > MAXROW) + nRow1 = MAXROW-(rData.nSizeY-1); + + USHORT nCol2 = nCol1+rData.nSizeX-1; + USHORT nRow2 = nRow1+rData.nSizeY-1; + + return ScRange(nCol1, nRow1, nTab, + nCol2, nRow2, nTab); +} + +BOOL __EXPORT ScGridWindow::QueryDrop( DropEvent& rEvt ) +{ + const ScDragData& rData = SC_MOD()->GetDragData(); + if (rEvt.IsLeaveWindow()) + { + DrawMarkDropObj( NULL ); + if (rData.pDoc) + return QueryDropPrivate( rEvt ); // internen Drop-Rahmen wegnehmen + else + return TRUE; + } + + if ( pViewData->GetDocShell()->IsReadOnly() ) + return FALSE; + + ScDocument* pDoc = pViewData->GetDocument(); + USHORT nTab = pViewData->GetTabNo(); + + short nPosX; + short nPosY; + + Point aPos = rEvt.GetPosPixel(); + pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); + + ScRange aDropRange = lcl_MakeDropRange(nPosX,nPosY,nTab,rData); + ScRange aSourceRange =lcl_MakeDropRange(rData.nStartX,rData.nStartY,nTab,rData); + + if( lcl_TestScenarioRedliningDrop(pDoc, aDropRange)|| + lcl_TestScenarioRedliningDrop(pDoc, aSourceRange)) + { + if (bDragRect) + { + bDragRect = FALSE; + pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich ); + } + return FALSE; + } + + BOOL bReturn = FALSE; + + if (rData.pDoc) + { + if ( rData.nSizeX<=MAXCOL && rData.nSizeY<=MAXROW && !rEvt.IsLeaveWindow() ) + DropScroll( rEvt.GetPosPixel() ); + bReturn = QueryDropPrivate( rEvt ); + } + else + { + if ( rData.aLinkDoc.Len() ) + { + String aThisName; + ScDocShell* pDocSh = pViewData->GetDocShell(); + if (pDocSh && pDocSh->HasName()) + aThisName = pDocSh->GetMedium()->GetName(); + + if ( rData.aLinkDoc != aThisName ) + bReturn = TRUE; + } + else if (rData.aJumpTarget.Len()) + { + // interne Bookmarks (aus Navigator) + // lokale Spruenge aus unbenanntem Dokument nur in dasselbe Dokument erlaubt + + if ( rData.pJumpLocalDoc ) + bReturn = ( rData.pJumpLocalDoc == pViewData->GetDocument() ); + else + bReturn = TRUE; + } + else + { + // wenn nicht im Dokument, dann Default = COPY + + if ( !IsMyModel(rData.pSdrView) ) // Drawing innerhalb des Doc? + if ( rEvt.IsDefaultAction() && rEvt.GetAction() == DROP_MOVE ) + rEvt.SetAction( DROP_COPY ); + + SvDataObjectRef pObject = SvDataObject::PasteDragServer(rEvt); + DropAction eAction = rEvt.GetAction(); + + ScDocument* pThisDoc = pViewData->GetDocument(); + SdrObject* pHitObj = pThisDoc->GetObjectAtPoint( + pViewData->GetTabNo(), PixelToLogic(rEvt.GetPosPixel()) ); + if ( pHitObj && eAction == DROP_LINK && !rData.pSdrModel ) + { + if ( pObject->HasFormat(SOT_FORMATSTR_ID_SVXB) + || pObject->HasFormat(FORMAT_GDIMETAFILE) + || pObject->HasFormat(FORMAT_BITMAP) ) + { + // Grafik auf Zeichenobjekt gezogen + DrawMarkDropObj( pHitObj ); + bReturn = TRUE; + } + } + if (!bReturn) + DrawMarkDropObj( NULL ); + + if ( !bReturn ) + { + switch (eAction) + { + case DROP_MOVE: + case DROP_COPY: + // einfuegen: alles und jeden + // aber FORMAT_FILE nicht als MOVE + // (sonst wuerde das File vom Beamer geloescht, #40299#) + + if(pThisDoc->GetChangeTrack()!=NULL && + pObject->HasFormat(SOT_FORMATSTR_ID_SBA_DATAEXCHANGE)) + { + bReturn=FALSE; + } + else + { + bReturn = pObject->HasFormat(SOT_FORMATSTR_ID_EMBED_SOURCE); + bReturn |=pObject->HasFormat(SOT_FORMATSTR_ID_LINK_SOURCE); + bReturn |=pObject->HasFormat(SOT_FORMATSTR_ID_EMBED_SOURCE_OLE); + bReturn |=pObject->HasFormat(SOT_FORMATSTR_ID_LINK_SOURCE_OLE); + bReturn |=ScImportExport::IsFormatSupported( pObject ); + bReturn |=pObject->HasFormat(SOT_FORMATSTR_ID_LINK); // DDE + bReturn |=pObject->HasFormat(SOT_FORMATSTR_ID_DRAWING); + bReturn |=pObject->HasFormat(SOT_FORMATSTR_ID_SVXB); + bReturn |=pObject->HasFormat(FORMAT_RTF); + bReturn |=pObject->HasFormat(FORMAT_GDIMETAFILE); + bReturn |=pObject->HasFormat(FORMAT_BITMAP); + bReturn |=( pObject->HasFormat(FORMAT_FILE) && eAction != DROP_MOVE ); + bReturn |=pObject->HasFormat( + Exchange::RegisterFormatName( + String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( + SBA_FIELDEXCHANGE_FORMAT)))); + bReturn |=pObject->HasFormat(SOT_FORMATSTR_ID_SBA_DATAEXCHANGE); + bReturn |=( INetBookmark::HasFormat(*pObject) && eAction != DROP_MOVE ); + } + break; + case DROP_LINK: + // linken: OLE und DDE, Datei weil es eine Grafik (Gallery) sein koennte + // Bookmarks, weil sie vom Internet Explorer als Link angeboten werden + bReturn = pObject->HasFormat(SOT_FORMATSTR_ID_LINK_SOURCE) + || pObject->HasFormat(SOT_FORMATSTR_ID_LINK_SOURCE_OLE) + || pObject->HasFormat(SOT_FORMATSTR_ID_LINK) + || pObject->HasFormat(FORMAT_FILE) + || INetBookmark::HasFormat(*pObject); + break; + default: + bReturn = FALSE; // hamma nich + } + } + } + + // Scrolling nur, wenn wir was damit anfangen koennen + if (bReturn) + DropScroll( rEvt.GetPosPixel() ); + } + + return bReturn; +} + +//-------------------------------------------------------- + +BOOL ScGridWindow::DropPrivate( const DropEvent& rEvt ) +{ + ScModule* pScMod = SC_MOD(); + const ScDragData& rData = pScMod->GetDragData(); + + BOOL bRet = TRUE; + ScDocument* pSourceDoc = rData.pDoc; + ScDocument* pThisDoc = pViewData->GetDocument(); + ScViewFunc* pView = pViewData->GetView(); + BOOL bIsNavi = ( rData.nFlags & SC_DROP_NAVIGATOR ) != 0; + BOOL bIsMove = ( rEvt.GetAction()==DROP_MOVE && !bIsNavi ); + BOOL bIsLink = ( rEvt.GetAction()==DROP_LINK ); + + ScRange aSource( rData.nStartX, rData.nStartY, rData.nTabNo, + rData.nStartX+rData.nSizeX-1, rData.nStartY+rData.nSizeY-1, rData.nTabNo ); + + if (bDragRect) + pView->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich ); + + if (pSourceDoc == pThisDoc) + { + if ( rData.nFlags & SC_DROP_TABLE ) // Tabelle ? + { + if ( !pThisDoc->IsDocEditable() ) + bRet = FALSE; + else + { + USHORT nSrcTab = rData.nTabNo; + USHORT nDestTab = pViewData->GetTabNo(); + pViewData->GetDocShell()->MoveTable( nSrcTab, nDestTab, !bIsMove, TRUE ); // mit Undo + pView->SetTabNo( nDestTab, TRUE ); + } + } + else // Block verschieben/kopieren + { + Point aPos = rEvt.GetPosPixel(); + String aChartName; + if (pThisDoc->HasChartAtPoint( pViewData->GetTabNo(), PixelToLogic(aPos), &aChartName )) + { + String aRangeName; + aSource.Format( aRangeName, SCR_ABS_3D, pThisDoc ); + SfxStringItem aNameItem( SID_CHART_NAME, aChartName ); + SfxStringItem aRangeItem( SID_CHART_SOURCE, aRangeName ); + USHORT nId = (rEvt.GetAction() == DROP_COPY) ? + SID_CHART_ADDSOURCE : SID_CHART_SOURCE; + SFX_DISPATCHER().Execute( nId, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, + &aRangeItem, &aNameItem, (void*) NULL ); + } + else if ( nDragStartX != rData.nStartX || nDragStartY != rData.nStartY || + rData.nTabNo != pViewData->GetTabNo() ) + { + ScAddress aDest( nDragStartX, nDragStartY, pViewData->GetTabNo() ); + if ( bIsLink ) + pView->LinkBlock( aSource, aDest ); + else + pView->MoveBlockTo( aSource, aDest, bIsMove ); + } + + pScMod->SetDragIntern(); // bei ExecuteDrag nicht loeschen + bRet = TRUE; + } + } + else // zwischen Dokumenten + { + if ( rData.nFlags & SC_DROP_TABLE ) // Tabelle kopieren ? + { + if ( !pThisDoc->IsDocEditable() ) + bRet = FALSE; + else + { + USHORT nTab = rData.nTabNo; + ScDocShell* pSrcShell = (ScDocShell*)pSourceDoc->GetDocumentShell(); +//@new 22.12.97 + USHORT nTabs[MAXTAB+1]; + + const ScMarkData& rMark = rData.aMarkData; + USHORT nTabCount = pSourceDoc->GetTableCount(); + USHORT nTabSelCount = 0; + + int i; + for(i=0;i<nTabCount;i++) + { + if(rMark.GetTableSelect(i)) + { + nTabs[nTabSelCount++]=i; + for(USHORT j=i+1;j<nTabCount;j++) + { + if((!pSourceDoc->IsVisible(j))&&(pSourceDoc->IsScenario(j))) + { + nTabs[nTabSelCount++]=j; + i=j; + } + else break; + } + } + } + +//@new 22.12.97 + pView->ImportTables( pSrcShell,nTabSelCount, nTabs, bIsLink, + pViewData->GetTabNo() ); //@ 15.12.97 + bRet = TRUE; + } + } + else + { + ScDocument* pDragDoc = new ScDocument( SCDOCMODE_CLIP ); + + if ( bIsLink ) // Dde-Link einfuegen + { + // wie PasteDDE + //! oder externe Referenzen einfuegen ??? + + SfxObjectShell* pSourceSh = pSourceDoc->GetDocumentShell(); + DBG_ASSERT(pSourceSh, "Drag-Dokument hat keine Shell"); + if (pSourceSh) + { + String aApp = Application::GetAppName(); + String aTopic = pSourceSh->GetTitle( SFX_TITLE_FULLNAME ); + String aItem; + aSource.Format( aItem, SCR_ABS_3D, pSourceDoc ); + + //! use tokens + String aFormula( '=' ); + aFormula += ScCompiler::pSymbolTableNative[SC_OPCODE_DDE]; + aFormula.AppendAscii(RTL_CONSTASCII_STRINGPARAM("(\"")); + aFormula += aApp; + aFormula.AppendAscii(RTL_CONSTASCII_STRINGPARAM("\";\"")); + aFormula += aTopic; + aFormula.AppendAscii(RTL_CONSTASCII_STRINGPARAM("\";\"")); + aFormula += aItem; + aFormula.AppendAscii(RTL_CONSTASCII_STRINGPARAM("\")")); + + pView->DoneBlockMode(); + pView->InitBlockMode( nDragStartX, nDragStartY, pViewData->GetTabNo() ); + pView->MarkCursor( nDragEndX, nDragEndY, pViewData->GetTabNo() ); + + pView->EnterMatrix( aFormula ); + pView->CursorPosChanged(); + bRet = TRUE; + } + } + else // verschieben + { + // wie CopyToClip: + //! HasSelectedBlockMatrixFragment ohne selektierte Tabelle + //! oder Teil einer Matrix nicht losdraggen + + pViewData->GetMarkData().ResetMark(); + + USHORT nEndX = rData.nStartX + rData.nSizeX - 1; + USHORT nEndY = rData.nStartY + rData.nSizeY - 1; + pSourceDoc->CopyTabToClip( rData.nStartX,rData.nStartY, nEndX,nEndY, + rData.nTabNo, pDragDoc ); + USHORT nMergeX = nEndX; + USHORT nMergeY = nEndY; + pDragDoc->ExtendMerge( rData.nStartX, rData.nStartY, nMergeX, nMergeY, rData.nTabNo, TRUE ); + + // einfuegen: + + pView->SetCursor( nDragStartX, nDragStartY ); + pView->PasteFromClip( IDF_ALL, pDragDoc ); + pViewData->GetMarkData().ResetMark(); + pView->CursorPosChanged(); + Invalidate(); + delete pDragDoc; + bRet = TRUE; + } + } + } + + bDragRect = FALSE; // bei naechstem IsLeave-QueryDrop nicht zeichnen + return bRet; +} + +extern BOOL bPasteIsDrop; //! viewfun4 -> in irgendein Headerfile !!! +extern BOOL bPasteIsMove; //! viewfun7 -> in irgendein Headerfile !!! + +BOOL __EXPORT ScGridWindow::Drop( const DropEvent& rEvt ) +{ + DrawMarkDropObj( NULL ); + + ScModule* pScMod = SC_MOD(); + const ScDragData& rData = pScMod->GetDragData(); + if (rData.pDoc) + return DropPrivate( rEvt ); + + if ( rData.aLinkDoc.Len() ) + { + // versuchen, einen Link einzufuegen + + BOOL bOk = TRUE; + String aThisName; + ScDocShell* pDocSh = pViewData->GetDocShell(); + if (pDocSh && pDocSh->HasName()) + aThisName = pDocSh->GetMedium()->GetName(); + + if ( rData.aLinkDoc == aThisName ) // Fehler - kein Link im selben Dokument + bOk = FALSE; + else + { + ScViewFunc* pView = pViewData->GetView(); + if ( rData.aLinkTable.Len() ) + pView->InsertTableLink( rData.aLinkDoc, EMPTY_STRING, EMPTY_STRING, + rData.aLinkTable ); + else if ( rData.aLinkArea.Len() ) + { + Point aPos = rEvt.GetPosPixel(); + short nPosX; + short nPosY; + pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); + pView->MoveCursorAbs( nPosX, nPosY, SC_FOLLOW_NONE, FALSE, FALSE ); + + pView->InsertAreaLink( rData.aLinkDoc, EMPTY_STRING, EMPTY_STRING, + rData.aLinkArea ); + } + else + { + DBG_ERROR("Drop mit Link: weder Tabelle noch Area"); + bOk = FALSE; + } + } + + return bOk; // nichts anderes mehr probieren + } + + Point aLogicPos = PixelToLogic(rEvt.GetPosPixel()); + + if (rData.pSdrModel) + { + bPasteIsMove = (rEvt.GetAction() == DROP_MOVE && !(rData.nFlags & SC_DROP_NAVIGATOR)); + pViewData->GetView()->PasteDraw( aLogicPos, rData.pSdrModel ); + pScMod->SetDragIntern( bPasteIsMove ); + bPasteIsMove = FALSE; + return TRUE; + } + + Point aPos = rEvt.GetPosPixel(); + short nPosX; + short nPosY; + pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); + + if (rData.aJumpTarget.Len()) + { + // interner Bookmark (aus Navigator) + // Bookmark-Clipboardformat ist in PasteDataObject + + if ( !rData.pJumpLocalDoc || rData.pJumpLocalDoc == pViewData->GetDocument() ) + { + pViewData->GetViewShell()->InsertBookmark( rData.aJumpText, rData.aJumpTarget, + nPosX, nPosY ); + return TRUE; + } + } + + SvDataObjectRef pObject = SvDataObject::PasteDragServer(rEvt); + + ScDocument* pThisDoc = pViewData->GetDocument(); + SdrObject* pHitObj = pThisDoc->GetObjectAtPoint( pViewData->GetTabNo(), PixelToLogic(aPos) ); + if ( pHitObj && rEvt.GetAction() == DROP_LINK ) + { + // auf Zeichenobjekt gezogen + // PasteOnDrawObject testet auf erlaubte Formate + if ( pViewData->GetView()->PasteOnDrawObject( pObject, pHitObj, TRUE ) ) + return TRUE; + } + + BOOL bRet = FALSE; + + bPasteIsDrop = TRUE; + if ( rEvt.GetAction() == DROP_LINK ) + bRet = pViewData->GetView()-> + LinkDataObject( pObject, nPosX, nPosY, this, &aLogicPos ); + else + bRet = pViewData->GetView()-> + PasteDataObject( pObject, nPosX, nPosY, this, &aLogicPos ); + bPasteIsDrop = FALSE; + + return bRet; +} + +//-------------------------------------------------------- + +void ScGridWindow::UpdateEditViewPos() +{ + if (pViewData->HasEditView(eWhich)) + { + EditView* pView; + USHORT nCol; + USHORT nRow; + pViewData->GetEditView( eWhich, pView, nCol, nRow ); + + // EditView verstecken? + + BOOL bHide = ( nCol<pViewData->GetPosX(eHWhich) || nRow<pViewData->GetPosY(eVWhich) ); + if ( SC_MOD()->IsFormulaMode() ) + if ( pViewData->GetTabNo() != pViewData->GetRefTabNo() ) + bHide = TRUE; + + if (bHide) + { + Rectangle aRect = pView->GetOutputArea(); + long nHeight = aRect.Bottom() - aRect.Top(); + aRect.Top() = PixelToLogic(GetOutputSizePixel(), pViewData->GetLogicMode()). + Height() * 2; + aRect.Bottom() = aRect.Top() + nHeight; + pView->SetOutputArea( aRect ); + pView->HideCursor(); + } + else + { + Rectangle aPixRect = pViewData->GetEditArea( eWhich, nCol, nRow, this ); + Point aScrPos = PixelToLogic( aPixRect.TopLeft(), pViewData->GetLogicMode() ); + + Rectangle aRect = pView->GetOutputArea(); + aRect.SetPos( aScrPos ); + pView->SetOutputArea( aRect ); + pView->ShowCursor(); + } + } +} + +void ScGridWindow::ScrollPixel( long nDifX, long nDifY ) +{ + ClickExtern(); + + bIsInScroll = TRUE; + BOOL bXor=DrawBeforeScroll(); + + SetMapMode(MAP_PIXEL); + Scroll( nDifX, nDifY, SCROLL_CHILDREN ); + SetMapMode( GetDrawMapMode() ); // verschobenen MapMode erzeugen + + UpdateEditViewPos(); + + DrawAfterScroll(bXor); + bIsInScroll = FALSE; +} + +// Formeln neu zeichnen ------------------------------------------------- + +void ScGridWindow::UpdateFormulas() +{ + if (pViewData->GetView()->IsMinimized()) + return; + + if ( nPaintCount ) + { + // nicht anfangen, verschachtelt zu painten + // (dann wuerde zumindest der MapMode nicht mehr stimmen) + + bNeedsRepaint = TRUE; // -> am Ende vom Paint nochmal Invalidate auf alles + aRepaintPixel = Rectangle(); // alles + return; + } + + USHORT nX1 = pViewData->GetPosX( eHWhich ); + USHORT nY1 = pViewData->GetPosY( eVWhich ); + USHORT nX2 = nX1 + pViewData->VisibleCellsX( eHWhich ); + USHORT nY2 = nY1 + pViewData->VisibleCellsY( eVWhich ); + + if (nX2 > MAXCOL) nX2 = MAXCOL; + if (nY2 > MAXROW) nY2 = MAXROW; + + Draw( nX1, nY1, nX2, nY2, SC_UPDATE_CHANGED ); +} + +void ScGridWindow::UpdateAutoFillMark(BOOL bMarked, const ScRange& rMarkRange) +{ + if ( bMarked != bAutoMarkVisible || ( bMarked && rMarkRange.aEnd != aAutoMarkPos ) ) + { + HideCursor(); + bAutoMarkVisible = bMarked; + if ( bMarked ) + aAutoMarkPos = rMarkRange.aEnd; + ShowCursor(); + } +} + +void ScGridWindow::HideCursor() +{ + ++nCursorHideCount; + if (nCursorHideCount==1) + { + BOOL bDrawCursor = TRUE; + BOOL bDrawAuto = TRUE; + + //! irgendwie erkennen, ob wirklich neu gepainted werden muss + //! immer flackert zu viel, weil ein Control sich immer komplett zeichnet + + if (!bIsInPaint) + { + // Controls unter dem Cursor ? + + ScMarkData& rMark = pViewData->GetMarkData(); + BOOL bMarked = ( rMark.IsMarked() || rMark.IsMultiMarked() ); + + ScDocument* pDoc = pViewData->GetDocument(); + USHORT nTab = pViewData->GetTabNo(); + USHORT nX = pViewData->GetCurX(); + USHORT nY = pViewData->GetCurY(); + + Point aScrPos = pViewData->GetScrPos( nX, nY, eWhich ); + long nSizeXPix; + long nSizeYPix; + pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix ); + aScrPos.X() -= 2; + aScrPos.Y() -= 2; + Rectangle aPixRect( aScrPos, Size( nSizeXPix+4,nSizeYPix+4 ) ); + + if ( bAutoMarkVisible && aAutoMarkPos == ScAddress(nX,nY,nTab) ) + { + aPixRect.Right() += 2; // Anfasser mit einschliessen + aPixRect.Bottom() += 2; + } + + MapMode aDrawMode = GetDrawMapMode(); + Rectangle aLogicRect = PixelToLogic( aPixRect, aDrawMode ); + + if (pDoc->HasControl( nTab, aLogicRect )) + { + Invalidate( PixelToLogic( aPixRect ) ); + if (bMarked) + pDoc->InvalidateControls( this, nTab, aLogicRect ); + + Update(); + bDrawCursor = FALSE; // nicht per XOR malen + } + + // Controls unter dem AutoFill-Anfasser ? + + if ( bAutoMarkVisible && aAutoMarkPos.Tab() == nTab ) + { + if ( aAutoMarkPos == ScAddress(nX,nY,nTab) ) + bDrawAuto = bDrawCursor; // schon erledigt + else + { + USHORT nAutoX = aAutoMarkPos.Col(); + USHORT nAutoY = aAutoMarkPos.Row(); + Point aFillPos = pViewData->GetScrPos( nAutoX, nAutoY, eWhich, TRUE ); + long nSizeXPix; + long nSizeYPix; + pViewData->GetMergeSizePixel( nAutoX, nAutoY, nSizeXPix, nSizeYPix ); + aFillPos.X() += nSizeXPix; + aFillPos.Y() += nSizeYPix; + + aFillPos.X() -= 2; + aFillPos.Y() -= 2; + Rectangle aFillRect( aFillPos, Size(6,6) ); + + Rectangle aLogicFill = PixelToLogic( aFillRect, aDrawMode ); + if (pDoc->HasControl( nTab, aLogicFill )) + { + Invalidate( PixelToLogic( aFillRect ) ); + if (bMarked) + pDoc->InvalidateControls( this, nTab, aLogicFill ); + + Update(); + bDrawAuto = FALSE; + } + } + } + } + + if (bDrawCursor) + DrawCursor(); + if (bDrawAuto) + DrawAutoFillMark(); + } +} + +void ScGridWindow::ShowCursor() +{ + if (nCursorHideCount==0) + { + DBG_ERROR("zuviel ShowCursor"); + return; + } + + --nCursorHideCount; + if (nCursorHideCount==0) + { + DrawAutoFillMark(); + DrawCursor(); + } +} + +void __EXPORT ScGridWindow::GetFocus() +{ + ScTabViewShell* pViewShell = pViewData->GetViewShell(); + pViewShell->GotFocus(); + + if ( !SC_MOD()->IsFormulaMode() ) + { + pViewShell->UpdateInputHandler(); +// StopMarking(); // falls Dialog (Fehler), weil dann kein ButtonUp + // MO: nur wenn nicht im RefInput-Modus + // -> GetFocus/MouseButtonDown-Reihenfolge + // auf dem Mac + } + + Window::GetFocus(); +} + +void __EXPORT ScGridWindow::LoseFocus() +{ + pViewData->GetViewShell()->LostFocus(); + + Window::LoseFocus(); +} + +Point ScGridWindow::GetMousePosPixel() const { return aCurMousePos; } + +//------------------------------------------------------------------------ + +BOOL ScGridWindow::HitRangeFinder( const Point& rMouse, BOOL& rCorner, + USHORT* pIndex, short* pAddX, short* pAddY ) +{ + BOOL bFound = FALSE; + ScInputHandler* pHdl = SC_MOD()->GetInputHdl( pViewData->GetViewShell() ); + if (pHdl) + { + ScRangeFindList* pRangeFinder = pHdl->GetRangeFindList(); + if ( pRangeFinder && !pRangeFinder->IsHidden() && + pRangeFinder->GetDocName() == pViewData->GetDocShell()->GetTitle() ) + { + short nPosX, nPosY; + pViewData->GetPosFromPixel( rMouse.X(), rMouse.Y(), eWhich, nPosX, nPosY ); + // zusammengefasste (einzeln/Bereich) ??? + ScAddress aAddr( nPosX, nPosY, pViewData->GetTabNo() ); + +// Point aNext = pViewData->GetScrPos( nPosX+1, nPosY+1, eWhich ); + + Point aNext = pViewData->GetScrPos( nPosX, nPosY, eWhich, TRUE ); + long nSizeXPix; + long nSizeYPix; + pViewData->GetMergeSizePixel( nPosX, nPosY, nSizeXPix, nSizeYPix ); + aNext.X() += nSizeXPix; + aNext.Y() += nSizeYPix; + + BOOL bCellCorner = ( rMouse.X() >= aNext.X() - 8 && rMouse.X() <= aNext.X() && + rMouse.Y() >= aNext.Y() - 8 && rMouse.Y() <= aNext.Y() ); + // Corner wird nur erkannt, wenn noch innerhalb der Zelle + + USHORT nCount = (USHORT)pRangeFinder->Count(); + for (USHORT i=nCount; i;) + { + // rueckwaerts suchen, damit der zuletzt gepaintete Rahmen gefunden wird + --i; + ScRangeFindData* pData = pRangeFinder->GetObject(i); + if ( pData && pData->aRef.In(aAddr) ) + { + if (pIndex) *pIndex = i; + if (pAddX) *pAddX = nPosX - pData->aRef.aStart.Col(); + if (pAddY) *pAddY = nPosY - pData->aRef.aStart.Row(); + bFound = TRUE; + rCorner = ( bCellCorner && aAddr == pData->aRef.aEnd ); + break; + } + } + } + } + return bFound; +} + +#define SCE_TOP 1 +#define SCE_BOTTOM 2 +#define SCE_LEFT 4 +#define SCE_RIGHT 8 +#define SCE_ALL 15 + +void lcl_PaintOneRange( ScDocShell* pDocSh, const ScRange& rRange, USHORT nEdges ) +{ + // der Range ist immer richtigherum + + USHORT nCol1 = rRange.aStart.Col(); + USHORT nRow1 = rRange.aStart.Row(); + USHORT nTab1 = rRange.aStart.Tab(); + USHORT nCol2 = rRange.aEnd.Col(); + USHORT nRow2 = rRange.aEnd.Row(); + USHORT nTab2 = rRange.aEnd.Tab(); + + if ( nCol2 > nCol1 + 1 && nRow2 > nRow1 + 1 ) + { + // nur an den Raendern entlang + // (die Ecken werden evtl. zweimal getroffen) + + if ( nEdges & SCE_TOP ) + pDocSh->PostPaint( nCol1, nRow1, nTab1, nCol2, nRow1, nTab2, PAINT_MARKS ); + if ( nEdges & SCE_LEFT ) + pDocSh->PostPaint( nCol1, nRow1, nTab1, nCol1, nRow2, nTab2, PAINT_MARKS ); + if ( nEdges & SCE_RIGHT ) + pDocSh->PostPaint( nCol2, nRow1, nTab1, nCol2, nRow2, nTab2, PAINT_MARKS ); + if ( nEdges & SCE_BOTTOM ) + pDocSh->PostPaint( nCol1, nRow2, nTab1, nCol2, nRow2, nTab2, PAINT_MARKS ); + } + else // alles am Stueck + pDocSh->PostPaint( rRange, PAINT_MARKS ); +} + +void lcl_PaintRefChanged( ScDocShell* pDocSh, const ScRange& rOldUn, const ScRange& rNewUn ) +{ + // Repaint fuer die Teile des Rahmens in Old, die bei New nicht mehr da sind + + ScRange aOld = rOldUn; + ScRange aNew = rNewUn; + aOld.Justify(); + aNew.Justify(); + + if ( aOld.aStart == aOld.aEnd ) //! Tab ignorieren? + pDocSh->GetDocument()->ExtendMerge(aOld); + if ( aNew.aStart == aNew.aEnd ) //! Tab ignorieren? + pDocSh->GetDocument()->ExtendMerge(aNew); + + USHORT nOldCol1 = aOld.aStart.Col(); + USHORT nOldRow1 = aOld.aStart.Row(); + USHORT nOldCol2 = aOld.aEnd.Col(); + USHORT nOldRow2 = aOld.aEnd.Row(); + USHORT nNewCol1 = aNew.aStart.Col(); + USHORT nNewRow1 = aNew.aStart.Row(); + USHORT nNewCol2 = aNew.aEnd.Col(); + USHORT nNewRow2 = aNew.aEnd.Row(); + USHORT nTab1 = aOld.aStart.Tab(); // Tab aendert sich nicht + USHORT nTab2 = aOld.aEnd.Tab(); + + if ( nNewRow2 < nOldRow1 || nNewRow1 > nOldRow2 || + nNewCol2 < nOldCol1 || nNewCol1 > nOldCol2 || + ( nNewCol1 != nOldCol1 && nNewRow1 != nOldRow1 && + nNewCol2 != nOldCol2 && nNewRow2 != nOldRow2 ) ) + { + // komplett weggeschoben oder alle Seiten veraendert + // (Abfrage <= statt < geht schief bei einzelnen Zeilen/Spalten) + + lcl_PaintOneRange( pDocSh, aOld, SCE_ALL ); + } + else // alle vier Kanten einzeln testen + { + // oberer Teil + if ( nNewRow1 < nOldRow1 ) // nur obere Linie loeschen + lcl_PaintOneRange( pDocSh, ScRange( + nOldCol1, nOldRow1, nTab1, nOldCol2, nOldRow1, nTab2 ), SCE_ALL ); + else if ( nNewRow1 > nOldRow1 ) // den Teil, der oben wegkommt + lcl_PaintOneRange( pDocSh, ScRange( + nOldCol1, nOldRow1, nTab1, nOldCol2, nNewRow1-1, nTab2 ), + SCE_ALL &~ SCE_BOTTOM ); + + // unterer Teil + if ( nNewRow2 > nOldRow2 ) // nur untere Linie loeschen + lcl_PaintOneRange( pDocSh, ScRange( + nOldCol1, nOldRow2, nTab1, nOldCol2, nOldRow2, nTab2 ), SCE_ALL ); + else if ( nNewRow2 < nOldRow2 ) // den Teil, der unten wegkommt + lcl_PaintOneRange( pDocSh, ScRange( + nOldCol1, nNewRow2+1, nTab1, nOldCol2, nOldRow2, nTab2 ), + SCE_ALL &~ SCE_TOP ); + + // linker Teil + if ( nNewCol1 < nOldCol1 ) // nur linke Linie loeschen + lcl_PaintOneRange( pDocSh, ScRange( + nOldCol1, nOldRow1, nTab1, nOldCol1, nOldRow2, nTab2 ), SCE_ALL ); + else if ( nNewCol1 > nOldCol1 ) // den Teil, der links wegkommt + lcl_PaintOneRange( pDocSh, ScRange( + nOldCol1, nOldRow1, nTab1, nNewCol1-1, nOldRow2, nTab2 ), + SCE_ALL &~ SCE_RIGHT ); + + // rechter Teil + if ( nNewCol2 > nOldCol2 ) // nur rechte Linie loeschen + lcl_PaintOneRange( pDocSh, ScRange( + nOldCol2, nOldRow1, nTab1, nOldCol2, nOldRow2, nTab2 ), SCE_ALL ); + else if ( nNewCol2 < nOldCol2 ) // den Teil, der rechts wegkommt + lcl_PaintOneRange( pDocSh, ScRange( + nNewCol2+1, nOldRow1, nTab1, nOldCol2, nOldRow2, nTab2 ), + SCE_ALL &~ SCE_LEFT ); + } +} + +void ScGridWindow::RFMouseMove( const MouseEvent& rMEvt, BOOL bUp ) +{ + ScInputHandler* pHdl = SC_MOD()->GetInputHdl( pViewData->GetViewShell() ); + if (!pHdl) + return; + ScRangeFindList* pRangeFinder = pHdl->GetRangeFindList(); + if (!pRangeFinder || nRFIndex >= pRangeFinder->Count()) + return; + ScRangeFindData* pData = pRangeFinder->GetObject( nRFIndex ); + if (!pData) + return; + + // Mauszeiger + + if (bRFSize) + SetPointer( Pointer( POINTER_CROSS ) ); + else + SetPointer( Pointer( POINTER_HAND ) ); + + // Scrolling + + BOOL bTimer = FALSE; + Point aPos = rMEvt.GetPosPixel(); + short nDx = 0; + short nDy = 0; + if ( aPos.X() < 0 ) nDx = -1; + if ( aPos.Y() < 0 ) nDy = -1; + Size aSize = GetOutputSizePixel(); + if ( aPos.X() >= aSize.Width() ) + nDx = 1; + if ( aPos.Y() >= aSize.Height() ) + nDy = 1; + if ( nDx || nDy ) + { + if ( nDx ) pViewData->GetView()->ScrollX( nDx, WhichH(eWhich) ); + if ( nDy ) pViewData->GetView()->ScrollY( nDy, WhichV(eWhich) ); + bTimer = TRUE; + } + + // Umschalten bei Fixierung (damit Scrolling funktioniert) + + if ( eWhich == pViewData->GetActivePart() ) //?? + { + if ( pViewData->GetHSplitMode() == SC_SPLIT_FIX ) + if ( nDx > 0 ) + { + if ( eWhich == SC_SPLIT_TOPLEFT ) + pViewData->GetView()->ActivatePart( SC_SPLIT_TOPRIGHT ); + else if ( eWhich == SC_SPLIT_BOTTOMLEFT ) + pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT ); + } + + if ( pViewData->GetVSplitMode() == SC_SPLIT_FIX ) + if ( nDy > 0 ) + { + if ( eWhich == SC_SPLIT_TOPLEFT ) + pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMLEFT ); + else if ( eWhich == SC_SPLIT_TOPRIGHT ) + pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT ); + } + } + + // Verschieben + + short nPosX; + short nPosY; + pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); + + ScRange aOld = pData->aRef; + ScRange aNew = aOld; + if ( bRFSize ) + { + aNew.aEnd.SetCol((USHORT)nPosX); + aNew.aEnd.SetRow((USHORT)nPosY); + } + else + { + long nStartX = nPosX - nRFAddX; + if ( nStartX < 0 ) nStartX = 0; + long nStartY = nPosY - nRFAddY; + if ( nStartY < 0 ) nStartY = 0; + long nEndX = nStartX + aOld.aEnd.Col() - aOld.aStart.Col(); + if ( nEndX > MAXCOL ) + { + nStartX -= ( nEndX - MAXROW ); + nEndX = MAXCOL; + } + long nEndY = nStartY + aOld.aEnd.Row() - aOld.aStart.Row(); + if ( nEndY > MAXROW ) + { + nStartY -= ( nEndY - MAXROW ); + nEndY = MAXROW; + } + + aNew.aStart.SetCol((USHORT)nStartX); + aNew.aStart.SetRow((USHORT)nStartY); + aNew.aEnd.SetCol((USHORT)nEndX); + aNew.aEnd.SetRow((USHORT)nEndY); + } + + if ( bUp ) + aNew.Justify(); // beim ButtonUp wieder richtigherum + + if ( aNew != aOld ) + { + pHdl->UpdateRange( nRFIndex, aNew ); + + ScDocShell* pDocSh = pViewData->GetDocShell(); + + // nur das neuzeichnen, was sich veraendert hat... + lcl_PaintRefChanged( pDocSh, aOld, aNew ); + + // neuen Rahmen nur drueberzeichnen (synchron) + pDocSh->Broadcast( ScIndexHint( SC_HINT_SHOWRANGEFINDER, nRFIndex ) ); + + Update(); // was man bewegt, will man auch sofort sehen + } + + // Timer fuer Scrolling + + if (bTimer) + pViewData->GetView()->SetTimer( this, rMEvt ); // Event wiederholen + else + pViewData->GetView()->ResetTimer(); +} + +//------------------------------------------------------------------------ + +BOOL ScGridWindow::GetEditUrl( const Point& rPos, + String* pName, String* pUrl, String* pTarget ) +{ + return GetEditUrlOrError( FALSE, rPos, pName, pUrl, pTarget ); +} + +BOOL ScGridWindow::GetEditUrlOrError( BOOL bSpellErr, const Point& rPos, + String* pName, String* pUrl, String* pTarget ) +{ + //! nPosX/Y mit uebergeben? + short nPosX; + short nPosY; + pViewData->GetPosFromPixel( rPos.X(), rPos.Y(), eWhich, nPosX, nPosY ); + + USHORT nTab = pViewData->GetTabNo(); + ScDocument* pDoc = pViewData->GetDocument(); + ScBaseCell* pCell = NULL; + + BOOL bFound = FALSE; + do + { + pDoc->GetCell( nPosX, nPosY, nTab, pCell ); + if ( !pCell || pCell->GetCellType() == CELLTYPE_NOTE ) + { + if ( nPosX <= 0 ) + return FALSE; // alles leer bis links + else + --nPosX; // weitersuchen + } + else if ( pCell->GetCellType() == CELLTYPE_EDIT ) + bFound = TRUE; + else + return FALSE; // andere Zelle + } + while ( !bFound ); + + const ScPatternAttr* pPattern = pDoc->GetPattern( nPosX, nPosY, nTab ); + Rectangle aEditRect = pViewData->GetEditArea( eWhich, nPosX, nPosY, this, pPattern ); + if (rPos.Y() < aEditRect.Top()) + return FALSE; + + // vertikal kann (noch) nicht angeklickt werden: + + SvxCellOrientation eOrient = (SvxCellOrientation) ((SvxOrientationItem&)pPattern-> + GetItem(ATTR_ORIENTATION)).GetValue(); + if (eOrient != SVX_ORIENTATION_STANDARD) + return FALSE; + + BOOL bBreak = ((SfxBoolItem&)pPattern->GetItem(ATTR_LINEBREAK)).GetValue() || + ((SvxCellHorJustify)((const SvxHorJustifyItem&)pPattern-> + GetItem( ATTR_HOR_JUSTIFY )).GetValue() == SVX_HOR_JUSTIFY_BLOCK); + SvxCellHorJustify eHorJust = (SvxCellHorJustify)((SvxHorJustifyItem&)pPattern-> + GetItem(ATTR_HOR_JUSTIFY)).GetValue(); + + // EditEngine + + ScFieldEditEngine aEngine( pDoc->GetEditPool() ); + aEngine.SetRefMapMode( MAP_100TH_MM ); + SfxItemSet aDefault( aEngine.GetEmptyItemSet() ); + pPattern->FillEditItemSet( &aDefault ); + SvxAdjust eSvxAdjust = SVX_ADJUST_LEFT; + switch (eHorJust) + { + case SVX_HOR_JUSTIFY_LEFT: + case SVX_HOR_JUSTIFY_REPEAT: // nicht implementiert + case SVX_HOR_JUSTIFY_STANDARD: // immer Text + eSvxAdjust = SVX_ADJUST_LEFT; + break; + case SVX_HOR_JUSTIFY_RIGHT: + eSvxAdjust = SVX_ADJUST_RIGHT; + break; + case SVX_HOR_JUSTIFY_CENTER: + eSvxAdjust = SVX_ADJUST_CENTER; + break; + case SVX_HOR_JUSTIFY_BLOCK: + eSvxAdjust = SVX_ADJUST_BLOCK; + break; + } + aDefault.Put( SvxAdjustItem( eSvxAdjust, EE_PARA_JUST ) ); + aEngine.SetDefaults( aDefault ); + if (bSpellErr) + aEngine.SetControlWord( aEngine.GetControlWord() | EE_CNTRL_ONLINESPELLING ); + + MapMode aEditMode = pViewData->GetLogicMode(eWhich); // ohne Drawing-Skalierung + Rectangle aLogicEdit = PixelToLogic( aEditRect, aEditMode ); + long nThisColLogic = aLogicEdit.Right() - aLogicEdit.Left() + 1; + + Size aPaperSize = Size( 1000000, 1000000 ); + if (bBreak) + aPaperSize.Width() = nThisColLogic; + aEngine.SetPaperSize( aPaperSize ); + + const EditTextObject* pData; + ((ScEditCell*)pCell)->GetData(pData); + if (pData) + aEngine.SetText(*pData); + + long nStartX = aLogicEdit.Left(); + + long nTextWidth = aEngine.CalcTextWidth(); + long nTextHeight = aEngine.GetTextHeight(); + if ( nTextWidth < nThisColLogic ) + { + if (eHorJust == SVX_HOR_JUSTIFY_RIGHT) + nStartX += nThisColLogic - nTextWidth; + else if (eHorJust == SVX_HOR_JUSTIFY_CENTER) + nStartX += (nThisColLogic - nTextWidth) / 2; + } + + aLogicEdit.Left() = nStartX; + if (!bBreak) + aLogicEdit.Right() = nStartX + nTextWidth; + aLogicEdit.Bottom() = aLogicEdit.Top() + nTextHeight; + + Point aLogicClick = PixelToLogic(rPos,aEditMode); + if ( aLogicEdit.IsInside(aLogicClick) ) + { +// aEngine.SetUpdateMode(FALSE); + EditView aTempView( &aEngine, this ); + aTempView.SetOutputArea( aLogicEdit ); + + BOOL bRet = FALSE; + MapMode aOld = GetMapMode(); + SetMapMode(aEditMode); // kein return mehr + + if (bSpellErr) // Spelling-Fehler suchen + { + bRet = aTempView.IsWrongSpelledWordAtPos( rPos ); + if ( bRet ) + pViewData->GetView()->SetCursor( nPosX, nPosY ); // Cursor setzen + } + else // URL suchen + { + const SvxFieldItem* pFieldItem = aTempView.GetFieldUnderMousePointer(); + + if (pFieldItem) + { + const SvxFieldData* pField = pFieldItem->GetField(); + if ( pField && pField->ISA(SvxURLField) ) + { + if ( pName || pUrl || pTarget ) + { + const SvxURLField* pURLField = (const SvxURLField*)pField; + if (pName) + *pName = pURLField->GetRepresentation(); + if (pUrl) + *pUrl = pURLField->GetURL(); + if (pTarget) + *pTarget = pURLField->GetTargetFrame(); + } + bRet = TRUE; + } + } + } + + SetMapMode(aOld); + + // bei SetOutputArea oben geht der Text-Cursor kaputt... + if ( pViewData->HasEditView(eWhich) && HasFocus() ) + pViewData->GetEditView(eWhich)->ShowCursor( FALSE, TRUE ); + + return bRet; + } + return FALSE; +} + +BOOL ScGridWindow::HasScenarioButton( const Point& rPosPixel, ScRange& rScenRange ) +{ + ScDocument* pDoc = pViewData->GetDocument(); + USHORT nTab = pViewData->GetTabNo(); + USHORT nTabCount = pDoc->GetTableCount(); + if ( nTab+1<nTabCount && pDoc->IsScenario(nTab+1) && !pDoc->IsScenario(nTab) ) + { + Size aButSize = pViewData->GetScenButSize(); + long nBWidth = aButSize.Width(); + if (!nBWidth) + return FALSE; // noch kein Button gezeichnet -> da ist auch keiner + long nBHeight = aButSize.Height(); + long nHSpace = (long)( SC_SCENARIO_HSPACE * pViewData->GetPPTX() ); + + //! Ranges an der Table cachen!!!! + + USHORT i; + ScMarkData aMarks; + for (i=nTab+1; i<nTabCount && pDoc->IsScenario(i); i++) + pDoc->MarkScenario( i, nTab, aMarks, FALSE, SC_SCENARIO_SHOWFRAME ); + ScRangeList aRanges; + aMarks.FillRangeListWithMarks( &aRanges, FALSE ); + + + USHORT nRangeCount = (USHORT)aRanges.Count(); + for (i=0; i<nRangeCount; i++) + { + ScRange aRange = *aRanges.GetObject(i); + // Szenario-Rahmen immer dann auf zusammengefasste Zellen erweitern, wenn + // dadurch keine neuen nicht-ueberdeckten Zellen mit umrandet werden + pDoc->ExtendTotalMerge( aRange ); + + BOOL bTextBelow = ( aRange.aStart.Row() == 0 ); + + Point aButtonPos; + if ( bTextBelow ) + { + aButtonPos = pViewData->GetScrPos( aRange.aEnd.Col()+1, aRange.aEnd.Row()+1, + eWhich, TRUE ); + } + else + { + aButtonPos = pViewData->GetScrPos( aRange.aEnd.Col()+1, aRange.aStart.Row(), + eWhich, TRUE ); + aButtonPos.Y() -= nBHeight; + } + aButtonPos.X() -= nBWidth - nHSpace; // in beiden Faellen gleich + + Rectangle aButRect( aButtonPos, Size(nBWidth,nBHeight) ); + if ( aButRect.IsInside( rPosPixel ) ) + { + rScenRange = aRange; + return TRUE; + } + } + } + + return FALSE; +} + + + + diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx new file mode 100644 index 000000000000..04e5aede33c3 --- /dev/null +++ b/sc/source/ui/view/gridwin2.cxx @@ -0,0 +1,1145 @@ +/************************************************************************* + * + * $RCSfile: gridwin2.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <vcl/msgbox.hxx> +#include <vcl/sound.hxx> + +#include "gridwin.hxx" +#include "tabvwsh.hxx" +#include "docsh.hxx" +#include "viewdata.hxx" +#include "pivot.hxx" +#include "pfiltdlg.hxx" +#include "uiitems.hxx" +#include "scresid.hxx" +#include "sc.hrc" +#include "globstr.hrc" +#include "pagedata.hxx" +#include "dpobject.hxx" +#include "dpsave.hxx" +#include "dpoutput.hxx" // ScDPPositionData +#include "dpshttab.hxx" +#include "dbdocfun.hxx" + +#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> + +using namespace com::sun::star; + + +// STATIC DATA ----------------------------------------------------------- + +// ----------------------------------------------------------------------- + +void ScGridWindow::DoPushButton( USHORT nCol, USHORT nRow, const MouseEvent& rMEvt ) +{ + ScDocument* pDoc = pViewData->GetDocument(); + USHORT nTab = pViewData->GetTabNo(); + + ScPivotCollection* pPivotCollection = pDoc->GetPivotCollection(); + ScPivot* pPivot = pPivotCollection->GetPivotAtCursor(nCol, nRow, nTab); + + ScDPObject* pDPObj = pDoc->GetDPAtCursor(nCol, nRow, nTab); + + if (pPivot) // alte Pivottabellen + { + if (pPivot->IsFilterAtCursor(nCol, nRow, nTab)) + { + ReleaseMouse(); // falls schon beim ButtonDown gecaptured, #44018# + + ScQueryParam aQueryParam; + pPivot->GetQuery(aQueryParam); + USHORT nSrcTab = pPivot->GetSrcArea().aStart.Tab(); + + SfxItemSet aArgSet( pViewData->GetViewShell()->GetPool(), + SCITEM_QUERYDATA, SCITEM_QUERYDATA ); + aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA, pViewData, &aQueryParam ) ); + + ScPivotFilterDlg* pDlg = new ScPivotFilterDlg( + pViewData->GetViewShell()->GetDialogParent(), + aArgSet, nSrcTab ); + if ( pDlg->Execute() == RET_OK ) + { + ScPivot* pNewPivot = pPivot->CreateNew(); + + const ScQueryItem& rQueryItem = pDlg->GetOutputItem(); + pNewPivot->SetQuery(rQueryItem.GetQueryData()); + + PivotField* pColArr = new PivotField[PIVOT_MAXFIELD]; + short nColCount; + pPivot->GetColFields( pColArr, nColCount ); + PivotField* pRowArr = new PivotField[PIVOT_MAXFIELD]; + short nRowCount; + pPivot->GetRowFields( pRowArr, nRowCount ); + PivotField* pDataArr = new PivotField[PIVOT_MAXFIELD]; + short nDataCount; + pPivot->GetDataFields( pDataArr, nDataCount ); + + pNewPivot->SetColFields( pColArr, nColCount ); + pNewPivot->SetRowFields( pRowArr, nRowCount ); + pNewPivot->SetDataFields( pDataArr, nDataCount ); + + pNewPivot->SetName( pPivot->GetName() ); + pNewPivot->SetTag( pPivot->GetTag() ); + + pViewData->GetDocShell()->PivotUpdate( pPivot, pNewPivot ); + } + delete pDlg; + } + else + { + USHORT nField; + if (pPivot->GetColFieldAtCursor(nCol, nRow, nTab, nField)) + { + bPivotMouse = TRUE; + nPivotField = nField; + bPivotColField = TRUE; + nPivotCol = nCol; + pDragPivot = pPivot; + PivotTestMouse( rMEvt, TRUE ); + // CaptureMouse(); + StartTracking(); + } + else if (pPivot->GetRowFieldAtCursor(nCol, nRow, nTab, nField)) + { + bPivotMouse = TRUE; + nPivotField = nField; + bPivotColField = FALSE; + nPivotCol = nCol; + pDragPivot = pPivot; + PivotTestMouse( rMEvt, TRUE ); + // CaptureMouse(); + StartTracking(); + } + } + } + else if (pDPObj) + { + ScAddress aPos( nCol, nRow, nTab ); + long nField = pDPObj->GetHeaderDim(aPos); + if ( nField >= 0 ) + { + bDPMouse = TRUE; + nDPField = nField; + pDragDPObj = pDPObj; + DPTestMouse( rMEvt, TRUE ); + StartTracking(); + } + else if ( pDPObj->IsFilterButton(aPos) ) + { + ReleaseMouse(); // may have been captured in ButtonDown + + ScQueryParam aQueryParam; + USHORT nSrcTab = 0; + const ScSheetSourceDesc* pDesc = pDPObj->GetSheetDesc(); + DBG_ASSERT(pDesc, "no sheet source for filter button"); + if (pDesc) + { + aQueryParam = pDesc->aQueryParam; + nSrcTab = pDesc->aSourceRange.aStart.Tab(); + } + + SfxItemSet aArgSet( pViewData->GetViewShell()->GetPool(), + SCITEM_QUERYDATA, SCITEM_QUERYDATA ); + aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA, pViewData, &aQueryParam ) ); + + ScPivotFilterDlg* pDlg = new ScPivotFilterDlg( + pViewData->GetViewShell()->GetDialogParent(), + aArgSet, nSrcTab ); + if ( pDlg->Execute() == RET_OK ) + { + ScSheetSourceDesc aNewDesc; + if (pDesc) + aNewDesc = *pDesc; + + const ScQueryItem& rQueryItem = pDlg->GetOutputItem(); + aNewDesc.aQueryParam = rQueryItem.GetQueryData(); + + ScDPObject aNewObj( *pDPObj ); + aNewObj.SetSheetDesc( aNewDesc ); + ScDBDocFunc aFunc( *pViewData->GetDocShell() ); + aFunc.DataPilotUpdate( pDPObj, &aNewObj, TRUE, FALSE ); + pViewData->GetView()->CursorPosChanged(); // shells may be switched + } + delete pDlg; + } + else + Sound::Beep(); + } + else + DBG_ERROR("Da is ja garnix"); +} + +void ScGridWindow::DoPivotDrop( BOOL bDelete, BOOL bToCols, short nDestPos ) +{ + if ( nPivotField == PIVOT_DATA_FIELD && bDelete ) + { + pViewData->GetView()->ErrorMessage(STR_PIVOT_MOVENOTALLOWED); + return; + } + + if ( bPivotColField != bToCols && !bDelete ) + { + short nDestCount = bToCols ? pDragPivot->GetColFieldCount() + : pDragPivot->GetRowFieldCount(); + if ( nDestCount >= PIVOT_MAXFIELD ) // schon voll? + { + // Versuch, mehr als PIVOT_MAXFIELD Eintraege zu erzeugen + pViewData->GetView()->ErrorMessage(STR_PIVOT_ERROR); + return; + } + } + + PivotField* pColArr = new PivotField[PIVOT_MAXFIELD]; + short nColCount; + pDragPivot->GetColFields( pColArr, nColCount ); + + PivotField* pRowArr = new PivotField[PIVOT_MAXFIELD]; + short nRowCount; + pDragPivot->GetRowFields( pRowArr, nRowCount ); + + PivotField* pDataArr = new PivotField[PIVOT_MAXFIELD]; + short nDataCount; + pDragPivot->GetDataFields( pDataArr, nDataCount ); + + short nOldPos = 0; + short i; + PivotField aMoveField; + + PivotField* pSource = bPivotColField ? pColArr : pRowArr; + short& rCount = bPivotColField ? nColCount : nRowCount; + + BOOL bFound = FALSE; + for (i=0; i<rCount && !bFound; i++) + if (pSource[i].nCol == (short) nPivotField) + { + nOldPos = i; + aMoveField = pSource[i]; + --rCount; + if (i<rCount) + memmove( &pSource[i], &pSource[i+1], (rCount-i)*sizeof(PivotField) ); + if ( bPivotColField == bToCols ) + if (nDestPos > i) + --nDestPos; + bFound = TRUE; + } + + if (bFound) + { + if (!bDelete) + { + PivotField* pDest = bToCols ? pColArr : pRowArr; + short& rDestCount = bToCols ? nColCount : nRowCount; + if (nDestPos < rDestCount) + memmove( &pDest[nDestPos+1], &pDest[nDestPos], + (rDestCount-nDestPos)*sizeof(PivotField) ); + pDest[nDestPos] = aMoveField; + ++rDestCount; + } + + ScPivotCollection* pPivotCollection = pViewData->GetDocument()->GetPivotCollection(); + + BOOL bEmpty = ( nColCount + nRowCount == 0 || + ( nColCount + nRowCount == 1 && nDataCount <= 1 ) ); + + if ( bEmpty ) // Pivottabelle loeschen + { + pViewData->GetDocShell()->PivotUpdate( pDragPivot, NULL ); + } + else + { + ScPivot* pNewPivot = pDragPivot->CreateNew(); + pNewPivot->SetColFields( pColArr, nColCount ); + pNewPivot->SetRowFields( pRowArr, nRowCount ); + pNewPivot->SetDataFields( pDataArr, nDataCount ); + + pNewPivot->SetName( pDragPivot->GetName() ); + pNewPivot->SetTag( pDragPivot->GetTag() ); + + pViewData->GetDocShell()->PivotUpdate( pDragPivot, pNewPivot ); + } + pDragPivot = NULL; + } + else + DBG_ASSERT(0,"Pivot-Eintrag nicht gefunden"); + + delete[] pColArr; + delete[] pRowArr; + delete[] pDataArr; +} + +BOOL ScGridWindow::PivotTestMouse( const MouseEvent& rMEvt, BOOL bMove ) +{ + BOOL bRet = FALSE; + BOOL bTimer = FALSE; + Point aPos = rMEvt.GetPosPixel(); + + short nDx = 0; + short nDy = 0; + if ( aPos.X() < 0 ) + nDx = -1; + if ( aPos.Y() < 0 ) + nDy = -1; + Size aSize = GetOutputSizePixel(); + if ( aPos.X() >= aSize.Width() ) + nDx = 1; + if ( aPos.Y() >= aSize.Height() ) + nDy = 1; + if ( nDx || nDy ) + { + if (bDragRect) + { + DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, FALSE ); + bDragRect = FALSE; + } + + if ( nDx ) + pViewData->GetView()->ScrollX( nDx, WhichH(eWhich) ); + if ( nDy ) + pViewData->GetView()->ScrollY( nDy, WhichV(eWhich) ); + + bTimer = TRUE; + } + + short nPosX; + short nPosY; + pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); + BOOL bMouseLeft; + BOOL bMouseTop; + pViewData->GetMouseQuadrant( aPos, eWhich, nPosX, nPosY, bMouseLeft, bMouseTop ); + + USHORT nPiCol1; + USHORT nPiRow1; + USHORT nPiCol2; + USHORT nPiRow2; + USHORT nTab; + pDragPivot->GetDestArea( nPiCol1, nPiRow1, nPiCol2, nPiRow2, nTab ); + + if ( nPosX >= (short) nPiCol1 && nPosX <= (short) nPiCol2 && + nPosY >= (short) nPiRow1 && nPosY <= (short) nPiRow2 ) + { + short nFilterAdd = 2; // Platz fuer Filter-Button + short nColRows = 1; //! Ueberschrift: 0, wenn keine Zeilen, aber mehrere Datenfelder + USHORT nNewStartX; + USHORT nNewStartY; + USHORT nNewEndX; + USHORT nNewEndY; + + short nRelX = nPosX - (short) nPiCol1; + short nRelY = nPosY - (short) nPiRow1 - nFilterAdd; + + PivotField* pFieldArr = new PivotField[PIVOT_MAXFIELD]; + short nColCount; + pDragPivot->GetColFields( pFieldArr, nColCount ); + short nRowCount; + pDragPivot->GetRowFields( pFieldArr, nRowCount ); + delete[] pFieldArr; + + BOOL bBefore; + short nColSize = Max( nColCount, (short) 1 ); + short nRowSize = Max( nRowCount, (short) 1 ); + + BOOL bToCols; + if (nRelX < nColSize && nRelY >= nRowSize) + bToCols = TRUE; // links + else if (nRelY < nRowSize && nRelX >= nColSize) + bToCols = FALSE; // oben + else + bToCols = ( nRelY-nRowSize > nRelX-nColSize ); + + short nDestCol = 0; + short nDestRow = 0; + BOOL bNothing = FALSE; + + if ( bToCols ) + { + bBefore = bMouseLeft; + nDestCol = nRelX; + if (nDestCol < 0) + { + nDestCol = 0; + bBefore = TRUE; + } + if (nDestCol >= nColCount) + { + nDestCol = nColCount-1; + bBefore = FALSE; + } + + nNewStartY = nPiRow1 + (USHORT) nFilterAdd + nRowCount + nColRows; + nNewEndY = nPiRow2 - 1; + nNewStartX = nPiCol1 + (USHORT) nDestCol; + nNewEndX = nNewStartX; + + if ( !bPivotColField ) // von der anderen Seite + { + if (bBefore) + nNewEndX = nNewStartX - 1; // vor dem Feld + else + nNewStartX = nNewEndX + 1; // hinter dem Feld + } + else + { + USHORT nThisCol = (USHORT) nPosX; // absolute Spalte ( == Maus ) + if ( nThisCol < nPivotCol ) + { + nNewEndX = nNewStartX - 1; // vor dem Feld + bBefore = TRUE; + } + else if ( nThisCol > nPivotCol ) + { + nNewStartX = nNewEndX + 1; // hinter dem Feld + bBefore = FALSE; + } + else + bNothing = TRUE; + } + SetPointer( Pointer( POINTER_PIVOT_ROW ) ); + } + else + { + nDestRow; + if (nRelY <= 0 && nRelX < nColCount+nRowCount) + { + nDestRow = nRelX-nColCount; + bBefore = bMouseLeft; + } + else + { + nDestRow = nRelY-1; + bBefore = bMouseTop; + } + if (nDestRow < 0) + { + nDestRow = 0; + bBefore = TRUE; + } + if (nDestRow >= nRowCount) + { + nDestRow = nRowCount-1; + bBefore = FALSE; + } + + nNewStartX = nPiCol1 + (USHORT) nColCount; + nNewEndX = nPiCol2 - 1; + nNewStartY = nPiRow1 + (USHORT) nFilterAdd + nDestRow + nColRows; + nNewEndY = nNewStartY; + if ( bPivotColField ) // von der anderen Seite + { + if (bBefore) + nNewEndY = nNewStartY - 1; // vor dem Feld + else + nNewStartY = nNewEndY + 1; // hinter dem Feld + } + else + { + USHORT nThisCol = nDestRow+nColCount+nPiCol1; // absolute Spalte + if ( nThisCol < nPivotCol ) + { + bBefore = TRUE; + nNewEndY = nNewStartY - 1; // vor dem Feld + } + else if ( nThisCol > nPivotCol ) + { + bBefore = FALSE; + nNewStartY = nNewEndY + 1; // hinter dem Feld + } + else + bNothing = TRUE; + } + SetPointer( Pointer( POINTER_PIVOT_COL ) ); + } + + if (bMove) + { + if ( nNewStartX != nDragStartX || nNewEndX != nDragEndX || + nNewStartY != nDragStartY || nNewEndY != nDragEndY || !bDragRect ) + { + if (bDragRect) + DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, FALSE ); + + nDragStartX = nNewStartX; + nDragStartY = nNewStartY; + nDragEndX = nNewEndX; + nDragEndY = nNewEndY; + bDragRect = TRUE; + + DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, FALSE ); + } + } + else + { + if (bDragRect) + { + DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, FALSE ); + bDragRect = FALSE; + } + + if (!bNothing) + { + short nDestPos = bToCols ? nDestCol : nDestRow; + if (!bBefore) + ++nDestPos; + DoPivotDrop( FALSE, bToCols, nDestPos ); + } + } + + bRet = TRUE; + } + else + { + if (bMove) + SetPointer( Pointer( POINTER_NOTALLOWED ) ); + if (bDragRect) + DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, FALSE ); + bDragRect = FALSE; + + if (!bMove) + DoPivotDrop( TRUE, FALSE,0 ); + } + + if (bTimer && bMove) + pViewData->GetView()->SetTimer( this, rMEvt ); // Event wiederholen + else + pViewData->GetView()->ResetTimer(); + + return bRet; +} + +void ScGridWindow::PivotMouseMove( const MouseEvent& rMEvt ) +{ + PivotTestMouse( rMEvt, TRUE ); +} + +void ScGridWindow::PivotMouseButtonUp( const MouseEvent& rMEvt ) +{ + bPivotMouse = FALSE; // als erstes, falls PivotTestMouse eine Fehlermeldung bringt + ReleaseMouse(); + + PivotTestMouse( rMEvt, FALSE ); + SetPointer( Pointer( POINTER_ARROW ) ); +} + +// ----------------------------------------------------------------------- +// +// Data Pilot interaction +// + +void ScGridWindow::DPTestMouse( const MouseEvent& rMEvt, BOOL bMove ) +{ + DBG_ASSERT(pDragDPObj, "pDragDPObj missing"); + + // scroll window if at edges + //! move this to separate method + + BOOL bTimer = FALSE; + Point aPixel = rMEvt.GetPosPixel(); + + short nDx = 0; + short nDy = 0; + if ( aPixel.X() < 0 ) + nDx = -1; + if ( aPixel.Y() < 0 ) + nDy = -1; + Size aSize = GetOutputSizePixel(); + if ( aPixel.X() >= aSize.Width() ) + nDx = 1; + if ( aPixel.Y() >= aSize.Height() ) + nDy = 1; + if ( nDx || nDy ) + { + UpdateDragRect( FALSE, Rectangle() ); + + if ( nDx ) + pViewData->GetView()->ScrollX( nDx, WhichH(eWhich) ); + if ( nDy ) + pViewData->GetView()->ScrollY( nDy, WhichV(eWhich) ); + + bTimer = TRUE; + } + + // --- + + short nPosX; + short nPosY; + pViewData->GetPosFromPixel( aPixel.X(), aPixel.Y(), eWhich, nPosX, nPosY ); + BOOL bMouseLeft; + BOOL bMouseTop; + pViewData->GetMouseQuadrant( aPixel, eWhich, nPosX, nPosY, bMouseLeft, bMouseTop ); + + ScAddress aPos( nPosX, nPosY, pViewData->GetTabNo() ); + + Rectangle aPosRect; + USHORT nOrient; + long nDimPos; + BOOL bHasRange = pDragDPObj->GetHeaderDrag( aPos, bMouseLeft, bMouseTop, nDPField, + aPosRect, nOrient, nDimPos ); + UpdateDragRect( bHasRange && bMove, aPosRect ); + + if (bMove) // set mouse pointer + { + PointerStyle ePointer = POINTER_NOTALLOWED; + if ( bHasRange ) + switch (nOrient) + { + case sheet::DataPilotFieldOrientation_COLUMN: ePointer = POINTER_PIVOT_COL; break; + case sheet::DataPilotFieldOrientation_ROW: ePointer = POINTER_PIVOT_ROW; break; + case sheet::DataPilotFieldOrientation_PAGE: + case sheet::DataPilotFieldOrientation_DATA: ePointer = POINTER_PIVOT_FIELD; break; + } + SetPointer( ePointer ); + } + else // execute change + { + if (!bHasRange) + nOrient = sheet::DataPilotFieldOrientation_HIDDEN; + + BOOL bIsDataLayout; + String aDimName = pDragDPObj->GetDimName( nDPField, bIsDataLayout ); + if ( bIsDataLayout && nOrient == sheet::DataPilotFieldOrientation_HIDDEN ) + { + // removing data layout is not allowed + pViewData->GetView()->ErrorMessage(STR_PIVOT_MOVENOTALLOWED); + } + else + { + ScDPSaveData aSaveData( *pDragDPObj->GetSaveData() ); + + ScDPSaveDimension* pDim; + if ( bIsDataLayout ) + pDim = aSaveData.GetDataLayoutDimension(); + else + pDim = aSaveData.GetDimensionByName(aDimName); + pDim->SetOrientation( nOrient ); + aSaveData.SetPosition( pDim, nDimPos ); + + //! docfunc method with ScDPSaveData as argument? + + ScDPObject aNewObj( *pDragDPObj ); + aNewObj.SetSaveData( aSaveData ); + ScDBDocFunc aFunc( *pViewData->GetDocShell() ); + aFunc.DataPilotUpdate( pDragDPObj, &aNewObj, TRUE, FALSE ); + pViewData->GetView()->CursorPosChanged(); // shells may be switched + } + } + + if (bTimer && bMove) + pViewData->GetView()->SetTimer( this, rMEvt ); // repeat event + else + pViewData->GetView()->ResetTimer(); +} + +void ScGridWindow::DPMouseMove( const MouseEvent& rMEvt ) +{ + DPTestMouse( rMEvt, TRUE ); +} + +void ScGridWindow::DPMouseButtonUp( const MouseEvent& rMEvt ) +{ + bDPMouse = FALSE; + ReleaseMouse(); + + DPTestMouse( rMEvt, FALSE ); + SetPointer( Pointer( POINTER_ARROW ) ); +} + +// ----------------------------------------------------------------------- + +void ScGridWindow::UpdateDragRect( BOOL bShowRange, const Rectangle& rPosRect ) +{ + USHORT nStartX = ( rPosRect.Left() >= 0 ) ? rPosRect.Left() : USHRT_MAX; + USHORT nStartY = ( rPosRect.Top() >= 0 ) ? rPosRect.Top() : USHRT_MAX; + USHORT nEndX = ( rPosRect.Right() >= 0 ) ? rPosRect.Right() : USHRT_MAX; + USHORT nEndY = ( rPosRect.Bottom() >= 0 ) ? rPosRect.Bottom() : USHRT_MAX; + + if ( bShowRange == bDragRect && nDragStartX == nStartX && nDragEndX == nEndX && + nDragStartY == nStartY && nDragEndY == nEndY ) + { + return; // everything unchanged + } + + if ( bDragRect ) + DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, FALSE ); + if ( bShowRange ) + { + nDragStartX = nStartX; + nDragStartY = nStartY; + nDragEndX = nEndX; + nDragEndY = nEndY; + bDragRect = TRUE; + DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, FALSE ); + } + else + bDragRect = FALSE; +} + +// ----------------------------------------------------------------------- + +// Page-Break-Modus + +USHORT ScGridWindow::HitPageBreak( const Point& rMouse, ScRange* pSource, + USHORT* pBreak, USHORT* pPrev ) +{ + USHORT nFound = SC_PD_NONE; // 0 + ScRange aSource; + USHORT nBreak = 0; + USHORT nPrev = 0; + + ScPageBreakData* pPageData = pViewData->GetView()->GetPageBreakData(); + if ( pPageData ) + { + BOOL bHori = FALSE; + BOOL bVert = FALSE; + USHORT nHitX, nHitY; + + long nMouseX = rMouse.X(); + long nMouseY = rMouse.Y(); + short nPosX, nPosY; + pViewData->GetPosFromPixel( nMouseX, nMouseY, eWhich, nPosX, nPosY ); + Point aTL = pViewData->GetScrPos( nPosX, nPosY, eWhich ); + Point aBR = pViewData->GetScrPos( nPosX+1, nPosY+1, eWhich ); + + // Horizontal mehr Toleranz als vertikal, weil mehr Platz ist + if ( nMouseX <= aTL.X() + 4 ) + { + bHori = TRUE; + nHitX = nPosX; + } + else if ( nMouseX >= aBR.X() - 6 ) + { + bHori = TRUE; + nHitX = nPosX+1; // linker Rand der naechsten Zelle + } + if ( nMouseY <= aTL.Y() + 2 ) + { + bVert = TRUE; + nHitY = nPosY; + } + else if ( nMouseY >= aBR.Y() - 4 ) + { + bVert = TRUE; + nHitY = nPosY+1; // oberer Rand der naechsten Zelle + } + + if ( bHori || bVert ) + { + USHORT nCount = pPageData->GetCount(); + for (USHORT nPos=0; nPos<nCount && !nFound; nPos++) + { + ScPrintRangeData& rData = pPageData->GetData(nPos); + ScRange aRange = rData.GetPrintRange(); + BOOL bLHit = ( bHori && nHitX == aRange.aStart.Col() ); + BOOL bRHit = ( bHori && nHitX == aRange.aEnd.Col() + 1 ); + BOOL bTHit = ( bVert && nHitY == aRange.aStart.Row() ); + BOOL bBHit = ( bVert && nHitY == aRange.aEnd.Row() + 1 ); + BOOL bInsideH = ( nPosX >= aRange.aStart.Col() && nPosX <= aRange.aEnd.Col() ); + BOOL bInsideV = ( nPosY >= aRange.aStart.Row() && nPosY <= aRange.aEnd.Row() ); + + if ( bLHit ) + { + if ( bTHit ) + nFound = SC_PD_RANGE_TL; + else if ( bBHit ) + nFound = SC_PD_RANGE_BL; + else if ( bInsideV ) + nFound = SC_PD_RANGE_L; + } + else if ( bRHit ) + { + if ( bTHit ) + nFound = SC_PD_RANGE_TR; + else if ( bBHit ) + nFound = SC_PD_RANGE_BR; + else if ( bInsideV ) + nFound = SC_PD_RANGE_R; + } + else if ( bTHit && bInsideH ) + nFound = SC_PD_RANGE_T; + else if ( bBHit && bInsideH ) + nFound = SC_PD_RANGE_B; + if (nFound) + aSource = aRange; + + // Umbrueche + + if ( bVert && bInsideH && !nFound ) + { + USHORT nRowCount = rData.GetPagesY(); + const USHORT* pRowEnd = rData.GetPageEndY(); + for (USHORT nRowPos=0; nRowPos+1<nRowCount; nRowPos++) + if ( pRowEnd[nRowPos]+1 == nHitY ) + { + nFound = SC_PD_BREAK_V; + aSource = aRange; + nBreak = nHitY; + if ( nRowPos ) + nPrev = pRowEnd[nRowPos-1]+1; + else + nPrev = aRange.aStart.Row(); + } + } + if ( bHori && bInsideV && !nFound ) + { + USHORT nColCount = rData.GetPagesX(); + const USHORT* pColEnd = rData.GetPageEndX(); + for (USHORT nColPos=0; nColPos+1<nColCount; nColPos++) + if ( pColEnd[nColPos]+1 == nHitX ) + { + nFound = SC_PD_BREAK_H; + aSource = aRange; + nBreak = nHitX; + if ( nColPos ) + nPrev = pColEnd[nColPos-1]+1; + else + nPrev = aRange.aStart.Col(); + } + } + } + } + } + + if (pSource) + *pSource = aSource; // Druckbereich + if (pBreak) + *pBreak = nBreak; // X/Y Position des verchobenen Seitenumbruchs + if (pPrev) + *pPrev = nPrev; // X/Y Anfang der Seite, die am Umbruch zuende ist + return nFound; +} + +void ScGridWindow::PagebreakMove( const MouseEvent& rMEvt, BOOL bUp ) +{ + //! Scrolling und Umschalten mit RFMouseMove zusammenfassen ! + //! (Weginvertieren vor dem Scrolling ist anders) + + // Scrolling + + BOOL bTimer = FALSE; + Point aPos = rMEvt.GetPosPixel(); + short nDx = 0; + short nDy = 0; + if ( aPos.X() < 0 ) nDx = -1; + if ( aPos.Y() < 0 ) nDy = -1; + Size aSize = GetOutputSizePixel(); + if ( aPos.X() >= aSize.Width() ) + nDx = 1; + if ( aPos.Y() >= aSize.Height() ) + nDy = 1; + if ( nDx || nDy ) + { + if ( bPagebreakDrawn ) // weginvertieren + { + DrawDragRect( aPagebreakDrag.aStart.Col(), aPagebreakDrag.aStart.Row(), + aPagebreakDrag.aEnd.Col(), aPagebreakDrag.aEnd.Row(), FALSE ); + bPagebreakDrawn = FALSE; + } + + if ( nDx ) pViewData->GetView()->ScrollX( nDx, WhichH(eWhich) ); + if ( nDy ) pViewData->GetView()->ScrollY( nDy, WhichV(eWhich) ); + bTimer = TRUE; + } + + // Umschalten bei Fixierung (damit Scrolling funktioniert) + + if ( eWhich == pViewData->GetActivePart() ) //?? + { + if ( pViewData->GetHSplitMode() == SC_SPLIT_FIX ) + if ( nDx > 0 ) + { + if ( eWhich == SC_SPLIT_TOPLEFT ) + pViewData->GetView()->ActivatePart( SC_SPLIT_TOPRIGHT ); + else if ( eWhich == SC_SPLIT_BOTTOMLEFT ) + pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT ); + } + + if ( pViewData->GetVSplitMode() == SC_SPLIT_FIX ) + if ( nDy > 0 ) + { + if ( eWhich == SC_SPLIT_TOPLEFT ) + pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMLEFT ); + else if ( eWhich == SC_SPLIT_TOPRIGHT ) + pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT ); + } + } + + // ab hier neu + + // gesucht wird eine Position zwischen den Zellen (vor nPosX / nPosY) + short nPosX, nPosY; + pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); + BOOL bLeft, bTop; + pViewData->GetMouseQuadrant( aPos, eWhich, nPosX, nPosY, bLeft, bTop ); + if ( !bLeft ) ++nPosX; + if ( !bTop ) ++nPosY; + + BOOL bBreak = ( nPagebreakMouse == SC_PD_BREAK_H || nPagebreakMouse == SC_PD_BREAK_V ); + BOOL bHide = FALSE; + BOOL bToEnd = FALSE; + ScRange aDrawRange = aPagebreakSource; + if ( bBreak ) + { + if ( nPagebreakMouse == SC_PD_BREAK_H ) + { + if ( nPosX > aPagebreakSource.aStart.Col() && + nPosX <= aPagebreakSource.aEnd.Col() + 1 ) // ans Ende ist auch erlaubt + { + bToEnd = ( nPosX == aPagebreakSource.aEnd.Col() + 1 ); + aDrawRange.aStart.SetCol( nPosX ); + aDrawRange.aEnd.SetCol( nPosX - 1 ); + } + else + bHide = TRUE; + } + else + { + if ( nPosY > aPagebreakSource.aStart.Row() && + nPosY <= aPagebreakSource.aEnd.Row() + 1 ) // ans Ende ist auch erlaubt + { + bToEnd = ( nPosY == aPagebreakSource.aEnd.Row() + 1 ); + aDrawRange.aStart.SetRow( nPosY ); + aDrawRange.aEnd.SetRow( nPosY - 1 ); + } + else + bHide = TRUE; + } + } + else + { + if ( nPagebreakMouse & SC_PD_RANGE_L ) + aDrawRange.aStart.SetCol( nPosX ); + if ( nPagebreakMouse & SC_PD_RANGE_T ) + aDrawRange.aStart.SetRow( nPosY ); + if ( nPagebreakMouse & SC_PD_RANGE_R ) + { + if ( nPosX > 0 ) + aDrawRange.aEnd.SetCol( nPosX-1 ); + else + bHide = TRUE; + } + if ( nPagebreakMouse & SC_PD_RANGE_B ) + { + if ( nPosY > 0 ) + aDrawRange.aEnd.SetRow( nPosY-1 ); + else + bHide = TRUE; + } + if ( aDrawRange.aStart.Col() > aDrawRange.aEnd.Col() || + aDrawRange.aStart.Row() > aDrawRange.aEnd.Row() ) + bHide = TRUE; + } + + if ( !bPagebreakDrawn || bUp || aDrawRange != aPagebreakDrag ) + { + // zeichnen... + + if ( bPagebreakDrawn ) + { + // weginvertieren + DrawDragRect( aPagebreakDrag.aStart.Col(), aPagebreakDrag.aStart.Row(), + aPagebreakDrag.aEnd.Col(), aPagebreakDrag.aEnd.Row(), FALSE ); + bPagebreakDrawn = FALSE; + } + aPagebreakDrag = aDrawRange; + if ( !bUp && !bHide ) + { + // hininvertieren + DrawDragRect( aPagebreakDrag.aStart.Col(), aPagebreakDrag.aStart.Row(), + aPagebreakDrag.aEnd.Col(), aPagebreakDrag.aEnd.Row(), FALSE ); + bPagebreakDrawn = TRUE; + } + } + + // bei ButtonUp die Aenderung ausfuehren + + if ( bUp ) + { + ScViewFunc* pViewFunc = pViewData->GetView(); + ScDocShell* pDocSh = pViewData->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + USHORT nTab = pViewData->GetTabNo(); + + if ( bBreak ) + { + BOOL bColumn = ( nPagebreakMouse == SC_PD_BREAK_H ); + USHORT nNew = bColumn ? nPosX : nPosY; + if ( nNew != nPagebreakBreak ) + { + String aUndo = ScGlobal::GetRscString( STR_UNDO_DRAG_BREAK ); + pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo ); + + BOOL bGrow = !bHide && nNew > nPagebreakBreak; + if ( bColumn ) + { + if ( pDoc->GetColFlags( nPagebreakBreak, nTab ) & CR_MANUALBREAK ) + { + ScAddress aOldAddr( nPagebreakBreak, nPosY, nTab ); + pViewFunc->DeletePageBreak( TRUE, TRUE, &aOldAddr, FALSE ); + } + if ( !bHide && !bToEnd ) // am Ende nicht + { + ScAddress aNewAddr( nNew, nPosY, nTab ); + pViewFunc->InsertPageBreak( TRUE, TRUE, &aNewAddr, FALSE ); + } + if ( bGrow ) + { + // vorigen Break auf hart, und Skalierung aendern + if ( nPagebreakPrev > aPagebreakSource.aStart.Col() && + !(pDoc->GetColFlags( nPagebreakPrev, nTab ) & CR_MANUALBREAK) ) + { + ScAddress aPrev( nPagebreakPrev, nPosY, nTab ); + pViewFunc->InsertPageBreak( TRUE, TRUE, &aPrev, FALSE ); + } + + if (!pDocSh->AdjustPrintZoom( ScRange( + nPagebreakPrev,0,nTab, nNew-1,0,nTab ) )) + bGrow = FALSE; + } + } + else + { + if ( pDoc->GetRowFlags( nPagebreakBreak, nTab ) & CR_MANUALBREAK ) + { + ScAddress aOldAddr( nPosX, nPagebreakBreak, nTab ); + pViewFunc->DeletePageBreak( FALSE, TRUE, &aOldAddr, FALSE ); + } + if ( !bHide && !bToEnd ) // am Ende nicht + { + ScAddress aNewAddr( nPosX, nNew, nTab ); + pViewFunc->InsertPageBreak( FALSE, TRUE, &aNewAddr, FALSE ); + } + if ( bGrow ) + { + // vorigen Break auf hart, und Skalierung aendern + if ( nPagebreakPrev > aPagebreakSource.aStart.Row() && + !(pDoc->GetRowFlags( nPagebreakPrev, nTab ) & CR_MANUALBREAK) ) + { + ScAddress aPrev( nPosX, nPagebreakPrev, nTab ); + pViewFunc->InsertPageBreak( FALSE, TRUE, &aPrev, FALSE ); + } + + if (!pDocSh->AdjustPrintZoom( ScRange( + 0,nPagebreakPrev,nTab, 0,nNew-1,nTab ) )) + bGrow = FALSE; + } + } + + pDocSh->GetUndoManager()->LeaveListAction(); + + if (!bGrow) // sonst in AdjustPrintZoom schon passiert + { + pViewFunc->UpdatePageBreakData( TRUE ); + pDocSh->SetDocumentModified(); + } + } + } + else if ( bHide || aPagebreakDrag != aPagebreakSource ) + { + // Druckbereich setzen + + String aNewRanges; + USHORT nOldCount = pDoc->GetPrintRangeCount( nTab ); + if ( nOldCount ) + { + for (USHORT nPos=0; nPos<nOldCount; nPos++) + { + const ScRange* pOld = pDoc->GetPrintRange( nTab, nPos ); + if ( pOld ) + { + String aTemp; + if ( *pOld != aPagebreakSource ) + pOld->Format( aTemp, SCA_VALID ); + else if ( !bHide ) + aPagebreakDrag.Format( aTemp, SCA_VALID ); + if (aTemp.Len()) + { + if ( aNewRanges.Len() ) + aNewRanges += ';'; + aNewRanges += aTemp; + } + } + } + } + else if (!bHide) + aPagebreakDrag.Format( aNewRanges, SCA_VALID ); + + pViewFunc->SetPrintRanges( &aNewRanges, NULL, NULL, FALSE ); + } + } + + // Timer fuer Scrolling + + if (bTimer && !bUp) + pViewData->GetView()->SetTimer( this, rMEvt ); // Event wiederholen + else + pViewData->GetView()->ResetTimer(); +} + + + + diff --git a/sc/source/ui/view/gridwin3.cxx b/sc/source/ui/view/gridwin3.cxx new file mode 100644 index 000000000000..835cf4ca0757 --- /dev/null +++ b/sc/source/ui/view/gridwin3.cxx @@ -0,0 +1,500 @@ +/************************************************************************* + * + * $RCSfile: gridwin3.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <svx/svdoutl.hxx> +#include <svx/svdotext.hxx> +#include <svx/svdpagv.hxx> +#include <svx/sizeitem.hxx> +#include <sfx2/bindings.hxx> +#include <svtools/ptitem.hxx> + +#include "tabvwsh.hxx" +#include "gridwin.hxx" +#include "dbfunc.hxx" +#include "viewdata.hxx" +#include "output.hxx" +#include "drawview.hxx" +#include "fupoor.hxx" + +#include "drawutil.hxx" +#include "document.hxx" + + +// STATIC DATA ----------------------------------------------------------- + +// ----------------------------------------------------------------------- + + +BOOL ScGridWindow::DrawMouseButtonDown(const MouseEvent& rMEvt) +{ + BOOL bRet = FALSE; + FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr(); + if (pDraw && !pViewData->IsRefMode()) + { + pDraw->SetWindow( this ); + Point aLogicPos = PixelToLogic(rMEvt.GetPosPixel()); + if ( pDraw->IsDetectiveHit( aLogicPos ) ) + { + // auf Detektiv-Pfeilen gar nichts (Doppelklick wird bei ButtonUp ausgewertet) + bRet = TRUE; + } + else + { + bRet = pDraw->MouseButtonDown( rMEvt ); + if ( bRet ) + UpdateStatusPosSize(); + } + } + + // bei rechter Taste Draw-Aktion abbrechen + + ScDrawView* pDrView = pViewData->GetScDrawView(); + if ( pDrView && !rMEvt.IsLeft() && !bRet ) + { + pDrView->BrkAction(); + bRet = TRUE; + } + return bRet; +} + +BOOL ScGridWindow::DrawMouseButtonUp(const MouseEvent& rMEvt) +{ + BOOL bRet = FALSE; + FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr(); + if (pDraw && !pViewData->IsRefMode()) + { + pDraw->SetWindow( this ); + bRet = pDraw->MouseButtonUp( rMEvt ); + } + + return bRet; +} + +BOOL ScGridWindow::DrawMouseMove(const MouseEvent& rMEvt) +{ + FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr(); + if (pDraw && !pViewData->IsRefMode()) + { + pDraw->SetWindow( this ); + BOOL bRet = pDraw->MouseMove( rMEvt ); + if ( bRet ) + UpdateStatusPosSize(); + return bRet; + } + else + { + SetPointer( Pointer( POINTER_ARROW ) ); + return FALSE; + } +} + +void ScGridWindow::DrawEndAction() +{ + ScDrawView* pDrView = pViewData->GetScDrawView(); + if ( pDrView && pDrView->IsAction() ) + pDrView->BrkAction(); + + FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr(); + if (pDraw) + pDraw->StopDragTimer(); + + // ReleaseMouse beim Aufruf +} + +BOOL ScGridWindow::DrawCommand(const CommandEvent& rCEvt) +{ + ScDrawView* pDrView = pViewData->GetScDrawView(); + FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr(); + if (pDrView && pDraw && !pViewData->IsRefMode()) + { + pDraw->SetWindow( this ); + BYTE nUsed = pDraw->Command( rCEvt ); + if( nUsed == SC_CMD_USED ) + nButtonDown = 0; // MouseButtonUp wird verschluckt... + if( nUsed || pDrView->IsAction() ) + return TRUE; + } + + return FALSE; +} + +BOOL ScGridWindow::DrawKeyInput(const KeyEvent& rKEvt) +{ + ScDrawView* pDrView = pViewData->GetScDrawView(); + FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr(); + if (pDrView && pDraw && !pViewData->IsRefMode()) + { + pDraw->SetWindow( this ); + BOOL bOldMarked = pDrView->HasMarkedObj(); + if (pDraw->KeyInput( rKEvt )) + { + BOOL bUsed = TRUE; + BOOL bNewMarked = pDrView->HasMarkedObj(); + if ( !pViewData->GetView()->IsDrawSelMode() ) + if ( !bNewMarked ) + { + pViewData->GetViewShell()->SetDrawShell( FALSE ); + if ( !bOldMarked && + rKEvt.GetKeyCode().GetCode() == KEY_DELETE ) + bUsed = FALSE; // nichts geloescht + } + return bUsed; + } + } + + return FALSE; +} + +void ScGridWindow::DrawRedraw( ScOutputData& rOutputData, const Rectangle& rDrawingRect, + ScUpdateMode eMode, ULONG nLayer ) +{ + //! eMode auswerten !!! + + USHORT nObjectFlags = 0; + const ScViewOptions& rOpts = pViewData->GetOptions(); + if ( rOpts.GetObjMode( VOBJ_TYPE_OLE ) == VOBJ_MODE_SHOW ) + nObjectFlags |= SC_OBJECTS_OLE; + if ( rOpts.GetObjMode( VOBJ_TYPE_CHART ) == VOBJ_MODE_SHOW ) + nObjectFlags |= SC_OBJECTS_CHARTS; + if ( rOpts.GetObjMode( VOBJ_TYPE_DRAW ) == VOBJ_MODE_SHOW ) + nObjectFlags |= SC_OBJECTS_DRAWING; + + USHORT nDummyFlags = 0; + if ( rOpts.GetObjMode( VOBJ_TYPE_OLE ) == VOBJ_MODE_DUMMY ) + nDummyFlags |= SC_OBJECTS_OLE; + if ( rOpts.GetObjMode( VOBJ_TYPE_CHART ) == VOBJ_MODE_DUMMY ) + nDummyFlags |= SC_OBJECTS_CHARTS; + if ( rOpts.GetObjMode( VOBJ_TYPE_DRAW ) == VOBJ_MODE_DUMMY ) + nDummyFlags |= SC_OBJECTS_DRAWING; + + if (nObjectFlags || nDummyFlags) + { + if ( eMode == SC_UPDATE_CHANGED ) + rOutputData.DrawingSingle( (USHORT) nLayer, nObjectFlags, nDummyFlags ); + else + rOutputData.DrawSelectiveObjects( (USHORT) nLayer, rDrawingRect, + nObjectFlags, nDummyFlags ); + } +} + +void ScGridWindow::DrawSdrGrid( const Rectangle& rDrawingRect ) +{ + // Draw-Gitterlinien + + ScDrawView* pDrView = pViewData->GetView()->GetScDrawView(); + if ( pDrView && pDrView->IsGridVisible() ) + { + SdrPageView* pPV = pDrView->GetPageViewPvNum(0); + DBG_ASSERT(pPV, "keine PageView"); + if (pPV) + { + SetLineColor(COL_GRAY); + + pPV->DrawGrid( *this, rDrawingRect ); + } + } +} + +MapMode ScGridWindow::GetDrawMapMode( BOOL bForce ) +{ + MapMode aDrawMode = pViewData->GetLogicMode(); + + ScDrawView* pDrView = pViewData->GetView()->GetScDrawView(); + if ( pDrView || bForce ) + { + Fraction aScaleX; + Fraction aScaleY; + if (pDrView) + pDrView->GetScale( aScaleX, aScaleY ); + else + { + ScDocument* pDoc = pViewData->GetDocument(); + USHORT nTab = pViewData->GetTabNo(); + USHORT nEndCol = 0; + USHORT nEndRow = 0; + pDoc->GetTableArea( nTab, nEndCol, nEndRow ); + if (nEndCol<20) nEndCol = 20; + if (nEndRow<20) nEndRow = 20; + ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, this, + pViewData->GetZoomX(),pViewData->GetZoomY(), + pViewData->GetPPTX(),pViewData->GetPPTY(), + aScaleX,aScaleY ); + } + aDrawMode.SetScaleX(aScaleX); + aDrawMode.SetScaleY(aScaleY); + } + aDrawMode.SetOrigin(Point()); + aDrawMode.SetOrigin( PixelToLogic( pViewData->GetPixPos(eWhich), aDrawMode ) ); + + return aDrawMode; +} + +BOOL ScGridWindow::DrawBeforeScroll() +{ + ScDrawView* pDrView = pViewData->GetView()->GetScDrawView(); + + BOOL bXor = FALSE; + if (pDrView) + { + bXor=pDrView->IsShownXorVisible(this); + if (bXor) pDrView->HideShownXor(this); + } + return bXor; +} + +void ScGridWindow::DrawAfterScroll(BOOL bVal) +{ + Update(); // immer, damit das Verhalten mit/ohne DrawingLayer gleich ist + + ScDrawView* pDrView = pViewData->GetView()->GetScDrawView(); + if (pDrView) + { + if (bVal) + pDrView->ShowShownXor(this); + + OutlinerView* pOlView = pDrView->GetTextEditOutlinerView(); + if (pOlView && pOlView->GetWindow() == this) + pOlView->ShowCursor(FALSE); // ist beim Scrollen weggekommen + } +} + +void ScGridWindow::DrawMarks() +{ + ScDrawView* pDrView = pViewData->GetView()->GetScDrawView(); + if (pDrView) + pDrView->DrawMarks(this); +} + +BOOL ScGridWindow::NeedDrawMarks() +{ + ScDrawView* pDrView = pViewData->GetView()->GetScDrawView(); + return pDrView && pDrView->IsMarkHdlShown() && pDrView->HasMarkedObj(); +} + +void ScGridWindow::CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& rAddress) +{ + ScDrawView* pDrView = pViewData->GetView()->GetScDrawView(); + if (pDrView) + { + const ScViewOptions& rOpts = pViewData->GetOptions(); + if(rOpts.GetOption( VOPT_ANCHOR )) + { + Point aPos = pViewData->GetScrPos( rAddress.Col(), rAddress.Row(), eWhich, TRUE ); + aPos = PixelToLogic(aPos); + rHdl.AddHdl(new SdrHdl(aPos ,HDL_ANCHOR)); + } + } +} + +void ScGridWindow::OutlinerViewPaint( const Rectangle& rRect ) +{ + ScDrawView* pDrView = pViewData->GetView()->GetScDrawView(); + if (pDrView && pDrView->GetTextEditOutlinerView()) + { + Outliner* pOut = pDrView->GetTextEditOutliner(); + ULONG nViewCount = pOut ? pOut->GetViewCount() : 0; + for (ULONG nView=0; nView<nViewCount; nView++) + { + OutlinerView* pOlView = pOut->GetView(nView); + + if (pOlView && pOlView->GetWindow() == this) + { + BOOL bFrame = FALSE; + Rectangle aEditRect = pOlView->GetOutputArea(); + SdrObject* pEditObj = GetEditObject(); + if (pEditObj && pEditObj->ISA(SdrTextObj)) + { + SdrTextObj* pTextObj = (SdrTextObj*)pEditObj; + Rectangle aMinRect; + pTextObj->TakeTextEditArea(NULL,NULL,NULL,&aMinRect); // PageView Offset ist 0 + aEditRect.Union(aMinRect); + bFrame = pTextObj->IsTextFrame(); + } + + if ( aEditRect.IsOver( rRect ) ) + { + Rectangle aEffRect = rRect.GetIntersection( aEditRect ); + if (bFrame) + { + // RedrawOneLayer mit dem Text-Rechteck zeichnet nur die Outliner-View + // und den Text-Rahmen (an den kommt man sonst von aussen nicht heran). + + SdrPageView* pPV = pDrView->GetPageViewPvNum(0); + DBG_ASSERT(pPV, "keine PageView"); + if (pPV) + { + SdrLayerID nLayer = pEditObj ? pEditObj->GetLayer() : SC_LAYER_FRONT; + pPV->RedrawOneLayer( nLayer, aEffRect, this ); + } + } + else + { + SetFillColor( pOlView->GetBackgroundColor() ); + SetLineColor(); + DrawRect( aEffRect ); + pOlView->Paint( aEffRect ); + } + } + } + } + } +} + +SdrObject* ScGridWindow::GetEditObject() +{ + ScDrawView* pDrView = pViewData->GetView()->GetScDrawView(); + if (pDrView) + { + OutlinerView* pOlView = pDrView->GetTextEditOutlinerView(); + if (pOlView && pOlView->GetWindow() == this) + return pDrView->GetTextEditObject(); + } + + return NULL; +} + +void ScGridWindow::UpdateStatusPosSize() +{ + ScDrawView* pDrView = pViewData->GetView()->GetScDrawView(); + if (!pDrView) + return; // sollte dann gar nicht gerufen werden + + Point aPos = PixelToLogic(aCurMousePos); + pDrView->GetPageViewPvNum(0)->LogicToPagePos(aPos); + + SfxItemSet aSet(pViewData->GetViewShell()->GetPool(), SID_ATTR_POSITION, SID_ATTR_SIZE); + + // Position- und Groesse-Items + if ( pDrView->IsAction() ) + { + Rectangle aRect; + pDrView->TakeActionRect( aRect ); + + if ( aRect.IsEmpty() ) + aSet.Put( SfxPointItem(SID_ATTR_POSITION, aPos) ); + else + { + pDrView->GetPageViewPvNum(0)->LogicToPagePos(aRect); + aSet.Put( SfxPointItem( SID_ATTR_POSITION, aRect.TopLeft() ) ); + aSet.Put( SvxSizeItem( SID_ATTR_SIZE, + Size( aRect.Right() - aRect.Left(), + aRect.Bottom() - aRect.Top() ) ) ); + } + } + else + { + aSet.Put( SfxPointItem(SID_ATTR_POSITION, aPos) ); + + if ( pDrView->HasMarkedObj() ) + { + Rectangle aRect = pDrView->GetAllMarkedRect(); + pDrView->GetPageViewPvNum(0)->LogicToPagePos(aRect); + aSet.Put( SvxSizeItem( SID_ATTR_SIZE, + Size( aRect.Right() - aRect.Left(), + aRect.Bottom() - aRect.Top()) ) ); + } + else + aSet.Put( SvxSizeItem( SID_ATTR_SIZE, Size( 0, 0 ) ) ); + } + + SFX_BINDINGS().SetState(aSet); +} + +BOOL ScGridWindow::DrawHasMarkedObj() +{ + ScDrawView* p = pViewData->GetScDrawView(); + return p ? p->HasMarkedObj() : FALSE; +} + +void ScGridWindow::DrawStartTimer() +{ + ScDrawView* pDrView = pViewData->GetView()->GetScDrawView(); + if (pDrView) + { + /* jetzt in DrawMarks + USHORT nWinNum = pDrView->FindWin(this); + if (nWinNum!=SDRVIEWWIN_NOTFOUND) + pDrView->AfterInitRedraw(nWinNum); + */ + + pDrView->PostPaint(); + pDrView->RestartAfterPaintTimer(); + } +} + +void ScGridWindow::DrawMarkDropObj( SdrObject* pObj ) +{ + ScDrawView* pDrView = pViewData->GetView()->GetScDrawView(); + if (pDrView) + pDrView->MarkDropObj(pObj); +} + + + diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx new file mode 100644 index 000000000000..b15e9bf25825 --- /dev/null +++ b/sc/source/ui/view/gridwin4.cxx @@ -0,0 +1,1573 @@ +/************************************************************************* + * + * $RCSfile: gridwin4.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <svx/editview.hxx> +#include <so3/ipenv.hxx> + +#ifdef MAC +#include <svx/brshitem.hxx> +#endif + +#include "gridwin.hxx" +#include "viewdata.hxx" +#include "output.hxx" +#include "document.hxx" +#include "attrib.hxx" +#include "patattr.hxx" // InvertSimple +#include "dbcolect.hxx" +#include "docoptio.hxx" +#include "notemark.hxx" +#include "dbfunc.hxx" // oder GetPageBreakData an die ViewData +#include "scmod.hxx" +#include "inputhdl.hxx" +#include "rfindlst.hxx" +#include "hiranges.hxx" +#include "pagedata.hxx" +#include "docpool.hxx" +#include "globstr.hrc" +#include "docsh.hxx" // oder GetSfxInPlaceObject +#include "cbutton.hxx" +#include "invmerge.hxx" + +//#include "tabvwsh.hxx" //! Test !!!! + +//------------------------------------------------------------------------ + +void lcl_LimitRect( Rectangle& rRect, const Rectangle& rVisible ) +{ + if ( rRect.Top() < rVisible.Top()-1 ) rRect.Top() = rVisible.Top()-1; +// if ( rRect.Left() < rVisible.Left()-1 ) rRect.Left() = rVisible.Left()-1; + if ( rRect.Bottom() > rVisible.Bottom()+1 ) rRect.Bottom() = rVisible.Bottom()+1; +// if ( rRect.Right() > rVisible.Right()+1 ) rRect.Right() = rVisible.Right()+1; + + // #51122# auch wenn das inner-Rectangle nicht sichtbar ist, muss evtl. + // die Titelzeile gezeichnet werden, darum kein Rueckgabewert mehr. + // Wenn's weit daneben liegt, wird lcl_DrawOneFrame erst gar nicht gerufen. +} + +void lcl_DrawOneFrame( OutputDevice* pDev, const Rectangle& rInnerPixel, + const String& rTitle, const Color& rColor, BOOL bTextBelow, + double nPPTX, double nPPTY, const Fraction& rZoomY, + ScDocument* pDoc, ScViewData* pButtonViewData ) +{ + // pButtonViewData wird nur benutzt, um die Button-Groesse zu setzen, + // darf ansonsten NULL sein! + + Rectangle aInner = rInnerPixel; + Rectangle aVisible( Point(0,0), pDev->GetOutputSizePixel() ); + lcl_LimitRect( aInner, aVisible ); + + Rectangle aOuter = aInner; + long nHor = (long) ( SC_SCENARIO_HSPACE * nPPTX ); + long nVer = (long) ( SC_SCENARIO_VSPACE * nPPTY ); + aOuter.Left() -= nHor; + aOuter.Right() += nHor; + aOuter.Top() -= nVer; + aOuter.Bottom() += nVer; + + Font aFont; + ((const ScPatternAttr&)pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN)). + GetFont(aFont,pDev,&rZoomY); + aFont.SetAlign( ALIGN_TOP ); + pDev->SetFont( aFont ); + + Size aTextSize( pDev->GetTextWidth( rTitle ), pDev->GetTextHeight() ); + + if ( bTextBelow ) + aOuter.Bottom() += aTextSize.Height(); + else + aOuter.Top() -= aTextSize.Height(); + + pDev->SetLineColor(); + pDev->SetFillColor( rColor ); + // links, oben, rechts, unten + pDev->DrawRect( Rectangle( aOuter.Left(), aOuter.Top(), aInner.Left(), aOuter.Bottom() ) ); + pDev->DrawRect( Rectangle( aOuter.Left(), aOuter.Top(), aOuter.Right(), aInner.Top() ) ); + pDev->DrawRect( Rectangle( aInner.Right(), aOuter.Top(), aOuter.Right(), aOuter.Bottom() ) ); + pDev->DrawRect( Rectangle( aOuter.Left(), aInner.Bottom(), aOuter.Right(), aOuter.Bottom() ) ); + + long nButtonY = bTextBelow ? aInner.Bottom() : aOuter.Top(); + + ScDDComboBoxButton aComboButton((Window*)pDev); + aComboButton.SetOptSizePixel(); + long nBWidth = ( aComboButton.GetSizePixel().Width() * rZoomY.GetNumerator() ) + / rZoomY.GetDenominator(); + long nBHeight = nVer + aTextSize.Height() + 1; + Size aButSize( nBWidth, nBHeight ); + aComboButton.Draw( Point(aOuter.Right()-nBWidth+1, nButtonY), aButSize, Color( COL_BLACK ) ); + if (pButtonViewData) + pButtonViewData->SetScenButSize( aButSize ); + + BOOL bWasClip = FALSE; + Region aOldClip; + BOOL bClip = ( aTextSize.Width() > aOuter.Right() - nBWidth - aInner.Left() ); + if ( bClip ) + { + if (pDev->IsClipRegion()) + { + bWasClip = TRUE; + aOldClip = pDev->GetActiveClipRegion(); + } + pDev->SetClipRegion( Rectangle( aInner.Left(), nButtonY + nVer/2, + aOuter.Right() - nBWidth, nButtonY + nVer/2 + aTextSize.Height() ) ); + } + + pDev->DrawText( Point( aInner.Left(), nButtonY + nVer/2 ), rTitle ); + + if ( bClip ) + { + if ( bWasClip ) + pDev->SetClipRegion(aOldClip); + else + pDev->SetClipRegion(); + } + + pDev->SetFillColor(); + pDev->SetLineColor( COL_BLACK ); + pDev->DrawRect( aInner ); + pDev->DrawRect( aOuter ); +} + +void lcl_DrawScenarioFrames( OutputDevice* pDev, ScViewData* pViewData, ScSplitPos eWhich, + USHORT nX1, USHORT nY1, USHORT nX2, USHORT nY2 ) +{ + ScDocument* pDoc = pViewData->GetDocument(); + USHORT nTab = pViewData->GetTabNo(); + USHORT nTabCount = pDoc->GetTableCount(); + if ( nTab+1<nTabCount && pDoc->IsScenario(nTab+1) && !pDoc->IsScenario(nTab) ) + { + if ( nX1 ) --nX1; + if ( nY1>=2 ) nY1 -= 2; // Hack: Titelzeile beruehrt zwei Zellen + else if ( nY1 ) --nY1; + if ( nX2 < MAXCOL ) ++nX2; + if ( nY2 < MAXROW-1 ) nY2 += 2; // Hack: Titelzeile beruehrt zwei Zellen + else if ( nY2 < MAXROW ) ++nY2; + ScRange aViewRange( nX1,nY1,nTab, nX2,nY2,nTab ); + + //! Ranges an der Table cachen!!!! + + USHORT i; + ScMarkData aMarks; + for (i=nTab+1; i<nTabCount && pDoc->IsScenario(i); i++) + pDoc->MarkScenario( i, nTab, aMarks, FALSE, SC_SCENARIO_SHOWFRAME ); + ScRangeListRef xRanges = new ScRangeList; + aMarks.FillRangeListWithMarks( xRanges, FALSE ); + + USHORT nRangeCount = (USHORT)xRanges->Count(); + for (i=0; i<nRangeCount; i++) + { + ScRange aRange = *xRanges->GetObject(i); + // Szenario-Rahmen immer dann auf zusammengefasste Zellen erweitern, wenn + // dadurch keine neuen nicht-ueberdeckten Zellen mit umrandet werden + pDoc->ExtendTotalMerge( aRange ); + + //! -> Repaint beim Zusammenfassen erweitern !!! + + if ( aRange.Intersects( aViewRange ) ) //! Platz fuer Text/Button? + { + Point aStartPos = pViewData->GetScrPos( + aRange.aStart.Col(), aRange.aStart.Row(), eWhich, TRUE ); + Point aEndPos = pViewData->GetScrPos( + aRange.aEnd.Col()+1, aRange.aEnd.Row()+1, eWhich, TRUE ); + // auf dem Gitter: + aStartPos.X() -= 1; + aStartPos.Y() -= 1; + aEndPos.X() -= 1; + aEndPos.Y() -= 1; + + BOOL bTextBelow = ( aRange.aStart.Row() == 0 ); + + String aCurrent; + Color aColor( COL_LIGHTGRAY ); + for (USHORT nAct=nTab+1; nAct<nTabCount && pDoc->IsScenario(nAct); nAct++) + if ( pDoc->IsActiveScenario(nAct) && pDoc->HasScenarioRange(nAct,aRange) ) + { + String aDummyComment; + USHORT nDummyFlags; + pDoc->GetName( nAct, aCurrent ); + pDoc->GetScenarioData( nAct, aDummyComment, aColor, nDummyFlags ); + } + + if (!aCurrent.Len()) + aCurrent = ScGlobal::GetRscString( STR_EMPTYDATA ); + + //! eigener Text "(keins)" statt "(leer)" ??? + + lcl_DrawOneFrame( pDev, Rectangle( aStartPos, aEndPos ), + aCurrent, aColor, bTextBelow, + pViewData->GetPPTX(), pViewData->GetPPTY(), pViewData->GetZoomY(), + pDoc, pViewData ); + } + } + } +} + +//------------------------------------------------------------------------ + +void lcl_DrawHighlight( ScOutputData& rOutputData, ScViewData* pViewData, + ScHighlightRanges& rHighlightRanges ) +{ + USHORT nTab = pViewData->GetTabNo(); + ULONG nCount = rHighlightRanges.Count(); + for (ULONG i=0; i<nCount; i++) + { + ScHighlightEntry* pEntry = rHighlightRanges.GetObject( i ); + if (pEntry) + { + ScRange aRange = pEntry->aRef; + if ( nTab >= aRange.aStart.Tab() && nTab <= aRange.aEnd.Tab() ) + { + rOutputData.DrawRefMark( + aRange.aStart.Col(), aRange.aStart.Row(), + aRange.aEnd.Col(), aRange.aEnd.Row(), + pEntry->aColor, FALSE ); + } + } + } +} + +//------------------------------------------------------------------------ + +void ScGridWindow::DoInvertRect( const Rectangle& rPixel ) +{ + Invert( PixelToLogic(rPixel) ); + + if ( rPixel == aInvertRect ) + aInvertRect = Rectangle(); // aufheben + else + { + DBG_ASSERT( aInvertRect.IsEmpty(), "DoInvertRect nicht paarig" ); + + aInvertRect = rPixel; // neues Rechteck merken + } +} + +//------------------------------------------------------------------------ + +void __EXPORT ScGridWindow::Paint( const Rectangle& rRect ) +{ + ScDocShell* pDocSh = pViewData->GetDocShell(); + SvInPlaceEnvironment* pEnv = pDocSh->GetIPEnv(); + if (pEnv && pEnv->GetRectsChangedLockCount()) + { + Invalidate(rRect); + return; + } + + ScDocument* pDoc = pViewData->GetDocument(); + if ( pDoc->IsInInterpreter() ) + { + // via Reschedule, interpretierende Zellen nicht nochmal anstossen + // hier kein Invalidate, sonst kommt z.B. eine Error-Box nie an die Reihe + // (Bug 36381). Durch bNeedsRepaint wird spaeter alles nochmal gemalt. + + if ( bNeedsRepaint ) + { + //! Rechtecke zusammenfassen? + aRepaintPixel = Rectangle(); // mehrfach -> alles painten + } + else + { + bNeedsRepaint = TRUE; + aRepaintPixel = LogicToPixel(rRect); // nur betroffenen Bereich + } + return; + } + + if (bIsInPaint) + return; + + bIsInPaint = TRUE; + + Rectangle aPixRect = LogicToPixel( rRect ); + + USHORT nX1 = pViewData->GetPosX(eHWhich); + USHORT nY1 = pViewData->GetPosY(eVWhich); + + USHORT nTab = pViewData->GetTabNo(); + + double nPPTX = pViewData->GetPPTX(); + double nPPTY = pViewData->GetPPTY(); + + long nScrX = (long) ( pDoc->GetColWidth( nX1, nTab ) * nPPTX ); + while ( nScrX <= aPixRect.Left() && nX1 < MAXCOL ) + { + ++nX1; + nScrX += (long) ( pDoc->GetColWidth( nX1, nTab ) * nPPTX ); + } + USHORT nX2 = nX1; + while ( nScrX <= aPixRect.Right() && nX2 < MAXCOL ) + { + ++nX2; + nScrX += (long) ( pDoc->GetColWidth( nX2, nTab ) * nPPTX ); + } + + long nScrY = (long) ( pDoc->GetRowHeight( nY1, nTab ) * nPPTY ); + while ( nScrY <= aPixRect.Top() && nY1 < MAXROW ) + { + ++nY1; + nScrY += (long) ( pDoc->GetRowHeight( nY1, nTab ) * nPPTY ); + } + USHORT nY2 = nY1; + while ( nScrY <= aPixRect.Bottom() && nY2 < MAXROW ) + { + ++nY2; + nScrY += (long) ( pDoc->GetRowHeight( nY2, nTab ) * nPPTY ); + } + + Draw( nX1,nY1,nX2,nY2, SC_UPDATE_MARKS ); // nicht weiterzeichnen + + OutlinerViewPaint( rRect ); + + if (!aInvertRect.IsEmpty()) + Invert( PixelToLogic(aInvertRect) ); // auf das Clipping verlassen... + + bIsInPaint = FALSE; +} + +// +// Draw ---------------------------------------------------------------- +// + +void ScGridWindow::Draw( USHORT nX1, USHORT nY1, USHORT nX2, USHORT nY2, ScUpdateMode eMode ) +{ + BOOL bGridFirst = TRUE; //! entscheiden!!! + + if (pViewData->IsMinimized()) + return; + + PutInOrder( nX1, nX2 ); + PutInOrder( nY1, nY2 ); + USHORT i; + + DBG_ASSERT( nX2<=MAXCOL && nY2<=MAXROW, "GridWin Draw Bereich zu gross" ); + + USHORT nPosX = pViewData->GetPosX( eHWhich ); + USHORT nPosY = pViewData->GetPosY( eVWhich ); + if (nX2 < nPosX || nY2 < nPosY) + return; // unsichtbar + if (nX1 < nPosX) nX1 = nPosX; + if (nY1 < nPosY) nY1 = nPosY; + + USHORT nXRight = nPosX + pViewData->VisibleCellsX(eHWhich); + if (nXRight > MAXCOL) nXRight = MAXCOL; + USHORT nYBottom = nPosY + pViewData->VisibleCellsY(eVWhich); + if (nYBottom > MAXROW) nYBottom = MAXROW; + + if (nX1 > nXRight || nY1 > nYBottom) + return; // unsichtbar + if (nX2 > nXRight) nX2 = nXRight; + if (nY2 > nYBottom) nY2 = nYBottom; + + if ( eMode != SC_UPDATE_MARKS ) + if (nX2 < nXRight) + nX2 = nXRight; // zum Weiterzeichnen + + // ab hier kein return mehr + + ++nPaintCount; // merken, dass gemalt wird (wichtig beim Invertieren) + + ScDocShell* pDocSh = pViewData->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + USHORT nTab = pViewData->GetTabNo(); + + pDoc->ExtendHidden( nX1, nY1, nX2, nY2, nTab ); + + Point aScrPos = pViewData->GetScrPos( nX1, nY1, eWhich ); + USHORT nScrX = (USHORT) aScrPos.X(); + USHORT nScrY = (USHORT) aScrPos.Y(); + + USHORT nCurX = pViewData->GetCurX(); + USHORT nCurY = pViewData->GetCurY(); + USHORT nCurEndX = nCurX; + USHORT nCurEndY = nCurY; + pDoc->ExtendMerge( nCurX, nCurY, nCurEndX, nCurEndY, nTab ); + BOOL bCurVis = nCursorHideCount==0 && + ( nCurEndX+1 >= nX1 && nCurX <= nX2+1 && nCurEndY+1 >= nY1 && nCurY <= nY2+1 ); + + // AutoFill-Anfasser + if ( !bCurVis && nCursorHideCount==0 && bAutoMarkVisible && aAutoMarkPos.Tab() == nTab && + ( aAutoMarkPos.Col() != nCurX || aAutoMarkPos.Row() != nCurY ) ) + { + USHORT nHdlX = aAutoMarkPos.Col(); + USHORT nHdlY = aAutoMarkPos.Row(); + pDoc->ExtendMerge( nHdlX, nHdlY, nHdlX, nHdlY, nTab ); + bCurVis = ( nHdlX+1 >= nX1 && nHdlX <= nX2 && nHdlY+1 >= nY1 && nHdlY <= nY2 ); + // links und oben ist nicht betroffen + + //! AutoFill-Anfasser alleine (ohne Cursor) zeichnen ??? + } + + double nPPTX = pViewData->GetPPTX(); + double nPPTY = pViewData->GetPPTY(); + + const ScViewOptions& rOpts = pViewData->GetOptions(); + BOOL bFormulaMode = rOpts.GetOption( VOPT_FORMULAS ); + BOOL bMarkClipped = rOpts.GetOption( VOPT_CLIPMARKS ); + + // Datenblock + + RowInfo* pRowInfo = new RowInfo[ROWINFO_MAX]; + USHORT nArrCount = pDoc->FillInfo( pRowInfo, nX1, nY1, nX2, nY2, nTab, + nPPTX, nPPTY, FALSE, bFormulaMode, + &pViewData->GetMarkData() ); + + //-------------------------------------------------------------------- + + Fraction aZoomX = pViewData->GetZoomX(); + Fraction aZoomY = pViewData->GetZoomY(); + ScOutputData aOutputData( this, OUTTYPE_WINDOW, pRowInfo, nArrCount, pDoc, nTab, + nScrX, nScrY, nX1, nY1, nX2, nY2, nPPTX, nPPTY, + &aZoomX, &aZoomY ); + + aOutputData.SetSyntaxMode ( pViewData->IsSyntaxMode() ); + aOutputData.SetGridColor ( rOpts.GetGridColor() ); + aOutputData.SetShowNullValues ( rOpts.GetOption( VOPT_NULLVALS ) ); + aOutputData.SetShowFormulas ( bFormulaMode ); + aOutputData.SetShowSpellErrors ( !rOpts.IsHideAutoSpell() && + pDoc->GetDocOptions().IsAutoSpell() ); + aOutputData.SetMarkClipped ( bMarkClipped ); + + aOutputData.SetEditObject( GetEditObject() ); + aOutputData.SetViewShell( pViewData->GetViewShell() ); + + BOOL bGrid = rOpts.GetOption( VOPT_GRID ); + BOOL bPage = rOpts.GetOption( VOPT_PAGEBREAKS ); + + if ( eMode == SC_UPDATE_CHANGED ) + { + aOutputData.FindChanged(); + aOutputData.SetSingleGrid(TRUE); + } + + BOOL bPageMode = pViewData->IsPagebreakMode(); + if (bPageMode) // nach FindChanged + { + // SetPagebreakMode initialisiert auch bPrinted Flags + aOutputData.SetPagebreakMode( pViewData->GetView()->GetPageBreakData() ); + } + + EditView* pEditView = NULL; + BOOL bEditMode = pViewData->HasEditView(eWhich); + if ( bEditMode && pViewData->GetRefTabNo() == nTab ) + { + USHORT nEditCol; + USHORT nEditRow; + pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow ); + USHORT nEditEndCol = pViewData->GetEditEndCol(); + USHORT nEditEndRow = pViewData->GetEditEndRow(); + + if ( nEditEndCol >= nX1 && nEditCol <= nX2 && nEditEndRow >= nY1 && nEditRow <= nY2 ) + aOutputData.SetEditCell( nEditCol, nEditRow ); + else + bEditMode = FALSE; + + // nur Edit-Area zu zeichnen? + //! dann muss trotzdem noch der Rand / das Gitter gemalt werden! + +// if ( nEditCol <= nX1 && nEditEndCol >= nX2 && nEditRow <= nY1 && nEditEndRow >= nY2 ) +// bOnlyEdit = TRUE; + } + + MapMode aDrawMode = GetDrawMapMode(); + Rectangle aDrawingRect = PixelToLogic( Rectangle( Point( nScrX, nScrY ), + Size( aOutputData.GetScrW(), aOutputData.GetScrH() ) ), + aDrawMode ); + + if (bCurVis) + HideCursor(); + + if ( pDoc->HasBackgroundDraw( nTab, aDrawingRect ) ) + { + SetMapMode(MAP_PIXEL); + aOutputData.DrawClear(); + + // Drawing Hintergrund + + SetMapMode(aDrawMode); + DrawRedraw( aOutputData, aDrawingRect, eMode, SC_LAYER_BACK ); + } + else + aOutputData.SetSolidBackground(TRUE); + + SetMapMode(MAP_PIXEL); + aOutputData.DrawBackground(); + if ( bGridFirst && ( bGrid || bPage ) ) + aOutputData.DrawGrid( bGrid, bPage ); + if ( bPageMode ) + DrawPagePreview(nX1,nY1,nX2,nY2); + aOutputData.DrawShadow(); + aOutputData.DrawFrame(); + aOutputData.DrawStrings(); + + // Autofilter- und Pivot-Buttons + + DrawButtons( nX1, nY1, nX2, nY2, pRowInfo, nArrCount ); // Pixel + + // Notiz-Anzeiger + + if ( rOpts.GetOption( VOPT_NOTES ) ) + aOutputData.DrawNoteMarks(); + + // Edit-Zellen + + SetMapMode(pViewData->GetLogicMode(eWhich)); + aOutputData.DrawEdit(TRUE); + + SetMapMode(MAP_PIXEL); + if ( !bGridFirst && ( bGrid || bPage ) ) + { +// SetMapMode(MAP_PIXEL); + aOutputData.DrawGrid( bGrid, bPage ); + } + aOutputData.DrawClipMarks(); + + // Szenario / ChangeTracking muss auf jeden Fall nach DrawGrid sein, auch bei !bGridFirst + + //! Test, ob ChangeTrack-Anzeige aktiv ist + //! Szenario-Rahmen per View-Optionen abschaltbar? + + USHORT nTabCount = pDoc->GetTableCount(); + ScHighlightRanges* pHigh = pViewData->GetView()->GetHighlightRanges(); + BOOL bHasScenario = ( nTab+1<nTabCount && pDoc->IsScenario(nTab+1) && !pDoc->IsScenario(nTab) ); + BOOL bHasChange = ( pDoc->GetChangeTrack() != NULL ); + + if ( bHasChange || bHasScenario || pHigh != NULL ) + { +// SetMapMode(MAP_PIXEL); + + //! SetChangedClip() mit DrawMarks() zusammenfassen?? (anderer MapMode!) + + BOOL bAny = TRUE; + if (eMode == SC_UPDATE_CHANGED) + bAny = aOutputData.SetChangedClip(); + if (bAny) + { + if ( bHasChange ) + aOutputData.DrawChangeTrack(); + + if ( bHasScenario ) + lcl_DrawScenarioFrames( this, pViewData, eWhich, nX1,nY1,nX2,nY2 ); + + if ( pHigh ) + lcl_DrawHighlight( aOutputData, pViewData, *pHigh ); + + if (eMode == SC_UPDATE_CHANGED) + SetClipRegion(); + } + } + + // Drawing Vordergrund + + SetMapMode(aDrawMode); + DrawRedraw( aOutputData, aDrawingRect, eMode, SC_LAYER_FRONT ); + DrawRedraw( aOutputData, aDrawingRect, eMode, SC_LAYER_INTERN ); + DrawRedraw( aOutputData, aDrawingRect, eMode, SC_LAYER_CONTROLS ); // als letztes + DrawSdrGrid( aDrawingRect ); + + if (!bIsInScroll) // Drawing Markierungen + { + BOOL bDraw = TRUE; + if (eMode == SC_UPDATE_CHANGED) + bDraw = NeedDrawMarks() && aOutputData.SetChangedClip(); + if (bDraw) + { + DrawMarks(); + if (eMode == SC_UPDATE_CHANGED) + SetClipRegion(); + } + } + + SetMapMode(MAP_PIXEL); + // InPlace Edit-View + //! gleich beim Zeichnen leer lassen !!! + if ( bEditMode && (pViewData->GetRefTabNo() == pViewData->GetTabNo()) ) + { + USHORT nCol1 = pViewData->GetEditViewCol(); + USHORT nRow1 = pViewData->GetEditViewRow(); + USHORT nCol2 = pViewData->GetEditEndCol(); + USHORT nRow2 = pViewData->GetEditEndRow(); + SetLineColor(); + SetFillColor( pEditView->GetBackgroundColor() ); + Point aStart = pViewData->GetScrPos( nCol1, nRow1, eWhich ); + Point aEnd = pViewData->GetScrPos( nCol2+1, nRow2+1, eWhich ); + aEnd.X() -= 2; // Gitter nicht ueberschreiben + aEnd.Y() -= 2; + DrawRect( Rectangle( aStart,aEnd ) ); + + SetMapMode(pViewData->GetLogicMode()); + pEditView->Paint( PixelToLogic( Rectangle( Point( nScrX, nScrY ), + Size( aOutputData.GetScrW(), aOutputData.GetScrH() ) ) ) ); + SetMapMode(MAP_PIXEL); + } + + if (pViewData->IsActive()) + aOutputData.DrawMark( this ); + + if ( pViewData->IsRefMode() && nTab >= pViewData->GetRefStartZ() && nTab <= pViewData->GetRefEndZ() ) + { + // Schraffur beim Loeschen per AutoFill + if ( pViewData->GetRefType() == SC_REFTYPE_FILL ) + { + ScRange aRange; + if ( pViewData->GetDelMark( aRange ) ) + { + if ( aRange.aStart.Col() < nX1 ) aRange.aStart.SetCol(nX1); + if ( aRange.aEnd.Col() > nX2 ) aRange.aEnd.SetCol(nX2); + if ( aRange.aStart.Row() < nY1 ) aRange.aStart.SetRow(nY1); + if ( aRange.aEnd.Row() > nY2 ) aRange.aEnd.SetRow(nY2); + if ( aRange.aStart.Col() <= aRange.aEnd.Col() && + aRange.aStart.Row() <= aRange.aEnd.Row() ) + { + Point aStart = pViewData->GetScrPos( aRange.aStart.Col(), + aRange.aStart.Row(), eWhich ); + Point aEnd = pViewData->GetScrPos( aRange.aEnd.Col()+1, + aRange.aEnd.Row()+1, eWhich ); + aEnd.X() -= 1; + aEnd.Y() -= 1; + + // Markierung aufheben - roter Rahmen bleibt stehen + Rectangle aRect( aStart,aEnd ); + Invert( aRect, INVERT_HIGHLIGHT ); + + //! Delete-Bereich extra kennzeichnen?!?!? + } + } + } + + aOutputData.DrawRefMark( pViewData->GetRefStartX(), pViewData->GetRefStartY(), + pViewData->GetRefEndX(), pViewData->GetRefEndY(), + Color(COL_LIGHTRED), FALSE ); + } + + // Range-Finder + + ScInputHandler* pHdl = SC_MOD()->GetInputHdl( pViewData->GetViewShell() ); + if (pHdl) + { + ScRangeFindList* pRangeFinder = pHdl->GetRangeFindList(); + if ( pRangeFinder && !pRangeFinder->IsHidden() && + pRangeFinder->GetDocName() == pDocSh->GetTitle() ) + { + USHORT nCount = (USHORT)pRangeFinder->Count(); + for (USHORT i=0; i<nCount; i++) + { + ScRangeFindData* pData = pRangeFinder->GetObject(i); + if (pData) + { + ScRange aRef = pData->aRef; + aRef.Justify(); + if ( aRef.aStart.Tab() >= nTab && aRef.aEnd.Tab() <= nTab ) + aOutputData.DrawRefMark( aRef.aStart.Col(), aRef.aStart.Row(), + aRef.aEnd.Col(), aRef.aEnd.Row(), + Color( ScRangeFindList::GetColorName( i ) ), + TRUE ); + } + } + } + } + + // Rand (Pixel) + + if ( nX2==MAXCOL || nY2==MAXROW ) + { + Rectangle aPixRect = Rectangle( Point(), GetOutputSizePixel() ); + SetFillColor( COL_LIGHTGRAY ); + SetLineColor(); + if ( nX2==MAXCOL ) + { + Rectangle aDrawRect( aPixRect ); + aDrawRect.Left() = nScrX + aOutputData.GetScrW(); + if (aDrawRect.Right() >= aDrawRect.Left()) + DrawRect( aDrawRect ); + } + if ( nY2==MAXROW ) + { + Rectangle aDrawRect( aPixRect ); + aDrawRect.Top() = nScrY + aOutputData.GetScrH(); + if ( nX2==MAXCOL ) + aDrawRect.Right() = nScrX + aOutputData.GetScrW() - 1; // Ecke nicht doppelt + if (aDrawRect.Bottom() >= aDrawRect.Top()) + DrawRect( aDrawRect ); + } + } + + if (bCurVis) + ShowCursor(); + + for (i=0; i<nArrCount; i++) + delete[] pRowInfo[i].pCellInfo; + delete[] pRowInfo; + + if (pViewData->HasEditView(eWhich)) + SetMapMode(pViewData->GetLogicMode()); + else + SetMapMode(aDrawMode); + + if ( pNoteMarker ) + pNoteMarker->Draw(); // ueber den Cursor, im Drawing-MapMode + + DrawStartTimer(); // fuer bunte Handles ohne System-Clipping + + // + // Wenn waehrend des Paint etwas invertiert wurde (Selektion geaendert aus Basic-Macro), + // ist das jetzt durcheinandergekommen und es muss neu gemalt werden + // + + DBG_ASSERT(nPaintCount, "nPaintCount falsch"); + --nPaintCount; + if (!nPaintCount) + CheckNeedsRepaint(); +} + +void ScGridWindow::CheckNeedsRepaint() +{ + // called at the end of painting, and from timer after background text width calculation + + if (bNeedsRepaint) + { + bNeedsRepaint = FALSE; + if (aRepaintPixel.IsEmpty()) + Invalidate(); + else + Invalidate(PixelToLogic(aRepaintPixel)); + aRepaintPixel = Rectangle(); + } +} + +void ScGridWindow::DrawPagePreview( USHORT nX1, USHORT nY1, USHORT nX2, USHORT nY2 ) +{ + ScPageBreakData* pPageData = pViewData->GetView()->GetPageBreakData(); + if (pPageData) + { + ScDocument* pDoc = pViewData->GetDocument(); + USHORT nTab = pViewData->GetTabNo(); + Size aWinSize = GetOutputSizePixel(); + Color aManual( COL_LIGHTBLUE ); + Color aAutomatic( COL_BLUE ); + + Font aFont; + ((const ScPatternAttr&)pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN)).GetFont(aFont); + aFont.SetColor( Color( COL_LIGHTGRAY ) ); + // Groesse wird nach Bedarf eingestellt + String aPageText = ScGlobal::GetRscString( STR_PAGE ); + aPageText += ' '; + + USHORT nCount = pPageData->GetCount(); + for (USHORT nPos=0; nPos<nCount; nPos++) + { + ScPrintRangeData& rData = pPageData->GetData(nPos); + ScRange aRange = rData.GetPrintRange(); + if ( aRange.aStart.Col() <= nX2+1 && aRange.aEnd.Col()+1 >= nX1 && + aRange.aStart.Row() <= nY2+1 && aRange.aEnd.Row()+1 >= nY1 ) + { + // 3 Pixel Rahmen um den Druckbereich + // (mittlerer Pixel auf den Gitterlinien) + + SetLineColor(); + if (rData.IsAutomatic()) + SetFillColor( aAutomatic ); + else + SetFillColor( aManual ); + + Point aStart = pViewData->GetScrPos( + aRange.aStart.Col(), aRange.aStart.Row(), eWhich, TRUE ); + Point aEnd = pViewData->GetScrPos( + aRange.aEnd.Col() + 1, aRange.aEnd.Row() + 1, eWhich, TRUE ); + aStart.X() -= 2; + aStart.Y() -= 2; + + // Ueberlaeufe verhindern: + if ( aStart.X() < -10 ) aStart.X() = -10; + if ( aStart.Y() < -10 ) aStart.Y() = -10; + if ( aEnd.X() > aWinSize.Width() + 10 ) + aEnd.X() = aWinSize.Width() + 10; + if ( aEnd.Y() > aWinSize.Height() + 10 ) + aEnd.Y() = aWinSize.Height() + 10; + + DrawRect( Rectangle( aStart, Point(aEnd.X(),aStart.Y()+2) ) ); + DrawRect( Rectangle( aStart, Point(aStart.X()+2,aEnd.Y()) ) ); + DrawRect( Rectangle( Point(aStart.X(),aEnd.Y()-2), aEnd ) ); + DrawRect( Rectangle( Point(aEnd.X()-2,aStart.Y()), aEnd ) ); + + // Seitenumbrueche + //! anders darstellen (gestrichelt ????) + + USHORT nColBreaks = rData.GetPagesX(); + const USHORT* pColEnd = rData.GetPageEndX(); + USHORT nColPos; + for (nColPos=0; nColPos+1<nColBreaks; nColPos++) + { + USHORT nBreak = pColEnd[nColPos]+1; + if ( nBreak >= nX1 && nBreak <= nX2+1 ) + { + //! hidden suchen + if ( pDoc->GetColFlags( nBreak, nTab ) & CR_MANUALBREAK ) + SetFillColor( aManual ); + else + SetFillColor( aAutomatic ); + Point aBreak = pViewData->GetScrPos( + nBreak, aRange.aStart.Row(), eWhich, TRUE ); + DrawRect( Rectangle( aBreak.X()-1, aStart.Y(), aBreak.X(), aEnd.Y() ) ); + } + } + + USHORT nRowBreaks = rData.GetPagesY(); + const USHORT* pRowEnd = rData.GetPageEndY(); + USHORT nRowPos; + for (nRowPos=0; nRowPos+1<nRowBreaks; nRowPos++) + { + USHORT nBreak = pRowEnd[nRowPos]+1; + if ( nBreak >= nY1 && nBreak <= nY2+1 ) + { + //! hidden suchen + if ( pDoc->GetRowFlags( nBreak, nTab ) & CR_MANUALBREAK ) + SetFillColor( aManual ); + else + SetFillColor( aAutomatic ); + Point aBreak = pViewData->GetScrPos( + aRange.aStart.Col(), nBreak, eWhich, TRUE ); + DrawRect( Rectangle( aStart.X(), aBreak.Y()-1, aEnd.X(), aBreak.Y() ) ); + } + } + + // Seitenzahlen + + USHORT nPrStartY = aRange.aStart.Row(); + for (nRowPos=0; nRowPos<nRowBreaks; nRowPos++) + { + USHORT nPrEndY = pRowEnd[nRowPos]; + if ( nPrEndY >= nY1 && nPrStartY <= nY2 ) + { + USHORT nPrStartX = aRange.aStart.Col(); + for (nColPos=0; nColPos<nColBreaks; nColPos++) + { + USHORT nPrEndX = pColEnd[nColPos]; + if ( nPrEndX >= nX1 && nPrStartX <= nX2 ) + { + Point aPageStart = pViewData->GetScrPos( + nPrStartX, nPrStartY, eWhich, TRUE ); + Point aPageEnd = pViewData->GetScrPos( + nPrEndX+1,nPrEndY+1, eWhich, TRUE ); + + long nPageNo = rData.GetFirstPage(); + if ( rData.IsTopDown() ) + nPageNo += ((long)nColPos)*nRowBreaks+nRowPos; + else + nPageNo += ((long)nRowPos)*nColBreaks+nColPos; + String aPageStr = aPageText; + aPageStr += String::CreateFromInt32(nPageNo); + + // passende Fontgroesse suchen + aFont.SetSize( Size( 0,100 ) ); + SetFont( aFont ); + Size aSize100( GetTextWidth( aPageStr ), GetTextHeight() ); + // 40% der Breite oder 60% der Hoehe + long nSizeX = 40 * ( aPageEnd.X() - aPageStart.X() ) / + aSize100.Width(); + long nSizeY = 60 * ( aPageEnd.Y() - aPageStart.Y() ) / + aSize100.Height(); + aFont.SetSize( Size( 0,Min(nSizeX,nSizeY) ) ); + SetFont( aFont ); + + // zentriert ausgeben + Size aTextSize( GetTextWidth( aPageStr ), GetTextHeight() ); + Point aPos( (aPageStart.X()+aPageEnd.X()-aTextSize.Width())/2, + (aPageStart.Y()+aPageEnd.Y()-aTextSize.Height())/2 ); + DrawText( aPos, aPageStr ); + } + nPrStartX = nPrEndX + 1; + } + } + nPrStartY = nPrEndY + 1; + } + } + } + } +} + +void ScGridWindow::DrawRefMark( USHORT nRefStartX, USHORT nRefStartY, + USHORT nRefEndX, USHORT nRefEndY, + const Color& rColor, BOOL bHandle ) +{ + PutInOrder( nRefStartX, nRefEndX ); + PutInOrder( nRefStartY, nRefEndY ); + + USHORT nTab = pViewData->GetTabNo(); + ScDocument* pDoc = pViewData->GetDocument(); + if ( nRefStartX == nRefEndX && nRefStartY == nRefEndY ) + pDoc->ExtendMerge( nRefStartX, nRefStartY, nRefEndX, nRefEndY, nTab ); + + MapMode aOld = GetMapMode(); + SetMapMode(MAP_PIXEL); + + USHORT nCurX = pViewData->GetCurX(); + USHORT nCurY = pViewData->GetCurY(); + BOOL bHide = ( nCurX+1 >= nRefStartX && nCurX <= nRefEndX+1 && + nCurY+1 >= nRefStartY && nCurY <= nRefEndY+1 ); + + Point aStartPos = pViewData->GetScrPos( nRefStartX, nRefStartY, eWhich, TRUE ); + Point aEndPos = pViewData->GetScrPos( nRefEndX+1, nRefEndY+1, eWhich, TRUE ); + aEndPos.X() -= 2; + aEndPos.Y() -= 2; // nicht ueber das Gitter + + // begrenzen um Ueberlaeufe mit Paint-Fehlern zu vermeiden + long nMinY = -10; + long nMaxY = GetOutputSizePixel().Height() + 10; // mit Abstand fuer Handle + if (aStartPos.Y() < nMinY) aStartPos.Y() = nMinY; + if (aStartPos.Y() > nMaxY) aStartPos.Y() = nMaxY; + if (aEndPos.Y() > nMaxY) aEndPos.Y() = nMaxY; + if (aEndPos.Y() < nMinY) aEndPos.Y() = nMinY; + + if (bHide) + HideCursor(); + + SetLineColor( rColor ); + SetFillColor(); + DrawRect( Rectangle( aStartPos, aEndPos ) ); + + if ( bHandle ) + { + SetLineColor(); + SetFillColor( rColor ); + DrawRect( Rectangle( aEndPos.X()-3, aEndPos.Y()-3, + aEndPos.X()+1, aEndPos.Y()+1 ) ); + } + + if (bHide) + ShowCursor(); + + SetMapMode(aOld); +} + +void ScGridWindow::DrawButtons( USHORT nX1, USHORT nY1, USHORT nX2, USHORT nY2, + RowInfo* pRowInfo, USHORT nArrCount ) +{ + USHORT nCol, nRow, nArrY, nQuery; + USHORT nTab = pViewData->GetTabNo(); + ScDocument* pDoc = pViewData->GetDocument(); + ScDBData* pDBData = NULL; + ScQueryParam* pQueryParam = NULL; + + Point aOldPos = aComboButton.GetPosPixel(); // Zustand fuer MouseDown/Up + Size aOldSize = aComboButton.GetSizePixel(); // merken + Color aOldCol = aComboButton.GetColor(); + + for (nArrY=1; nArrY+1<nArrCount; nArrY++) + { + if ( pRowInfo[nArrY].bAutoFilter && pRowInfo[nArrY].bChanged ) + { + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + + nRow = pThisRowInfo->nRowNo; + + + for (nCol=nX1; nCol<=nX2; nCol++) + { + CellInfo* pInfo = &pThisRowInfo->pCellInfo[nCol+1]; + if ( pInfo->bAutoFilter && !pInfo->bHOverlapped && !pInfo->bVOverlapped ) + { + if (!pQueryParam) + pQueryParam = new ScQueryParam; + + BOOL bNewData = TRUE; + if (pDBData) + { + USHORT nStartCol; + USHORT nStartRow; + USHORT nEndCol; + USHORT nEndRow; + USHORT nAreaTab; + pDBData->GetArea( nAreaTab, nStartCol, nStartRow, nEndCol, nEndRow ); + if ( nCol >= nStartCol && nCol <= nEndCol && + nRow >= nStartRow && nRow <= nEndRow ) + bNewData = FALSE; + } + if (bNewData) + { + pDBData = pDoc->GetDBAtCursor( nCol, nRow, nTab ); + if (pDBData) + pDBData->GetQueryParam( *pQueryParam ); + else + DBG_ERROR("Auto-Filter-Button ohne DBData"); + } + + // pQueryParam kann nur MAXQUERY Eintraege enthalten + + BOOL bSimpleQuery = TRUE; + BOOL bColumnFound = FALSE; + if (!pQueryParam->bInplace) + bSimpleQuery = FALSE; + for (nQuery=0; nQuery<MAXQUERY && bSimpleQuery; nQuery++) + if (pQueryParam->GetEntry(nQuery).bDoQuery) + { + // hier nicht auf EQUAL beschraenken + // (auch bei ">1" soll der Spaltenkopf blau werden) + + if (pQueryParam->GetEntry(nQuery).nField == nCol) + bColumnFound = TRUE; + if (nQuery > 0) + if (pQueryParam->GetEntry(nQuery).eConnect != SC_AND) + bSimpleQuery = FALSE; + } + + Color aColor( ( bSimpleQuery && bColumnFound ) + ? COL_LIGHTBLUE + : COL_BLACK ); + long nSizeX; + long nSizeY; + + pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY ); + aComboButton.SetOptSizePixel(); + aComboButton.SetColor( aColor ); + DrawComboButton( pViewData->GetScrPos( nCol, nRow, eWhich ), + nSizeX, nSizeY ); + + aComboButton.SetPosPixel( aOldPos ); // alten Zustand + aComboButton.SetSizePixel( aOldSize ); // fuer MouseUp/Down + aComboButton.SetColor( aOldCol ); // wiederherstellen + } + } + } + + if ( pRowInfo[nArrY].bPushButton && pRowInfo[nArrY].bChanged ) + { + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + nRow = pThisRowInfo->nRowNo; + for (nCol=nX1; nCol<=nX2; nCol++) + { + CellInfo* pInfo = &pThisRowInfo->pCellInfo[nCol+1]; + if ( pInfo->bPushButton && !pInfo->bHOverlapped && !pInfo->bVOverlapped ) + { + Point aScrPos = pViewData->GetScrPos( nCol, nRow, eWhich ); + long nSizeX; + long nSizeY; + pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY ); + long nPosX = aScrPos.X(); + long nPosY = aScrPos.Y(); + + SetLineColor( COL_WHITE ); + DrawLine( Point(nPosX,nPosY), Point(nPosX,nPosY+nSizeY-1) ); + DrawLine( Point(nPosX,nPosY), Point(nPosX+nSizeX-1,nPosY) ); +// SetLineColor( SC_SMALL3DSHADOW ); + SetLineColor( COL_GRAY ); + DrawLine( Point(nPosX,nPosY+nSizeY-1), Point(nPosX+nSizeX-1,nPosY+nSizeY-1) ); + DrawLine( Point(nPosX+nSizeX-1,nPosY), Point(nPosX+nSizeX-1,nPosY+nSizeY-1) ); + SetLineColor( COL_BLACK ); +// SetFillColor(); +// DrawRect( Rectangle( nPosX-1,nPosY-1, nPosX+nSizeX-1,nPosY+nSizeY-1 ) ); + } + } + } + } + + delete pQueryParam; +} + +BOOL ScGridWindow::IsAutoFilterActive( USHORT nCol, USHORT nRow, USHORT nTab ) +{ + ScDocument* pDoc = pViewData->GetDocument(); + ScDBData* pDBData = pDoc->GetDBAtCursor( nCol, nRow, nTab ); + ScQueryParam aQueryParam; + + if ( pDBData ) + pDBData->GetQueryParam( aQueryParam ); + else + DBG_ERROR("Auto-Filter-Button ohne DBData"); + + BOOL bSimpleQuery = TRUE; + BOOL bColumnFound = FALSE; + USHORT nQuery; + + if ( !aQueryParam.bInplace ) + bSimpleQuery = FALSE; + + // aQueryParam kann nur MAXQUERY Eintraege enthalten + + for ( nQuery=0; nQuery<MAXQUERY && bSimpleQuery; nQuery++ ) + if ( aQueryParam.GetEntry(nQuery).bDoQuery ) + { + if (aQueryParam.GetEntry(nQuery).nField == nCol) + bColumnFound = TRUE; + + if (nQuery > 0) + if (aQueryParam.GetEntry(nQuery).eConnect != SC_AND) + bSimpleQuery = FALSE; + } + + return ( bSimpleQuery && bColumnFound ); +} + +void ScGridWindow::DrawComboButton( const Point& rCellPos, + long nCellSizeX, + long nCellSizeY, + BOOL bBtnIn ) +{ + Point aScrPos = rCellPos; + Size aBtnSize = aComboButton.GetSizePixel(); + + if ( nCellSizeX < aBtnSize.Width() || nCellSizeY < aBtnSize.Height() ) + { + if ( nCellSizeX < aBtnSize.Width() ) + aBtnSize.Width() = nCellSizeX; + + if ( nCellSizeY < aBtnSize.Height() ) + aBtnSize.Height() = nCellSizeY; + + aComboButton.SetSizePixel( aBtnSize ); + } + + aScrPos.X() += nCellSizeX - aBtnSize.Width(); + aScrPos.Y() += nCellSizeY - aBtnSize.Height(); + + aComboButton.SetPosPixel( aScrPos ); + + HideCursor(); + aComboButton.Draw( bBtnIn ); + ShowCursor(); +} + +void ScGridWindow::InvertSimple( USHORT nX1, USHORT nY1, USHORT nX2, USHORT nY2, + BOOL bTestMerge, BOOL bRepeat ) +{ + //! if INVERT_HIGHLIGHT swaps foreground and background (like on Mac), + //! use INVERT_HIGHLIGHT only for cells that have no background color set + //! (here and in ScOutputData::DrawMark) + + PutInOrder( nX1, nX2 ); + PutInOrder( nY1, nY2 ); + + ScMarkData& rMark = pViewData->GetMarkData(); + ScDocument* pDoc = pViewData->GetDocument(); + USHORT nTab = pViewData->GetTabNo(); + + USHORT nTestX2 = nX2; + USHORT nTestY2 = nY2; + if (bTestMerge) + pDoc->ExtendMerge( nX1,nY1, nTestX2,nTestY2, nTab ); + + USHORT nPosX = pViewData->GetPosX( eHWhich ); + USHORT nPosY = pViewData->GetPosY( eVWhich ); + if (nTestX2 < nPosX || nTestY2 < nPosY) + return; // unsichtbar + USHORT nRealX1 = nX1; + if (nX1 < nPosX) + nX1 = nPosX; + if (nY1 < nPosY) + nY1 = nPosY; + + USHORT nXRight = nPosX + pViewData->VisibleCellsX(eHWhich); + if (nXRight > MAXCOL) nXRight = MAXCOL; + USHORT nYBottom = nPosY + pViewData->VisibleCellsY(eVWhich); + if (nYBottom > MAXROW) nYBottom = MAXROW; + + if (nX1 > nXRight || nY1 > nYBottom) + return; // unsichtbar + if (nX2 > nXRight) nX2 = nXRight; + if (nY2 > nYBottom) nY2 = nYBottom; + + MapMode aOld = GetMapMode(); SetMapMode(MAP_PIXEL); // erst nach den return's !!! + + double nPPTX = pViewData->GetPPTX(); + double nPPTY = pViewData->GetPPTY(); + + ScInvertMerger aInvert( this ); + + Point aScrPos = pViewData->GetScrPos( nX1, nY1, eWhich ); + USHORT nScrY = (USHORT) aScrPos.Y(); + BOOL bWasHidden = FALSE; + for (USHORT nY=nY1; nY<=nY2; nY++) + { + BOOL bDoHidden = FALSE; // versteckte nachholen ? + USHORT nHeightTwips = pDoc->GetRowHeight( nY,nTab ); + BOOL bDoRow = ( nHeightTwips != 0 ); + if (bDoRow) + { + if (bTestMerge) + if (bWasHidden) // auf versteckte zusammengefasste testen + { +// --nY; // nY geaendert -> vorherige zeichnen + bDoHidden = TRUE; + bDoRow = TRUE; + } + + bWasHidden = FALSE; + } + else + { + bWasHidden = TRUE; + if (bTestMerge) + if (nY==nY2) + bDoRow = TRUE; // letzte Zeile aus Block + } + + if ( bDoRow ) + { + USHORT nLoopEndX = nX2; + if (nX2 < nX1) // Rest von zusammengefasst + { + USHORT nStartX = nX1; + while ( ((const ScMergeFlagAttr*)pDoc-> + GetAttr(nStartX,nY,nTab,ATTR_MERGE_FLAG))->IsHorOverlapped() ) + --nStartX; + if (nStartX <= nX2) + nLoopEndX = nX1; + } + + USHORT nEndY = nScrY + (USHORT) ( nHeightTwips * nPPTY ) - 1; + USHORT nScrX = (USHORT) aScrPos.X(); + for (USHORT nX=nX1; nX<=nLoopEndX; nX++) + { + USHORT nEndX = nScrX + (USHORT) ( pDoc->GetColWidth( nX,nTab ) * nPPTX ) - 1; + if (bTestMerge) + { + USHORT nThisY = nY; + const ScPatternAttr* pPattern = pDoc->GetPattern( nX, nY, nTab ); + const ScMergeFlagAttr* pMergeFlag = (const ScMergeFlagAttr*) &pPattern-> + GetItem(ATTR_MERGE_FLAG); + if ( pMergeFlag->IsVerOverlapped() && bDoHidden ) + { + while ( pMergeFlag->IsVerOverlapped() ? + (pDoc->GetRowFlags( nThisY-1, nTab ) & CR_HIDDEN) : FALSE ) + { + --nThisY; + pPattern = pDoc->GetPattern( nX, nThisY, nTab ); + pMergeFlag = (const ScMergeFlagAttr*) &pPattern->GetItem(ATTR_MERGE_FLAG); + } + } + + // nur Rest von zusammengefasster zu sehen ? + USHORT nThisX = nX; + if ( pMergeFlag->IsHorOverlapped() && nX == nPosX && nX > nRealX1 ) + { + while ( pMergeFlag->IsHorOverlapped() ) + { + --nThisX; + pPattern = pDoc->GetPattern( nThisX, nThisY, nTab ); + pMergeFlag = (const ScMergeFlagAttr*) &pPattern->GetItem(ATTR_MERGE_FLAG); + } + } + + if ( rMark.IsCellMarked( nThisX, nThisY, TRUE ) == bRepeat ) + { + if ( !pMergeFlag->IsOverlapped() ) + { + ScMergeAttr* pMerge = (ScMergeAttr*)&pPattern->GetItem(ATTR_MERGE); + if (pMerge->GetColMerge() || pMerge->GetRowMerge()) + { + Point aEndPos = pViewData->GetScrPos( + nThisX + pMerge->GetColMerge(), + nThisY + pMerge->GetRowMerge(), eWhich ); + if ( aEndPos.X() > nScrX && aEndPos.Y() > nScrY ) + { + aInvert.AddRect( Rectangle( nScrX,nScrY,aEndPos.X()-1,aEndPos.Y()-1 ) ); + } + } + else if ( nEndX >= nScrX && nEndY >= nScrY ) + { + aInvert.AddRect( Rectangle( nScrX,nScrY,nEndX,nEndY ) ); + } + } + } + } + else // !bTestMerge + { + if ( rMark.IsCellMarked( nX, nY, TRUE ) == bRepeat && + nEndX >= nScrX && nEndY >= nScrY ) + { + aInvert.AddRect( Rectangle( nScrX,nScrY,nEndX,nEndY ) ); + } + } + + nScrX = nEndX + 1; + } + nScrY = nEndY + 1; + } + } + + aInvert.Flush(); // before restoring MapMode + + SetMapMode(aOld); + + CheckInverted(); +} + +// ------------------------------------------------------------------------- + +void ScGridWindow::DrawDragRect( USHORT nX1, USHORT nY1, USHORT nX2, USHORT nY2, + BOOL bMarkDrop ) +{ + if ( nX2 < pViewData->GetPosX(eHWhich) || nY2 < pViewData->GetPosY(eVWhich) ) + return; + + // Nur auf dem Mac wird bei Drag&Drop nur die Einfuegeposition markiert +#ifndef MAC + bMarkDrop = FALSE; +#endif + + if (bMarkDrop) + nY2 = nY1; // nur 1 Zeile + + Update(); // wegen XOR + + MapMode aOld = GetMapMode(); SetMapMode(MAP_PIXEL); + + USHORT nTab = pViewData->GetTabNo(); + + USHORT nPosX = pViewData->GetPosX(WhichH(eWhich)); + USHORT nPosY = pViewData->GetPosY(WhichV(eWhich)); + if (nX1 < nPosX) nX1 = nPosX; + if (nX2 < nPosX) nX2 = nPosX; + if (nY1 < nPosY) nY1 = nPosY; + if (nY2 < nPosY) nY2 = nPosY; + + Point aScrPos( pViewData->GetScrPos( nX1, nY1, eWhich ) ); + + long nSizeXPix=0; + long nSizeYPix=0; + ScDocument* pDoc = pViewData->GetDocument(); + double nPPTX = pViewData->GetPPTX(); + double nPPTY = pViewData->GetPPTY(); + USHORT i; + + if (bMarkDrop) + { + aScrPos.X() -= 1; // nur die Position markieren + nSizeXPix += 2; + } + else + { + if (nX2<=MAXCOL && nX2>=nX1) + for (i=nX1; i<=nX2; i++) + nSizeXPix += (long) ( pDoc->GetColWidth( i, nTab ) * nPPTX ); + else + { + aScrPos.X() -= 1; + nSizeXPix += 2; + } + } + + if (nY2<=MAXROW && nY2>=nY1) + for (i=nY1; i<=nY2; i++) + nSizeYPix += (long) ( pDoc->GetRowHeight( i, nTab ) * nPPTY ); + else + { + aScrPos.Y() -= 1; + nSizeYPix += 2; + } + + aScrPos.X() -= 2; + aScrPos.Y() -= 2; + Rectangle aRect( aScrPos, Size( nSizeXPix + 3, nSizeYPix + 3 ) ); + + Invert(Rectangle( aRect.Left(), aRect.Top(), aRect.Left()+2, aRect.Bottom() )); + Invert(Rectangle( aRect.Right()-2, aRect.Top(), aRect.Right(), aRect.Bottom() )); + Invert(Rectangle( aRect.Left()+3, aRect.Top(), aRect.Right()-3, aRect.Top()+2 )); + Invert(Rectangle( aRect.Left()+3, aRect.Bottom()-2, aRect.Right()-3, aRect.Bottom() )); + + SetMapMode(aOld); +} + +// ------------------------------------------------------------------------- + +void ScGridWindow::DrawCursor() +{ + USHORT nTab = pViewData->GetTabNo(); + USHORT nX = pViewData->GetCurX(); + USHORT nY = pViewData->GetCurY(); + + // in verdeckten Zellen nicht zeichnen + + ScDocument* pDoc = pViewData->GetDocument(); + const ScPatternAttr* pPattern = pDoc->GetPattern(nX,nY,nTab); + const ScMergeFlagAttr& rMerge = (const ScMergeFlagAttr&) pPattern->GetItem(ATTR_MERGE_FLAG); + if (rMerge.IsOverlapped()) + return; + + // links/oben ausserhalb des Bildschirms ? + + BOOL bVis = ( nX>=pViewData->GetPosX(eHWhich) && nY>=pViewData->GetPosY(eVWhich) ); + if (!bVis) + { + USHORT nEndX = nX; + USHORT nEndY = nY; + ScDocument* pDoc = pViewData->GetDocument(); + const ScMergeAttr& rMerge = (const ScMergeAttr&) pPattern->GetItem(ATTR_MERGE); + if (rMerge.GetColMerge() > 1) + nEndX += rMerge.GetColMerge()-1; + if (rMerge.GetRowMerge() > 1) + nEndX += rMerge.GetRowMerge()-1; + bVis = ( nEndX>=pViewData->GetPosX(eHWhich) && nEndY>=pViewData->GetPosY(eVWhich) ); + } + + if ( bVis ) + { + // hier kein Update, da aus Paint gerufen und laut Zaehler Cursor schon da + // wenn Update noetig, dann bei Hide/Showcursor vor dem Hoch-/Runterzaehlen + + MapMode aOld = GetMapMode(); SetMapMode(MAP_PIXEL); + + Point aScrPos = pViewData->GetScrPos( nX, nY, eWhich, TRUE ); + + // rechts/unten ausserhalb des Bildschirms ? + + Size aOutSize = GetOutputSizePixel(); + if ( aScrPos.X() <= aOutSize.Width() + 2 && aScrPos.Y() <= aOutSize.Height() + 2 ) + { + long nSizeXPix; + long nSizeYPix; + pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix ); + + BOOL bFix = ( pViewData->GetHSplitMode() == SC_SPLIT_FIX || + pViewData->GetVSplitMode() == SC_SPLIT_FIX ); + if ( pViewData->GetActivePart()==eWhich || bFix ) + { + // old UNX version with two Invert calls causes flicker. + // if optimization is needed, a new flag should be added + // to InvertTracking + + aScrPos.X() -= 2; + aScrPos.Y() -= 2; + Rectangle aRect( aScrPos, Size( nSizeXPix + 3, nSizeYPix + 3 ) ); + + Invert(Rectangle( aRect.Left(), aRect.Top(), aRect.Left()+2, aRect.Bottom() )); + Invert(Rectangle( aRect.Right()-2, aRect.Top(), aRect.Right(), aRect.Bottom() )); + Invert(Rectangle( aRect.Left()+3, aRect.Top(), aRect.Right()-3, aRect.Top()+2 )); + Invert(Rectangle( aRect.Left()+3, aRect.Bottom()-2, aRect.Right()-3, aRect.Bottom() )); + } + else + { + Rectangle aRect( aScrPos, Size( nSizeXPix - 1, nSizeYPix - 1 ) ); + Invert( aRect ); + } + } + + SetMapMode(aOld); + } +} + + // AutoFill-Anfasser: + +void ScGridWindow::DrawAutoFillMark() +{ + if ( bAutoMarkVisible && aAutoMarkPos.Tab() == pViewData->GetTabNo() ) + { + USHORT nX = aAutoMarkPos.Col(); + USHORT nY = aAutoMarkPos.Row(); + + Point aFillPos = pViewData->GetScrPos( nX, nY, eWhich, TRUE ); + long nSizeXPix; + long nSizeYPix; + pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix ); + aFillPos.X() += nSizeXPix; + aFillPos.Y() += nSizeYPix; + + aFillPos.X() -= 2; + aFillPos.Y() -= 2; + Rectangle aFillRect( aFillPos, Size(6,6) ); + // Anfasser von Zeichenobjekten sind 7*7 + + MapMode aOld = GetMapMode(); SetMapMode(MAP_PIXEL); + Invert( aFillRect ); + SetMapMode(aOld); + } +} + +// ------------------------------------------------------------------------- + +void ScGridWindow::DataChanged( const DataChangedEvent& rDCEvt ) +{ + Window::DataChanged(rDCEvt); + + if ( (rDCEvt.GetType() == DATACHANGED_PRINTER) || + (rDCEvt.GetType() == DATACHANGED_DISPLAY) || + (rDCEvt.GetType() == DATACHANGED_FONTS) || + (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) || + ((rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE)) ) + { + if ( rDCEvt.GetType() == DATACHANGED_FONTS && eWhich == pViewData->GetActivePart() ) + pViewData->GetDocShell()->UpdateFontList(); + + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + // RepeatResize falls sich die Scrollbar-Groesse geaendert hat + if ( eWhich == pViewData->GetActivePart() ) // einmal reicht + pViewData->GetView()->RepeatResize(); + } + + Invalidate(); + } +} + + + + diff --git a/sc/source/ui/view/gridwin5.cxx b/sc/source/ui/view/gridwin5.cxx new file mode 100644 index 000000000000..36ed4121df8a --- /dev/null +++ b/sc/source/ui/view/gridwin5.cxx @@ -0,0 +1,369 @@ +/************************************************************************* + * + * $RCSfile: gridwin5.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#ifndef _EEITEM_HXX //autogen +#include <svx/eeitem.hxx> +#endif + +#define ITEMID_FIELD EE_FEATURE_FIELD +#include <svx/flditem.hxx> +#include <svx/svdobj.hxx> +#include <svx/svdpagv.hxx> +#include <svtools/imapobj.hxx> +#include <vcl/help.hxx> +#ifndef _URLOBJ_HXX +#include <tools/urlobj.hxx> +#endif + + +// INCLUDE --------------------------------------------------------------- + +#include "gridwin.hxx" +#include "viewdata.hxx" +#include "drawview.hxx" +#include "drwlayer.hxx" +#include "drawpage.hxx" +#include "document.hxx" +#include "notemark.hxx" +#include "chgtrack.hxx" +#include "chgviset.hxx" +#include "dbfunc.hxx" + + +// STATIC DATA ----------------------------------------------------------- + +// ----------------------------------------------------------------------- + +void __EXPORT ScGridWindow::RequestHelp(const HelpEvent& rHEvt) +{ + BOOL bDone = FALSE; + BOOL bHelpEnabled = ( rHEvt.GetMode() & ( HELPMODE_BALLOON | HELPMODE_QUICK ) ) != 0; + SdrView* pDrView = pViewData->GetScDrawView(); + + BOOL bDrawTextEdit = FALSE; + if (pDrView) + bDrawTextEdit = pDrView->IsTextEdit(); + + // Notizen + + if ( bHelpEnabled && !bDrawTextEdit ) + { + ScPostIt aNote; + Point aPosPixel = ScreenToOutputPixel( rHEvt.GetMousePosPixel() ); + ScDocument* pDoc = pViewData->GetDocument(); + short nPosX, nPosY; + pViewData->GetPosFromPixel( aPosPixel.X(), aPosPixel.Y(), eWhich, nPosX, nPosY ); + USHORT nTab = pViewData->GetTabNo(); + ScAddress aCellPos( nPosX, nPosY, nTab ); + + String aTrackText; + BOOL bLeftEdge = FALSE; + + // Change-Tracking + + ScChangeTrack* pTrack = pDoc->GetChangeTrack(); + ScChangeViewSettings* pSettings = pDoc->GetChangeViewSettings(); + if ( pTrack && pTrack->GetFirst() && pSettings && pSettings->ShowChanges()) + { + const ScChangeAction* pFound = NULL; + const ScChangeAction* pFoundContent = NULL; + const ScChangeAction* pFoundMove = NULL; + long nModified = 0; + const ScChangeAction* pAction = pTrack->GetFirst(); + while (pAction) + { + if ( pAction->IsVisible() && + ScViewUtil::IsActionShown( *pAction, *pSettings, *pDoc ) ) + { + ScChangeActionType eType = pAction->GetType(); + const ScBigRange& rBig = pAction->GetBigRange(); + if ( rBig.aStart.Tab() == nTab ) + { + ScRange aRange = rBig.MakeRange(); + + if ( eType == SC_CAT_DELETE_ROWS ) + aRange.aEnd.SetRow( aRange.aStart.Row() ); + else if ( eType == SC_CAT_DELETE_COLS ) + aRange.aEnd.SetCol( aRange.aStart.Col() ); + + if ( aRange.In( aCellPos ) ) + { + pFound = pAction; // der letzte gewinnt + switch ( eType ) + { + case SC_CAT_CONTENT : + pFoundContent = pAction; + break; + case SC_CAT_MOVE : + pFoundMove = pAction; + break; + } + ++nModified; + } + } + if ( eType == SC_CAT_MOVE ) + { + ScRange aRange = + ((const ScChangeActionMove*)pAction)-> + GetFromRange().MakeRange(); + if ( aRange.In( aCellPos ) ) + { + pFound = pAction; + ++nModified; + } + } + } + pAction = pAction->GetNext(); + } + + if ( pFound ) + { + if ( pFoundContent && pFound->GetType() != SC_CAT_CONTENT ) + pFound = pFoundContent; // Content gewinnt + if ( pFoundMove && pFound->GetType() != SC_CAT_MOVE && + pFoundMove->GetActionNumber() > + pFound->GetActionNumber() ) + pFound = pFoundMove; // Move gewinnt + + // bei geloeschten Spalten: Pfeil auf die linke Seite der Zelle + if ( pFound->GetType() == SC_CAT_DELETE_COLS ) + bLeftEdge = TRUE; + + DateTime aDT = pFound->GetDateTime(); + aTrackText = pFound->GetUser(); + aTrackText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ", " )); + aTrackText += ScGlobal::pScInternational->GetDate(aDT); + aTrackText += ' '; + aTrackText += ScGlobal::pScInternational->GetTime(aDT); + aTrackText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ":\n" )); + String aComStr=pFound->GetComment(); + if(aComStr.Len()>0) + { + aTrackText += aComStr; + aTrackText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "\n( " )); + } + pFound->GetDescription( aTrackText, pDoc ); + if(aComStr.Len()>0) + { + aTrackText +=')'; + } + } + } + + // Notiz nur, wenn sie nicht schon auf dem Drawing-Layer angezeigt wird: + if ( aTrackText.Len() || ( pDoc->GetNote( nPosX, nPosY, nTab, aNote ) && + !pDoc->HasNoteObject( nPosX, nPosY, nTab ) ) ) + { + BOOL bNew = TRUE; + BOOL bFast = FALSE; + if ( pNoteMarker ) // schon eine Notiz angezeigt + { + if ( pNoteMarker->GetDocPos() == aCellPos ) // dieselbe + bNew = FALSE; // dann stehenlassen + else + bFast = TRUE; // sonst sofort + } + if ( bNew ) + { + delete pNoteMarker; + + Window* pRight = NULL; + Window* pBottom = NULL; + Window* pDiagonal = NULL; + if ( pViewData->GetHSplitMode() == SC_SPLIT_FIX && eHWhich == SC_SPLIT_LEFT ) + { + ScSplitPos eRight = ( eVWhich == SC_SPLIT_TOP ) ? + SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT; + pRight = pViewData->GetView()->GetWindowByPos(eRight); + } + if ( pViewData->GetVSplitMode() == SC_SPLIT_FIX && eVWhich == SC_SPLIT_TOP ) + { + ScSplitPos eBottom = ( eHWhich == SC_SPLIT_LEFT ) ? + SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT; + pBottom = pViewData->GetView()->GetWindowByPos(eBottom); + } + if ( pRight && pBottom ) + pDiagonal = pViewData->GetView()->GetWindowByPos(SC_SPLIT_BOTTOMRIGHT); + + pNoteMarker = new ScNoteMarker( this, pRight, pBottom, pDiagonal, + pDoc, aCellPos, aTrackText, + GetDrawMapMode(TRUE), bLeftEdge, bFast ); + } + + Window::RequestHelp( rHEvt ); // alte Tip/Balloon ausschalten + bDone = TRUE; + } + } + + if (!bDone) + DELETEZ(pNoteMarker); + + // Image-Map / Text-URL + + if ( bHelpEnabled && !bDone && !nButtonDown ) // nur ohne gedrueckten Button + { + String aHelpText; + Rectangle aPixRect; + Point aPosPixel = ScreenToOutputPixel( rHEvt.GetMousePosPixel() ); + + if ( pDrView ) // URL / Image-Map + { + SdrViewEvent aVEvt; + MouseEvent aMEvt( aPosPixel, 1, 0, MOUSE_LEFT ); + SdrHitKind eHit = pDrView->PickAnything( aMEvt, SDRMOUSEBUTTONDOWN, aVEvt ); + + if ( eHit != SDRHIT_NONE && aVEvt.pObj != NULL ) + { + // URL fuer IMapObject unter Pointer ist Hilfetext + if ( ScDrawLayer::GetIMapInfo( aVEvt.pObj ) ) + { + Point aLogicPos = PixelToLogic( aPosPixel ); + IMapObject* pIMapObj = ScDrawLayer::GetHitIMapObject( + aVEvt.pObj, aLogicPos, *this ); + + if ( pIMapObj ) + { + // #44990# Bei ImageMaps die Description anzeigen, wenn vorhanden + aHelpText = pIMapObj->GetDescription(); + if (!aHelpText.Len()) + aHelpText = pIMapObj->GetURL(); + aPixRect = LogicToPixel(aVEvt.pObj->GetLogicRect()); + } + } + // URL in Textobjekt + if ( !aHelpText.Len() && aVEvt.eEvent == SDREVENT_EXECUTEURL ) + { + aHelpText = aVEvt.pURLField->GetURL(); + aPixRect = LogicToPixel(aVEvt.pObj->GetLogicRect()); + } + } + } + + if ( !aHelpText.Len() ) // Text-URL + { + String aUrl; + if ( GetEditUrl( aPosPixel, NULL, &aUrl, NULL ) ) + { + aHelpText = INetURLObject::decode( aUrl, INET_HEX_ESCAPE, + INetURLObject::DECODE_UNAMBIGUOUS ); + + ScDocument* pDoc = pViewData->GetDocument(); + short nPosX, nPosY; + USHORT nTab = pViewData->GetTabNo(); + pViewData->GetPosFromPixel( aPosPixel.X(), aPosPixel.Y(), eWhich, nPosX, nPosY ); + const ScPatternAttr* pPattern = pDoc->GetPattern( nPosX, nPosY, nTab ); + aPixRect = pViewData->GetEditArea( eWhich, nPosX, nPosY, this, pPattern ); + } + } + + if ( aHelpText.Len() ) + { + Rectangle aScreenRect(OutputToScreenPixel(aPixRect.TopLeft()), + OutputToScreenPixel(aPixRect.BottomRight())); + + if ( rHEvt.GetMode() & HELPMODE_BALLOON ) + Help::ShowBalloon(this,rHEvt.GetMousePosPixel(), aScreenRect, aHelpText); + else if ( rHEvt.GetMode() & HELPMODE_QUICK ) + Help::ShowQuickHelp(this,aScreenRect, aHelpText); + + bDone = TRUE; + } + } + + // Basic-Controls + + if ( pDrView && bHelpEnabled && !bDone ) + { + SdrPageView* pPV = pDrView->GetPageViewPvNum(0); + DBG_ASSERT( pPV, "SdrPageView* ist NULL" ); + if (pPV) + bDone = ((ScDrawPage*)pPV->GetPage())->RequestHelp( this, pDrView, rHEvt ); + } + + // Wenn QuickHelp fuer AutoFill angezeigt wird, nicht wieder wegnehmen lassen + + if ( nMouseStatus == SC_GM_TABDOWN && pViewData->GetRefType() == SC_REFTYPE_FILL && + Help::IsQuickHelpEnabled() ) + bDone = TRUE; + + if (!bDone) + Window::RequestHelp( rHEvt ); +} + +BOOL ScGridWindow::IsMyModel(SdrEditView* pSdrView) +{ + return pSdrView && + pSdrView->GetModel() == pViewData->GetDocument()->GetDrawLayer(); +} + +void ScGridWindow::HideNoteMarker() +{ + DELETEZ(pNoteMarker); +} + diff --git a/sc/source/ui/view/hdrcont.cxx b/sc/source/ui/view/hdrcont.cxx new file mode 100644 index 000000000000..f17668015242 --- /dev/null +++ b/sc/source/ui/view/hdrcont.cxx @@ -0,0 +1,829 @@ +/************************************************************************* + * + * $RCSfile: hdrcont.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include <sfx2/dispatch.hxx> +#include <vcl/help.hxx> + +#include "scresid.hxx" +#include "sc.hrc" +#include "tabvwsh.hxx" +#include "hdrcont.hxx" +#include "scmod.hxx" // Optionen +#include "inputopt.hxx" // Optionen +#include "gridmerg.hxx" + +// ----------------------------------------------------------------------- + +#define SC_DRAG_MIN 2 + +// passes in paint +// (selection left/right must be first because the continuous lines +// are partly overwritten later) + +#define SC_HDRPAINT_SEL_RIGHT 0 +#define SC_HDRPAINT_SEL_LEFT 1 +#define SC_HDRPAINT_TOP 2 +#define SC_HDRPAINT_SEL_TOP 3 +#define SC_HDRPAINT_SEL_BOTTOM 4 +#define SC_HDRPAINT_BOTTOM 5 +#define SC_HDRPAINT_TEXT 6 +#define SC_HDRPAINT_COUNT 7 + +//================================================================== + +ScHeaderControl::ScHeaderControl( Window* pParent, SelectionEngine* pSelectionEngine, + USHORT nNewSize, USHORT nNewFlags ) : + Window ( pParent ), + pSelEngine ( pSelectionEngine ), + nSize ( nNewSize ), + nFlags ( nNewFlags ), + bVertical ( (nNewFlags & HDR_VERTICAL) != 0 ), + bDragging ( FALSE ), + bIgnoreMove ( FALSE ), + nMarkStart ( 0 ), + nMarkEnd ( 0 ), + bMarkRange ( FALSE ) +{ + aNormFont = GetFont(); + aNormFont.SetTransparent( TRUE ); //! WEIGHT_NORMAL hart setzen ??? + aBoldFont = aNormFont; + aBoldFont.SetWeight( WEIGHT_BOLD ); + + SetFont(aBoldFont); + bBoldSet = TRUE; + + Size aSize = LogicToPixel( Size( + GetTextWidth( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("8888")) ), + GetTextHeight() ) ); + aSize.Width() += 4; // Platz fuer hervorgehobene Umrandung + aSize.Height() += 3; + SetSizePixel( aSize ); + + nWidth = nSmallWidth = aSize.Width(); + nBigWidth = LogicToPixel( Size( GetTextWidth( + String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("88888")) ), 0 ) ).Width() + 4; + + SetBackground(); // sonst Probleme auf OS/2 !?!?! +} + +void ScHeaderControl::SetWidth( long nNew ) +{ + DBG_ASSERT( bVertical, "SetDigits nur fuer Zeilenkoepfe erlaubt" ); + if ( nNew != nWidth ) + { + Size aSize( nNew, GetSizePixel().Height() ); // Hoehe nicht aendern + SetSizePixel( aSize ); + + nWidth = nNew; + + Invalidate(); // neu zentrieren + } +} + +__EXPORT ScHeaderControl::~ScHeaderControl() +{ +} + +void ScHeaderControl::DoPaint( USHORT nStart, USHORT nEnd ) +{ + Rectangle aRect( Point(0,0), GetOutputSizePixel() ); + if ( bVertical ) + { + aRect.Top() = GetScrPos( nStart ); + aRect.Bottom() = GetScrPos( nEnd+1 )-1; + } + else + { + aRect.Left() = GetScrPos( nStart ); + aRect.Right() = GetScrPos( nEnd+1 )-1; + } + Invalidate(aRect); +} + +void ScHeaderControl::SetMark( BOOL bNewSet, USHORT nNewStart, USHORT nNewEnd ) +{ + BOOL bEnabled = SC_MOD()->GetInputOptions().GetMarkHeader(); //! cachen? + if (!bEnabled) + bNewSet = FALSE; + + // Variablen setzen + + BOOL bOldSet = bMarkRange; + USHORT nOldStart = nMarkStart; + USHORT nOldEnd = nMarkEnd; + PutInOrder( nNewStart, nNewEnd ); + bMarkRange = bNewSet; + nMarkStart = nNewStart; + nMarkEnd = nNewEnd; + + // Paint + + if ( bNewSet ) + { + if ( bOldSet ) + { + if ( nNewStart == nOldStart ) + { + if ( nNewEnd != nOldEnd ) + DoPaint( Min( nNewEnd, nOldEnd ) + 1, Max( nNewEnd, nOldEnd ) ); + // sonst nix + } + else if ( nNewEnd == nOldEnd ) + DoPaint( Min( nNewStart, nOldStart ), Max( nNewStart, nOldStart ) - 1 ); + else if ( nNewStart > nOldEnd || nNewEnd < nOldStart ) + { + // zwei Bereiche... + DoPaint( nOldStart, nOldEnd ); + DoPaint( nNewStart, nNewEnd ); + } + else // irgendwie ueberlappend... (kommt eh nicht oft vor) + DoPaint( Min( nNewStart, nOldStart ), Max( nNewEnd, nOldEnd ) ); + } + else + DoPaint( nNewStart, nNewEnd ); // komplett neu + } + else if ( bOldSet ) + DoPaint( nOldStart, nOldEnd ); // komplett aufheben + + // sonst war nix, is nix +} + +long ScHeaderControl::GetScrPos( USHORT nEntryNo ) +{ + long nScrPos; + + long nMax = ( bVertical ? GetOutputSizePixel().Height() : GetOutputSizePixel().Width() ) + 1; + if (nEntryNo >= nSize) + nScrPos = nMax; + else + { + nScrPos = 0; + for (USHORT i=GetPos(); i<nEntryNo && nScrPos<nMax; i++) + { + USHORT nAdd = GetEntrySize(i); + if (nAdd) + nScrPos += nAdd; + else + { + USHORT nHidden = GetHiddenCount(i); + if (nHidden) + i += nHidden - 1; + } + } + } + + return nScrPos; +} + +// +// Paint +// + +void __EXPORT ScHeaderControl::Paint( const Rectangle& rRect ) +{ + // fuer VCL ist es wichtig, wenig Aufrufe zu haben, darum werden die aeusseren + // Linien zusammengefasst + + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + + SetTextColor( rStyleSettings.GetButtonTextColor() ); + SetFillColor( rStyleSettings.GetFaceColor() ); + SetLineColor(); + DrawRect( rRect ); + + const FunctionSet* pFuncSet = pSelEngine->GetFunctionSet(); + String aString; + USHORT nBarSize; + Point aScrPos; + Point aEndPos; + Size aTextSize; + Size aSize = GetOutputSizePixel(); + + if (bVertical) + nBarSize = (USHORT) GetSizePixel().Width(); + else + nBarSize = (USHORT) GetSizePixel().Height(); + + USHORT nPos = GetPos(); + + long nPStart = bVertical ? rRect.Top() : rRect.Left(); + long nPEnd = bVertical ? rRect.Bottom() : rRect.Right(); + + // aeussere Linien komplett durchzeichnen + // Zuerst Ende der letzten Zelle finden + + long nLineEnd = -1; + for (USHORT i=nPos; i<nSize; i++) + { + USHORT nSizePix = GetEntrySize( i ); + if (nSizePix) + { + nLineEnd += nSizePix; + if ( nLineEnd > nPEnd ) + { + nLineEnd = nPEnd; + break; + } + } + else + { + USHORT nHidden = GetHiddenCount(i); + if (nHidden) + i += nHidden - 1; + } + } + + if ( nLineEnd >= nPStart ) + { + SetLineColor( rStyleSettings.GetLightColor() ); + if (bVertical) + DrawLine( Point( 0, nPStart ), Point( 0, nLineEnd ) ); + else + DrawLine( Point( nPStart, 0 ), Point( nLineEnd, 0 ) ); + SetLineColor( rStyleSettings.GetDarkShadowColor() ); + if (bVertical) + DrawLine( Point( nBarSize-1, nPStart ), Point( nBarSize-1, nLineEnd ) ); + else + DrawLine( Point( nPStart, nBarSize-1 ), Point( nLineEnd, nBarSize-1 ) ); + } + + // + // loop through entries several times to avoid changing the line color too often + // and to allow merging of lines + // + + ScGridMerger aGrid( this, 1, 1 ); + for (USHORT nPass = 0; nPass < SC_HDRPAINT_COUNT; nPass++) + { + // set line color etc. before entry loop + switch ( nPass ) + { + case SC_HDRPAINT_SEL_RIGHT: + SetLineColor( rStyleSettings.GetShadowColor() ); + break; + case SC_HDRPAINT_SEL_LEFT: + SetLineColor( rStyleSettings.GetLightColor() ); + break; + case SC_HDRPAINT_TOP: + SetLineColor( rStyleSettings.GetLightColor() ); + break; + case SC_HDRPAINT_SEL_TOP: + SetLineColor( rStyleSettings.GetLightColor() ); + break; + case SC_HDRPAINT_SEL_BOTTOM: + SetLineColor( rStyleSettings.GetShadowColor() ); + break; + case SC_HDRPAINT_BOTTOM: + SetLineColor( rStyleSettings.GetDarkShadowColor() ); + break; + //case SC_HDRPAINT_TEXT: + // break; + } + + USHORT nCount=0; + long nScrPos=0; + do + { + if (bVertical) + aScrPos = Point( 0, nScrPos ); + else + aScrPos = Point( nScrPos, 0 ); + + USHORT nEntryNo = nCount + nPos; + if ( nEntryNo >= nSize ) // MAXCOL/MAXROW + nScrPos = nPEnd + 1; // ausserhalb -> Ende + else + { + USHORT nSizePix = GetEntrySize( nEntryNo ); + + if (nSizePix == 0) + { + USHORT nHidden = GetHiddenCount(nEntryNo); + if (nHidden) + nCount += nHidden - 1; + } + else if (nScrPos+nSizePix >= nPStart) + { + Point aEndPos(aScrPos); + if (bVertical) + aEndPos = Point( aScrPos.X()+nBarSize-1, aScrPos.Y()+nSizePix-1 ); + else + aEndPos = Point( aScrPos.X()+nSizePix-1, aScrPos.Y()+nBarSize-1 ); + + BOOL bMark = bMarkRange && nEntryNo >= nMarkStart && nEntryNo <= nMarkEnd; + + switch ( nPass ) + { + case SC_HDRPAINT_SEL_LEFT: + if (bMark) + { + // continuous line - partly overwritten later + if (bVertical) + aGrid.AddVerLine( aScrPos.X()+1, aScrPos.Y(), aEndPos.Y() ); + else + aGrid.AddHorLine( aScrPos.X(), aEndPos.X(), aScrPos.Y()+1 ); + } + break; + + case SC_HDRPAINT_SEL_TOP: + if (bMark) + { + if (bVertical) + aGrid.AddHorLine( aScrPos.X()+1, aEndPos.X()-2, aScrPos.Y()+1 ); + else + aGrid.AddVerLine( aScrPos.X()+1, aScrPos.Y()+1, aEndPos.Y()-2 ); + } + break; + + case SC_HDRPAINT_SEL_RIGHT: + if (bMark) + { + // continuous line - partly overwritten later + if (bVertical) + aGrid.AddVerLine( aEndPos.X()-1, aScrPos.Y(), aEndPos.Y() ); + else + aGrid.AddHorLine( aScrPos.X(), aEndPos.X(), aEndPos.Y()-1 ); + } + break; + + case SC_HDRPAINT_SEL_BOTTOM: + if (bMark) + { + if (bVertical) + aGrid.AddHorLine( aScrPos.X()+1, aEndPos.X()-1, aEndPos.Y()-1 ); + else + aGrid.AddVerLine( aEndPos.X()-1, aScrPos.Y()+1, aEndPos.Y()-1 ); + } + break; + + case SC_HDRPAINT_TOP: + if (bVertical) + aGrid.AddHorLine( aScrPos.X(), aEndPos.X()-1, aScrPos.Y() ); + else + aGrid.AddVerLine( aScrPos.X(), aScrPos.Y(), aEndPos.Y()-1 ); + break; + + case SC_HDRPAINT_BOTTOM: + if (bVertical) + aGrid.AddHorLine( aScrPos.X(), aEndPos.X(), aEndPos.Y() ); + else + aGrid.AddVerLine( aEndPos.X(), aScrPos.Y(), aEndPos.Y() ); + + // thick bottom for hidden rows + // (drawn directly, without aGrid) + if ( nEntryNo+1 < nSize ) + if ( GetEntrySize(nEntryNo+1)==0 ) + { + if (bVertical) + DrawLine( Point(aScrPos.X(),aEndPos.Y()-1), + Point(aEndPos.X(),aEndPos.Y()-1) ); + else + DrawLine( Point(aEndPos.X()-1,aScrPos.Y()), + Point(aEndPos.X()-1,aEndPos.Y()) ); + } + break; + + case SC_HDRPAINT_TEXT: + { + if ( bMark != bBoldSet ) + { + if (bMark) + SetFont(aBoldFont); + else + SetFont(aNormFont); + bBoldSet = bMark; + } + aString = GetEntryText( nEntryNo ); + aTextSize.Width() = GetTextWidth( aString ); + aTextSize.Height() = GetTextHeight(); + + Point aTxtPos(aScrPos); + if (bVertical) + { + aTxtPos.X() += (nBarSize-aTextSize.Width())/2; + aTxtPos.Y() += (nSizePix-aTextSize.Height())/2; + } + else + { + aTxtPos.X() += (nSizePix-aTextSize.Width()+1)/2; + aTxtPos.Y() += (nBarSize-aTextSize.Height()+1)/2; + } + DrawText( aTxtPos, aString ); + } + break; + } + + // bei Selektion der ganzen Zeile/Spalte: + // InvertRect( Rectangle( aScrPos, aEndPos ) ); + } + nScrPos += nSizePix; // auch wenn noch oberhalb + } + ++nCount; + } + while ( nScrPos <= nPEnd ); + + aGrid.Flush(); + } +} + +// +// Maus - Handling +// + +USHORT ScHeaderControl::GetMousePos( const MouseEvent& rMEvt, BOOL& rBorder ) +{ + BOOL bFound=FALSE; + USHORT nCount = 1; + USHORT nPos = GetPos(); + USHORT nHitNo = nPos; + long nScrPos; + long nMousePos = bVertical ? rMEvt.GetPosPixel().Y() : rMEvt.GetPosPixel().X(); + long nDif; + Size aSize = GetOutputSizePixel(); + + nScrPos = GetScrPos( nPos ) - 1; + do + { + USHORT nEntryNo = nCount + nPos; + +// nScrPos = GetScrPos( nEntryNo ) - 1; + + if (nEntryNo >= nSize) + nScrPos = ( bVertical ? GetOutputSizePixel().Height() : GetOutputSizePixel().Width() ) + 1; + else + nScrPos += GetEntrySize( nEntryNo - 1 ); //! GetHiddenCount() ?? + + nDif = nMousePos - nScrPos; + if (nDif >= -2 && nDif <= 2 && nCount > 0) + { + bFound=TRUE; + nHitNo=nEntryNo-1; + } + else if (nDif >= 0) + nHitNo = nEntryNo; + ++nCount; + } + while ( nScrPos < ( bVertical ? aSize.Height() : aSize.Width() ) && nDif > 0 ); + + rBorder = bFound; + return nHitNo; +} + +void __EXPORT ScHeaderControl::MouseButtonDown( const MouseEvent& rMEvt ) +{ + if (IsDisabled()) + return; + + bIgnoreMove = FALSE; + SelectWindow(); + + BOOL bFound; + USHORT nHitNo = GetMousePos( rMEvt, bFound ); + + if ( bFound && rMEvt.IsLeft() && ResizeAllowed() ) + { + nDragNo = nHitNo; + USHORT nClicks = rMEvt.GetClicks(); + if ( nClicks && nClicks%2==0 ) + { + SetEntrySize( nDragNo, HDR_SIZE_OPTIMUM ); + SetPointer( Pointer( POINTER_ARROW ) ); + } + else + { + if (bVertical) + nDragStart = rMEvt.GetPosPixel().Y(); + else + nDragStart = rMEvt.GetPosPixel().X(); + nDragPos = nDragStart; + ShowDragHelp(); + DrawInvert( nDragPos ); + + // CaptureMouse(); + StartTracking(); + bDragging = TRUE; + bDragMoved = FALSE; + } + } + else if (rMEvt.IsLeft()) + { + pSelEngine->SetWindow( this ); + Point aPoint; + Rectangle aVis( aPoint,GetOutputSizePixel() ); + if (bVertical) + aVis.Left() = LONG_MIN, aVis.Right() = LONG_MAX; + else + aVis.Top() = LONG_MIN, aVis.Bottom() = LONG_MAX; + pSelEngine->SetVisibleArea( aVis ); + + SetMarking( TRUE ); // muss vor SelMouseButtonDown sein + pSelEngine->SelMouseButtonDown( rMEvt ); + + if (IsMouseCaptured()) + { + // Tracking statt CaptureMouse, damit sauber abgebrochen werden kann + //! Irgendwann sollte die SelectionEngine selber StartTracking rufen!?! + ReleaseMouse(); + StartTracking(); + } + } +} + +void __EXPORT ScHeaderControl::MouseButtonUp( const MouseEvent& rMEvt ) +{ + if ( IsDisabled() ) + return; + + SetMarking( FALSE ); + bIgnoreMove = FALSE; + BOOL bFound; + USHORT nHitNo = GetMousePos( rMEvt, bFound ); + + if ( bDragging ) + { + DrawInvert( nDragPos ); + ReleaseMouse(); + bDragging = FALSE; + + long nScrPos = GetScrPos( nDragNo ); + long nMousePos = bVertical ? rMEvt.GetPosPixel().Y() : rMEvt.GetPosPixel().X(); + long nNewWidth = nMousePos + 2 - nScrPos; + + if ( nNewWidth < 0 /* && !IsSelected(nDragNo) */ ) + { + USHORT nStart; + USHORT nEnd = nDragNo; + while (nNewWidth < 0) + { + nStart = nDragNo; + if (nDragNo>0) + { + --nDragNo; + nNewWidth += GetEntrySize( nDragNo ); //! GetHiddenCount() ??? + } + else + nNewWidth = 0; + } + HideEntries( nStart, nEnd ); + } + else + { + if (nNewWidth<0) nNewWidth=0; + if (bDragMoved) + SetEntrySize( nDragNo, (USHORT) nNewWidth ); + } + } + else + { + pSelEngine->SelMouseButtonUp( rMEvt ); + ReleaseMouse(); + } +} + +void __EXPORT ScHeaderControl::MouseMove( const MouseEvent& rMEvt ) +{ + if ( IsDisabled() ) + { + SetPointer( Pointer( POINTER_ARROW ) ); + return; + } + + BOOL bFound; + USHORT nHitNo = GetMousePos( rMEvt, bFound ); + + if ( bDragging ) + { + long nNewPos = bVertical ? rMEvt.GetPosPixel().Y() : rMEvt.GetPosPixel().X(); + if ( nNewPos != nDragPos ) + { + DrawInvert( nDragPos ); + nDragPos = nNewPos; + ShowDragHelp(); + DrawInvert( nDragPos ); + + if (nDragPos <= nDragStart-SC_DRAG_MIN || nDragPos >= nDragStart+SC_DRAG_MIN) + bDragMoved = TRUE; + } + } + else + { + if ( bFound && rMEvt.GetButtons()==0 && ResizeAllowed() ) + SetPointer( Pointer( bVertical ? POINTER_VSIZEBAR : POINTER_HSIZEBAR ) ); + else + SetPointer( Pointer( POINTER_ARROW ) ); + + if (!bIgnoreMove) + pSelEngine->SelMouseMove( rMEvt ); + } +} + +void ScHeaderControl::Tracking( const TrackingEvent& rTEvt ) +{ + // Weil die SelectionEngine kein Tracking kennt, die Events nur auf + // die verschiedenen MouseHandler verteilen... + + if ( rTEvt.IsTrackingCanceled() ) + StopMarking(); + else if ( rTEvt.IsTrackingEnded() ) + MouseButtonUp( rTEvt.GetMouseEvent() ); + else + MouseMove( rTEvt.GetMouseEvent() ); +} + +void __EXPORT ScHeaderControl::Command( const CommandEvent& rCEvt ) +{ + USHORT nCmd = rCEvt.GetCommand(); + if ( nCmd == COMMAND_CONTEXTMENU ) + { + StopMarking(); // Selektion / Dragging beenden + + // Popup ausfuehren + + ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, + SfxViewShell::Current() ); + if ( pViewSh ) + { + ScResId aResId( bVertical ? RID_POPUP_ROWHEADER : RID_POPUP_COLHEADER ); + pViewSh->GetDispatcher()->ExecutePopup( aResId ); + } + } + else if ( nCmd == COMMAND_STARTDRAG ) + { + pSelEngine->Command( rCEvt ); + } +} + +void ScHeaderControl::StopMarking() +{ + if ( bDragging ) + { + DrawInvert( nDragPos ); + bDragging = FALSE; + } + + SetMarking( FALSE ); + bIgnoreMove = TRUE; + pSelEngine->Reset(); + ReleaseMouse(); +} + +void ScHeaderControl::ShowDragHelp() +{ + if (Help::IsQuickHelpEnabled()) + { + long nVal = nDragPos + 2 - GetScrPos( nDragNo ); + + String aHelpStr = GetDragHelp( nVal ); + Point aPos = OutputToScreenPixel( Point(0,0) ); + Size aSize = GetSizePixel(); + +#ifdef VCL + Point aMousePos = OutputToScreenPixel(GetPointerPosPixel()); +#else + Point aMousePos = Pointer::GetPosPixel(); +#endif + + Rectangle aRect; + USHORT nAlign; + if (!bVertical) + { + // oberhalb + aRect.Left() = aMousePos.X(); + aRect.Top() = aPos.Y() - 4; + nAlign = QUICKHELP_BOTTOM|QUICKHELP_CENTER; + } + else + { + // rechts oben + aRect.Left() = aPos.X() + aSize.Width() + 8; + aRect.Top() = aMousePos.Y() - 2; + nAlign = QUICKHELP_LEFT|QUICKHELP_BOTTOM; + } + + aRect.Right() = aRect.Left(); + aRect.Bottom() = aRect.Top(); + + Help::ShowQuickHelp(this, aRect, aHelpStr, nAlign); + } +} + +void __EXPORT ScHeaderControl::RequestHelp( const HelpEvent& rHEvt ) +{ + // Wenn eigene QuickHelp angezeigt wird, nicht durch RequestHelp + // wieder wegnehmen lassen + + BOOL bOwn = bDragging && Help::IsQuickHelpEnabled(); + if (!bOwn) + Window::RequestHelp(rHEvt); +} + +// ----------------------------------------------------------------------- +// Dummys fuer virtuelle Methoden +// ----------------------------------------------------------------------- + +USHORT ScHeaderControl::GetHiddenCount( USHORT nEntryNo ) +{ + USHORT nHidden = 0; + while ( nEntryNo < nSize && GetEntrySize( nEntryNo ) == 0 ) + { + ++nEntryNo; + ++nHidden; + } + return nHidden; +} + +BOOL ScHeaderControl::IsDisabled() +{ + return FALSE; +} + +BOOL ScHeaderControl::ResizeAllowed() +{ + return TRUE; +} + +void ScHeaderControl::SelectWindow() +{ +} + +void ScHeaderControl::DrawInvert( long nDragPos ) +{ +} + +String ScHeaderControl::GetDragHelp( long nVal ) +{ + return EMPTY_STRING; +} + +void ScHeaderControl::SetMarking( BOOL bSet ) +{ +} + + + diff --git a/sc/source/ui/view/hintwin.cxx b/sc/source/ui/view/hintwin.cxx new file mode 100644 index 000000000000..49efacadf812 --- /dev/null +++ b/sc/source/ui/view/hintwin.cxx @@ -0,0 +1,188 @@ +/************************************************************************* + * + * $RCSfile: hintwin.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// System - Includes ----------------------------------------------------- + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +#ifndef PCH +#include <segmentc.hxx> +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "hintwin.hxx" +#include "global.hxx" + +#define HINT_LINESPACE 2 +#define HINT_INDENT 3 +#define HINT_MARGIN 4 + +// STATIC DATA ----------------------------------------------------------- + +SEG_EOFGLOBALS() + +//================================================================== +#pragma SEG_FUNCDEF(hintwin_01) + +ScHintWindow::ScHintWindow( Window* pParent, const String& rTit, const String& rMsg ) : + Window( pParent, WinBits( WB_BORDER ) ), + aTitle( rTit ), + aMessage( rMsg ) +{ + aMessage.ConvertLineEnd( LINEEND_CR ); + + // Hellgelb, wie Notizen in detfunc.cxx + Color aYellow( 255,255,192 ); // hellgelb + SetBackground( aYellow ); + + aTextFont = GetFont(); + aTextFont.SetTransparent( TRUE ); + aTextFont.SetWeight( WEIGHT_NORMAL ); + aHeadFont = aTextFont; + aHeadFont.SetWeight( WEIGHT_BOLD ); + + SetFont( aHeadFont ); + Size aHeadSize( GetTextWidth( aTitle ), GetTextHeight() ); + SetFont( aTextFont ); + + Size aTextSize; + xub_StrLen nIndex = 0; + while ( nIndex != STRING_NOTFOUND ) + { + String aLine = aMessage.GetToken( 0, CHAR_CR, nIndex ); + Size aLineSize( GetTextWidth( aLine ), GetTextHeight() ); + nTextHeight = aLineSize.Height(); + aTextSize.Height() += nTextHeight; + if ( aLineSize.Width() > aTextSize.Width() ) + aTextSize.Width() = aLineSize.Width(); + } + aTextSize.Width() += HINT_INDENT; + + aTextStart = Point( HINT_MARGIN + HINT_INDENT, + aHeadSize.Height() + HINT_MARGIN + HINT_LINESPACE ); + + Size aWinSize( Max( aHeadSize.Width(), aTextSize.Width() ) + 2 * HINT_MARGIN + 1, + aHeadSize.Height() + aTextSize.Height() + HINT_LINESPACE + 2 * HINT_MARGIN + 1 ); + SetOutputSizePixel( aWinSize ); +} + +#pragma SEG_FUNCDEF(hintwin_02) + +ScHintWindow::~ScHintWindow() +{ +} + +#pragma SEG_FUNCDEF(hintwin_03) + +void __EXPORT ScHintWindow::Paint( const Rectangle& rRect ) +{ + SetFont( aHeadFont ); + DrawText( Point(HINT_MARGIN,HINT_MARGIN), aTitle ); + + SetFont( aTextFont ); + xub_StrLen nIndex = 0; + Point aLineStart = aTextStart; + while ( nIndex != STRING_NOTFOUND ) + { + String aLine = aMessage.GetToken( 0, CHAR_CR, nIndex ); + DrawText( aLineStart, aLine ); + aLineStart.Y() += nTextHeight; + } +} + +/*------------------------------------------------------------------------ + + $Log: not supported by cvs2svn $ + Revision 1.7 2000/09/17 14:09:33 willem.vandorp + OpenOffice header added. + + Revision 1.6 2000/08/31 16:38:46 willem.vandorp + Header and footer replaced + + Revision 1.5 2000/05/26 15:07:49 er + NOOLDSV + + Revision 1.4 2000/04/14 08:31:37 nn + unicode changes + + Revision 1.3 1997/10/10 14:35:00 NN + Hint-Window auch unter VCL in richtiger Farbe anzeigen + + + Rev 1.2 10 Oct 1997 16:35:00 NN + Hint-Window auch unter VCL in richtiger Farbe anzeigen + + Rev 1.1 16 Dec 1996 16:51:50 NN + auch mehrzeiliger Text + + Rev 1.0 28 Oct 1996 10:56:14 NN + Initial revision. + +------------------------------------------------------------------------*/ + +#pragma SEG_EOFMODULE + + diff --git a/sc/source/ui/view/imapwrap.cxx b/sc/source/ui/view/imapwrap.cxx new file mode 100644 index 000000000000..bbde273613a1 --- /dev/null +++ b/sc/source/ui/view/imapwrap.cxx @@ -0,0 +1,111 @@ +/************************************************************************* + * + * $RCSfile: imapwrap.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include <svx/imapdlg.hxx> +#include <sfx2/viewfrm.hxx> + + +USHORT ScIMapChildWindowId() +{ + return SvxIMapDlgChildWindow::GetChildWindowId(); +} + +SvxIMapDlg* ScGetIMapDlg() +{ + //! pass view frame here and in SVXIMAPDLG() + + SfxViewFrame* pViewFrm = SfxViewFrame::Current(); + if( pViewFrm && pViewFrm->HasChildWindow( SvxIMapDlgChildWindow::GetChildWindowId() ) ) + return SVXIMAPDLG(); + else + return NULL; +} + +void ScIMapDlgSet( const Graphic& rGraphic, const ImageMap* pImageMap, + const TargetList* pTargetList, void* pEditingObj ) +{ + SvxIMapDlgChildWindow::UpdateIMapDlg( rGraphic, pImageMap, pTargetList, pEditingObj ); +} + +const void* ScIMapDlgGetObj( SvxIMapDlg* pDlg ) +{ + if ( pDlg ) + return pDlg->GetEditingObject(); + else + return NULL; +} + +const ImageMap& ScIMapDlgGetMap( SvxIMapDlg* pDlg ) +{ + return pDlg->GetImageMap(); +} + + + + diff --git a/sc/source/ui/view/invmerge.cxx b/sc/source/ui/view/invmerge.cxx new file mode 100644 index 000000000000..31b0fb122435 --- /dev/null +++ b/sc/source/ui/view/invmerge.cxx @@ -0,0 +1,156 @@ +/************************************************************************* + * + * $RCSfile: invmerge.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +#include <vcl/window.hxx> +#include <tools/debug.hxx> + +#include "invmerge.hxx" + +//------------------------------------------------------------------ + +ScInvertMerger::ScInvertMerger( Window* pWindow ) : + pWin( pWindow ) +{ + // both rectangles empty +} + +ScInvertMerger::~ScInvertMerger() +{ + Flush(); +} + +void ScInvertMerger::Flush() +{ + FlushLine(); + FlushTotal(); + + DBG_ASSERT( aLineRect.IsEmpty() && aTotalRect.IsEmpty(), "Flush: not empty" ); +} + +void ScInvertMerger::FlushTotal() +{ + if( aTotalRect.IsEmpty() ) + return; // nothing to do + + pWin->Invert( aTotalRect, INVERT_HIGHLIGHT ); + aTotalRect.SetEmpty(); +} + +void ScInvertMerger::FlushLine() +{ + if( aLineRect.IsEmpty() ) + return; // nothing to do + + if ( aTotalRect.IsEmpty() ) + { + aTotalRect = aLineRect; // start new total rect + } + else + { + if ( aLineRect.Left() == aTotalRect.Left() && + aLineRect.Right() == aTotalRect.Right() && + aLineRect.Top() == aTotalRect.Bottom() + 1 ) + { + // extend total rect + aTotalRect.Bottom() = aLineRect.Bottom(); + } + else + { + FlushTotal(); // draw old total rect + aTotalRect = aLineRect; // and start new one + } + } + + aLineRect.SetEmpty(); +} + +void ScInvertMerger::AddRect( const Rectangle& rRect ) +{ + if ( aLineRect.IsEmpty() ) + { + aLineRect = rRect; // start new line rect + } + else + { + if ( rRect.Top() == aLineRect.Top() && + rRect.Bottom() == aLineRect.Bottom() && + rRect.Left() == aLineRect.Right() + 1 ) + { + // extend line rect + aLineRect.Right() = rRect.Right(); + } + else + { + FlushLine(); // use old line rect for total rect + aLineRect = rRect; // and start new one + } + } +} + + + + diff --git a/sc/source/ui/view/makefile.mk b/sc/source/ui/view/makefile.mk new file mode 100644 index 000000000000..fa648fd29037 --- /dev/null +++ b/sc/source/ui/view/makefile.mk @@ -0,0 +1,257 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=sc +TARGET=view + +PROJECTPCH4DLL=TRUE +PROJECTPCH=ui_pch +PDBTARGET=ui_pch +PROJECTPCHSOURCE=..\pch\ui_pch + +AUTOSEG=true + +# --- Settings ----------------------------------------------------- + +.INCLUDE : scpre.mk +.INCLUDE : settings.mk +.INCLUDE : sc.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- +# drawattr.cxx fuer IDL (enums), sollte in den Svx gehen?? + +CXXFILES = \ + tabview.cxx \ + tabview2.cxx \ + tabview3.cxx \ + tabview4.cxx \ + tabview5.cxx \ + viewfunc.cxx \ + viewfun2.cxx \ + viewfun3.cxx \ + viewfun4.cxx \ + viewfun5.cxx \ + viewfun6.cxx \ + viewfun7.cxx \ + dbfunc.cxx \ + dbfunc2.cxx \ + dbfunc3.cxx \ + dbfunc4.cxx \ + tabvwsh.cxx \ + tabvwsh2.cxx \ + tabvwsh3.cxx \ + tabvwsh4.cxx \ + tabvwsh5.cxx \ + tabvwsh7.cxx \ + tabvwsh8.cxx \ + tabvwsh9.cxx \ + tabvwsha.cxx \ + tabvwshb.cxx \ + tabvwshc.cxx \ + tabvwshd.cxx \ + tabvwshe.cxx \ + tabvwshf.cxx \ + tabvwshg.cxx \ + tabvwshh.cxx \ + printfun.cxx \ + preview.cxx \ + prevwsh.cxx \ + prevwsh2.cxx \ + editsh.cxx \ + editsh2.cxx \ + pivotsh.cxx \ + auditsh.cxx \ + gridwin.cxx \ + gridwin2.cxx \ + gridwin3.cxx \ + gridwin4.cxx \ + gridwin5.cxx \ + drawview.cxx \ + drawvie2.cxx \ + drawvie3.cxx \ + drawvie4.cxx \ + drawutil.cxx \ + output.cxx \ + output2.cxx \ + output3.cxx \ + gridmerg.cxx \ + invmerge.cxx \ + select.cxx \ + olinewin.cxx \ + hintwin.cxx \ + notemark.cxx \ + tabcont.cxx \ + tabsplit.cxx \ + viewdata.cxx \ + viewutil.cxx \ + hdrcont.cxx \ + colrowba.cxx \ + olkact.cxx \ + galwrap.cxx \ + imapwrap.cxx \ + reffact.cxx \ + spelleng.cxx \ + waitoff.cxx \ + cellsh.cxx \ + cellsh1.cxx \ + cellsh2.cxx \ + cellsh3.cxx \ + cellsh4.cxx \ + formatsh.cxx \ + pgbrksh.cxx + +# drawattr.cxx ?????? + + +SLOFILES = \ + $(SLO)$/tabview.obj \ + $(SLO)$/tabview2.obj \ + $(SLO)$/tabview3.obj \ + $(SLO)$/tabview4.obj \ + $(SLO)$/tabview5.obj \ + $(SLO)$/viewfunc.obj \ + $(SLO)$/viewfun2.obj \ + $(SLO)$/viewfun3.obj \ + $(SLO)$/viewfun4.obj \ + $(SLO)$/viewfun5.obj \ + $(SLO)$/viewfun6.obj \ + $(SLO)$/viewfun7.obj \ + $(SLO)$/dbfunc.obj \ + $(SLO)$/dbfunc2.obj \ + $(SLO)$/dbfunc3.obj \ + $(SLO)$/dbfunc4.obj \ + $(SLO)$/tabvwsh.obj \ + $(SLO)$/tabvwsh2.obj \ + $(SLO)$/tabvwsh3.obj \ + $(SLO)$/tabvwsh4.obj \ + $(SLO)$/tabvwsh5.obj \ + $(SLO)$/tabvwsh7.obj \ + $(SLO)$/tabvwsh8.obj \ + $(SLO)$/tabvwsh9.obj \ + $(SLO)$/tabvwsha.obj \ + $(SLO)$/tabvwshb.obj \ + $(SLO)$/tabvwshc.obj \ + $(SLO)$/tabvwshd.obj \ + $(SLO)$/tabvwshe.obj \ + $(SLO)$/tabvwshf.obj \ + $(SLO)$/tabvwshg.obj \ + $(SLO)$/tabvwshh.obj \ + $(SLO)$/printfun.obj \ + $(SLO)$/preview.obj \ + $(SLO)$/prevwsh.obj \ + $(SLO)$/prevwsh2.obj \ + $(SLO)$/editsh.obj \ + $(SLO)$/editsh2.obj \ + $(SLO)$/pivotsh.obj \ + $(SLO)$/auditsh.obj \ + $(SLO)$/gridwin.obj \ + $(SLO)$/gridwin2.obj \ + $(SLO)$/gridwin3.obj \ + $(SLO)$/gridwin4.obj \ + $(SLO)$/gridwin5.obj \ + $(SLO)$/drawview.obj \ + $(SLO)$/drawvie2.obj \ + $(SLO)$/drawvie3.obj \ + $(SLO)$/drawvie4.obj \ + $(SLO)$/drawutil.obj \ + $(SLO)$/output.obj \ + $(SLO)$/output2.obj \ + $(SLO)$/output3.obj \ + $(SLO)$/gridmerg.obj \ + $(SLO)$/invmerge.obj \ + $(SLO)$/select.obj \ + $(SLO)$/olinewin.obj \ + $(SLO)$/hintwin.obj \ + $(SLO)$/notemark.obj \ + $(SLO)$/tabcont.obj \ + $(SLO)$/tabsplit.obj \ + $(SLO)$/viewdata.obj \ + $(SLO)$/viewutil.obj \ + $(SLO)$/hdrcont.obj \ + $(SLO)$/colrowba.obj \ + $(SLO)$/olkact.obj \ + $(SLO)$/galwrap.obj \ + $(SLO)$/imapwrap.obj \ + $(SLO)$/reffact.obj \ + $(SLO)$/spelleng.obj \ + $(SLO)$/waitoff.obj \ + $(SLO)$/cellsh.obj \ + $(SLO)$/cellsh1.obj\ + $(SLO)$/cellsh2.obj\ + $(SLO)$/cellsh3.obj\ + $(SLO)$/cellsh4.obj\ + $(SLO)$/formatsh.obj\ + $(SLO)$/pgbrksh.obj\ + + +NOOPTFILES=\ + $(SLO)$/drawview.obj \ + $(SLO)$/dbfunc2.obj \ + $(SLO)$/tabvwsh2.obj + +# --- Targets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/sc/source/ui/view/notemark.cxx b/sc/source/ui/view/notemark.cxx new file mode 100644 index 000000000000..29d90cf4437b --- /dev/null +++ b/sc/source/ui/view/notemark.cxx @@ -0,0 +1,234 @@ +/************************************************************************* + * + * $RCSfile: notemark.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include <svx/svdoutl.hxx> +#include <svx/svdmodel.hxx> +#include <svx/svdobj.hxx> +#include <svx/xoutx.hxx> +#include <sfx2/app.hxx> +#include <sfx2/printer.hxx> +#include <svtools/iniman.hxx> +#include <svtools/itempool.hxx> + +#include "notemark.hxx" +#include "document.hxx" +#include "detfunc.hxx" + +#define SC_NOTEMARK_TIME 800 +#define SC_NOTEMARK_SHORT 70 + +// STATIC DATA ----------------------------------------------------------- + +// ----------------------------------------------------------------------- + +ScNoteMarker::ScNoteMarker( Window* pWin, Window* pRight, Window* pBottom, Window* pDiagonal, + ScDocument* pD, ScAddress aPos, const String& rUser, + const MapMode& rMap, BOOL bLeftEdge, BOOL bForce ) : + pWindow( pWin ), + pRightWin( pRight ), + pBottomWin( pBottom ), + pDiagWin( pDiagonal ), + pDoc( pD ), + aDocPos( aPos ), + aUserText( rUser ), + aMapMode( rMap ), + bLeft( bLeftEdge ), + bVisible( FALSE ), + pModel( NULL ), + pObject( NULL ) +{ + aTimer.SetTimeoutHdl( LINK( this, ScNoteMarker, TimeHdl ) ); + aTimer.SetTimeout( bForce ? SC_NOTEMARK_SHORT : SC_NOTEMARK_TIME ); + aTimer.Start(); +} + +ScNoteMarker::~ScNoteMarker() +{ + InvalidateWin(); + + delete pModel; +} + +IMPL_LINK( ScNoteMarker, TimeHdl, Timer*, pTimer ) +{ + if (!bVisible) + { + pModel = new SdrModel(SFX_APP()->GetAppIniManager()->Get(SFX_KEY_PALETTE_PATH)); + pModel->SetScaleUnit(MAP_100TH_MM); + SfxItemPool& rPool = pModel->GetItemPool(); + rPool.SetDefaultMetric(SFX_MAPUNIT_100TH_MM); + rPool.FreezeIdRanges(); + + Printer* pPrinter = pDoc->GetPrinter(); + if (pPrinter) + { + // Am Outliner des Draw-Model ist auch der Drucker als RefDevice gesetzt, + // und es soll einheitlich aussehen. + Outliner& rOutliner = pModel->GetDrawOutliner(); + rOutliner.SetRefDevice(pPrinter); + } + + SdrPage* pPage = pModel->AllocPage(FALSE); + + Size aSizePixel = pWindow->GetOutputSizePixel(); + Rectangle aVisPixel( Point(0,0), aSizePixel ); + Rectangle aVisible = pWindow->PixelToLogic( aVisPixel, aMapMode ); + + USHORT nCol = aDocPos.Col(); + USHORT nRow = aDocPos.Row(); + USHORT nTab = aDocPos.Tab(); + pObject = ScDetectiveFunc( pDoc,nTab ). + ShowCommentUser( nCol, nRow, aUserText, aVisible, bLeft, FALSE, pPage ); + + if (pObject) + aRect = pObject->GetBoundRect(); + + // #39351# Page einfuegen damit das Model sie kennt und auch deleted + pModel->InsertPage( pPage ); + + bVisible = TRUE; + } + + Draw(); + return 0; +} + +void lcl_DrawWin( SdrObject* pObject, Window* pWindow, const MapMode& rMap ) +{ + MapMode aOld = pWindow->GetMapMode(); + pWindow->SetMapMode( rMap ); + + ExtOutputDevice* pXOut = new ExtOutputDevice( pWindow ); + pXOut->SetOutDev( pWindow ); + SdrPaintInfoRec aInfoRec; + pObject->Paint( *pXOut, aInfoRec ); + delete pXOut; + + pWindow->SetMapMode( aOld ); +} + +MapMode lcl_MoveMapMode( const MapMode& rMap, const Size& rMove ) +{ + MapMode aNew = rMap; + Point aOrigin = aNew.GetOrigin(); + aOrigin.X() -= rMove.Width(); + aOrigin.Y() -= rMove.Height(); + aNew.SetOrigin(aOrigin); + return aNew; +} + +void ScNoteMarker::Draw() +{ + if ( pObject && bVisible ) + { + lcl_DrawWin( pObject, pWindow, aMapMode ); + + if ( pRightWin || pBottomWin ) + { + Size aWinSize = pWindow->PixelToLogic( pWindow->GetOutputSizePixel(), aMapMode ); + if ( pRightWin ) + lcl_DrawWin( pObject, pRightWin, + lcl_MoveMapMode( aMapMode, Size( aWinSize.Width(), 0 ) ) ); + if ( pBottomWin ) + lcl_DrawWin( pObject, pBottomWin, + lcl_MoveMapMode( aMapMode, Size( 0, aWinSize.Height() ) ) ); + if ( pDiagWin ) + lcl_DrawWin( pObject, pDiagWin, lcl_MoveMapMode( aMapMode, aWinSize ) ); + } + } +} + +void ScNoteMarker::InvalidateWin() +{ + if (bVisible) + { + pWindow->Invalidate( pWindow->LogicToLogic(aRect, aMapMode, pWindow->GetMapMode()) ); + + if ( pRightWin || pBottomWin ) + { + Size aWinSize = pWindow->PixelToLogic( pWindow->GetOutputSizePixel(), aMapMode ); + if ( pRightWin ) + pRightWin->Invalidate( pRightWin->LogicToLogic(aRect, + lcl_MoveMapMode( aMapMode, Size( aWinSize.Width(), 0 ) ), + pRightWin->GetMapMode()) ); + if ( pBottomWin ) + pBottomWin->Invalidate( pBottomWin->LogicToLogic(aRect, + lcl_MoveMapMode( aMapMode, Size( 0, aWinSize.Height() ) ), + pBottomWin->GetMapMode()) ); + if ( pDiagWin ) + pDiagWin->Invalidate( pDiagWin->LogicToLogic(aRect, + lcl_MoveMapMode( aMapMode, aWinSize ), + pDiagWin->GetMapMode()) ); + } + } +} + + + + diff --git a/sc/source/ui/view/olinewin.cxx b/sc/source/ui/view/olinewin.cxx new file mode 100644 index 000000000000..18daf341d862 --- /dev/null +++ b/sc/source/ui/view/olinewin.cxx @@ -0,0 +1,916 @@ +/************************************************************************* + * + * $RCSfile: olinewin.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// System - Includes ----------------------------------------------------- + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +#ifndef PCH +#include <segmentc.hxx> +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "olinewin.hxx" +#include "olinetab.hxx" +#include "document.hxx" // GetOutline +#include "sc.hrc" +#include "dbfunc.hxx" // Funktionen + +#define SC_OL_BITMAPSIZE 12 + +#define SC_OL_IMAGE_PLUS 9 +#define SC_OL_IMAGE_MINUS 10 + +// STATIC DATA ----------------------------------------------------------- + +SEG_EOFGLOBALS() + + +//================================================================== +#pragma SEG_FUNCDEF(olinewin_03) + +ScOutlineWindow::ScOutlineWindow( Window* pParent, ScOutlineMode eNewMode, + ScViewData* pData, ScSplitPos eNewWhich ) : + Window( pParent ), + eMode( eNewMode ), + pViewData( pData ), + eWhich( eNewWhich ), + nHeaderSize( 0 ), + bHitMode( FALSE ), + aColor( COL_BLACK ) +{ + ImplInitSettings(); +} + +#pragma SEG_FUNCDEF(olinewin_04) + +__EXPORT ScOutlineWindow::~ScOutlineWindow() +{ +} + +#pragma SEG_FUNCDEF(olinewin_11) + +BOOL ScOutlineWindow::IsFirst(USHORT nPos) +{ + // sind alle Spalten vor dieser ausgeblendet? + + BOOL bHor = (eMode==SC_OUTLINE_HOR); + ScDocument* pDoc = pViewData->GetDocument(); + USHORT nTab = pViewData->GetTabNo(); + for (;;) + { + if (nPos==0) + return TRUE; + BOOL bHidden; + if (bHor) + bHidden = (pDoc->GetColFlags(nPos-1,nTab)&CR_HIDDEN)!=0; + else + bHidden = (pDoc->GetRowFlags(nPos-1,nTab)&CR_HIDDEN)!=0; + if (bHidden) + --nPos; + else + return FALSE; + } +} + +#pragma SEG_FUNCDEF(olinewin_05) + +BOOL ScOutlineWindow::GetEntryPos( ScOutlineEntry* pEntry, + long& rFirstEntry, long& rSecondEntry, long& rBitmapEntry, + ScOutlineEntry* pPrevious ) +{ + BOOL bHor = (eMode==SC_OUTLINE_HOR); + ScDocument* pDoc = pViewData->GetDocument(); + USHORT nTab = pViewData->GetTabNo(); + + USHORT nStart = pEntry->GetStart(); + USHORT nEnd = pEntry->GetEnd(); + + if (bHor) + { + rFirstEntry = nHeaderSize + pViewData->GetScrPos( nStart, 0, eWhich, TRUE ).X(); + rSecondEntry = nHeaderSize + pViewData->GetScrPos( nEnd+1, 0, eWhich, TRUE ).X(); + } + else + { + rFirstEntry = nHeaderSize + pViewData->GetScrPos( 0, nStart, eWhich, TRUE ).Y(); + rSecondEntry = nHeaderSize + pViewData->GetScrPos( 0, nEnd+1, eWhich, TRUE ).Y(); + } + // bAllowNeg = TRUE bei GetScrPos -> auch ausserhalb des sichtbaren Bereichs weiterzaehlen, + // sonst wuerde die Bitmap nach oben geschoben, wenn die Position ganz unten ist. + + BOOL bHidden; + if (bHor) + bHidden = (pDoc->GetColFlags(nStart,nTab)&CR_HIDDEN)!=0; + else + bHidden = (pDoc->GetRowFlags(nStart,nTab)&CR_HIDDEN)!=0; + + if (bHidden) + rBitmapEntry = rFirstEntry - SC_OL_BITMAPSIZE / 2; + else + rBitmapEntry = rFirstEntry + 1; + rBitmapEntry = Min( (long)rBitmapEntry, + (long)(( rFirstEntry+rSecondEntry-SC_OL_BITMAPSIZE ) / 2 )); + + // Anpassungen + + if (bHidden && IsFirst(nStart)) + rBitmapEntry = rFirstEntry; // ganz links nicht abschneiden + + if (!bHidden && pPrevious) // ausgeblendeten nicht mit naechstem verdecken + { + USHORT nPrevEnd = pPrevious->GetEnd(); + if (nPrevEnd+1 == nStart) + { + BOOL bPrevHidden; + if (bHor) + bPrevHidden = (pDoc->GetColFlags(nPrevEnd,nTab)&CR_HIDDEN)!=0; + else + bPrevHidden = (pDoc->GetRowFlags(nPrevEnd,nTab)&CR_HIDDEN)!=0; + + if (bPrevHidden) + { + if ( IsFirst( pPrevious->GetStart() ) ) + rBitmapEntry = rFirstEntry + SC_OL_BITMAPSIZE; + else + rBitmapEntry = rFirstEntry + SC_OL_BITMAPSIZE / 2; + } + } + } + + // rFirstEntry und rSecondEntry koennen auf den sichtbaren Bereich begrenzt werden, + // der "Haken" unten/rechts wird nur gezeichnet, wenn die letzte Zelle sichtbar ist. + // Ohne Begrenzung wird in die Ziffernfelder hineingemalt. + if ( rFirstEntry < nHeaderSize ) + rFirstEntry = nHeaderSize; + if ( rSecondEntry < nHeaderSize ) + rSecondEntry = nHeaderSize; + + // Filter + + BOOL bVisible; + if (bHor) + bVisible = TRUE; // horizontal: keine Filter + else + { + bVisible = FALSE; + USHORT nRow; + for (nRow=nStart; nRow<=nEnd && !bVisible; nRow++) + if (!pDoc->IsFiltered(nRow,nTab)) + bVisible = TRUE; + } + + return bVisible; +} + +#define GETPREV(nLevel,nEntryNo) (nEntryNo ? pArray->GetEntry( nLevel, nEntryNo-1 ) : 0) + +#pragma SEG_FUNCDEF(olinewin_06) + +void __EXPORT ScOutlineWindow::Paint( const Rectangle& rRect ) +{ + ImageList* pBitmaps = ScGlobal::GetOutlineBitmaps(); + + USHORT nTab = pViewData->GetTabNo(); + ScDocument* pDoc = pViewData->GetDocument(); + ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab ); + if (!pTable) + return; + + double nPPTX = pViewData->GetPPTX(); + double nPPTY = pViewData->GetPPTY(); + BOOL bHor = (eMode==SC_OUTLINE_HOR); + ScOutlineArray* pArray = bHor ? pTable->GetColArray() : pTable->GetRowArray(); + USHORT nDepth = pArray->GetDepth(); + USHORT nLevel; + + Size aSize = GetOutputSizePixel(); + long nAllSize = bHor ? aSize.Height() : aSize.Width(); + long nDestPos = nAllSize - 1; + + SetLineColor( aColor ); + + if (bHor) + DrawLine(Point(0,nDestPos), Point(aSize.Width()-1,nDestPos)); + else + DrawLine(Point(nDestPos,0), Point(nDestPos,aSize.Height()-1)); + + Point aFirstPos; + long& nFirstLevel = bHor ? aFirstPos.Y() : aFirstPos.X(); + long& nFirstEntry = bHor ? aFirstPos.X() : aFirstPos.Y(); + + Point aSecondPos; + long& nSecondLevel = bHor ? aSecondPos.Y() : aSecondPos.X(); + long& nSecondEntry = bHor ? aSecondPos.X() : aSecondPos.Y(); + + if (nHeaderSize) + { + // Ebenen - Nummern + // + + nFirstEntry = ( nHeaderSize - SC_OL_BITMAPSIZE ) / 2; + nFirstLevel = ( nAllSize - (nDepth+1) * SC_OL_BITMAPSIZE ) / 2; + + for (nLevel=0; nLevel<=nDepth; nLevel++) + { + DrawImage( aFirstPos, pBitmaps->GetImage(nLevel+1) ); + nFirstLevel += SC_OL_BITMAPSIZE; + } + + long nStart = nHeaderSize-1; + if (bHor) + DrawLine(Point(nStart,0),Point(nStart,nDestPos)); + else + DrawLine(Point(0,nStart),Point(nDestPos,nStart)); + } + + USHORT nStartIndex; + USHORT nEndIndex; + if (bHor) + { + nStartIndex = pViewData->GetPosX( WhichH(eWhich) ); + nEndIndex = nStartIndex + pViewData->VisibleCellsX( WhichH(eWhich) ); + while ( nStartIndex>0 ? (pDoc->GetColFlags(nStartIndex-1,nTab) & CR_HIDDEN) : FALSE ) + --nStartIndex; + } + else + { + nStartIndex = pViewData->GetPosY( WhichV(eWhich) ); + nEndIndex = nStartIndex + pViewData->VisibleCellsY( WhichV(eWhich) ); + while ( nStartIndex>0 ? (pDoc->GetRowFlags(nStartIndex-1,nTab) & CR_HIDDEN) : FALSE ) + --nStartIndex; + } + + // + // Outline-Gruppen + // + + nFirstLevel = ( nAllSize - (nDepth+1) * SC_OL_BITMAPSIZE ) / 2; + for (nLevel=0; nLevel<nDepth; nLevel++) + { + short nEntryCount = (short) pArray->GetCount( nLevel ); + short nEntryNo; + for (nEntryNo=0; nEntryNo<nEntryCount; nEntryNo++) + { + ScOutlineEntry* pEntry = pArray->GetEntry( nLevel, nEntryNo ); + BOOL bDoThis = FALSE; + + long nBitmapEntry; + USHORT nStart = pEntry->GetStart(); + USHORT nEnd = pEntry->GetEnd(); + + if ( nEnd >= nStartIndex && nStart <= nEndIndex ) + if (GetEntryPos( pEntry, nFirstEntry, nSecondEntry, nBitmapEntry, GETPREV(nLevel,nEntryNo) )) + if (pEntry->IsVisible()) // nicht von hoeherer Ebene verdeckt + bDoThis = TRUE; + + if (bDoThis) + { + Point aOldFirstPos = aFirstPos; + BOOL bDraw = FALSE; + BOOL bLeftOut = ( nStart < nStartIndex ); + + if (pEntry->IsHidden()) + bDraw = FALSE; // ausgeblendet + else + bDraw = TRUE; // eingeblendet + + if (bDraw) + { + SetLineColor(); + + nSecondLevel = nFirstLevel; + nSecondLevel += 1; + if (!bLeftOut) + nFirstEntry += 1; + nSecondEntry -= 2; + DrawRect( Rectangle( aFirstPos, aSecondPos ) ); // Linie + + if ( nEnd <= nEndIndex ) + { + aFirstPos = aSecondPos; + nFirstEntry -= 1; + nSecondLevel += SC_OL_BITMAPSIZE / 3; + DrawRect( Rectangle( aFirstPos, aSecondPos ) ); // rechts + } + + // links wird von Bitmap verdeckt + } + + aFirstPos = aOldFirstPos; + } + } + + for (nEntryNo=nEntryCount-1; nEntryNo>=0; nEntryNo--) // short + { + ScOutlineEntry* pEntry = pArray->GetEntry( nLevel, nEntryNo ); + BOOL bDoThis = FALSE; + + long nBitmapEntry; + USHORT nStart = pEntry->GetStart(); + USHORT nEnd = pEntry->GetEnd(); + + if ( nEnd >= nStartIndex && nStart <= nEndIndex + 1 ) // +1 wegen Verschiebung + if (GetEntryPos( pEntry, nFirstEntry, nSecondEntry, nBitmapEntry, GETPREV(nLevel,nEntryNo) )) + if (pEntry->IsVisible()) // nicht von hoeherer Ebene verdeckt + bDoThis = TRUE; + + if (bDoThis) + { + Point aOldFirstPos = aFirstPos; + BOOL bLeftOut = ( nStart < nStartIndex ); + + if (!bLeftOut) + { + aFirstPos = aOldFirstPos; + nFirstEntry = nBitmapEntry; + + BOOL bClip = ( nBitmapEntry < (long) nHeaderSize ); + if (bClip) + { + if (bHor) + SetClipRegion( Rectangle( Point(nHeaderSize,0), + Point(aSize.Width()-1,aSize.Height()-1) ) ); + else + SetClipRegion( Rectangle( Point(0,nHeaderSize), + Point(aSize.Width()-1,aSize.Height()-1) ) ); + } + + if (pEntry->IsHidden()) + DrawImage( aFirstPos, pBitmaps->GetImage(SC_OL_IMAGE_PLUS) ); + else + DrawImage( aFirstPos, pBitmaps->GetImage(SC_OL_IMAGE_MINUS) ); + + if (bClip) + SetClipRegion(); + } + + aFirstPos = aOldFirstPos; + } + } + + nFirstLevel += SC_OL_BITMAPSIZE; + } +} + +#pragma SEG_FUNCDEF(olinewin_07) + +void ScOutlineWindow::ToggleRect( const Rectangle& rRect ) +{ + Update(); + Invert( Rectangle( rRect.Left()+1, rRect.Top()+1, rRect.Right()-2, rRect.Top()+1 ) ); + Invert( Rectangle( rRect.Left()+1, rRect.Top()+2, rRect.Left()+1, rRect.Bottom()-2 ) ); +} + +#pragma SEG_FUNCDEF(olinewin_08) + +BOOL ScOutlineWindow::ButtonHit( const Point& rPos, USHORT& rLevel, USHORT& rEntry, BOOL& rHeader, + Rectangle& rInvRect ) +{ + USHORT nTab = pViewData->GetTabNo(); + ScDocument* pDoc = pViewData->GetDocument(); + ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab ); + if (!pTable) + return FALSE; + + BOOL bHor = (eMode==SC_OUTLINE_HOR); + ScOutlineArray* pArray = bHor ? pTable->GetColArray() : pTable->GetRowArray(); + USHORT nDepth = pArray->GetDepth(); + Size aSize = GetOutputSizePixel(); + long nAllSize = bHor ? aSize.Height() : aSize.Width(); + + USHORT nStartIndex; + USHORT nEndIndex; + if (bHor) + { + nStartIndex = pViewData->GetPosX( WhichH(eWhich) ); + nEndIndex = nStartIndex + pViewData->VisibleCellsX( WhichH(eWhich) ); + while ( nStartIndex>0 ? (pDoc->GetColFlags(nStartIndex-1,nTab) & CR_HIDDEN) : FALSE ) + --nStartIndex; + } + else + { + nStartIndex = pViewData->GetPosY( WhichV(eWhich) ); + nEndIndex = nStartIndex + pViewData->VisibleCellsY( WhichV(eWhich) ); + while ( nStartIndex>0 ? (pDoc->GetRowFlags(nStartIndex-1,nTab) & CR_HIDDEN) : FALSE ) + --nStartIndex; + } + + long nEntryPos; + long nLevelPos; + long nEntryMouse = bHor ? rPos.X() : rPos.Y(); + long nLevelMouse = bHor ? rPos.Y() : rPos.X(); + + USHORT nLevel; + nLevelPos = ( nAllSize - (nDepth+1) * SC_OL_BITMAPSIZE ) / 2; + for (nLevel=0; nLevel<=nDepth; nLevel++) + { + if ( nLevelMouse >= nLevelPos && nLevelMouse <= nLevelPos + SC_OL_BITMAPSIZE ) + { + if (nHeaderSize) // Ebenen-Nummern + { + nEntryPos = ( nHeaderSize - SC_OL_BITMAPSIZE ) / 2; + if ( nEntryMouse >= nEntryPos && nEntryMouse <= nEntryPos + SC_OL_BITMAPSIZE ) + { + rLevel = nLevel; + rEntry = 0; + rHeader = TRUE; + if (bHor) + rInvRect = Rectangle( Point( nEntryPos, nLevelPos ), + Size( SC_OL_BITMAPSIZE, SC_OL_BITMAPSIZE ) ); + else + rInvRect = Rectangle( Point( nLevelPos, nEntryPos ), + Size( SC_OL_BITMAPSIZE, SC_OL_BITMAPSIZE ) ); + return TRUE; + } + } + + if (nLevel<nDepth) // Outline-Handles + { + USHORT nEntryCount = pArray->GetCount( nLevel ); + for (USHORT nEntryNo=0; nEntryNo<nEntryCount; nEntryNo++) + { + ScOutlineEntry* pEntry = pArray->GetEntry( nLevel, nEntryNo ); + + USHORT nStart = pEntry->GetStart(); + if ( nStart >= nStartIndex && nStart <= nEndIndex ) + { + long nDummy1; + long nDummy2; + if (GetEntryPos( pEntry, nDummy1, nDummy2, nEntryPos, GETPREV(nLevel,nEntryNo) )) + { + if (pEntry->IsVisible()) + { + if ( nEntryMouse >= nEntryPos && nEntryMouse <= nEntryPos + SC_OL_BITMAPSIZE ) + { + rLevel = nLevel; + rEntry = nEntryNo; + rHeader = FALSE; + if (bHor) + rInvRect = Rectangle( Point( nEntryPos, nLevelPos ), + Size( SC_OL_BITMAPSIZE, SC_OL_BITMAPSIZE ) ); + else + rInvRect = Rectangle( Point( nLevelPos, nEntryPos ), + Size( SC_OL_BITMAPSIZE, SC_OL_BITMAPSIZE ) ); + return TRUE; + } + } + } + } + } + } + } + nLevelPos += SC_OL_BITMAPSIZE; + } + + return FALSE; +} + +#pragma SEG_FUNCDEF(olinewin_09) + +BOOL ScOutlineWindow::LineHit( const Point& rPos, USHORT& rLevel, USHORT& rEntry ) +{ + USHORT nTab = pViewData->GetTabNo(); + ScDocument* pDoc = pViewData->GetDocument(); + ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab ); + if (!pTable) + return FALSE; + + BOOL bHor = (eMode==SC_OUTLINE_HOR); + ScOutlineArray* pArray = bHor ? pTable->GetColArray() : pTable->GetRowArray(); + USHORT nDepth = pArray->GetDepth(); + Size aSize = GetOutputSizePixel(); + long nAllSize = bHor ? aSize.Height() : aSize.Width(); + + USHORT nStartIndex; + USHORT nEndIndex; + if (bHor) + { + nStartIndex = pViewData->GetPosX( WhichH(eWhich) ); + nEndIndex = nStartIndex + pViewData->VisibleCellsX( WhichH(eWhich) ); + } + else + { + nStartIndex = pViewData->GetPosY( WhichV(eWhich) ); + nEndIndex = nStartIndex + pViewData->VisibleCellsY( WhichV(eWhich) ); + } + + long nEntryStart; + long nEntryEnd; + long nLevelPos; + long nEntryMouse = bHor ? rPos.X() : rPos.Y(); + long nLevelMouse = bHor ? rPos.Y() : rPos.X(); + + USHORT nLevel; + nLevelPos = ( nAllSize - (nDepth+1) * SC_OL_BITMAPSIZE ) / 2; + for (nLevel=0; nLevel<nDepth; nLevel++) + { + if ( nLevelMouse >= nLevelPos && nLevelMouse <= nLevelPos + SC_OL_BITMAPSIZE / 2 ) + { + ScOutlineEntry* pEntry; + USHORT nEntryNo = pArray->GetCount( nLevel ); // Rueckwaerts ! + while (nEntryNo) + { + --nEntryNo; + pEntry = pArray->GetEntry( nLevel, nEntryNo ); + + USHORT nStart = pEntry->GetStart(); + USHORT nEnd = pEntry->GetEnd(); + if ( nEnd >= nStartIndex && nStart <= nEndIndex ) + { + long nDummy; + if (GetEntryPos( pEntry, nEntryStart, nEntryEnd, nDummy, GETPREV(nLevel,nEntryNo) )) + { + if (pEntry->IsVisible()) + { + if ( nEntryMouse >= nEntryStart && nEntryMouse < nEntryEnd ) + { + rLevel = nLevel; + rEntry = nEntryNo; + return TRUE; + } + } + } + } + } + } + nLevelPos += SC_OL_BITMAPSIZE; + } + + return FALSE; +} + +#pragma SEG_FUNCDEF(olinewin_0a) + +void ScOutlineWindow::DoFunction( USHORT nLevel, USHORT nEntry, BOOL bHeader ) +{ + BOOL bHor = (eMode==SC_OUTLINE_HOR); + + if (bHeader) + pViewData->GetView()->SelectLevel( bHor, nLevel ); + else + { + ScDocument* pDoc = pViewData->GetDocument(); + USHORT nTab = pViewData->GetTabNo(); + ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab ); + ScOutlineArray* pArray = bHor ? pTable->GetColArray() : pTable->GetRowArray(); + ScOutlineEntry* pEntry = pArray->GetEntry( nLevel, nEntry ); + + if (pEntry->IsHidden()) + pViewData->GetView()->ShowOutline( bHor, nLevel, nEntry ); + else + pViewData->GetView()->HideOutline( bHor, nLevel, nEntry ); + } +} + +#pragma SEG_FUNCDEF(olinewin_0b) + +void __EXPORT ScOutlineWindow::MouseMove( const MouseEvent& rMEvt ) +{ + USHORT nLevel; + USHORT nEntry; + BOOL bHeader; + Rectangle aDummyRect; + + if ( bHitMode ) + { + BOOL bHit = FALSE; + if ( ButtonHit( rMEvt.GetPosPixel(), nLevel, nEntry, bHeader, aDummyRect ) ) + if ( nLevel == nHitLevel && nEntry == nHitEntry && bHeader == bHitHeader ) + bHit = TRUE; + + if (bHit) + { + if (!bIsInverted) + ToggleRect( aInvRect ); + bIsInverted = TRUE; + } + else + { + if (bIsInverted) + ToggleRect( aInvRect ); + bIsInverted = FALSE; + } + } +} + +#pragma SEG_FUNCDEF(olinewin_0c) + +void __EXPORT ScOutlineWindow::MouseButtonUp( const MouseEvent& rMEvt ) +{ + USHORT nLevel; + USHORT nEntry; + BOOL bHeader; + Rectangle aDummyRect; + + if ( bHitMode ) + { + if ( bIsInverted ) + ToggleRect( aInvRect ); + + if ( ButtonHit( rMEvt.GetPosPixel(), nLevel, nEntry, bHeader, aDummyRect ) ) + if ( nLevel == nHitLevel && nEntry == nHitEntry && bHeader == bHitHeader ) + DoFunction( nLevel, nEntry, bHeader ); + + bHitMode = FALSE; + } +} + +#pragma SEG_FUNCDEF(olinewin_0d) + +void __EXPORT ScOutlineWindow::MouseButtonDown( const MouseEvent& rMEvt ) +{ + USHORT nLevel; + USHORT nEntry; + BOOL bHeader; + + if ( ButtonHit( rMEvt.GetPosPixel(), nLevel, nEntry, bHeader, aInvRect ) ) + { + bHitMode = TRUE; + nHitLevel = nLevel; + nHitEntry = nEntry; + bHitHeader = bHeader; + + ToggleRect( aInvRect ); + bIsInverted = TRUE; + } + else if ( rMEvt.GetClicks() == 2 ) + { + if ( LineHit( rMEvt.GetPosPixel(), nLevel, nEntry ) ) + DoFunction( nLevel, nEntry, FALSE ); + } +} + +#pragma SEG_FUNCDEF(olinewin_0e) + +void ScOutlineWindow::SetHeaderSize( USHORT nNewSize ) +{ + if ( nNewSize != nHeaderSize ) + { + nHeaderSize = nNewSize; + Invalidate(); + } +} + +#pragma SEG_FUNCDEF(olinewin_0f) + +long ScOutlineWindow::GetDepthSize() +{ + long nSize = 0; + + const ScOutlineTable* pTable = pViewData->GetDocument()->GetOutlineTable(pViewData->GetTabNo()); + if (pTable) + { + BOOL bHor = (eMode==SC_OUTLINE_HOR); + const ScOutlineArray* pArray = bHor ? pTable->GetColArray() : pTable->GetRowArray(); + USHORT nDepth = pArray->GetDepth(); + + if ( nDepth ) + nSize = ( (nDepth+1) * SC_OL_BITMAPSIZE ) + 5; + } + + return nSize; +} + +#pragma SEG_FUNCDEF(olinewin_10) + +void ScOutlineWindow::ScrollPixel( long nDiff ) +{ + BOOL bHor = (eMode==SC_OUTLINE_HOR); + if (nHeaderSize) + { + long nStart = nHeaderSize; + long nEnd; + long nSize; + Size aSize = GetOutputSizePixel(); + if (bHor) + { + nEnd = aSize.Width() - 1; + nSize = aSize.Height() - 1; + } + else + { + nEnd = aSize.Height() - 1; + nSize = aSize.Width() - 1; + } + long nInvStart; + long nInvEnd; + + if (nDiff < 0) + { + nStart -= nDiff; + nInvStart = nEnd + nDiff; + nInvEnd = nEnd; + } + else + { + nEnd -= nDiff; + nInvStart = nStart; + nInvEnd = nStart + nDiff; + } + + if (bHor) + { + Scroll( nDiff, 0, Rectangle( nStart, 0, nEnd, nSize ) ); + Invalidate( Rectangle( nInvStart, 0, nInvEnd, nSize ) ); + } + else + { + Scroll( 0, nDiff, Rectangle( 0, nStart, nSize, nEnd ) ); + Invalidate( Rectangle( 0, nInvStart, nSize, nInvEnd ) ); + } + Update(); + } + else + { + if (bHor) + Scroll( nDiff, 0 ); + else + Scroll( 0, nDiff ); + } +} + +void ScOutlineWindow::ImplInitSettings() +{ + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + SetBackground( rStyleSettings.GetFaceColor() ); + SetFillColor( rStyleSettings.GetButtonTextColor() ); + aColor = rStyleSettings.GetButtonTextColor(); + + Invalidate(); + + +} +// ----------------------------------------------------------------------- + +void ScOutlineWindow::DataChanged( const DataChangedEvent& rDCEvt ) +{ + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + ImplInitSettings(); + Invalidate(); + } + else + Window::DataChanged( rDCEvt ); +} + +/*------------------------------------------------------------------------ + + $Log: not supported by cvs2svn $ + Revision 1.28 2000/09/17 14:09:33 willem.vandorp + OpenOffice header added. + + Revision 1.27 2000/08/31 16:38:46 willem.vandorp + Header and footer replaced + + Revision 1.26 2000/05/26 15:07:52 er + NOOLDSV + + Revision 1.25 1998/08/31 18:17:42 ANK + #54242# Farbeinstellung + + + Rev 1.24 31 Aug 1998 20:17:42 ANK + #54242# Farbeinstellung + + Rev 1.23 02 Mar 1998 12:42:18 NN + #44879# 3D-Farben aus StyleSettings + + Rev 1.22 16 Oct 1997 12:48:42 NN + Paint: Rechteck fuer den Haken richtigherum + + Rev 1.21 07 Oct 1997 19:03:30 NN + GetEntryPos: First/SecondEntry begrenzen + + Rev 1.20 07 Oct 1997 15:13:20 NN + GetEntryPos: GetScrPos mit bAllowNeg=TRUE + + Rev 1.19 10 Sep 1997 20:19:26 NN + IsFirst: Hidden-Abfrage fuer vorangehende Zeile/Spalte + + Rev 1.18 18 Apr 1996 14:58:30 NN + auch verschobene Buttons ganz unten painten + + Rev 1.17 14 Feb 1996 20:38:02 NN + ButtonHit: ausgeblendete Zeilen oberhalb ueberspringen + + Rev 1.16 20 Dec 1995 18:23:20 NN + doppelte Korrektur, wenn ganz links ausgeblendete Gruppe, dann sichtbare + + Rev 1.15 14 Dec 1995 22:53:06 NN + Korrekturen bei der Position der Bitmaps (14806) + + Rev 1.14 08 Nov 1995 13:07:32 JN + Aenderung fuer 301 + + Rev 1.13 04 Jul 1995 11:52:56 NN + Reihenfolge der Handle-Bitmaps + + Rev 1.12 24 Jun 1995 17:12:40 NN + GetPPTX und Y statt GetPixelPerTwips + + Rev 1.11 20 Apr 1995 19:30:00 NN + Imagelist fuer Outline-Bitmaps + + Rev 1.10 29 Jan 1995 13:22:16 NN + include dbfunc statt tabview + + Rev 1.9 27 Jan 1995 12:14:20 TRI + __EXPORT bei virtuellen Methoden eingebaut + + Rev 1.8 24 Jan 1995 12:43:54 TRI + NT Anpassung: zwei long-casts in Min Funktion eingefuegt + + Rev 1.7 20 Jan 1995 17:15:42 NN + komplett weggefilterte Outlines nicht anzeigen + + Rev 1.6 18 Jan 1995 15:58:24 TRI + Pragmas zur Segementierung eingebaut + + Rev 1.5 03 Jan 1995 18:22:54 NN + Doppelklick auf Linie + + Rev 1.4 23 Dec 1994 14:40:16 NN + Clipping des linken Buttons + + Rev 1.3 22 Dec 1994 17:29:12 NN + Handles nach vorn, innerhalb der Gruppe verschoben + + Rev 1.2 21 Dec 1994 10:51:54 NN + ausgeblendete Spalten am Anfang beruecksichtigen + + Rev 1.1 19 Dec 1994 18:23:16 NN + Mausabfrage + + Rev 1.0 16 Dec 1994 14:43:46 NN + Initial revision. + +------------------------------------------------------------------------*/ + +#pragma SEG_EOFMODULE + + diff --git a/sc/source/ui/view/olkact.cxx b/sc/source/ui/view/olkact.cxx new file mode 100644 index 000000000000..ee17cdb2129b --- /dev/null +++ b/sc/source/ui/view/olkact.cxx @@ -0,0 +1,318 @@ +/************************************************************************* + * + * $RCSfile: olkact.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +#define _BIGINT_HXX +#define _CACHESTR_HXX +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _CTRLTOOL_HXX +#define _DLGCFG_HXX +#define _DYNARR_HXX +#define _EXTATTR_HXX +#define _FILDLG_HXX +#define _FONTDLG_HXX +#define _FRM3D_HXX +#define _INTRO_HXX +#define _ISETBWR_HXX +#define _NO_SVRTF_PARSER_HXX +#define _MACRODLG_HXX +#define _MODALDLG_HXX +#define _MOREBUTTON_HXX +#define _OUTLINER_HXX +#define _PASSWD_HXX +#define _PRNDLG_HXX +//#define _POLY_HXX +#define _PVRWIN_HXX +#define _QUEUE_HXX +#define _RULER_HXX +#define _SCRWIN_HXX +#define _SETBRW_HXX +#define _STACK_HXX +//#define _STATUS_HXX *** +#define _STDMENU_HXX +#define _TABBAR_HXX +//#define _VCBRW_HXX +#define _VCTRLS_HXX +//#define _VCSBX_HXX +#define _VCONT_HXX +#define _VDRWOBJ_HXX + + +//sfx +#define _SFXAPPWIN_HXX +#define _SFXCTRLITEM +#define _SFXDISPATCH_HXX +#define _SFXFILEDLG_HXX +#define _SFXIMGMGR_HXX +#define _SFXIPFRM_HXX +#define _SFX_MACRO_HXX +#define _SFXMULTISEL_HXX +#define _SFX_MINFITEM_HXX + + +//sfxcore.hxx +//#define _SFXINIMGR_HXX *** +//#define _SFXCFGITEM_HXX +//#define _SFX_PRINTER_HXX +#define _SFXGENLINK_HXX +#define _SFXHINTPOST_HXX +#define _SFXDOCINF_HXX +#define _SFXLINKHDL_HXX +//#define _SFX_PROGRESS_HXX + +//sfxsh.hxx +//#define _SFX_SHELL_HXX +//#define _SFXAPP_HXX +//#define _SFX_BINDINGS_HXX +//#define _SFXDISPATCH_HXX +//#define _SFXMSG_HXX *** +//#define _SFXOBJFACE_HXX *** +//#define _SFXREQUEST_HXX +#define _SFXMACRO_HXX + +// SFX +//#define _SFXAPPWIN_HXX *** +#define _SFX_SAVEOPT_HXX +//#define _SFX_CHILDWIN_HXX +//#define _SFXCTRLITEM_HXX +#define _SFXPRNMON_HXX +#define _INTRO_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFXFILEDLG_HXX +#define _PASSWD_HXX +#define _SFXTBXCTRL_HXX +#define _SFXSTBITEM_HXX +#define _SFXMNUITEM_HXX +#define _SFXIMGMGR_HXX +#define _SFXTBXMGR_HXX +#define _SFXSTBMGR_HXX +#define _SFX_MINFITEM_HXX +#define _SFXEVENT_HXX + +//sfxdoc.hxx +//#define _SFX_OBJSH_HXX +//#define _SFX_CLIENTSH_HXX +//#define _SFXDOCINF_HXX +//#define _SFX_OBJFAC_HXX +#define _SFX_DOCFILT_HXX +//#define _SFXDOCFILE_HXX *** +//define _VIEWFAC_HXX +//#define _SFXVIEWFRM_HXX +//#define _SFXVIEWSH_HXX +//#define _MDIFRM_HXX *** +#define _SFX_IPFRM_HXX +//#define _SFX_INTERNO_HXX + +//sfxdlg.hxx +//#define _SFXTABDLG_HXX +//#define _BASEDLGS_HXX *** +#define _SFX_DINFDLG_HXX +#define _SFXDINFEDT_HXX +#define _SFX_MGETEMPL_HXX +#define _SFX_TPLPITEM_HXX +//#define _SFX_STYLEDLG_HXX +#define _NEWSTYLE_HXX +//#define _SFXDOCTEMPL_HXX *** +//#define _SFXDOCTDLG_HXX *** +//#define _SFX_TEMPLDLG_HXX *** +//#define _SFXNEW_HXX *** +#define _SFXDOCMAN_HXX +//#define _SFXDOCKWIN_HXX + +//sfxitems.hxx +#define _SFX_WHMAP_HXX +#define _ARGS_HXX +//#define _SFXPOOLITEM_HXX +//#define _SFXINTITEM_HXX +//#define _SFXENUMITEM_HXX +#define _SFXFLAGITEM_HXX +//#define _SFXSTRITEM_HXX +#define _SFXPTITEM_HXX +#define _SFXRECTITEM_HXX +//#define _SFXITEMPOOL_HXX +//#define _SFXITEMSET_HXX +#define _SFXITEMITER_HXX +#define _SFX_WHITER_HXX +#define _SFXPOOLCACH_HXX +//#define _AEITEM_HXX +#define _SFXRNGITEM_HXX +//#define _SFXSLSTITM_HXX +//#define _SFXSTYLE_HXX + +//xout.hxx +//#define _XENUM_HXX +//#define _XPOLY_HXX +//#define _XATTR_HXX +//#define _XOUTX_HXX +//#define _XPOOL_HXX +//#define _XTABLE_HXX + +//svdraw.hxx +#define _SDR_NOITEMS +#define _SDR_NOTOUCH +#define _SDR_NOTRANSFORM +//#define _SDR_NOOBJECTS +//#define _SDR_NOVIEWS + + + + +#define _SFXBASIC_HXX +#define _SFX_DOCFILE_HXX +#define _SFX_DOCFILT_HXX +#define _SFX_DOCINF_HXX +#define _SFX_DOCSH_HXX +#define _SFX_TEMPLDLG_HXX +#define _SFXSTBMGR_HXX +#define _SFXTBXMGR_HXX +#define _SFXIMGMGR_HXX +#define _SFXMNUITEM_HXX +#define _SFXMNUMGR_HXX +#define _SFXSTBITEM_HXX +#define _SFXTBXCTRL_HXX +#define _SFXFILEDLG_HXX +#define _SFXREQUEST_HXX +#define _SFXOBJFACE_HXX +#define _SFXMSGPOOL_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSG_HXX +#define _SFX_PRNMON_HXX + +//si +#define _SI_NOSBXCONTROLS +#define _SI_NOCONTROL +//#define SI_NOITEMS +//#define SI_NODRW +//#define SI_NOOTHERFORMS +#define _SIDLL_HXX +//#define _VCSBX_HXX +//#define _VCBRW_HXX + +//#define _SVDATTR_HXX <--- der wars +#define _SVDXOUT_HXX +#define _SVDEC_HXX +//#define _SVDIO_HXX +//#define _SVDLAYER_HXX +//#define _SVDRAG_HXX +#define _SVINCVW_HXX +#define _SV_MULTISEL_HXX +#define _SVRTV_HXX +#define _SVTABBX_HXX + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_THESDLG_HXX + +// INCLUDE --------------------------------------------------------------- + +#include <sfx2/childwin.hxx> +#include <sfx2/objsh.hxx> + +#include "document.hxx" +#include "viewdata.hxx" +#include "drawview.hxx" +#include "drawpage.hxx" +#include "drwlayer.hxx" + +// STATIC DATA ----------------------------------------------------------- + +// ----------------------------------------------------------------------- + +void ActivateOlk( ScViewData* pViewData ) +{ + // Browser fuer Virtual Controls fuellen + // VC's und den Browser dazu gibts nicht mehr... + + // GetSbxForm gibt's nicht mehr, muss auch nichts mehr angemeldet werden +} + +void DeActivateOlk( ScViewData* pViewData ) +{ + // Browser fuer Virtual Controls fuellen + // VC's und den Browser dazu gibts nicht mehr... + + // GetSbxForm gibt's nicht mehr, muss auch nichts mehr angemeldet werden +} + + + + + diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx new file mode 100644 index 000000000000..ec2598983828 --- /dev/null +++ b/sc/source/ui/view/output.cxx @@ -0,0 +1,2684 @@ +/************************************************************************* + * + * $RCSfile: output.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <svx/boxitem.hxx> +#include <svx/brshitem.hxx> +#include <svx/rotmodit.hxx> +#include <svx/shaditem.hxx> +#include <svx/svxfont.hxx> +#include <so3/ipobj.hxx> +#include <vcl/poly.hxx> +#include <vcl/svapp.hxx> + +#include <math.h> + +#include "output.hxx" +#include "document.hxx" +#include "cell.hxx" +#include "attrib.hxx" +#include "patattr.hxx" +#include "sclnlnk.hxx" +#include "docpool.hxx" +#include "tabvwsh.hxx" +#include "progress.hxx" +#include "pagedata.hxx" +#include "chgtrack.hxx" +#include "chgviset.hxx" +#include "viewutil.hxx" +#include "gridmerg.hxx" +#include "invmerge.hxx" + +#include "scmod.hxx" +#include "appoptio.hxx" + + +// STATIC DATA ----------------------------------------------------------- + +// Farben fuer ChangeTracking "nach Autor" wie im Writer (swmodul1.cxx) + +#define SC_AUTHORCOLORCOUNT 9 + +static ColorData nAuthorColor[ SC_AUTHORCOLORCOUNT ] = { + COL_LIGHTRED, COL_LIGHTBLUE, COL_LIGHTMAGENTA, + COL_GREEN, COL_RED, COL_BLUE, + COL_BROWN, COL_MAGENTA, COL_CYAN }; + +// Hilfsklasse, fuer die Farbzuordnung, +// um nicht mehrfach hintereinander denselben User aus der Liste zu suchen + +class ScActionColorChanger +{ +private: + const ScAppOptions& rOpt; + const StrCollection& rUsers; + String aLastUserName; + USHORT nLastUserIndex; + ColorData nColor; + +public: + ScActionColorChanger( const ScChangeTrack& rTrack ); + ~ScActionColorChanger() {} + + void Update( const ScChangeAction& rAction ); + ColorData GetColor() const { return nColor; } +}; + +//------------------------------------------------------------------ + +ScActionColorChanger::ScActionColorChanger( const ScChangeTrack& rTrack ) : + rOpt( SC_MOD()->GetAppOptions() ), + rUsers( rTrack.GetUserCollection() ), + nLastUserIndex( 0 ), + nColor( COL_BLACK ) +{ +} + +void ScActionColorChanger::Update( const ScChangeAction& rAction ) +{ + ColorData nSetColor; + switch (rAction.GetType()) + { + case SC_CAT_INSERT_COLS: + case SC_CAT_INSERT_ROWS: + case SC_CAT_INSERT_TABS: + nSetColor = rOpt.GetTrackInsertColor(); + break; + case SC_CAT_DELETE_COLS: + case SC_CAT_DELETE_ROWS: + case SC_CAT_DELETE_TABS: + nSetColor = rOpt.GetTrackDeleteColor(); + break; + case SC_CAT_MOVE: + nSetColor = rOpt.GetTrackMoveColor(); + break; + default: + nSetColor = rOpt.GetTrackContentColor(); + break; + } + if ( nSetColor != COL_TRANSPARENT ) // Farbe eingestellt + nColor = nSetColor; + else // nach Autor + { + if ( rAction.GetUser() != aLastUserName ) + { + aLastUserName = rAction.GetUser(); + StrData aData(aLastUserName); + USHORT nIndex; + if (!rUsers.Search(&aData, nIndex)) + { + DBG_ERROR("Autor nicht gefunden"); + nIndex = 0; + } + nLastUserIndex = nIndex % SC_AUTHORCOLORCOUNT; + } + nColor = nAuthorColor[nLastUserIndex]; + } +} + +//================================================================== + +ScOutputData::ScOutputData( OutputDevice* pNewDev, ScOutputType eNewType, + RowInfo* pNewRowInfo, USHORT nNewCount, ScDocument* pNewDoc, + USHORT nNewTab, long nNewScrX, long nNewScrY, + USHORT nNewX1, USHORT nNewY1, USHORT nNewX2, USHORT nNewY2, + double nPixelPerTwipsX, double nPixelPerTwipsY, + const Fraction* pZoomX, const Fraction* pZoomY ) : + pDev( pNewDev ), + pRefDevice( pNewDev ), // Default: Ausgabe-Device + eType( eNewType ), + pRowInfo( pNewRowInfo ), + nArrCount( nNewCount ), + pDoc( pNewDoc ), + nTab( nNewTab ), + nScrX( nNewScrX ), + nScrY( nNewScrY ), + nX1( nNewX1 ), + nY1( nNewY1 ), + nX2( nNewX2 ), + nY2( nNewY2 ), + nPPTX( nPixelPerTwipsX ), + nPPTY( nPixelPerTwipsY ), + bEditMode( FALSE ), + bMetaFile( FALSE ), + bPagebreakMode( FALSE ), + bSolidBackground( FALSE ), + bSyntaxMode( FALSE ), + pValueColor( NULL ), + pTextColor( NULL ), + pFormulaColor( NULL ), + bSingleGrid( FALSE ), + aGridColor( COL_BLACK ), + bMarkClipped( FALSE ), // FALSE fuer Drucker/Metafile etc. + bShowNullValues( TRUE ), + bShowFormulas( FALSE ), + bSnapPixel( FALSE ), + bShowSpellErrors( FALSE ), + pEditObj( NULL ), + pViewShell( NULL ), + bAnyRotated( FALSE ), + bAnyClipped( FALSE ) +{ + if (pZoomX) + aZoomX = *pZoomX; + else + aZoomX = Fraction(1,1); + if (pZoomY) + aZoomY = *pZoomY; + else + aZoomY = Fraction(1,1); + + nVisX1 = nX1; + nVisY1 = nY1; + nVisX2 = nX2; + nVisY2 = nY2; + pDoc->StripHidden( nVisX1, nVisY1, nVisX2, nVisY2, nTab ); + + nScrW = 0; + for (USHORT nX=nVisX1; nX<=nVisX2; nX++) + nScrW += pRowInfo[0].pCellInfo[nX+1].nWidth; + + nScrH = 0; + for (USHORT nArrY=1; nArrY+1<nArrCount; nArrY++) + nScrH += pRowInfo[nArrY].nHeight; +} + +ScOutputData::~ScOutputData() +{ + delete pValueColor; + delete pTextColor; + delete pFormulaColor; +} + +void ScOutputData::SetGridColor( const Color& rColor ) +{ + aGridColor = rColor; +} + +void ScOutputData::SetMarkClipped( BOOL bSet ) +{ + bMarkClipped = bSet; +} + +void ScOutputData::SetShowNullValues( BOOL bSet ) +{ + bShowNullValues = bSet; +} + +void ScOutputData::SetShowFormulas( BOOL bSet ) +{ + bShowFormulas = bSet; +} + +void ScOutputData::SetShowSpellErrors( BOOL bSet ) +{ + bShowSpellErrors = bSet; +} + +void ScOutputData::SetSnapPixel( BOOL bSet ) +{ + bSnapPixel = bSet; +} + +void ScOutputData::SetEditCell( USHORT nCol, USHORT nRow ) +{ + nEditCol = nCol; + nEditRow = nRow; + bEditMode = TRUE; +} + +void ScOutputData::SetMetaFileMode( BOOL bNewMode ) +{ + bMetaFile = bNewMode; +} + +void ScOutputData::SetSingleGrid( BOOL bNewMode ) +{ + bSingleGrid = bNewMode; +} + +void ScOutputData::SetSyntaxMode( BOOL bNewMode ) +{ + bSyntaxMode = bNewMode; + if (bNewMode) + if (!pValueColor) + { + pValueColor = new Color( COL_LIGHTBLUE ); + pTextColor = new Color( COL_BLACK ); + pFormulaColor = new Color( COL_GREEN ); + } +} + +void ScOutputData::DrawGrid( BOOL bGrid, BOOL bPage ) +{ + USHORT nX; + USHORT nY; + long nPosX; + long nPosY; + USHORT i; + USHORT nArrY; + BYTE nOldFlags = 0; + BYTE nFlags; + BOOL bSingle; + Color aPageColor; + Color aManualColor; + + if (bPagebreakMode) + bPage = FALSE; // keine "normalen" Umbrueche ueber volle Breite/Hoehe + + //! um den einen Pixel sieht das Metafile (oder die Druck-Ausgabe) anders aus + //! als die Bildschirmdarstellung, aber wenigstens passen Druck und Metafile zusammen + + Size aOnePixel = pDev->PixelToLogic(Size(1,1)); + long nOneX = aOnePixel.Width(); + long nOneY = aOnePixel.Height(); + if (bMetaFile) + nOneX = nOneY = 1; + + if ( eType == OUTTYPE_WINDOW ) + { + aPageColor = COL_GRAY; + aManualColor = COL_BLUE; + } + + pDev->SetLineColor( aGridColor ); + ScGridMerger aGrid( pDev, nOneX, nOneY ); + + // + // Vertikale Linien + // + + nPosX = nScrX; + for (nX=nX1; nX<=nX2; nX++) + { + USHORT nXplus1 = nX+1; + USHORT nXplus2 = nX+2; + USHORT nWidth = pRowInfo[0].pCellInfo[nXplus1].nWidth; + if (nWidth) + { + nPosX += nWidth; + + if ( bPage ) + { + // Seitenumbrueche auch in ausgeblendeten suchen + nFlags = 0; + USHORT nCol = nXplus1; + while (nCol <= MAXCOL) + { + BYTE nDocFl = pDoc->GetColFlags( nCol, nTab ); + nFlags = nDocFl & ( CR_PAGEBREAK | CR_MANUALBREAK ); + if ( nFlags || !(nDocFl & CR_HIDDEN) ) + break; + ++nCol; + } + + if (nFlags != nOldFlags) + { + aGrid.Flush(); + pDev->SetLineColor( (nFlags & CR_MANUALBREAK) ? aManualColor : + (nFlags) ? aPageColor : aGridColor ); + nOldFlags = nFlags; + } + } + + BOOL bDraw = bGrid || nOldFlags; // einfaches Gitter nur wenn eingestellt + + //! Mit dieser Abfrage wird zuviel weggelassen, wenn ein automatischer + //! Umbruch mitten in den Wiederholungsspalten liegt. + //! Dann lieber den aeusseren Rahmen zweimal ausgeben... +#if 0 + // auf dem Drucker die Aussen-Linien weglassen (werden getrennt ausgegeben) + if ( eType == OUTTYPE_PRINTER && !bMetaFile ) + { + if ( nX == MAXCOL ) + bDraw = FALSE; + else if (pDoc->GetColFlags(nXplus1,nTab) & ( CR_PAGEBREAK | CR_MANUALBREAK )) + bDraw = FALSE; + } +#endif + + USHORT nWidthXplus2 = pRowInfo[0].pCellInfo[nXplus2].nWidth; + bSingle = bSingleGrid; //! in Fillinfo holen !!!!! + if ( nX<MAXCOL && !bSingle ) + { + bSingle = ( nWidthXplus2 == 0 ); + for (nArrY=1; nArrY+1<nArrCount && !bSingle; nArrY++) + { + if (pRowInfo[nArrY].pCellInfo[nXplus2].bHOverlapped) + bSingle = TRUE; + if (pRowInfo[nArrY].pCellInfo[nXplus1].bHideGrid) + bSingle = TRUE; + } + } + + if (bDraw) + { + if ( nX<MAXCOL && bSingle ) + { + USHORT nVisX = nXplus1; + while ( nVisX < MAXCOL && !pDoc->GetColWidth(nVisX,nTab) ) + ++nVisX; + + nPosY = nScrY; + long nNextY; + for (nArrY=1; nArrY+1<nArrCount; nArrY++) + { + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + nNextY = nPosY + pThisRowInfo->nHeight; + + BOOL bHOver = pThisRowInfo->pCellInfo[nXplus1].bHideGrid; + if (!bHOver) + { + if (nWidthXplus2) + bHOver = pThisRowInfo->pCellInfo[nXplus2].bHOverlapped; + else + { + if (nVisX <= nX2) + bHOver = pThisRowInfo->pCellInfo[nVisX+1].bHOverlapped; + else + bHOver = ((ScMergeFlagAttr*)pDoc->GetAttr( + nVisX,pThisRowInfo->nRowNo,nTab,ATTR_MERGE_FLAG)) + ->IsHorOverlapped(); + if (bHOver) + bHOver = ((ScMergeFlagAttr*)pDoc->GetAttr( + nXplus1,pThisRowInfo->nRowNo,nTab,ATTR_MERGE_FLAG)) + ->IsHorOverlapped(); + } + } + + if (pThisRowInfo->bChanged && !bHOver) + { + //Point aStart( nPosX-nOneX, nPosY ); + //Point aEnd( nPosX-nOneX, nNextY-nOneY ); + //pDev->DrawLine( aStart, aEnd ); + aGrid.AddVerLine( nPosX-nOneX, nPosY, nNextY-nOneY ); + } + nPosY = nNextY; + } + } + else + { + //Point aStart( nPosX-nOneX, nScrY ); + //Point aEnd( nPosX-nOneX, nScrY+nScrH-nOneY ); + //pDev->DrawLine( aStart, aEnd ); + aGrid.AddVerLine( nPosX-nOneX, nScrY, nScrY+nScrH-nOneY ); + } + } + } + } + + // + // Horizontale Linien + // + + nPosY = nScrY; + for (nArrY=1; nArrY+1<nArrCount; nArrY++) + { + USHORT nArrYplus1 = nArrY+1; + nY = pRowInfo[nArrY].nRowNo; + USHORT nYplus1 = nY+1; + nPosY += pRowInfo[nArrY].nHeight; + + if (pRowInfo[nArrY].bChanged) + { + if ( bPage ) + { + // Seitenumbrueche auch in ausgeblendeten suchen + nFlags = 0; + USHORT nRow = nYplus1; + while (nRow <= MAXROW) + { + BYTE nDocFl = pDoc->GetRowFlags( nRow, nTab ); + nFlags = nDocFl & ( CR_PAGEBREAK | CR_MANUALBREAK ); + if ( nFlags || !(nDocFl & CR_HIDDEN) ) + break; + ++nRow; + } + + if (nFlags != nOldFlags) + { + aGrid.Flush(); + pDev->SetLineColor( (nFlags & CR_MANUALBREAK) ? aManualColor : + (nFlags) ? aPageColor : aGridColor ); + nOldFlags = nFlags; + } + } + + BOOL bDraw = bGrid || nOldFlags; // einfaches Gitter nur wenn eingestellt + + //! Mit dieser Abfrage wird zuviel weggelassen, wenn ein automatischer + //! Umbruch mitten in den Wiederholungszeilen liegt. + //! Dann lieber den aeusseren Rahmen zweimal ausgeben... +#if 0 + // auf dem Drucker die Aussen-Linien weglassen (werden getrennt ausgegeben) + if ( eType == OUTTYPE_PRINTER && !bMetaFile ) + { + if ( nY == MAXROW ) + bDraw = FALSE; + else if (pDoc->GetRowFlags(nYplus1,nTab) & ( CR_PAGEBREAK | CR_MANUALBREAK )) + bDraw = FALSE; + } +#endif + + BOOL bNextYisNextRow = (pRowInfo[nArrYplus1].nRowNo == nYplus1); + bSingle = !bNextYisNextRow; // Hidden + for (i=nX1; i<=nX2 && !bSingle; i++) + { + if (pRowInfo[nArrYplus1].pCellInfo[i+1].bVOverlapped) + bSingle = TRUE; + } + + if (bDraw) + { + if ( bSingle && nY<MAXROW ) + { + USHORT nVisY = pRowInfo[nArrYplus1].nRowNo; + + nPosX = nScrX; + long nNextX; + for (i=nX1; i<=nX2; i++) + { + nNextX = nPosX + pRowInfo[0].pCellInfo[i+1].nWidth; + if (nNextX != nPosX) // sichtbar + { + BOOL bVOver; + if ( bNextYisNextRow ) + bVOver = pRowInfo[nArrYplus1].pCellInfo[i+1].bVOverlapped; + else + { + bVOver = ((ScMergeFlagAttr*)pDoc->GetAttr( + i,nYplus1,nTab,ATTR_MERGE_FLAG)) + ->IsVerOverlapped() + && ((ScMergeFlagAttr*)pDoc->GetAttr( + i,nVisY,nTab,ATTR_MERGE_FLAG)) + ->IsVerOverlapped(); + //! nVisY aus Array ?? + } + if (!bVOver) + { + //Point aStart( nPosX, nPosY-nOneY ); + //Point aEnd( nNextX-nOneX, nPosY-nOneY ); + //pDev->DrawLine( aStart, aEnd ); + aGrid.AddHorLine( nPosX, nNextX-nOneX, nPosY-nOneY ); + } + } + nPosX = nNextX; + } + } + else + { + //Point aStart( nScrX, nPosY-nOneY ); + //Point aEnd( nScrX+nScrW-nOneX, nPosY-nOneY ); + //pDev->DrawLine( aStart, aEnd ); + aGrid.AddHorLine( nScrX, nScrX+nScrW-nOneX, nPosY-nOneY ); + } + } + } + } +} + +// ---------------------------------------------------------------------------- + +void ScOutputData::SetPagebreakMode( ScPageBreakData* pPageData ) +{ + bPagebreakMode = TRUE; + if (!pPageData) + return; // noch nicht initialisiert -> alles "nicht gedruckt" + + // gedruckten Bereich markieren + // (in FillInfo ist schon alles auf FALSE initialisiert) + + USHORT nRangeCount = pPageData->GetCount(); + for (USHORT nPos=0; nPos<nRangeCount; nPos++) + { + ScRange aRange = pPageData->GetData( nPos ).GetPrintRange(); + + USHORT nStartX = Max( aRange.aStart.Col(), nX1 ); + USHORT nEndX = Min( aRange.aEnd.Col(), nX2 ); + USHORT nStartY = Max( aRange.aStart.Row(), nY1 ); + USHORT nEndY = Min( aRange.aEnd.Row(), nY2 ); + + for (USHORT nArrY=1; nArrY+1<nArrCount; nArrY++) + { + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + if ( pThisRowInfo->bChanged && pThisRowInfo->nRowNo >= nStartY && + pThisRowInfo->nRowNo <= nEndY ) + { + for (USHORT nX=nStartX; nX<=nEndX; nX++) + pThisRowInfo->pCellInfo[nX+1].bPrinted = TRUE; + } + } + } +} + +void ScOutputData::FindRotated() +{ + //! nRotMax speichern + USHORT nRotMax = nX2; + for (USHORT nRotY=0; nRotY<nArrCount; nRotY++) + if (pRowInfo[nRotY].nRotMaxCol != SC_ROTMAX_NONE && pRowInfo[nRotY].nRotMaxCol > nRotMax) + nRotMax = pRowInfo[nRotY].nRotMaxCol; + + for (USHORT nArrY=1; nArrY<nArrCount; nArrY++) + { + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + if ( pThisRowInfo->nRotMaxCol != SC_ROTMAX_NONE && + ( pThisRowInfo->bChanged || pRowInfo[nArrY-1].bChanged || + ( nArrY+1<nArrCount && pRowInfo[nArrY+1].bChanged ) ) ) + { + USHORT nY = pThisRowInfo->nRowNo; + + for (USHORT nX=0; nX<=nRotMax; nX++) + { + CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1]; + const ScPatternAttr* pPattern = pInfo->pPatternAttr; + const SfxItemSet* pCondSet = pInfo->pConditionSet; + + if ( !pPattern && (pDoc->GetColFlags(nX,nTab) & CR_HIDDEN) == 0 ) + { + pPattern = pDoc->GetPattern( nX, nY, nTab ); + pCondSet = pDoc->GetCondResult( nX, nY, nTab ); + } + + if ( pPattern ) // Spalte nicht ausgeblendet + { + BYTE nDir = pPattern->GetRotateDir( pCondSet ); + if (nDir != SC_ROTDIR_NONE) + { + pInfo->nRotateDir = nDir; + bAnyRotated = TRUE; + } + } + } + } + } +} + +// ---------------------------------------------------------------------------- + +USHORT lcl_GetRotateDir( ScDocument* pDoc, USHORT nCol, USHORT nRow, USHORT nTab ) +{ + const ScPatternAttr* pPattern = pDoc->GetPattern( nCol, nRow, nTab ); + const SfxItemSet* pCondSet = pDoc->GetCondResult( nCol, nRow, nTab ); + + USHORT nRet = SC_ROTDIR_NONE; + + long nAttrRotate = pPattern->GetRotateVal( pCondSet ); + if ( nAttrRotate ) + { + SvxRotateMode eRotMode = (SvxRotateMode)((const SvxRotateModeItem&) + pPattern->GetItem(ATTR_ROTATE_MODE, pCondSet)).GetValue(); + + if ( eRotMode == SVX_ROTATE_MODE_STANDARD ) + nRet = SC_ROTDIR_STANDARD; + else if ( eRotMode == SVX_ROTATE_MODE_CENTER ) + nRet = SC_ROTDIR_CENTER; + else if ( eRotMode == SVX_ROTATE_MODE_TOP || eRotMode == SVX_ROTATE_MODE_BOTTOM ) + { + long nRot180 = nAttrRotate % 18000; // 1/100 Grad + if ( nRot180 == 9000 ) + nRet = SC_ROTDIR_CENTER; + else if ( ( eRotMode == SVX_ROTATE_MODE_TOP && nRot180 < 9000 ) || + ( eRotMode == SVX_ROTATE_MODE_BOTTOM && nRot180 > 9000 ) ) + nRet = SC_ROTDIR_LEFT; + else + nRet = SC_ROTDIR_RIGHT; + } + } + + return nRet; +} + +const SvxBrushItem* lcl_FindBackground( ScDocument* pDoc, USHORT nCol, USHORT nRow, USHORT nTab ) +{ + const ScPatternAttr* pPattern = pDoc->GetPattern( nCol, nRow, nTab ); + const SfxItemSet* pCondSet = pDoc->GetCondResult( nCol, nRow, nTab ); + const SvxBrushItem* pBackground = (const SvxBrushItem*) + &pPattern->GetItem( ATTR_BACKGROUND, pCondSet ); + + USHORT nDir = lcl_GetRotateDir( pDoc, nCol, nRow, nTab ); + + // CENTER wird wie RIGHT behandelt... + if ( nDir == SC_ROTDIR_RIGHT || nDir == SC_ROTDIR_CENTER ) + { + // Text geht nach rechts -> Hintergrund von links nehmen + while ( nCol > 0 && lcl_GetRotateDir( pDoc, nCol, nRow, nTab ) == nDir && + pBackground->GetColor().GetTransparency() != 255 ) + { + --nCol; + pPattern = pDoc->GetPattern( nCol, nRow, nTab ); + pCondSet = pDoc->GetCondResult( nCol, nRow, nTab ); + pBackground = (const SvxBrushItem*)&pPattern->GetItem( ATTR_BACKGROUND, pCondSet ); + } + } + else if ( nDir == SC_ROTDIR_LEFT ) + { + // Text geht nach links -> Hintergrund von rechts nehmen + while ( nCol < MAXCOL && lcl_GetRotateDir( pDoc, nCol, nRow, nTab ) == nDir && + pBackground->GetColor().GetTransparency() != 255 ) + { + ++nCol; + pPattern = pDoc->GetPattern( nCol, nRow, nTab ); + pCondSet = pDoc->GetCondResult( nCol, nRow, nTab ); + pBackground = (const SvxBrushItem*)&pPattern->GetItem( ATTR_BACKGROUND, pCondSet ); + } + } + + return pBackground; +} + +// ---------------------------------------------------------------------------- + +BOOL lcl_EqualBack( const RowInfo& rFirst, const RowInfo& rOther, + USHORT nX1, USHORT nX2, BOOL bShowProt, BOOL bPagebreakMode ) +{ + if ( rFirst.bChanged != rOther.bChanged || + rFirst.bEmptyBack != rOther.bEmptyBack ) + return FALSE; + + USHORT nX; + if ( bShowProt ) + { + for ( nX=nX1; nX<=nX2; nX++ ) + { + const ScPatternAttr* pPat1 = rFirst.pCellInfo[nX+1].pPatternAttr; + const ScPatternAttr* pPat2 = rOther.pCellInfo[nX+1].pPatternAttr; + if ( !pPat1 || !pPat2 || + &pPat1->GetItem(ATTR_PROTECTION) != &pPat2->GetItem(ATTR_PROTECTION) ) + return FALSE; + } + } + else + { + for ( nX=nX1; nX<=nX2; nX++ ) + if ( rFirst.pCellInfo[nX+1].pBackground != rOther.pCellInfo[nX+1].pBackground ) + return FALSE; + } + + if ( rFirst.nRotMaxCol != SC_ROTMAX_NONE || rOther.nRotMaxCol != SC_ROTMAX_NONE ) + for ( nX=nX1; nX<=nX2; nX++ ) + if ( rFirst.pCellInfo[nX+1].nRotateDir != rOther.pCellInfo[nX+1].nRotateDir ) + return FALSE; + + if ( bPagebreakMode ) + for ( nX=nX1; nX<=nX2; nX++ ) + if ( rFirst.pCellInfo[nX+1].bPrinted != rOther.pCellInfo[nX+1].bPrinted ) + return FALSE; + + return TRUE; +} + +void ScOutputData::DrawBackground() +{ + FindRotated(); //! von aussen ? + + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + Color aBgColor = rStyleSettings.GetWindowColor(); + + Rectangle aRect; + Size aOnePixel = pDev->PixelToLogic(Size(1,1)); + long nOneX = aOnePixel.Width(); + long nOneY = aOnePixel.Height(); + + if (bMetaFile) + nOneX = nOneY = 0; + + pDev->SetLineColor(); + + BOOL bShowProt = bSyntaxMode && pDoc->IsTabProtected(nTab); + BOOL bDoAll = bShowProt || bPagebreakMode || bSolidBackground; + + long nPosY = nScrY; + for (USHORT nArrY=1; nArrY+1<nArrCount; nArrY++) + { + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + long nRowHeight = pThisRowInfo->nHeight; + + if ( pThisRowInfo->bChanged ) + { + if ( ( ( pThisRowInfo->bEmptyBack ) || bSyntaxMode ) && !bDoAll ) + { + // nichts + } + else + { + // scan for rows with the same background: + USHORT nSkip = 0; + while ( nArrY+nSkip+2<nArrCount && + lcl_EqualBack( *pThisRowInfo, pRowInfo[nArrY+nSkip+1], + nX1, nX2, bShowProt, bPagebreakMode ) ) + { + ++nSkip; + nRowHeight += pRowInfo[nArrY+nSkip].nHeight; // after incrementing + } + + long nPosX = nScrX; + aRect = Rectangle( nPosX,nPosY, nPosX,nPosY+nRowHeight-nOneY ); + + const SvxBrushItem* pOldBackground = NULL; + const SvxBrushItem* pBackground; + for (USHORT nX=nX1; nX<=nX2; nX++) + { + CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1]; + + if (bShowProt) // Zellschutz im Syntax-Modus anzeigen + { + const ScPatternAttr* pP = pInfo->pPatternAttr; + if (pP) + { + const ScProtectionAttr& rProt = (const ScProtectionAttr&) + pP->GetItem(ATTR_PROTECTION); + if (rProt.GetProtection() || rProt.GetHideCell()) + pBackground = ScGlobal::GetProtectedBrushItem(); + else + pBackground = ScGlobal::GetEmptyBrushItem(); + } + else + pBackground = NULL; + } + else + pBackground = pInfo->pBackground; + + if ( bPagebreakMode && !pInfo->bPrinted ) + pBackground = ScGlobal::GetProtectedBrushItem(); + + if ( pInfo->nRotateDir > SC_ROTDIR_STANDARD && + pBackground->GetColor().GetTransparency() != 255 ) + { + USHORT nY = pRowInfo[nArrY].nRowNo; + pBackground = lcl_FindBackground( pDoc, nX, nY, nTab ); + } + + if ( pBackground != pOldBackground ) + { + aRect.Right() = nPosX-nOneX; + if (pOldBackground) // ==0 if hidden + { + Color aBackCol = pOldBackground->GetColor(); + if ( bSolidBackground && aBackCol.GetTransparency() ) + aBackCol = aBgColor; + if ( !aBackCol.GetTransparency() ) //! partial transparency? + { + pDev->SetFillColor( aBackCol ); + pDev->DrawRect( aRect ); + } + } + aRect.Left() = nPosX; + pOldBackground = pBackground; + } + nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth; + } + aRect.Right() = nPosX-nOneX; + if (pOldBackground) + { + Color aBackCol = pOldBackground->GetColor(); + if ( bSolidBackground && aBackCol.GetTransparency() ) + aBackCol = aBgColor; + if ( !aBackCol.GetTransparency() ) //! partial transparency? + { + pDev->SetFillColor( aBackCol ); + pDev->DrawRect( aRect ); + } + } + + nArrY += nSkip; + } + } + nPosY += nRowHeight; + } +} + +void ScOutputData::DrawShadow() +{ + pDev->SetLineColor(); + + long nPosY = nScrY; + for (USHORT nArrY=1; nArrY+1<nArrCount; nArrY++) + { + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + long nRowHeight = pThisRowInfo->nHeight; + + if ( pThisRowInfo->bChanged ) + { + long nPosX = nScrX; + + for (USHORT nX=nX1; nX<=nX2; nX++) + { + for (USHORT nPass=0; nPass<2; nPass++) // horizontal / vertikal + { + const SvxShadowItem* pAttr = nPass ? + pThisRowInfo->pCellInfo[nX+1].pVShadowOrigin : + pThisRowInfo->pCellInfo[nX+1].pHShadowOrigin; + if (pAttr) + { + ScShadowPart ePart = nPass ? + pThisRowInfo->pCellInfo[nX+1].eVShadowPart : + pThisRowInfo->pCellInfo[nX+1].eHShadowPart; + + long nMaxWidth = pRowInfo[0].pCellInfo[nX+1].nWidth; + if (!nMaxWidth) + { + USHORT nWx = nX+1; + while (!pRowInfo[0].pCellInfo[nWx+1].nWidth && nWx<nX2) + ++nWx; + nMaxWidth = pRowInfo[0].pCellInfo[nWx+1].nWidth; + } + + Rectangle aRect( Point(nPosX,nPosY), + Size( pRowInfo[0].pCellInfo[nX+1].nWidth, + pRowInfo[nArrY].nHeight ) ); + + long nSize = pAttr->GetWidth(); + long nSizeX = (long)(nSize*nPPTX); + if (nSizeX >= nMaxWidth) nSizeX = nMaxWidth-1; + long nSizeY = (long)(nSize*nPPTY); + if (nSizeY >= nRowHeight) nSizeY = nRowHeight-1; + + SvxShadowLocation eLoc = pAttr->GetLocation(); + + if (ePart == SC_SHADOW_HORIZ || ePart == SC_SHADOW_HSTART || + ePart == SC_SHADOW_CORNER) + { + if (eLoc == SVX_SHADOW_TOPLEFT || eLoc == SVX_SHADOW_TOPRIGHT) + aRect.Top() = aRect.Bottom() - nSizeY; + else + aRect.Bottom() = aRect.Top() + nSizeY; + } + if (ePart == SC_SHADOW_VERT || ePart == SC_SHADOW_VSTART || + ePart == SC_SHADOW_CORNER) + { + if (eLoc == SVX_SHADOW_TOPLEFT || eLoc == SVX_SHADOW_BOTTOMLEFT) + aRect.Left() = aRect.Right() - nSizeX; + else + aRect.Right() = aRect.Left() + nSizeX; + } + if (ePart == SC_SHADOW_HSTART) + { + if (eLoc == SVX_SHADOW_TOPLEFT || eLoc == SVX_SHADOW_BOTTOMLEFT) + aRect.Right() -= nSizeX; + else + aRect.Left() += nSizeX; + } + if (ePart == SC_SHADOW_VSTART) + { + if (eLoc == SVX_SHADOW_TOPLEFT || eLoc == SVX_SHADOW_TOPRIGHT) + aRect.Bottom() -= nSizeY; + else + aRect.Top() += nSizeY; + } + + pDev->SetFillColor( pAttr->GetColor() ); //! zusammenfassen + pDev->DrawRect( aRect ); + } + } + + nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth; + } + } + nPosY += nRowHeight; + } +} + +void ScOutputData::DrawExtraShadow(BOOL bLeft, BOOL bTop, BOOL bRight, BOOL bBottom) +{ + // DrawExtraShadow enthaelt DrawShadow + //! DrawShadow weglassen, stattdessen DrawExtraShadow(FALSE,FALSE,FALSE,FALSE) ??? + + pDev->SetLineColor(); + + long nPosY = nScrY - pRowInfo[0].nHeight; + for (USHORT nArrY=0; nArrY<nArrCount; nArrY++) + { + BOOL bCornerY = ( nArrY == 0 ) || ( nArrY+1 == nArrCount ); + BOOL bSkipY = ( nArrY==0 && !bTop ) || ( nArrY+1 == nArrCount && !bBottom ); + + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + long nRowHeight = pThisRowInfo->nHeight; + + if ( pThisRowInfo->bChanged && !bSkipY ) + { + long nPosX = nScrX - pRowInfo[0].pCellInfo[nX1].nWidth; + for (USHORT nArrX=nX1; nArrX<=nX2+2; nArrX++) + { + BOOL bCornerX = ( nArrX==nX1 || nArrX==nX2+2 ); + BOOL bSkipX = ( nArrX==nX1 && !bLeft ) || ( nArrX==nX2+2 && !bRight ); + + for (USHORT nPass=0; nPass<2; nPass++) // horizontal / vertikal + { + const SvxShadowItem* pAttr = nPass ? + pThisRowInfo->pCellInfo[nArrX].pVShadowOrigin : + pThisRowInfo->pCellInfo[nArrX].pHShadowOrigin; + if ( pAttr && !bSkipX ) + { + ScShadowPart ePart = nPass ? + pThisRowInfo->pCellInfo[nArrX].eVShadowPart : + pThisRowInfo->pCellInfo[nArrX].eHShadowPart; + + BOOL bDo = TRUE; + if ( (nPass==0 && bCornerX) || (nPass==1 && bCornerY) ) + if ( ePart != SC_SHADOW_CORNER ) + bDo = FALSE; + + if (bDo) + { + long nMaxWidth = pRowInfo[0].pCellInfo[nArrX].nWidth; + if (!nMaxWidth) + { + USHORT nWx = nArrX; // nX+1 + while (nWx<nX2 && !pRowInfo[0].pCellInfo[nWx+1].nWidth) + ++nWx; + nMaxWidth = pRowInfo[0].pCellInfo[nWx+1].nWidth; + } + + Rectangle aRect( Point(nPosX,nPosY), + Size( pRowInfo[0].pCellInfo[nArrX].nWidth, + pRowInfo[nArrY].nHeight ) ); + + long nSize = pAttr->GetWidth(); + long nSizeX = (long)(nSize*nPPTX); + if (nSizeX >= nMaxWidth) nSizeX = nMaxWidth-1; + long nSizeY = (long)(nSize*nPPTY); + if (nSizeY >= nRowHeight) nSizeY = nRowHeight-1; + + SvxShadowLocation eLoc = pAttr->GetLocation(); + + if (ePart == SC_SHADOW_HORIZ || ePart == SC_SHADOW_HSTART || + ePart == SC_SHADOW_CORNER) + { + if (eLoc == SVX_SHADOW_TOPLEFT || eLoc == SVX_SHADOW_TOPRIGHT) + aRect.Top() = aRect.Bottom() - nSizeY; + else + aRect.Bottom() = aRect.Top() + nSizeY; + } + if (ePart == SC_SHADOW_VERT || ePart == SC_SHADOW_VSTART || + ePart == SC_SHADOW_CORNER) + { + if (eLoc == SVX_SHADOW_TOPLEFT || eLoc == SVX_SHADOW_BOTTOMLEFT) + aRect.Left() = aRect.Right() - nSizeX; + else + aRect.Right() = aRect.Left() + nSizeX; + } + if (ePart == SC_SHADOW_HSTART) + { + if (eLoc == SVX_SHADOW_TOPLEFT || eLoc == SVX_SHADOW_BOTTOMLEFT) + aRect.Right() -= nSizeX; + else + aRect.Left() += nSizeX; + } + if (ePart == SC_SHADOW_VSTART) + { + if (eLoc == SVX_SHADOW_TOPLEFT || eLoc == SVX_SHADOW_TOPRIGHT) + aRect.Bottom() -= nSizeY; + else + aRect.Top() += nSizeY; + } + + pDev->SetFillColor( pAttr->GetColor() ); //! zusammenfassen + pDev->DrawRect( aRect ); + } + } + } + + nPosX += pRowInfo[0].pCellInfo[nArrX].nWidth; + } + } + nPosY += nRowHeight; + } +} + +// +// Loeschen +// + +void ScOutputData::DrawClear() +{ + Rectangle aRect; + Size aOnePixel = pDev->PixelToLogic(Size(1,1)); + long nOneX = aOnePixel.Width(); + long nOneY = aOnePixel.Height(); + + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + Color aBgColor = rStyleSettings.GetWindowColor(); + + + if (bMetaFile) + nOneX = nOneY = 0; + + pDev->SetLineColor(); + + pDev->SetFillColor( aBgColor ); + + long nPosY = nScrY; + for (USHORT nArrY=1; nArrY+1<nArrCount; nArrY++) + { + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + long nRowHeight = pThisRowInfo->nHeight; + + if ( pThisRowInfo->bChanged ) + { + // scan for more rows which must be painted: + USHORT nSkip = 0; + while ( nArrY+nSkip+2<nArrCount && pRowInfo[nArrY+nSkip+1].bChanged ) + { + ++nSkip; + nRowHeight += pRowInfo[nArrY+nSkip].nHeight; // after incrementing + } + + aRect = Rectangle( Point( nScrX, nPosY ), + Size( nScrW+1-nOneX, nRowHeight+1-nOneY) ); + pDev->DrawRect( aRect ); + + nArrY += nSkip; + } + nPosY += nRowHeight; + } +} + + +// +// Linien +// + +void lcl_SnapPixelX( OutputDevice* pDev, long& rValue ) +{ + if (rValue) + { + Size aSize = pDev->LogicToPixel(Size(rValue,0)); + rValue = pDev->PixelToLogic(aSize).Width(); + } +} + +void lcl_SnapPixelY( OutputDevice* pDev, long& rValue ) +{ + if (rValue) + { + Size aSize = pDev->LogicToPixel(Size(0,rValue)); + rValue = pDev->PixelToLogic(aSize).Height(); + } +} + +inline short MultOne( short nVal, double nScale ) +{ + return nVal ? Max((short)1, (short)(nVal*nScale)) : 0; +} + +inline void GetLineStruct( ScLineStruct& rLine, const SvxBorderLine* pAttr, double nScale ) +{ + if (pAttr) + { + rLine.nLeft = MultOne(pAttr->GetOutWidth(), nScale); + rLine.nMiddle = MultOne(pAttr->GetDistance(), nScale); + rLine.nRight = MultOne(pAttr->GetInWidth(), nScale); + } + else + { + rLine.nLeft = 0; + rLine.nMiddle = 0; + rLine.nRight = 0; + } +} + +inline void SwapLineStruct( ScLineStruct& rLine ) +{ + if ( rLine.nRight ) + { + short nTemp = rLine.nRight; + rLine.nRight = rLine.nLeft; + rLine.nLeft = nTemp; + } +} + +inline void UpdateOldRectHor( OutputDevice* pDev, Rectangle& rOldRect, BOOL& rOldValid, + long nStartX, long nStartY, long nEndX, long nEndY ) +{ + if ( rOldValid ) + { + if ( nStartY != rOldRect.Top() || nEndY != rOldRect.Bottom() || + nStartX > rOldRect.Right()+1 ) + { + pDev->DrawRect( rOldRect ); + rOldValid = FALSE; + } + } + + if ( !rOldValid ) + { + rOldRect.Left() = nStartX; + rOldRect.Top() = nStartY; + rOldRect.Bottom() = nEndY; + rOldValid = TRUE; + } + rOldRect.Right() = nEndX; +} + +inline void UpdateOldRectVer( OutputDevice* pDev, Rectangle& rOldRect, BOOL& rOldValid, + long nStartX, long nStartY, long nEndX, long nEndY ) +{ + if ( rOldValid ) + { + if ( nStartX != rOldRect.Left() || nEndX != rOldRect.Right() || + nStartY > rOldRect.Bottom()+1 ) + { + pDev->DrawRect( rOldRect ); + rOldValid = FALSE; + } + } + + if ( !rOldValid ) + { + rOldRect.Top() = nStartY; + rOldRect.Left() = nStartX; + rOldRect.Right() = nEndX; + rOldValid = TRUE; + } + rOldRect.Bottom() = nEndY; +} + +inline void FinishOldRect( OutputDevice* pDev, Rectangle& rOldRect, BOOL& rOldValid ) +{ + if ( rOldValid ) + { + pDev->DrawRect( rOldRect ); + rOldValid = FALSE; + } +} + +void ScOutputData::DrawFrame() +{ + if (bAnyRotated) + DrawRotatedFrame(); // loescht die Linien, die hier weggelassen werden muessen + + USHORT nArrY; + USHORT nArrX; + + long nPosX; + long nPosY; + + short nFirstSize; + short nSpaceSize; + short nSecondSize; + + long nDrawX; + long nDrawY; + long nDrawStartX; + long nDrawStartY; + long nDrawEndX; + long nDrawEndY; + + const SvxBorderLine* pDrawLine; + const SvxBorderLine* pOldLine = NULL; + + Color aOldCol( COL_BLACK ); + + short nLinkRes[4]; + ScLineStruct aDrawLine; + ScLineStruct aLineLT; + ScLineStruct aLineLB; + ScLineStruct aLineRT; + ScLineStruct aLineRB; + ScLineStruct aLineL; + ScLineStruct aLineR; + + // Dummy-Initialisierung + aDrawLine.nLeft = 0; + aDrawLine.nMiddle = 0; + aDrawLine.nRight = 0; + aLineLT = aDrawLine; + aLineLB = aDrawLine; + aLineRT = aDrawLine; + aLineRB = aDrawLine; + aLineL = aDrawLine; + aLineR = aDrawLine; + + BOOL bIsLine; + BOOL bWasLine; + + BOOL bOldValid = FALSE; // Rechtecke zusammenfassen + Rectangle aOldRect; + BOOL bOldValid2 = FALSE; // zweite Linien + Rectangle aOldRect2; + + pDev->SetLineColor(); + pDev->SetFillColor( aOldCol ); + + // + // Horizontale Linien + // + + nPosY = nScrY - 1; + for (nArrY=0; nArrY+1<nArrCount; nArrY++) // einer vorher + { + if (nArrY>0) // "nullte Zeile" ganz oben + nPosY += pRowInfo[nArrY].nHeight; + + long nSnapPosY = nPosY; + if (bSnapPixel) + lcl_SnapPixelY(pDev,nSnapPosY); + + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + if ( pThisRowInfo->bChanged || pRowInfo[nArrY+1].bChanged ) + { + bWasLine = FALSE; + nPosX = nScrX - 1; + + for (USHORT nX=nX1; nX<=nX2; nX++) + { + bIsLine = FALSE; + long nEndX = nPosX + pRowInfo[0].pCellInfo[nX+1].nWidth; + + pDrawLine = pThisRowInfo->pCellInfo[nX+1].pBottomLine; + if ( pDrawLine ) + { + if ( pDrawLine->GetOutWidth() ) + { + long nSnapPosX = nPosX; + long nSnapEndX = nEndX; + if (bSnapPixel) + { + lcl_SnapPixelX(pDev,nSnapPosX); + lcl_SnapPixelX(pDev,nSnapEndX); + } + + bIsLine = TRUE; + if ( pDrawLine != pOldLine ) + { + Color aColor( pDrawLine->GetColor() ); + if ( aColor != aOldCol ) + { + FinishOldRect( pDev, aOldRect, bOldValid ); + FinishOldRect( pDev, aOldRect2, bOldValid2 ); + pDev->SetFillColor( aColor ); + aOldCol = aColor; + } + + nFirstSize = Max((short) 1, (short) ( pDrawLine->GetOutWidth() * nPPTY )); + if ( pDrawLine->GetInWidth() ) + { + nSpaceSize = Max((short) 1, (short) ( pDrawLine->GetDistance() * nPPTY )); + nSecondSize = Max((short) 1, (short) ( pDrawLine->GetInWidth() * nPPTY )); + } + else + { + nSpaceSize = 0; + nSecondSize = 0; + } + } + + nDrawY = nSnapPosY - (nFirstSize + nSpaceSize + nSecondSize - 1) / 2; + + // durchzeichnen ? + + if( (nX == 0) ? FALSE : + ( pRowInfo[nArrY].pCellInfo[nX].pBottomLine == pRowInfo[nArrY].pCellInfo[nX-1].pBottomLine + && pRowInfo[nArrY].pCellInfo[nX].pRightLine == pRowInfo[nArrY].pCellInfo[nX-1].pRightLine + && pRowInfo[nArrY].pCellInfo[nX+1].pBottomLine == pRowInfo[nArrY].pCellInfo[nX].pBottomLine + && pRowInfo[nArrY].pCellInfo[nX+1].pRightLine == pRowInfo[nArrY].pCellInfo[nX].pRightLine + && pRowInfo[nArrY].pCellInfo[nX+2].pBottomLine == pRowInfo[nArrY].pCellInfo[nX+1].pBottomLine + && pRowInfo[nArrY+1].pCellInfo[nX].pRightLine == pRowInfo[nArrY+1].pCellInfo[nX-1].pRightLine + && pRowInfo[nArrY+1].pCellInfo[nX+1].pRightLine == pRowInfo[nArrY+1].pCellInfo[nX].pRightLine + ) ) + { + bIsLine = FALSE; // Variablen ungueltig + nDrawStartX = nSnapPosX + nLinkRes[0]; + nDrawEndX = nSnapEndX + nLinkRes[2]; + } + else + { + if (bWasLine) // Vorgaenger gueltig ? + { + aLineLT = aLineRT; + aLineLB = aLineRB; + aLineL = aDrawLine; + aDrawLine = aLineR; + } + else + { + aDrawLine.nLeft = nFirstSize; + aDrawLine.nMiddle = nSpaceSize; + aDrawLine.nRight = nSecondSize; + GetLineStruct( aLineLT, pRowInfo[nArrY].pCellInfo[nX].pRightLine, nPPTX ); + GetLineStruct( aLineLB, pRowInfo[nArrY+1].pCellInfo[nX].pRightLine, nPPTX ); + GetLineStruct( aLineL, pRowInfo[nArrY].pCellInfo[nX].pBottomLine, nPPTY ); + } + GetLineStruct( aLineRT, pRowInfo[nArrY].pCellInfo[nX+1].pRightLine, nPPTX ); + GetLineStruct( aLineRB, pRowInfo[nArrY+1].pCellInfo[nX+1].pRightLine, nPPTX ); + GetLineStruct( aLineR, pRowInfo[nArrY].pCellInfo[nX+2].pBottomLine, nPPTY ); + + ScLinkLine( aDrawLine, aLineLT, aLineL, aLineLB, aLineRT, aLineR, aLineRB, nLinkRes ); + + nDrawStartX = nSnapPosX + nLinkRes[0]; + nDrawEndX = nSnapEndX + nLinkRes[2]; + } + nDrawStartY = nDrawY; + nDrawEndY = nDrawY + nFirstSize - 1; + + UpdateOldRectHor( pDev, aOldRect, bOldValid, + nDrawStartX, nDrawStartY, nDrawEndX, nDrawEndY ); + + if (nSecondSize) + { + nDrawStartX = nSnapPosX + nLinkRes[1]; + nDrawEndX = nSnapEndX + nLinkRes[3]; + nDrawStartY = nDrawY + nFirstSize + nSpaceSize; + nDrawEndY = nDrawY + nFirstSize + nSpaceSize + nSecondSize - 1; + + UpdateOldRectHor( pDev, aOldRect2, bOldValid2, + nDrawStartX, nDrawStartY, nDrawEndX, nDrawEndY ); + } + + pOldLine = pDrawLine; // nur vorhandene + } + } + nPosX = nEndX; + bWasLine = bIsLine; + } + } + } + + // + // Vertikale Linien + // + + nPosX = nScrX - 1; + for (nArrX=nX1; nArrX<=nX2+1; nArrX++) // einer vorher + { + if (nArrX>nX1) // "nullte Zeile" ganz links + nPosX += pRowInfo[0].pCellInfo[nArrX].nWidth; + + long nSnapPosX = nPosX; + if (bSnapPixel) + lcl_SnapPixelX(pDev,nSnapPosX); + + bWasLine = FALSE; + nPosY = nScrY - 1; + for (nArrY=1; nArrY+1<nArrCount; nArrY++) + { + bIsLine = FALSE; + long nEndY = nPosY + pRowInfo[nArrY].nHeight; + + // Zeile +-1 nur, um Variablen mitzufuehren, gezeichnet wird nicht + if ( pRowInfo[nArrY].bChanged || + pRowInfo[nArrY+1].bChanged || pRowInfo[nArrY-1].bChanged ) + { + pDrawLine = pRowInfo[nArrY].pCellInfo[nArrX].pRightLine; + if ( pDrawLine ) + { + if ( pDrawLine->GetOutWidth() ) + { + long nSnapPosY = nPosY; + long nSnapEndY = nEndY; + if (bSnapPixel) + { + lcl_SnapPixelY(pDev,nSnapPosY); + lcl_SnapPixelY(pDev,nSnapEndY); + } + + bIsLine = TRUE; + if ( pDrawLine != pOldLine ) + { + Color aColor( pDrawLine->GetColor() ); + if ( aColor != aOldCol ) + { + FinishOldRect( pDev, aOldRect, bOldValid ); + FinishOldRect( pDev, aOldRect2, bOldValid2 ); + pDev->SetFillColor( aColor ); + aOldCol = aColor; + } + + nFirstSize = Max((short) 1, (short) ( pDrawLine->GetOutWidth() * nPPTX )); + if ( pDrawLine->GetInWidth() ) + { + nSpaceSize = Max((short) 1, (short) ( pDrawLine->GetDistance() * nPPTX )); + nSecondSize = Max((short) 1, (short) ( pDrawLine->GetInWidth() * nPPTX )); + } + else + { + nSpaceSize = 0; + nSecondSize = 0; + } + } + + nDrawX = nSnapPosX - (nFirstSize + nSpaceSize + nSecondSize - 1) / 2; + + // durchzeichnen ? + // (nur wenn nLinkRes gueltig -> bChanged) + + if ( nArrY >= 2 + && pRowInfo[nArrY].bChanged + && pRowInfo[nArrY-1].pCellInfo[nArrX].pRightLine == pRowInfo[nArrY-2].pCellInfo[nArrX].pRightLine + && pRowInfo[nArrY-1].pCellInfo[nArrX].pBottomLine == pRowInfo[nArrY-2].pCellInfo[nArrX].pBottomLine + && pRowInfo[nArrY ].pCellInfo[nArrX].pRightLine == pRowInfo[nArrY-1].pCellInfo[nArrX].pRightLine + && pRowInfo[nArrY ].pCellInfo[nArrX].pBottomLine == pRowInfo[nArrY-1].pCellInfo[nArrX].pBottomLine + && pRowInfo[nArrY+1].pCellInfo[nArrX].pRightLine == pRowInfo[nArrY ].pCellInfo[nArrX].pRightLine + && pRowInfo[nArrY-1].pCellInfo[nArrX+1].pBottomLine == pRowInfo[nArrY-2].pCellInfo[nArrX+1].pBottomLine + && pRowInfo[nArrY ].pCellInfo[nArrX+1].pBottomLine == pRowInfo[nArrY-1].pCellInfo[nArrX+1].pBottomLine ) + { + bIsLine = FALSE; // Variablen ungueltig + nDrawStartY = nSnapPosY + nLinkRes[0]; + nDrawEndY = nSnapEndY + nLinkRes[2]; + } + else + { + if (bWasLine) // Vorgaenger gueltig ? + { + aLineLT = aLineRT; + aLineLB = aLineRB; + aLineL = aDrawLine; + aDrawLine = aLineR; + } + else + { + aDrawLine.nLeft = nSecondSize; + aDrawLine.nMiddle = nSpaceSize; + aDrawLine.nRight = nFirstSize; + SwapLineStruct( aDrawLine ); + GetLineStruct( aLineLT, pRowInfo[nArrY-1].pCellInfo[nArrX].pBottomLine, nPPTY ); + GetLineStruct( aLineLB, pRowInfo[nArrY-1].pCellInfo[nArrX+1].pBottomLine, nPPTY ); + GetLineStruct( aLineL, pRowInfo[nArrY-1].pCellInfo[nArrX].pRightLine, nPPTX ); + SwapLineStruct( aLineL ); + } + GetLineStruct( aLineRT, pRowInfo[nArrY].pCellInfo[nArrX].pBottomLine, nPPTY ); + GetLineStruct( aLineRB, pRowInfo[nArrY].pCellInfo[nArrX+1].pBottomLine, nPPTY ); + GetLineStruct( aLineR, pRowInfo[nArrY+1].pCellInfo[nArrX].pRightLine, nPPTX ); + SwapLineStruct( aLineR ); + + ScLinkLine( aDrawLine, aLineLT, aLineL, aLineLB, aLineRT, aLineR, aLineRB, nLinkRes ); + + nDrawStartY = nSnapPosY + nLinkRes[0]; + nDrawEndY = nSnapEndY + nLinkRes[2]; + } + + if (pRowInfo[nArrY].bChanged) + { + // Zeichnen nur in wirklich geaenderten Zeilen + + nDrawStartX = nDrawX; + nDrawEndX = nDrawX + nFirstSize - 1; + + UpdateOldRectVer( pDev, aOldRect, bOldValid, + nDrawStartX, nDrawStartY, nDrawEndX, nDrawEndY ); + + if (nSecondSize && pRowInfo[nArrY].bChanged) //! + { + nDrawStartX = nDrawX + nFirstSize + nSpaceSize; + nDrawEndX = nDrawX + nFirstSize + nSpaceSize + nSecondSize - 1; + nDrawStartY = nSnapPosY + nLinkRes[1]; + nDrawEndY = nSnapEndY + nLinkRes[3]; + + + UpdateOldRectVer( pDev, aOldRect2, bOldValid2, + nDrawStartX, nDrawStartY, nDrawEndX, nDrawEndY ); + } + } + + pOldLine = pDrawLine; // nur vorhandene + } + } + } + nPosY = nEndY; + bWasLine = bIsLine; + } + + // Bei ausgeblendeten Spalten liegt die naechste Spalte an derselben Position + // -> ohne FinishOldRect wuerden die Rechtecke dann weitergezeichnet (#31261#) + FinishOldRect( pDev, aOldRect, bOldValid ); + FinishOldRect( pDev, aOldRect2, bOldValid2 ); + } + + FinishOldRect( pDev, aOldRect, bOldValid ); + FinishOldRect( pDev, aOldRect2, bOldValid2 ); +} + +// ------------------------------------------------------------------------- + +// Linie unter der Zelle + +const SvxBorderLine* lcl_FindHorLine( ScDocument* pDoc, + USHORT nCol, USHORT nRow, USHORT nTab, USHORT nRotDir, + BOOL bTopLine ) +{ + if ( nRotDir != SC_ROTDIR_LEFT && nRotDir != SC_ROTDIR_RIGHT ) + return NULL; + + BOOL bFound = FALSE; + while (!bFound) + { + if ( nRotDir == SC_ROTDIR_LEFT ) + { + // Text nach links -> Linie von rechts + if ( nCol < MAXCOL ) + ++nCol; + else + return NULL; // war nix + } + else + { + // Text nach rechts -> Linie von links + if ( nCol > 0 ) + --nCol; + else + return NULL; // war nix + } + const ScPatternAttr* pPattern = pDoc->GetPattern( nCol, nRow, nTab ); + const SfxItemSet* pCondSet = pDoc->GetCondResult( nCol, nRow, nTab ); + if ( !pPattern->GetRotateVal( pCondSet ) || + ((const SvxRotateModeItem&)pPattern->GetItem( + ATTR_ROTATE_MODE, pCondSet)).GetValue() == SVX_ROTATE_MODE_STANDARD ) + bFound = TRUE; + } + + if (bTopLine) + --nRow; + const SvxBorderLine* pThisBottom; + if ( nRow <= MAXROW ) + pThisBottom = ((const SvxBoxItem*)pDoc->GetAttr( nCol, nRow, nTab, ATTR_BORDER ))->GetBottom(); + else + pThisBottom = NULL; + const SvxBorderLine* pNextTop; + if ( nRow < MAXROW ) + pNextTop = ((const SvxBoxItem*)pDoc->GetAttr( nCol, nRow+1, nTab, ATTR_BORDER ))->GetTop(); + else + pNextTop = NULL; + + if ( HasPriority( pThisBottom, pNextTop ) ) + return pThisBottom; + else + return pNextTop; +} + +// lcl_HorizLine muss genau zu normal ausgegebenen Linien passen! + +void lcl_HorizLine( OutputDevice* pDev, const Point& rLeft, const Point& rRight, + const SvxBorderLine* pLine, double nLineScale ) +{ + // horizontal ist nicht schraeg + DBG_ASSERT( rLeft.Y() == rRight.Y(), "Horizontale Linie schraeg ???!?" ); + + if (!pLine || !pLine->GetOutWidth()) + return; + + pDev->SetLineColor(); + pDev->SetFillColor(pLine->GetColor()); + + long nFirst = (long) ( pLine->GetOutWidth() * nLineScale ); + if (nFirst == 0) + nFirst = 1; + long nSpace = 0; + long nSecond = 0; + if ( pLine->GetInWidth() ) + { + nSpace = (long) ( pLine->GetDistance() * nLineScale ); + if (nSpace == 0) + nSpace = 1; + nSecond = (long) ( pLine->GetInWidth() * nLineScale ); + if (nSecond == 0) + nSecond = 1; + } + + long nStart = rLeft.Y() - (nFirst + nSpace + nSecond - 1) / 2; + + Rectangle aRect( rLeft.X(), nStart, rRight.X(), nStart+nFirst-1 ); + pDev->DrawRect( aRect ); + + if ( nSecond ) + { + long nSecStart = nStart + nFirst + nSpace; + Rectangle aSecond( rLeft.X(), nSecStart, rRight.X(), nSecStart+nSecond-1 ); + pDev->DrawRect( aSecond ); + } +} + +long lcl_LineTotal( const SvxBorderLine& rLine, double nScale ) +{ + long nFirst = 0; + long nSpace = 0; + long nSecond = 0; + + if (rLine.GetOutWidth()) + { + nFirst = (long) ( rLine.GetOutWidth() * nScale ); + if (!nFirst) + nFirst = 1; + } + if (rLine.GetInWidth()) + { + nSpace = (long) ( rLine.GetDistance() * nScale ); + if (!nSpace) + nSpace = 1; + nSecond = (long) ( rLine.GetInWidth() * nScale ); + if (!nSecond) + nSecond = 1; + } + + return nFirst+nSpace+nSecond; +} + +void lcl_VertLine( OutputDevice* pDev, const Point& rTop, const Point& rBottom, + const SvxBorderLine* pLine, double nLineScale, + const SvxBorderLine* pTopLine, const SvxBorderLine* pBottomLine, + double nPPTY, long nTopCenter, long nBottomCenter ) +{ + if (!pLine || !pLine->GetOutWidth()) + return; + + if ( pLine->GetInWidth() ) // doppelte Linie -> zwei einzelne Aufrufe + { + long nFirst = (long) ( pLine->GetOutWidth() * nLineScale ); + if (!nFirst) + nFirst = 1; + long nSpace = (long) ( pLine->GetDistance() * nLineScale ); + if (!nSpace) + nSpace = 1; + long nSecond = (long) ( pLine->GetInWidth() * nLineScale ); + if (!nSecond) + nSecond = 1; + Point aNewTop = rTop; + Point aNewBottom = rBottom; + + // links + long nMove = ( nFirst + nSecond + nSpace - 1 ) / 2 - ( nFirst-1 ) / 2; + aNewTop.X() = rTop.X() - nMove; + aNewBottom.X() = rBottom.X() - nMove; + SvxBorderLine aLeft( &pLine->GetColor(), pLine->GetOutWidth() ); + lcl_VertLine( pDev, aNewTop, aNewBottom, &aLeft, nLineScale, + pTopLine, pBottomLine, nPPTY, nTopCenter, nBottomCenter ); + + // rechts + aNewTop.X() += nFirst + nSpace; + aNewBottom.X() += nFirst + nSpace; + SvxBorderLine aRight( &pLine->GetColor(), pLine->GetInWidth() ); + lcl_VertLine( pDev, aNewTop, aNewBottom, &aRight, nLineScale, + pTopLine, pBottomLine, nPPTY, nTopCenter, nBottomCenter ); + + return; + } + + pDev->SetLineColor(pLine->GetColor()); // PEN_NULL ??? + pDev->SetFillColor(pLine->GetColor()); + + long nWidth = (long) ( pLine->GetOutWidth() * nLineScale ); + if (nWidth == 0) + nWidth = 1; + long nSmall = (nWidth - 1) / 2; + + // Position oben/unten muss unabhaengig von der Liniendicke sein, + // damit der Winkel stimmt (oder X-Position auch anpassen) + long nTopPos = rTop.Y(); + long nBotPos = rBottom.Y(); + + long nTopLeft = rTop.X()-nSmall; + long nTopRight = nTopLeft+nWidth-1; + long nBotLeft = rBottom.X()-nSmall; + long nBotRight = nBotLeft+nWidth-1; + + Point aPoints[4]; + aPoints[0] = Point( nTopLeft, nTopPos ); + aPoints[1] = Point( nTopRight, nTopPos ); + aPoints[2] = Point( nBotRight, nBotPos ); + aPoints[3] = Point( nBotLeft, nBotPos ); + + Polygon aPoly( 4, aPoints ); + pDev->DrawPolygon( aPoly ); + + // oben abschliessen + + if ( pTopLine && pTopLine->GetOutWidth() ) + { + long nLine = lcl_LineTotal( *pTopLine, nPPTY ); + if (nLine >= 2) + { + Point aTriangle[3]; + aTriangle[0] = Point( nTopLeft, nTopPos ); // wie aPoints[0] + aTriangle[1] = Point( nTopRight, nTopPos ); // wie aPoints[1] +// aTriangle[2] = Point( rTop.X(), nTopPos - nLine/2 + 1 ); + aTriangle[2] = Point( nTopCenter, nTopPos - nLine/2 + 1 ); + Polygon aTriPoly( 3, aTriangle ); + pDev->DrawPolygon( aTriPoly ); + } + } + + // unten abschliessen + + if ( pBottomLine && pBottomLine->GetOutWidth() ) + { + long nLine = lcl_LineTotal( *pBottomLine, nPPTY ); + if (nLine >= 2) + { + Point aTriangle[3]; + aTriangle[0] = Point( nBotLeft, nBotPos ); // wie aPoints[3] + aTriangle[1] = Point( nBotRight, nBotPos ); // wie aPoints[2] +// aTriangle[2] = Point( rBottom.X(), nBotPos + nLine/2 - 1 ); + aTriangle[2] = Point( nBottomCenter, nBotPos + nLine/2 - 1 ); + Polygon aTriPoly( 3, aTriangle ); + pDev->DrawPolygon( aTriPoly ); + } + } +} + +void ScOutputData::DrawRotatedFrame() +{ + //! nRotMax speichern + USHORT nRotMax = nX2; + for (USHORT nRotY=0; nRotY<nArrCount; nRotY++) + if (pRowInfo[nRotY].nRotMaxCol != SC_ROTMAX_NONE && pRowInfo[nRotY].nRotMaxCol > nRotMax) + nRotMax = pRowInfo[nRotY].nRotMaxCol; + + const ScPatternAttr* pPattern; + const SfxItemSet* pCondSet; + const ScPatternAttr* pOldPattern = NULL; + const SfxItemSet* pOldCondSet = NULL; + + Rectangle aClipRect( Point(nScrX, nScrY), Size(nScrW, nScrH) ); + if (bMetaFile) + { + pDev->Push(); + pDev->IntersectClipRegion( aClipRect ); + } + else + pDev->SetClipRegion( Region( aClipRect ) ); + + long nPosY = nScrY; + for (USHORT nArrY=1; nArrY<nArrCount; nArrY++) + { + // Rotated wird auch 1 Zeile ueber/unter Changed gezeichnet, falls Teile + // in die Zeile hineinragen... + + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + long nRowHeight = pThisRowInfo->nHeight; + if ( pThisRowInfo->nRotMaxCol != SC_ROTMAX_NONE && + ( pThisRowInfo->bChanged || pRowInfo[nArrY-1].bChanged || + ( nArrY+1<nArrCount && pRowInfo[nArrY+1].bChanged ) ) ) + { + USHORT nY = pRowInfo[nArrY].nRowNo; + long nPosX = 0; + USHORT nX; + for (nX=0; nX<=nRotMax; nX++) + { + if (nX==nX1) nPosX = nScrX; // vorher wird einzeln berechnet + + CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1]; + long nColWidth = pRowInfo[0].pCellInfo[nX+1].nWidth; + if ( pInfo->nRotateDir > SC_ROTDIR_STANDARD && + !pInfo->bHOverlapped && !pInfo->bVOverlapped ) + { + pPattern = pInfo->pPatternAttr; + pCondSet = pInfo->pConditionSet; + if (!pPattern) + { + pPattern = pDoc->GetPattern( nX, nY, nTab ); + pInfo->pPatternAttr = pPattern; + pCondSet = pDoc->GetCondResult( nX, nY, nTab ); + pInfo->pConditionSet = pCondSet; + } + + //! LastPattern etc. + + long nAttrRotate = pPattern->GetRotateVal( pCondSet ); + SvxRotateMode eRotMode = (SvxRotateMode)((const SvxRotateModeItem&) + pPattern->GetItem(ATTR_ROTATE_MODE, pCondSet)).GetValue(); + + if ( nAttrRotate ) + { + if (nX<nX1) // negative Position berechnen + { + nPosX = nScrX; + USHORT nCol = nX1; + while (nCol > nX) + { + --nCol; + nPosX -= (long) pRowInfo[0].pCellInfo[nCol+1].nWidth; + } + } + + // Startposition minus 1, damit auch schraege Hintergruende + // zur Umrandung passen (Umrandung ist auf dem Gitter) + + long nTop = nPosY - 1; + long nBottom = nPosY + nRowHeight - 1; + long nTopLeft = nPosX - 1; + long nTopRight = nPosX + nColWidth - 1; + long nBotLeft = nTopLeft; + long nBotRight = nTopRight; + + double nRealOrient = nAttrRotate * F_PI18000; // 1/100 Grad + double nCos = cos( nRealOrient ); + double nSin = sin( nRealOrient ); + //! begrenzen !!! + long nSkew = (long) ( nRowHeight * nCos / nSin ); + + switch (eRotMode) + { + case SVX_ROTATE_MODE_BOTTOM: + nTopLeft += nSkew; + nTopRight += nSkew; + break; + case SVX_ROTATE_MODE_CENTER: + nSkew /= 2; + nTopLeft += nSkew; + nTopRight += nSkew; + nBotLeft -= nSkew; + nBotRight -= nSkew; + break; + case SVX_ROTATE_MODE_TOP: + nBotLeft -= nSkew; + nBotRight -= nSkew; + break; + } + + Point aPoints[4]; + aPoints[0] = Point( nTopLeft, nTop ); + aPoints[1] = Point( nTopRight, nTop ); + aPoints[2] = Point( nBotRight, nBottom ); + aPoints[3] = Point( nBotLeft, nBottom ); + + const SvxBrushItem* pBackground = pInfo->pBackground; + if (!pBackground) + pBackground = (const SvxBrushItem*) &pPattern->GetItem( + ATTR_BACKGROUND, pCondSet ); + const Color& rColor = pBackground->GetColor(); + if ( rColor.GetTransparency() != 255 ) + { + Polygon aPoly( 4, aPoints ); + + // ohne Pen wird bei DrawPolygon rechts und unten + // ein Pixel weggelassen... + if ( rColor.GetTransparency() == 0 ) + pDev->SetLineColor(rColor); + else + pDev->SetLineColor(); + pDev->SetFillColor(rColor); + pDev->DrawPolygon( aPoly ); + } + + const SvxBorderLine* pTopLine = + pRowInfo[nArrY-1].pCellInfo[nX+1].pBottomLine; + const SvxBorderLine* pBottomLine = pInfo->pBottomLine; + const SvxBorderLine* pLeftLine = pThisRowInfo->pCellInfo[nX].pRightLine; + const SvxBorderLine* pRightLine = pInfo->pRightLine; + + if ( nX < nX1 || nX > nX2 ) // Attribute in FillInfo nicht gesetzt + { + //! Seitengrenzen fuer Druck beruecksichtigen !!!!! + pDoc->GetBorderLines( nX, nY, nTab, + &pLeftLine, &pTopLine, &pRightLine, &pBottomLine ); + } + + lcl_HorizLine( pDev, aPoints[0],aPoints[1], pTopLine, nPPTY ); + lcl_HorizLine( pDev, aPoints[3],aPoints[2], pBottomLine, nPPTY ); + + double nVLineScale = nPPTX / fabs(nSin); + lcl_VertLine( pDev, aPoints[0],aPoints[3], pLeftLine, + nVLineScale, pTopLine, pBottomLine, nPPTY, + aPoints[0].X(), aPoints[3].X() ); + lcl_VertLine( pDev, aPoints[1],aPoints[2], pRightLine, + nVLineScale, pTopLine, pBottomLine, nPPTY, + aPoints[1].X(), aPoints[2].X() ); + } + } + nPosX += nColWidth; + } + + // erst hinterher im zweiten Schritt die Linien fuer normale Ausgabe loeschen + + nX = nX1 ? (nX1-1) : 0; + for (; nX<=nX2+1; nX++) // sichtbarer Teil +- 1 + { + CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1]; + if ( pInfo->nRotateDir > SC_ROTDIR_STANDARD && + !pInfo->bHOverlapped && !pInfo->bVOverlapped ) + { + pPattern = pInfo->pPatternAttr; + pCondSet = pInfo->pConditionSet; + SvxRotateMode eRotMode = (SvxRotateMode)((const SvxRotateModeItem&) + pPattern->GetItem(ATTR_ROTATE_MODE, pCondSet)).GetValue(); + + // horizontal: angrenzende Linie verlaengern + // (nur, wenn die gedrehte Zelle eine Umrandung hat) + USHORT nDir = pInfo->nRotateDir; + if ( pRowInfo[nArrY-1].pCellInfo[nX+1].pBottomLine && + eRotMode != SVX_ROTATE_MODE_TOP ) + pRowInfo[nArrY-1].pCellInfo[nX+1].pBottomLine = + lcl_FindHorLine( pDoc, nX, nY, nTab, nDir, TRUE ); + if ( pInfo->pBottomLine && eRotMode != SVX_ROTATE_MODE_BOTTOM ) + pInfo->pBottomLine = lcl_FindHorLine( pDoc, nX, nY, nTab, nDir, FALSE ); + + // vertikale Linien kommen immer ganz weg... + pThisRowInfo->pCellInfo[nX].pRightLine = NULL; + pInfo->pRightLine = NULL; + } + } + } + nPosY += nRowHeight; + } + + if (bMetaFile) + pDev->Pop(); + else + pDev->SetClipRegion(); +} + +// Drucker + +void ScOutputData::DrawPageBorder( USHORT nStartX, USHORT nStartY, USHORT nEndX, USHORT nEndY ) +{ + PutInOrder( nStartX, nEndX ); + PutInOrder( nStartY, nEndY ); + + if ( nStartX <= nX2 && nEndX >= nX1 && + nStartY <= nY2 && nEndY >= nY1 ) + { + long nMinX = nScrX; + long nMinY = nScrY; + long nMaxX = nScrX+nScrW-1; + long nMaxY = nScrY+nScrH-1; + BOOL bTop = FALSE; + BOOL bBottom = FALSE; + BOOL bLeft = FALSE; + BOOL bRight = FALSE; + + long nPosY = nScrY; + for (USHORT nArrY=1; nArrY+1<nArrCount; nArrY++) + { + USHORT nY = pRowInfo[nArrY].nRowNo; + + if ( nY==nStartY ) + { + nMinY = nPosY; + bTop = TRUE; + } + + if ( nY==nEndY ) + { +// nMaxY = nPosY + pRowInfo[nArrY].nHeight - 2; + nMaxY = nPosY + pRowInfo[nArrY].nHeight; + bBottom = TRUE; + } + + nPosY += pRowInfo[nArrY].nHeight; + } + + RowInfo* pThisRowInfo = &pRowInfo[0]; + long nPosX = nScrX; + for (USHORT nX=nX1; nX<=nX2; nX++) + { + if ( nX==nStartX ) + { + nMinX = nPosX; + bLeft = TRUE; + } + if ( nX==nEndX ) + { +// nMaxX = nPosX + pRowInfo[0].pCellInfo[nX+1].nWidth - 2; + nMaxX = nPosX + pRowInfo[0].pCellInfo[nX+1].nWidth; + bRight = TRUE; + } + nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth; + } + + pDev->SetLineColor( COL_BLACK ); + if (bTop && bBottom && bLeft && bRight) + { + pDev->SetFillColor(); + pDev->DrawRect( Rectangle( nMinX, nMinY, nMaxX, nMaxY ) ); + } + else + { + if (bTop) + pDev->DrawLine( Point( nMinX,nMinY ), Point( nMaxX,nMinY ) ); + if (bBottom) + pDev->DrawLine( Point( nMinX,nMaxY ), Point( nMaxX,nMaxY ) ); + if (bLeft) + pDev->DrawLine( Point( nMinX,nMinY ), Point( nMinX,nMaxY ) ); + if (bRight) + pDev->DrawLine( Point( nMaxX,nMinY ), Point( nMaxX,nMaxY ) ); + } + } +} + +BOOL ScOutputData::SetChangedClip() +{ + PolyPolygon aPoly; + + Rectangle aDrawingRect; + aDrawingRect.Left() = nScrX; + aDrawingRect.Right() = nScrX+nScrW-1; + + BOOL bHad = FALSE; + long nPosY = nScrY; + USHORT nArrY; + for (nArrY=1; nArrY+1<nArrCount; nArrY++) + { + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + + if ( pThisRowInfo->bChanged ) + { + if (!bHad) + { + aDrawingRect.Top() = nPosY; + bHad = TRUE; + } + aDrawingRect.Bottom() = nPosY + pRowInfo[nArrY].nHeight - 1; + } + else if (bHad) + { + aPoly.Insert( Polygon( pDev->PixelToLogic(aDrawingRect) ) ); + bHad = FALSE; + } + nPosY += pRowInfo[nArrY].nHeight; + } + + if (bHad) + aPoly.Insert( Polygon( pDev->PixelToLogic(aDrawingRect) ) ); + + BOOL bRet = (aPoly.Count() != 0); + if (bRet) + pDev->SetClipRegion(Region(aPoly)); + return bRet; +} + +void ScOutputData::FindChanged() +{ + USHORT nX; + USHORT nArrY; + + BOOL bWasIdleDisabled = pDoc->IsIdleDisabled(); + pDoc->DisableIdle( TRUE ); + for (nArrY=0; nArrY<nArrCount; nArrY++) + pRowInfo[nArrY].bChanged = FALSE; + + BOOL bProgress = FALSE; + for (nArrY=0; nArrY<nArrCount; nArrY++) + { + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + for (nX=nX1; nX<=nX2; nX++) + { + ScBaseCell* pCell = pThisRowInfo->pCellInfo[nX+1].pCell; + if (pCell) + if (pCell->GetCellType() == CELLTYPE_FORMULA) + { + ScFormulaCell* pFCell = (ScFormulaCell*)pCell; + if ( !bProgress && pFCell->GetDirty() ) + { + ScProgress::CreateInterpretProgress( pDoc, TRUE ); + bProgress = TRUE; + } + if (!pFCell->IsRunning()) + { + double aVal = pFCell->GetValue(); + if (pFCell->IsChanged()) + { + pThisRowInfo->bChanged = TRUE; + if ( pThisRowInfo->pCellInfo[nX+1].bMerged ) + { + USHORT nOverY = nArrY + 1; + while ( nOverY<nArrCount && + pRowInfo[nOverY].pCellInfo[nX+1].bVOverlapped ) + { + pRowInfo[nOverY].bChanged = TRUE; + ++nOverY; + } + } + } + } + } + } + } + if ( bProgress ) + ScProgress::DeleteInterpretProgress(); + pDoc->DisableIdle( bWasIdleDisabled ); +} + +void ScOutputData::DrawMark( Window* pWin ) +{ + Rectangle aRect; + ScInvertMerger aInvert( pWin ); + //! additional method AddLineRect for ScInvertMerger? + + long nPosY = nScrY; + for (USHORT nArrY=1; nArrY+1<nArrCount; nArrY++) + { + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + if ( pThisRowInfo->bChanged ) + { + long nPosX = nScrX; + aRect = Rectangle( Point( nPosX,nPosY ), Size(0, pThisRowInfo->nHeight) ); + + BOOL bOldMarked = FALSE; + for (USHORT nX=nX1; nX<=nX2; nX++) + { + if ( pThisRowInfo->pCellInfo[nX+1].bMarked != bOldMarked ) + { + if (bOldMarked && aRect.Right() >= aRect.Left()) + aInvert.AddRect( aRect ); + aRect.Left() = nPosX; + bOldMarked = pThisRowInfo->pCellInfo[nX+1].bMarked; + } + nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth; + aRect.Right() = nPosX-1; + } + if (bOldMarked && aRect.Right() >= aRect.Left()) + aInvert.AddRect( aRect ); + } + nPosY += pThisRowInfo->nHeight; + } +} + +void ScOutputData::DrawRefMark( USHORT nRefStartX, USHORT nRefStartY, + USHORT nRefEndX, USHORT nRefEndY, + const Color& rColor, BOOL bHandle ) +{ + PutInOrder( nRefStartX, nRefEndX ); + PutInOrder( nRefStartY, nRefEndY ); + + if ( nRefStartX == nRefEndX && nRefStartY == nRefEndY ) + pDoc->ExtendMerge( nRefStartX, nRefStartY, nRefEndX, nRefEndY, nTab ); + + if ( nRefStartX <= nX2 && nRefEndX >= nX1 && + nRefStartY <= nY2 && nRefEndY >= nY1 ) + { + long nMinX = nScrX; + long nMinY = nScrY; + long nMaxX = nScrX+nScrW-1; + long nMaxY = nScrY+nScrH-1; + BOOL bTop = FALSE; + BOOL bBottom = FALSE; + BOOL bLeft = FALSE; + BOOL bRight = FALSE; + + long nPosY = nScrY; + BOOL bNoStartY = FALSE; + BOOL bNoEndY = FALSE; + for (USHORT nArrY=1; nArrY+1<nArrCount; nArrY++) + { + USHORT nY = pRowInfo[nArrY].nRowNo; + + if ( nY==nRefStartY || (nY>nRefStartY && bNoStartY) ) + { + nMinY = nPosY; + bTop = TRUE; + } + if ( nY==nRefEndY ) + { + nMaxY = nPosY + pRowInfo[nArrY].nHeight - 2; + bBottom = TRUE; + } + if ( nY>nRefEndY && bNoEndY ) + { + nMaxY = nPosY-2; + bBottom = TRUE; + } + bNoStartY = ( nY < nRefStartY ); + bNoEndY = ( nY < nRefEndY ); + nPosY += pRowInfo[nArrY].nHeight; + } + + RowInfo* pThisRowInfo = &pRowInfo[0]; + long nPosX = nScrX; + for (USHORT nX=nX1; nX<=nX2; nX++) + { + if ( nX==nRefStartX ) + { + nMinX = nPosX; + bLeft = TRUE; + } + if ( nX==nRefEndX ) + { + nMaxX = nPosX + pRowInfo[0].pCellInfo[nX+1].nWidth - 2; + bRight = TRUE; + } + nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth; + } + + if ( nMaxX >= nMinX && nMaxY >= nMinY ) + { + pDev->SetLineColor( rColor ); + if (bTop && bBottom && bLeft && bRight) + { + pDev->SetFillColor(); + pDev->DrawRect( Rectangle( nMinX, nMinY, nMaxX, nMaxY ) ); + } + else + { + if (bTop) + pDev->DrawLine( Point( nMinX,nMinY ), Point( nMaxX,nMinY ) ); + if (bBottom) + pDev->DrawLine( Point( nMinX,nMaxY ), Point( nMaxX,nMaxY ) ); + if (bLeft) + pDev->DrawLine( Point( nMinX,nMinY ), Point( nMinX,nMaxY ) ); + if (bRight) + pDev->DrawLine( Point( nMaxX,nMinY ), Point( nMaxX,nMaxY ) ); + } + if ( bHandle && bRight && bBottom ) + { + pDev->SetLineColor(); + pDev->SetFillColor( rColor ); + pDev->DrawRect( Rectangle( nMaxX-3, nMaxY-3, nMaxX+1, nMaxY+1 ) ); + } + } + } +} + +void ScOutputData::DrawOneChange( USHORT nRefStartX, USHORT nRefStartY, + USHORT nRefEndX, USHORT nRefEndY, + const Color& rColor, USHORT nType ) +{ + PutInOrder( nRefStartX, nRefEndX ); + PutInOrder( nRefStartY, nRefEndY ); + + if ( nRefStartX == nRefEndX && nRefStartY == nRefEndY ) + pDoc->ExtendMerge( nRefStartX, nRefStartY, nRefEndX, nRefEndY, nTab ); + + if ( nRefStartX <= nX2 + 1 && nRefEndX >= nX1 && + nRefStartY <= nY2 + 1 && nRefEndY >= nY1 ) // +1 weil's links oben raus geht + { + long nMinX = nScrX; + long nMinY = nScrY; + long nMaxX = nScrX+nScrW-1; + long nMaxY = nScrY+nScrH-1; + BOOL bTop = FALSE; + BOOL bBottom = FALSE; + BOOL bLeft = FALSE; + BOOL bRight = FALSE; + + long nPosY = nScrY; + BOOL bNoStartY = FALSE; + BOOL bNoEndY = FALSE; + for (USHORT nArrY=1; nArrY<nArrCount; nArrY++) + { + USHORT nY = pRowInfo[nArrY].nRowNo; + + if ( nY==nRefStartY || (nY>nRefStartY && bNoStartY) ) + { + nMinY = nPosY - 1; + bTop = TRUE; + } + if ( nY==nRefEndY ) + { + nMaxY = nPosY + pRowInfo[nArrY].nHeight - 1; + bBottom = TRUE; + } + if ( nY>nRefEndY && bNoEndY ) + { + nMaxY = nPosY - 1; + bBottom = TRUE; + } + bNoStartY = ( nY < nRefStartY ); + bNoEndY = ( nY < nRefEndY ); + nPosY += pRowInfo[nArrY].nHeight; + } + + RowInfo* pThisRowInfo = &pRowInfo[0]; + long nPosX = nScrX; + for (USHORT nX=nX1; nX<=nX2+1; nX++) + { + if ( nX==nRefStartX ) + { + nMinX = nPosX - 1; + bLeft = TRUE; + } + if ( nX==nRefEndX ) + { + nMaxX = nPosX + pRowInfo[0].pCellInfo[nX+1].nWidth - 1; + bRight = TRUE; + } + nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth; + } + + if ( nMaxX >= nMinX && nMaxY >= nMinY ) + { + if ( nType == SC_CAT_DELETE_ROWS ) + bLeft = bRight = bBottom = FALSE; //! dicke Linie ??? + else if ( nType == SC_CAT_DELETE_COLS ) + bTop = bBottom = bRight = FALSE; //! dicke Linie ??? + + pDev->SetLineColor( rColor ); + if (bTop && bBottom && bLeft && bRight) + { + pDev->SetFillColor(); + pDev->DrawRect( Rectangle( nMinX, nMinY, nMaxX, nMaxY ) ); + } + else + { + if (bTop) + { + pDev->DrawLine( Point( nMinX,nMinY ), Point( nMaxX,nMinY ) ); + if ( nType == SC_CAT_DELETE_ROWS ) + pDev->DrawLine( Point( nMinX,nMinY+1 ), Point( nMaxX,nMinY+1 ) ); + } + if (bBottom) + pDev->DrawLine( Point( nMinX,nMaxY ), Point( nMaxX,nMaxY ) ); + if (bLeft) + { + pDev->DrawLine( Point( nMinX,nMinY ), Point( nMinX,nMaxY ) ); + if ( nType == SC_CAT_DELETE_COLS ) + pDev->DrawLine( Point( nMinX+1,nMinY ), Point( nMinX+1,nMaxY ) ); + } + if (bRight) + pDev->DrawLine( Point( nMaxX,nMinY ), Point( nMaxX,nMaxY ) ); + } + if ( bLeft && bTop ) + { + pDev->SetLineColor(); + pDev->SetFillColor( rColor ); + pDev->DrawRect( Rectangle( nMinX+1, nMinY+1, nMinX+3, nMinY+3 ) ); + } + } + } +} + +void ScOutputData::DrawChangeTrack() +{ + ScChangeTrack* pTrack = pDoc->GetChangeTrack(); + ScChangeViewSettings* pSettings = pDoc->GetChangeViewSettings(); + if ( !pTrack || !pTrack->GetFirst() || !pSettings || !pSettings->ShowChanges() ) + return; // nix da oder abgeschaltet + + ScActionColorChanger aColorChanger(*pTrack); + + // Clipping passiert von aussen + //! ohne Clipping, nur betroffene Zeilen painten ??!??!? + + USHORT nEndX = nX2; + USHORT nEndY = nY2; + if ( nEndX < MAXCOL ) ++nEndX; // auch noch von der naechsten Zelle, weil die Markierung + if ( nEndY < MAXROW ) ++nEndY; // in die jeweils vorhergehende Zelle hineinragt + ScRange aViewRange( nX1, nY1, nTab, nEndX, nEndY, nTab ); + const ScChangeAction* pAction = pTrack->GetFirst(); + while (pAction) + { + ScChangeActionType eType; + if ( pAction->IsVisible() ) + { + eType = pAction->GetType(); + const ScBigRange& rBig = pAction->GetBigRange(); + if ( rBig.aStart.Tab() == nTab ) + { + ScRange aRange = rBig.MakeRange(); + + if ( eType == SC_CAT_DELETE_ROWS ) + aRange.aEnd.SetRow( aRange.aStart.Row() ); + else if ( eType == SC_CAT_DELETE_COLS ) + aRange.aEnd.SetCol( aRange.aStart.Col() ); + + if ( aRange.Intersects( aViewRange ) && + ScViewUtil::IsActionShown( *pAction, *pSettings, *pDoc ) ) + { + aColorChanger.Update( *pAction ); + Color aColor( aColorChanger.GetColor() ); + DrawOneChange( aRange.aStart.Col(), aRange.aStart.Row(), + aRange.aEnd.Col(), aRange.aEnd.Row(), aColor, eType ); + + } + } + if ( eType == SC_CAT_MOVE && + ((const ScChangeActionMove*)pAction)-> + GetFromRange().aStart.Tab() == nTab ) + { + ScRange aRange = ((const ScChangeActionMove*)pAction)-> + GetFromRange().MakeRange(); + if ( aRange.Intersects( aViewRange ) && + ScViewUtil::IsActionShown( *pAction, *pSettings, *pDoc ) ) + { + aColorChanger.Update( *pAction ); + Color aColor( aColorChanger.GetColor() ); + DrawOneChange( aRange.aStart.Col(), aRange.aStart.Row(), + aRange.aEnd.Col(), aRange.aEnd.Row(), aColor, eType ); + } + } + } + + pAction = pAction->GetNext(); + } +} + +void ScOutputData::DrawNoteMarks() +{ + BOOL bFirst = TRUE; + + long nPosY = nScrY; + for (USHORT nArrY=1; nArrY+1<nArrCount; nArrY++) + { + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + if ( pThisRowInfo->bChanged ) + { + long nPosX = nScrX; + for (USHORT nX=nX1; nX<=nX2; nX++) + { + CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1]; + ScBaseCell* pCell = pInfo->pCell; + BOOL bIsMerged = FALSE; + + if ( nX==nX1 && pInfo->bHOverlapped && !pInfo->bVOverlapped ) + { + // find start of merged cell + bIsMerged = TRUE; + USHORT nY = pRowInfo[nArrY].nRowNo; + USHORT nMergeX = nX; + USHORT nMergeY = nY; + pDoc->ExtendOverlapped( nMergeX, nMergeY, nX, nY, nTab ); + pCell = pDoc->GetCell( ScAddress(nMergeX,nMergeY,nTab) ); + // use origin's pCell for NotePtr test below + } + + if ( pCell && pCell->GetNotePtr() && ( bIsMerged || + ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) ) + { + if (bFirst) + { + pDev->SetLineColor(); + pDev->SetFillColor(COL_LIGHTRED); + bFirst = FALSE; + } + + long nMarkX = nPosX + pRowInfo[0].pCellInfo[nX+1].nWidth - 4; + if ( bIsMerged || pInfo->bMerged ) + { + // if merged, add widths of all cells + USHORT nNextX = nX + 1; + while ( nNextX <= nX2 + 1 && pThisRowInfo->pCellInfo[nNextX+1].bHOverlapped ) + { + nMarkX += pRowInfo[0].pCellInfo[nNextX+1].nWidth; + ++nNextX; + } + } + if ( nMarkX < nScrX+nScrW ) + pDev->DrawRect( Rectangle( nMarkX,nPosY,nMarkX+2,nPosY+2 ) ); + } + + nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth; + } + } + nPosY += pThisRowInfo->nHeight; + } +} + +long lcl_FindInList( const List& rPosList, const ScTripel &rPos ) +{ + long nCount = rPosList.Count(); + for (long i=0; i<nCount; i++) + if (*(ScTripel*)rPosList.GetObject(i) == rPos) + return i+1; + + return 0; +} + +void ScOutputData::PrintNoteMarks( const List& rPosList ) +{ + Font aFont; + ((const ScPatternAttr&)pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN)).GetFont(aFont); + aFont.SetSize( Size( 0, (long) ( 120 * nPPTY ) ) ); // 6 pt + pDev->SetFont( aFont ); + + String aStr; + + long nPosY = nScrY; + for (USHORT nArrY=1; nArrY+1<nArrCount; nArrY++) + { + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + if ( pThisRowInfo->bChanged ) + { + long nPosX = nScrX; + for (USHORT nX=nX1; nX<=nX2; nX++) + { + CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1]; + ScBaseCell* pCell = pInfo->pCell; + if ( pCell && pCell->GetNotePtr() ) // auch verdeckte wegen der Numerierung + { + aStr = lcl_FindInList( rPosList, ScTripel( nX, pThisRowInfo->nRowNo, nTab ) ); + long nMarkX = nPosX + pRowInfo[0].pCellInfo[nX+1].nWidth - 2 - + pDev->GetTextWidth(aStr); + pDev->DrawText( Point( nMarkX,nPosY ), aStr ); + } + + nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth; + } + } + nPosY += pThisRowInfo->nHeight; + } +} + +void ScOutputData::ConnectObject( const SvInPlaceObjectRef& rRef, SdrOle2Obj* pOleObj ) +{ + if (rRef.Is()) + { + ULONG nMisc = rRef->GetMiscStatus(); + if ( nMisc & SVOBJ_MISCSTATUS_ACTIVATEWHENVISIBLE ) + pViewShell->ConnectObject( pOleObj ); + } +} + +void ScOutputData::DrawClipMarks() +{ + if (!bAnyClipped) + return; + + long nPosY = nScrY; + for (USHORT nArrY=1; nArrY+1<nArrCount; nArrY++) + { + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + if ( pThisRowInfo->bChanged ) + { + USHORT nY = pThisRowInfo->nRowNo; + long nPosX = nScrX; + for (USHORT nX=nX1; nX<=nX2; nX++) + { + CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1]; + if (pInfo->bStandard) //! umbenennen in bClipped + { + if (pInfo->bHOverlapped || pInfo->bVOverlapped) + { + //! ... + } + + long nOutWidth = pRowInfo[0].pCellInfo[nX+1].nWidth; + long nOutHeight = pThisRowInfo->nHeight; + + if ( pInfo->bMerged && pInfo->pPatternAttr ) + { + USHORT nOverX = nX; + USHORT nOverY = nY; + USHORT i; + const ScMergeAttr* pMerge = + (ScMergeAttr*)&pInfo->pPatternAttr->GetItem(ATTR_MERGE); + USHORT nCountX = pMerge->GetColMerge(); + for (i=1; i<nCountX; i++) + nOutWidth += (long) ( pDoc->GetColWidth(nOverX+i,nTab) * nPPTX ); + USHORT nCountY = pMerge->GetRowMerge(); + for (i=1; i<nCountY; i++) + nOutHeight += (long) ( pDoc->GetRowHeight(nOverY+i,nTab) * nPPTY ); + + } + + Rectangle aCellRect( Point( nPosX, nPosY ), Size( nOutWidth, nOutHeight ) ); + + long nMarkPixel = (long)( SC_CLIPMARK_SIZE * nPPTX ); + Size aMarkSize( nMarkPixel, (nMarkPixel-1)*2 ); + + Rectangle aMarkRect = aCellRect; + aMarkRect.Left() = aCellRect.Right()-nMarkPixel; + aMarkRect.Bottom() -= 1; // nicht das Gitter uebermalen + aMarkRect.Right() -= 1; +#if 0 + //! Test + pDev->SetLineColor(); pDev->SetFillColor(COL_LIGHTGREEN); + pDev->DrawRect(aMarkRect); + //! Test +#endif + SvxFont::DrawArrow( *pDev, aMarkRect, aMarkSize, Color(COL_LIGHTRED), FALSE ); + } + + nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth; + } + } + nPosY += pThisRowInfo->nHeight; + } +} + + + diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx new file mode 100644 index 000000000000..67a654e7be0c --- /dev/null +++ b/sc/source/ui/view/output2.cxx @@ -0,0 +1,2884 @@ +/************************************************************************* + * + * $RCSfile: output2.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <svx/adjitem.hxx> +#include <svx/algitem.hxx> +#include <svx/colritem.hxx> +#include <svx/editstat.hxx> +#include <svx/fhgtitem.hxx> +#include <svx/langitem.hxx> +#include <svx/rotmodit.hxx> +#include <svtools/zforlist.hxx> +#include <vcl/svapp.hxx> +#include <vcl/metric.hxx> +#include <vcl/outdev.hxx> +#include <math.h> + +#include "output.hxx" +#include "document.hxx" +#include "cell.hxx" +#include "attrib.hxx" +#include "patattr.hxx" +#include "cellform.hxx" +#include "editutil.hxx" +#include "progress.hxx" + + //! Autofilter-Breite mit column.cxx zusammenfassen +#define DROPDOWN_BITMAP_SIZE 17 + +#define DRAWTEXT_MAX 32767 + + +// STATIC DATA ----------------------------------------------------------- + +// ----------------------------------------------------------------------- + +class ScDrawStringsVars +{ + ScOutputData* pOutput; // Verbindung + SvNumberFormatter* pFormatter; + + const ScPatternAttr* pPattern; // Attribute + const SfxItemSet* pCondSet; // aus bedingter Formatierung + + Font aFont; // aus Attributen erzeugt + FontMetric aMetric; + SvxCellOrientation eAttrOrient; + SvxCellHorJustify eAttrHorJust; + SvxCellVerJustify eAttrVerJust; + const SvxMarginItem* pMargin; + USHORT nIndent; + BOOL bRotated; + + String aString; // Inhalte + Size aTextSize; + + ScBaseCell* pLastCell; + ULONG nValueFormat; + BOOL bLineBreak; + +public: + ScDrawStringsVars(ScOutputData* pData); + ~ScDrawStringsVars(); + + // SetPattern = ex-SetVars + // SetPatternSimple: ohne Font + + void SetPattern( const ScPatternAttr* pNew, const SfxItemSet* pSet, ScBaseCell* pCell ); + void SetPatternSimple( const ScPatternAttr* pNew, const SfxItemSet* pSet ); + + BOOL SetText( ScBaseCell* pCell ); // TRUE -> pOldPattern vergessen + void ResetText(); + void SetHashText(); + + const ScPatternAttr* GetPattern() const { return pPattern; } + SvxCellOrientation GetOrient() const { return eAttrOrient; } + SvxCellHorJustify GetHorJust() const { return eAttrHorJust; } + SvxCellVerJustify GetVerJust() const { return eAttrVerJust; } + const SvxMarginItem* GetMargin() const { return pMargin; } + + USHORT GetLeftTotal() const { return pMargin->GetLeftMargin() + nIndent; } + + const String& GetString() const { return aString; } + const Size& GetTextSize() const { return aTextSize; } + + ULONG GetValueFormat() const { return nValueFormat; } + BOOL GetLineBreak() const { return bLineBreak; } + + long GetAscent() const { return aMetric.GetAscent(); } + BOOL IsRotated() const { return bRotated; } + + BOOL HasCondHeight() const { return pCondSet && SFX_ITEM_SET == + pCondSet->GetItemState( ATTR_FONT_HEIGHT, TRUE ); } +}; + +//================================================================== + +ScDrawStringsVars::ScDrawStringsVars(ScOutputData* pData) : + pOutput ( pData ), + pPattern ( NULL ), + pCondSet ( NULL ), + pMargin ( NULL ), + nIndent ( 0 ), + bRotated ( FALSE ), + eAttrHorJust( SVX_HOR_JUSTIFY_STANDARD ), + eAttrVerJust( SVX_VER_JUSTIFY_BOTTOM ), + eAttrOrient ( SVX_ORIENTATION_STANDARD ), + bLineBreak ( FALSE ), + nValueFormat( 0 ), + pLastCell ( NULL ) +{ + pFormatter = pData->pDoc->GetFormatTable(); +} + +ScDrawStringsVars::~ScDrawStringsVars() +{ +} + +void ScDrawStringsVars::SetPattern( const ScPatternAttr* pNew, const SfxItemSet* pSet, + ScBaseCell* pCell ) +{ + pPattern = pNew; + pCondSet = pSet; + + // pPattern auswerten + + OutputDevice* pDev = pOutput->pDev; + OutputDevice* pRefDevice = pOutput->pRefDevice; + + // Font + + pPattern->GetFont( aFont, pRefDevice, &pOutput->aZoomY, pCondSet ); + aFont.SetAlign(ALIGN_BASELINE); + + // Orientierung + + const SfxPoolItem* pCondItem; + if ( pCondSet && pCondSet->GetItemState( ATTR_ORIENTATION, TRUE, &pCondItem ) == SFX_ITEM_SET ) + eAttrOrient = (SvxCellOrientation)((const SvxOrientationItem*)pCondItem)->GetValue(); + else + eAttrOrient = (SvxCellOrientation) + ((const SvxOrientationItem&)pPattern->GetItem(ATTR_ORIENTATION)).GetValue(); + + short nRot; + switch (eAttrOrient) + { + case SVX_ORIENTATION_STANDARD: + nRot = 0; + long nRotate; + if ( pCondSet && pCondSet->GetItemState( ATTR_ROTATE_VALUE, TRUE, &pCondItem ) == + SFX_ITEM_SET ) + nRotate = ((const SfxInt32Item*)pCondItem)->GetValue(); + else + nRotate = ((const SfxInt32Item&)pPattern->GetItem(ATTR_ROTATE_VALUE)).GetValue(); + bRotated = ( nRotate != 0 ); + break; + case SVX_ORIENTATION_STACKED: + nRot = 0; + bRotated = FALSE; + break; + case SVX_ORIENTATION_TOPBOTTOM: + nRot = 2700; + bRotated = FALSE; + break; + case SVX_ORIENTATION_BOTTOMTOP: + nRot = 900; + bRotated = FALSE; + break; + default: + DBG_ERROR("Falscher SvxCellOrientation Wert"); + nRot = 0; + bRotated = FALSE; + break; + } + aFont.SetOrientation( nRot ); + + // Syntax-Modus + + if (pOutput->bSyntaxMode) + pOutput->SetSyntaxColor( &aFont, pCell ); + + pDev->SetFont( aFont ); + if ( pRefDevice != pDev ) + pRefDevice->SetFont( aFont ); + + aMetric = pRefDevice->GetFontMetric(); + + // + // Wenn auf dem Drucker das Leading 0 ist, gibt es Probleme + // -> Metric vom Bildschirm nehmen (wie EditEngine!) + // + + if ( pRefDevice->GetOutDevType() == OUTDEV_PRINTER && aMetric.GetLeading() == 0 ) + { + OutputDevice* pDefaultDev = Application::GetDefaultDevice(); + MapMode aOld = pDefaultDev->GetMapMode(); + pDefaultDev->SetMapMode( pRefDevice->GetMapMode() ); + aMetric = pDefaultDev->GetFontMetric( aFont ); + pDefaultDev->SetMapMode( aOld ); + } + + // Ausrichtung + + if ( pCondSet && pCondSet->GetItemState( ATTR_HOR_JUSTIFY, TRUE, &pCondItem ) == SFX_ITEM_SET ) + eAttrHorJust = (SvxCellHorJustify) + ((const SvxHorJustifyItem*)pCondItem)->GetValue(); + else + eAttrHorJust = (SvxCellHorJustify) + ((const SvxHorJustifyItem&)pPattern->GetItem(ATTR_HOR_JUSTIFY)).GetValue(); + + if ( pCondSet && pCondSet->GetItemState( ATTR_VER_JUSTIFY, TRUE, &pCondItem ) == SFX_ITEM_SET ) + eAttrVerJust = (SvxCellVerJustify) + ((const SvxVerJustifyItem*)pCondItem)->GetValue(); + else + eAttrVerJust = (SvxCellVerJustify) + ((const SvxVerJustifyItem&)pPattern->GetItem(ATTR_VER_JUSTIFY)).GetValue(); + if ( eAttrVerJust == SVX_VER_JUSTIFY_STANDARD ) + eAttrVerJust = SVX_VER_JUSTIFY_BOTTOM; + + // Umbruch + + if ( pCondSet && pCondSet->GetItemState( ATTR_LINEBREAK, TRUE, &pCondItem ) == SFX_ITEM_SET ) + bLineBreak = ((const SfxBoolItem*)pCondItem)->GetValue(); + else + bLineBreak = ((const SfxBoolItem&)pPattern->GetItem(ATTR_LINEBREAK)).GetValue(); + + // Zahlenformat + + ULONG nOld = nValueFormat; + nValueFormat = pPattern->GetNumberFormat( pFormatter, pCondSet ); + +/* s.u. + if (nValueFormat != nOld) + pLastCell = NULL; // immer neu formatieren +*/ + // Raender + + if ( pCondSet && pCondSet->GetItemState( ATTR_MARGIN, TRUE, &pCondItem ) == SFX_ITEM_SET ) + pMargin = (const SvxMarginItem*)pCondItem; + else + pMargin = (const SvxMarginItem*)&pPattern->GetItem(ATTR_MARGIN); + if ( eAttrHorJust == SVX_HOR_JUSTIFY_LEFT ) + { + if ( pCondSet && pCondSet->GetItemState( ATTR_INDENT, TRUE, &pCondItem ) == SFX_ITEM_SET ) + nIndent = ((const SfxUInt16Item*)pCondItem)->GetValue(); + else + nIndent = ((const SfxUInt16Item&)pPattern->GetItem(ATTR_INDENT)).GetValue(); + } + else + nIndent = 0; + + // zumindest die Text-Groesse muss neu geholt werden + //! unterscheiden, und den Text nicht neu vom Numberformatter holen? + + pLastCell = NULL; +} + +void ScDrawStringsVars::SetPatternSimple( const ScPatternAttr* pNew, const SfxItemSet* pSet ) +{ + // wird gerufen, wenn sich die Font-Variablen nicht aendern (!StringDiffer) + + pPattern = pNew; + pCondSet = pSet; //! noetig ??? + + // Zahlenformat + + ULONG nOld = nValueFormat; +// nValueFormat = pPattern->GetNumberFormat( pFormatter ); + const SfxPoolItem* pFormItem; + if ( !pCondSet || pCondSet->GetItemState(ATTR_VALUE_FORMAT,TRUE,&pFormItem) != SFX_ITEM_SET ) + pFormItem = &pPattern->GetItem(ATTR_VALUE_FORMAT); + const SfxPoolItem* pLangItem; + if ( !pCondSet || pCondSet->GetItemState(ATTR_LANGUAGE_FORMAT,TRUE,&pLangItem) != SFX_ITEM_SET ) + pLangItem = &pPattern->GetItem(ATTR_LANGUAGE_FORMAT); + nValueFormat = pFormatter->GetFormatForLanguageIfBuiltIn( + ((SfxUInt32Item*)pFormItem)->GetValue(), + ((SvxLanguageItem*)pLangItem)->GetLanguage() ); + + if (nValueFormat != nOld) + pLastCell = NULL; // immer neu formatieren + + // Raender + + const SfxPoolItem* pCondItem; + if ( pCondSet && pCondSet->GetItemState( ATTR_MARGIN, TRUE, &pCondItem ) == SFX_ITEM_SET ) + pMargin = (const SvxMarginItem*)pCondItem; + else + pMargin = (const SvxMarginItem*)&pPattern->GetItem(ATTR_MARGIN); + if ( eAttrHorJust == SVX_HOR_JUSTIFY_LEFT ) + { + if ( pCondSet && pCondSet->GetItemState( ATTR_INDENT, TRUE, &pCondItem ) == SFX_ITEM_SET ) + nIndent = ((const SfxUInt16Item*)pCondItem)->GetValue(); + else + nIndent = ((const SfxUInt16Item&)pPattern->GetItem(ATTR_INDENT)).GetValue(); + } + else + nIndent = 0; +} + +inline BOOL SameValue( ScBaseCell* pCell, ScBaseCell* pOldCell ) // pCell ist != 0 +{ + return pOldCell && pOldCell->GetCellType() == CELLTYPE_VALUE && + pCell->GetCellType() == CELLTYPE_VALUE && + ((ScValueCell*)pCell)->GetValue() == ((ScValueCell*)pOldCell)->GetValue(); +} + +BOOL ScDrawStringsVars::SetText( ScBaseCell* pCell ) +{ + BOOL bChanged = FALSE; + + if (pCell) + { + if ( !SameValue( pCell, pLastCell ) ) + { + pLastCell = pCell; // Zelle merken + + Color* pColor; + ULONG nFormat = GetValueFormat(); + ScCellFormat::GetString( pCell, + nFormat, aString, &pColor, + *pFormatter, + pOutput->bShowNullValues, + pOutput->bShowFormulas, + ftCheck ); + + if (aString.Len() > DRAWTEXT_MAX) + aString.Erase(DRAWTEXT_MAX); + + if ( pColor && !pOutput->bSyntaxMode ) + { + OutputDevice* pDev = pOutput->pDev; + aFont.SetColor(*pColor); + pDev->SetFont( aFont ); // nur fuer Ausgabe + bChanged = TRUE; + pLastCell = NULL; // naechstes Mal wieder hierherkommen + } + + OutputDevice* pRefDevice = pOutput->pRefDevice; + aTextSize.Width() = pRefDevice->GetTextWidth( aString ); + aTextSize.Height() = pRefDevice->GetTextHeight(); + + if ( !pRefDevice->GetConnectMetaFile() || pRefDevice->GetOutDevType() == OUTDEV_PRINTER ) + { + double fMul = pOutput->GetStretch(); + aTextSize.Width() = (long)(aTextSize.Width() / fMul + 0.5); + } + + aTextSize.Height() = aMetric.GetAscent() + aMetric.GetDescent(); + if ( GetOrient() != SVX_ORIENTATION_STANDARD ) + { + long nTemp = aTextSize.Height(); + aTextSize.Height() = aTextSize.Width(); + aTextSize.Width() = nTemp; + } + } + // sonst String/Groesse behalten + } + else + { + aString.Erase(); + pLastCell = NULL; + aTextSize = Size(0,0); + } + + return bChanged; +} + +void ScDrawStringsVars::ResetText() +{ + aString.Erase(); + pLastCell = NULL; + aTextSize = Size(0,0); +} + +void ScDrawStringsVars::SetHashText() +{ + aString = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("###")); + + OutputDevice* pRefDevice = pOutput->pRefDevice; + aTextSize.Width() = pRefDevice->GetTextWidth( aString ); + aTextSize.Height() = pRefDevice->GetTextHeight(); + + if ( !pRefDevice->GetConnectMetaFile() || pRefDevice->GetOutDevType() == OUTDEV_PRINTER ) + { + double fMul = pOutput->GetStretch(); + aTextSize.Width() = (long)(aTextSize.Width() / fMul + 0.5); + } + + aTextSize.Height() = aMetric.GetAscent() + aMetric.GetDescent(); + if ( GetOrient() != SVX_ORIENTATION_STANDARD ) + { + long nTemp = aTextSize.Height(); + aTextSize.Height() = aTextSize.Width(); + aTextSize.Width() = nTemp; + } + + pLastCell = NULL; // derselbe Text kann in der naechsten Zelle wieder passen +} + +//================================================================== + +double ScOutputData::GetStretch() +{ + MapMode aOld = pRefDevice->GetMapMode(); + Fraction aFract = aOld.GetScaleY(); + aFract /= aOld.GetScaleX(); + aFract *= aZoomY; + aFract /= aZoomX; + return (double) aFract; +} + +//================================================================== + +// +// Strings ausgeben +// + +void ScOutputData::SetSyntaxColor( Font* pFont, ScBaseCell* pCell ) +{ + if (pCell) + { + switch (pCell->GetCellType()) + { + case CELLTYPE_VALUE: + pFont->SetColor( *pValueColor ); + break; + case CELLTYPE_STRING: + pFont->SetColor( *pTextColor ); + break; + case CELLTYPE_FORMULA: + pFont->SetColor( *pFormulaColor ); + break; + } + } +} + +void lcl_SetEditColor( EditEngine& rEngine, const Color& rColor ) +{ + ESelection aSel( 0, 0, rEngine.GetParagraphCount(), 0 ); + SfxItemSet aSet( rEngine.GetEmptyItemSet() ); + aSet.Put( SvxColorItem( rColor, EE_CHAR_COLOR ) ); + rEngine.SetUpdateMode( FALSE ); + rEngine.QuickSetAttribs( aSet, aSel ); + rEngine.SetUpdateMode( TRUE ); +} + +void ScOutputData::SetEditSyntaxColor( EditEngine& rEngine, ScBaseCell* pCell ) +{ + if (pCell) + { + Color aColor; + switch (pCell->GetCellType()) + { + case CELLTYPE_VALUE: + aColor = *pValueColor; + break; + case CELLTYPE_STRING: + aColor = *pTextColor; + break; + case CELLTYPE_FORMULA: + aColor = *pFormulaColor; + break; + } + lcl_SetEditColor( rEngine, aColor ); + } +} + +BOOL ScOutputData::GetMergeOrigin( USHORT nX, USHORT nY, USHORT nArrY, + USHORT& rOverX, USHORT& rOverY, + long& rVirtPosX, long& rVirtPosY, + BOOL bClipVirt, BOOL bVisRowChanged ) +{ + BOOL bDoMerge = FALSE; + BOOL bIsLeft = ( nX == nVisX1 ); + BOOL bIsTop = ( nY == nVisY1 ) || bVisRowChanged; + + CellInfo* pInfo = &pRowInfo[nArrY].pCellInfo[nX+1]; + if ( pInfo->bHOverlapped && pInfo->bVOverlapped ) + bDoMerge = bIsLeft && bIsTop; + else if ( pInfo->bHOverlapped ) + bDoMerge = bIsLeft; + else if ( pInfo->bVOverlapped ) + bDoMerge = bIsTop; + + // weiter solange versteckt +/* if (!bDoMerge) + return FALSE; +*/ + + rOverX = nX; + rOverY = nY; + BOOL bHOver = pInfo->bHOverlapped; + BOOL bVOver = pInfo->bVOverlapped; + BOOL bHidden; + + while (bHOver) // nY konstant + { + --rOverX; + bHidden = ( (pDoc->GetColFlags(rOverX,nTab) & CR_HIDDEN) != 0 ); + if ( !bDoMerge && !bHidden ) + return FALSE; + + if (rOverX >= nX1 && !bHidden) + { + rVirtPosX -= pRowInfo[0].pCellInfo[rOverX+1].nWidth; + bHOver = pRowInfo[nArrY].pCellInfo[rOverX+1].bHOverlapped; + bVOver = pRowInfo[nArrY].pCellInfo[rOverX+1].bVOverlapped; + } + else + { + if (!bClipVirt) + rVirtPosX -= (long) (pDoc->GetColWidth( rOverX, nTab ) * nPPTX); + USHORT nOverlap = ((ScMergeFlagAttr*)pDoc->GetAttr( + rOverX, rOverY, nTab, ATTR_MERGE_FLAG ))->GetValue(); + bHOver = ((nOverlap & SC_MF_HOR) != 0); + bVOver = ((nOverlap & SC_MF_VER) != 0); + } + } + + while (bVOver) + { + --rOverY; + bHidden = ( (pDoc->GetRowFlags(rOverY,nTab) & CR_HIDDEN) != 0 ); + if ( !bDoMerge && !bHidden ) + return FALSE; + + if (nArrY>0) + --nArrY; // lokale Kopie ! + + if (rOverX >= nX1 && rOverY >= nY1 && + (pDoc->GetColFlags(rOverX,nTab) & CR_HIDDEN) == 0 && + (pDoc->GetRowFlags(rOverY,nTab) & CR_HIDDEN) == 0 && + pRowInfo[nArrY].nRowNo == rOverY) + { + rVirtPosY -= pRowInfo[nArrY].nHeight; + bHOver = pRowInfo[nArrY].pCellInfo[rOverX+1].bHOverlapped; + bVOver = pRowInfo[nArrY].pCellInfo[rOverX+1].bVOverlapped; + } + else + { + if (!bClipVirt) + rVirtPosY -= (long) (pDoc->GetRowHeight( rOverY, nTab ) * nPPTY); + USHORT nOverlap = ((ScMergeFlagAttr*)pDoc->GetAttr( + rOverX, rOverY, nTab, ATTR_MERGE_FLAG ))->GetValue(); + bHOver = ((nOverlap & SC_MF_HOR) != 0); + bVOver = ((nOverlap & SC_MF_VER) != 0); + } + } + return TRUE; +} + +inline BOOL StringDiffer( const ScPatternAttr*& rpOldPattern, const ScPatternAttr*& rpNewPattern ) +{ + DBG_ASSERT( rpNewPattern, "pNewPattern" ); + + if ( rpNewPattern == rpOldPattern ) + return FALSE; + else if ( !rpOldPattern ) + return TRUE; + else if ( &rpNewPattern->GetItem( ATTR_FONT ) != &rpOldPattern->GetItem( ATTR_FONT ) ) + return TRUE; + else if ( &rpNewPattern->GetItem( ATTR_FONT_HEIGHT ) != &rpOldPattern->GetItem( ATTR_FONT_HEIGHT ) ) + return TRUE; + else if ( &rpNewPattern->GetItem( ATTR_FONT_WEIGHT ) != &rpOldPattern->GetItem( ATTR_FONT_WEIGHT ) ) + return TRUE; + else if ( &rpNewPattern->GetItem( ATTR_FONT_POSTURE ) != &rpOldPattern->GetItem( ATTR_FONT_POSTURE ) ) + return TRUE; + else if ( &rpNewPattern->GetItem( ATTR_FONT_UNDERLINE ) != &rpOldPattern->GetItem( ATTR_FONT_UNDERLINE ) ) + return TRUE; + else if ( &rpNewPattern->GetItem( ATTR_FONT_CROSSEDOUT ) != &rpOldPattern->GetItem( ATTR_FONT_CROSSEDOUT ) ) + return TRUE; + else if ( &rpNewPattern->GetItem( ATTR_FONT_CONTOUR ) != &rpOldPattern->GetItem( ATTR_FONT_CONTOUR ) ) + return TRUE; + else if ( &rpNewPattern->GetItem( ATTR_FONT_SHADOWED ) != &rpOldPattern->GetItem( ATTR_FONT_SHADOWED ) ) + return TRUE; + else if ( &rpNewPattern->GetItem( ATTR_FONT_COLOR ) != &rpOldPattern->GetItem( ATTR_FONT_COLOR ) ) + return TRUE; + else if ( &rpNewPattern->GetItem( ATTR_HOR_JUSTIFY ) != &rpOldPattern->GetItem( ATTR_HOR_JUSTIFY ) ) + return TRUE; + else if ( &rpNewPattern->GetItem( ATTR_VER_JUSTIFY ) != &rpOldPattern->GetItem( ATTR_VER_JUSTIFY ) ) + return TRUE; + else if ( &rpNewPattern->GetItem( ATTR_ORIENTATION ) != &rpOldPattern->GetItem( ATTR_ORIENTATION ) ) + return TRUE; + else if ( &rpNewPattern->GetItem( ATTR_LINEBREAK ) != &rpOldPattern->GetItem( ATTR_LINEBREAK ) ) + return TRUE; + else if ( &rpNewPattern->GetItem( ATTR_MARGIN ) != &rpOldPattern->GetItem( ATTR_MARGIN ) ) + return TRUE; + else if ( &rpNewPattern->GetItem( ATTR_ROTATE_VALUE ) != &rpOldPattern->GetItem( ATTR_ROTATE_VALUE ) ) + return TRUE; + else + { + rpOldPattern = rpNewPattern; + return FALSE; + } +} + +inline void lcl_CreateInterpretProgress( BOOL& bProgress, ScDocument* pDoc, + ScFormulaCell* pFCell ) +{ + if ( !bProgress && pFCell->GetDirty() ) + { + ScProgress::CreateInterpretProgress( pDoc, TRUE ); + bProgress = TRUE; + } +} + +BOOL lcl_IsValueDataAtPos( BOOL& bProgress, ScDocument* pDoc, + USHORT nCol, USHORT nRow, USHORT nTab ) +{ + ScBaseCell* pCell; + pDoc->GetCell( nCol, nRow, nTab, pCell ); + if ( pCell ) + { + if ( pCell->GetCellType() == CELLTYPE_FORMULA ) + { // kein weiteres Interpret anstossen + ScFormulaCell* pFCell = (ScFormulaCell*) pCell; + if ( pFCell->IsRunning() ) + return TRUE; + else + { + lcl_CreateInterpretProgress( bProgress, pDoc, pFCell ); + return pFCell->HasValueData(); + } + } + else + return pCell->HasValueData(); + } + else + return FALSE; +} + +void ScOutputData::DrawStrings() +{ + DBG_ASSERT( pDev == pRefDevice || + pDev->GetMapMode().GetMapUnit() == pRefDevice->GetMapMode().GetMapUnit(), + "DrawStrings: unterschiedliche MapUnits ?!?!" ); + + BOOL bWasIdleDisabled = pDoc->IsIdleDisabled(); + pDoc->DisableIdle( TRUE ); + Size aMinSize = pRefDevice->PixelToLogic(Size(0,100)); // erst darueber wird ausgegeben + UINT32 nMinHeight = aMinSize.Height() / 200; // 1/2 Pixel + + ScDrawStringsVars aVars( this ); + + const ScPatternAttr* pOldPattern = NULL; + const SfxItemSet* pOldCondSet = NULL; + + BOOL bProgress = FALSE; + + long nPosY = nScrY; + for (USHORT nArrY=1; nArrY+1<nArrCount; nArrY++) + { + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + if ( pThisRowInfo->bChanged ) + { + USHORT nY = pThisRowInfo->nRowNo; + long nCellHeight = (long) pThisRowInfo->nHeight; + long nPosX = nScrX; + for (USHORT nX=nX1; nX<=nX2; nX++) + { + ScForceTextFmt eForceText = ftDontForce; + + BOOL bLeftOver = FALSE; // Ueberhang von langem String (immer linksb.) + BOOL bMergeOver = FALSE; // Rest von zusammengefassten Zellen + BOOL bMergeEmpty= FALSE; + long nVirtPosX = nPosX; + long nVirtPosY = nPosY; + long nOutWidth = 0; + long nOutHeight = nCellHeight; + USHORT nOverX; // Start der zusammengefassten Zellen + USHORT nOverY; + + CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1]; + BOOL bEmpty = pInfo->bEmptyCellText; + + // + // Teil von zusammengefasster Zelle ? + // + + if ( pInfo->bHOverlapped || pInfo->bVOverlapped ) + { + bEmpty = TRUE; + + BOOL bVisChanged = !pRowInfo[nArrY-1].bChanged; + if (GetMergeOrigin( nX,nY, nArrY, nOverX,nOverY, nVirtPosX,nVirtPosY, + FALSE, bVisChanged )) + { + ScBaseCell* pCell; + pDoc->GetCell( nOverX, nOverY, nTab, pCell ); + if (pCell) + { + BOOL bEdit = ( pCell->GetCellType() == CELLTYPE_EDIT ); + if (!bEdit) + { + const ScPatternAttr* pPattern = + pDoc->GetPattern( nOverX, nOverY, nTab ); + const SfxItemSet* pCondSet = + pDoc->GetCondResult( nOverX, nOverY, nTab ); + if ( pPattern != pOldPattern || + pCondSet != pOldCondSet || bSyntaxMode ) + { + if ( StringDiffer(pOldPattern,pPattern) || + pCondSet != pOldCondSet || bSyntaxMode ) + aVars.SetPattern( pPattern, pCondSet, pCell ); + else + aVars.SetPatternSimple( pPattern, pCondSet ); + pOldPattern = pPattern; + pOldCondSet = pCondSet; + } + + if ( aVars.GetOrient() == SVX_ORIENTATION_STACKED || + aVars.IsRotated() ) + bEdit = TRUE; + } + if (!bEdit) + { + if ( pCell->GetCellType() == CELLTYPE_FORMULA ) + lcl_CreateInterpretProgress( bProgress, + pDoc, (ScFormulaCell*)pCell ); + if ( aVars.SetText(pCell) ) + pOldPattern = NULL; + + if (nOverX >= nX1) + nOutWidth = ((long)pRowInfo[0].pCellInfo[nOverX+1].nWidth) - 1; + else + nOutWidth = ((long)(pDoc->GetColWidth( nOverX, nTab ) * + nPPTX)) - 1; + + nOutHeight = (long) (pDoc->GetRowHeight( nOverY, nTab ) * nPPTY); + + bMergeOver = TRUE; + } + else // Edit-Zelle + { + if (nOverY == nY || bVisChanged) + pThisRowInfo->pCellInfo[nOverX+1].bEditEngine = TRUE; + else + pRowInfo[0].pCellInfo[nOverX+1].bEditEngine = TRUE; + } + } + } + bMergeEmpty = TRUE; + } + + // + // Rest von langem Text weiter links ? + // + + // nJustPosX ist incl. Ausrichtung, nVirtPosX fuer Clipping ohne Ausrichtung + long nJustPosX = nVirtPosX; + if ( bEmpty && !bMergeEmpty ) + { + if (nX==nX1) // links Zellen zum Weiterzeichnen ? + { + nOutWidth = ((long)pRowInfo[0].pCellInfo[nX+1].nWidth) - 1; + USHORT nTempX=nX; + while (nTempX > 0 && pThisRowInfo->pCellInfo[nTempX+1].bEmptyCellText) + { + --nTempX; + nVirtPosX -= pRowInfo[0].pCellInfo[nTempX+1].nWidth; + nOutWidth += pRowInfo[0].pCellInfo[nTempX+1].nWidth; + } + nJustPosX = nVirtPosX; + if ( !pThisRowInfo->pCellInfo[nTempX+1].bEmptyCellText ) + { + ScBaseCell* pCell = pThisRowInfo->pCellInfo[nTempX+1].pCell; + CellType eCellType = pCell->GetCellType(); + if ( eCellType == CELLTYPE_STRING || + (eCellType == CELLTYPE_FORMULA + && !lcl_IsValueDataAtPos( bProgress, pDoc, + nTempX, nY, nTab )) ) + { + const ScPatternAttr* pPattern = + pDoc->GetPattern( nTempX, nY, nTab ); + const SfxItemSet* pCondSet = + pDoc->GetCondResult( nTempX, nY, nTab ); + if ( pPattern != pOldPattern || + pCondSet != pOldCondSet || bSyntaxMode ) + { + if ( StringDiffer(pOldPattern,pPattern) || + pCondSet != pOldCondSet || bSyntaxMode ) + aVars.SetPattern( pPattern, pCondSet, pCell ); + else + aVars.SetPatternSimple( pPattern, pCondSet ); + pOldPattern = pPattern; + pOldCondSet = pCondSet; + } + + if ( aVars.GetOrient() == SVX_ORIENTATION_STANDARD && + !aVars.GetLineBreak() && !aVars.IsRotated() && + aVars.GetHorJust() != SVX_HOR_JUSTIFY_BLOCK ) + { + if ( eCellType == CELLTYPE_FORMULA ) + lcl_CreateInterpretProgress( bProgress, + pDoc, (ScFormulaCell*)pCell ); + if ( aVars.SetText(pCell) ) + pOldPattern = NULL; + + nJustPosX += (long) ( aVars.GetLeftTotal() * nPPTX ); + + if ( nJustPosX + aVars.GetTextSize().Width() + 1 > nPosX && + !pDoc->HasAttrib( nTempX,nY,nTab, nX,nY,nTab, + HASATTR_MERGED | HASATTR_OVERLAPPED ) ) + { + bLeftOver = TRUE; + } + } + } + else if (eCellType == CELLTYPE_EDIT) + { + if ( !pDoc->HasAttrib( nTempX,nY,nTab, nX,nY,nTab, + HASATTR_MERGED | HASATTR_OVERLAPPED ) ) + pThisRowInfo->pCellInfo[nTempX+1].bEditEngine = TRUE; + } + } + } + } + + if (bEditMode) + if ( nX == nEditCol && nY == nEditRow ) + bLeftOver = FALSE; + + if (!bEmpty) + if (pInfo->pCell->GetCellType() == CELLTYPE_EDIT) + { + pInfo->bEditEngine = TRUE; + bEmpty = TRUE; // Edit-Zelle hier nicht zeichnen + } + + // zu kleinen Text in der Druckvorschau als Pixel zeichnen: + + if ( !bEmpty && eType == OUTTYPE_PRINTER && + pDev->GetOutDevType() == OUTDEV_WINDOW && + ((const SvxFontHeightItem&)pInfo->pPatternAttr-> + GetItem(ATTR_FONT_HEIGHT)).GetHeight() <= nMinHeight ) + { + Point aPos(nPosX,nPosY); + pDev->DrawPixel( aPos, + ((const SvxColorItem&)pInfo->pPatternAttr-> + GetItem( ATTR_FONT_COLOR )).GetValue() ); + bEmpty = TRUE; + } + + if (!bEmpty) // bei MergeOver schon geschehen + { + const ScPatternAttr* pPattern = pInfo->pPatternAttr; + const SfxItemSet* pCondSet = pInfo->pConditionSet; + if ( pPattern != pOldPattern || + pCondSet != pOldCondSet || bSyntaxMode ) + { + if ( StringDiffer(pOldPattern,pPattern) || + pCondSet != pOldCondSet || bSyntaxMode ) + aVars.SetPattern( pPattern, pCondSet, pInfo->pCell ); + else + aVars.SetPatternSimple( pPattern, pCondSet ); + pOldPattern = pPattern; + pOldCondSet = pCondSet; + } + + if ( aVars.GetOrient() == SVX_ORIENTATION_STACKED || + aVars.IsRotated() ) + { + pInfo->bEditEngine = TRUE; + bEmpty = TRUE; + } + } + + if ( !bEmpty || bLeftOver || bMergeOver ) + { + CellType eCellType; + SvxCellHorJustify eOutHorJust; + + BOOL bMergeHClip = FALSE; // Teil von zusammengefassten ausserhalb? + BOOL bMergeVClip = FALSE; + + if ( !bEmpty || bMergeOver ) + { + if (!bEmpty) + { + if ( pInfo->pCell->GetCellType() == CELLTYPE_FORMULA ) + lcl_CreateInterpretProgress( bProgress, + pDoc, (ScFormulaCell*)pInfo->pCell ); + if ( aVars.SetText(pInfo->pCell) ) + pOldPattern = NULL; + + nOutWidth = ((long)pRowInfo[0].pCellInfo[nX+1].nWidth)-1; + } + + BOOL bMerged = bMergeOver ? TRUE : pInfo->bMerged; + + if ( bMerged ) // Zusammengefasst + { + if (!bMergeOver) + { + nOverX = nX; + nOverY = nY; + } + USHORT i; + const ScMergeAttr* pMerge = + (ScMergeAttr*)&aVars.GetPattern()->GetItem(ATTR_MERGE); + USHORT nCountX = pMerge->GetColMerge(); + for (i=1; i<nCountX; i++) + nOutWidth += (long) ( pDoc->GetColWidth(nOverX+i,nTab) * nPPTX ); + USHORT nCountY = pMerge->GetRowMerge(); + for (i=1; i<nCountY; i++) + nOutHeight += (long) ( pDoc->GetRowHeight(nOverY+i,nTab) * nPPTY ); + + if (nOverX+nCountX > nX2+1) + bMergeHClip = TRUE; + if (nOverY+nCountY > nY2+1) + bMergeVClip = TRUE; + } + + if (bEditMode) + if ( nX == nEditCol && nY == nEditRow ) + aVars.ResetText(); + + // GetTextSize ist schon bei SetText passiert + + if (bMergeOver) + { + ScBaseCell* pBCell; + pDoc->GetCell( nOverX, nOverY, nTab, pBCell ); + eCellType = (pBCell ? pBCell->GetCellType() : CELLTYPE_NONE); + if ( aVars.GetHorJust() != SVX_HOR_JUSTIFY_STANDARD ) + eOutHorJust = aVars.GetHorJust(); + else + switch( eCellType ) + { + case CELLTYPE_STRING: + eOutHorJust = SVX_HOR_JUSTIFY_LEFT; + break; + case CELLTYPE_VALUE: + eOutHorJust = ( eForceText == ftForce ) + ? SVX_HOR_JUSTIFY_LEFT + : SVX_HOR_JUSTIFY_RIGHT; + break; + case CELLTYPE_FORMULA: + { + ScFormulaCell* pFCell = (ScFormulaCell*)pBCell; + if ( pFCell->IsRunning() ) + eOutHorJust = SVX_HOR_JUSTIFY_RIGHT; + else + { + lcl_CreateInterpretProgress( bProgress, pDoc, pFCell ); + if ( pFCell->HasValueData() ) + eOutHorJust = SVX_HOR_JUSTIFY_RIGHT; + else + eOutHorJust = SVX_HOR_JUSTIFY_LEFT; + } + } + break; + default: + eOutHorJust = SVX_HOR_JUSTIFY_CENTER; // unbekannt + break; + } + } + else + { + eCellType = pInfo->pCell->GetCellType(); + if ( aVars.GetHorJust() != SVX_HOR_JUSTIFY_STANDARD ) + eOutHorJust = aVars.GetHorJust(); + else + switch( eCellType ) + { + case CELLTYPE_STRING: + eOutHorJust = SVX_HOR_JUSTIFY_LEFT; + break; + case CELLTYPE_VALUE: + eOutHorJust = ( eForceText == ftForce ) + ? SVX_HOR_JUSTIFY_LEFT + : SVX_HOR_JUSTIFY_RIGHT; + break; + case CELLTYPE_FORMULA: + { + ScFormulaCell* pFCell = (ScFormulaCell*)pInfo->pCell; + if ( pFCell->IsRunning() ) + eOutHorJust = SVX_HOR_JUSTIFY_RIGHT; + else + { + lcl_CreateInterpretProgress( bProgress, pDoc, pFCell ); + if ( pFCell->IsValue() ) + eOutHorJust = SVX_HOR_JUSTIFY_RIGHT; + else + eOutHorJust = SVX_HOR_JUSTIFY_LEFT; + } + } + break; + default: + eOutHorJust = SVX_HOR_JUSTIFY_CENTER; // unbekannt + break; + } + } + } + else // Leftover (langer String) + { + eCellType = CELLTYPE_STRING; + eOutHorJust = SVX_HOR_JUSTIFY_LEFT; + } + + if ( eOutHorJust == SVX_HOR_JUSTIFY_BLOCK || eOutHorJust == SVX_HOR_JUSTIFY_REPEAT ) + eOutHorJust = SVX_HOR_JUSTIFY_LEFT; // noch nicht implementiert + + + // Clipping testen + BOOL bHClip = FALSE; + BOOL bVClip = FALSE; +// BOOL bExtended = FALSE; + CellInfo* pClipRight = NULL; // Zelle mit Clipping-Markierung (rechts) + + long nJustOutWidth = nOutWidth; // fuer Ausrichtung + + long nNeededWidth; + if (eType == OUTTYPE_WINDOW) + nNeededWidth = aVars.GetTextSize().Width() + + (long) ( aVars.GetLeftTotal() * nPPTX ) + + (long) ( aVars.GetMargin()->GetRightMargin() * nPPTX ); + else + { + nNeededWidth = aVars.GetTextSize().Width(); // in Margin zeichnen erlaubt + switch (eOutHorJust) + { + case SVX_HOR_JUSTIFY_LEFT: + nNeededWidth += (long) ( aVars.GetLeftTotal() * nPPTX ); + break; + case SVX_HOR_JUSTIFY_RIGHT: + nNeededWidth += (long) ( aVars.GetMargin()->GetRightMargin() * nPPTX ); + break; + case SVX_HOR_JUSTIFY_CENTER: + break; + default: + nNeededWidth += (long) ( aVars.GetLeftTotal() * nPPTX ) + + (long) ( aVars.GetMargin()->GetRightMargin() * nPPTX ); + } + } + + // + // horizontalen Platz testen + // + + BOOL bNeedEditEngine = FALSE; + if ( aVars.GetLineBreak() || + aVars.GetHorJust() == SVX_HOR_JUSTIFY_BLOCK ) + { + //! hier immer Margin beruecksichtigen ??? + + BOOL bBig; + + //if (aVars.GetString().Search((sal_Unicode)10) != STRING_NOTFOUND) + // bBig = TRUE; + //else ... + + if (aVars.GetOrient() == SVX_ORIENTATION_STANDARD) + { + long nCmpWidth = nOutWidth; // auch hier AutoFilter abziehen + if ( eType==OUTTYPE_WINDOW && pInfo && pInfo->bAutoFilter ) + nCmpWidth -= Min( pThisRowInfo->nHeight, + (USHORT) DROPDOWN_BITMAP_SIZE ); + bBig = (nNeededWidth+1 > nCmpWidth); + } + else + bBig = (aVars.GetTextSize().Height() > nOutHeight); + + if (bBig) + { + if (bMergeOver) + { + // BOOL bVisChanged = !pRowInfo[nArrY-1].bChanged + if (nOverY == nY || !pRowInfo[nArrY-1].bChanged ) + pThisRowInfo->pCellInfo[nOverX+1].bEditEngine = TRUE; + else + pRowInfo[0].pCellInfo[nOverX+1].bEditEngine = TRUE; + } + else + pInfo->bEditEngine = TRUE; + bNeedEditEngine = TRUE; + } + } + + if (!bNeedEditEngine) + { + if ( eCellType == CELLTYPE_STRING || + (eCellType == CELLTYPE_FORMULA + && !lcl_IsValueDataAtPos( bProgress, pDoc, + nX, nY, nTab )) ) + { // rechts Platz suchen + if (nNeededWidth+1 > nOutWidth ) + { + if ( bMergeOver ) + { + // zusammengefasste zu klein - nicht weitersuchen + eOutHorJust = SVX_HOR_JUSTIFY_LEFT; + bHClip = TRUE; + } + else + { + if ( aVars.GetOrient() == SVX_ORIENTATION_STANDARD ) + { + if ( !pThisRowInfo->pCellInfo[nX+1].bMerged ) + { + USHORT nTempX = nX+1; + BOOL bCont = TRUE; + while (bCont) + { + BOOL bMayCont = pThisRowInfo->pCellInfo[nTempX+1].bEmptyCellText && + !pThisRowInfo->pCellInfo[nTempX+1].bMerged && + !pThisRowInfo->pCellInfo[nTempX+1].bHOverlapped && + !pThisRowInfo->pCellInfo[nTempX+1].bVOverlapped; + bCont = bMayCont && (nTempX<=nX2); + if ( bEditMode && nTempX == nEditCol && nY == nEditRow ) + bCont = FALSE; + + // Grid (fuer nTempX-1) abschalten ? + // + if (nOutWidth < nNeededWidth) + { + if (bMayCont) + pThisRowInfo->pCellInfo[nTempX].bHideGrid = TRUE; + else + pClipRight = &pThisRowInfo->pCellInfo[nTempX]; + // auf "Hindernis" gestossen + } + + if (bCont) + nOutWidth += (long) pRowInfo[0].pCellInfo[nTempX+1].nWidth; + ++nTempX; + } + } + } + +// bExtended = TRUE; + eOutHorJust = SVX_HOR_JUSTIFY_LEFT; + bHClip = bLeftOver || (nNeededWidth + 1 > nOutWidth); + } + } + else + { + bHClip = bLeftOver || bMergeOver; + } + } + else // Zahlen, Formeln + { + if (nNeededWidth + 1 > nOutWidth) + { + aVars.SetHashText(); + nNeededWidth = aVars.GetTextSize().Width() + + (long) ( aVars.GetLeftTotal() * nPPTX ) + + (long) ( aVars.GetMargin()->GetRightMargin() * nPPTX ); + bHClip = (nNeededWidth + 1 > nOutWidth); + if (bHClip) // #56609# Clip-Markierung auch fuer Zahlen + pClipRight = &pThisRowInfo->pCellInfo[nX+1]; + } + if (bMergeOver) + bHClip = TRUE; + } + + if ( !bLeftOver ) // sonst ist schon + { + long nAvailWidth = nJustOutWidth; + if (eType==OUTTYPE_WINDOW && pInfo->bAutoFilter) + { +#ifndef MAC + if (pRowInfo[nArrY].nHeight < DROPDOWN_BITMAP_SIZE) + nAvailWidth -= pRowInfo[nArrY].nHeight; + else + nAvailWidth -= DROPDOWN_BITMAP_SIZE; // Bitmap-Groesse +#else + nAvailWidth -= pRefDevice->LogicToPixel( Size(22,0), MAP_POINT ).Width(); +#endif + + long nComp = aVars.GetTextSize().Width() + + (long) ( aVars.GetLeftTotal() * nPPTX ) + + (long) ( aVars.GetMargin()->GetRightMargin() * nPPTX ); + if (nAvailWidth<nComp) nAvailWidth=nComp; + } + + switch (eOutHorJust) + { + case SVX_HOR_JUSTIFY_LEFT: + nJustPosX += (long) ( aVars.GetLeftTotal() * nPPTX ); + break; + case SVX_HOR_JUSTIFY_RIGHT: + nJustPosX += nAvailWidth - aVars.GetTextSize().Width() - + (long) ( aVars.GetMargin()->GetRightMargin() * nPPTX ); + break; + case SVX_HOR_JUSTIFY_CENTER: + nJustPosX += ( nAvailWidth - aVars.GetTextSize().Width() + + (long) ( aVars.GetLeftTotal() * nPPTX ) - + (long) ( aVars.GetMargin()->GetRightMargin() * nPPTX ) ) / 2; + break; + } + } + + long nTestClipHeight = aVars.GetTextSize().Height(); + + long nJustPosY = nVirtPosY; +// long nLongBot = (long) ( aVars.GetMargin()->GetBottomMargin() * nPPTY ); + switch (aVars.GetVerJust()) + { + case SVX_VER_JUSTIFY_TOP: + { + long nTop = (long)( aVars.GetMargin()->GetTopMargin() * nPPTY ); + nJustPosY += nTop; + nTestClipHeight += nTop; + } + break; + case SVX_VER_JUSTIFY_BOTTOM: + { + long nBot = (long)( aVars.GetMargin()->GetBottomMargin() * nPPTY ); + nJustPosY += nOutHeight - aVars.GetTextSize().Height() - nBot; + nTestClipHeight += nBot; + } + break; + case SVX_VER_JUSTIFY_CENTER: + { + long nTop = (long)( aVars.GetMargin()->GetTopMargin() * nPPTY ); + long nBot = (long)( aVars.GetMargin()->GetBottomMargin() * nPPTY ); + nJustPosY += ( nOutHeight + nTop - + aVars.GetTextSize().Height() - nBot ) / 2; + nTestClipHeight += Abs( nTop - nBot ); + } + break; + } + + if ( nTestClipHeight > nOutHeight ) + { + // kein vertikales Clipping beim Drucken von Zellen mit + // optimaler Hoehe, ausser bei Groesse in bedingter Formatierung + if ( eType != OUTTYPE_PRINTER || + ( pDoc->GetRowFlags( nY, nTab ) & CR_MANUALSIZE ) || + ( aVars.HasCondHeight() ) ) + bVClip = TRUE; + } + if ( bMergeOver ) + bVClip = TRUE; + + Rectangle aClipRect( nPosX, nPosY, nVirtPosX+nOutWidth-1, + nVirtPosY+nOutHeight-1 ); + + if ( bMergeHClip ) + { + if ( aClipRect.Right() > nScrX+nScrW ) + aClipRect.Right() = nScrX+nScrW; + bHClip = TRUE; + } + if ( bMergeVClip ) + { + if ( aClipRect.Bottom() > nScrY+nScrH ) + aClipRect.Bottom() = nScrY+nScrH; + bVClip = TRUE; + } + + if ( bHClip || bVClip ) + { + if ( pClipRight && bMarkClipped ) + { + // rechts markieren + + pClipRight->bStandard = TRUE; //! umbenennen in bClipped + bAnyClipped = TRUE; + + long nMarkPixel = (long)( SC_CLIPMARK_SIZE * nPPTX ); + aClipRect.Right() -= nMarkPixel; + } + + // nur die betroffene Dimension clippen, + // damit bei nicht-proportionalem Resize nicht alle + // rechtsbuendigen Zahlen abgeschnitten werden: + + if (!bHClip) + { + aClipRect.Left() = nScrX; + aClipRect.Right() = nScrX+nScrW; + } + if (!bVClip) + { + aClipRect.Top() = nScrY; + aClipRect.Bottom() = nScrY+nScrH; + } + +/* //! Test + if ( pDev->GetOutDevType() != OUTDEV_PRINTER ) + { + pDev->SetPen(PEN_NULL); + pDev->SetFillInBrush(Brush(Color(COL_LIGHTRED))); + pDev->DrawRect( aClipRect ); + } + //! Test +*/ + if (bMetaFile) + { + pDev->Push(); + pDev->IntersectClipRegion( aClipRect ); + } + else + pDev->SetClipRegion( Region( aClipRect ) ); + } + + switch (aVars.GetOrient()) + { + case SVX_ORIENTATION_STANDARD: + nJustPosY += aVars.GetAscent(); + break; + case SVX_ORIENTATION_TOPBOTTOM: + nJustPosX += aVars.GetTextSize().Width() - aVars.GetAscent(); + break; + case SVX_ORIENTATION_BOTTOMTOP: + nJustPosY += aVars.GetTextSize().Height(); + nJustPosX += aVars.GetAscent(); + break; + } + +#ifdef MAC_DOCH_NICHT + nJustPosY++; // Passt sonst nicht zur EditEngine +#endif +#ifdef OS2_AUCH_NICHT + nJustPosY++; // Passt sonst nicht zur EditEngine +#endif + + // in Metafiles immer DrawTextArray, damit die Positionen mit + // aufgezeichnet werden (fuer nicht-proportionales Resize): + + String aString = aVars.GetString(); + if (bMetaFile || pRefDevice != pDev || aZoomX != aZoomY) + { + long* pDX = new long[aString.Len()]; + pRefDevice->GetTextArray( aString, pDX ); + + if ( !pRefDevice->GetConnectMetaFile() || + pRefDevice->GetOutDevType() == OUTDEV_PRINTER ) + { + double fMul = GetStretch(); + xub_StrLen nLen = aString.Len(); + for (xub_StrLen i=0; i<nLen; i++) + pDX[i] = (long)(pDX[i] / fMul + 0.5); + } + + pDev->DrawTextArray( Point( nJustPosX, nJustPosY ), aString, pDX ); + delete[] pDX; + } + else + pDev->DrawText( Point( nJustPosX, nJustPosY ), aString ); + + if ( bHClip || bVClip ) + { + if (bMetaFile) + pDev->Pop(); + else + pDev->SetClipRegion(); + } + } + } + nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth; + } + } + nPosY += pRowInfo[nArrY].nHeight; + } + if ( bProgress ) + ScProgress::DeleteInterpretProgress(); + pDoc->DisableIdle( bWasIdleDisabled ); +} + +// ------------------------------------------------------------------------------- + +void lcl_ClearEdit( EditEngine& rEngine ) // Text und Attribute +{ + rEngine.SetText(EMPTY_STRING); + // keine Para-Attribute uebrigbehalten... + const SfxItemSet& rPara = rEngine.GetParaAttribs(0); + if (rPara.Count()) + rEngine.SetParaAttribs( 0, + SfxItemSet( *rPara.GetPool(), rPara.GetRanges() ) ); +} + +void ScOutputData::DrawEdit(BOOL bPixelToLogic, double nScaleX, double nScaleY) +{ + Size aMinSize = pRefDevice->PixelToLogic(Size(0,100)); // erst darueber wird ausgegeben + UINT32 nMinHeight = aMinSize.Height() / 200; // 1/2 Pixel + + SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + + ScFieldEditEngine* pEngine = NULL; + const ScPatternAttr* pPattern; + const SfxItemSet* pCondSet; + const ScPatternAttr* pOldPattern = NULL; + const SfxItemSet* pOldCondSet = NULL; + ScBaseCell* pCell = NULL; + + long nRowPosY = nScrY; + for (USHORT nArrY=0; nArrY+1<nArrCount; nArrY++) // 0 fuer Reste von zusammengefassten + { + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + long nCellHeight = (long) pThisRowInfo->nHeight; + if (nArrY==1) nRowPosY = nScrY; // vorher wird einzeln berechnet + + if ( pThisRowInfo->bChanged || nArrY==0 ) + { + long nPosX = 0; + for (USHORT nX=0; nX<=nX2; nX++) // wegen Ueberhaengen + { + if (nX==nX1) nPosX = nScrX; // vorher wird einzeln berechnet + + CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1]; + if (pInfo->bEditEngine) + { + USHORT nY = pThisRowInfo->nRowNo; + + BOOL bHidden = FALSE; + if (bEditMode) + if ( nX == nEditCol && nY == nEditRow ) + bHidden = TRUE; + + if (!bHidden) + { + if (!pEngine) + { + // Ein RefDevice muss auf jeden Fall gesetzt werden, + // sonst legt sich die EditEngine ein VirtualDevice an! + pEngine = new ScFieldEditEngine( pDoc->GetEnginePool() ); + pEngine->SetRefDevice( pRefDevice ); // immer gesetzt + ULONG nCtrl = pEngine->GetControlWord(); + if ( bShowSpellErrors ) + nCtrl |= EE_CNTRL_ONLINESPELLING; + if ( eType == OUTTYPE_PRINTER ) + nCtrl &= ~EE_CNTRL_MARKFIELDS; + pEngine->SetControlWord( nCtrl ); + } + else + lcl_ClearEdit( *pEngine ); + + long nPosY = nRowPosY; + BOOL bVisChanged = FALSE; + + if ( nArrY==0 ) + { + nPosY = nScrY; + nY = pRowInfo[1].nRowNo; + pPattern = pDoc->GetPattern( nX, nY, nTab ); + while (((ScMergeFlagAttr&)pPattern->GetItem(ATTR_MERGE_FLAG)).IsVerOverlapped()) + { + --nY; + nPosY -= (long) (pDoc->FastGetRowHeight(nY,nTab) * nPPTY); + pPattern = pDoc->GetPattern( nX, nY, nTab ); + } + pInfo = NULL; + pCondSet = pDoc->GetCondResult( nX, nY, nTab ); + pDoc->GetCell( nX, nY, nTab, pCell ); + } + else + { + BOOL bFromDoc = FALSE; + pPattern = pInfo->pPatternAttr; + pCondSet = pInfo->pConditionSet; + if (!pPattern) + { + pPattern = pDoc->GetPattern( nX, nY, nTab ); + bFromDoc = TRUE; + } + pCell = pInfo->pCell; + + bVisChanged = !pRowInfo[nArrY-1].bChanged; + if (bVisChanged) + { + while (((ScMergeFlagAttr&)pPattern->GetItem(ATTR_MERGE_FLAG)).IsVerOverlapped()) + { + --nY; + nPosY -= (long) (pDoc->FastGetRowHeight(nY,nTab) * nPPTY); + pPattern = pDoc->GetPattern( nX, nY, nTab ); + bFromDoc = TRUE; + } + pInfo = NULL; + pDoc->GetCell( nX, nY, nTab, pCell ); + } + if (bFromDoc) + pCondSet = pDoc->GetCondResult( nX, nY, nTab ); + } + + long nCellWidth = (long) pRowInfo[0].pCellInfo[nX+1].nWidth; + + const SfxPoolItem* pCondItem; + + SvxCellHorJustify eHorJust; + if ( pCondSet && pCondSet->GetItemState( + ATTR_HOR_JUSTIFY, TRUE, &pCondItem ) == SFX_ITEM_SET ) + eHorJust = (SvxCellHorJustify) ((const SvxHorJustifyItem*) + pCondItem)->GetValue(); + else + eHorJust = (SvxCellHorJustify)((const SvxHorJustifyItem&)pPattern-> + GetItem(ATTR_HOR_JUSTIFY)).GetValue(); + + BOOL bBreak; + if ( eHorJust == SVX_HOR_JUSTIFY_BLOCK ) + bBreak = TRUE; + else if ( pCondSet && pCondSet->GetItemState( + ATTR_LINEBREAK, TRUE, &pCondItem ) == SFX_ITEM_SET ) + bBreak = ((const SfxBoolItem*)pCondItem)->GetValue(); + else + bBreak = ((const SfxBoolItem&)pPattern->GetItem(ATTR_LINEBREAK)).GetValue(); + + SvxCellOrientation eOrient; + if ( pCondSet && pCondSet->GetItemState( + ATTR_ORIENTATION, TRUE, &pCondItem ) == SFX_ITEM_SET ) + eOrient = (SvxCellOrientation)((const SvxOrientationItem*) + pCondItem)->GetValue(); + else + eOrient = (SvxCellOrientation)((const SvxOrientationItem&) + pPattern->GetItem(ATTR_ORIENTATION)).GetValue(); + + long nAttrRotate; + if ( pCondSet && pCondSet->GetItemState( + ATTR_ROTATE_VALUE, TRUE, &pCondItem ) == SFX_ITEM_SET ) + nAttrRotate = ((const SfxInt32Item*)pCondItem)->GetValue(); + else + nAttrRotate = ((const SfxInt32Item&)pPattern-> + GetItem(ATTR_ROTATE_VALUE)).GetValue(); + if ( eOrient==SVX_ORIENTATION_STANDARD && nAttrRotate ) + { + //! Flag setzen, um die Zelle in DrawRotated wiederzufinden ? + //! (oder Flag schon bei DrawBackground, dann hier keine Abfrage) + bHidden = TRUE; // gedreht wird getrennt ausgegeben + } + + const ScMergeAttr* pMerge = + (ScMergeAttr*)&pPattern->GetItem(ATTR_MERGE); + BOOL bMerged = pMerge->GetColMerge() > 1 || pMerge->GetRowMerge() > 1; + + long nStartX = nPosX; + long nStartY = nPosY; + if (nX<nX1) + { + if ((bBreak || eOrient!=SVX_ORIENTATION_STANDARD) && !bMerged) + bHidden = TRUE; + else + { + nStartX = nScrX; + USHORT nCol = nX1; + while (nCol > nX) + { + --nCol; + nStartX -= (long) pRowInfo[0].pCellInfo[nCol+1].nWidth; + } + } + } + + if ( !bHidden && eType == OUTTYPE_PRINTER && + pDev->GetOutDevType() == OUTDEV_WINDOW && + ((const SvxFontHeightItem&)pPattern-> + GetItem(ATTR_FONT_HEIGHT)).GetHeight() <= nMinHeight ) + { + Point aPos((long)( nStartX / nScaleX ), + (long)( nStartY / nScaleY )); + pDev->DrawPixel( aPos, + ((const SvxColorItem&)pPattern-> + GetItem( ATTR_FONT_COLOR )).GetValue() ); + bHidden = TRUE; + } + + if (!bHidden) + { + long nOutWidth = nCellWidth - 1; + long nOutHeight; + if (pInfo) + nOutHeight = nCellHeight; + else + nOutHeight = (long) ( pDoc->GetRowHeight(nY,nTab) * nPPTY ); + + if ( bMerged ) // Zusammengefasst + { + USHORT i; + const ScMergeAttr* pMerge = + (ScMergeAttr*)&pPattern->GetItem(ATTR_MERGE); + USHORT nCountX = pMerge->GetColMerge(); + for (i=1; i<nCountX; i++) + nOutWidth += (long) ( pDoc->GetColWidth(nX+i,nTab) * nPPTX ); + USHORT nCountY = pMerge->GetRowMerge(); + for (i=1; i<nCountY; i++) + nOutHeight += (long) ( pDoc->GetRowHeight(nY+i,nTab) * nPPTY ); + } + + // aCellRect: Margins nicht abgezogen + Rectangle aCellRect( nStartX, nStartY, + nStartX+nOutWidth-1, nStartY+nOutHeight-1 ); + + SvxCellVerJustify eVerJust; + if ( pCondSet && pCondSet->GetItemState( + ATTR_VER_JUSTIFY, TRUE, &pCondItem ) == SFX_ITEM_SET ) + eVerJust = (SvxCellVerJustify) ((const SvxVerJustifyItem*) + pCondItem)->GetValue(); + else + eVerJust = (SvxCellVerJustify)((const SvxVerJustifyItem&)pPattern-> + GetItem(ATTR_VER_JUSTIFY)).GetValue(); + + // Syntax-Modus wird hier ignoriert... + + if ( StringDiffer(pOldPattern,pPattern) || pCondSet != pOldCondSet ) + { + SfxItemSet* pSet = new SfxItemSet( pEngine->GetEmptyItemSet() ); + pPattern->FillEditItemSet( pSet, pCondSet ); + + // Ausrichtung fuer EditEngine + SvxAdjust eSvxAdjust = SVX_ADJUST_LEFT; + if (eOrient==SVX_ORIENTATION_STACKED) + eSvxAdjust = SVX_ADJUST_CENTER; + else if (bBreak) + { + if (eOrient==SVX_ORIENTATION_STANDARD) + switch (eHorJust) + { + case SVX_HOR_JUSTIFY_LEFT: + case SVX_HOR_JUSTIFY_REPEAT: // nicht implementiert + case SVX_HOR_JUSTIFY_STANDARD: // immer Text + eSvxAdjust = SVX_ADJUST_LEFT; + break; + case SVX_HOR_JUSTIFY_RIGHT: + eSvxAdjust = SVX_ADJUST_RIGHT; + break; + case SVX_HOR_JUSTIFY_CENTER: + eSvxAdjust = SVX_ADJUST_CENTER; + break; + case SVX_HOR_JUSTIFY_BLOCK: + eSvxAdjust = SVX_ADJUST_BLOCK; + break; + } + else + switch (eVerJust) + { + case SVX_VER_JUSTIFY_TOP: + eSvxAdjust = (eOrient==SVX_ORIENTATION_TOPBOTTOM) ? + SVX_ADJUST_LEFT : SVX_ADJUST_RIGHT; + break; + case SVX_VER_JUSTIFY_CENTER: + eSvxAdjust = SVX_ADJUST_CENTER; + break; + case SVX_VER_JUSTIFY_BOTTOM: + case SVX_HOR_JUSTIFY_STANDARD: + eSvxAdjust = (eOrient==SVX_ORIENTATION_TOPBOTTOM) ? + SVX_ADJUST_RIGHT : SVX_ADJUST_LEFT; + break; + } + } + pSet->Put( SvxAdjustItem( eSvxAdjust, EE_PARA_JUST ) ); + + pEngine->SetDefaults( pSet ); + pOldPattern = pPattern; + pOldCondSet = pCondSet; + + ULONG nControl = pEngine->GetControlWord(); + if (eOrient==SVX_ORIENTATION_STACKED) + nControl |= EE_CNTRL_ONECHARPERLINE; + else + nControl &= ~EE_CNTRL_ONECHARPERLINE; + pEngine->SetControlWord( nControl ); + } + + // Raender + + //! Position und Papersize auf EditUtil umstellen !!! + +/* Rectangle aPixRect = ScEditUtil( pDoc, + nX,nY,nTab, Point(nStartX,nStartY), + pDev, nPPTX, nPPTY, nZoom ) + .GetEditArea( pPattern ); + + pDev->SetFillInBrush(Brush(Color(COL_LIGHTRED))); + pDev->DrawRect(pDev->PixelToLogic(aPixRect)); +*/ + const SvxMarginItem* pMargin; + if ( pCondSet && pCondSet->GetItemState( + ATTR_MARGIN, TRUE, &pCondItem ) == SFX_ITEM_SET ) + pMargin = (const SvxMarginItem*)pCondItem; + else + pMargin = (const SvxMarginItem*)&pPattern->GetItem(ATTR_MARGIN); + USHORT nIndent = 0; + if ( eHorJust == SVX_HOR_JUSTIFY_LEFT ) + { + if ( pCondSet && pCondSet->GetItemState( + ATTR_INDENT, TRUE, &pCondItem ) == SFX_ITEM_SET ) + nIndent = ((const SfxUInt16Item*)pCondItem)->GetValue(); + else + nIndent = ((const SfxUInt16Item&)pPattern-> + GetItem(ATTR_INDENT)).GetValue(); + } + long nLeftM = (long) ( (pMargin->GetLeftMargin() + nIndent) * nPPTX ); + long nTopM = (long) ( pMargin->GetTopMargin() * nPPTY ); + nStartX += nLeftM; + nStartY += nTopM; + nOutWidth -= nLeftM + (long) ( pMargin->GetRightMargin() * nPPTX ); + nOutHeight -= nTopM + (long) ( pMargin->GetBottomMargin() * nPPTY ); + + Size aPaperSize = Size( 1000000, 1000000 ); + if (eOrient==SVX_ORIENTATION_STACKED) + aPaperSize.Width() = nOutWidth; // zum Zentrieren + else if (bBreak) + { + if (eOrient == SVX_ORIENTATION_STANDARD) + { + if (eType==OUTTYPE_WINDOW && + eOrient!=SVX_ORIENTATION_STACKED && + pInfo && pInfo->bAutoFilter) + { + long nSub = Min( pRowInfo[nArrY].nHeight, + (USHORT) DROPDOWN_BITMAP_SIZE ); + if ( nOutWidth > nSub ) + nOutWidth -= nSub; + } + aPaperSize.Width() = nOutWidth; + } + else + aPaperSize.Width() = nOutHeight - 1; + } + if (bPixelToLogic) + pEngine->SetPaperSize(pRefDevice->PixelToLogic(aPaperSize)); + else + pEngine->SetPaperSize(Size( + (long)(aPaperSize.Width() / nScaleX), + (long)(aPaperSize.Height() / nScaleY))); + + // Daten aus Zelle lesen + + if (pCell) + { + if (pCell->GetCellType() == CELLTYPE_EDIT) + { + const EditTextObject* pData; + ((ScEditCell*)pCell)->GetData(pData); + + if (pData) + pEngine->SetText(*pData); + else + DBG_ERROR("pData == 0"); + } + else + { + ULONG nFormat = pPattern->GetNumberFormat( + pFormatter, pCondSet ); + String aString; + Color* pColor; + ScCellFormat::GetString( pCell, + nFormat,aString, &pColor, + *pFormatter, + bShowNullValues, + bShowFormulas, + ftCheck ); + + pEngine->SetText(aString); + if ( pColor && !bSyntaxMode ) + lcl_SetEditColor( *pEngine, *pColor ); + } + + if ( bSyntaxMode ) + SetEditSyntaxColor( *pEngine, pCell ); + } + else + DBG_ERROR("pCell == NULL"); + + long nEngineWidth; + if ( bBreak && eOrient != SVX_ORIENTATION_STACKED ) + nEngineWidth = 0; + else + nEngineWidth = (long) pEngine->CalcTextWidth(); + long nEngineHeight = pEngine->GetTextHeight(); + + if (eOrient != SVX_ORIENTATION_STANDARD && + eOrient != SVX_ORIENTATION_STACKED) + { + long nTemp = nEngineWidth; + nEngineWidth = nEngineHeight; + nEngineHeight = nTemp; + } + + if (eOrient == SVX_ORIENTATION_STACKED) + nEngineWidth = nEngineWidth * 11 / 10; + + if (nX<nX1 && !bMerged) + { + long nEnginePixel = bPixelToLogic ? + pRefDevice->LogicToPixel(Size(nEngineWidth,0)).Width() : + (long)( nEngineWidth * nScaleX ); + if ( nStartX + nEnginePixel < (long) nScrX ) + bHidden = TRUE; + } + + if (!bHidden) + { + BOOL bExtend = FALSE; // ueber Zellenrand geschrieben ? + BOOL bClip = FALSE; + CellInfo* pClipRight = NULL; // Zelle mit Clipping-Markierung + BOOL bSimClip = FALSE; + Size aClipSize = Size( nScrX+nScrW-nStartX, nScrY+nScrH-nStartY ); + + // Zelle, an der Clipping-Markierung gesetzt wird, wenn + // vertikal zu klein + CellInfo* pEndInfo = &pThisRowInfo->pCellInfo[nX+1]; + + // weiterschreiben + + Size aCellSize; + if (bPixelToLogic) + aCellSize = pRefDevice->PixelToLogic( Size( nOutWidth, nOutHeight ) ); + else + aCellSize = Size( (long)( nOutWidth / nScaleX ), + (long)( nOutHeight / nScaleY ) ); + if ( !bBreak || eOrient!=SVX_ORIENTATION_STANDARD ) + { + if ( eOrient == SVX_ORIENTATION_STANDARD && !bMerged ) + { + USHORT nNextX = nX + 1; + BOOL bCont = TRUE; + while (bCont) + { + BOOL bMayCont = + pThisRowInfo->pCellInfo[nNextX+1].bEmptyCellText && + !pThisRowInfo->pCellInfo[nNextX+1].bMerged && + !pThisRowInfo->pCellInfo[nNextX+1].bHOverlapped && + !pThisRowInfo->pCellInfo[nNextX+1].bVOverlapped; + bCont = bMayCont && (nNextX<=nX2); + if ( bEditMode && nNextX==nEditCol && nY==nEditRow ) + bCont = FALSE; + + // Grid (fuer nNextX-1) abschalten + // + if ( nEngineWidth > aCellSize.Width() ) + { + if (bMayCont) + { + pThisRowInfo->pCellInfo[nNextX].bHideGrid = TRUE; + pEndInfo = &pThisRowInfo->pCellInfo[nNextX+1]; + } + else + pClipRight = &pThisRowInfo->pCellInfo[nNextX]; + // auf "Hindernis" gestossen + } + else + bCont = FALSE; // #55142# bExtend nicht zu oft + + if (bCont) + { + long nAdd = pRowInfo[0].pCellInfo[nNextX+1].nWidth; + aCellRect.Right() += nAdd; + nOutWidth += nAdd; + if (bPixelToLogic) + aCellSize = pRefDevice->PixelToLogic( Size( nOutWidth, nOutHeight ) ); + else + aCellSize = Size( (long)( nOutWidth / nScaleX ), + (long)( nOutHeight / nScaleY ) ); + bExtend = TRUE; + } + ++nNextX; + } + } + if ( nEngineWidth > aCellSize.Width() ) + { + bExtend = TRUE; // -> immer linksbuendig + bClip = TRUE; + aClipSize.Width() = nOutWidth; // Pixel + } + } + if ( nEngineHeight > aCellSize.Height() ) + { + // kein vertikales Clipping beim Drucken von Zellen mit + // optimaler Hoehe, ausser bei Groesse in bedingter + // Formatierung + if ( eType != OUTTYPE_PRINTER || + ( pDoc->GetRowFlags( nY, nTab ) & CR_MANUALSIZE ) || + ( pCondSet && SFX_ITEM_SET == + pCondSet->GetItemState(ATTR_FONT_HEIGHT, TRUE) ) ) + bClip = TRUE; + else + bSimClip = TRUE; + aClipSize.Height() = nOutHeight; // Pixel + + // Clipping-Markierung, wenn 5 Punkt zu klein, + // nicht zusammengefasst, und mehrere Zeilen + if ( nEngineHeight - aCellSize.Height() > 100 && !bMerged && + ( pEngine->GetParagraphCount() > 1 || + pEngine->GetLineCount(0) > 1 ) ) + pClipRight = pEndInfo; + } + + long nClipStartX = nStartX; + if (nX<nX1) + { + //! Clipping unnoetig, wenn links am Fenster + + bClip = TRUE; // nur Rest ausgeben! + if (nStartX<nScrX) + { + long nDif = nScrX - nStartX; + nClipStartX = nScrX; + aClipSize.Width() -= nDif; + } + } + + long nClipStartY = nStartY; + if (nArrY==0 || bVisChanged) + { + if ( nClipStartY < nRowPosY ) + { + long nDif = nRowPosY - nClipStartY; + bClip = TRUE; + nClipStartY = nRowPosY; + aClipSize.Height() -= nDif; + } + } + + Rectangle aClipRect; + if (bClip || bSimClip) + { + if ( pClipRight && bMarkClipped ) + { + // rechts markieren + + pClipRight->bStandard = TRUE; //! umbenennen in bClipped + bAnyClipped = TRUE; + + long nMarkPixel = (long)( SC_CLIPMARK_SIZE * nPPTX ); + long nMarkLeft = aCellRect.Right()-nMarkPixel+1; + long nClipEnd = nClipStartX + aClipSize.Width(); + if (nClipEnd > nMarkLeft) + aClipSize.Width() -= nClipEnd - nMarkLeft; + } + + if (bPixelToLogic) + aClipRect = pRefDevice->PixelToLogic( Rectangle( + Point(nClipStartX,nClipStartY), aClipSize ) ); + else + aClipRect = Rectangle(Point( + (long)( nClipStartX / nScaleX ), + (long)( nClipStartY / nScaleY )), + Size( + (long)( aClipSize.Width() / nScaleX ), + (long)( aClipSize.Height() / nScaleY ))); + +#if 0 + //! Test + if ( pDev->GetOutDevType() != OUTDEV_PRINTER ) + { + pDev->SetPen(PEN_NULL); + if (bClip) + pDev->SetFillInBrush(Brush(Color(COL_LIGHTGREEN))); + else + pDev->SetFillInBrush(Brush(Color(COL_LIGHTRED))); + pDev->DrawRect( aClipRect ); + } + //! Test +#endif + + if (bClip) // bei bSimClip nur aClipRect initialisieren + { + if (bMetaFile) + { + pDev->Push(); + pDev->IntersectClipRegion( aClipRect ); + } + else + pDev->SetClipRegion( Region( aClipRect ) ); + } + } + + Point aLogicStart; + if (bPixelToLogic) + aLogicStart = pRefDevice->PixelToLogic( Point(nStartX,nStartY) ); + else + aLogicStart = Point((long)( nStartX / nScaleX ), + (long)( nStartY / nScaleY )); + if ( (eOrient!=SVX_ORIENTATION_STANDARD || !bBreak) && !bExtend ) + { + long nAvailWidth = aCellSize.Width(); + if (eType==OUTTYPE_WINDOW && + eOrient!=SVX_ORIENTATION_STACKED && + pInfo && pInfo->bAutoFilter) + { + USHORT nSub = Min( pRowInfo[nArrY].nHeight, + (USHORT) DROPDOWN_BITMAP_SIZE ); + if (bPixelToLogic) + nAvailWidth -= pRefDevice->PixelToLogic(Size(0,nSub)).Height(); + else + nAvailWidth -= (long) (nSub / nScaleX); + if (nAvailWidth < nEngineWidth) nAvailWidth = nEngineWidth; + + nOutWidth -= nSub; + long nEnginePixel = bPixelToLogic ? + pRefDevice->LogicToPixel(Size(nEngineWidth,0)).Width() : + (long)( nEngineWidth * nScaleX ); + if (nOutWidth <= nEnginePixel) nOutWidth = nEnginePixel+1; + } + + // horizontale Ausrichtung + + if (eOrient==SVX_ORIENTATION_STANDARD) + { + if (eHorJust==SVX_HOR_JUSTIFY_RIGHT || + eHorJust==SVX_HOR_JUSTIFY_CENTER) + { + SvxAdjust eSvxAdjust = + (eHorJust==SVX_HOR_JUSTIFY_RIGHT) ? + SVX_ADJUST_RIGHT : SVX_ADJUST_CENTER; + pEngine->SetDefaultItem( + SvxAdjustItem( eSvxAdjust, EE_PARA_JUST ) ); + + // #55142# Adjustment fuer naechste Zelle wieder zurueck + pOldPattern = NULL; + + aPaperSize.Width() = nOutWidth; + if (bPixelToLogic) + pEngine->SetPaperSize(pRefDevice->PixelToLogic(aPaperSize)); + else + pEngine->SetPaperSize(Size( + (long)(aPaperSize.Width() / nScaleX), + (long)(aPaperSize.Height() / nScaleY))); + } + } + else + { + if (eHorJust==SVX_HOR_JUSTIFY_RIGHT) + aLogicStart.X() += nAvailWidth - nEngineWidth; + else if (eHorJust==SVX_HOR_JUSTIFY_CENTER) + aLogicStart.X() += (nAvailWidth - nEngineWidth) / 2; + } + } + if ( eOrient==SVX_ORIENTATION_STANDARD || + eOrient==SVX_ORIENTATION_STACKED || !bBreak ) + { + if (eVerJust==SVX_VER_JUSTIFY_BOTTOM || + eVerJust==SVX_VER_JUSTIFY_STANDARD) + { + if (bPixelToLogic) + aLogicStart.Y() += pRefDevice->PixelToLogic( Size(0, + pRefDevice->LogicToPixel(aCellSize).Height() - + pRefDevice->LogicToPixel(Size(0,nEngineHeight)).Height() + )).Height(); + else + aLogicStart.Y() += aCellSize.Height() - nEngineHeight; + } + + else if (eVerJust==SVX_VER_JUSTIFY_CENTER) + { + if (bPixelToLogic) + aLogicStart.Y() += pRefDevice->PixelToLogic( Size(0,( + pRefDevice->LogicToPixel(aCellSize).Height() - + pRefDevice->LogicToPixel(Size(0,nEngineHeight)).Height()) + / 2)).Height(); + else + aLogicStart.Y() += (aCellSize.Height() - nEngineHeight) / 2; + } + } + + short nOriVal = 0; + if (eOrient==SVX_ORIENTATION_TOPBOTTOM) + { + // nOriVal = -900; + nOriVal = 2700; + aLogicStart.X() += nEngineWidth; + } + else if (eOrient==SVX_ORIENTATION_BOTTOMTOP) + { + nOriVal = 900; + aLogicStart.Y() += bBreak ? aCellSize.Height() : + nEngineHeight; + } + else if (eOrient==SVX_ORIENTATION_STACKED) + { + Size aPaperLogic = pEngine->GetPaperSize(); + aPaperLogic.Width() = nEngineWidth; + pEngine->SetPaperSize(aPaperLogic); + } + + if ( bSimClip && !nOriVal ) + { + // kein hartes Clipping, aber nur die betroffenen + // Zeilen ausgeben + + Point aDocStart = aClipRect.TopLeft(); + aDocStart -= aLogicStart; + pEngine->Draw( pDev, aClipRect, aDocStart, FALSE ); + } + else + pEngine->Draw( pDev, aLogicStart, nOriVal ); + + if (bClip) + { + if (bMetaFile) + pDev->Pop(); + else + pDev->SetClipRegion(); + } + } + } + } + } + nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth; + } + } + nRowPosY += pRowInfo[nArrY].nHeight; + } + + delete pEngine; + + if (bAnyRotated) + DrawRotated(bPixelToLogic); //! von aussen rufen ? +} + +// ------------------------------------------------------------------------------- + +void ScOutputData::DrawRotated(BOOL bPixelToLogic) +{ + //! nRotMax speichern + USHORT nRotMax = nX2; + for (USHORT nRotY=0; nRotY<nArrCount; nRotY++) + if (pRowInfo[nRotY].nRotMaxCol != SC_ROTMAX_NONE && pRowInfo[nRotY].nRotMaxCol > nRotMax) + nRotMax = pRowInfo[nRotY].nRotMaxCol; + + + SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + + ScFieldEditEngine* pEngine = NULL; + const ScPatternAttr* pPattern; + const SfxItemSet* pCondSet; + const ScPatternAttr* pOldPattern = NULL; + const SfxItemSet* pOldCondSet = NULL; + ScBaseCell* pCell = NULL; + + long nRowPosY = nScrY; + for (USHORT nArrY=0; nArrY+1<nArrCount; nArrY++) // 0 fuer Reste von zusammengefassten + { + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + long nCellHeight = (long) pThisRowInfo->nHeight; + if (nArrY==1) nRowPosY = nScrY; // vorher wird einzeln berechnet + + if ( ( pThisRowInfo->bChanged || nArrY==0 ) && pThisRowInfo->nRotMaxCol != SC_ROTMAX_NONE ) + { + long nPosX = 0; + for (USHORT nX=0; nX<=nRotMax; nX++) + { + if (nX==nX1) nPosX = nScrX; // vorher wird einzeln berechnet + + CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1]; + if ( pInfo->nRotateDir != SC_ROTDIR_NONE ) + { + USHORT nY = pThisRowInfo->nRowNo; + + BOOL bHidden = FALSE; + if (bEditMode) + if ( nX == nEditCol && nY == nEditRow ) + bHidden = TRUE; + + if (!bHidden) + { + if (!pEngine) + { + // Ein RefDevice muss auf jeden Fall gesetzt werden, + // sonst legt sich die EditEngine ein VirtualDevice an! + pEngine = new ScFieldEditEngine( pDoc->GetEnginePool() ); + pEngine->SetRefDevice( pRefDevice ); // immer gesetzt + ULONG nCtrl = pEngine->GetControlWord(); + if ( bShowSpellErrors ) + nCtrl |= EE_CNTRL_ONLINESPELLING; + if ( eType == OUTTYPE_PRINTER ) + nCtrl &= ~EE_CNTRL_MARKFIELDS; + pEngine->SetControlWord( nCtrl ); + } + else + lcl_ClearEdit( *pEngine ); + + long nPosY = nRowPosY; + BOOL bVisChanged = FALSE; + + //! Rest von zusammengefasster Zelle weiter oben funktioniert nicht! + + BOOL bFromDoc = FALSE; + pPattern = pInfo->pPatternAttr; + pCondSet = pInfo->pConditionSet; + if (!pPattern) + { + pPattern = pDoc->GetPattern( nX, nY, nTab ); + bFromDoc = TRUE; + } + pCell = pInfo->pCell; + if (bFromDoc) + pCondSet = pDoc->GetCondResult( nX, nY, nTab ); + + if (!pCell && nX>nX2) + pDoc->GetCell( nX, nY, nTab, pCell ); + + if (!pCell) + bHidden = TRUE; // nRotateDir wird auch ohne Zelle gesetzt + + long nCellWidth = (long) pRowInfo[0].pCellInfo[nX+1].nWidth; + + const SfxPoolItem* pCondItem; + + SvxCellHorJustify eHorJust; + if ( pCondSet && pCondSet->GetItemState( + ATTR_HOR_JUSTIFY, TRUE, &pCondItem ) == SFX_ITEM_SET ) + eHorJust = (SvxCellHorJustify) ((const SvxHorJustifyItem*) + pCondItem)->GetValue(); + else + eHorJust = (SvxCellHorJustify)((const SvxHorJustifyItem&)pPattern-> + GetItem(ATTR_HOR_JUSTIFY)).GetValue(); + + BOOL bBreak; + if ( eHorJust == SVX_HOR_JUSTIFY_BLOCK ) + bBreak = TRUE; + else if ( pCondSet && pCondSet->GetItemState( + ATTR_LINEBREAK, TRUE, &pCondItem ) == SFX_ITEM_SET ) + bBreak = ((const SfxBoolItem*)pCondItem)->GetValue(); + else + bBreak = ((const SfxBoolItem&)pPattern->GetItem(ATTR_LINEBREAK)).GetValue(); + + SvxCellOrientation eOrient; + if ( pCondSet && pCondSet->GetItemState( + ATTR_ORIENTATION, TRUE, &pCondItem ) == SFX_ITEM_SET ) + eOrient = (SvxCellOrientation)((const SvxOrientationItem*) + pCondItem)->GetValue(); + else + eOrient = (SvxCellOrientation)((const SvxOrientationItem&) + pPattern->GetItem(ATTR_ORIENTATION)).GetValue(); + + const ScMergeAttr* pMerge = + (ScMergeAttr*)&pPattern->GetItem(ATTR_MERGE); + BOOL bMerged = pMerge->GetColMerge() > 1 || pMerge->GetRowMerge() > 1; + + long nStartX = nPosX; + long nStartY = nPosY; + if (nX<nX1) + { + if ((bBreak || eOrient!=SVX_ORIENTATION_STANDARD) && !bMerged) + bHidden = TRUE; + else + { + nStartX = nScrX; + USHORT nCol = nX1; + while (nCol > nX) + { + --nCol; + nStartX -= (long) pRowInfo[0].pCellInfo[nCol+1].nWidth; + } + } + } + + // Ersatzdarstellung fuer zu kleinen Text weggelassen + + if (!bHidden) + { + long nOutWidth = nCellWidth - 1; + long nOutHeight; + if (pInfo) + nOutHeight = nCellHeight; + else + nOutHeight = (long) ( pDoc->GetRowHeight(nY,nTab) * nPPTY ); + + if ( bMerged ) // Zusammengefasst + { + USHORT i; + const ScMergeAttr* pMerge = + (ScMergeAttr*)&pPattern->GetItem(ATTR_MERGE); + USHORT nCountX = pMerge->GetColMerge(); + for (i=1; i<nCountX; i++) + nOutWidth += (long) ( pDoc->GetColWidth(nX+i,nTab) * nPPTX ); + USHORT nCountY = pMerge->GetRowMerge(); + for (i=1; i<nCountY; i++) + nOutHeight += (long) ( pDoc->GetRowHeight(nY+i,nTab) * nPPTY ); + } + + SvxCellVerJustify eVerJust; + if ( pCondSet && pCondSet->GetItemState( + ATTR_VER_JUSTIFY, TRUE, &pCondItem ) == SFX_ITEM_SET ) + eVerJust = (SvxCellVerJustify) ((const SvxVerJustifyItem*) + pCondItem)->GetValue(); + else + eVerJust = (SvxCellVerJustify)((const SvxVerJustifyItem&)pPattern-> + GetItem(ATTR_VER_JUSTIFY)).GetValue(); + + // Syntax-Modus wird hier ignoriert... + + if ( StringDiffer(pOldPattern,pPattern) || pCondSet != pOldCondSet ) + { + SfxItemSet* pSet = new SfxItemSet( pEngine->GetEmptyItemSet() ); + pPattern->FillEditItemSet( pSet, pCondSet ); + + // Ausrichtung fuer EditEngine + SvxAdjust eSvxAdjust = SVX_ADJUST_LEFT; + if (eOrient==SVX_ORIENTATION_STACKED) + eSvxAdjust = SVX_ADJUST_CENTER; + // Adjustment fuer bBreak ist hier weggelassen + pSet->Put( SvxAdjustItem( eSvxAdjust, EE_PARA_JUST ) ); + + pEngine->SetDefaults( pSet ); + pOldPattern = pPattern; + pOldCondSet = pCondSet; + + ULONG nControl = pEngine->GetControlWord(); + if (eOrient==SVX_ORIENTATION_STACKED) + nControl |= EE_CNTRL_ONECHARPERLINE; + else + nControl &= ~EE_CNTRL_ONECHARPERLINE; + pEngine->SetControlWord( nControl ); + } + + // Raender + + //! Position und Papersize auf EditUtil umstellen !!! + + const SvxMarginItem* pMargin; + if ( pCondSet && pCondSet->GetItemState( + ATTR_MARGIN, TRUE, &pCondItem ) == SFX_ITEM_SET ) + pMargin = (const SvxMarginItem*)pCondItem; + else + pMargin = (const SvxMarginItem*)&pPattern->GetItem(ATTR_MARGIN); + USHORT nIndent = 0; + if ( eHorJust == SVX_HOR_JUSTIFY_LEFT ) + { + if ( pCondSet && pCondSet->GetItemState( + ATTR_INDENT, TRUE, &pCondItem ) == SFX_ITEM_SET ) + nIndent = ((const SfxUInt16Item*)pCondItem)->GetValue(); + else + nIndent = ((const SfxUInt16Item&)pPattern-> + GetItem(ATTR_INDENT)).GetValue(); + } + + long nTotalHeight = nOutHeight; // ohne Rand abzuziehen + if ( bPixelToLogic ) + nTotalHeight = pRefDevice->PixelToLogic(Size(0,nTotalHeight)).Height(); + + long nLeftM = (long) ( (pMargin->GetLeftMargin() + nIndent) * nPPTX ); + long nTopM = (long) ( pMargin->GetTopMargin() * nPPTY ); + nStartX += nLeftM; + nStartY += nTopM; + nOutWidth -= nLeftM + (long) ( pMargin->GetRightMargin() * nPPTX ); + nOutHeight -= nTopM + (long) ( pMargin->GetBottomMargin() * nPPTY ); + + // Rotation schon hier, um bei Umbruch auch PaperSize anzupassen + long nAttrRotate = 0; + double nSin = 0.0; + double nCos = 1.0; + SvxRotateMode eRotMode = SVX_ROTATE_MODE_STANDARD; + if ( eOrient == SVX_ORIENTATION_STANDARD ) + { + if ( pCondSet && pCondSet->GetItemState( + ATTR_ROTATE_VALUE, TRUE, &pCondItem ) == SFX_ITEM_SET ) + nAttrRotate = ((const SfxInt32Item*)pCondItem)->GetValue(); + else + nAttrRotate = ((const SfxInt32Item&)pPattern-> + GetItem(ATTR_ROTATE_VALUE)).GetValue(); + if ( nAttrRotate ) + { + if ( pCondSet && pCondSet->GetItemState( + ATTR_ROTATE_MODE, TRUE, &pCondItem ) == SFX_ITEM_SET ) + eRotMode = (SvxRotateMode)((const SvxRotateModeItem*) + pCondItem)->GetValue(); + else + eRotMode = (SvxRotateMode)((const SvxRotateModeItem&) + pPattern->GetItem(ATTR_ROTATE_MODE)).GetValue(); + + if ( nAttrRotate == 18000 ) + eRotMode = SVX_ROTATE_MODE_STANDARD; // keinen Ueberlauf + + double nRealOrient = nAttrRotate * F_PI18000; // 1/100 Grad + nCos = cos( nRealOrient ); + nSin = sin( nRealOrient ); + } + } + + Size aPaperSize = Size( 1000000, 1000000 ); + if (eOrient==SVX_ORIENTATION_STACKED) + aPaperSize.Width() = nOutWidth; // zum Zentrieren + else if (bBreak) + { + if (nAttrRotate) + { + //! richtige PaperSize fuer Umbruch haengt von der Zeilenzahl + //! ab, solange die Zeilen nicht einzeln versetzt ausgegeben + //! werden koennen -> darum unbegrenzt, also kein Umbruch. + //! Mit versetzten Zeilen waere das folgende richtig: + aPaperSize.Width() = (long)(nOutHeight / fabs(nSin)); + } + else if (eOrient == SVX_ORIENTATION_STANDARD) + aPaperSize.Width() = nOutWidth; + else + aPaperSize.Width() = nOutHeight - 1; + } + if (bPixelToLogic) + pEngine->SetPaperSize(pRefDevice->PixelToLogic(aPaperSize)); + else + pEngine->SetPaperSize(aPaperSize); // Scale ist immer 1 + + // Daten aus Zelle lesen + + if (pCell) + { + if (pCell->GetCellType() == CELLTYPE_EDIT) + { + const EditTextObject* pData; + ((ScEditCell*)pCell)->GetData(pData); + + if (pData) + pEngine->SetText(*pData); + else + DBG_ERROR("pData == 0"); + } + else + { + ULONG nFormat = pPattern->GetNumberFormat( + pFormatter, pCondSet ); + String aString; + Color* pColor; + ScCellFormat::GetString( pCell, + nFormat,aString, &pColor, + *pFormatter, + bShowNullValues, + bShowFormulas, + ftCheck ); + + pEngine->SetText(aString); + if ( pColor && !bSyntaxMode ) + lcl_SetEditColor( *pEngine, *pColor ); + } + + if ( bSyntaxMode ) + SetEditSyntaxColor( *pEngine, pCell ); + } + else + DBG_ERROR("pCell == NULL"); + + long nEngineWidth = (long) pEngine->CalcTextWidth(); + long nEngineHeight = pEngine->GetTextHeight(); + + if (nAttrRotate && bBreak) + { + double nAbsCos = fabs( nCos ); + double nAbsSin = fabs( nSin ); + + // #47740# adjust witdh of papersize for height of text + int nSteps = 5; + while (nSteps > 0) + { + // everything is in pixels + long nEnginePixel = pRefDevice->LogicToPixel( + Size(0,nEngineHeight)).Height(); + long nEffHeight = nOutHeight - (long)(nEnginePixel * nAbsCos) + 2; + long nNewWidth = (long)(nEffHeight / nAbsSin) + 2; + BOOL bFits = ( nNewWidth >= aPaperSize.Width() ); + if ( bFits ) + nSteps = 0; + else + { + if ( nNewWidth < 4 ) + { + // can't fit -> fall back to using half height + nEffHeight = nOutHeight / 2; + nNewWidth = (long)(nEffHeight / nAbsSin) + 2; + nSteps = 0; + } + else + --nSteps; + + // set paper width and get new text height + aPaperSize.Width() = nNewWidth; + if (bPixelToLogic) + pEngine->SetPaperSize(pRefDevice->PixelToLogic(aPaperSize)); + else + pEngine->SetPaperSize(aPaperSize); // Scale ist immer 1 + //pEngine->QuickFormatDoc( TRUE ); + nEngineWidth = (long) pEngine->CalcTextWidth(); + nEngineHeight = pEngine->GetTextHeight(); + } + } + } + + long nRealWidth = nEngineWidth; + long nRealHeight = nEngineHeight; + + // wenn gedreht, Groesse anpassen + if (nAttrRotate) + { + double nAbsCos = fabs( nCos ); + double nAbsSin = fabs( nSin ); + + if ( eRotMode == SVX_ROTATE_MODE_STANDARD ) + nEngineWidth = (long) ( nRealWidth * nAbsCos + + nRealHeight * nAbsSin ); + else + nEngineWidth = (long) ( nRealHeight / nAbsSin ); + //! begrenzen !!! + + nEngineHeight = (long) ( nRealHeight * nAbsCos + + nRealWidth * nAbsSin ); + } + + if (!nAttrRotate) // hier nur gedrehter Text + bHidden = TRUE; //! vorher abfragen !!! + + //! weglassen, was nicht hereinragt + + if (!bHidden) + { + BOOL bExtend = FALSE; // ueber Zellenrand geschrieben ? + BOOL bClip = FALSE; + BOOL bSimClip = FALSE; + Size aClipSize = Size( nScrX+nScrW-nStartX, nScrY+nScrH-nStartY ); + + // weiterschreiben + + Size aCellSize; + if (bPixelToLogic) + aCellSize = pRefDevice->PixelToLogic( Size( nOutWidth, nOutHeight ) ); + else + aCellSize = Size( nOutWidth, nOutHeight ); // Scale ist 1 + + long nGridWidth = nEngineWidth; + BOOL bNegative = FALSE; + if ( eRotMode != SVX_ROTATE_MODE_STANDARD ) + { + nGridWidth = aCellSize.Width() + + Abs((long) ( aCellSize.Height() * nCos / nSin )); + bNegative = ( pInfo->nRotateDir == SC_ROTDIR_LEFT ); + } + + if ( !bBreak || eOrient!=SVX_ORIENTATION_STANDARD ) + { + if ( eOrient == SVX_ORIENTATION_STANDARD && !bMerged ) + { + USHORT nNextX = bNegative ? (nX - 1) : (nX + 1); + // Unterlauf wird durch nNextX<=nX2 abgefangen + while ( nGridWidth > aCellSize.Width() && + nNextX>=nX1 && nNextX<=nX2 && + !pThisRowInfo->pCellInfo[nNextX+1].bHOverlapped && + !pThisRowInfo->pCellInfo[nNextX+1].bVOverlapped && + !( bEditMode && nNextX==nEditCol && nY==nEditRow ) ) + { + nOutWidth += pRowInfo[0].pCellInfo[nNextX+1].nWidth; + if (bPixelToLogic) + aCellSize = pRefDevice->PixelToLogic( Size( nOutWidth, nOutHeight ) ); + else + aCellSize = Size( nOutWidth, nOutHeight ); + + // Grid abschalten + if (bNegative) + { + pThisRowInfo->pCellInfo[nNextX+1].bHideGrid = TRUE; + --nNextX; + } + else + { + pThisRowInfo->pCellInfo[nNextX].bHideGrid = TRUE; + ++nNextX; + } + bExtend = TRUE; + } + } + if ( nGridWidth > aCellSize.Width() ) + { + bExtend = TRUE; // -> immer linksbuendig + bClip = TRUE; + aClipSize.Width() = nOutWidth; // Pixel + } + } + if ( nEngineHeight > aCellSize.Height() ) + { + // kein vertikales Clipping beim Drucken von Zellen mit + // optimaler Hoehe, ausser bei Groesse in bedingter + // Formatierung + if ( eType != OUTTYPE_PRINTER || + ( pDoc->GetRowFlags( nY, nTab ) & CR_MANUALSIZE ) || + ( pCondSet && SFX_ITEM_SET == + pCondSet->GetItemState(ATTR_FONT_HEIGHT, TRUE) ) ) + bClip = TRUE; + else + bSimClip = TRUE; + aClipSize.Height() = nOutHeight; // Pixel + } + + long nClipStartX = nStartX; + if (nX<nX1) + { + //! Clipping unnoetig, wenn links am Fenster + + bClip = TRUE; // nur Rest ausgeben! + if (nStartX<nScrX) + { + long nDif = nScrX - nStartX; + nClipStartX = nScrX; + aClipSize.Width() -= nDif; + } + } + + long nClipStartY = nStartY; + if (nArrY==0 || bVisChanged) + { + if ( nClipStartY < nRowPosY ) + { + long nDif = nRowPosY - nClipStartY; + bClip = TRUE; + nClipStartY = nRowPosY; + aClipSize.Height() -= nDif; + } + } + + bClip = TRUE; //! Test !!!! + + Rectangle aClipRect; + if (bClip || bSimClip) + { + if ( nAttrRotate /* && eRotMode != SVX_ROTATE_MODE_STANDARD */ ) + { + // gedrehten, ausgerichteten Text nur an den + // Seitengrenzen clippen + nClipStartX = nScrX; + aClipSize.Width() = nScrW; + } + + if (bPixelToLogic) + aClipRect = pRefDevice->PixelToLogic( Rectangle( + Point(nClipStartX,nClipStartY), aClipSize ) ); + else + aClipRect = Rectangle(Point(nClipStartX, nClipStartY), + aClipSize ); // Scale = 1 + + if (bClip) // bei bSimClip nur aClipRect initialisieren + { + if (bMetaFile) + { + pDev->Push(); + pDev->IntersectClipRegion( aClipRect ); + } + else + pDev->SetClipRegion( Region( aClipRect ) ); + } + } + + Point aLogicStart; + if (bPixelToLogic) + aLogicStart = pRefDevice->PixelToLogic( Point(nStartX,nStartY) ); + else + aLogicStart = Point(nStartX, nStartY); + if ( (eOrient!=SVX_ORIENTATION_STANDARD || !bBreak) && !bExtend ) + { + long nAvailWidth = aCellSize.Width(); + if (eType==OUTTYPE_WINDOW && + eOrient!=SVX_ORIENTATION_STACKED && + pInfo && pInfo->bAutoFilter) + { + if (pRowInfo[nArrY].nHeight < DROPDOWN_BITMAP_SIZE) + { + if (bPixelToLogic) + nAvailWidth -= pRefDevice->PixelToLogic(Size(0,pRowInfo[nArrY].nHeight)).Height(); + else + nAvailWidth -= pRowInfo[nArrY].nHeight; + } + else + { + if (bPixelToLogic) + nAvailWidth -= pRefDevice->PixelToLogic(Size(0,DROPDOWN_BITMAP_SIZE)).Height(); + else + nAvailWidth -= DROPDOWN_BITMAP_SIZE; + } + long nComp = nEngineWidth; + if (nAvailWidth<nComp) nAvailWidth=nComp; + } + + // horizontale Ausrichtung + + if (eOrient==SVX_ORIENTATION_STANDARD && !nAttrRotate) + { + if (eHorJust==SVX_HOR_JUSTIFY_RIGHT || + eHorJust==SVX_HOR_JUSTIFY_CENTER) + { + SvxAdjust eSvxAdjust = + (eHorJust==SVX_HOR_JUSTIFY_RIGHT) ? + SVX_ADJUST_RIGHT : SVX_ADJUST_CENTER; + pEngine->SetDefaultItem( + SvxAdjustItem( eSvxAdjust, EE_PARA_JUST ) ); + + aPaperSize.Width() = nOutWidth; + if (bPixelToLogic) + pEngine->SetPaperSize(pRefDevice->PixelToLogic(aPaperSize)); + else + pEngine->SetPaperSize(aPaperSize); + } + } + else + { + // bei gedrehtem Text ist Standard zentriert + if (eHorJust==SVX_HOR_JUSTIFY_RIGHT) + aLogicStart.X() += nAvailWidth - nEngineWidth; + else if (eHorJust==SVX_HOR_JUSTIFY_CENTER || + eHorJust==SVX_HOR_JUSTIFY_STANDARD) + aLogicStart.X() += (nAvailWidth - nEngineWidth) / 2; + } + } + else if (bExtend && eRotMode != SVX_ROTATE_MODE_STANDARD) + { + // Ausrichtung mit Bezugskante + + long nRealWidth = nCellWidth - 1; //! Merge beruecksichtigen? + if (bPixelToLogic) + nRealWidth = pRefDevice->PixelToLogic( + Size( nRealWidth, 0 ) ).Width(); + + // hier ist Standard links (?) + if (eHorJust==SVX_HOR_JUSTIFY_RIGHT) + aLogicStart.X() += nRealWidth - nEngineWidth; + else if (eHorJust==SVX_HOR_JUSTIFY_CENTER) + aLogicStart.X() += (nRealWidth - nEngineWidth) / 2; + } + + if ( eOrient==SVX_ORIENTATION_STANDARD || + eOrient==SVX_ORIENTATION_STACKED || !bBreak ) + { + if (eVerJust==SVX_VER_JUSTIFY_BOTTOM || + eVerJust==SVX_VER_JUSTIFY_STANDARD) + { + if (bPixelToLogic) + aLogicStart.Y() += pRefDevice->PixelToLogic( Size(0, + pRefDevice->LogicToPixel(aCellSize).Height() - + pRefDevice->LogicToPixel(Size(0,nEngineHeight)).Height() + )).Height(); + else + aLogicStart.Y() += aCellSize.Height() - nEngineHeight; + } + + else if (eVerJust==SVX_VER_JUSTIFY_CENTER) + { + if (bPixelToLogic) + aLogicStart.Y() += pRefDevice->PixelToLogic( Size(0,( + pRefDevice->LogicToPixel(aCellSize).Height() - + pRefDevice->LogicToPixel(Size(0,nEngineHeight)).Height()) + / 2)).Height(); + else + aLogicStart.Y() += (aCellSize.Height() - nEngineHeight) / 2; + } + } + + // TOPBOTTON and BOTTOMTOP are handled in DrawStrings/DrawEdit + DBG_ASSERT( eOrient == SVX_ORIENTATION_STANDARD && nAttrRotate, + "DrawRotated: no rotation" ); + + long nOriVal = 0; + if ( nAttrRotate ) + { + // Attribut ist 1/100, Font 1/10 Grad + nOriVal = nAttrRotate / 10; + + double nAddX = 0.0; + double nAddY = 0.0; + if ( nCos > 0.0 && eRotMode != SVX_ROTATE_MODE_STANDARD ) + { + //! begrenzen !!! + double nH = nRealHeight * nCos; + nAddX += nH * ( nCos / fabs(nSin) ); + } + if ( nCos < 0.0 && eRotMode == SVX_ROTATE_MODE_STANDARD ) + nAddX -= nRealWidth * nCos; + if ( nSin < 0.0 ) + nAddX -= nRealHeight * nSin; + if ( nSin > 0.0 ) + nAddY += nRealWidth * nSin; + if ( nCos < 0.0 ) + nAddY -= nRealHeight * nCos; + + if ( eRotMode != SVX_ROTATE_MODE_STANDARD ) + { + //! begrenzen !!! + double nSkew = nTotalHeight * nCos / fabs(nSin); + if ( eRotMode == SVX_ROTATE_MODE_CENTER ) + nAddX -= nSkew * 0.5; + if ( ( eRotMode == SVX_ROTATE_MODE_TOP && nSin > 0.0 ) || + ( eRotMode == SVX_ROTATE_MODE_BOTTOM && nSin < 0.0 ) ) + nAddX -= nSkew; + + long nUp = 0; + if ( eVerJust == SVX_VER_JUSTIFY_CENTER ) + nUp = ( aCellSize.Height() - nEngineHeight ) / 2; + else if ( eVerJust == SVX_VER_JUSTIFY_TOP ) + { + if ( nSin > 0.0 ) + nUp = aCellSize.Height() - nEngineHeight; + } + else // BOTTOM / STANDARD + { + if ( nSin < 0.0 ) + nUp = aCellSize.Height() - nEngineHeight; + } + if ( nUp ) + nAddX += ( nUp * nCos / fabs(nSin) ); + } + + aLogicStart.X() += (long) nAddX; + aLogicStart.Y() += (long) nAddY; + } + + //! bSimClip is not used here (because nOriVal is set) + + pEngine->Draw( pDev, aLogicStart, (short)nOriVal ); + + if (bClip) + { + if (bMetaFile) + pDev->Pop(); + else + pDev->SetClipRegion(); + } + } + } + } + } + nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth; + } + } + nRowPosY += pRowInfo[nArrY].nHeight; + } + + delete pEngine; +} + + + diff --git a/sc/source/ui/view/output3.cxx b/sc/source/ui/view/output3.cxx new file mode 100644 index 000000000000..f829f147f39c --- /dev/null +++ b/sc/source/ui/view/output3.cxx @@ -0,0 +1,630 @@ +/************************************************************************* + * + * $RCSfile: output3.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +// TOOLS +#define _BIGINT_HXX +#define _SFXMULTISEL_HXX +#define _STACK_HXX +#define _QUEUE_HXX +#define _DYNARR_HXX +#define _TREELIST_HXX +#define _CACHESTR_HXX +#define _NEW_HXX +//#define _SHL_HXX +//#define _LINK_HXX +//#define _ERRCODE_HXX +//#define _GEN_HXX +//#define _FRACT_HXX +//#define _STRING_HXX +//#define _MTF_HXX +//#define _CONTNR_HXX +//#define _LIST_HXX +//#define _TABLE_HXX +#define _DYNARY_HXX +//#define _UNQIDX_HXX +//#define _UNQID_HXX +//#define _DEBUG_HXX +//#define _DATE_HXX +//#define _TIME_HXX +//#define _DATETIME_HXX +//#define _INTN_HXX +//#define _WLDCRD_HXX +//#define _FSYS_HXX +//#define _STREAM_HXX +#define _CACHESTR_HXX +#define _SV_MULTISEL_HXX + +//SV +//#define _CLIP_HXX *** +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _FONTDLG_HXX +#define _PRVWIN_HXX +//#define _COLOR_HXX +//#define _PAL_HXX +//#define _BITMAP_HXX +//#define _GDIOBJ_HXX +//#define _POINTR_HXX +//#define _ICON_HXX +//#define _IMAGE_HXX +//#define _KEYCOD_HXX +//#define _EVENT_HXX +#define _HELP_HXX +//#define _APP_HXX +//#define _MDIAPP_HXX +//#define _TIMER_HXX +//#define _METRIC_HXX +//#define _REGION_HXX +//#define _OUTDEV_HXX +//#define _SYSTEM_HXX +//#define _VIRDEV_HXX +//#define _JOBSET_HXX +//#define _PRINT_HXX +//#define _WINDOW_HXX +//#define _SYSWIN_HXX +//#define _WRKWIN_HXX +#define _MDIWIN_HXX +//#define _FLOATWIN_HXX +//#define _DOCKWIN_HXX +//#define _CTRL_HXX +//#define _SCRBAR_HXX +//#define _BUTTON_HXX +//#define _IMAGEBTN_HXX +//#define _FIXED_HXX +//#define _GROUP_HXX +//#define _EDIT_HXX +//#define _COMBOBOX_HXX +//#define _LSTBOX_HXX +//#define _SELENG_HXX +//#define _SPLIT_HXX +#define _SPIN_HXX +//#define _FIELD_HXX +//#define _MOREBTN_HXX +//#define _TOOLBOX_HXX +//#define _STATUS_HXX +//#define _DIALOG_HXX +//#define _MSGBOX_HXX +//#define _SYSDLG_HXX +//#define _FILDLG_HXX +//#define _PRNDLG_HXX +#define _COLDLG_HXX +//#define _TABDLG_HXX +//#define _MENU_HXX +//#define _GDIMTF_HXX +//#define _POLY_HXX +//#define _ACCEL_HXX +//#define _GRAPH_HXX +#define _SOUND_HXX + +#if defined WIN +#define _MENUBTN_HXX +#endif + +//svtools +#define _SCRWIN_HXX +#define _RULER_HXX +//#define _TABBAR_HXX +//#define _VALUESET_HXX +#define _STDMENU_HXX +//#define _STDCTRL_HXX +//#define _CTRLBOX_HXX +#define _CTRLTOOL_HXX +#define _EXTATTR_HXX +#define _FRM3D_HXX +#define _EXTATTR_HXX + +//SVTOOLS +//#define _SVTREELIST_HXX *** +#define _FILTER_HXX +//#define _SVLBOXITM_HXX *** +//#define _SVTREEBOX_HXX *** +#define _SVICNVW_HXX +#define _SVTABBX_HXX + +//sfxcore.hxx +//#define _SFXINIMGR_HXX *** +//#define _SFXCFGITEM_HXX +//#define _SFX_PRINTER_HXX +#define _SFXGENLINK_HXX +#define _SFXHINTPOST_HXX +#define _SFXDOCINF_HXX +#define _SFXLINKHDL_HXX +//#define _SFX_PROGRESS_HXX + +//sfxsh.hxx +//#define _SFX_SHELL_HXX +//#define _SFXAPP_HXX +//#define _SFX_BINDINGS_HXX +//#define _SFXDISPATCH_HXX +#define _SFXMSG_HXX //* +#define _SFXOBJFACE_HXX +#define _SFXREQUEST_HXX +#define _SFXMACRO_HXX + +// SFX +#define _SFXAPPWIN_HXX +#define _SFX_SAVEOPT_HXX +#define _SFXCTRLITEM_HXX +#define _SFXPRNMON_HXX +#define _INTRO_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFXFILEDLG_HXX +#define _PASSWD_HXX +#define _SFXTBXCTRL_HXX +#define _SFXSTBITEM_HXX +#define _SFXMNUITEM_HXX +#define _SFXIMGMGR_HXX +#define _SFXTBXMGR_HXX +#define _SFXSTBMGR_HXX +#define _SFX_MINFITEM_HXX +#define _SFXEVENT_HXX + +//sfxdoc.hxx +//#define _SFX_OBJSH_HXX +//#define _SFX_CLIENTSH_HXX +//#define _SFXDOCINF_HXX +//#define _SFX_OBJFAC_HXX +#define _SFX_DOCFILT_HXX +//#define _SFXDOCFILE_HXX *** +//define _VIEWFAC_HXX +//#define _SFXVIEWFRM_HXX +//#define _SFXVIEWSH_HXX +//#define _MDIFRM_HXX *** +#define _SFX_IPFRM_HXX +//#define _SFX_INTERNO_HXX + +//sfxdlg.hxx +//#define _SFXTABDLG_HXX +//#define _BASEDLGS_HXX *** +#define _SFX_DINFDLG_HXX +#define _SFXDINFEDT_HXX +#define _SFX_MGETEMPL_HXX +#define _SFX_TPLPITEM_HXX +//#define _SFX_STYLEDLG_HXX +#define _NEWSTYLE_HXX +//#define _SFXDOCTEMPL_HXX *** +//#define _SFXDOCTDLG_HXX *** +//#define _SFX_TEMPLDLG_HXX *** +//#define _SFXNEW_HXX *** +#define _SFXDOCMAN_HXX +//#define _SFXDOCKWIN_HXX + +//sfxitems.hxx +#define _SFX_WHMAP_HXX +#define _ARGS_HXX +//#define _SFXPOOLITEM_HXX +//#define _SFXINTITEM_HXX +//#define _SFXENUMITEM_HXX +#define _SFXFLAGITEM_HXX +//#define _SFXSTRITEM_HXX +#define _SFXPTITEM_HXX +#define _SFXRECTITEM_HXX +#define _SFXITEMITER_HXX +#define _SFX_WHITER_HXX +#define _SFXPOOLCACH_HXX +#define _AEITEM_HXX +#define _SFXRNGITEM_HXX +#define _SFXSLSTITM_HXX + +//xout.hxx +//#define _XENUM_HXX +//#define _XPOLY_HXX +//#define _XATTR_HXX +//#define _XOUTX_HXX + +//svdraw.hxx +#define _SDR_NOITEMS +#define _SDR_NOTOUCH +#define _SDR_NOTRANSFORM +//#define _SDR_NOVIEWS + +#define SI_NOITEMS +#define _SI_NOSBXCONTROLS +#define _VCATTR_HXX +#define _VCONT_HXX +#define _SI_NOOTHERFORMS +#define _VCTRLS_HXX +#define _SI_NOCONTROL +#define _SETBRW_HXX +#define _VCBRW_HXX +#define _SI_NOSBXCONTROLS +#define _SIDLL_HXX + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_THESDLG_HXX + + +// INCLUDE --------------------------------------------------------------- + +#include <svx/svdograf.hxx> +#include <svx/svdoole2.hxx> +#include <svx/svdpage.hxx> +#include <svx/svdpagv.hxx> +#include <svx/svdview.hxx> +#include <svx/xoutx.hxx> + +#include "output.hxx" +#include "drwlayer.hxx" +#include "document.hxx" +#include "tabvwsh.hxx" + + +#ifdef IRIX +#ifndef _SBXCLASS_HXX +#include <svtools/sbx.hxx> +#endif +#endif + +// STATIC DATA ----------------------------------------------------------- + +SdrObject* pSkipPaintObj = NULL; + + +//================================================================== + +void ScOutputData::DrawingLayer( USHORT nLayer, USHORT nObjectFlags, long nLogStX, long nLogStY ) +{ + if ( nObjectFlags == SC_OBJECTS_NONE || !pDoc->GetDrawLayer() ) + return; + + MapMode aOldMode = pDev->GetMapMode(); + + // Area auch fuer Metafiles + USHORT nCol; + USHORT nRow; + + Point aOffset; + Rectangle aRect; + + for (nCol=0; nCol<nX1; nCol++) + aOffset.X() -= pDoc->GetColWidth( nCol, nTab ); + for (nRow=0; nRow<nY1; nRow++) + aOffset.Y() -= pDoc->GetRowHeight( nRow, nTab ); + + aRect.Left() = aRect.Right() = -aOffset.X(); + aRect.Top() = aRect.Bottom() = -aOffset.Y(); + + Point aMMOffset( aOffset ); + aMMOffset.X() = (long)(aMMOffset.X() * HMM_PER_TWIPS); + aMMOffset.Y() = (long)(aMMOffset.Y() * HMM_PER_TWIPS); + + if (!bMetaFile) + aMMOffset += Point( nLogStX, nLogStY ); + + for (nCol=nX1; nCol<=nX2; nCol++) + aRect.Right() += pDoc->GetColWidth( nCol, nTab ); + for (nRow=nY1; nRow<=nY2; nRow++) + aRect.Bottom() += pDoc->GetRowHeight( nRow, nTab ); + + aRect.Left() = (long) (aRect.Left() * HMM_PER_TWIPS); + aRect.Top() = (long) (aRect.Top() * HMM_PER_TWIPS); + aRect.Right() = (long) (aRect.Right() * HMM_PER_TWIPS); + aRect.Bottom() = (long) (aRect.Bottom() * HMM_PER_TWIPS); + + // HACK: Ausschnitt genau auf Ausgabe-Pixel anpassen +//! aRect = Rectangle( aRect.TopLeft(), pDev->PixelToLogic( Size( nScrW,nScrH ) ) ); + + if (!bMetaFile) + pDev->SetMapMode( MapMode( MAP_100TH_MM, aMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) ); + + //! bMeta: um aMMOffset verschieben ( DrawView ) !!!!! + + // Layer zeichnen + + DrawSelectiveObjects( nLayer, aRect, nObjectFlags ); + + if (!bMetaFile) + pDev->SetMapMode( aOldMode ); +} + +void ScOutputData::DrawSelectiveObjects( USHORT nLayer, const Rectangle& rRect, + USHORT nObjectFlags, USHORT nDummyFlags ) +{ + ScDrawLayer* pModel = pDoc->GetDrawLayer(); + if (!pModel) + return; + + ExtOutputDevice* pXOut = new ExtOutputDevice( pDev ); + pXOut->SetOutDev( pDev ); + SdrPaintInfoRec aInfoRec; + + if ( pViewShell ) + { + SdrView* pDrawView = pViewShell->GetSdrView(); + if (pDrawView) + aInfoRec.pPV = pDrawView->GetPageViewPvNum(0); + } + + BOOL bDidDummy = FALSE; + + SdrPage* pPage = pModel->GetPage(nTab); + DBG_ASSERT(pPage,"Page nicht gefunden"); + if (!pPage) + return; + + if ( aInfoRec.pPV && aInfoRec.pPV->GetObjList() == pPage ) + aInfoRec.bNotActive = FALSE; + + // DrawMode handling copied from SdrObjList::Paint + UINT32 nWasDrawMode = pDev->GetDrawMode(); + if(!aInfoRec.bOriginalDrawModeSet) + { + // Original-Paintmode retten + aInfoRec.bOriginalDrawModeSet = TRUE; + aInfoRec.nOriginalDrawMode = pDev->GetDrawMode(); + } + if(aInfoRec.pPV && aInfoRec.bNotActive) + { + if(aInfoRec.pPV->GetView().DoVisualizeEnteredGroup()) + { + // Darstellung schmal + pDev->SetDrawMode(nWasDrawMode | ( + DRAWMODE_GHOSTEDLINE|DRAWMODE_GHOSTEDFILL|DRAWMODE_GHOSTEDTEXT|DRAWMODE_GHOSTEDBITMAP|DRAWMODE_GHOSTEDGRADIENT)); + } + } + else + { + // Darstellung normal + pDev->SetDrawMode(aInfoRec.nOriginalDrawMode); + } + + // Paint ueber SdrObjListIter geht bei 3D-Objekten schief + + ULONG nObjCount = pPage->GetObjCount(); + for (ULONG nObjNum = 0; nObjNum<nObjCount; nObjNum++) + { + SdrObject* pObject = pPage->GetObj(nObjNum); + + if ( pObject->GetLayer()==(SdrLayerID) nLayer && pObject != pSkipPaintObj ) + { + // #62107# nur das anfassen, was ueberhaupt gepainted werden koennte, + // damit nicht unnoetig durch Cache-Miss nachgeladen wird + + Rectangle aObjRect = pObject->GetBoundRect(); + if ( aObjRect.IsOver( rRect ) ) + { + BOOL bDraw; + BOOL bDummy; + UINT16 nSdrObjKind = pObject->GetObjIdentifier(); + if (nSdrObjKind == OBJ_OLE2) + { + if ( pDoc->IsChart( pObject ) ) + { + bDraw = (nObjectFlags & SC_OBJECTS_CHARTS) != 0; + bDummy = (nDummyFlags & SC_OBJECTS_CHARTS) != 0; + } + else + { + bDraw = (nObjectFlags & SC_OBJECTS_OLE) != 0; + bDummy = (nDummyFlags & SC_OBJECTS_OLE) != 0; + } + } + else if (nSdrObjKind == OBJ_GRAF) // Grafiken zusammen mit Ole-Objekten + { + bDraw = (nObjectFlags & SC_OBJECTS_OLE) != 0; + bDummy = (nDummyFlags & SC_OBJECTS_OLE) != 0; + } + else + { + bDraw = (nObjectFlags & SC_OBJECTS_DRAWING) != 0; + bDummy = (nDummyFlags & SC_OBJECTS_DRAWING) != 0; + } + + if (bDraw || bDummy) + { + BOOL bClip = !rRect.IsInside( aObjRect ); + BOOL bPush = FALSE; + + if (bClip && bDraw && nSdrObjKind == OBJ_GRAF) + { + const Graphic& rGraph = ((SdrGrafObj*)pObject)->GetGraphic(); + GraphicType eType = rGraph.GetType(); +#ifndef VCL + if ( eType == GRAPHIC_GDIMETAFILE || eType == GRAPHIC_WINMETAFILE || + eType == GRAPHIC_WNTMETAFILE || eType == GRAPHIC_OS2METAFILE || +#else + if ( eType == GRAPHIC_GDIMETAFILE || +#endif + rGraph.IsAnimated() ) + bClip = FALSE; + } + + // #36427#/#37790#: VC-Objekte pfuschen mit den ClipRegions rum, + // darum fuer Metafiles Push/Pop aussenherum. + //! Hier wieder raus, wenn die VC-Objekte richtig funktionieren! +// if ( bMetaFile && bDraw && !bClip && pObject->ISA(VCSbxDrawObject) ) +// bPush = TRUE; + + if (bClip) + { + if (bMetaFile) + { + pDev->Push(); + pDev->IntersectClipRegion( rRect ); + } + else + { + if ( nLayer != SC_LAYER_BACK ) + { // #29660# HACK: + // untere Gitterlinie blieb manchmal stehen, + // anscheinend Rundungsfehler in ClipRegion + // vom Grafiktreiber + Rectangle aPix = pDev->LogicToPixel(rRect); + aPix.Bottom() += 1; + Rectangle aNew = pDev->PixelToLogic(aPix); + pDev->SetClipRegion( aNew ); + } + else + pDev->SetClipRegion( rRect ); + } + } + else if (bPush) // nur Push/Pop + pDev->Push(); + + if (bDraw) + { + if (pObject == pEditObj) + { + aInfoRec.nPaintMode|=SDRPAINTMODE_TEXTEDIT; + pObject->Paint( *pXOut, aInfoRec ); + aInfoRec.nPaintMode&=~SDRPAINTMODE_TEXTEDIT; + } + else + pObject->Paint( *pXOut, aInfoRec ); + bDidDummy = FALSE; + + // Plugins connecten, wenn sichtbar: + + if ( pViewShell && pObject->ISA(SdrOle2Obj) ) + { + SdrOle2Obj* pOleObj = (SdrOle2Obj*)pObject; + ConnectObject( pOleObj->GetObjRef(), pOleObj ); + } + } + else + { + if (!bDidDummy) + { + pDev->SetFillColor(COL_LIGHTGRAY); + pDev->SetLineColor(COL_BLACK); + bDidDummy = TRUE; + } + pDev->DrawRect( aObjRect ); + } + + if (bClip || bPush) // bei bPush ist auch bMetaFile=TRUE + { + if (bMetaFile) + pDev->Pop(); + else + pDev->SetClipRegion(); + } + } + } + } + } + + pDev->SetDrawMode(aInfoRec.nOriginalDrawMode); + + delete pXOut; +} + +// Teile nur fuer Bildschirm + +void ScOutputData::DrawingSingle( USHORT nLayer, USHORT nObjectFlags, USHORT nDummyFlags ) +{ + Rectangle aDrawingRect; + aDrawingRect.Left() = nScrX; + aDrawingRect.Right() = nScrX+nScrW-1; + + BOOL bHad = FALSE; + long nPosY = nScrY; + USHORT nArrY; + for (nArrY=1; nArrY+1<nArrCount; nArrY++) + { + BOOL bChanged = FALSE; + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + + if ( pThisRowInfo->bChanged ) + { + if (!bHad) + { + aDrawingRect.Top() = nPosY; + bHad = TRUE; + } + aDrawingRect.Bottom() = nPosY + pRowInfo[nArrY].nHeight - 1; + } + else if (bHad) + { + DrawSelectiveObjects( nLayer, pDev->PixelToLogic(aDrawingRect), nObjectFlags, nDummyFlags ); + bHad = FALSE; + } + nPosY += pRowInfo[nArrY].nHeight; + } + + if (bHad) + DrawSelectiveObjects( nLayer, pDev->PixelToLogic(aDrawingRect), nObjectFlags, nDummyFlags ); +} + + + + diff --git a/sc/source/ui/view/pgbrksh.cxx b/sc/source/ui/view/pgbrksh.cxx new file mode 100644 index 000000000000..df8838677254 --- /dev/null +++ b/sc/source/ui/view/pgbrksh.cxx @@ -0,0 +1,118 @@ +/************************************************************************* + * + * $RCSfile: pgbrksh.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +#include "scitems.hxx" +#include <svx/srchitem.hxx> +#include <sfx2/app.hxx> +#include <sfx2/objface.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/request.hxx> +#include <svtools/whiter.hxx> + +#define GLOBALOVERFLOW +#include "segmentc.hxx" + + +#include "pgbrksh.hxx" +#include "tabvwsh.hxx" +#include "scresid.hxx" +#include "document.hxx" +#include "sc.hrc" + +//------------------------------------------------------------------------ + +#define ScPageBreakShell +#include "scslots.hxx" + +//------------------------------------------------------------------------ + +TYPEINIT1( ScPageBreakShell, SfxShell ); + +SFX_IMPL_INTERFACE(ScPageBreakShell, SfxShell, ScResId(SCSTR_PAGEBREAKSHELL)) +{ + SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_PAGEBREAK) ); +} + + +//------------------------------------------------------------------------ +ScPageBreakShell::ScPageBreakShell( ScTabViewShell* pViewSh ) : + SfxShell(pViewSh) +{ + SetPool( &pViewSh->GetPool() ); + SetUndoManager( pViewSh->GetViewData()->GetSfxDocShell()->GetUndoManager() ); + SetHelpId( HID_SCSHELL_PAGEBREAK ); + SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("PageBreak"))); +} + +//------------------------------------------------------------------------ +ScPageBreakShell::~ScPageBreakShell() +{ +} + + diff --git a/sc/source/ui/view/pivotsh.cxx b/sc/source/ui/view/pivotsh.cxx new file mode 100644 index 000000000000..8ebf38f4073b --- /dev/null +++ b/sc/source/ui/view/pivotsh.cxx @@ -0,0 +1,242 @@ +/************************************************************************* + * + * $RCSfile: pivotsh.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +#include "scitems.hxx" +#include <svx/srchitem.hxx> +#include <sfx2/app.hxx> +#include <sfx2/objface.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/request.hxx> +#include <svtools/whiter.hxx> + +#define GLOBALOVERFLOW +#include "segmentc.hxx" + + +#include "pivotsh.hxx" +#include "tabvwsh.hxx" +#include "scresid.hxx" +#include "document.hxx" +#include "docsh.hxx" +#include "sc.hrc" + +//------------------------------------------------------------------------ + +#define ScPivotShell +#include "scslots.hxx" + +//------------------------------------------------------------------------ + +SEG_EOFGLOBALS() + + +#pragma SEG_SEGCLASS(SFXMACROS_SEG,STARTWORK_CODE) + + +TYPEINIT1( ScPivotShell, SfxShell ); + +SFX_IMPL_INTERFACE(ScPivotShell, SfxShell, ScResId(SCSTR_PIVOTSHELL)) +{ + SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_PIVOT) ); +} + + +//------------------------------------------------------------------------ +#pragma SEG_FUNCDEF(pivotsh_01) + +ScPivotShell::ScPivotShell( ScTabViewShell* pViewSh ) : + SfxShell(pViewSh), + pViewShell( pViewSh ) +{ + SetPool( &pViewSh->GetPool() ); + SetUndoManager( pViewSh->GetViewData()->GetSfxDocShell()->GetUndoManager() ); + SetHelpId( HID_SCSHELL_PIVOTSH ); + SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Pivot"))); +} + +//------------------------------------------------------------------------ +#pragma SEG_FUNCDEF(pivotsh_02) + +ScPivotShell::~ScPivotShell() +{ +} + +//------------------------------------------------------------------------ +#pragma SEG_FUNCDEF(pivotsh_03) + +void ScPivotShell::Execute( SfxRequest& rReq ) +{ + switch ( rReq.GetSlot() ) + { + case SID_PIVOT_RECALC: + pViewShell->RecalcPivotTable(); + break; + + case SID_PIVOT_KILL: + pViewShell->DeletePivotTable(); + break; + } +} + +//------------------------------------------------------------------------ +#pragma SEG_FUNCDEF(pivotsh_04) + +void __EXPORT ScPivotShell::GetState( SfxItemSet& rSet ) +{ + ScDocShell* pDocSh = pViewShell->GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + while (nWhich) + { + switch (nWhich) + { + case SID_PIVOT_RECALC: + case SID_PIVOT_KILL: + { + //! move ReadOnly check to idl flags + + if ( pDocSh->IsReadOnly() || pDoc->GetChangeTrack()!=NULL ) + { + rSet.DisableItem( nWhich ); + } + } + break; + } + nWhich = aIter.NextWhich(); + } +} + +/*------------------------------------------------------------------------ + + $Log: not supported by cvs2svn $ + Revision 1.18 2000/09/17 14:09:34 willem.vandorp + OpenOffice header added. + + Revision 1.17 2000/08/31 16:38:46 willem.vandorp + Header and footer replaced + + Revision 1.16 2000/05/09 18:30:15 nn + use IMPL_INTERFACE macro without IDL + + Revision 1.15 2000/04/14 08:31:38 nn + unicode changes + + Revision 1.14 2000/03/16 15:47:42 nn + #74017# check ReadOnly state + + Revision 1.13 1999/06/02 19:42:10 ANK + #66547# SubShells + + + Rev 1.12 02 Jun 1999 21:42:10 ANK + #66547# SubShells + + Rev 1.11 04 Sep 1998 18:24:48 ANK + #55978# Slots disablen bei Redlining + + Rev 1.10 24 Nov 1997 20:04:54 NN + includes + + Rev 1.9 04 Sep 1997 19:48:30 RG + change header + + Rev 1.8 05 Aug 1997 14:31:18 TJ + include svx/srchitem.hxx + + Rev 1.7 29 Oct 1996 13:36:00 NN + ueberall ScResId statt ResId + + Rev 1.6 09 Aug 1996 20:34:46 NN + Svx-Includes aus scitems.hxx raus + + Rev 1.5 16 Oct 1995 09:56:32 JN + HelpIds fuer Shells + + Rev 1.4 01 Aug 1995 15:30:36 NN + SetUndoManager + + Rev 1.3 03 Jul 1995 10:19:28 STE + GetState exported + + Rev 1.2 20 Jun 1995 16:24:22 NN + nochmal Segmentierung + + Rev 1.1 13 Jun 1995 18:43:52 MO + seg-pragmas korrigiert + + Rev 1.0 30 May 1995 14:59:28 MO + Initial revision. + +------------------------------------------------------------------------*/ + +#pragma SEG_EOFMODULE + + diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx new file mode 100644 index 000000000000..86b031242979 --- /dev/null +++ b/sc/source/ui/view/preview.cxx @@ -0,0 +1,650 @@ +/************************************************************************* + * + * $RCSfile: preview.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- +#include <tools/pstm.hxx> +#include "scitems.hxx" +#include <svx/fmview.hxx> +#include <svx/sizeitem.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <svtools/itemset.hxx> +#include <tools/multisel.hxx> +#include <vcl/waitobj.hxx> + +#include "preview.hxx" +#include "prevwsh.hxx" +#include "docsh.hxx" +#include "printfun.hxx" +#include "stlpool.hxx" +#include "drwlayer.hxx" +#include "globstr.hrc" +#include "sc.hrc" // fuer ShellInvalidate + +// STATIC DATA ----------------------------------------------------------- + +//================================================================== + +long lcl_GetDisplayStart( USHORT nTab, ScDocument* pDoc, long* pPages ) +{ + long nDisplayStart = 0; + for (USHORT i=0; i<nTab; i++) + { + if ( pDoc->NeedPageResetAfterTab(i) ) + nDisplayStart = 0; + else + nDisplayStart += pPages[i]; + } + return nDisplayStart; +} + + +ScPreview::ScPreview( Window* pParent, ScDocShell* pDocSh, ScPreviewShell* pViewSh ) : + Window( pParent ), + pDocShell( pDocSh ), + pViewShell( pViewSh ), + bInPaint( FALSE ), + bValid( FALSE ), + bStateValid( FALSE ), + bInGetState( FALSE ), + pDrawView( NULL ), + nTabsTested( 0 ), + nPageNo( 0 ), + nZoom( 100 ), + nTab( 0 ), + nTotalPages( 0 ), + nTabStart( 0 ), + nDisplayStart( 0 ) +{ + SetBackground(); + + SetHelpId( HID_SC_WIN_PREVIEW ); + SetUniqueId( HID_SC_WIN_PREVIEW ); +} + + +__EXPORT ScPreview::~ScPreview() +{ + delete pDrawView; +} + + +void ScPreview::UpdateDrawView() // nTab muss richtig sein +{ + ScDocument* pDoc = pDocShell->GetDocument(); + + Rectangle aFull( 0, 0, LONG_MAX, LONG_MAX ); + if ( pDoc->HasControl( nTab, aFull ) ) + { + if ( pDrawView && !pDrawView->GetPageViewPgNum(nTab) ) + { + // die angezeigte Page der DrawView umzustellen (s.u.) funktioniert nicht ?!? + delete pDrawView; + pDrawView = NULL; + } + + if ( !pDrawView ) // neu anlegen? + { + ScDrawLayer* pModel = pDoc->GetDrawLayer(); // ist nicht 0 + pDrawView = new FmFormView( pModel, this ); + // #55259# die DrawView uebernimmt den Design-Modus vom Model + // (Einstellung "Im Entwurfsmodus oeffnen"), darum hier zuruecksetzen + pDrawView->SetDesignMode( TRUE ); + pDrawView->SetPrintPreview( TRUE ); + pDrawView->ShowPagePgNum( nTab, Point() ); + } +#if 0 + else if ( !pDrawView->GetPageViewPgNum(nTab) ) // angezeigte Page umstellen + { + pDrawView->HideAllPages(); + pDrawView->ShowPagePgNum( nTab, Point() ); + } +#endif + } + else if ( pDrawView ) + { + delete pDrawView; // fuer diese Tabelle nicht gebraucht + pDrawView = NULL; + } +} + + +void ScPreview::TestLastPage() +{ + if (nPageNo >= nTotalPages) + { + if (nTotalPages) + { + nPageNo = nTotalPages - 1; + nTab = nTabCount - 1; + while (nTab && !nPages[nTab]) // letzte nicht leere Tabelle + --nTab; + DBG_ASSERT(nPages[nTab],"alle Tabellen leer?"); + nTabPage = nPages[nTab] - 1; + nTabStart = 0; + for (USHORT i=0; i<nTab; i++) + nTabStart += nPages[i]; + + ScDocument* pDoc = pDocShell->GetDocument(); + nDisplayStart = lcl_GetDisplayStart( nTab, pDoc, nPages ); + } + else // leeres Dokument + { + nTab = 0; + nPageNo = nTabPage = nTabStart = nDisplayStart = 0; + aState.nPrintTab = aState.nStartCol = aState.nStartRow = + aState.nEndCol = aState.nEndRow = aState.nZoom = 0; + aState.nPagesX = aState.nPagesY = aState.nTabPages = + aState.nTotalPages = aState.nPageStart = aState.nDocPages = 0; + } + } +} + + +void ScPreview::CalcPages( USHORT nToWhichTab ) +{ + WaitObject( this ); + + ScDocument* pDoc = pDocShell->GetDocument(); + nTabCount = pDoc->GetTableCount(); + USHORT i; + + USHORT nAnz = Min( nTabCount, USHORT(nToWhichTab+1) ); + USHORT nStart = nTabsTested; + if (!bValid) + { + nStart = 0; + nTotalPages = 0; + nTabsTested = 0; + } + + for (i=nStart; i<nAnz; i++) + { + long nAttrPage = i ? nFirstAttr[i-1] : 1; + + long nThisStart = nTotalPages; + ScPrintFunc aPrintFunc( pDocShell, this, i, nAttrPage ); + long nThisTab = aPrintFunc.GetTotalPages(); + nPages[i] = nThisTab; + nTotalPages += nThisTab; + nFirstAttr[i] = aPrintFunc.GetFirstPageNo(); // behalten oder aus Vorlage + + if (nPageNo>=nThisStart && nPageNo<nTotalPages) + { + nTab = i; + nTabPage = nPageNo - nThisStart; + nTabStart = nThisStart; + + aPrintFunc.GetPrintState( aState ); + aPageSize = aPrintFunc.GetPageSize(); + } + } + + nDisplayStart = lcl_GetDisplayStart( nTab, pDoc, nPages ); + + if (nAnz > nTabsTested) + nTabsTested = nAnz; + + // testen, ob hinter letzter Seite + + if ( nTabsTested >= nTabCount ) + TestLastPage(); + + aState.nDocPages = nTotalPages; + + bValid = TRUE; + bStateValid = TRUE; + DoInvalidate(); +} + + +void ScPreview::RecalcPages() // nur nPageNo geaendert +{ + if (!bValid) + return; // dann wird CalcPages aufgerufen + + USHORT nOldTab = nTab; + USHORT i; + + BOOL bDone = FALSE; + while (nPageNo >= nTotalPages && nTabsTested < nTabCount) + { + CalcPages( nTabsTested ); + bDone = TRUE; + } + + if (!bDone) + { + long nPartPages = 0; + for (i=0; i<nTabsTested; i++) + { + long nThisStart = nPartPages; + nPartPages += nPages[i]; + + if (nPageNo>=nThisStart && nPageNo<nPartPages) + { + nTab = i; + nTabPage = nPageNo - nThisStart; + nTabStart = nThisStart; + +// aPageSize = aPrintFunc.GetPageSize(); + } + } + + ScDocument* pDoc = pDocShell->GetDocument(); + nDisplayStart = lcl_GetDisplayStart( nTab, pDoc, nPages ); + } + + TestLastPage(); // testen, ob hinter letzter Seite + + if ( nTab != nOldTab ) + bStateValid = FALSE; + + DoInvalidate(); +} + + +void __EXPORT ScPreview::Paint( const Rectangle& rRect ) +{ + if (!bValid) + { + CalcPages(0); + RecalcPages(); + UpdateDrawView(); // Tabelle evtl. geaendert + } + + Fraction aPreviewZoom( nZoom, 100 ); + Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); + MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom ); + + Size aPageSize; + if ( nPageNo < nTotalPages ) + { + ScPrintFunc* pPrintFunc; + if (bStateValid) + pPrintFunc = new ScPrintFunc( pDocShell, this, aState ); + else + pPrintFunc = new ScPrintFunc( pDocShell, this, nTab, nFirstAttr[nTab], nTotalPages ); + + pPrintFunc->SetOffset(aOffset); + pPrintFunc->SetManualZoom(nZoom); + pPrintFunc->SetDateTime(aDate,aTime); + pPrintFunc->SetClearFlag(TRUE); + + pPrintFunc->SetDrawView( pDrawView ); + + // MultiSelection fuer die eine Seite muss etwas umstaendlich erzeugt werden... + Range aPageRange( nPageNo+1, nPageNo+1 ); + MultiSelection aPage( aPageRange ); + aPage.SetTotalRange( Range(0,RANGE_MAX) ); + aPage.Select( aPageRange ); + + long nPrinted = pPrintFunc->DoPrint( aPage, nTabStart, nDisplayStart ); + DBG_ASSERT(nPrinted<=1, "was'n nu los?"); + + SetMapMode(aMMMode); +// USHORT nPrintZoom = pPrintFunc->GetZoom(); + + if (nPrinted) // wenn nichts, alles grau zeichnen + { + aPageSize = pPrintFunc->GetPageSize(); + aPageSize.Width() = (long) (aPageSize.Width() * HMM_PER_TWIPS ); + aPageSize.Height() = (long) (aPageSize.Height() * HMM_PER_TWIPS ); + } + + if (!bStateValid) + { + pPrintFunc->GetPrintState( aState ); + aState.nDocPages = nTotalPages; + bStateValid = TRUE; + } + delete pPrintFunc; + } + + long nPageEndX = aPageSize.Width() - aOffset.X(); + long nPageEndY = aPageSize.Height() - aOffset.Y(); + Size aWinSize = GetOutputSize(); + Point aWinEnd( aWinSize.Width(), aWinSize.Height() ); + BOOL bRight = nPageEndX <= aWinEnd.X(); + BOOL bBottom = nPageEndY <= aWinEnd.Y(); + if (bRight || bBottom) + { + SetLineColor(); + SetFillColor(COL_LIGHTGRAY); + if (bRight) + DrawRect(Rectangle(nPageEndX,0, aWinEnd.X(),aWinEnd.Y())); + if (bBottom) + { + if (bRight) + DrawRect(Rectangle(0,nPageEndY, nPageEndX,aWinEnd.Y())); // Ecke nicht doppelt + else + DrawRect(Rectangle(0,nPageEndY, aWinEnd.X(),aWinEnd.Y())); + } + } + + pViewShell->UpdateScrollBars(); +} + + +void __EXPORT ScPreview::Command( const CommandEvent& rCEvt ) +{ + USHORT nCmd = rCEvt.GetCommand(); + if ( nCmd == COMMAND_WHEEL || nCmd == COMMAND_STARTAUTOSCROLL || nCmd == COMMAND_AUTOSCROLL ) + { + BOOL bDone = pViewShell->ScrollCommand( rCEvt ); + if (!bDone) + Window::Command(rCEvt); + } + else if ( nCmd == COMMAND_CONTEXTMENU ) + SfxDispatcher::ExecutePopup(); + else + Window::Command( rCEvt ); +} + + +void __EXPORT ScPreview::KeyInput( const KeyEvent& rKEvt ) +{ + if (!pViewShell->KeyInput(rKEvt)) + Window::KeyInput(rKEvt); +} + + +void ScPreview::DataChanged(BOOL bNewTime) +{ + if (bNewTime) + { + aDate = Date(); + aTime = Time(); + } + + bValid = FALSE; + Invalidate(); +} + + +String ScPreview::GetPosString() +{ + if (!bValid) + { + CalcPages(nTab); + UpdateDrawView(); // Tabelle evtl. geaendert + } + + String aString( ScGlobal::GetRscString( STR_PAGE ) ); + aString += ' '; + aString += String::CreateFromInt32(nPageNo+1); + + if (nTabsTested >= nTabCount) + { + aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " / " )); + aString += String::CreateFromInt32(nTotalPages); + } + + return aString; +} + + +void ScPreview::SetZoom(USHORT nNewZoom) +{ + if (nNewZoom < 20) + nNewZoom = 20; + if (nNewZoom > 400) + nNewZoom = 400; + if (nNewZoom != nZoom) + { + double nFact = nNewZoom / (double) nZoom; + nZoom = nNewZoom; + aOffset.X() = (long) ( aOffset.X() * nFact ); + aOffset.Y() = (long) ( aOffset.Y() * nFact ); + +// DataChanged(); + + bStateValid = FALSE; + DoInvalidate(); + Invalidate(); + } +} + + +void ScPreview::SetPageNo( long nPage ) +{ + nPageNo = nPage; + RecalcPages(); + UpdateDrawView(); // Tabelle evtl. geaendert + Invalidate(); +} + + +long ScPreview::GetFirstPage(USHORT nTab) +{ + USHORT nTabCount = pDocShell->GetDocument()->GetTableCount(); + if (nTab >= nTabCount) + nTab = nTabCount-1; + + long nPage = 0; + if (nTab>0) + { + CalcPages( nTab ); + UpdateDrawView(); // Tabelle evtl. geaendert + + for (USHORT i=0; i<nTab; i++) + nPage += nPages[i]; + + // bei leerer Tabelle vorhergehende Seite + + if ( nPages[nTab]==0 && nPage > 0 ) + --nPage; + } + + return nPage; +} + + +Size lcl_GetDocPageSize( ScDocument* pDoc, USHORT nTab ) +{ + String aName = pDoc->GetPageStyle( nTab ); + ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool(); + SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aName, SFX_STYLE_FAMILY_PAGE ); + if ( pStyleSheet ) + { + SfxItemSet& rStyleSet = pStyleSheet->GetItemSet(); + return ((const SvxSizeItem&) rStyleSet.Get(ATTR_PAGE_SIZE)).GetSize(); + } + else + { + DBG_ERROR( "PageStyle not found" ); + return Size(); + } +} + + +USHORT ScPreview::GetOptimalZoom(BOOL bWidthOnly) +{ + double nWinScaleX = ScGlobal::nScreenPPTX / pDocShell->GetOutputFactor(); + double nWinScaleY = ScGlobal::nScreenPPTY; + Size aWinSize = GetOutputSizePixel(); + + Size aPageSize = lcl_GetDocPageSize( pDocShell->GetDocument(), nTab ); + if ( aPageSize.Width() && aPageSize.Height() ) + { + long nZoomX = (long) ( aWinSize.Width() * 100 / ( aPageSize.Width() * nWinScaleX )); + long nZoomY = (long) ( aWinSize.Height() * 100 / ( aPageSize.Height() * nWinScaleY )); + + long nOptimal = nZoomX; + if (!bWidthOnly && nZoomY<nOptimal) + nOptimal = nZoomY; + + if (nOptimal<20) + nOptimal = 20; + if (nOptimal>400) + nOptimal = 400; + + return (USHORT) nOptimal; + } + else + return nZoom; +} + + +void ScPreview::SetXOffset( long nX ) +{ + if (bValid) + { + long nDif = LogicToPixel(aOffset).X() - LogicToPixel(Point(nX,0)).X(); + aOffset.X() = nX; + if (!bInPaint) + { + MapMode aOldMode = GetMapMode(); SetMapMode(MAP_PIXEL); + Scroll( nDif, 0 ); + SetMapMode(aOldMode); + } + } + else + { + aOffset.X() = nX; + if (!bInPaint) + Invalidate(); + } +} + + +void ScPreview::SetYOffset( long nY ) +{ + if (bValid) + { + long nDif = LogicToPixel(aOffset).Y() - LogicToPixel(Point(0,nY)).Y(); + aOffset.Y() = nY; + if (!bInPaint) + { + MapMode aOldMode = GetMapMode(); SetMapMode(MAP_PIXEL); + Scroll( 0, nDif ); + SetMapMode(aOldMode); + } + } + else + { + aOffset.Y() = nY; + if (!bInPaint) + Invalidate(); + } +} + + +void ScPreview::DoInvalidate() +{ + // Wenn das ganze aus dem GetState der Shell gerufen wird, + // muss das Invalidate hinterher asynchron kommen... + + if (bInGetState) + Application::PostUserEvent( STATIC_LINK( this, ScPreview, InvalidateHdl ) ); + else + StaticInvalidate(); // sofort +} + +void ScPreview::StaticInvalidate() +{ + SfxBindings& rBindings = SFX_BINDINGS(); + rBindings.Invalidate(SID_STATUS_DOCPOS); + rBindings.Invalidate(SID_STATUS_PAGESTYLE); + rBindings.Invalidate(SID_PREVIEW_PREVIOUS); + rBindings.Invalidate(SID_PREVIEW_NEXT); + rBindings.Invalidate(SID_PREVIEW_FIRST); + rBindings.Invalidate(SID_PREVIEW_LAST); + rBindings.Invalidate(SID_ATTR_ZOOM); + rBindings.Invalidate(SID_PREVIEW_ZOOMIN); + rBindings.Invalidate(SID_PREVIEW_ZOOMOUT); +} + +IMPL_STATIC_LINK( ScPreview, InvalidateHdl, void*, EMPTYARG ) +{ + StaticInvalidate(); + return 0; +} + +void ScPreview::DataChanged( const DataChangedEvent& rDCEvt ) +{ + Window::DataChanged(rDCEvt); + + if ( (rDCEvt.GetType() == DATACHANGED_PRINTER) || + (rDCEvt.GetType() == DATACHANGED_DISPLAY) || + (rDCEvt.GetType() == DATACHANGED_FONTS) || + (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) || + ((rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE)) ) + { + //! Resize, wenn Scrollbars geaendert + + if ( rDCEvt.GetType() == DATACHANGED_FONTS ) + pDocShell->UpdateFontList(); + + Invalidate(); + } +} + + + + diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx new file mode 100644 index 000000000000..373865445942 --- /dev/null +++ b/sc/source/ui/view/prevwsh.cxx @@ -0,0 +1,844 @@ +/************************************************************************* + * + * $RCSfile: prevwsh.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <svx/sizeitem.hxx> +#include <svx/srchitem.hxx> +#include <svx/zoom.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/request.hxx> +#include <sfx2/topfrm.hxx> +#include <svtools/printdlg.hxx> +#include <svtools/stritem.hxx> +#include <svtools/whiter.hxx> +#include <vcl/msgbox.hxx> +#include <tools/urlobj.hxx> +#include <sfx2/docfile.hxx> + +#include "prevwsh.hxx" +#include "preview.hxx" +#include "scmod.hxx" +#include "inputhdl.hxx" +#include "docsh.hxx" +#include "tabvwsh.hxx" +#include "stlpool.hxx" +#include "editutil.hxx" +#include "scresid.hxx" +#include "globstr.hrc" +#include "sc.hrc" + +// fuer Rad-Maus +#define SC_DELTA_ZOOM 10 + +#define SC_USERDATA_SEP ';' + +// ----------------------------------------------------------------------- + +#define ScPreviewShell +#include "scslots.hxx" + +TYPEINIT1( ScPreviewShell, SfxViewShell ); + +SFX_IMPL_INTERFACE( ScPreviewShell, SfxViewShell, ScResId(SCSTR_PREVIEWSHELL) ) +{ + SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD| + SFX_VISIBILITY_SERVER|SFX_VISIBILITY_READONLYDOC, + ScResId(RID_OBJECTBAR_PREVIEW)); + SFX_POPUPMENU_REGISTRATION(ScResId(RID_POPUP_PREVIEW)); +} + +SFX_IMPL_VIEWFACTORY( ScPreviewShell, ScResId(STR_NONAME) ) +{ + SFX_VIEW_REGISTRATION(ScDocShell); +} + +//------------------------------------------------------------------ + +void ScPreviewShell::Construct( Window* pParent ) +{ + eZoom = SVX_ZOOM_WHOLEPAGE; + + pCorner = new Window(pParent, WinBits( WB_BORDER )); + pCorner->SetBackground( Color( COL_LIGHTGRAY ) ); + + pHorScroll = new ScrollBar(pParent, WB_HSCROLL ); + pVerScroll = new ScrollBar(pParent, WB_VSCROLL); + + pHorScroll->SetEndScrollHdl( LINK( this, ScPreviewShell, ScrollHandler ) ); + pVerScroll->SetEndScrollHdl( LINK( this, ScPreviewShell, ScrollHandler ) ); + + pPreview = new ScPreview( pParent, pDocShell, this ); + + SetPool( &SC_MOD()->GetPool() ); + SetWindow( pPreview ); + StartListening(*pDocShell); + StartListening(*SFX_APP()); + SfxBroadcaster* pDrawBC = pDocShell->GetDocument()->GetDrawBroadcaster(); + if (pDrawBC) + StartListening(*pDrawBC); + +// pPreview->Show(); // wird vom Sfx angezeigt + pHorScroll->Show(); + pVerScroll->Show(); + pCorner->Show(); + SetHelpId( HID_SCSHELL_PREVWSH ); + SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Preview"))); +} + +ScPreviewShell::ScPreviewShell( SfxViewFrame* pViewFrame, + const ScPreviewShell& rWin ) : + SfxViewShell( pViewFrame, SFX_VIEW_MAXIMIZE_FIRST | SFX_VIEW_CAN_PRINT ), + pDocShell( rWin.pDocShell ), + aSourceData( rWin.aSourceData ) +{ + Construct( &pViewFrame->GetWindow() ); +} + +ScPreviewShell::ScPreviewShell( SfxViewFrame* pViewFrame, + Window *pParent ) : + SfxViewShell( pViewFrame, SFX_VIEW_MAXIMIZE_FIRST | SFX_VIEW_CAN_PRINT ), + pDocShell( (ScDocShell*)pViewFrame->GetObjectShell() ) +{ + Construct( pParent ); +} + +ScPreviewShell::ScPreviewShell( SfxViewFrame* pViewFrame, + SfxViewShell* pOldSh ) : + SfxViewShell( pViewFrame, SFX_VIEW_MAXIMIZE_FIRST | SFX_VIEW_CAN_PRINT ), + pDocShell( (ScDocShell*)pViewFrame->GetObjectShell() ) +{ + Construct( &pViewFrame->GetWindow() ); + + if ( pOldSh && pOldSh->ISA( ScTabViewShell ) ) + { + // store view settings, show table from TabView + //! store live ScViewData instead, and update on ScTablesHint? + //! or completely forget aSourceData on ScTablesHint? + + ScViewData* pData = ((ScTabViewShell*)pOldSh)->GetViewData(); + pData->WriteUserData( aSourceData ); + InitStartTable( pData->GetTabNo() ); + } +} + +__EXPORT ScPreviewShell::~ScPreviewShell() +{ + SfxBroadcaster* pDrawBC = pDocShell->GetDocument()->GetDrawBroadcaster(); + if (pDrawBC) + EndListening(*pDrawBC); + EndListening(*SFX_APP()); + EndListening(*pDocShell); + + SetWindow(0); + delete pPreview; + delete pHorScroll; + delete pVerScroll; + delete pCorner; + + // #47435# wie im Writer (SwPagePreView::~SwPagePreView): + // Wenn die Preview zugemacht wird, eine andere View des Dokuments suchen und aktivieren + + TypeId aType = TYPE( SfxTopViewFrame ); + for( SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pDocShell, aType ); + pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell, aType ) ) + if( pFrame != GetViewFrame() ) + { + // es gibt noch eine weitere Sicht auf unser Dokument, also + // aktiviere dieses + pFrame->GetFrame()->Appear(); + break; + } +} + +void ScPreviewShell::InitStartTable(USHORT nTab) +{ + pPreview->SetPageNo( pPreview->GetFirstPage(nTab) ); +} + +//------------------------------------------------------------------ + +String __EXPORT ScPreviewShell::GetDescription() const +{ + return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(" ** Test ** ")); +} + +Size __EXPORT ScPreviewShell::GetOptimalSizePixel() const +{ + Size aOptSize(100,100); + + ScTabViewShell* pViewSh = pDocShell->GetBestViewShell(); + + if ( pViewSh ) + { + ScViewData* pViewData = pViewSh->GetViewData(); + USHORT nCurTab = pViewData->GetTabNo(); + ScDocument* pDoc = pDocShell->GetDocument(); + ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool(); + SfxStyleSheetBase* pStyleSheet = pStylePool->Find( + pDoc->GetPageStyle( nCurTab ), + SFX_STYLE_FAMILY_PAGE ); + + DBG_ASSERT( pStyleSheet, "PageStyle not found :-/" ); + + if ( pStyleSheet ) + { + const SfxItemSet& rSet = pStyleSheet->GetItemSet(); + const SvxSizeItem& rItem = (const SvxSizeItem&)rSet.Get( ATTR_PAGE_SIZE ); + const Size& rPageSize = rItem.GetSize(); + + aOptSize.Width() = (long) (rPageSize.Width() * pViewData->GetPPTX()); + aOptSize.Height() = (long) (rPageSize.Height() * pViewData->GetPPTY()); + } + } + else + DBG_ERROR( "TabViewShell not found :-/" ); + + return aOptSize; +} + +void __EXPORT ScPreviewShell::AdjustPosSizePixel( const Point &rPos, const Size &rSize ) +{ + long nBarW = pVerScroll->GetSizePixel().Width(); + long nBarH = pHorScroll->GetSizePixel().Height(); + Size aOutSize( rSize.Width()-nBarW, rSize.Height()-nBarH ); + pPreview->SetPosSizePixel( rPos, aOutSize ); + pHorScroll->SetPosSizePixel( Point( rPos.X(), rPos.Y() + aOutSize.Height() ), + Size( aOutSize.Width(), nBarH ) ); + pVerScroll->SetPosSizePixel( Point( rPos.X() + aOutSize.Width(), rPos.Y() ), + Size( nBarW, aOutSize.Height() ) ); + pCorner->SetPosSizePixel( Point( rPos.X() + aOutSize.Width(), rPos.Y() + aOutSize.Height() ), + Size( nBarW, nBarH ) ); + + if ( SVX_ZOOM_WHOLEPAGE == eZoom ) + pPreview->SetZoom( pPreview->GetOptimalZoom(FALSE) ); + else if ( SVX_ZOOM_PAGEWIDTH == eZoom ) + pPreview->SetZoom( pPreview->GetOptimalZoom(TRUE) ); +} + +void __EXPORT ScPreviewShell::InnerResizePixel( const Point &rOfs, const Size &rSize ) +{ + AdjustPosSizePixel( rOfs,rSize ); +} + +void __EXPORT ScPreviewShell::OuterResizePixel( const Point &rOfs, const Size &rSize ) +{ + AdjustPosSizePixel( rOfs,rSize ); +} + +void ScPreviewShell::UpdateScrollBars() +{ + ScDocument* pDoc = pDocShell->GetDocument(); + USHORT nTab = pPreview->GetTab(); + + ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool(); + SfxStyleSheetBase* pStyleSheet = pStylePool->Find( pDoc->GetPageStyle( nTab ), + SFX_STYLE_FAMILY_PAGE ); + DBG_ASSERT(pStyleSheet,"StyleSheet nicht gefunden"); + if (!pStyleSheet) return; + const SfxItemSet* pParamSet = &pStyleSheet->GetItemSet(); + + Size aPageSize = ((const SvxSizeItem&) pParamSet->Get(ATTR_PAGE_SIZE)).GetSize(); + aPageSize.Width() = (long) (aPageSize.Width() * HMM_PER_TWIPS ); + aPageSize.Height() = (long) (aPageSize.Height() * HMM_PER_TWIPS ); + Size aWindowSize = pPreview->GetOutputSize(); + + Point aOfs = pPreview->GetOffset(); + long nMaxPos; + + pHorScroll->SetRange( Range( 0, aPageSize.Width() ) ); + pHorScroll->SetLineSize( aWindowSize.Width() / 16 ); + pHorScroll->SetPageSize( aWindowSize.Width() ); + pHorScroll->SetVisibleSize( aWindowSize.Width() ); + nMaxPos = aPageSize.Width() - aWindowSize.Width(); + if (nMaxPos<0) nMaxPos = 0; + if (aOfs.X() > nMaxPos) + { + aOfs.X() = nMaxPos; + pPreview->SetXOffset(nMaxPos); + } + pHorScroll->SetThumbPos( aOfs.X() ); + + pVerScroll->SetRange( Range( 0, aPageSize.Height() ) ); + pVerScroll->SetLineSize( aWindowSize.Height() / 16 ); + pVerScroll->SetPageSize( aWindowSize.Height() ); + pVerScroll->SetVisibleSize( aWindowSize.Height() ); + nMaxPos = aPageSize.Height() - aWindowSize.Height(); + if (nMaxPos<0) nMaxPos = 0; + if (aOfs.Y() > nMaxPos) + { + aOfs.Y() = nMaxPos; + pPreview->SetYOffset(nMaxPos); + } + pVerScroll->SetThumbPos( aOfs.Y() ); +} + +IMPL_LINK (ScPreviewShell,ScrollHandler, ScrollBar* ,pScroll ) +{ + long nDelta = pScroll->GetDelta(); + long nPos = pScroll->GetThumbPos(); + + BOOL bHoriz = ( pScroll == pHorScroll ); + if (bHoriz) + pPreview->SetXOffset( nPos ); + else + pPreview->SetYOffset( nPos ); + + return 0; +} + +BOOL ScPreviewShell::ScrollCommand( const CommandEvent& rCEvt ) +{ + BOOL bDone = FALSE; + const CommandWheelData* pData = rCEvt.GetWheelData(); + if ( pData && pData->GetMode() == COMMAND_WHEEL_ZOOM ) + { + long nOld = pPreview->GetZoom(); + long nNew = nOld; + if ( pData->GetDelta() < 0 ) + nNew = Max( (long) MINZOOM, (long)( nOld - SC_DELTA_ZOOM ) ); + else + nNew = Min( (long) MAXZOOM, (long)( nOld + SC_DELTA_ZOOM ) ); + + if ( nNew != nOld ) + { + eZoom = SVX_ZOOM_PERCENT; + pPreview->SetZoom( nNew ); + } + + bDone = TRUE; + } + else + { + bDone = pPreview->HandleScrollCommand( rCEvt, pHorScroll, pVerScroll ); + + //! ist das noetig ???? + if ( bDone ) + { + Point aOld = pPreview->GetOffset(); + long nHorThunb = pHorScroll->GetThumbPos(); + if ( nHorThunb != aOld.X() ) + pPreview->SetXOffset( nHorThunb ); + long nVerThunb = pVerScroll->GetThumbPos(); + if ( nVerThunb != aOld.Y() ) + pPreview->SetYOffset( nVerThunb ); + } + } + + return bDone; +} + +SfxPrinter* __EXPORT ScPreviewShell::GetPrinter( BOOL bCreate ) +{ + // Drucker ist immer da (wird fuer die FontListe schon beim Starten angelegt) + return pDocShell->GetPrinter(); +} + +USHORT __EXPORT ScPreviewShell::SetPrinter( SfxPrinter *pNewPrinter, USHORT nDiffFlags ) +{ + return pDocShell->SetPrinter( pNewPrinter, nDiffFlags ); +} + +PrintDialog* __EXPORT ScPreviewShell::CreatePrintDialog( Window* pParent ) +{ + pDocShell->GetDocument()->SetPrintOptions(); // Optionen aus OFA am Printer setzen + SfxPrinter* pPrinter = GetPrinter(); + + const long nCurPage = pPreview->GetPageNo()+1; + const long nDocPageMax = pPreview->GetTotalPages(); +#ifndef VCL + PrintDialog* pDlg = new PrintDialog( pParent, + WinBits(WB_SVLOOK|WB_STDMODAL) ); +#else + PrintDialog* pDlg = new PrintDialog( pParent ); +#endif +// wenn zu langsam wieder einbauen +// if ( pPreview->AllTested() ) +// nPageMax = pPreview->GetTotalPages(); + + if ( nDocPageMax > 0 ) + pDlg->SetRangeText( String::CreateFromInt32( nCurPage ) ); + + pDlg->EnableRange ( PRINTDIALOG_ALL ); + pDlg->EnableRange ( PRINTDIALOG_RANGE ); + pDlg->SetFirstPage ( 1 ); + pDlg->SetMinPage ( 1 ); + pDlg->SetLastPage ( (USHORT)nDocPageMax ); + pDlg->SetMaxPage ( (USHORT)nDocPageMax ); + pDlg->EnableCollate (); + + // Selektion hier nicht + + return pDlg; +} + +void __EXPORT ScPreviewShell::PreparePrint( PrintDialog* pPrintDialog ) +{ + SfxViewShell::PreparePrint( pPrintDialog ); + pDocShell->PreparePrint( pPrintDialog, NULL ); +} + +USHORT __EXPORT ScPreviewShell::Print( SfxProgress& rProgress, PrintDialog* pPrintDialog ) +{ + pDocShell->GetDocument()->SetPrintOptions(); // Optionen aus OFA am Printer setzen + + SfxViewShell::Print( rProgress, pPrintDialog ); + pDocShell->Print( rProgress, pPrintDialog, NULL ); + + return 0; +} + +//------------------------------------------------------------------------ + +void __EXPORT ScPreviewShell::Activate(BOOL bMDI) +{ + SfxViewShell::Activate(bMDI); + + //! Basic etc. -> auslagern in eigene Datei (s. tabvwsh4) + + if (bMDI) + { + // InputHdl ist jetzt meistens Null, keine Assertion mehr! + ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl(); + if ( pInputHdl ) + pInputHdl->NotifyChange( NULL ); + } +} + +void __EXPORT ScPreviewShell::Deactivate(BOOL bMDI) +{ + SfxViewShell::Deactivate(bMDI); + + if (bMDI) + { + } +} + +//------------------------------------------------------------------------ + +void __EXPORT ScPreviewShell::Execute( SfxRequest& rReq ) +{ + USHORT nSlot = rReq.GetSlot(); + const SfxItemSet* pReqArgs = rReq.GetArgs(); + + switch ( nSlot ) + { + case SID_FORMATPAGE: + case SID_STATUS_PAGESTYLE: + case SID_HFEDIT: + pDocShell->ExecutePageStyle( *this, rReq, pPreview->GetTab() ); + break; + case SID_REPAINT: + pPreview->Invalidate(); + rReq.Done(); + break; + case SID_PREV_TABLE: // Accelerator + case SID_PREVIEW_PREVIOUS: + { + long nPage = pPreview->GetPageNo(); + long nTotal = pPreview->GetTotalPages(); + if (nTotal && nPage > 0) + pPreview->SetPageNo( nPage-1 ); + } + break; + case SID_NEXT_TABLE: // Accelerator + case SID_PREVIEW_NEXT: + { + BOOL bAllTested = pPreview->AllTested(); + long nPage = pPreview->GetPageNo(); + long nTotal = pPreview->GetTotalPages(); + if (nTotal && (nPage+1 < nTotal || !bAllTested)) + pPreview->SetPageNo( nPage+1 ); + } + break; + case SID_CURSORTOPOFFILE: // Accelerator + case SID_PREVIEW_FIRST: + { + long nPage = pPreview->GetPageNo(); + long nTotal = pPreview->GetTotalPages(); + if (nTotal && nPage != 0) + pPreview->SetPageNo( 0 ); + } + break; + case SID_CURSORENDOFFILE: // Accelerator + case SID_PREVIEW_LAST: + { + if (!pPreview->AllTested()) + pPreview->CalcAll(); + + long nPage = pPreview->GetPageNo(); + long nTotal = pPreview->GetTotalPages(); + if (nTotal && nPage+1 != nTotal) + pPreview->SetPageNo( nTotal-1 ); + } + break; + case SID_ATTR_ZOOM: + case FID_SCALE: + { + USHORT nZoom = 100; + BOOL bCancel = FALSE; + + eZoom = SVX_ZOOM_PERCENT; + + if ( pReqArgs ) + { + + const SvxZoomItem& rZoomItem = (const SvxZoomItem&) + pReqArgs->Get(SID_ATTR_ZOOM); + + eZoom = rZoomItem.GetType(); + nZoom = rZoomItem.GetValue(); + } + else + { + SfxItemSet aSet ( GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM ); + SvxZoomItem aZoomItem( SVX_ZOOM_PERCENT, pPreview->GetZoom(), SID_ATTR_ZOOM ); + + aSet.Put( aZoomItem ); + SvxZoomDialog* pDlg = pDlg = new SvxZoomDialog( NULL, aSet ); + pDlg->SetLimits( 20, 400 ); + pDlg->HideButton( ZOOMBTN_OPTIMAL ); + bCancel = ( RET_CANCEL == pDlg->Execute() ); + + if ( !bCancel ) + { + const SvxZoomItem& rZoomItem = (const SvxZoomItem&) + pDlg->GetOutputItemSet()-> + Get( SID_ATTR_ZOOM ); + + eZoom = rZoomItem.GetType(); + nZoom = rZoomItem.GetValue(); + } + + delete pDlg; + } + + if ( !bCancel ) + { + switch ( eZoom ) + { + case SVX_ZOOM_OPTIMAL: + case SVX_ZOOM_WHOLEPAGE: + nZoom = pPreview->GetOptimalZoom(FALSE); + break; + case SVX_ZOOM_PAGEWIDTH: + nZoom = pPreview->GetOptimalZoom(TRUE); + break; + } + + pPreview->SetZoom( nZoom ); + rReq.Done(); + } + } + break; + case SID_PREVIEW_ZOOMIN: + { + USHORT nNew = pPreview->GetZoom() + 20 ; + nNew -= nNew % 20; + pPreview->SetZoom( nNew ); + eZoom = SVX_ZOOM_PERCENT; + rReq.Done(); + } + break; + case SID_PREVIEW_ZOOMOUT: + { + USHORT nNew = pPreview->GetZoom() - 1; + nNew -= nNew % 20; + pPreview->SetZoom( nNew ); + eZoom = SVX_ZOOM_PERCENT; + rReq.Done(); + } + break; + case SID_PRINTPREVIEW: + // print preview is now always in the same frame as the tab view + // -> always switch this frame back to normal view + // (ScTabViewShell ctor reads stored view data) + + GetViewFrame()->GetBindings().Execute( SID_VIEWSHELL0, NULL, 0, SFX_CALLMODE_ASYNCHRON ); + break; + case SID_CURSORPAGEUP: + case SID_CURSORPAGEDOWN: + case SID_CURSORHOME: + case SID_CURSOREND: + case SID_CURSORUP: + case SID_CURSORDOWN: + case SID_CURSORLEFT: + case SID_CURSORRIGHT: + DoScroll( nSlot ); + break; + + default: + break; + } +} + +void __EXPORT ScPreviewShell::GetState( SfxItemSet& rSet ) +{ + pPreview->SetInGetState(TRUE); + + USHORT nTab = pPreview->GetTab(); + long nPage = pPreview->GetPageNo(); + long nTotal = pPreview->GetTotalPages(); + USHORT nZoom = pPreview->GetZoom(); + BOOL bAllTested = pPreview->AllTested(); + + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + while ( nWhich ) + { + switch (nWhich) + { + case SID_STATUS_PAGESTYLE: + case SID_HFEDIT: + pDocShell->GetStatePageStyle( *this, rSet, nTab ); + break; + case SID_UNDO: + case SID_REDO: + case SID_REPEAT: + rSet.DisableItem(nWhich); + break; + case SID_PREVIEW_PREVIOUS: + case SID_PREVIEW_FIRST: + if (!nTotal || nPage==0) + rSet.DisableItem(nWhich); + break; + case SID_PREVIEW_NEXT: + case SID_PREVIEW_LAST: + if (bAllTested) + if (!nTotal || nPage==nTotal-1) + rSet.DisableItem(nWhich); + break; + case SID_PREVIEW_ZOOMIN: + if (nZoom >= 400) + rSet.DisableItem(nWhich); + break; + case SID_PREVIEW_ZOOMOUT: + if (nZoom <= 20) + rSet.DisableItem(nWhich); + break; + case SID_ATTR_ZOOM: + { + SvxZoomItem aZoom( eZoom, nZoom, nWhich ); + aZoom.SetValueSet( SVX_ZOOM_ENABLE_ALL & ~SVX_ZOOM_ENABLE_OPTIMAL ); + rSet.Put( aZoom ); + } + break; + case SID_STATUS_DOCPOS: + rSet.Put( SfxStringItem( nWhich, pPreview->GetPosString() ) ); + break; + case SID_PRINTPREVIEW: + rSet.Put( SfxBoolItem( nWhich, TRUE ) ); + break; + case SID_FORMATPAGE: + //! bei geschuetzten Tabellen ??? + if (pDocShell->IsReadOnly()) + rSet.DisableItem( nWhich ); + break; + } + + nWhich = aIter.NextWhich(); + } + + pPreview->SetInGetState(FALSE); +} + +void ScPreviewShell::FillFieldData( ScHeaderFieldData& rData ) +{ + ScDocument* pDoc = pDocShell->GetDocument(); + USHORT nTab = pPreview->GetTab(); + pDoc->GetName( nTab, rData.aTabName ); + + rData.aTitle = pDocShell->GetTitle(); + rData.aLongDocName = pDocShell->GetMedium()->GetName(); + if ( !rData.aLongDocName.Len() ) + rData.aLongDocName = rData.aTitle; + rData.aShortDocName = INetURLObject( rData.aLongDocName ).GetName(); + rData.nPageNo = pPreview->GetPageNo() + 1; + + BOOL bAllTested = pPreview->AllTested(); + if (bAllTested) + rData.nTotalPages = pPreview->GetTotalPages(); + else + rData.nTotalPages = 99; + + // eNumType kennt der Dialog selber +} + +void __EXPORT ScPreviewShell::WriteUserData(String& rData, BOOL bBrowse) +{ + // nZoom + // nPageNo + + rData = String::CreateFromInt32(pPreview->GetZoom()); + rData += (sal_Unicode) SC_USERDATA_SEP; + rData += String::CreateFromInt32(pPreview->GetPageNo()); + + if ( aSourceData.Len() ) + { + // add settings from tabview in parentheses + + rData += (sal_Unicode) SC_USERDATA_SEP; + rData += (sal_Unicode) '('; + rData += aSourceData; + rData += (sal_Unicode) ')'; + } +} + +void __EXPORT ScPreviewShell::ReadUserData(const String& rData, BOOL bBrowse) +{ + xub_StrLen nCount = rData.GetTokenCount(); + if (nCount) + { + xub_StrLen nIndex = 0; + pPreview->SetZoom(rData.GetToken( 0, SC_USERDATA_SEP, nIndex ).ToInt32()); + pPreview->SetPageNo(rData.GetToken( 0, SC_USERDATA_SEP, nIndex ).ToInt32()); + eZoom = SVX_ZOOM_PERCENT; + + // tabview data is enclosed in parentheses + + String aTabStr = rData.Copy( nIndex ); + if ( aTabStr.GetChar(0) == '(' ) + { + xub_StrLen nParPos = aTabStr.Search( ')' ); + if ( nParPos != STRING_NOTFOUND ) + { + // get the string in the parentheses + aSourceData = aTabStr.Copy( 1, nParPos - 1 ); + } + } + } +} + +void ScPreviewShell::DoScroll( USHORT nMode ) +{ + Point aCurPos, aPrevPos; + + long nHRange = pHorScroll->GetRange().Max(); + long nHLine = pHorScroll->GetLineSize(); + long nHPage = pHorScroll->GetPageSize(); + long nVRange = pVerScroll->GetRange().Max(); + long nVLine = pVerScroll->GetLineSize(); + long nVPage = pVerScroll->GetPageSize(); + + aCurPos.X() = pHorScroll->GetThumbPos(); + aCurPos.Y() = pVerScroll->GetThumbPos(); + aPrevPos = aCurPos; + + switch( nMode ) + { + case SID_CURSORUP: + aCurPos.Y() -= nVLine; + break; + case SID_CURSORDOWN: + aCurPos.Y() += nVLine; + break; + case SID_CURSORLEFT: + aCurPos.X() -= nHLine; + break; + case SID_CURSORRIGHT: + aCurPos.X() += nHLine; + break; + case SID_CURSORPAGEUP: + aCurPos.Y() -= nVPage; + break; + case SID_CURSORPAGEDOWN: + aCurPos.Y() += nVPage; + break; + case SID_CURSORHOME: + aCurPos.Y() = 0; + aCurPos.X() = 0; + break; + case SID_CURSOREND: + aCurPos.Y() = nVRange; + aCurPos.X() = nHRange; + break; + } + + // nHRange-nHPage kann negativ sein, deshalb Abfrage auf < 0 hinterher + + if( aCurPos.Y() > (nVRange-nVPage) ) aCurPos.Y() = (nVRange-nVPage); + if( aCurPos.Y() < 0 ) aCurPos.Y() = 0; + if( aCurPos.X() > (nHRange-nHPage) ) aCurPos.X() = (nHRange-nHPage); + if( aCurPos.X() < 0 ) aCurPos.X() = 0; + + if( aCurPos.Y() != aPrevPos.Y() ) + { + pVerScroll->SetThumbPos( aCurPos.Y() ); + pPreview->SetYOffset( aCurPos.Y() ); + } + + if( aCurPos.X() != aPrevPos.X() ) + { + pHorScroll->SetThumbPos( aCurPos.X() ); + pPreview->SetXOffset( aCurPos.X() ); + } + +} + + + diff --git a/sc/source/ui/view/prevwsh2.cxx b/sc/source/ui/view/prevwsh2.cxx new file mode 100644 index 000000000000..cba1b283f325 --- /dev/null +++ b/sc/source/ui/view/prevwsh2.cxx @@ -0,0 +1,392 @@ +/************************************************************************* + * + * $RCSfile: prevwsh2.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +// TOOLS +#define _BIGINT_HXX +#define _SFXMULTISEL_HXX +#define _STACK_HXX +#define _QUEUE_HXX +#define _DYNARR_HXX +#define _TREELIST_HXX +#define _CACHESTR_HXX +#define _NEW_HXX +//#define _SHL_HXX +//#define _LINK_HXX +//#define _ERRCODE_HXX +//#define _GEN_HXX +//#define _FRACT_HXX +//#define _STRING_HXX +//#define _MTF_HXX +//#define _CONTNR_HXX +//#define _LIST_HXX +//#define _TABLE_HXX +#define _DYNARY_HXX +//#define _UNQIDX_HXX +#define _SVMEMPOOL_HXX +//#define _UNQID_HXX +//#define _DEBUG_HXX +//#define _DATE_HXX +//#define _TIME_HXX +//#define _DATETIME_HXX +//#define _INTN_HXX +//#define _WLDCRD_HXX +//#define _FSYS_HXX +//#define _STREAM_HXX +#define _CACHESTR_HXX +#define _SV_MULTISEL_HXX + +//SV +//#define _CLIP_HXX *** +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _FONTDLG_HXX +#define _PRVWIN_HXX +//#define _COLOR_HXX +//#define _PAL_HXX +//#define _BITMAP_HXX +//#define _GDIOBJ_HXX +//#define _POINTR_HXX +//#define _ICON_HXX +//#define _IMAGE_HXX +//#define _KEYCOD_HXX +//#define _EVENT_HXX +#define _HELP_HXX +//#define _APP_HXX +//#define _MDIAPP_HXX +//#define _TIMER_HXX +//#define _METRIC_HXX +//#define _REGION_HXX +//#define _OUTDEV_HXX +//#define _SYSTEM_HXX +//#define _VIRDEV_HXX +//#define _JOBSET_HXX +//#define _PRINT_HXX +//#define _WINDOW_HXX +//#define _SYSWIN_HXX +//#define _WRKWIN_HXX +#define _MDIWIN_HXX +//#define _FLOATWIN_HXX +//#define _DOCKWIN_HXX +//#define _CTRL_HXX +//#define _SCRBAR_HXX +//#define _BUTTON_HXX +//#define _IMAGEBTN_HXX +//#define _FIXED_HXX +//#define _GROUP_HXX +//#define _EDIT_HXX +//#define _COMBOBOX_HXX +//#define _LSTBOX_HXX +//#define _SELENG_HXX *** +//#define _SPLIT_HXX +#define _SPIN_HXX +//#define _FIELD_HXX +//#define _MOREBTN_HXX *** +//#define _TOOLBOX_HXX +//#define _STATUS_HXX *** +//#define _DIALOG_HXX +//#define _MSGBOX_HXX +//#define _SYSDLG_HXX +//#define _PRNDLG_HXX +#define _COLDLG_HXX +//#define _TABDLG_HXX +//#define _GDIMTF_HXX +//#define _POLY_HXX +//#define _ACCEL_HXX +//#define _GRAPH_HXX +#define _SOUND_HXX + +#if defined WIN +#define _MENUBTN_HXX +#endif + +//svtools +#define _SCRWIN_HXX +#define _RULER_HXX +//#define _TABBAR_HXX +//#define _VALUESET_HXX +#define _STDMENU_HXX +//#define _STDCTRL_HXX +//#define _CTRLBOX_HXX +#define _CTRLTOOL_HXX +#define _EXTATTR_HXX +#define _FRM3D_HXX +#define _EXTATTR_HXX + +//SVTOOLS +//#define _SVTREELIST_HXX *** +#define _FILTER_HXX +//#define _SVLBOXITM_HXX *** +//#define _SVTREEBOX_HXX *** +#define _SVICNVW_HXX +#define _SVTABBX_HXX + +//sfxcore.hxx +//#define _SFXINIMGR_HXX *** +//#define _SFXCFGITEM_HXX +//#define _SFX_PRINTER_HXX +#define _SFXGENLINK_HXX +#define _SFXHINTPOST_HXX +#define _SFXDOCINF_HXX +#define _SFXLINKHDL_HXX +//#define _SFX_PROGRESS_HXX + +//sfxsh.hxx +//#define _SFX_SHELL_HXX +//#define _SFXAPP_HXX +//#define _SFX_BINDINGS_HXX +//#define _SFXDISPATCH_HXX +//#define _SFXMSG_HXX *** +//#define _SFXOBJFACE_HXX *** +//#define _SFXREQUEST_HXX +#define _SFXMACRO_HXX + +// SFX +//#define _SFXAPPWIN_HXX *** +#define _SFX_SAVEOPT_HXX +//#define _SFX_CHILDWIN_HXX +//#define _SFXCTRLITEM_HXX +#define _SFXPRNMON_HXX +#define _INTRO_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFXFILEDLG_HXX +#define _PASSWD_HXX +#define _SFXTBXCTRL_HXX +#define _SFXSTBITEM_HXX +#define _SFXMNUITEM_HXX +#define _SFXIMGMGR_HXX +#define _SFXTBXMGR_HXX +#define _SFXSTBMGR_HXX +#define _SFX_MINFITEM_HXX +#define _SFXEVENT_HXX + +//sfxdoc.hxx +//#define _SFX_OBJSH_HXX +//#define _SFX_CLIENTSH_HXX +//#define _SFXDOCINF_HXX +//#define _SFX_OBJFAC_HXX +#define _SFX_DOCFILT_HXX +//#define _SFXDOCFILE_HXX *** +//define _VIEWFAC_HXX +//#define _SFXVIEWFRM_HXX +//#define _SFXVIEWSH_HXX +//#define _MDIFRM_HXX *** +#define _SFX_IPFRM_HXX +//#define _SFX_INTERNO_HXX + +//sfxdlg.hxx +//#define _SFXTABDLG_HXX +//#define _BASEDLGS_HXX *** +#define _SFX_DINFDLG_HXX +#define _SFXDINFEDT_HXX +#define _SFX_MGETEMPL_HXX +#define _SFX_TPLPITEM_HXX +//#define _SFX_STYLEDLG_HXX +#define _NEWSTYLE_HXX +//#define _SFXDOCTEMPL_HXX *** +//#define _SFXDOCTDLG_HXX *** +//#define _SFX_TEMPLDLG_HXX *** +//#define _SFXNEW_HXX *** +#define _SFXDOCMAN_HXX +#define _SFXDOCKWIN_HXX + +//sfxitems.hxx +#define _SFX_WHMAP_HXX +//#define _ARGS_HXX *** +//#define _SFXPOOLITEM_HXX +//#define _SFXINTITEM_HXX +//#define _SFXENUMITEM_HXX +#define _SFXFLAGITEM_HXX +//#define _SFXSTRITEM_HXX +#define _SFXPTITEM_HXX +#define _SFXRECTITEM_HXX +//#define _SFXITEMPOOL_HXX +//#define _SFXITEMSET_HXX +#define _SFXITEMITER_HXX +#define _SFX_WHITER_HXX +#define _SFXPOOLCACH_HXX +//#define _AEITEM_HXX +#define _SFXRNGITEM_HXX +//#define _SFXSLSTITM_HXX +//#define _SFXSTYLE_HXX + +//xout.hxx +//#define _XENUM_HXX +//#define _XPOLY_HXX +//#define _XATTR_HXX +//#define _XOUTX_HXX +//#define _XPOOL_HXX +//#define _XTABLE_HXX + +//svdraw.hxx +#define _SDR_NOITEMS +#define _SDR_NOTOUCH +#define _SDR_NOTRANSFORM +//#define _SDR_NOOBJECTS +//#define _SDR_NOVIEWS +#define _SDR_NOTRANSFORM +#define _SDR_NOVIEWMARKER +#define _SDR_NODRAGMETHODS +#define _SDR_NOUNDO +#define _SDR_NOXOUTDEV + + +//#define SI_NOITEMS +//#define SI_NODRW +#define _SI_NOSBXCONTROLS +//#define _VCATTR_HXX +#define _VCONT_HXX +//#define _VCSBX_HXX +#define _SI_NOOTHERFORMS +#define _VCTRLS_HXX +//#define _VCDRWOBJ_HXX +#define _SI_NOCONTROL +#define _SETBRW_HXX +#define _VCBRW_HXX +#define _SI_NOSBXCONTROLS +//#define _SIDLL_HXX *** + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_THESDLG_HXX + + + + +// INCLUDE --------------------------------------------------------------- + +#include <svx/svdmodel.hxx> +#include <svtools/smplhint.hxx> + +#include "prevwsh.hxx" +#include "docsh.hxx" +#include "preview.hxx" +#include "hints.hxx" +#include "sc.hrc" + +// STATIC DATA ----------------------------------------------------------- + +// ----------------------------------------------------------------------- + +void __EXPORT ScPreviewShell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, + const SfxHint& rHint, const TypeId& rHintType ) +{ + BOOL bDataChanged = FALSE; + + if (rHint.ISA(SfxSimpleHint)) + { + ULONG nSlot = ((const SfxSimpleHint&)rHint).GetId(); + switch ( nSlot ) + { + case FID_DATACHANGED: + bDataChanged = TRUE; + break; + case SC_HINT_DRWLAYER_NEW: + { + SfxBroadcaster* pDrawBC = pDocShell->GetDocument()->GetDrawBroadcaster(); + if (pDrawBC) + StartListening(*pDrawBC); + } + break; + } + } + else if (rHint.ISA(ScPaintHint)) + { + if ( ((const ScPaintHint&)rHint).GetPrintFlag() ) + { + USHORT nParts = ((const ScPaintHint&)rHint).GetParts(); + if (nParts & ( PAINT_GRID | PAINT_LEFT | PAINT_TOP | PAINT_SIZE )) + bDataChanged = TRUE; + } + } + else if (rHint.ISA(SdrHint)) + { + if (((const SdrHint&)rHint).IsNeedRepaint()) + bDataChanged = TRUE; + } + + if (bDataChanged) + pPreview->DataChanged(TRUE); +} + + + + + diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx new file mode 100644 index 000000000000..55001cacb351 --- /dev/null +++ b/sc/source/ui/view/printfun.cxx @@ -0,0 +1,2721 @@ +/************************************************************************* + * + * $RCSfile: printfun.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <svx/svxids.hrc> +#include <svx/adjitem.hxx> +#include <svx/boxitem.hxx> +#include <svx/brshitem.hxx> +#include <svx/editstat.hxx> // EE_CNTRL_RTFSTYLESHEETS +#include <svx/fmview.hxx> +#include <svx/lrspitem.hxx> +#include <svx/paperinf.hxx> +#include <svx/pbinitem.hxx> +#include <svx/shaditem.hxx> +#include <svx/sizeitem.hxx> +#include <svx/svdpagv.hxx> +#include <svx/ulspitem.hxx> +#include <sfx2/app.hxx> +#include <sfx2/printer.hxx> +#include <sfx2/progress.hxx> +#include <tools/multisel.hxx> +#ifndef _SFXDOCFILE_HXX //autogen +#include <sfx2/docfile.hxx> +#endif +#ifndef _URLOBJ_HXX //autogen +#include <tools/urlobj.hxx> +#endif + +#ifdef MAC +#define RGBColor MAC_RGBColor +#include <svx/xoutbmp.hxx> +#undef RGBColor +#else +#include <svx/xoutbmp.hxx> +#endif + + +//#if defined( WIN ) || defined( WNT ) +//#include <svwin.h> +//#endif + + +#include "editutil.hxx" +#include "docsh.hxx" +#include "output.hxx" +#include "viewdata.hxx" +#include "viewopti.hxx" +#include "stlpool.hxx" +#include "pagepar.hxx" +#include "attrib.hxx" +#include "patattr.hxx" +#include "docpool.hxx" +#include "dociter.hxx" +#include "cell.hxx" +#include "drawutil.hxx" +#include "globstr.hrc" +#include "scresid.hxx" +#include "sc.hrc" +#include "pagedata.hxx" + +#define _PRINTFUN_CXX +#include "printfun.hxx" + + + +#define ZOOM_MIN 10 + +#define GET_BOOL(set,which) ((const SfxBoolItem&)(set)->Get((which))).GetValue() +#define GET_USHORT(set,which) ((const SfxUInt16Item&)(set)->Get((which))).GetValue() +#define GET_SHOW(set,which) ( VOBJ_MODE_SHOW == ScVObjMode( ((const ScViewObjectModeItem&)(set)->Get((which))).GetValue()) ) + +//------------------------------------------------------------------------ + +ScPageRowEntry::ScPageRowEntry(const ScPageRowEntry& r) +{ + nStartRow = r.nStartRow; + nEndRow = r.nEndRow; + nPagesX = r.nPagesX; + if (r.pHidden && nPagesX) + { + pHidden = new BOOL[nPagesX]; + memcpy( pHidden, r.pHidden, nPagesX * sizeof(BOOL) ); + } + else + pHidden = NULL; +} + +const ScPageRowEntry& ScPageRowEntry::operator=(const ScPageRowEntry& r) +{ + delete[] pHidden; + + nStartRow = r.nStartRow; + nEndRow = r.nEndRow; + nPagesX = r.nPagesX; + if (r.pHidden && nPagesX) + { + pHidden = new BOOL[nPagesX]; + memcpy( pHidden, r.pHidden, nPagesX * sizeof(BOOL) ); + } + else + pHidden = NULL; + + return *this; +} + +void ScPageRowEntry::SetPagesX(USHORT nNew) +{ + if (pHidden) + { + DBG_ERROR("SetPagesX nicht nach SetHidden"); + delete[] pHidden; + pHidden = NULL; + } + nPagesX = nNew; +} + +void ScPageRowEntry::SetHidden(USHORT nX) +{ + if ( nX < nPagesX ) + { + if ( nX+1 == nPagesX ) // letzte Seite? + --nPagesX; + else + { + if (!pHidden) + { + pHidden = new BOOL[nPagesX]; + memset( pHidden, FALSE, nPagesX * sizeof(BOOL) ); + } + pHidden[nX] = TRUE; + } + } +} + +BOOL ScPageRowEntry::IsHidden(USHORT nX) const +{ + return nX>=nPagesX || ( pHidden && pHidden[nX] ); //! inline? +} + +USHORT ScPageRowEntry::CountVisible() const +{ + if ( pHidden ) + { + USHORT nVis = 0; + for (USHORT i=0; i<nPagesX; i++) + if (!pHidden[i]) + ++nVis; + return nVis; + } + else + return nPagesX; +} + +//------------------------------------------------------------------------ + +long lcl_LineTotal(const SvxBorderLine* pLine) +{ + return pLine ? ( pLine->GetOutWidth() + pLine->GetInWidth() + pLine->GetDistance() ) : 0; +} + +void ScPrintFunc::Construct() +{ + pDoc = pDocShell->GetDocument(); + + SfxPrinter* pDocPrinter = pDoc->GetPrinter(); // auch fuer Preview den Drucker nehmen + if (pDocPrinter) + aOldPrinterMode = pDocPrinter->GetMapMode(); + + // einheitlicher MapMode ueber alle Aufrufe (z.B. Repaint !!!), + // weil die EditEngine sonst unterschiedliche Texthoehen liefert + pDev->SetMapMode(MAP_PIXEL); + + pPageEndX = NULL; + pPageEndY = NULL; + pPageRows = NULL; + pBorderItem = NULL; + pBackgroundItem = NULL; + pShadowItem = NULL; + + pEditEngine = NULL; + pEditDefaults = NULL; + + ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool(); + SfxStyleSheetBase* pStyleSheet = pStylePool->Find( + pDoc->GetPageStyle( nPrintTab ), + SFX_STYLE_FAMILY_PAGE ); + if (pStyleSheet) + pParamSet = &pStyleSheet->GetItemSet(); + else + { + DBG_ERROR("Seitenvorlage nicht gefunden" ); + pParamSet = NULL; + } + + if (!bState) + nZoom = 100; + nManualZoom = 100; + bClearWin = FALSE; + + InitParam(); + + pPageData = NULL; // wird nur zur Initialisierung gebraucht +} + +ScPrintFunc::ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, USHORT nTab, + long nPage, long nDocP, const ScRange* pArea, + ScPageBreakData* pData ) + : pDocShell ( pShell ), + pPrinter ( pNewPrinter ), + pDrawView ( NULL ), + nPrintTab ( nTab ), + nPageStart ( nPage ), + nDocPages ( nDocP ), + pUserArea ( pArea ), + pPageData ( pData ), + nTotalPages ( 0 ), + nTabPages ( 0 ), + bState ( FALSE ), + bPrintCurrentTable ( FALSE ), + bMultiArea ( FALSE ) +{ + pDev = pPrinter; + aSrcOffset = pPrinter->PixelToLogic( pPrinter->GetPageOffsetPixel(), MAP_100TH_MM ); + Construct(); +} + +ScPrintFunc::ScPrintFunc( ScDocShell* pShell, Window* pWindow, USHORT nTab, + long nPage, long nDocP, const ScRange* pArea ) + : pDocShell ( pShell ), + pPrinter ( NULL ), + pDrawView ( NULL ), + nPrintTab ( nTab ), + nPageStart ( nPage ), + nDocPages ( nDocP ), + pUserArea ( pArea ), + pPageData ( NULL ), + nTotalPages ( 0 ), + nTabPages ( 0 ), + bState ( FALSE ), + bPrintCurrentTable ( FALSE ), + bMultiArea ( FALSE ) +{ + pDev = pWindow; + Construct(); +} + +ScPrintFunc::ScPrintFunc( ScDocShell* pShell, Window* pWindow, + const ScPrintState& rState ) + : pDocShell ( pShell ), + pPrinter ( NULL ), + pDrawView ( NULL ), + pUserArea ( NULL ), + pPageData ( NULL ), + bPrintCurrentTable ( FALSE ), + bMultiArea ( FALSE ) +{ + pDev = pWindow; + + nPrintTab = rState.nPrintTab; + nStartCol = rState.nStartCol; + nStartRow = rState.nStartRow; + nEndCol = rState.nEndCol; + nEndRow = rState.nEndRow; + nZoom = rState.nZoom; + nPagesX = rState.nPagesX; + nPagesY = rState.nPagesY; + nTabPages = rState.nTabPages; + nTotalPages = rState.nTotalPages; + nPageStart = rState.nPageStart; + nDocPages = rState.nDocPages; + bState = TRUE; + + Construct(); +} + +void ScPrintFunc::GetPrintState( ScPrintState& rState ) +{ + rState.nPrintTab = nPrintTab; + rState.nStartCol = nStartCol; + rState.nStartRow = nStartRow; + rState.nEndCol = nEndCol; + rState.nEndRow = nEndRow; + rState.nZoom = nZoom; + rState.nPagesX = nPagesX; + rState.nPagesY = nPagesY; + rState.nTabPages = nTabPages; + rState.nTotalPages = nTotalPages; + rState.nPageStart = nPageStart; + rState.nDocPages = nDocPages; +} + +void ScPrintFunc::FillPageData() +{ + if (pPageData) + { + USHORT nCount = pPageData->GetCount(); + ScPrintRangeData& rData = pPageData->GetData(nCount); // hochzaehlen + + rData.SetPrintRange( ScRange( nStartCol, nStartRow, nPrintTab, + nEndCol, nEndRow, nPrintTab ) ); + rData.SetPagesX( nPagesX, pPageEndX ); + rData.SetPagesY( nTotalY, pPageEndY ); + + // Einstellungen + rData.SetTopDown( aTableParam.bTopDown ); + rData.SetAutomatic( !aAreaParam.bPrintArea ); + } +} + +ScPrintFunc::~ScPrintFunc() +{ + ScTripel* pTripel = (ScTripel*) aNotePosList.First(); + while (pTripel) + { + delete pTripel; + pTripel = (ScTripel*) aNotePosList.Next(); + } + aNotePosList.Clear(); + + delete[] pPageEndX; + delete[] pPageEndY; + delete[] pPageRows; + delete pEditDefaults; + delete pEditEngine; + + // Druckereinstellungen werden jetzt von aussen wiederhergestellt + + // #64294# Fuer DrawingLayer/Charts muss der MapMode am Drucker (RefDevice) immer stimmen + SfxPrinter* pDocPrinter = pDoc->GetPrinter(); // auch fuer Preview den Drucker nehmen + if (pDocPrinter) + pDocPrinter->SetMapMode(aOldPrinterMode); +} + +void ScPrintFunc::SetDrawView( FmFormView* pNew ) +{ + pDrawView = pNew; +} + +// +// Ausgabe auf Device (static) +// +// wird benutzt fuer: +// - Clipboard/Bitmap +// - Ole-Object (DocShell::Draw) +// - Vorschau bei Vorlagen + +void ScPrintFunc::DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double nPrintFactor, + const Rectangle& rBound, ScViewData* pViewData, BOOL bMetaFile ) +{ + //! nPrintFactor auswerten !!! + + USHORT nTab = 0; + if (pViewData) + nTab = pViewData->GetTabNo(); + + BOOL bDoGrid, bNullVal, bFormula; + ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool(); + SfxStyleSheetBase* pStyleSheet = pStylePool->Find( pDoc->GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE ); + if (pStyleSheet) + { + SfxItemSet& rSet = pStyleSheet->GetItemSet(); + bDoGrid = ((const SfxBoolItem&)rSet.Get(ATTR_PAGE_GRID)).GetValue(); + bNullVal = ((const SfxBoolItem&)rSet.Get(ATTR_PAGE_NULLVALS)).GetValue(); + bFormula = ((const SfxBoolItem&)rSet.Get(ATTR_PAGE_FORMULAS)).GetValue(); + } + else + { + const ScViewOptions& rOpt = pDoc->GetViewOptions(); + bDoGrid = rOpt.GetOption(VOPT_GRID); + bNullVal = rOpt.GetOption(VOPT_NULLVALS); + bFormula = rOpt.GetOption(VOPT_FORMULAS); + } + + MapMode aMode = pDev->GetMapMode(); + + Rectangle aRect = rBound; + + if (aRect.Right() < aRect.Left() || aRect.Bottom() < aRect.Top()) + aRect = Rectangle( Point(), pDev->GetOutputSize() ); + + USHORT nX1 = 0; + USHORT nY1 = 0; + USHORT nX2 = OLE_STD_CELLS_X - 1; + USHORT nY2 = OLE_STD_CELLS_Y - 1; + if (bMetaFile) + { + ScRange aRange = pDoc->GetRange( nTab, rBound ); + nX1 = aRange.aStart.Col(); + nY1 = aRange.aStart.Row(); + nX2 = aRange.aEnd.Col(); + nY2 = aRange.aEnd.Row(); + } + else if (pViewData) + { + ScSplitPos eWhich = pViewData->GetActivePart(); + ScHSplitPos eHWhich = WhichH(eWhich); + ScVSplitPos eVWhich = WhichV(eWhich); + nX1 = pViewData->GetPosX(eHWhich); + nY1 = pViewData->GetPosY(eVWhich); + nX2 = nX1 + pViewData->VisibleCellsX(eHWhich); + if (nX2>nX1) --nX2; + nY2 = nY1 + pViewData->VisibleCellsY(eVWhich); + if (nY2>nY1) --nY2; + } + + if (nX1 > MAXCOL) nX1 = MAXCOL; + if (nX2 > MAXCOL) nX2 = MAXCOL; + if (nY1 > MAXROW) nY1 = MAXROW; + if (nY2 > MAXROW) nY2 = MAXROW; + + USHORT i; + long nDevSizeX = aRect.Right()-aRect.Left()+1; + long nDevSizeY = aRect.Bottom()-aRect.Top()+1; + + Rectangle aLines; + ScRange aRange( nX1,nY1,nTab, nX2,nY2,nTab ); + BOOL bAddLines = pDoc->HasLines( aRange, aLines ); + + long nTwipsSizeX = 0; + for (i=nX1; i<=nX2; i++) + nTwipsSizeX += pDoc->GetColWidth( i, nTab ); + long nTwipsSizeY = 0; + for (i=nY1; i<=nY2; i++) + nTwipsSizeY += pDoc->GetRowHeight( i, nTab ); + + // wenn keine Linien, dann trotzdem Platz fuer den Aussenrahmen (20 Twips = 1pt) + // (HasLines initalisiert aLines auf 0,0,0,0) + nTwipsSizeX += aLines.Left() + Max( aLines.Right(), 20L ); + nTwipsSizeY += aLines.Top() + Max( aLines.Bottom(), 20L ); + + double nScaleX = (double) nDevSizeX / nTwipsSizeX; + double nScaleY = (double) nDevSizeY / nTwipsSizeY; + + //! Flag bei FillInfo uebergeben !!!!! + ScTripel aEStart; + ScTripel aEEnd; + BOOL bEmbed = pDoc->IsEmbedded(); + if (bEmbed) + { + pDoc->GetEmbedded(aEStart,aEEnd); + pDoc->ResetEmbedded(); + } + + // Daten zusammenstellen + + RowInfo* pRowInfo = new RowInfo[ROWINFO_MAX]; + USHORT nArrCount = pDoc->FillInfo( pRowInfo, nX1, nY1, nX2, nY2, nTab, + nScaleX, nScaleY, FALSE, bFormula ); + + if (bEmbed) + pDoc->SetEmbedded(aEStart,aEEnd); + +/* if (!bMetaFile) + pDev->SetMapMode(MAP_PIXEL); +*/ + long nScrX = aRect.Left(); + long nScrY = aRect.Top(); + + // Wenn keine Linien, trotzdem Platz fuer Gitterlinien lassen + // (werden sonst abgeschnitten) + long nAddX = (long)( aLines.Left() * nScaleX ); + nScrX += ( nAddX ? nAddX : 1 ); + long nAddY = (long)( aLines.Top() * nScaleY ); + nScrY += ( nAddY ? nAddY : 1 ); + + ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, pRowInfo, nArrCount, pDoc, nTab, + nScrX, nScrY, nX1, nY1, nX2, nY2, nScaleX, nScaleY ); + aOutputData.SetMetaFileMode(bMetaFile); + aOutputData.SetShowNullValues(bNullVal); + aOutputData.SetShowFormulas(bFormula); + + if ( bMetaFile && pDev->GetOutDevType() == OUTDEV_VIRDEV ) + aOutputData.SetSnapPixel(); + + Point aLogStart = pDev->PixelToLogic( Point(nScrX,nScrY), MAP_100TH_MM ); + long nLogStX = aLogStart.X(); + long nLogStY = aLogStart.Y(); + + //! nZoom fuer GetFont in OutputData ??? + + if (!bMetaFile && pViewData) + pDev->SetMapMode(pViewData->GetLogicMode(pViewData->GetActivePart())); + aOutputData.DrawingLayer(SC_LAYER_BACK,SC_OBJECTS_ALL,nLogStX,nLogStY); + if (!bMetaFile && pViewData) + pDev->SetMapMode(aMode); + + aOutputData.DrawBackground(); + +#ifdef OS2 + if (bMetaFile && !bDoGrid) + { + // unter OS2 fuer Metafiles gesamte Flaeche benutzen, + // weil sonst die Groesse nicht erkannt wird + pDev->SetLineColor(); + pDev->SetFillColor(); + pDev->DrawRect( Rectangle( nScrX,nScrY, + nScrX+aOutputData.GetScrW(), nScrY+aOutputData.GetScrH() ) ); + } +#endif + + aOutputData.DrawShadow(); + aOutputData.DrawFrame(); + aOutputData.DrawStrings(); + + if (!bMetaFile && pViewData) + pDev->SetMapMode(pViewData->GetLogicMode(pViewData->GetActivePart())); + + aOutputData.DrawEdit(!bMetaFile); + + if (bDoGrid) + { + if (!bMetaFile && pViewData) + pDev->SetMapMode(aMode); + + aOutputData.DrawGrid( TRUE, FALSE ); // keine Seitenumbrueche + + pDev->SetLineColor( COL_BLACK ); + + Size aOne = pDev->PixelToLogic( Size(1,1) ); + if (bMetaFile) + aOne = Size(1,1); // kompatibel zu DrawGrid + pDev->DrawLine( Point(nScrX,nScrY), Point(nScrX,nScrY+aOutputData.GetScrH()-aOne.Width() ) ); + pDev->DrawLine( Point(nScrX,nScrY), Point(nScrX+aOutputData.GetScrW()-aOne.Height(),nScrY ) ); + } + + aOutputData.DrawingLayer(SC_LAYER_FRONT,SC_OBJECTS_ALL,nLogStX,nLogStY); + aOutputData.DrawingLayer(SC_LAYER_INTERN,SC_OBJECTS_ALL,nLogStX,nLogStY); + + for (i=0; i<nArrCount; i++) + delete[] pRowInfo[i].pCellInfo; + delete[] pRowInfo; +} + +// +// Drucken +// + +void lcl_FillHFParam( ScPrintHFParam& rParam, const SfxItemSet* pHFSet ) +{ + // nDistance muss vorher unterschiedlich initalisiert sein + + if ( pHFSet == NULL ) + { + rParam.bEnable = FALSE; + rParam.pBorder = NULL; + rParam.pBack = NULL; + rParam.pShadow = NULL; + } + else + { + rParam.bEnable = ((const SfxBoolItem&) pHFSet->Get(ATTR_PAGE_ON)).GetValue(); + rParam.bDynamic = ((const SfxBoolItem&) pHFSet->Get(ATTR_PAGE_DYNAMIC)).GetValue(); + rParam.bShared = ((const SfxBoolItem&) pHFSet->Get(ATTR_PAGE_SHARED)).GetValue(); + rParam.nHeight = ((const SvxSizeItem&) pHFSet->Get(ATTR_PAGE_SIZE)).GetSize().Height(); + const SvxLRSpaceItem* pHFLR = &(const SvxLRSpaceItem&) pHFSet->Get(ATTR_LRSPACE); + long nTmp; + nTmp = pHFLR->GetLeft(); + rParam.nLeft = nTmp < 0 ? 0 : USHORT(nTmp); + nTmp = pHFLR->GetRight(); + rParam.nRight = nTmp < 0 ? 0 : USHORT(nTmp); + rParam.pBorder = (const SvxBoxItem*) &pHFSet->Get(ATTR_BORDER); + rParam.pBack = (const SvxBrushItem*) &pHFSet->Get(ATTR_BACKGROUND); + rParam.pShadow = (const SvxShadowItem*)&pHFSet->Get(ATTR_SHADOW);; + +// jetzt doch wieder schon im Dialog: +// rParam.nHeight += rParam.nDistance; // nicht mehr im Dialog ??? + + if (rParam.pBorder) + rParam.nHeight += lcl_LineTotal( rParam.pBorder->GetTop() ) + + lcl_LineTotal( rParam.pBorder->GetBottom() ); + + rParam.nManHeight = rParam.nHeight; + } + + if (!rParam.bEnable) + rParam.nHeight = 0; +} + +// bNew = TRUE: benutzten Bereich aus dem Dokument suchen +// bNew = FALSE: nur ganze Zeilen/Spalten begrenzen + +BOOL ScPrintFunc::AdjustPrintArea( BOOL bNew ) +{ + USHORT nOldEndCol = nEndCol; // nur wichtig bei !bNew + USHORT nOldEndRow = nEndRow; + BOOL bChangeCol = TRUE; // bei bNew werden beide angepasst + BOOL bChangeRow = TRUE; + + BOOL bNotes = aTableParam.bNotes; + if ( bNew ) + { + nStartCol = nStartRow = 0; + if (!pDoc->GetPrintArea( nPrintTab, nEndCol, nEndRow, bNotes )) + return FALSE; // nix + } + else + { + BOOL bFound = TRUE; + bChangeCol = ( nStartCol == 0 && nEndCol == MAXCOL ); + bChangeRow = ( nStartRow == 0 && nEndRow == MAXROW ); + if ( bChangeCol && bChangeRow ) + bFound = pDoc->GetPrintArea( nPrintTab, nEndCol, nEndRow, bNotes ); + else if ( bChangeCol ) + bFound = pDoc->GetPrintAreaHor( nPrintTab, nStartRow, nEndRow, nEndCol, bNotes ); + else if ( bChangeRow ) + bFound = pDoc->GetPrintAreaVer( nPrintTab, nStartCol, nEndCol, nEndRow, bNotes ); + + if (!bFound) + return FALSE; // leer + } + + pDoc->ExtendMerge( nStartCol,nStartRow, nEndCol,nEndRow, nPrintTab, + FALSE, TRUE ); // kein Refresh, incl. Attrs + + if ( bChangeCol ) + { + OutputDevice* pRefDev = pDoc->GetPrinter(); // auch fuer Preview den Drucker nehmen + pRefDev->SetMapMode( MAP_PIXEL ); // wichtig fuer GetNeededSize + + pDoc->ExtendPrintArea( pRefDev, + nPrintTab, nStartCol, nStartRow, nEndCol, nEndRow ); + // nEndCol wird veraendert + } + + if ( nEndCol < MAXCOL && pDoc->HasAttrib( + nEndCol,nStartRow,nPrintTab, nEndCol,nEndRow,nPrintTab, HASATTR_SHADOW_RIGHT ) ) + ++nEndCol; + if ( nEndRow < MAXROW && pDoc->HasAttrib( + nStartCol,nEndRow,nPrintTab, nEndCol,nEndRow,nPrintTab, HASATTR_SHADOW_DOWN ) ) + ++nEndRow; + + if (!bChangeCol) nEndCol = nOldEndCol; + if (!bChangeRow) nEndRow = nOldEndRow; + + return TRUE; +} + +long ScPrintFunc::TextHeight( const EditTextObject* pObject ) +{ + if (!pObject) + return 0; + +// pEditEngine->SetPageNo( nTotalPages ); + pEditEngine->SetText( *pObject ); + + return (long) pEditEngine->GetTextHeight(); +} + +// nZoom muss gesetzt sein !!! +// und der entsprechende Twip-MapMode eingestellt + +void ScPrintFunc::UpdateHFHeight( ScPrintHFParam& rParam ) +{ + DBG_ASSERT( aPageSize.Width(), "UpdateHFHeight ohne aPageSize"); + + if (rParam.bEnable && rParam.bDynamic) + { + // nHeight aus Inhalten berechnen + + MakeEditEngine(); + long nPaperWidth = ( aPageSize.Width() - nLeftMargin - nRightMargin - + rParam.nLeft - rParam.nRight ) * 100 / nZoom; + if (rParam.pBorder) + nPaperWidth -= ( 2*rParam.pBorder->GetDistance() + + lcl_LineTotal(rParam.pBorder->GetLeft()) + + lcl_LineTotal(rParam.pBorder->GetRight()) ) * 100 / nZoom; + + if (rParam.pShadow && rParam.pShadow->GetLocation() != SVX_SHADOW_NONE) + nPaperWidth -= ( rParam.pShadow->CalcShadowSpace(SHADOW_LEFT) + + rParam.pShadow->CalcShadowSpace(SHADOW_RIGHT) ) * 100L / nZoom; + + pEditEngine->SetPaperSize( Size( nPaperWidth, 10000 ) ); + + long nMaxHeight = 0; + if ( rParam.pLeft ) + { + nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pLeft->GetLeftArea() ) ); + nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pLeft->GetCenterArea() ) ); + nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pLeft->GetRightArea() ) ); + } + if ( rParam.pRight ) + { + nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pRight->GetLeftArea() ) ); + nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pRight->GetCenterArea() ) ); + nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pRight->GetRightArea() ) ); + } + + rParam.nHeight = nMaxHeight + rParam.nDistance; + if (rParam.pBorder) + rParam.nHeight += 2*rParam.pBorder->GetDistance() + + lcl_LineTotal( rParam.pBorder->GetTop() ) + + lcl_LineTotal( rParam.pBorder->GetBottom() ); + if (rParam.pShadow && rParam.pShadow->GetLocation() != SVX_SHADOW_NONE) + rParam.nHeight += rParam.pShadow->CalcShadowSpace(SHADOW_TOP) + + rParam.pShadow->CalcShadowSpace(SHADOW_BOTTOM); + + if (rParam.nHeight < rParam.nManHeight) + rParam.nHeight = rParam.nManHeight; // eingestelltes Minimum + } +} + +void ScPrintFunc::InitParam() +{ + if (!pParamSet) + return; + + // TabPage "Seite" + const SvxLRSpaceItem* pLRItem = (const SvxLRSpaceItem*) &pParamSet->Get( ATTR_LRSPACE ); + long nTmp; + nTmp = pLRItem->GetLeft(); + nLeftMargin = nTmp < 0 ? 0 : USHORT(nTmp); + nTmp = pLRItem->GetRight(); + nRightMargin = nTmp < 0 ? 0 : USHORT(nTmp); + const SvxULSpaceItem* pULItem = (const SvxULSpaceItem*) &pParamSet->Get( ATTR_ULSPACE ); + nTopMargin = pULItem->GetUpper(); + nBottomMargin = pULItem->GetLower(); + + const SvxPageItem* pPageItem = (const SvxPageItem*) &pParamSet->Get( ATTR_PAGE ); + nPageUsage = pPageItem->GetPageUsage(); + bLandscape = pPageItem->IsLandscape(); + aFieldData.eNumType = pPageItem->GetNumType(); + + bCenterHor = ((const SfxBoolItem&) pParamSet->Get(ATTR_PAGE_HORCENTER)).GetValue(); + bCenterVer = ((const SfxBoolItem&) pParamSet->Get(ATTR_PAGE_VERCENTER)).GetValue(); + + aPageSize = ((const SvxSizeItem&) pParamSet->Get(ATTR_PAGE_SIZE)).GetSize(); + if ( !aPageSize.Width() || !aPageSize.Height() ) + { + DBG_ERROR("PageSize Null ?!?!?"); + aPageSize = SvxPaperInfo::GetPaperSize( SVX_PAPER_A4 ); + } + + pBorderItem = (const SvxBoxItem*) &pParamSet->Get(ATTR_BORDER); + pBackgroundItem = (const SvxBrushItem*) &pParamSet->Get(ATTR_BACKGROUND); + pShadowItem = (const SvxShadowItem*) &pParamSet->Get(ATTR_SHADOW); + + // TabPage "Kopfzeile" + + aHdr.pLeft = (const ScPageHFItem*) &pParamSet->Get(ATTR_PAGE_HEADERLEFT); // Inhalt + aHdr.pRight = (const ScPageHFItem*) &pParamSet->Get(ATTR_PAGE_HEADERRIGHT); + + const SvxSetItem* pHeaderSetItem; + const SfxItemSet* pHeaderSet = NULL; + if ( pParamSet->GetItemState( ATTR_PAGE_HEADERSET, FALSE, + (const SfxPoolItem**)&pHeaderSetItem ) == SFX_ITEM_SET ) + { + pHeaderSet = &pHeaderSetItem->GetItemSet(); + // Kopfzeile hat unteren Abstand + aHdr.nDistance = ((const SvxULSpaceItem&) pHeaderSet->Get(ATTR_ULSPACE)).GetLower(); + } + lcl_FillHFParam( aHdr, pHeaderSet ); + + // TabPage "Fusszeile" + + aFtr.pLeft = (const ScPageHFItem*) &pParamSet->Get(ATTR_PAGE_FOOTERLEFT); // Inhalt + aFtr.pRight = (const ScPageHFItem*) &pParamSet->Get(ATTR_PAGE_FOOTERRIGHT); + + const SvxSetItem* pFooterSetItem; + const SfxItemSet* pFooterSet = NULL; + if ( pParamSet->GetItemState( ATTR_PAGE_FOOTERSET, FALSE, + (const SfxPoolItem**)&pFooterSetItem ) == SFX_ITEM_SET ) + { + pFooterSet = &pFooterSetItem->GetItemSet(); + // Fusszeile hat oberen Abstand + aFtr.nDistance = ((const SvxULSpaceItem&) pFooterSet->Get(ATTR_ULSPACE)).GetUpper(); + } + lcl_FillHFParam( aFtr, pFooterSet ); + + //------------------------------------------------------ + // Table-/Area-Params aus einzelnen Items zusammenbauen: + //------------------------------------------------------ + // TabPage "Tabelle" + + const SfxUInt16Item* pScaleItem = NULL; + const SfxUInt16Item* pScaleToPagesItem = NULL; + SfxItemState eState; + + eState = pParamSet->GetItemState( ATTR_PAGE_SCALE, FALSE, + (const SfxPoolItem**)&pScaleItem ); + if ( SFX_ITEM_DEFAULT == eState ) + pScaleItem = (const SfxUInt16Item*) + &pParamSet->GetPool()-> + GetDefaultItem( ATTR_PAGE_SCALE ); + + eState = pParamSet->GetItemState( ATTR_PAGE_SCALETOPAGES, FALSE, + (const SfxPoolItem**)&pScaleToPagesItem ); + if ( SFX_ITEM_DEFAULT == eState ) + pScaleToPagesItem = (const SfxUInt16Item*) + &pParamSet->GetPool()-> + GetDefaultItem( ATTR_PAGE_SCALETOPAGES ); + + DBG_ASSERT( pScaleItem && pScaleToPagesItem, "Missing ScaleItem! :-/" ); + + aTableParam.bNotes = GET_BOOL(pParamSet,ATTR_PAGE_NOTES); + aTableParam.bGrid = GET_BOOL(pParamSet,ATTR_PAGE_GRID); + aTableParam.bHeaders = GET_BOOL(pParamSet,ATTR_PAGE_HEADERS); + aTableParam.bFormulas = GET_BOOL(pParamSet,ATTR_PAGE_FORMULAS); + aTableParam.bNullVals = GET_BOOL(pParamSet,ATTR_PAGE_NULLVALS); + aTableParam.bCharts = GET_SHOW(pParamSet,ATTR_PAGE_CHARTS); + aTableParam.bObjects = GET_SHOW(pParamSet,ATTR_PAGE_OBJECTS); + aTableParam.bDrawings = GET_SHOW(pParamSet,ATTR_PAGE_DRAWINGS); + aTableParam.bTopDown = GET_BOOL(pParamSet,ATTR_PAGE_TOPDOWN); + aTableParam.bLeftRight = !aTableParam.bLeftRight; + aTableParam.nFirstPageNo = GET_USHORT(pParamSet,ATTR_PAGE_FIRSTPAGENO); + if (!aTableParam.nFirstPageNo) + aTableParam.nFirstPageNo = (USHORT) nPageStart; // von vorheriger Tabelle + + if ( pScaleItem && pScaleToPagesItem ) + { + UINT16 nScaleAll = pScaleItem->GetValue(); + UINT16 nScaleToPages = pScaleToPagesItem->GetValue(); + + aTableParam.bScaleNone = (nScaleAll == 100); + aTableParam.bScaleAll = (nScaleAll > 0 ); + aTableParam.bScalePageNum = (nScaleToPages > 0 ); + aTableParam.nScaleAll = nScaleAll; + aTableParam.nScalePageNum = nScaleToPages; + } + else + { + aTableParam.bScaleNone = TRUE; + aTableParam.bScaleAll = FALSE; + aTableParam.bScalePageNum = FALSE; + aTableParam.nScaleAll = 0; + aTableParam.nScalePageNum = 0; + } + + aTableParam.bSkipEmpty = FALSE; //! aus Seitenvorlage !!!!!!!! +// aTableParam.bSkipEmpty = TRUE; //! Test !!!!!!!!!!!!!!!! + if ( pPageData ) + aTableParam.bSkipEmpty = FALSE; + // Wenn pPageData gesetzt ist, interessieren fuer die Umbruch-Vorschau + // nur die Umbrueche, leere Seiten werden nicht speziell behandelt + + //------------------------------------------------------ + // TabPage "Bereiche": + //------------------------------------------------------ + + //! alle PrintAreas der Tabelle durchgehen !!! + const ScRange* pPrintArea = pDoc->GetPrintRange( nPrintTab, 0 ); + const ScRange* pRepeatCol = pDoc->GetRepeatColRange( nPrintTab ); + const ScRange* pRepeatRow = pDoc->GetRepeatRowRange( nPrintTab ); + + // ATTR_PAGE_PRINTTABLES wird ignoriert + + if ( pUserArea ) // UserArea (Selektion) hat Vorrang + { + bPrintCurrentTable = + aAreaParam.bPrintArea = TRUE; // Selektion + aAreaParam.aPrintArea = *pUserArea; + + // Die Tabellen-Abfrage ist schon in DocShell::Print, hier immer + aAreaParam.aPrintArea.aStart.SetTab(nPrintTab); + aAreaParam.aPrintArea.aEnd.SetTab(nPrintTab); + +// lcl_LimitRange( aAreaParam.aPrintArea, nPrintTab ); // ganze Zeilen/Spalten... + } + else if ( pDoc->HasPrintRange() ) + { + if ( pPrintArea ) // mindestens eine gesetzt ? + { + bPrintCurrentTable = + aAreaParam.bPrintArea = TRUE; + aAreaParam.aPrintArea = *pPrintArea; + + bMultiArea = ( pDoc->GetPrintRangeCount(nPrintTab) > 1 ); + } + else + { + aAreaParam.bPrintArea = TRUE; + bPrintCurrentTable = FALSE; + } + } + else + { + // #74834# don't print hidden tables if there's no print range defined there + if ( pDoc->IsVisible( nPrintTab ) ) + { + aAreaParam.bPrintArea = FALSE; + bPrintCurrentTable = TRUE; + } + else + { + aAreaParam.bPrintArea = TRUE; // otherwise the table is always counted + bPrintCurrentTable = FALSE; + } + } + + if ( pRepeatCol ) + { + aAreaParam.bRepeatCol = TRUE; + aAreaParam.aRepeatCol = *pRepeatCol; + nRepeatStartCol = pRepeatCol->aStart.Col(); + nRepeatEndCol = pRepeatCol->aEnd .Col(); + } + else + { + aAreaParam.bRepeatCol = FALSE; + nRepeatStartCol = nRepeatEndCol = REPEAT_NONE; + } + + if ( pRepeatRow ) + { + aAreaParam.bRepeatRow = TRUE; + aAreaParam.aRepeatRow = *pRepeatRow; + nRepeatStartRow = pRepeatRow->aStart.Row(); + nRepeatEndRow = pRepeatRow->aEnd .Row(); + } + else + { + aAreaParam.bRepeatRow = FALSE; + nRepeatStartRow = nRepeatEndRow = REPEAT_NONE; + } + + // + // Seiten aufteilen + // + + if (!bState) + { + nTabPages = CountPages(); // berechnet auch Zoom + nTotalPages = nTabPages; + nTotalPages += CountNotePages(); + } + else + { + CalcPages(); // nur Umbrueche suchen + CountNotePages(); // Notizen zaehlen, auch wenn Seitenzahl schon bekannt + } + + if (nDocPages) + aFieldData.nTotalPages = nDocPages; + else + aFieldData.nTotalPages = nTotalPages; + + SetDateTime( Date(), Time() ); + + aFieldData.aTitle = pDocShell->GetTitle(); + aFieldData.aLongDocName = pDocShell->GetMedium()->GetName(); + if ( !aFieldData.aLongDocName.Len() ) + aFieldData.aLongDocName = aFieldData.aTitle; + aFieldData.aShortDocName= INetURLObject( aFieldData.aLongDocName ).GetName(); + + // Druckereinstellungen (Orientation, Paper) jetzt erst bei DoPrint +} + +Size ScPrintFunc::GetDataSize() const +{ + Size aSize = aPageSize; + aSize.Width() -= nLeftMargin + nRightMargin; + aSize.Height() -= nTopMargin + nBottomMargin; + aSize.Height() -= aHdr.nHeight + aFtr.nHeight; + return aSize; +} + +void ScPrintFunc::GetScaleData( Size& rPhysSize, long& rDocHdr, long& rDocFtr ) +{ + rPhysSize = aPageSize; + rPhysSize.Width() -= nLeftMargin + nRightMargin; + rPhysSize.Height() -= nTopMargin + nBottomMargin; + + rDocHdr = aHdr.nHeight; + rDocFtr = aFtr.nHeight; +} + +void ScPrintFunc::SetDateTime( const Date& rDate, const Time& rTime ) +{ + aFieldData.aDate = rDate; + aFieldData.aTime = rTime; +} + +void lcl_DrawGraphic( const Graphic &rGraphic, OutputDevice *pOut, + const Rectangle &rGrf, const Rectangle &rOut ) +{ + const FASTBOOL bNotInside = !rOut.IsInside( rGrf ); + if ( bNotInside ) + { + pOut->Push(); + pOut->IntersectClipRegion( rOut ); + } + + ((Graphic&)rGraphic).Draw( pOut, rGrf.TopLeft(), rGrf.GetSize() ); + + if ( bNotInside ) + pOut->Pop(); +} + +void lcl_DrawGraphic( const Bitmap& rBitmap, OutputDevice *pOut, + const Rectangle &rGrf, const Rectangle &rOut ) +{ + const FASTBOOL bNotInside = !rOut.IsInside( rGrf ); + if ( bNotInside ) + { + pOut->Push(); + pOut->IntersectClipRegion( rOut ); + } + + pOut->DrawBitmap( rGrf.TopLeft(), rGrf.GetSize(), rBitmap ); + + if ( bNotInside ) + pOut->Pop(); +} + +void lcl_DrawGraphic( const SvxBrushItem &rBrush, OutputDevice *pOut, + const Rectangle &rOrg, const Rectangle &rOut ) +{ + Size aGrfSize(0,0); + const Graphic *pGraphic = rBrush.GetGraphic(); + SvxGraphicPosition ePos; + if ( pGraphic && pGraphic->IsSupportedGraphic() ) + { + const MapMode aMapMM( MAP_100TH_MM ); + if ( pGraphic->GetPrefMapMode().GetMapUnit() == MAP_PIXEL ) + { + MapMode aOldMap( pOut->GetMapMode() ); + pOut->SetMapMode( aMapMM ); + aGrfSize = pOut->PixelToLogic( pGraphic->GetPrefSize() ); + pOut->SetMapMode( aOldMap ); + } + else + aGrfSize = OutputDevice::LogicToLogic( pGraphic->GetPrefSize(), + pGraphic->GetPrefMapMode(), aMapMM ); + ePos = rBrush.GetGraphicPos(); + } + else + ePos = GPOS_NONE; + + Point aPos; + Size aSize = aGrfSize; + + FASTBOOL bDraw = TRUE; +// FASTBOOL bRetouche = TRUE; + switch ( ePos ) + { + case GPOS_LT: aPos = rOrg.TopLeft(); + break; + case GPOS_MT: aPos.Y() = rOrg.Top(); + aPos.X() = rOrg.Left() + rOrg.GetSize().Width()/2 - aGrfSize.Width()/2; + break; + case GPOS_RT: aPos.Y() = rOrg.Top(); + aPos.X() = rOrg.Right() - aGrfSize.Width(); + break; + + case GPOS_LM: aPos.Y() = rOrg.Top() + rOrg.GetSize().Height()/2 - aGrfSize.Height()/2; + aPos.X() = rOrg.Left(); + break; + case GPOS_MM: aPos.Y() = rOrg.Top() + rOrg.GetSize().Height()/2 - aGrfSize.Height()/2; + aPos.X() = rOrg.Left() + rOrg.GetSize().Width()/2 - aGrfSize.Width()/2; + break; + case GPOS_RM: aPos.Y() = rOrg.Top() + rOrg.GetSize().Height()/2 - aGrfSize.Height()/2; + aPos.X() = rOrg.Right() - aGrfSize.Width(); + break; + + case GPOS_LB: aPos.Y() = rOrg.Bottom() - aGrfSize.Height(); + aPos.X() = rOrg.Left(); + break; + case GPOS_MB: aPos.Y() = rOrg.Bottom() - aGrfSize.Height(); + aPos.X() = rOrg.Left() + rOrg.GetSize().Width()/2 - aGrfSize.Width()/2; + break; + case GPOS_RB: aPos.Y() = rOrg.Bottom() - aGrfSize.Height(); + aPos.X() = rOrg.Right() - aGrfSize.Width(); + break; + + case GPOS_AREA: + aPos = rOrg.TopLeft(); + aSize = rOrg.GetSize(); +// bRetouche = FALSE; + break; + case GPOS_TILED: + { + const FASTBOOL bUseQuickBmp = OUTDEV_PRINTER != pOut->GetOutDevType() && + !pOut->GetConnectMetaFile(); + Bitmap* pQuickDrawBmp = NULL; + if (bUseQuickBmp) + { + pQuickDrawBmp = new Bitmap; + *pQuickDrawBmp = XOutBitmap::CreateQuickDrawBitmapEx( + *pGraphic, *pOut, pOut->GetMapMode(), + aGrfSize, Point(), aGrfSize ).GetBitmap(); + } + aPos = rOrg.TopLeft(); + aSize = aGrfSize; + do + { + do + { + Rectangle aGrf( aPos,aSize ); + if ( aGrf.IsOver( rOut ) ) + { + if (bUseQuickBmp) + lcl_DrawGraphic( *pQuickDrawBmp, pOut, aGrf, rOut ); + else + lcl_DrawGraphic( *pGraphic, pOut, aGrf, rOut ); + } + aPos.X() += aGrfSize.Width(); + } + while ( aPos.X() < rOut.Right() ); + + aPos.X() = rOrg.Left(); + aPos.Y() += aGrfSize.Height(); + + } + while ( aPos.Y() < rOut.Bottom() ) ; + bDraw = FALSE; +// bRetouche = FALSE; + + delete pQuickDrawBmp; + } + break; + + case GPOS_NONE: + bDraw = FALSE; + break; + + default: DBG_ASSERT( !pOut, "new Graphic position?" ); + } + Rectangle aGrf( aPos,aSize ); + if ( bDraw && aGrf.IsOver( rOut ) ) + { + lcl_DrawGraphic( *pGraphic, pOut, aGrf, rOut ); + } +} + +// Rahmen wird nach innen gezeichnet + +void ScPrintFunc::DrawBorder( long nScrX, long nScrY, long nScrW, long nScrH, + const SvxBoxItem* pBorderData, const SvxBrushItem* pBackground, + const SvxShadowItem* pShadow ) +{ + //! direkte Ausgabe aus SvxBoxItem !!! + + if (pBorderData) + if ( !pBorderData->GetTop() && !pBorderData->GetBottom() && !pBorderData->GetLeft() && + !pBorderData->GetRight() ) + pBorderData = NULL; + + if (!pBorderData && !pBackground && !pShadow) + return; // nichts zu tun + + long nLeft = 0; + long nRight = 0; + long nTop = 0; + long nBottom = 0; + + // aFrameRect - aussen um die Umrandung, ohne Schatten + if ( pShadow && pShadow->GetLocation() != SVX_SHADOW_NONE ) + { + nLeft += (long) ( pShadow->CalcShadowSpace(SHADOW_LEFT) * nScaleX ); + nRight += (long) ( pShadow->CalcShadowSpace(SHADOW_RIGHT) * nScaleX ); + nTop += (long) ( pShadow->CalcShadowSpace(SHADOW_TOP) * nScaleY ); + nBottom += (long) ( pShadow->CalcShadowSpace(SHADOW_BOTTOM) * nScaleY ); + } + Rectangle aFrameRect( Point(nScrX+nLeft, nScrY+nTop), + Size(nScrW-nLeft-nRight, nScrH-nTop-nBottom) ); + + // Mitte der Umrandung, um Linien ueber OutputData zu zeichnen: + if (pBorderData) + { + nLeft += (long) ( lcl_LineTotal(pBorderData->GetLeft()) * nScaleX / 2 ); + nRight += (long) ( lcl_LineTotal(pBorderData->GetRight()) * nScaleX / 2 ); + nTop += (long) ( lcl_LineTotal(pBorderData->GetTop()) * nScaleY / 2 ); + nBottom += (long) ( lcl_LineTotal(pBorderData->GetBottom()) * nScaleY / 2 ); + } + long nEffHeight = nScrH - nTop - nBottom; + long nEffWidth = nScrW - nLeft - nRight; + if (nEffHeight<=0 || nEffWidth<=0) + return; // leer + + if (pBackground) + { +// Rectangle aBackRect( Point(nScrX+nLeft, nScrY+nTop), Size(nEffWidth,nEffHeight) ); + if (pBackground->GetGraphicPos() != GPOS_NONE) + lcl_DrawGraphic( *pBackground, pDev, aFrameRect, aFrameRect ); + else + { + pDev->SetFillColor(pBackground->GetColor()); + pDev->SetLineColor(); + pDev->DrawRect(aFrameRect); + } + } + + if ( pShadow && pShadow->GetLocation() != SVX_SHADOW_NONE ) + { + pDev->SetFillColor(pShadow->GetColor()); + pDev->SetLineColor(); + long nShadowX = (long) ( pShadow->GetWidth() * nScaleX ); + long nShadowY = (long) ( pShadow->GetWidth() * nScaleY ); + switch (pShadow->GetLocation()) + { + case SVX_SHADOW_TOPLEFT: + pDev->DrawRect( Rectangle( + aFrameRect.Left()-nShadowX, aFrameRect.Top()-nShadowY, + aFrameRect.Right()-nShadowX, aFrameRect.Top() ) ); + pDev->DrawRect( Rectangle( + aFrameRect.Left()-nShadowX, aFrameRect.Top()-nShadowY, + aFrameRect.Left(), aFrameRect.Bottom()-nShadowY ) ); + break; + case SVX_SHADOW_TOPRIGHT: + pDev->DrawRect( Rectangle( + aFrameRect.Left()+nShadowX, aFrameRect.Top()-nShadowY, + aFrameRect.Right()+nShadowX, aFrameRect.Top() ) ); + pDev->DrawRect( Rectangle( + aFrameRect.Right(), aFrameRect.Top()-nShadowY, + aFrameRect.Right()+nShadowX, aFrameRect.Bottom()-nShadowY ) ); + break; + case SVX_SHADOW_BOTTOMLEFT: + pDev->DrawRect( Rectangle( + aFrameRect.Left()-nShadowX, aFrameRect.Bottom(), + aFrameRect.Right()-nShadowX, aFrameRect.Bottom()+nShadowY ) ); + pDev->DrawRect( Rectangle( + aFrameRect.Left()-nShadowX, aFrameRect.Top()+nShadowY, + aFrameRect.Left(), aFrameRect.Bottom()+nShadowY ) ); + break; + case SVX_SHADOW_BOTTOMRIGHT: + pDev->DrawRect( Rectangle( + aFrameRect.Left()+nShadowX, aFrameRect.Bottom(), + aFrameRect.Right()+nShadowX, aFrameRect.Bottom()+nShadowY ) ); + pDev->DrawRect( Rectangle( + aFrameRect.Right(), aFrameRect.Top()+nShadowY, + aFrameRect.Right()+nShadowX, aFrameRect.Bottom()+nShadowY ) ); + break; + } + } + + USHORT i; + if (pBorderData) + { + ScDocument* pBorderDoc = new ScDocument( SCDOCMODE_UNDO ); + pBorderDoc->InitUndo( pDoc, 0,0, TRUE,TRUE ); + if (pBorderData) + pBorderDoc->ApplyAttr( 0,0,0, *pBorderData ); + + RowInfo* pRowInfo = new RowInfo[ROWINFO_MAX]; + USHORT nArrCount = pBorderDoc->FillInfo( pRowInfo, 0,0, 0,0, 0, + nScaleX, nScaleY, FALSE, FALSE ); + DBG_ASSERT(nArrCount,"nArrCount == 0"); + + pRowInfo[1].nHeight = (USHORT) nEffHeight; + pRowInfo[0].pCellInfo[1].nWidth = + pRowInfo[1].pCellInfo[1].nWidth = (USHORT) nEffWidth; + + ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, pRowInfo, nArrCount, pBorderDoc, 0, + nScrX+nLeft, nScrY+nTop, 0,0, 0,0, nScaleX, nScaleY ); + +// pDev->SetMapMode(aTwipMode); + + if (pBorderData) + aOutputData.DrawFrame(); + + for (i=0; i<nArrCount; i++) + delete[] pRowInfo[i].pCellInfo; + delete[] pRowInfo; + + delete pBorderDoc; + } +} + +void ScPrintFunc::PrintColHdr( USHORT nX1, USHORT nX2, long nScrX, long nScrY ) +{ + Size aOnePixel = pDev->PixelToLogic(Size(1,1)); + long nOneX = aOnePixel.Width(); + long nOneY = aOnePixel.Height(); + + long nHeight = (long) (PRINT_HEADER_HEIGHT * nScaleY); + long nEndY = nScrY + nHeight - nOneY; + + long nPosX = nScrX - nOneX; + long nPosY = nScrY - nOneY; + String aText; + + for (USHORT nCol=nX1; nCol<=nX2; nCol++) + { + USHORT nDocW = pDoc->GetColWidth( nCol, nPrintTab ); + if (nDocW) + { + long nWidth = (long) (nDocW * nScaleX); + long nEndX = nPosX + nWidth; + + pDev->DrawRect( Rectangle( nPosX,nPosY,nEndX,nEndY ) ); + + if ( nCol < 26 ) + aText = (sal_Unicode) ( 'A' + nCol ); + else + { + aText = (sal_Unicode) ( 'A' + ( nCol / 26 ) - 1 ); + aText += (sal_Unicode) ( 'A' + ( nCol % 26 ) ); + } + long nTextWidth = pDev->GetTextWidth(aText); + long nTextHeight = pDev->GetTextHeight(); + long nAddX = ( nWidth - nTextWidth ) / 2; + long nAddY = ( nHeight - nTextHeight ) / 2; + pDev->DrawText( Point( nPosX+nAddX,nPosY+nAddY ), aText ); + + nPosX = nEndX; + } + } +} + +void ScPrintFunc::PrintRowHdr( USHORT nY1, USHORT nY2, long nScrX, long nScrY ) +{ + Size aOnePixel = pDev->PixelToLogic(Size(1,1)); + long nOneX = aOnePixel.Width(); + long nOneY = aOnePixel.Height(); + + long nWidth = (long) (PRINT_HEADER_WIDTH * nScaleX); + long nEndX = nScrX + nWidth - nOneX; + + long nPosX = nScrX - nOneX; + long nPosY = nScrY - nOneY; + String aText; + + for (USHORT nRow=nY1; nRow<=nY2; nRow++) + { + USHORT nDocH = pDoc->FastGetRowHeight( nRow, nPrintTab ); + if (nDocH) + { + long nHeight = (long) (nDocH * nScaleY); + long nEndY = nPosY + nHeight; + + pDev->DrawRect( Rectangle( nPosX,nPosY,nEndX,nEndY ) ); + + aText = String::CreateFromInt32( nRow+1 ); + long nTextWidth = pDev->GetTextWidth(aText); + long nTextHeight = pDev->GetTextHeight(); + long nAddX = ( nWidth - nTextWidth ) / 2; + long nAddY = ( nHeight - nTextHeight ) / 2; + pDev->DrawText( Point( nPosX+nAddX,nPosY+nAddY ), aText ); + + nPosY = nEndY; + } + } +} + +void lcl_HidePrint( RowInfo* pRowInfo, USHORT nArrCount, USHORT nX1, USHORT nX2 ) +{ + for (USHORT nArrY=1; nArrY+1<nArrCount; nArrY++) + { + RowInfo* pThisRowInfo = &pRowInfo[nArrY]; + for (USHORT nX=nX1; nX<=nX2; nX++) + { + const CellInfo& rCellInfo = pThisRowInfo->pCellInfo[nX+1]; + if (!rCellInfo.bEmptyCellText) + if (((const ScProtectionAttr&)rCellInfo.pPatternAttr-> + GetItem(ATTR_PROTECTION, rCellInfo.pConditionSet)).GetHidePrint()) + { + pThisRowInfo->pCellInfo[nX+1].pCell = NULL; + pThisRowInfo->pCellInfo[nX+1].bEmptyCellText = TRUE; + } + } + } +} + +void ScPrintFunc::PrintArea( USHORT nX1, USHORT nY1, USHORT nX2, USHORT nY2, + long nScrX, long nScrY, + BOOL bShLeft, BOOL bShTop, BOOL bShRight, BOOL bShBottom ) +{ + USHORT i; + + //! Flag bei FillInfo uebergeben !!!!! + ScTripel aEStart; + ScTripel aEEnd; + BOOL bEmbed = pDoc->IsEmbedded(); + if (bEmbed) + { + pDoc->GetEmbedded(aEStart,aEEnd); + pDoc->ResetEmbedded(); + } + + Point aPos = OutputDevice::LogicToLogic(Point(nScrX,nScrY), aOffsetMode, aLogicMode); + long nLogStX = aPos.X(); + long nLogStY = aPos.Y(); + + // Daten zusammenstellen + + RowInfo* pRowInfo = new RowInfo[ROWINFO_MAX]; + USHORT nArrCount = pDoc->FillInfo( pRowInfo, nX1, nY1, nX2, nY2, nPrintTab, + nScaleX, nScaleY, TRUE, aTableParam.bFormulas ); + lcl_HidePrint( pRowInfo, nArrCount, nX1, nX2 ); + + if (bEmbed) + pDoc->SetEmbedded(aEStart,aEEnd); + + ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, pRowInfo, nArrCount, pDoc, nPrintTab, + nScrX, nScrY, nX1, nY1, nX2, nY2, nScaleX, nScaleY ); + + if (nObjectFlags) + { + pDev->SetMapMode(aLogicMode); + // hier kein Clipping setzen (Mapmode wird verschoben) + aOutputData.DrawingLayer(SC_LAYER_BACK,nObjectFlags,nLogStX,nLogStY); + } + + pDev->SetMapMode(aOffsetMode); + + aOutputData.SetShowFormulas( aTableParam.bFormulas ); + aOutputData.SetShowNullValues( aTableParam.bNullVals ); + + if (!pPrinter) + { + OutputDevice* pRefDev = pDoc->GetPrinter(); // auch fuer Preview den Drucker nehmen + Fraction aPrintFrac( nZoom, 100 ); // ohne nManualZoom + // MapMode, wie er beim Drucken herauskommen wuerde: + pRefDev->SetMapMode( MapMode( MAP_100TH_MM, Point(), aPrintFrac, aPrintFrac ) ); + aOutputData.SetRefDevice( pRefDev ); + } + +// aOutputData.SetMetaFileMode(TRUE); + aOutputData.DrawBackground(); + + pDev->SetClipRegion( Rectangle( aPos, Size( aOutputData.GetScrW(), aOutputData.GetScrH() ) ) ); + SFX_APP()->SpoilDemoOutput( *pDev, OutputDevice::LogicToLogic( + aPageRect, aTwipMode, aOffsetMode ) ); + pDev->SetClipRegion(); +// + aOutputData.SetMetaFileMode(FALSE); + aOutputData.DrawExtraShadow( bShLeft, bShTop, bShRight, bShBottom ); + aOutputData.DrawFrame(); + aOutputData.DrawStrings(); + +// pDev->SetMapMode(aLogicMode); + aOutputData.DrawEdit(FALSE,1.0,1.0); + +// pDev->SetMapMode(aOffsetMode); + if (aTableParam.bGrid) + aOutputData.DrawGrid( TRUE, FALSE ); // keine Seitenumbrueche + +/*!!!!!!!!!!! Notizen in Tabelle markieren ?????????????????????????? + + if (aTableParam.bNotes) + { + pDev->SetMapMode(aOffsetMode); + aOutputData.PrintNoteMarks(aNotePosList); + pDev->SetMapMode(aLogicMode); + } +*/ + +// pDev->SetMapMode(aDrawMode); + if (nObjectFlags) + aOutputData.DrawingLayer(SC_LAYER_FRONT,nObjectFlags,nLogStX,nLogStY); + aOutputData.DrawingLayer(SC_LAYER_INTERN,SC_OBJECTS_ALL,nLogStX,nLogStY); + + if ( pDrawView && (nObjectFlags & SC_OBJECTS_DRAWING) ) + { + SdrPageView* pPV = pDrawView->GetPageViewPgNum(nPrintTab); + DBG_ASSERT(pPV, "keine PageView fuer gedruckte Tabelle"); + if (pPV) + { + Rectangle aLogicRect = pDoc->GetMMRect( nX1,nY1, nX2,nY2, nPrintTab ); + Point aControlOffset( nLogStX - aLogicRect.Left(), nLogStY - aLogicRect.Top() ); + MapMode aControlMode( MAP_100TH_MM, aControlOffset, + aLogicMode.GetScaleX(), aLogicMode.GetScaleY() ); + pDev->SetMapMode( aControlMode ); + pPV->RedrawOneLayer( SC_LAYER_CONTROLS, aLogicRect ); + } + } + + for (i=0; i<nArrCount; i++) + delete[] pRowInfo[i].pCellInfo; + delete[] pRowInfo; +} + +BOOL ScPrintFunc::IsMirror( long nPageNo ) // Raender spiegeln ? +{ + SvxPageUsage eUsage = (SvxPageUsage) ( nPageUsage & 0x000f ); + return ( eUsage == SVX_PAGE_MIRROR && (nPageNo & 1) ); +} + +BOOL ScPrintFunc::IsLeft( long nPageNo ) // linke Fussnoten ? +{ + SvxPageUsage eUsage = (SvxPageUsage) ( nPageUsage & 0x000f ); + BOOL bLeft; + if (eUsage == SVX_PAGE_LEFT) + bLeft = TRUE; + else if (eUsage == SVX_PAGE_RIGHT) + bLeft = FALSE; + else + bLeft = (nPageNo & 1) != 0; + return bLeft; +} + +void ScPrintFunc::MakeTableString() +{ + pDoc->GetName( nPrintTab, aFieldData.aTabName ); +} + +String lcl_CmdStr( USHORT nId ) +{ + String aDel( ScGlobal::GetRscString( STR_HFCMD_DELIMITER ) ); + String aCmd = aDel; + aCmd += ScGlobal::GetRscString( nId ); + aCmd += aDel; + return aCmd; +} + +void ScPrintFunc::MakeEditEngine() +{ + if (!pEditEngine) + { + Font aDefFont; + ((const ScPatternAttr&)pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN)).GetFont(aDefFont); + // #69193# dont use font color, because background color is not used + //! there's no way to set the background for note pages + aDefFont.SetColor( COL_BLACK ); + + // can't use document's edit engine pool here, + // because pool must have twips as default metric + pEditEngine = new ScHeaderEditEngine( EditEngine::CreatePool(), TRUE ); + + pEditEngine->EnableUndo(FALSE); + pEditEngine->SetRefDevice( pDev ); + pEditEngine->SetWordDelimiters( + ScEditUtil::ModifyDelimiters( pEditEngine->GetWordDelimiters() ) ); + pEditEngine->SetControlWord( pEditEngine->GetControlWord() & ~EE_CNTRL_RTFSTYLESHEETS ); + + // Default-Set fuer Ausrichtung + pEditDefaults = new SfxItemSet( pEditEngine->GetEmptyItemSet() ); + + EditEngine::SetFontInfoInItemSet( *pEditDefaults, aDefFont ); + } + + pEditEngine->SetData( aFieldData ); // Seitennummer etc. setzen +} + +// nStartY = logic +void ScPrintFunc::PrintHF( long nPageNo, const ScPrintHFParam& rParam, long nStartY ) +{ + pDev->SetMapMode( aTwipMode ); // Kopf-/Fusszeilen in Twips + + BOOL bLeft = IsLeft(nPageNo) && !rParam.bShared; + const ScPageHFItem* pHFItem = bLeft ? rParam.pLeft : rParam.pRight; + + long nLineStartX = aPageRect.Left() + rParam.nLeft; + long nLineEndX = aPageRect.Right() - rParam.nRight; + long nLineWidth = nLineEndX - nLineStartX + 1; + + // Edit-Engine + + Point aStart( nLineStartX, nStartY ); + Size aPaperSize( nLineWidth, rParam.nHeight-rParam.nDistance ); + if ( rParam.pBorder ) + { + long nLeft = lcl_LineTotal( rParam.pBorder->GetLeft() ) + rParam.pBorder->GetDistance(); + long nTop = lcl_LineTotal( rParam.pBorder->GetTop() ) + rParam.pBorder->GetDistance(); + aStart.X() += nLeft; + aStart.Y() += nTop; + aPaperSize.Width() -= nLeft + lcl_LineTotal( rParam.pBorder->GetRight() ) + rParam.pBorder->GetDistance(); + aPaperSize.Height() -= nTop + lcl_LineTotal( rParam.pBorder->GetBottom() ) + rParam.pBorder->GetDistance(); + } + + if ( rParam.pShadow && rParam.pShadow->GetLocation() != SVX_SHADOW_NONE ) + { + long nLeft = rParam.pShadow->CalcShadowSpace(SHADOW_LEFT); + long nTop = rParam.pShadow->CalcShadowSpace(SHADOW_TOP); + aStart.X() += nLeft; + aStart.Y() += nTop; + aPaperSize.Width() -= nLeft + rParam.pShadow->CalcShadowSpace(SHADOW_RIGHT); + aPaperSize.Height() -= nTop + rParam.pShadow->CalcShadowSpace(SHADOW_BOTTOM); + } + + aFieldData.nPageNo = nPageNo+aTableParam.nFirstPageNo; + MakeEditEngine(); + + pEditEngine->SetPaperSize(aPaperSize); + const EditTextObject* pObject; + + // Rahmen / Hintergrund + + Point aBorderStart( nLineStartX, nStartY ); + Size aBorderSize( nLineWidth, rParam.nHeight-rParam.nDistance ); + if ( rParam.bDynamic ) + { + // hier nochmal anpassen, wegen geraden/ungeraden Kopf/Fusszeilen + // und evtl. anderen Umbruechen durch Variablen (Seitennummer etc.) + + long nMaxHeight = 0; + nMaxHeight = Max( nMaxHeight, TextHeight( pHFItem->GetLeftArea() ) ); + nMaxHeight = Max( nMaxHeight, TextHeight( pHFItem->GetCenterArea() ) ); + nMaxHeight = Max( nMaxHeight, TextHeight( pHFItem->GetRightArea() ) ); + if (rParam.pBorder) + nMaxHeight += lcl_LineTotal( rParam.pBorder->GetTop() ) + + lcl_LineTotal( rParam.pBorder->GetBottom() ) + + 2*rParam.pBorder->GetDistance(); + if (rParam.pShadow && rParam.pShadow->GetLocation() != SVX_SHADOW_NONE) + nMaxHeight += rParam.pShadow->CalcShadowSpace(SHADOW_TOP) + + rParam.pShadow->CalcShadowSpace(SHADOW_BOTTOM); + + if (nMaxHeight < rParam.nManHeight-rParam.nDistance) + nMaxHeight = rParam.nManHeight-rParam.nDistance; // eingestelltes Minimum + + aBorderSize.Height() = nMaxHeight; + } + + double nOldScaleX = nScaleX; + double nOldScaleY = nScaleY; + nScaleX = nScaleY = 1.0; // direkt in Twips ausgeben + DrawBorder( aBorderStart.X(), aBorderStart.Y(), aBorderSize.Width(), aBorderSize.Height(), + rParam.pBorder, rParam.pBack, rParam.pShadow ); + nScaleX = nOldScaleX; + nScaleY = nOldScaleY; + + // Clipping fuer Text + + pDev->SetClipRegion( Rectangle( aStart, aPaperSize ) ); + + // links + + pObject = pHFItem->GetLeftArea(); + if (pObject) + { + pEditDefaults->Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) ); + pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, FALSE ); + Point aDraw = aStart; + long nDif = aPaperSize.Height() - (long) pEditEngine->GetTextHeight(); + if (nDif > 0) + aDraw.Y() += nDif / 2; + pEditEngine->Draw( pDev, aDraw, 0 ); + } + + // Mitte + + pObject = pHFItem->GetCenterArea(); + if (pObject) + { + pEditDefaults->Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) ); + pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, FALSE ); + Point aDraw = aStart; + long nDif = aPaperSize.Height() - (long) pEditEngine->GetTextHeight(); + if (nDif > 0) + aDraw.Y() += nDif / 2; + pEditEngine->Draw( pDev, aDraw, 0 ); + } + + // rechts + + pObject = pHFItem->GetRightArea(); + if (pObject) + { + pEditDefaults->Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) ); + pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, FALSE ); + Point aDraw = aStart; + long nDif = aPaperSize.Height() - (long) pEditEngine->GetTextHeight(); + if (nDif > 0) + aDraw.Y() += nDif / 2; + pEditEngine->Draw( pDev, aDraw, 0 ); + } + + pDev->SetClipRegion(); +} + +long ScPrintFunc::DoNotes( long nNoteStart, BOOL bDoPrint ) +{ + if (bDoPrint) + pDev->SetMapMode(aTwipMode); + + MakeEditEngine(); + pEditDefaults->Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) ); + pEditEngine->SetDefaults( *pEditDefaults ); + + Font aMarkFont; + ((const ScPatternAttr&)pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN)).GetFont(aMarkFont); +//? aMarkFont.SetWeight( WEIGHT_BOLD ); + pDev->SetFont( aMarkFont ); + long nMarkLen = pDev->GetTextWidth( + String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("GW99999:"))); + // ohne Space, weil's eh selten so weit kommt + + Size aDataSize = aPageRect.GetSize(); + if ( nMarkLen > aDataSize.Width() / 2 ) // alles viel zu klein? + nMarkLen = aDataSize.Width() / 2; // Seite bruederlich aufteilen + aDataSize.Width() -= nMarkLen; + + pEditEngine->SetPaperSize( aDataSize ); + long nPosX = aPageRect.Left() + nMarkLen; + long nPosY = aPageRect.Top(); + + long nCount = 0; + BOOL bOk; + do + { + bOk = FALSE; + ScTripel* pPos = (ScTripel*) aNotePosList.GetObject( nNoteStart+nCount ); + if (pPos) + { + ScBaseCell* pCell; + pDoc->GetCell( pPos->GetCol(), pPos->GetRow(), pPos->GetTab(), pCell ); + const ScPostIt* pNote = pCell->GetNotePtr(); + if (pNote) + { + String aString = pNote->GetText(); + pEditEngine->SetText(aString); + long nTextHeight = pEditEngine->GetTextHeight(); + if ( nPosY + nTextHeight < aPageRect.Bottom() ) + { + if (bDoPrint) + { + pEditEngine->Draw( pDev, Point( nPosX, nPosY ), 0 ); + + ScAddress aAddress( pPos->GetCol(), pPos->GetRow(), pPos->GetTab() ); + String aMarkStr; + aAddress.Format( aMarkStr, SCA_VALID, pDoc ); + aMarkStr += ':'; + + // Zellposition auch per EditEngine, damit die Position stimmt + pEditEngine->SetText(aMarkStr); + pEditEngine->Draw( pDev, Point( aPageRect.Left(), nPosY ), 0 ); + } + + nPosY += nTextHeight; + nPosY += 200; // Abstand + ++nCount; + bOk = TRUE; + } + } + } + } + while (bOk); + + return nCount; +} + +long ScPrintFunc::PrintNotes( long nPageNo, long nNoteStart, BOOL bDoPrint ) +{ + if ( nNoteStart >= (long) aNotePosList.Count() || !aTableParam.bNotes ) + return 0; + + if ( bDoPrint && bClearWin ) + { + //! mit PrintPage zusammenfassen !!! + + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + + pDev->SetMapMode(aOffsetMode); + pDev->SetLineColor(); + pDev->SetFillColor(rStyleSettings.GetWindowColor()); + pDev->DrawRect(Rectangle(Point(), + Size((long)(aPageSize.Width() * nScaleX * 100 / nZoom), + (long)(aPageSize.Height() * nScaleY * 100 / nZoom)))); + } + + + // aPageRect auf linke / rechte Seiten anpassen + + Rectangle aTempRect = Rectangle( Point(), aPageSize ); + if (IsMirror(nPageNo)) + { + aPageRect.Left() = ( aTempRect.Left() + nRightMargin ) * 100 / nZoom; + aPageRect.Right() = ( aTempRect.Right() - nLeftMargin ) * 100 / nZoom; + } + else + { + aPageRect.Left() = ( aTempRect.Left() + nLeftMargin ) * 100 / nZoom; + aPageRect.Right() = ( aTempRect.Right() - nRightMargin ) * 100 / nZoom; + } + + if (bDoPrint) + { + if (pPrinter) + pPrinter->StartPage(); + + // Kopf- und Fusszeilen + + if (aHdr.bEnable) + { + long nHeaderY = aPageRect.Top()-aHdr.nHeight; + PrintHF( nPageNo, aHdr, nHeaderY ); + } + if (aFtr.bEnable) + { + long nFooterY = aPageRect.Bottom()+aFtr.nDistance; + PrintHF( nPageNo, aFtr, nFooterY ); + } + } + + long nCount = DoNotes( nNoteStart, bDoPrint ); + + if (pPrinter && bDoPrint) + pPrinter->EndPage(); + + return nCount; +} + +void ScPrintFunc::PrintPage( long nPageNo, USHORT nX1, USHORT nY1, USHORT nX2, USHORT nY2 ) +{ + // nPageNo - Seitennummer innerhalb einer "Startseite"-Einstellung + + if (bClearWin) + { + // muss genau zum Zeichnen des Rahmens in preview.cxx passen !!! + + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + + pDev->SetMapMode(aOffsetMode); + pDev->SetLineColor(); + pDev->SetFillColor(rStyleSettings.GetWindowColor()); + pDev->DrawRect(Rectangle(Point(), + Size((long)(aPageSize.Width() * nScaleX * 100 / nZoom), + (long)(aPageSize.Height() * nScaleY * 100 / nZoom)))); + } + + + // aPageRect auf linke / rechte Seiten anpassen + + Rectangle aTempRect = Rectangle( Point(), aPageSize ); + if (IsMirror(nPageNo)) + { + aPageRect.Left() = ( aTempRect.Left() + nRightMargin ) * 100 / nZoom; + aPageRect.Right() = ( aTempRect.Right() - nLeftMargin ) * 100 / nZoom; + } + else + { + aPageRect.Left() = ( aTempRect.Left() + nLeftMargin ) * 100 / nZoom; + aPageRect.Right() = ( aTempRect.Right() - nRightMargin ) * 100 / nZoom; + } + + if ( aAreaParam.bRepeatCol ) + if ( nX1 > nRepeatStartCol && nX1 <= nRepeatEndCol ) + nX1 = nRepeatEndCol + 1; + BOOL bDoRepCol = (aAreaParam.bRepeatCol && nX1 > nRepeatEndCol); + if ( aAreaParam.bRepeatRow ) + if ( nY1 > nRepeatStartRow && nY1 <= nRepeatEndRow ) + nY1 = nRepeatEndRow + 1; + BOOL bDoRepRow = (aAreaParam.bRepeatRow && nY1 > nRepeatEndRow); + + nObjectFlags = 0; + if ( aTableParam.bDrawings ) + nObjectFlags |= SC_OBJECTS_DRAWING; + if ( aTableParam.bObjects ) + nObjectFlags |= SC_OBJECTS_OLE; + if ( aTableParam.bCharts ) + nObjectFlags |= SC_OBJECTS_CHARTS; + + USHORT i; + + if (pPrinter) + pPrinter->StartPage(); + + // Kopf- und Fusszeilen (ohne Zentrierung) + + if (aHdr.bEnable) + { + long nHeaderY = aPageRect.Top()-aHdr.nHeight; + PrintHF( nPageNo, aHdr, nHeaderY ); + } + if (aFtr.bEnable) + { + long nFooterY = aPageRect.Bottom()+aFtr.nDistance; + PrintHF( nPageNo, aFtr, nFooterY ); + } + + // Position ( Raender / zentrieren ) + + long nLeftSpace = aPageRect.Left(); // Document-Twips + long nTopSpace = aPageRect.Top(); + if ( bCenterHor ) + { + long nDataWidth = 0; + for (i=nX1; i<=nX2; i++) + nDataWidth += pDoc->GetColWidth( i,nPrintTab ); + if (bDoRepCol) + for (i=nRepeatStartCol; i<=nRepeatEndCol; i++) + nDataWidth += pDoc->GetColWidth( i,nPrintTab ); + if (aTableParam.bHeaders) + nDataWidth += (long) PRINT_HEADER_WIDTH; + if (pBorderItem) + nDataWidth += 2 * pBorderItem->GetDistance(); //! Linenstaerke ??? + if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE) + nDataWidth += pShadowItem->CalcShadowSpace(SHADOW_LEFT) + + pShadowItem->CalcShadowSpace(SHADOW_RIGHT); + nLeftSpace += ( aPageRect.GetWidth() - nDataWidth ) / 2; + if (pBorderItem) + nLeftSpace -= lcl_LineTotal(pBorderItem->GetLeft()); + } + if ( bCenterVer ) + { + long nDataHeight = 0; + for (i=nY1; i<=nY2; i++) + nDataHeight += pDoc->FastGetRowHeight( i,nPrintTab ); + if (bDoRepRow) + for (i=nRepeatStartRow; i<=nRepeatEndRow; i++) + nDataHeight += pDoc->FastGetRowHeight( i,nPrintTab ); + if (aTableParam.bHeaders) + nDataHeight += (long) PRINT_HEADER_HEIGHT; + if (pBorderItem) + nDataHeight += 2 * pBorderItem->GetDistance(); //! Linenstaerke ??? + if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE) + nDataHeight += pShadowItem->CalcShadowSpace(SHADOW_TOP) + + pShadowItem->CalcShadowSpace(SHADOW_BOTTOM); + nTopSpace += ( aPageRect.GetHeight() - nDataHeight ) / 2; + if (pBorderItem) + nTopSpace -= lcl_LineTotal(pBorderItem->GetTop()); + } + + // Seite aufteilen + + long nStartX = ((long) ( nLeftSpace * nScaleX )); + long nStartY = ((long) ( nTopSpace * nScaleY )); +// nStartX -= aOffset.X(); // schon im MapMode +// nStartY -= aOffset.Y(); + + long nInnerStartX = nStartX; + long nInnerStartY = nStartY; + if (pBorderItem) + { + nInnerStartX += (long) ( ( lcl_LineTotal(pBorderItem->GetLeft()) + + pBorderItem->GetDistance() ) * nScaleX ); + nInnerStartY += (long) ( ( lcl_LineTotal(pBorderItem->GetTop()) + + pBorderItem->GetDistance() ) * nScaleY ); + } + if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE) + { + nInnerStartX += (long) ( pShadowItem->CalcShadowSpace(SHADOW_LEFT) * nScaleX ); + nInnerStartY += (long) ( pShadowItem->CalcShadowSpace(SHADOW_TOP) * nScaleY ); + } + long nRepStartX = nInnerStartX; + long nRepStartY = nInnerStartY; + if (aTableParam.bHeaders) + { + nRepStartX += (long) (PRINT_HEADER_WIDTH * nScaleX); + nRepStartY += (long) (PRINT_HEADER_HEIGHT * nScaleY); + } + long nDataX = nRepStartX; + long nDataY = nRepStartY; + if (bDoRepCol) + for (i=nRepeatStartCol; i<=nRepeatEndCol; i++) + nDataX += (long) (pDoc->GetColWidth(i,nPrintTab) * nScaleX); + if (bDoRepRow) + for (i=nRepeatStartRow; i<=nRepeatEndRow; i++) + nDataY += (long) (pDoc->FastGetRowHeight(i,nPrintTab) * nScaleY); + long nEndX = nDataX; + long nEndY = nDataY; + for (i=nX1; i<=nX2; i++) + nEndX += (long) (pDoc->GetColWidth(i,nPrintTab) * nScaleX); + for (i=nY1; i<=nY2; i++) + nEndY += (long) (pDoc->FastGetRowHeight(i,nPrintTab) * nScaleY); + + // Seiten-Rahmen / Hintergrund + + //! nEndX/Y anpassen + + long nBorderEndX = nEndX; + long nBorderEndY = nEndY; + if (pBorderItem) + { + nBorderEndX += (long) ( ( lcl_LineTotal(pBorderItem->GetRight()) + + pBorderItem->GetDistance() ) * nScaleX ); + nBorderEndY += (long) ( ( lcl_LineTotal(pBorderItem->GetBottom()) + + pBorderItem->GetDistance() ) * nScaleY ); + } + if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE) + { + nBorderEndX += (long) ( pShadowItem->CalcShadowSpace(SHADOW_RIGHT) * nScaleX ); + nBorderEndY += (long) ( pShadowItem->CalcShadowSpace(SHADOW_BOTTOM) * nScaleY ); + } + pDev->SetMapMode( aOffsetMode ); + DrawBorder( nStartX, nStartY, nBorderEndX-nStartX, nBorderEndY-nStartY, + pBorderItem, pBackgroundItem, pShadowItem ); + + pDev->SetMapMode( aTwipMode ); + SFX_APP()->SpoilDemoOutput( *pDev, aPageRect ); + pDev->SetMapMode( aOffsetMode ); + + // Wiederholungszeilen/Spalten ausgeben + + if (bDoRepCol && bDoRepRow) + PrintArea( nRepeatStartCol,nRepeatStartRow, nRepeatEndCol,nRepeatEndRow, + nRepStartX,nRepStartY, TRUE,TRUE,FALSE,FALSE ); + if (bDoRepCol) + PrintArea( nRepeatStartCol,nY1, nRepeatEndCol,nY2, nRepStartX,nDataY, + TRUE,!bDoRepRow,FALSE,TRUE ); + if (bDoRepRow) + PrintArea( nX1,nRepeatStartRow, nX2,nRepeatEndRow, nDataX,nRepStartY, + !bDoRepCol,TRUE,TRUE,FALSE ); + + // Daten ausgeben + + PrintArea( nX1,nY1, nX2,nY2, nDataX,nDataY, !bDoRepCol,!bDoRepRow,TRUE,TRUE ); + + // Spalten-/Zeilenkoepfe ausgeben + // nach den Daten (ueber evtl. weitergezeichneten Schatten) + + if (aTableParam.bHeaders) + { + pDev->SetLineColor( COL_BLACK ); + pDev->SetFillColor(); + + ScPatternAttr aPattern( pDoc->GetPool() ); + Font aFont; +// aPattern.GetFont( aFont, pDev, (USHORT)((nZoom * (long) nManualZoom) / 100) ); + aPattern.GetFont( aFont, pDev ); + pDev->SetFont( aFont ); + + if (bDoRepCol) + PrintColHdr( nRepeatStartCol,nRepeatEndCol, nRepStartX,nInnerStartY ); + PrintColHdr( nX1,nX2, nDataX,nInnerStartY ); + if (bDoRepRow) + PrintRowHdr( nRepeatStartRow,nRepeatEndRow, nInnerStartX,nRepStartY ); + PrintRowHdr( nY1,nY2, nInnerStartX,nDataY ); + } + + // einfacher Rahmen + + if (aTableParam.bGrid || aTableParam.bHeaders) + { + Size aOnePixel = pDev->PixelToLogic(Size(1,1)); + long nOneX = aOnePixel.Width(); + long nOneY = aOnePixel.Height(); + + long nLeftX = nInnerStartX-nOneX; + long nTopY = nInnerStartY-nOneY; + pDev->SetMapMode(aOffsetMode); + pDev->SetLineColor( COL_BLACK ); + pDev->SetFillColor(); + pDev->DrawRect( Rectangle( nLeftX, nTopY, nEndX-nOneX, nEndY-nOneY ) ); + // nEndX/Y ohne Rahmen-Anpassung + } + + if (pPrinter) + pPrinter->EndPage(); +} + +void ScPrintFunc::SetOffset( const Point& rOfs ) +{ + aSrcOffset = rOfs; +} + +void ScPrintFunc::SetManualZoom( USHORT nNewZoom ) +{ + nManualZoom = nNewZoom; +} + +void ScPrintFunc::SetClearFlag( BOOL bFlag ) +{ + bClearWin = bFlag; +} + +// +// UpdatePages wird nur von aussen gerufen, um die Umbrueche fuer die Anzeige +// richtig zu setzen - immer ohne UserArea +// + +BOOL ScPrintFunc::UpdatePages() +{ + if (!pParamSet) + return FALSE; + + // Zoom + + nZoom = 100; + if (aTableParam.bScalePageNum) + nZoom = ZOOM_MIN; // stimmt fuer Umbrueche + else if (aTableParam.bScaleAll) + { + nZoom = aTableParam.nScaleAll; + if ( nZoom <= ZOOM_MIN ) + nZoom = ZOOM_MIN; + } + + String aName = pDoc->GetPageStyle( nPrintTab ); + USHORT nTabCount = pDoc->GetTableCount(); + for (USHORT nTab=0; nTab<nTabCount; nTab++) + if ( nTab==nPrintTab || pDoc->GetPageStyle(nTab)==aName ) + { + // Wiederholungszeilen / Spalten + pDoc->SetRepeatArea( nTab, nRepeatStartCol,nRepeatEndCol, nRepeatStartRow,nRepeatEndRow ); + + // Umbrueche setzen + ResetBreaks(nTab); + pDocShell->PostPaint(0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID); + } + + return TRUE; +} + +long ScPrintFunc::CountPages() // setzt auch nPagesX, nPagesY +{ + BOOL bAreaOk = FALSE; + + if (pDoc->HasTable( nPrintTab )) + { + if (aAreaParam.bPrintArea) // Druckbereich angegeben? + { + if ( bPrintCurrentTable ) + { + ScRange& rRange = aAreaParam.aPrintArea; + + // hier kein Vergleich der Tabellen mehr, die Area gilt immer fuer diese Tabelle + // wenn hier verglichen werden soll, muss die Tabelle der Druckbereiche beim + // Einfuegen von Tabellen etc. angepasst werden ! + + nStartCol = rRange.aStart.Col(); + nStartRow = rRange.aStart.Row(); + nEndCol = rRange.aEnd .Col(); + nEndRow = rRange.aEnd .Row(); + bAreaOk = AdjustPrintArea(FALSE); // begrenzen + } + else + bAreaOk = FALSE; + } + else // aus Dokument suchen + bAreaOk = AdjustPrintArea(TRUE); + } + + if (bAreaOk) + { + long nPages = 0; + USHORT nY; + if (bMultiArea) + { + USHORT nRCount = pDoc->GetPrintRangeCount( nPrintTab ); + for (USHORT i=0; i<nRCount; i++) + { + CalcZoom(i); + if ( aTableParam.bSkipEmpty ) + for (nY=0; nY<nPagesY; nY++) + nPages += pPageRows[nY].CountVisible(); + else + nPages += ((long) nPagesX) * nPagesY; + if ( pPageData ) + FillPageData(); + } + } + else + { + CalcZoom(RANGENO_NORANGE); // Zoom berechnen + if ( aTableParam.bSkipEmpty ) + for (nY=0; nY<nPagesY; nY++) + nPages += pPageRows[nY].CountVisible(); + else + nPages += ((long) nPagesX) * nPagesY; + if ( pPageData ) + FillPageData(); + } + return nPages; + } + else + { +// nZoom = 100; // nZoom auf letztem Wert stehenlassen !!! + nPagesX = nPagesY = nTotalY = 0; + return 0; + } +} + +long ScPrintFunc::CountNotePages() +{ + if ( !aTableParam.bNotes || !bPrintCurrentTable ) + return 0; + + long nCount=0; + USHORT nCol; + USHORT nRow; + + BOOL bError = FALSE; + if (!aAreaParam.bPrintArea) + bError = !AdjustPrintArea(TRUE); // komplett aus Dok suchen + + USHORT nRepeats = 1; // wie oft durchgehen ? + if (bMultiArea) + nRepeats = pDoc->GetPrintRangeCount(nPrintTab); + if (bError) + nRepeats = 0; + + for (USHORT nStep=0; nStep<nRepeats; nStep++) + { + BOOL bDoThis = TRUE; + if (bMultiArea) // alle Areas durchgehen + { + const ScRange* pThisRange = pDoc->GetPrintRange( nPrintTab, nStep ); + if ( pThisRange ) + { + nStartCol = pThisRange->aStart.Col(); + nStartRow = pThisRange->aStart.Row(); + nEndCol = pThisRange->aEnd .Col(); + nEndRow = pThisRange->aEnd .Row(); + bDoThis = AdjustPrintArea(FALSE); + } + } + + if (bDoThis) + { + ScHorizontalCellIterator aIter( pDoc, nPrintTab, nStartCol,nStartRow, nEndCol,nEndRow ); + ScBaseCell* pCell = aIter.GetNext( nCol, nRow ); + while (pCell) + { + if (pCell->GetNotePtr()) + { + aNotePosList.Insert( new ScTripel( nCol,nRow,nPrintTab ), LIST_APPEND ); + ++nCount; + } + + pCell = aIter.GetNext( nCol, nRow ); + } + } + } + + long nPages = 0; + long nNoteNr = 0; + long nNoteAdd; + do + { + nNoteAdd = PrintNotes( nPages, nNoteNr, FALSE ); + if (nNoteAdd) + { + nNoteNr += nNoteAdd; + ++nPages; + } + } + while (nNoteAdd); + + return nPages; +} + +void ScPrintFunc::InitModes() // aus nZoom etc. die MapModes setzen +{ + aOffset = Point( aSrcOffset.X()*100/nZoom, aSrcOffset.Y()*100/nZoom ); + + long nEffZoom = nZoom * (long) nManualZoom; + +// nScaleX = nScaleY = 1.0; // Ausgabe in Twips + nScaleX = nScaleY = HMM_PER_TWIPS; // Ausgabe in 1/100 mm + + Fraction aZoomFract( nEffZoom,10000 ); + Fraction aHorFract = aZoomFract; + + if (!pPrinter) // Massstab anpassen fuer Preview + { + double nFact = pDocShell->GetOutputFactor(); + aHorFract = Fraction( (long)( nEffZoom / nFact ), 10000 ); + } + + aLogicMode = MapMode( MAP_100TH_MM, Point(), aHorFract, aZoomFract ); + + Point aLogicOfs( -aOffset.X(), -aOffset.Y() ); + aOffsetMode = MapMode( MAP_100TH_MM, aLogicOfs, aHorFract, aZoomFract ); + + Point aTwipsOfs( (long) ( -aOffset.X() / nScaleX + 0.5 ), (long) ( -aOffset.Y() / nScaleY + 0.5 ) ); + aTwipMode = MapMode( MAP_TWIP, aTwipsOfs, aHorFract, aZoomFract ); +} + +//-------------------------------------------------------------------- + +void ScPrintFunc::ApplyPrintSettings() +{ + if ( pPrinter ) + { + // + // Printer zum Drucken umstellen + // + + Size aEnumSize = aPageSize; + if ( bLandscape ) + { + long nTemp = aEnumSize.Width(); + aEnumSize.Width() = aEnumSize.Height(); + aEnumSize.Height() = nTemp; + } + Paper ePaper = SvxPaperInfo::GetSvPaper( aEnumSize, MAP_TWIP, TRUE ); + USHORT nPaperBin = ((const SvxPaperBinItem&)pParamSet->Get(ATTR_PAGE_PAPERBIN)).GetValue(); + + pPrinter->SetPaper( ePaper ); + if ( PAPER_USER == ePaper ) + { + MapMode aPrinterMode = pPrinter->GetMapMode(); + MapMode aLocalMode( MAP_TWIP ); + pPrinter->SetMapMode( aLocalMode ); + pPrinter->SetPaperSizeUser( aEnumSize ); + pPrinter->SetMapMode( aPrinterMode ); + } + pPrinter->SetPaperBin( nPaperBin ); + pPrinter->SetOrientation( bLandscape ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT ); + } +} + +//-------------------------------------------------------------------- +// rPageRanges = Range fuer alle Tabellen +// nStartPage = in rPageRanges beginnen bei nStartPage +// nDisplayStart = lfd. Nummer fuer Anzeige der Seitennummer + +long ScPrintFunc::DoPrint( const MultiSelection& rPageRanges, + long nStartPage, long nDisplayStart, + SfxProgress* pProgress ) +{ + DBG_ASSERT(pDev,"Device == NULL"); + if (!pParamSet) + return 0; + + if ( pPrinter ) + ApplyPrintSettings(); + + //-------------------------------------------------------------------- + + InitModes(); + + MakeTableString(); + + if ( pProgress ) + pProgress->SetText( String( ScResId( SCSTR_STAT_PRINT ) ) ); + + //-------------------------------------------------------------------- + + long nPageNo = 0; + long nPrinted = 0; + long nEndPage = rPageRanges.GetTotalRange().Max(); + + USHORT nRepeats = 1; // wie oft durchgehen ? + if (bMultiArea) + nRepeats = pDoc->GetPrintRangeCount(nPrintTab); + for (USHORT nStep=0; nStep<nRepeats; nStep++) + { + if (bMultiArea) // Bereich neu belegen ? + { + CalcZoom(nStep); // setzt auch nStartCol etc. neu + InitModes(); + } + + USHORT nX1; + USHORT nY1; + USHORT nX2; + USHORT nY2; + USHORT nCountX; + USHORT nCountY; + + if (aTableParam.bTopDown) // von oben nach unten + { + nX1 = nStartCol; + for (nCountX=0; nCountX<nPagesX; nCountX++) + { + nX2 = pPageEndX[nCountX]; + for (nCountY=0; nCountY<nPagesY; nCountY++) + { + nY1 = pPageRows[nCountY].GetStartRow(); + nY2 = pPageRows[nCountY].GetEndRow(); + if ( !aTableParam.bSkipEmpty || !pPageRows[nCountY].IsHidden(nCountX) ) + { + if ( rPageRanges.IsSelected( nPageNo+nStartPage+1 ) ) + { + // PrintPage( nPageNo+nStartPage, nX1, nY1, nX2, nY2 ); + PrintPage( nPageNo+nDisplayStart, nX1, nY1, nX2, nY2 ); + + if ( pProgress ) + { + pProgress->SetState( nPageNo+nStartPage+1, nEndPage ); + pProgress->Reschedule(); //Mag der Anwender noch oder hat er genug? + } + ++nPrinted; + } + ++nPageNo; + } + } + nX1 = nX2 + 1; + } + } + else // von links nach rechts + { + for (nCountY=0; nCountY<nPagesY; nCountY++) + { + nY1 = pPageRows[nCountY].GetStartRow(); + nY2 = pPageRows[nCountY].GetEndRow(); + nX1 = nStartCol; + for (nCountX=0; nCountX<nPagesX; nCountX++) + { + nX2 = pPageEndX[nCountX]; + if ( !aTableParam.bSkipEmpty || !pPageRows[nCountY].IsHidden(nCountX) ) + { + if ( rPageRanges.IsSelected( nPageNo+nStartPage+1 ) ) + { + // PrintPage( nPageNo+nStartPage, nX1, nY1, nX2, nY2 ); + PrintPage( nPageNo+nDisplayStart, nX1, nY1, nX2, nY2 ); + + if ( pProgress ) + { + pProgress->SetState( nPageNo+nStartPage+1, nEndPage ); + pProgress->Reschedule(); //Mag der Anwender noch oder hat er genug? + } + ++nPrinted; + } + ++nPageNo; + } + nX1 = nX2 + 1; + } + } + } + } + + aFieldData.aTabName = ScGlobal::GetRscString( STR_NOTES ); + + long nNoteNr = 0; + long nNoteAdd; + do + { + if ( nPageNo+nStartPage <= nEndPage ) + { + BOOL bPageSelected = rPageRanges.IsSelected( nPageNo+nStartPage+1 ); + nNoteAdd = PrintNotes( nPageNo+nStartPage, nNoteNr, bPageSelected ); + if ( nNoteAdd ) + { + nNoteNr += nNoteAdd; + if ( pProgress && bPageSelected ) + { + pProgress->SetState( nPageNo+nStartPage+1, nEndPage ); + pProgress->Reschedule(); //Mag der Anwender noch oder hat er genug? + } + if (bPageSelected) + ++nPrinted; + ++nPageNo; + } + } + else + nNoteAdd = 0; + } + while (nNoteAdd); + + if ( bMultiArea ) + ResetBreaks(nPrintTab); // Breaks fuer Anzeige richtig + + return nPrinted; +} + +void ScPrintFunc::CalcZoom( USHORT nRangeNo ) // Zoom berechnen +{ + USHORT nRCount = pDoc->GetPrintRangeCount( nPrintTab ); + const ScRange* pThisRange = NULL; + if ( nRangeNo != RANGENO_NORANGE || nRangeNo < nRCount ) + pThisRange = pDoc->GetPrintRange( nPrintTab, nRangeNo ); + if ( pThisRange ) + { + nStartCol = pThisRange->aStart.Col(); + nStartRow = pThisRange->aStart.Row(); + nEndCol = pThisRange->aEnd .Col(); + nEndRow = pThisRange->aEnd .Row(); + } + + if (!AdjustPrintArea(FALSE)) // leer + { + nZoom = 100; + nPagesX = nPagesY = nTotalY = 0; + return; + } + + pDoc->SetRepeatArea( nPrintTab, nRepeatStartCol,nRepeatEndCol, nRepeatStartRow,nRepeatEndRow ); + + if (aTableParam.bScalePageNum) + { + nZoom = 100; + BOOL bFound = FALSE; + USHORT nPagesToFit = aTableParam.nScalePageNum; + while (!bFound) + { + CalcPages(); + if ( nPagesX * nPagesY <= nPagesToFit || nZoom <= ZOOM_MIN ) + bFound = TRUE; + else + --nZoom; + } + } + else if (aTableParam.bScaleAll) + { + nZoom = aTableParam.nScaleAll; + if ( nZoom <= ZOOM_MIN ) + nZoom = ZOOM_MIN; + CalcPages(); + } + else + { + DBG_ASSERT( aTableParam.bScaleNone, "kein Scale-Flag gesetzt" ); + nZoom = 100; + CalcPages(); + } +} + +Size ScPrintFunc::GetDocPageSize() +{ + // Hoehe Kopf-/Fusszeile anpassen + + InitModes(); // aTwipMode aus nZoom initialisieren + pDev->SetMapMode( aTwipMode ); // Kopf-/Fusszeilen in Twips + UpdateHFHeight( aHdr ); + UpdateHFHeight( aFtr ); + + // Seitengroesse in Document-Twips + // Berechnung Left / Right auch in PrintPage + + aPageRect = Rectangle( Point(), aPageSize ); + aPageRect.Left() = ( aPageRect.Left() + nLeftMargin ) * 100 / nZoom; + aPageRect.Right() = ( aPageRect.Right() - nRightMargin ) * 100 / nZoom; + aPageRect.Top() = ( aPageRect.Top() + nTopMargin ) * 100 / nZoom + aHdr.nHeight; + aPageRect.Bottom() = ( aPageRect.Bottom() - nBottomMargin ) * 100 / nZoom - aFtr.nHeight; + + Size aDocPageSize = aPageRect.GetSize(); + if (aTableParam.bHeaders) + { + aDocPageSize.Width() -= (long) PRINT_HEADER_WIDTH; + aDocPageSize.Height() -= (long) PRINT_HEADER_HEIGHT; + } + if (pBorderItem) + { + aDocPageSize.Width() -= lcl_LineTotal(pBorderItem->GetLeft()) + + lcl_LineTotal(pBorderItem->GetRight()) + + 2 * pBorderItem->GetDistance(); + aDocPageSize.Height() -= lcl_LineTotal(pBorderItem->GetTop()) + + lcl_LineTotal(pBorderItem->GetBottom()) + + 2 * pBorderItem->GetDistance(); + } + if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE) + { + aDocPageSize.Width() -= pShadowItem->CalcShadowSpace(SHADOW_LEFT) + + pShadowItem->CalcShadowSpace(SHADOW_RIGHT); + aDocPageSize.Height() -= pShadowItem->CalcShadowSpace(SHADOW_TOP) + + pShadowItem->CalcShadowSpace(SHADOW_BOTTOM); + } + return aDocPageSize; +} + +void ScPrintFunc::ResetBreaks( USHORT nTab ) // Breaks fuer Anzeige richtig setzen +{ + pDoc->SetPageSize( nTab, GetDocPageSize() ); + pDoc->UpdatePageBreaks( nTab, NULL ); +} + +void lcl_SetHidden( ScDocument* pDoc, USHORT nPrintTab, ScPageRowEntry& rPageRowEntry, + USHORT nStartCol, const USHORT* pPageEndX ) +{ + USHORT nPagesX = rPageRowEntry.GetPagesX(); + USHORT nStartRow = rPageRowEntry.GetStartRow(); + USHORT nEndRow = rPageRowEntry.GetEndRow(); + + BOOL bLeftIsEmpty = FALSE; + ScRange aTempRange; + Rectangle aTempRect = pDoc->GetMMRect( 0,0, 0,0, 0 ); + + for (USHORT i=0; i<nPagesX; i++) + { + USHORT nEndCol = pPageEndX[i]; + if ( pDoc->IsPrintEmpty( nPrintTab, nStartCol, nStartRow, nEndCol, nEndRow, + bLeftIsEmpty, &aTempRange, &aTempRect ) ) + { + rPageRowEntry.SetHidden(i); + bLeftIsEmpty = TRUE; + } + else + bLeftIsEmpty = FALSE; + + nStartCol = nEndCol+1; + } +} + +void ScPrintFunc::CalcPages() // berechnet aPageRect und Seiten aus nZoom +{ + if (!pPageEndX) pPageEndX = new USHORT[MAXCOL+1]; + if (!pPageEndY) pPageEndY = new USHORT[MAXROW+1]; + if (!pPageRows) pPageRows = new ScPageRowEntry[MAXROW+1]; //! vorher zaehlen !!!! + + pDoc->SetPageSize( nPrintTab, GetDocPageSize() ); + if (aAreaParam.bPrintArea) + { + ScRange aRange( nStartCol, nStartRow, nPrintTab, nEndCol, nEndRow, nPrintTab ); + pDoc->UpdatePageBreaks( nPrintTab, &aRange ); + } + else + pDoc->UpdatePageBreaks( nPrintTab, NULL ); // sonst wird das Ende markiert + + // + // Seiteneinteilung nach Umbruechen in Col/RowFlags + // Von mehreren Umbruechen in einem ausgeblendeten Bereich zaehlt nur einer. + // + + USHORT i; + nPagesX = 0; + nPagesY = 0; + nTotalY = 0; + + BOOL bVisCol = FALSE; + for (i=nStartCol; i<=nEndCol; i++) + { + BYTE nFlags = pDoc->GetColFlags(i,nPrintTab); + if ( i>nStartCol && bVisCol && (nFlags & CR_PAGEBREAK) ) + { + pPageEndX[nPagesX] = i-1; + ++nPagesX; + bVisCol = FALSE; + } + if (!(nFlags & CR_HIDDEN)) + bVisCol = TRUE; + } + if (bVisCol) // auch am Ende keine leeren Seiten + { + pPageEndX[nPagesX] = nEndCol; + ++nPagesX; + } + + BOOL bVisRow = FALSE; + USHORT nPageStartRow = nStartRow; + for (i=nStartRow; i<=nEndRow; i++) + { + BYTE nFlags = pDoc->GetRowFlags(i,nPrintTab); + if ( i>nStartRow && bVisRow && (nFlags & CR_PAGEBREAK) ) + { + pPageEndY[nTotalY] = i-1; + ++nTotalY; + + if ( !aTableParam.bSkipEmpty || + !pDoc->IsPrintEmpty( nPrintTab, nStartCol, nPageStartRow, nEndCol, i-1 ) ) + { + pPageRows[nPagesY].SetStartRow( nPageStartRow ); + pPageRows[nPagesY].SetEndRow( i-1 ); + pPageRows[nPagesY].SetPagesX( nPagesX ); + if (aTableParam.bSkipEmpty) + lcl_SetHidden( pDoc, nPrintTab, pPageRows[nPagesY], nStartCol, pPageEndX ); + ++nPagesY; + } + + nPageStartRow = i; + bVisRow = FALSE; + } + if (!(nFlags & CR_HIDDEN)) + bVisRow = TRUE; + } + if (bVisRow) + { + pPageEndY[nTotalY] = nEndRow; + ++nTotalY; + + if ( !aTableParam.bSkipEmpty || + !pDoc->IsPrintEmpty( nPrintTab, nStartCol, nPageStartRow, nEndCol, nEndRow ) ) + { + pPageRows[nPagesY].SetStartRow( nPageStartRow ); + pPageRows[nPagesY].SetEndRow( nEndRow ); + pPageRows[nPagesY].SetPagesX( nPagesX ); + if (aTableParam.bSkipEmpty) + lcl_SetHidden( pDoc, nPrintTab, pPageRows[nPagesY], nStartCol, pPageEndX ); + ++nPagesY; + } + } +} + +//------------------------------------------------------------------------ +// class ScJobSetup +//------------------------------------------------------------------------ + +ScJobSetup::ScJobSetup( SfxPrinter* pPrinter ) +{ + eOrientation = pPrinter->GetOrientation(); + nPaperBin = pPrinter->GetPaperBin(); + ePaper = pPrinter->GetPaper(); + + if ( PAPER_USER == ePaper ) + { + aUserSize = pPrinter->GetPaperSize(); + aUserMapMode = pPrinter->GetMapMode(); + } +}; + + + + + diff --git a/sc/source/ui/view/reffact.cxx b/sc/source/ui/view/reffact.cxx new file mode 100644 index 000000000000..4d0f3f834927 --- /dev/null +++ b/sc/source/ui/view/reffact.cxx @@ -0,0 +1,373 @@ +/************************************************************************* + * + * $RCSfile: reffact.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include <sfx2/basedlgs.hxx> +#include <sfx2/viewfrm.hxx> + +#include "reffact.hxx" +#include "tabvwsh.hxx" +#include "sc.hrc" +#include "acredlin.hxx" +#include "simpref.hxx" +#include "scmod.hxx" + +// ----------------------------------------------------------------------- + +SFX_IMPL_MODELESSDIALOG(ScNameDlgWrapper, FID_DEFINE_NAME ) +SFX_IMPL_MODELESSDIALOG(ScSolverDlgWrapper, SID_OPENDLG_SOLVE ) +SFX_IMPL_MODELESSDIALOG(ScPivotLayoutWrapper, SID_OPENDLG_PIVOTTABLE ) +SFX_IMPL_MODELESSDIALOG(ScTabOpDlgWrapper, SID_OPENDLG_TABOP ) +SFX_IMPL_MODELESSDIALOG(ScFilterDlgWrapper, SID_FILTER ) +SFX_IMPL_MODELESSDIALOG(ScSpecialFilterDlgWrapper, SID_SPECIAL_FILTER ) +SFX_IMPL_MODELESSDIALOG(ScDbNameDlgWrapper, SID_DEFINE_DBNAME ) +SFX_IMPL_MODELESSDIALOG(ScConsolidateDlgWrapper, SID_OPENDLG_CONSOLIDATE ) +SFX_IMPL_MODELESSDIALOG(ScChartDlgWrapper, SID_OPENDLG_CHART ) +SFX_IMPL_MODELESSDIALOG(ScPrintAreasDlgWrapper, SID_OPENDLG_EDIT_PRINTAREA ) +SFX_IMPL_MODELESSDIALOG(ScCondFormatDlgWrapper, SID_OPENDLG_CONDFRMT ) +SFX_IMPL_MODELESSDIALOG(ScColRowNameRangesDlgWrapper, SID_DEFINE_COLROWNAMERANGES ) +SFX_IMPL_MODELESSDIALOG(ScFormulaDlgWrapper, SID_OPENDLG_FUNCTION ) +SFX_IMPL_MODELESSDIALOG(ScAcceptChgDlgWrapper, FID_CHG_ACCEPT ) +SFX_IMPL_MODELESSDIALOG(ScHighlightChgDlgWrapper, FID_CHG_SHOW ) +SFX_IMPL_MODELESSDIALOG(ScSimpleRefDlgWrapper, WID_SIMPLE_REF ) +/*!!! dafuer muss der Funktionsautopilot noch umgebaut werden +SFX_IMPL_CHILDWINDOW(ScFunctionDlgWrapper, SID_OPENDLG_FUNCTION ) +SFX_IMPL_CHILDWINDOW(ScEditFunctionDlgWrapper, SID_OPENDLG_EDITFUNCTION ) +SFX_IMPL_CHILDWINDOW(ScArgumentDlgWrapper, SID_OPENDLG_ARGUMENT ) +*/ + +#define IMPL_CHILD_CTOR(Class,sid) \ + Class::Class( Window* pParent, \ + USHORT nId, \ + SfxBindings* p, \ + SfxChildWinInfo* pInfo ) \ + : SfxChildWindow(pParent, nId) \ + { \ + ScTabViewShell* pViewShell = \ + PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); \ + DBG_ASSERT( pViewShell, "missing view shell :-(" ); \ + pWindow = pViewShell ? \ + pViewShell->CreateRefDialog( p, this, pInfo, pParent, sid ) : NULL; \ + if (pViewShell && !pWindow) \ + pViewShell->GetViewFrame()->SetChildWindow( nId, FALSE ); \ + } + + +//========================================================================= + +//------------------------------------------------------------------------- +// ScNameDlgWrapper +//------------------------------------------------------------------------- + +IMPL_CHILD_CTOR( ScNameDlgWrapper, FID_DEFINE_NAME ) + +//------------------------------------------------------------------------- +// ScSolverDlgWrapper +//------------------------------------------------------------------------- + +IMPL_CHILD_CTOR( ScSolverDlgWrapper, SID_OPENDLG_SOLVE ) + +//------------------------------------------------------------------------- +// ScPivotLayoutWrapper +//------------------------------------------------------------------------- + +IMPL_CHILD_CTOR( ScPivotLayoutWrapper, SID_OPENDLG_PIVOTTABLE ) + +//------------------------------------------------------------------------- +// ScTabOpDlgWrapper +//------------------------------------------------------------------------- + +IMPL_CHILD_CTOR( ScTabOpDlgWrapper, SID_OPENDLG_TABOP ) + +//------------------------------------------------------------------------- +// ScFilterDlgWrapper +//------------------------------------------------------------------------- + +IMPL_CHILD_CTOR( ScFilterDlgWrapper, SID_FILTER ) + +//------------------------------------------------------------------------- +// ScSpecialFilterDlgWrapper +//------------------------------------------------------------------------- + +IMPL_CHILD_CTOR( ScSpecialFilterDlgWrapper, SID_SPECIAL_FILTER ) + +//------------------------------------------------------------------------- +// ScDbNameDlgWrapper +//------------------------------------------------------------------------- + +IMPL_CHILD_CTOR( ScDbNameDlgWrapper, SID_DEFINE_DBNAME ) + +//------------------------------------------------------------------------- +// ScColRowNameRangesDlgWrapper +//------------------------------------------------------------------------- + +IMPL_CHILD_CTOR( ScColRowNameRangesDlgWrapper, SID_DEFINE_COLROWNAMERANGES ) + +//------------------------------------------------------------------------- +// ScConsolidateDlgWrapper +//------------------------------------------------------------------------- + +IMPL_CHILD_CTOR( ScConsolidateDlgWrapper, SID_OPENDLG_CONSOLIDATE ) + +//------------------------------------------------------------------------- +// ScChartDlgWrapper +//------------------------------------------------------------------------- + +IMPL_CHILD_CTOR( ScChartDlgWrapper, SID_OPENDLG_CHART ) + +//------------------------------------------------------------------------- +// ScPrintAreasDlgWrapper +//------------------------------------------------------------------------- + +IMPL_CHILD_CTOR( ScPrintAreasDlgWrapper, SID_OPENDLG_EDIT_PRINTAREA ) + +//------------------------------------------------------------------------- +// ScCondFormatDlgWrapper +//------------------------------------------------------------------------- + +IMPL_CHILD_CTOR( ScCondFormatDlgWrapper, SID_OPENDLG_CONDFRMT ) + +//------------------------------------------------------------------------- +// ScFormulaDlgWrapper +//------------------------------------------------------------------------- + +IMPL_CHILD_CTOR( ScFormulaDlgWrapper, SID_OPENDLG_FUNCTION ) + + +//------------------------------------------------------------------------- +// ScSimpleRefDlgWrapper +//------------------------------------------------------------------------- + +static BOOL bScSimpleRefFlag; +static long nScSimpleRefHeight; +static long nScSimpleRefWidth; +static long nScSimpleRefX; +static long nScSimpleRefY; +static BOOL bAutoReOpen=TRUE; + +ScSimpleRefDlgWrapper::ScSimpleRefDlgWrapper( Window* pParent, + USHORT nId, + SfxBindings* p, + SfxChildWinInfo* pInfo ) + : SfxChildWindow(pParent, nId) +{ + ScTabViewShell* pViewShell = + PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); + DBG_ASSERT( pViewShell, "missing view shell :-(" ); + + if(pInfo!=NULL && bScSimpleRefFlag) + { + pInfo->aPos.X()=nScSimpleRefX; + pInfo->aPos.Y()=nScSimpleRefY; + pInfo->aSize.Height()=nScSimpleRefHeight; + pInfo->aSize.Width()=nScSimpleRefWidth; + } + pWindow = NULL; + + if(bAutoReOpen) + pWindow = pViewShell->CreateRefDialog( p, this, pInfo, pParent, WID_SIMPLE_REF); + + if (!pWindow) + { + SC_MOD()->SetRefDialog( nId, FALSE ); + } +} + +void ScSimpleRefDlgWrapper::SetDefaultPosSize(Point aPos, Size aSize, BOOL bSet) +{ + bScSimpleRefFlag=bSet; + if(bScSimpleRefFlag) + { + nScSimpleRefX=aPos.X(); + nScSimpleRefY=aPos.Y(); + nScSimpleRefHeight=aSize.Height(); + nScSimpleRefWidth=aSize.Width(); + } +} + + +String ScSimpleRefDlgWrapper::GetRefString() +{ + String aResult; + ScTabViewShell* pViewShell = + PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); + DBG_ASSERT( pViewShell, "missing view shell :-(" ); + + if(pWindow!=NULL) + { + aResult=((ScSimpleRefDlg*)pWindow)->GetRefString(); + } + return aResult; +} + +void ScSimpleRefDlgWrapper::SetAutoReOpen(BOOL bFlag) +{ + bAutoReOpen=bFlag; +} + +void ScSimpleRefDlgWrapper::SetRefString(const String& rStr) +{ + ScTabViewShell* pViewShell = + PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); + DBG_ASSERT( pViewShell, "missing view shell :-(" ); + + if(pWindow!=NULL) + { + ((ScSimpleRefDlg*)pWindow)->SetRefString(rStr); + } +} + +void ScSimpleRefDlgWrapper::SetCloseHdl( const Link& rLink ) +{ + ScTabViewShell* pViewShell = + PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); + DBG_ASSERT( pViewShell, "missing view shell :-(" ); + + if(pWindow!=NULL) + { + ((ScSimpleRefDlg*)pWindow)->SetCloseHdl(rLink ); + } +} + +void ScSimpleRefDlgWrapper::StartRefInput() +{ + ScTabViewShell* pViewShell = + PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); + DBG_ASSERT( pViewShell, "missing view shell :-(" ); + + if(pWindow!=NULL) + { + ((ScSimpleRefDlg*)pWindow)->StartRefInput(); + } +} + + + +//------------------------------------------------------------------------- +// ScAcceptChgDlgWrapper //Kommentar: sollte in die ViewShell +//------------------------------------------------------------------------- + +ScAcceptChgDlgWrapper::ScAcceptChgDlgWrapper( Window* pParent, + USHORT nId, + SfxBindings* pBindings, + SfxChildWinInfo* pInfo ) : + SfxChildWindow( pParent, nId ) +{ + ScTabViewShell* pViewShell = + PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); + DBG_ASSERT( pViewShell, "missing view shell :-(" ); + pWindow = new ScAcceptChgDlg( pBindings, this, pParent, pViewShell->GetViewData() ); + if(pWindow!=NULL) + { + ((ScAcceptChgDlg*)pWindow)->Initialize( pInfo ); + } + if (pViewShell && !pWindow) + pViewShell->GetViewFrame()->SetChildWindow( nId, FALSE ); +} + +void ScAcceptChgDlgWrapper::ReInitDlg() +{ + ScTabViewShell* pViewShell = + PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); + DBG_ASSERT( pViewShell, "missing view shell :-(" ); + + if(pWindow!=NULL) + { + ((ScAcceptChgDlg*)pWindow)->ReInit(pViewShell->GetViewData()); + } +} + +//------------------------------------------------------------------------- +// ScHighlightChgDlgWrapper +//------------------------------------------------------------------------- + +IMPL_CHILD_CTOR( ScHighlightChgDlgWrapper, FID_CHG_SHOW ) + +/*------------------------------------------------------------------------*/ +/*@@@ + //------------------------------------------------------------------------- + // ScFunctionDlgWrapper + //------------------------------------------------------------------------- + + IMPL_CHILD_CTOR( ScFunctionDlgWrapper, SID_OPENDLG_FUNCTION ) + + //------------------------------------------------------------------------- + // ScEditFunctionDlgWrapper + //------------------------------------------------------------------------- + + IMPL_CHILD_CTOR( ScEditFunctionDlgWrapper, SID_OPENDLG_EDITFUNCTION ) + + //------------------------------------------------------------------------- + // ScArgumentDlgWrapper + //------------------------------------------------------------------------- + + IMPL_CHILD_CTOR( ScArgumentDlgWrapper, SID_OPENDLG_ARGUMENT ) +@@@*/ +/*------------------------------------------------------------------------*/ + + diff --git a/sc/source/ui/view/select.cxx b/sc/source/ui/view/select.cxx new file mode 100644 index 000000000000..eca17d1e2428 --- /dev/null +++ b/sc/source/ui/view/select.cxx @@ -0,0 +1,848 @@ +/************************************************************************* + * + * $RCSfile: select.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include <vcl/sound.hxx> + +#include "select.hxx" +#include "sc.hrc" +#include "tabvwsh.hxx" +#include "scmod.hxx" +#include "document.hxx" +#include "dataobj.hxx" + +extern USHORT nScFillModeMouseModifier; // global.cxx + +// STATIC DATA ----------------------------------------------------------- + +static Point aSwitchPos; //! Member +static BOOL bDidSwitch = FALSE; + +// ----------------------------------------------------------------------- + +// +// View (Gridwin / Tastatur) +// + +ScViewFunctionSet::ScViewFunctionSet( ScViewData* pNewViewData ) : + pViewData( pNewViewData ), + pEngine( NULL ), + bAnchor( FALSE ), + bStarted( FALSE ) +{ + DBG_ASSERT(pViewData, "ViewData==0 bei FunctionSet"); +} + +ScSplitPos ScViewFunctionSet::GetWhich() +{ + if (pEngine) + return pEngine->GetWhich(); + else + return pViewData->GetActivePart(); +} + +void ScViewFunctionSet::SetSelectionEngine( ScViewSelectionEngine* pSelEngine ) +{ + pEngine = pSelEngine; +} + +// Drag & Drop + +void __EXPORT ScViewFunctionSet::BeginDrag() +{ + USHORT nTab = pViewData->GetTabNo(); + + short nPosX; + short nPosY; + if (pEngine) + { + Point aMPos = pEngine->GetMousePosPixel(); + pViewData->GetPosFromPixel( aMPos.X(), aMPos.Y(), GetWhich(), nPosX, nPosY ); + } + else + { + nPosX = pViewData->GetCurX(); + nPosY = pViewData->GetCurY(); + } + + ScModule* pScMod = SC_MOD(); + BOOL bRefMode = pScMod->IsFormulaMode(); + if (!bRefMode) + { + pViewData->GetView()->FakeButtonUp( GetWhich() ); // ButtonUp wird verschluckt + + ScMarkData& rMark = pViewData->GetMarkData(); +// rMark.SetMarking(FALSE); // es fehlt ein ButtonUp + rMark.MarkToSimple(); + if ( rMark.IsMarked() && !rMark.IsMultiMarked() ) + { + ScDocument* pDoc = pViewData->GetDocument(); + ScRange aMarkRange; + rMark.GetMarkArea( aMarkRange ); + USHORT nStartX = aMarkRange.aStart.Col(); // Block + USHORT nStartY = aMarkRange.aStart.Row(); + USHORT nEndX = aMarkRange.aEnd.Col(); + USHORT nEndY = aMarkRange.aEnd.Row(); + USHORT nHandleX = (nPosX >= (short) nStartX) ? nPosX - nStartX : 0; + USHORT nHandleY = (nPosY >= (short) nStartY) ? nPosY - nStartY : 0; + + pScMod->SetDragObject( rMark,ScRange( nStartX,nStartY,nTab,nEndX,nEndY,nTab ), + nHandleX, nHandleY, pDoc, 0 ); + + Region aRegion = pDoc->GetMMRect( nStartX,nStartY, nEndX,nEndY, nTab ); + + SvDataObjectRef pDragServer = new ScDataObject( pDoc, FALSE, + pViewData->GetDocShell(), NULL, &aMarkRange ); + DropAction eAction = pDragServer->ExecuteDrag(pViewData->GetActiveWin(), + POINTER_MOVEDATA, POINTER_COPYDATA, POINTER_LINKDATA, + DRAG_ALL, &aRegion ); + BOOL bIntern = pScMod->GetDragIntern(); + + pScMod->ResetDragObject(); + + switch (eAction) + { + case DROP_MOVE: + case DROP_DISCARD: + if (!bIntern) + { + ScViewFunc* pView = pViewData->GetView(); + pView->DoneBlockMode(); + pView->MoveCursorAbs( nStartX, nStartY, SC_FOLLOW_JUMP, FALSE, FALSE ); + pView->InitOwnBlockMode(); + rMark.SetMarkArea( ScRange( nStartX,nStartY,nTab, nEndX,nEndY,nTab ) ); + pView->DeleteContents( IDF_ALL ); + } + break; + default: + break; + } + + return; // Dragging passiert + } + } + + Sound::Beep(); // kein Dragging +} + +// Selektion + +void __EXPORT ScViewFunctionSet::CreateAnchor() +{ + if (bAnchor) return; + + BOOL bRefMode = SC_MOD()->IsFormulaMode(); + if (bRefMode) + SetAnchor( pViewData->GetRefStartX(), pViewData->GetRefStartY() ); + else + SetAnchor( pViewData->GetCurX(), pViewData->GetCurY() ); +} + +void ScViewFunctionSet::SetAnchor( USHORT nPosX, USHORT nPosY ) +{ + BOOL bRefMode = SC_MOD()->IsFormulaMode(); + ScTabView* pView = pViewData->GetView(); + USHORT nTab = pViewData->GetTabNo(); + + if (bRefMode) + { + pView->DoneRefMode( FALSE ); + aAnchorPos.Put( nPosX, nPosY, nTab ); + pView->InitRefMode( aAnchorPos.GetCol(), aAnchorPos.GetRow(), aAnchorPos.GetTab(), + SC_REFTYPE_REF ); + bStarted = TRUE; + } + else if (pViewData->IsAnyFillMode()) + { + aAnchorPos.Put( nPosX, nPosY, nTab ); + bStarted = TRUE; + } + else + { + // nicht weg und gleich wieder hin + if ( bStarted && pView->IsMarking( nPosX, nPosY, nTab ) ) + { + // nix + } + else + { + pView->DoneBlockMode( TRUE ); + aAnchorPos.Put( nPosX, nPosY, nTab ); + ScMarkData& rMark = pViewData->GetMarkData(); + if ( rMark.IsMarked() || rMark.IsMultiMarked() ) + { + pView->InitBlockMode( aAnchorPos.GetCol(), aAnchorPos.GetRow(), + aAnchorPos.GetTab(), TRUE ); + bStarted = TRUE; + } + else + bStarted = FALSE; + } + } + bAnchor = TRUE; +} + +void __EXPORT ScViewFunctionSet::DestroyAnchor() +{ + BOOL bRefMode = SC_MOD()->IsFormulaMode(); + if (bRefMode) + pViewData->GetView()->DoneRefMode( TRUE ); + else + pViewData->GetView()->DoneBlockMode( TRUE ); + + bAnchor = FALSE; +} + +void ScViewFunctionSet::SetAnchorFlag( BOOL bSet ) +{ + bAnchor = bSet; +} + +BOOL __EXPORT ScViewFunctionSet::SetCursorAtPoint( const Point& rPointPixel, BOOL bDontSelectAtCursor ) +{ + if ( bDidSwitch ) + { + if ( rPointPixel == aSwitchPos ) + return FALSE; // nicht auf falschem Fenster scrollen + else + bDidSwitch = FALSE; + } + aSwitchPos = rPointPixel; // nur wichtig, wenn bDidSwitch + + // Scrolling + + Size aWinSize = pEngine->GetWindow()->GetOutputSizePixel(); + BOOL bRightScroll = ( rPointPixel.X() >= aWinSize.Width() ); + BOOL bBottomScroll = ( rPointPixel.Y() >= aWinSize.Height() ); + BOOL bNegScroll = ( rPointPixel.X() < 0 || rPointPixel.Y() < 0 ); + BOOL bScroll = bRightScroll || bBottomScroll || bNegScroll; + + short nPosX; + short nPosY; + pViewData->GetPosFromPixel( rPointPixel.X(), rPointPixel.Y(), GetWhich(), + nPosX, nPosY, TRUE, TRUE ); // mit Repair + + // fuer AutoFill in der Mitte der Zelle umschalten + // dabei aber nicht das Scrolling nach rechts/unten verhindern + if ( pViewData->IsFillMode() || pViewData->GetFillMode() == SC_FILL_MATRIX ) + { + BOOL bLeft, bTop; + pViewData->GetMouseQuadrant( rPointPixel, GetWhich(), nPosX, nPosY, bLeft, bTop ); + ScDocument* pDoc = pViewData->GetDocument(); + USHORT nTab = pViewData->GetTabNo(); + if ( bLeft && !bRightScroll ) + do --nPosX; while ( nPosX>=0 && ( pDoc->GetColFlags( nPosX, nTab ) & CR_HIDDEN ) ); + if ( bTop && !bBottomScroll ) + do --nPosY; while ( nPosY>=0 && ( pDoc->GetRowFlags( nPosY, nTab ) & CR_HIDDEN ) ); + // negativ ist erlaubt + } + + // ueber Fixier-Grenze bewegt? + + ScSplitPos eWhich = GetWhich(); + if ( eWhich == pViewData->GetActivePart() ) + { + if ( pViewData->GetHSplitMode() == SC_SPLIT_FIX ) + if ( rPointPixel.X() >= aWinSize.Width() ) + { + if ( eWhich == SC_SPLIT_TOPLEFT ) + pViewData->GetView()->ActivatePart( SC_SPLIT_TOPRIGHT ), bScroll = FALSE, bDidSwitch = TRUE; + else if ( eWhich == SC_SPLIT_BOTTOMLEFT ) + pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT ), bScroll = FALSE, bDidSwitch = TRUE; + } + + if ( pViewData->GetVSplitMode() == SC_SPLIT_FIX ) + if ( rPointPixel.Y() >= aWinSize.Height() ) + { + if ( eWhich == SC_SPLIT_TOPLEFT ) + pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMLEFT ), bScroll = FALSE, bDidSwitch = TRUE; + else if ( eWhich == SC_SPLIT_TOPRIGHT ) + pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT ), bScroll = FALSE, bDidSwitch = TRUE; + } + } + + pViewData->ResetOldCursor(); + return SetCursorAtCell( nPosX, nPosY, bScroll ); +} + +BOOL ScViewFunctionSet::SetCursorAtCell( short nPosX, short nPosY, BOOL bScroll ) +{ + ScTabView* pView = pViewData->GetView(); + USHORT nTab = pViewData->GetTabNo(); + BOOL bRefMode = SC_MOD()->IsFormulaMode(); + + BOOL bHide = !bRefMode && !pViewData->IsAnyFillMode() && + ( nPosX != (short) pViewData->GetCurX() || nPosY != (short) pViewData->GetCurY() ); + + if (bHide) + pView->HideAllCursors(); + + if (bScroll) + { + if (bRefMode) + { + ScSplitPos eWhich = GetWhich(); + pView->AlignToCursor( nPosX, nPosY, SC_FOLLOW_LINE, &eWhich ); + } + else + pView->AlignToCursor( nPosX, nPosY, SC_FOLLOW_LINE ); + } + + if (bRefMode) + { + if (!bAnchor) + { + pView->DoneRefMode( TRUE ); + pView->InitRefMode( nPosX, nPosY, pViewData->GetTabNo(), SC_REFTYPE_REF ); + } + + pView->UpdateRef( nPosX, nPosY, pViewData->GetTabNo() ); + } + else if (pViewData->IsFillMode() || + (pViewData->GetFillMode() == SC_FILL_MATRIX && (nScFillModeMouseModifier & KEY_MOD1) )) + { + // Wenn eine Matrix angefasst wurde, kann mit Ctrl auf AutoFill zurueckgeschaltet werden + + USHORT nStartX, nStartY, nEndX, nEndY; // Block + USHORT nDummy; + pViewData->GetSimpleArea( nStartX, nStartY, nDummy, nEndX, nEndY, nDummy, FALSE ); + + if (pViewData->GetRefType() != SC_REFTYPE_FILL) + { + pView->InitRefMode( nStartX, nStartY, nTab, SC_REFTYPE_FILL ); + CreateAnchor(); + } + + ScRange aDelRange; + BOOL bOldDelMark = pViewData->GetDelMark( aDelRange ); + ScDocument* pDoc = pViewData->GetDocument(); + + if ( nPosX+1 >= (short) nStartX && nPosX <= (short) nEndX && + nPosY+1 >= (short) nStartY && nPosY <= (short) nEndY && + ( nPosX != nEndX || nPosY != nEndY ) ) // verkleinern ? + { + // Richtung (links oder oben) + + short i; + long nSizeX = 0; + for (i=nPosX+1; i<=nEndX; i++) + nSizeX += pDoc->GetColWidth( i, nTab ); + long nSizeY = 0; + for (i=nPosY+1; i<=nEndY; i++) + nSizeY += pDoc->GetRowHeight( i, nTab ); + + USHORT nDelStartX = nStartX; + USHORT nDelStartY = nStartY; + if ( nSizeX > nSizeY ) + nDelStartX = nPosX + 1; + else + nDelStartY = nPosY + 1; + // 0 braucht nicht mehr getrennt abgefragt zu werden, weil nPosX/Y auch negativ wird + + if ( nDelStartX < nStartX ) + nDelStartX = nStartX; + if ( nDelStartY < nStartY ) + nDelStartY = nStartY; + + // Bereich setzen + + pViewData->SetDelMark( ScRange( nDelStartX,nDelStartY,nTab, + nEndX,nEndY,nTab ) ); + + if ( bOldDelMark ) + { + ScUpdateRect aRect( aDelRange.aStart.Col(), aDelRange.aStart.Row(), + aDelRange.aEnd.Col(), aDelRange.aEnd.Row() ); + aRect.SetNew( nDelStartX,nDelStartY, nEndX,nEndY ); + USHORT nPaintStartX; + USHORT nPaintStartY; + USHORT nPaintEndX; + USHORT nPaintEndY; + if (aRect.GetDiff( nPaintStartX, nPaintStartY, nPaintEndX, nPaintEndY )) + pViewData->GetView()-> + PaintArea( nPaintStartX, nPaintStartY, + nPaintEndX, nPaintEndY, SC_UPDATE_MARKS ); + } + else + pViewData->GetView()-> + PaintArea( nStartX,nDelStartY, nEndX,nEndY, SC_UPDATE_MARKS ); + + nPosX = nEndX; // roten Rahmen um ganzen Bereich lassen + nPosY = nEndY; + + // Referenz wieder richtigherum, falls unten umgedreht + if ( nStartX != pViewData->GetRefStartX() || nStartY != pViewData->GetRefStartY() ) + { + pViewData->GetView()->DoneRefMode(); + pViewData->GetView()->InitRefMode( nStartX, nStartY, nTab, SC_REFTYPE_FILL ); + } + } + else + { + if ( bOldDelMark ) + { + pViewData->ResetDelMark(); + pViewData->GetView()-> + PaintArea( aDelRange.aStart.Col(), aDelRange.aStart.Row(), + aDelRange.aEnd.Col(), aDelRange.aEnd.Row(), SC_UPDATE_MARKS ); + } + + BOOL bNegX = ( nPosX < (short) nStartX ); + BOOL bNegY = ( nPosY < (short) nStartY ); + short i; + + long nSizeX = 0; + if ( bNegX ) + { + ++nPosX; + for (i=nPosX; i<nStartX; i++) + nSizeX += pDoc->GetColWidth( i, nTab ); + } + else + for (i=nEndX+1; i<=nPosX; i++) + nSizeX += pDoc->GetColWidth( i, nTab ); + + long nSizeY = 0; + if ( bNegY ) + { + ++nPosY; + for (i=nPosY; i<nStartY; i++) + nSizeY += pDoc->GetRowHeight( i, nTab ); + } + else + for (i=nEndY+1; i<=nPosY; i++) + nSizeY += pDoc->GetRowHeight( i, nTab ); + + if ( nSizeX > nSizeY ) // Fill immer nur in einer Richtung + { + nPosY = nEndY; + bNegY = FALSE; + } + else + { + nPosX = nEndX; + bNegX = FALSE; + } + + USHORT nRefStX = bNegX ? nEndX : nStartX; + USHORT nRefStY = bNegY ? nEndY : nStartY; + if ( nRefStX != pViewData->GetRefStartX() || nRefStY != pViewData->GetRefStartY() ) + { + pViewData->GetView()->DoneRefMode(); + pViewData->GetView()->InitRefMode( nRefStX, nRefStY, nTab, SC_REFTYPE_FILL ); + } + } + + pView->UpdateRef( nPosX, nPosY, nTab ); + } + else if (pViewData->IsAnyFillMode()) + { + BYTE nMode = pViewData->GetFillMode(); + if ( nMode == SC_FILL_EMBED_LT || nMode == SC_FILL_EMBED_RB ) + { + ScDocument* pDoc = pViewData->GetDocument(); + DBG_ASSERT( pDoc->IsEmbedded(), "!pDoc->IsEmbedded()" ); + ScTripel aStart; + ScTripel aEnd; + pDoc->GetEmbedded( aStart, aEnd ); + ScRefType eRefMode = (nMode == SC_FILL_EMBED_LT) ? SC_REFTYPE_EMBED_LT : SC_REFTYPE_EMBED_RB; + if (pViewData->GetRefType() != eRefMode) + { + if ( nMode == SC_FILL_EMBED_LT ) + pView->InitRefMode( aEnd.GetCol(), aEnd.GetRow(), nTab, eRefMode ); + else + pView->InitRefMode( aStart.GetCol(), aStart.GetRow(), nTab, eRefMode ); + CreateAnchor(); + } + + pView->UpdateRef( nPosX, nPosY, nTab ); + } + else if ( nMode == SC_FILL_MATRIX ) + { + USHORT nStartX, nStartY, nEndX, nEndY; // Block + USHORT nDummy; + pViewData->GetSimpleArea( nStartX, nStartY, nDummy, nEndX, nEndY, nDummy, FALSE ); + + if (pViewData->GetRefType() != SC_REFTYPE_FILL) + { + pView->InitRefMode( nStartX, nStartY, nTab, SC_REFTYPE_FILL ); + CreateAnchor(); + } + + if ( nPosX < nStartX ) nPosX = nStartX; + if ( nPosY < nStartY ) nPosY = nStartY; + + pView->UpdateRef( nPosX, nPosY, nTab ); + } + // else neue Modi + } + else // normales Markieren + { + BOOL bHideCur = bAnchor && ( (USHORT)nPosX != pViewData->GetCurX() || + (USHORT)nPosY != pViewData->GetCurY() ); + if (bHideCur) + pView->HideAllCursors(); // sonst zweimal: Block und SetCursor + + if (bAnchor) + { + if (!bStarted) + { + BOOL bMove = ( nPosX != (short) aAnchorPos.GetCol() || + nPosY != (short) aAnchorPos.GetRow() ); + if ( bMove || ( pEngine && pEngine->GetMouseEvent().IsShift() ) ) + { + pView->InitBlockMode( aAnchorPos.GetCol(), aAnchorPos.GetRow(), + aAnchorPos.GetTab(), TRUE ); + bStarted = TRUE; + } + } + if (bStarted) + pView->MarkCursor( (USHORT) nPosX, (USHORT) nPosY, nTab ); + } + else + { + ScMarkData& rMark = pViewData->GetMarkData(); + if (rMark.IsMarked() || rMark.IsMultiMarked()) + { + pView->DoneBlockMode(TRUE); + pView->InitBlockMode( nPosX, nPosY, nTab, TRUE ); + pView->MarkCursor( (USHORT) nPosX, (USHORT) nPosY, nTab ); + + aAnchorPos.Put( nPosX, nPosY, nTab ); + bStarted = TRUE; + } + } + + pView->SetCursor( (USHORT) nPosX, (USHORT) nPosY ); + pViewData->SetRefStart( nPosX, nPosY, nTab ); + if (bHideCur) + pView->ShowAllCursors(); + } + + if (bHide) + pView->ShowAllCursors(); + + return TRUE; +} + +BOOL __EXPORT ScViewFunctionSet::IsSelectionAtPoint( const Point& rPointPixel ) +{ + BOOL bRefMode = SC_MOD()->IsFormulaMode(); + if (bRefMode) + return FALSE; + + if (pViewData->IsAnyFillMode()) + return FALSE; + + ScMarkData& rMark = pViewData->GetMarkData(); + if (bAnchor || !rMark.IsMultiMarked()) + { + short nPosX; + short nPosY; + pViewData->GetPosFromPixel( rPointPixel.X(), rPointPixel.Y(), GetWhich(), nPosX, nPosY ); + return pViewData->GetMarkData().IsCellMarked( (USHORT) nPosX, (USHORT) nPosY ); + } + + return FALSE; +} + +void __EXPORT ScViewFunctionSet::DeselectAtPoint( const Point& rPointPixel ) +{ + // gibt's nicht +} + +void __EXPORT ScViewFunctionSet::DeselectAll() +{ + if (pViewData->IsAnyFillMode()) + return; + + BOOL bRefMode = SC_MOD()->IsFormulaMode(); + if (bRefMode) + { + pViewData->GetView()->DoneRefMode( FALSE ); + } + else + { + pViewData->GetView()->DoneBlockMode( FALSE ); + pViewData->GetViewShell()->UpdateInputHandler(); + } + + bAnchor = FALSE; +} + +//------------------------------------------------------------------------ + +ScViewSelectionEngine::ScViewSelectionEngine( Window* pWindow, ScTabView* pView, + ScSplitPos eSplitPos ) : + SelectionEngine( pWindow, pView->GetFunctionSet() ), + eWhich( eSplitPos ) +{ + // Parameter einstellen + SetSelectionMode( MULTIPLE_SELECTION ); + EnableDrag( TRUE ); +} + + +//------------------------------------------------------------------------ + +// +// Spalten- / Zeilenheader +// + +ScHeaderFunctionSet::ScHeaderFunctionSet( ScViewData* pNewViewData ) : + pViewData( pNewViewData ), + bColumn( FALSE ), + eWhich( SC_SPLIT_TOPLEFT ), + bAnchor( FALSE ), + nCursorPos( 0 ) +{ + DBG_ASSERT(pViewData, "ViewData==0 bei FunctionSet"); +} + +void ScHeaderFunctionSet::SetColumn( BOOL bSet ) +{ + bColumn = bSet; +} + +void ScHeaderFunctionSet::SetWhich( ScSplitPos eNew ) +{ + eWhich = eNew; +} + +void __EXPORT ScHeaderFunctionSet::BeginDrag() +{ + // gippsnich +} + +void __EXPORT ScHeaderFunctionSet::CreateAnchor() +{ + if (bAnchor) + return; + + ScTabView* pView = pViewData->GetView(); + pView->DoneBlockMode( TRUE ); + if (bColumn) + { + pView->InitBlockMode( nCursorPos, 0, pViewData->GetTabNo(), TRUE, TRUE, FALSE ); + pView->MarkCursor( nCursorPos, MAXROW, pViewData->GetTabNo() ); + } + else + { + pView->InitBlockMode( 0, nCursorPos, pViewData->GetTabNo(), TRUE, FALSE, TRUE ); + pView->MarkCursor( MAXCOL, nCursorPos, pViewData->GetTabNo() ); + } + bAnchor = TRUE; +} + +void __EXPORT ScHeaderFunctionSet::DestroyAnchor() +{ + pViewData->GetView()->DoneBlockMode( TRUE ); + bAnchor = FALSE; +} + +BOOL __EXPORT ScHeaderFunctionSet::SetCursorAtPoint( const Point& rPointPixel, BOOL bDontSelectAtCursor ) +{ + if ( bDidSwitch ) + { + // die naechste gueltige Position muss vom anderen Fenster kommen + if ( rPointPixel == aSwitchPos ) + return FALSE; // nicht auf falschem Fenster scrollen + else + bDidSwitch = FALSE; + } + + // Scrolling + + Size aWinSize = pViewData->GetActiveWin()->GetOutputSizePixel(); + BOOL bScroll; + if (bColumn) + bScroll = ( rPointPixel.X() < 0 || rPointPixel.X() >= aWinSize.Width() ); + else + bScroll = ( rPointPixel.Y() < 0 || rPointPixel.Y() >= aWinSize.Height() ); + + // ueber Fixier-Grenze bewegt? + + BOOL bSwitched = FALSE; + if ( bColumn ) + { + if ( pViewData->GetHSplitMode() == SC_SPLIT_FIX ) + { + if ( rPointPixel.X() > aWinSize.Width() ) + { + if ( eWhich == SC_SPLIT_TOPLEFT ) + pViewData->GetView()->ActivatePart( SC_SPLIT_TOPRIGHT ), bSwitched = TRUE; + else if ( eWhich == SC_SPLIT_BOTTOMLEFT ) + pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT ), bSwitched = TRUE; + } + } + } + else // Zeilenkoepfe + { + if ( pViewData->GetVSplitMode() == SC_SPLIT_FIX ) + { + if ( rPointPixel.Y() > aWinSize.Height() ) + { + if ( eWhich == SC_SPLIT_TOPLEFT ) + pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMLEFT ), bSwitched = TRUE; + else if ( eWhich == SC_SPLIT_TOPRIGHT ) + pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT ), bSwitched = TRUE; + } + } + } + if (bSwitched) + { + aSwitchPos = rPointPixel; + bDidSwitch = TRUE; + return FALSE; // nicht mit falschen Positionen rechnen + } + + // + + short nPosX; + short nPosY; + pViewData->GetPosFromPixel( rPointPixel.X(), rPointPixel.Y(), pViewData->GetActivePart(), + nPosX, nPosY, FALSE ); + if (bColumn) + { + nCursorPos = nPosX; + nPosY = pViewData->GetPosY(WhichV(pViewData->GetActivePart())); + } + else + { + nCursorPos = nPosY; + nPosX = pViewData->GetPosX(WhichH(pViewData->GetActivePart())); + } + + ScTabView* pView = pViewData->GetView(); + BOOL bHide = pViewData->GetCurX() != nPosX || + pViewData->GetCurY() != nPosY; + if (bHide) + pView->HideAllCursors(); + + if (bScroll) + pView->AlignToCursor( nPosX, nPosY, SC_FOLLOW_LINE ); + pView->SetCursor( nPosX, nPosY ); + + if (!bAnchor) + { + pView->DoneBlockMode( TRUE ); + pViewData->GetMarkData().MarkToMulti(); //! wer verstellt das ??? + pView->InitBlockMode( nPosX, nPosY, pViewData->GetTabNo(), TRUE, bColumn, !bColumn ); + + bAnchor = TRUE; + } + + pView->MarkCursor( nPosX, nPosY, pViewData->GetTabNo(), bColumn, !bColumn ); + + // SelectionChanged innerhalb von HideCursor wegen UpdateAutoFillMark + pView->SelectionChanged(); + + if (bHide) + pView->ShowAllCursors(); + + return TRUE; +} + +BOOL __EXPORT ScHeaderFunctionSet::IsSelectionAtPoint( const Point& rPointPixel ) +{ + short nPosX; + short nPosY; + pViewData->GetPosFromPixel( rPointPixel.X(), rPointPixel.Y(), pViewData->GetActivePart(), + nPosX, nPosY, FALSE ); + + ScMarkData& rMark = pViewData->GetMarkData(); + if (bColumn) + return rMark.IsColumnMarked( nPosX ); + else + return rMark.IsRowMarked( nPosY ); +} + +void __EXPORT ScHeaderFunctionSet::DeselectAtPoint( const Point& rPointPixel ) +{ +} + +void __EXPORT ScHeaderFunctionSet::DeselectAll() +{ + pViewData->GetView()->DoneBlockMode( FALSE ); + bAnchor = FALSE; +} + +//------------------------------------------------------------------------ + +ScHeaderSelectionEngine::ScHeaderSelectionEngine( Window* pWindow, ScHeaderFunctionSet* pFuncSet ) : + SelectionEngine( pWindow, pFuncSet ) +{ + // Parameter einstellen + SetSelectionMode( MULTIPLE_SELECTION ); + EnableDrag( FALSE ); +} + + + + + diff --git a/sc/source/ui/view/spelleng.cxx b/sc/source/ui/view/spelleng.cxx new file mode 100644 index 000000000000..147d40cbefd0 --- /dev/null +++ b/sc/source/ui/view/spelleng.cxx @@ -0,0 +1,376 @@ +/************************************************************************* + * + * $RCSfile: spelleng.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <svx/langitem.hxx> +#include <svx/editobj.hxx> +#include <svx/editview.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/system.hxx> + +#ifndef ONE_LINGU +#include <hm2/splchk.hxx> +#endif + +#include "spelleng.hxx" +#include "tabvwsh.hxx" +#include "docsh.hxx" +#include "cell.hxx" +#include "patattr.hxx" +#include "waitoff.hxx" +#include "globstr.hrc" + + +// ----------------------------------------------------------------------- + +BOOL lcl_HasString( ScDocument* pDoc, USHORT nCol, USHORT nRow, USHORT nTab, + const String& rString ) +{ + String aCompStr; + pDoc->GetString( nCol, nRow, nTab, aCompStr ); + return ( aCompStr == rString ); //! case-insensitive? +} + +BOOL __EXPORT ScSpellingEngine::SpellNextDocument() +{ + ScDocShell* pDocSh = pViewData->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + ScMarkData& rMark = pViewData->GetMarkData(); + ScTabViewShell* pViewShell = pViewData->GetViewShell(); + ScSplitPos eWhich = pViewData->GetActivePart(); + CellType eCellType; + ScBaseCell* pCell = NULL; + LanguageType eLnge; + EditTextObject* pETObject = NULL; + const SfxPoolItem* pItem = NULL; + SvxLanguageItem* pLangIt = NULL; + const ScPatternAttr* pPattern = NULL; + const ScPatternAttr* pLastPattern = NULL; + SfxItemSet* pEditDefaults = new SfxItemSet( GetEmptyItemSet() ); + + if (IsModified()) + { + bIsModifiedAtAll = TRUE; + + String aNewStr = GetText(); + + BOOL bMultiTab = ( rMark.GetSelectCount() > 1 ); + String aVisibleStr; + if (bMultiTab) + pDoc->GetString( nOldCol, nOldRow, nOrgTab, aVisibleStr ); + + USHORT nTabCount = pDoc->GetTableCount(); + for ( USHORT nTab=0; nTab<nTabCount; nTab++ ) + { + // #69965# always change the cell on the visible tab, + // on the other selected tabs only if they contain the same text + + if ( nTab == nOrgTab || ( bMultiTab && rMark.GetTableSelect(nTab) && + lcl_HasString( pDoc, nOldCol, nOldRow, nTab, aVisibleStr ) ) ) + { + pDoc->GetCellType(nOldCol, nOldRow, nTab, eCellType); + pDoc->GetCell(nOldCol, nOldRow, nTab, pCell); + if (pUndoDoc && pCell) + { + ScBaseCell* pUndoCell = pCell->Clone(pUndoDoc); + pUndoDoc->PutCell(nOldCol, nOldRow, nTab, pUndoCell); + } + if (eCellType == CELLTYPE_EDIT) + { + if (pCell) + { + pETObject = CreateTextObject(); + ((ScEditCell*) pCell)->SetData( pETObject, GetEditTextObjectPool() ); + delete pETObject; + } + } + else + { + pDoc->SetString(nOldCol, nOldRow, nTab, aNewStr); + pDoc->GetCell(nOldCol, nOldRow, nTab, pCell); + } + if (pRedoDoc && pCell) + { + ScBaseCell* pRedoCell = pCell->Clone(pRedoDoc); + pRedoDoc->PutCell(nOldCol, nOldRow, nTab, pRedoCell); + } + pDocSh->PostPaintCell(nOldCol, nOldRow, nTab); + } + } + } + pCell = NULL; + USHORT nCol, nRow; + BOOL bStop = FALSE; + BOOL bNext; + nCol = nOldCol; + if (bFirstTime) + { + bFirstTime = FALSE; + if (nOldCol == nOrgCol && nOldRow == nOrgRow) // das erste Mal + nRow = nOldRow-1; + else + nRow = nOldRow; + } + else + nRow = nOldRow; + while (!bStop) + { + bNext = pDoc->GetNextSpellingCell(nCol, nRow, nOrgTab, bInSel, rMark); + if (bNext) + { + if (!bFirstTable && + (nCol > nOrgCol || (nCol == nOrgCol && nRow >= nOrgRow))) + { + pDoc->GetCellType(nOldCol, nOldRow, nOrgTab, eCellType); + if (eCellType == CELLTYPE_STRING) + { + String sOldText; + pDoc->GetString(nOldCol, nOldRow, nOrgTab, sOldText); + SetText(sOldText); + } + else if (eCellType == CELLTYPE_EDIT) + { + pDoc->GetCell(nOldCol, nOldRow, nOrgTab, pCell); + if (pCell) + { + const EditTextObject* pNewTObj = NULL; + ((ScEditCell*) pCell)->GetData(pNewTObj); + if (pNewTObj) + SetText(*pNewTObj); + } + } + else + SetText(EMPTY_STRING); + + { // own scope for WaitCursorOff + ScWaitCursorOff aWaitOff( pDocSh->GetDialogParent() ); + InfoBox aBox( pViewData->GetDialogParent(), + ScGlobal::GetRscString(STR_SPELLING_STOP_OK)); + aBox.Execute(); + } + return FALSE; + } + else if ( nCol == MAXCOL+1 ) + { + if ( nOrgCol == 0 && nOrgRow == 0 ) + { + pDoc->GetCellType(nOldCol, nOldRow, nOrgTab, eCellType); + if (eCellType == CELLTYPE_STRING) + { + String sOldText; + pDoc->GetString(nOldCol, nOldRow, nOrgTab, sOldText); + SetText(sOldText); + } + else if (eCellType == CELLTYPE_EDIT) + { + pDoc->GetCell(nOldCol, nOldRow, nOrgTab, pCell); + if (pCell) + { + const EditTextObject* pNewTObj = NULL; + ((ScEditCell*) pCell)->GetData(pNewTObj); + if (pNewTObj) + SetText(*pNewTObj); + } + } + else + SetText(EMPTY_STRING); + + { // own scope for WaitCursorOff + ScWaitCursorOff aWaitOff( pDocSh->GetDialogParent() ); + InfoBox aBox( pViewData->GetDialogParent(), + ScGlobal::GetRscString(STR_SPELLING_STOP_OK)); + aBox.Execute(); + } + + return FALSE; + } + else + { + // zuerst auf letzte Zelle zuruecksetzen + // fuer Paint + pDoc->GetCellType(nOldCol, nOldRow, nOrgTab, eCellType); + if (eCellType == CELLTYPE_STRING) + { + String sOldText; + pDoc->GetString(nOldCol, nOldRow, nOrgTab, sOldText); + SetText(sOldText); + } + else if (eCellType == CELLTYPE_EDIT) + { + pDoc->GetCell(nOldCol, nOldRow, nOrgTab, pCell); + if (pCell) + { + const EditTextObject* pNewTObj = NULL; + ((ScEditCell*) pCell)->GetData(pNewTObj); + if (pNewTObj) + SetText(*pNewTObj); + } + } + else + SetText(EMPTY_STRING); + + short nRet; + { // own scope for WaitCursorOff + ScWaitCursorOff aWaitOff( pDocSh->GetDialogParent() ); + nRet = MessBox( pViewData->GetDialogParent(), + WinBits(WB_YES_NO | WB_DEF_YES), + ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), // "StarCalc" + ScGlobal::GetRscString( STR_SPELLING_BEGIN_TAB) ) // Fortsetzen? + .Execute(); + } + if (nRet == RET_YES) + { + nRow = MAXROW+2; + bFirstTable = FALSE; + } + else + return FALSE; + } + } + else // Stringzelle mit Inhalt + { + pPattern = pDoc->GetPattern(nCol, nRow, nOrgTab); + if (pPattern && pPattern != pLastPattern) + { + pPattern->FillEditItemSet( pEditDefaults ); + SetDefaults( *pEditDefaults ); + pLastPattern = pPattern; + } + pItem = pDoc->GetAttr(nCol, nRow, nOrgTab, ATTR_FONT_LANGUAGE); + pLangIt = PTR_CAST( SvxLanguageItem, pItem ); + if (pLangIt) + { + eLnge = (LanguageType) pLangIt->GetValue(); + if ( eLnge == LANGUAGE_SYSTEM ) + eLnge = System::GetLanguage(); // Spelling nie mit SYSTEM + if (eLnge != eOldLnge) + { + eOldLnge = eLnge; +#ifdef ONE_LINGU + SetDefaultLanguage( eLnge ); +#else + SpellCheck* pSpCheck = GetSpeller(); + if (pSpCheck) + pSpCheck->SetActualLanguage(eLnge); + else + { + DBG_ERROR( + "ScSpellingEngine::SpellNextDoc: Kein Spell Checker"); + } +#endif + } + } + pDoc->GetCellType(nCol, nRow, nOrgTab, eCellType); + if (eCellType == CELLTYPE_STRING) + { + String sOldText; + pDoc->GetString(nCol, nRow, nOrgTab, sOldText); + SetText(sOldText); + } + else if (eCellType == CELLTYPE_EDIT) + { + pDoc->GetCell(nCol, nRow, nOrgTab, pCell); + if (pCell) + { + const EditTextObject* pNewTObj = NULL; + ((ScEditCell*) pCell)->GetData(pNewTObj); + if (pNewTObj) + SetText(*pNewTObj); + } + } + else + SetText(EMPTY_STRING); + if (HasSpellErrors(eLnge)) + bStop = TRUE; + } + } + else + return FALSE; + } + pViewShell->AlignToCursor( nCol, nRow, SC_FOLLOW_JUMP ); + pViewShell->SetCursor( nCol, nRow, TRUE ); + pViewData->GetView()->MakeEditView(this, nCol, nRow ); + EditView* pEditView = pViewData->GetSpellingView(); + if (pEditSel) // hoechstens beim ersten Mal + { + pEditView->SetSelection(*pEditSel); + pEditSel = NULL; + } + else + pEditView->SetSelection(ESelection(0,0,0,0)); + ClearModifyFlag(); + nOldCol = nCol; + nOldRow = nRow; + delete pEditDefaults; + return TRUE; +} + + + + diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx new file mode 100644 index 000000000000..f79d9f4d1e63 --- /dev/null +++ b/sc/source/ui/view/tabcont.cxx @@ -0,0 +1,566 @@ +/************************************************************************* + * + * $RCSfile: tabcont.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include <sfx2/dispatch.hxx> +#include <vcl/sound.hxx> + +#include "tabcont.hxx" +#include "tabvwsh.hxx" +#include "docsh.hxx" +#include "scmod.hxx" +#include "scresid.hxx" +#include "sc.hrc" +#include "globstr.hrc" +#include "dataobj.hxx" + + +// STATIC DATA ----------------------------------------------------------- + +//================================================================== + +ScTabControl::ScTabControl( Window* pParent, ScViewData* pData ) : + TabBar( pParent, WinBits( WB_BORDER | WB_3DLOOK | WB_SCROLL | + WB_RANGESELECT | WB_MULTISELECT | WB_DRAG | WB_SIZEABLE ) ), + pViewData( pData ), + bDragging( FALSE ), + bErrorShown( FALSE ), + bAddDown( FALSE ) +{ + ScDocument* pDoc = pViewData->GetDocument(); + + String aString; + USHORT nCount = pDoc->GetTableCount(); + for (USHORT i=0; i<nCount; i++) + { + if (pDoc->IsVisible(i)) + if (pDoc->GetName(i,aString)) + if ( pDoc->IsScenario(i) ) + InsertPage( i+1, aString, TPB_SPECIAL ); + else + InsertPage( i+1, aString ); + } + + SetCurPageId( pViewData->GetTabNo() + 1 ); + + SetSizePixel( Size(SC_TABBAR_DEFWIDTH, 0) ); + + SetSplitHdl( LINK( pViewData->GetView(), ScTabView, TabBarResize ) ); + + EnableEditMode(); +} + +__EXPORT ScTabControl::~ScTabControl() +{ +} + +USHORT ScTabControl::GetMaxId() const +{ + USHORT nVisCnt = GetPageCount(); + if (nVisCnt) + return GetPageId(nVisCnt-1); + + return 0; +} + +USHORT ScTabControl::GetPrivatDropPos(const Point& rPos ) +{ + USHORT nPos = ShowDropPos(rPos); + + USHORT nRealPos = nPos; + + if(nPos !=0 ) + { + ScDocument* pDoc = pViewData->GetDocument(); + + USHORT nCount = pDoc->GetTableCount(); + + USHORT nViewPos=0; + nRealPos = nCount; + for (USHORT i=0; i<nCount; i++) + { + if (pDoc->IsVisible(i)) + { + nViewPos++; + if(nViewPos==nPos) + { + USHORT j; + for (j=i+1; j<nCount; j++) + { + if (pDoc->IsVisible(j)) + { + break; + } + } + nRealPos =j; + break; + } + } + } + } + return nRealPos ; +} + +void __EXPORT ScTabControl::MouseButtonDown( const MouseEvent& rMEvt ) +{ + bAddDown = FALSE; + + ScModule* pScMod = SC_MOD(); + if ( !pScMod->IsModalMode() && !pScMod->IsFormulaMode() && !IsInEditMode() ) + { + // View aktivieren + pViewData->GetViewShell()->SetActive(); // Appear und SetViewFrame + pViewData->GetView()->ActiveGrabFocus(); + } + + // #47745# Klick neben Tabellen -> neue Tabelle einfuegen (wie im Draw) + // eine saubere linke Maustaste ohne verwaessernde Modifier (damit koennte + /// ja das Kontextmenue gemeint sein) + if ( rMEvt.IsLeft() && !rMEvt.IsMod1() && !rMEvt.IsMod2() && !rMEvt.IsShift()) + { + Point aPos = PixelToLogic( rMEvt.GetPosPixel() ); + if ( GetPageId(aPos) == 0 ) + bAddDown = TRUE; // erst im ButtonUp, weil ein Dialog kommt + } + + TabBar::MouseButtonDown( rMEvt ); +} + +void __EXPORT ScTabControl::MouseButtonUp( const MouseEvent& rMEvt ) +{ + if ( bAddDown ) + { + Point aPos = PixelToLogic( rMEvt.GetPosPixel() ); + if ( GetPageId(aPos) == 0 ) + { + SfxDispatcher* pDispatcher = pViewData->GetViewShell()->GetViewFrame()->GetDispatcher(); + pDispatcher->Execute( FID_INS_TABLE, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD ); + } + } + + bAddDown = FALSE; + TabBar::MouseButtonUp( rMEvt ); +} + +void __EXPORT ScTabControl::Select() +{ + ScModule* pScMod = SC_MOD(); + ScDocument* pDoc = pViewData->GetDocument(); + ScMarkData& rMark = pViewData->GetMarkData(); + USHORT nCount = pDoc->GetTableCount(); + USHORT i; + + if ( pScMod->IsTableLocked() ) // darf jetzt nicht umgeschaltet werden ? + { + // den alten Zustand des TabControls wiederherstellen: + + for (i=0; i<nCount; i++) + SelectPage( i+1, rMark.GetTableSelect(i) ); + SetCurPageId( pViewData->GetTabNo() + 1 ); + + Sound::Beep(); + return; + } + + USHORT nCurId = GetCurPageId(); + if (!nCurId) return; // kann vorkommen, wenn bei Excel-Import alles versteckt ist + USHORT nPage = nCurId - 1; + + // OLE-inplace deaktivieren + if ( nPage != pViewData->GetTabNo() ) + pViewData->GetView()->DrawMarkListHasChanged(); + + // InputEnterHandler nur wenn nicht Referenzeingabe + + BOOL bRefMode = pScMod->IsFormulaMode(); + if (!bRefMode) + pScMod->InputEnterHandler(); + + for (i=0; i<nCount; i++) + rMark.SelectTable( i, IsPageSelected(i+1) ); + +/* Markierungen werden per Default nicht pro Tabelle gehalten + USHORT nSelCnt = GetSelectPageCount(); + if (nSelCnt>1) + pDoc->ExtendMarksFromTable( nPage ); +*/ + + if (SFX_DISPATCHER().IsLocked()) + pViewData->GetView()->SetTabNo( nPage ); + else + { + // Tabelle fuer Basic ist 1-basiert + SfxUInt16Item aItem( SID_CURRENTTAB, nPage + 1 ); + SFX_DISPATCHER().Execute( SID_CURRENTTAB, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, + &aItem, (void*) NULL ); + } + + SfxBindings& rBind = SFX_BINDINGS(); + rBind.Invalidate( FID_FILL_TAB ); + + rBind.Invalidate( FID_INS_TABLE ); + rBind.Invalidate( FID_TAB_APPEND ); + rBind.Invalidate( FID_TAB_MOVE ); + rBind.Invalidate( FID_TAB_RENAME ); + rBind.Invalidate( FID_DELETE_TABLE ); + rBind.Invalidate( FID_TABLE_SHOW ); + rBind.Invalidate( FID_TABLE_HIDE ); + + // SetReference nur wenn der Konsolidieren-Dialog offen ist + // (fuer Referenzen ueber mehrere Tabellen) + // bei anderen gibt das nur unnoetiges Gezappel + + if ( bRefMode && pViewData->GetRefType() == SC_REFTYPE_REF ) + if ( pViewData->GetViewShell()->GetViewFrame()->HasChildWindow(SID_OPENDLG_CONSOLIDATE) ) + { + ScRange aRange( + pViewData->GetRefStartX(), pViewData->GetRefStartY(), pViewData->GetRefStartZ(), + pViewData->GetRefEndX(), pViewData->GetRefEndY(), pViewData->GetRefEndZ() ); + pScMod->SetReference( aRange, pDoc, &rMark ); + pScMod->EndReference(); // wegen Auto-Hide + } +} + +void ScTabControl::UpdateStatus() +{ + ScDocument* pDoc = pViewData->GetDocument(); + ScMarkData& rMark = pViewData->GetMarkData(); + BOOL bActive = pViewData->IsActive(); + + USHORT nCount = pDoc->GetTableCount(); + USHORT i; + String aString; + USHORT nMaxCnt = Max( nCount, GetMaxId() ); + + BOOL bModified = FALSE; // Tabellen-Namen + for (i=0; i<nMaxCnt && !bModified; i++) + { + if (pDoc->IsVisible(i)) + pDoc->GetName(i,aString); + else + aString.Erase(); + + if (GetPageText(i+1) != aString) + bModified = TRUE; + } + + if (bModified) + { + Clear(); + for (i=0; i<nCount; i++) + if (pDoc->IsVisible(i)) + if (pDoc->GetName(i,aString)) + if ( pDoc->IsScenario(i) ) + InsertPage( i+1, aString, TPB_SPECIAL ); + else + InsertPage( i+1, aString ); + } + SetCurPageId( pViewData->GetTabNo() + 1 ); + + if (bActive) + { + bModified = FALSE; // Selektion + for (i=0; i<nMaxCnt && !bModified; i++) + if ( rMark.GetTableSelect(i) != IsPageSelected(i+1) ) + bModified = TRUE; + + if ( bModified ) + for (i=0; i<nCount; i++) + SelectPage( i+1, rMark.GetTableSelect(i) ); + } + else + { + } +} + +void ScTabControl::ActivateView(BOOL bActivate) +{ +// ScDocument* pDoc = pViewData->GetDocument(); + ScMarkData& rMark = pViewData->GetMarkData(); + +// ResetMark direkt in TabView +// pDoc->ResetMark(); + + USHORT nCurId = GetCurPageId(); + if (!nCurId) return; // kann vorkommen, wenn bei Excel-Import alles versteckt ist + USHORT nPage = nCurId - 1; + USHORT nCount = GetMaxId(); + + /* + USHORT i; + for (i=0; i<nCount; i++) + { + SelectPage( i+1, FALSE ); + if (bActivate) + rMark.SelectTable( i, FALSE ); + } + */ + if (bActivate) + { + SelectPage( nPage+1, TRUE ); + rMark.SelectTable( nPage, TRUE ); + } + Invalidate(); +} + +void __EXPORT ScTabControl::Command( const CommandEvent& rCEvt ) +{ + ScModule* pScMod = SC_MOD(); + ScTabViewShell* pViewSh = pViewData->GetViewShell(); + BOOL bDisable = pScMod->IsFormulaMode() || pScMod->IsModalMode(); + + // ViewFrame erstmal aktivieren (Bug 19493): + pViewSh->SetActive(); + + USHORT nCmd = rCEvt.GetCommand(); + if ( nCmd == COMMAND_CONTEXTMENU ) + { + if (!bDisable) + { + // nur eine Tabelle selektieren: + /* + USHORT nId = GetPageId( rCEvt.GetMousePosPixel() ); + if (nId) + { + SetCurPageId( nId ); + USHORT nCount = GetMaxId(); + + for (USHORT i=1; i<=nCount; i++) + SelectPage( i, i==nId ); + Select(); + } + */ + // Popup-Menu: + pViewSh->GetDispatcher()->ExecutePopup( ScResId(RID_POPUP_TAB) ); + } + } + else if ( nCmd == COMMAND_STARTDRAG ) + { + if (!bDisable) + { + Region aRegion( Rectangle(0,0,0,0) ); + if (StartDrag( rCEvt, aRegion )) + DoDrag( aRegion ); + } + } +} + + +void ScTabControl::DoDrag( const Region& rRegion ) +{ + ScModule* pScMod = SC_MOD(); + + ScDocument* pDoc = pViewData->GetDocument(); + ScMarkData& rMark= pViewData->GetMarkData(); + + USHORT nTab = pViewData->GetTabNo(); + pScMod->SetDragObject( rMark, ScRange(0,0,nTab,MAXCOL,MAXROW,nTab), 0,0, pDoc, SC_DROP_TABLE ); + + bDragging = TRUE; // um Tabellen innerhalb dieses TabBars zu verschieben + + SvDataObjectRef pDragServer = new ScDataObject(pDoc,FALSE,pViewData->GetDocShell()); + DropAction eAction = pDragServer->ExecuteDrag(pViewData->GetActiveWin(), + Pointer(POINTER_MOVEDATA), + Pointer(POINTER_COPYDATA), + Pointer(POINTER_LINKDATA) ); + + bDragging = FALSE; + + pScMod->ResetDragObject(); + + //! eAction auswerten +} + +USHORT lcl_DocShellNr( ScDocument* pDoc ) +{ + USHORT nShellCnt = 0; + SfxObjectShell* pShell = SfxObjectShell::GetFirst(); + while ( pShell ) + { + if ( pShell->Type() == TYPE(ScDocShell) ) + { + if ( ((ScDocShell*)pShell)->GetDocument() == pDoc ) + return nShellCnt; + + ++nShellCnt; + } + pShell = SfxObjectShell::GetNext( *pShell ); + } + + DBG_ERROR("Dokument nicht gefunden"); + return 0; +} + +BOOL __EXPORT ScTabControl::Drop( const DropEvent& rEvt ) +{ + EndSwitchPage(); + + ScModule* pScMod = SC_MOD(); + ScDocument* pSourceDoc = pScMod->GetDragData().pDoc; + if (pSourceDoc && bDragging) + { + USHORT nPos = GetPrivatDropPos( rEvt.GetPosPixel() ); + HideDropPos(); + ScDocument* pDestDoc = pViewData->GetDocument(); + if ( pSourceDoc == pDestDoc && pSourceDoc->IsDocEditable() ) + { + pViewData->GetView()->MoveTable( lcl_DocShellNr(pDestDoc), nPos, rEvt.GetAction()==DROP_COPY ); + + pScMod->SetDragIntern(); // nicht loeschen + return TRUE; + } + else + Sound::Beep(); + } + + return FALSE; +} + +BOOL __EXPORT ScTabControl::QueryDrop( DropEvent& rEvt ) +{ + if (rEvt.IsLeaveWindow()) + { + EndSwitchPage(); + HideDropPos(); + return TRUE; + } + + if (bDragging) // innerhalb eines TabControls + { + const ScDocument* pDoc = pViewData->GetDocument(); + if ( !pDoc->GetChangeTrack() && pDoc->IsDocEditable() ) + { + ShowDropPos( rEvt.GetPosPixel() ); + return TRUE; + } + } + else // umschalten fuer alle Formate + { + SwitchPage( rEvt.GetPosPixel() ); // switch sheet after timeout + return FALSE; // nothing can be dropped here + } + + return FALSE; +} + +long ScTabControl::StartRenaming() +{ + if ( pViewData->GetDocument()->IsDocEditable() ) + return TAB_RENAMING_YES; + else + return TAB_RENAMING_NO; +} + +long ScTabControl::AllowRenaming() +{ + ScTabViewShell* pViewSh = pViewData->GetViewShell(); + DBG_ASSERT( pViewSh, "pViewData->GetViewShell()" ); + + long nRet = TAB_RENAMING_CANCEL; + USHORT nId = GetEditPageId(); + if ( nId ) + { + USHORT nTab = nId - 1; + String aNewName = GetEditText(); + BOOL bDone = pViewSh->RenameTable( aNewName, nTab ); + if ( bDone ) + nRet = TAB_RENAMING_YES; + else if ( bErrorShown ) + { + // if the error message from this TabControl is currently visible, + // don't end edit mode now, to avoid problems when returning to + // the other call (showing the error) - this should not happen + DBG_ERROR("ScTabControl::AllowRenaming: nested calls"); + nRet = TAB_RENAMING_NO; + } + else if ( Application::IsInModalMode() ) + { + // #73472# don't show error message above any modal dialog + // instead cancel renaming without error message + nRet = TAB_RENAMING_CANCEL; + } + else + { + bErrorShown = TRUE; + pViewSh->ErrorMessage( STR_INVALIDTABNAME ); + bErrorShown = FALSE; + nRet = TAB_RENAMING_NO; + } + } + return nRet; +} + +void ScTabControl::EndRenaming() +{ + if ( HasFocus() ) + pViewData->GetView()->ActiveGrabFocus(); +} + + + + diff --git a/sc/source/ui/view/tabpopsh.cxx b/sc/source/ui/view/tabpopsh.cxx new file mode 100644 index 000000000000..34f27eaf60fd --- /dev/null +++ b/sc/source/ui/view/tabpopsh.cxx @@ -0,0 +1,164 @@ +/************************************************************************* + * + * $RCSfile: tabpopsh.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#pragma hdrstop + +#define GLOBALOVERFLOW +#include "segmentc.hxx" +#include "tabpopsh.hxx" +#include "sc.hrc" + +//#define ScTabPopShell +//#include "scslots.hxx" +#undef ShellClass +#define ShellClass ScTabPopShell +SFX_SLOTMAP(ScTabPopShell) +{ + SFX_SLOT( 0,0, DummyExec, DummyState, 0, SfxVoidItem ) +}; +SEG_EOFGLOBALS() + +#pragma SEG_SEGCLASS(SFXMACROS_SEG,STARTWORK_CODE) + +TYPEINIT1(ScTabPopShell,SfxShell); + +//SFX_IMPL_IDL_INTERFACE(ScTabPopShell, SfxShell, 0) +SFX_IMPL_INTERFACE(ScTabPopShell, SfxShell, ResId( 0, NULL)) +{ + SFX_POPUPMENU_REGISTRATION( RID_POPUP_TAB ); +} + + + +#pragma SEG_FUNCDEF(tabpopsh_01) + +ScTabPopShell::ScTabPopShell(SfxItemPool& rItemPool) +{ + SetPool( &rItemPool ); +} + +#pragma SEG_FUNCDEF(tabpopsh_02) + +ScTabPopShell::~ScTabPopShell() +{ +} + +#pragma SEG_FUNCDEF(tabpopsh_03) + +void ScTabPopShell::DummyExec( SfxRequest& rReq ) +{ +} + +#pragma SEG_FUNCDEF(tabpopsh_04) + +void ScTabPopShell::DummyState( SfxItemSet& rSet ) +{ +} + + +/*------------------------------------------------------------------------ + + $Log: not supported by cvs2svn $ + Revision 1.12 2000/09/17 14:09:34 willem.vandorp + OpenOffice header added. + + Revision 1.11 2000/08/31 16:38:47 willem.vandorp + Header and footer replaced + + Revision 1.10 1995/06/20 14:24:26 NN + nochmal Segmentierung + + + Rev 1.9 20 Jun 1995 16:24:26 NN + nochmal Segmentierung + + Rev 1.8 13 Jun 1995 18:47:14 MO + seg-pragmas korrigiert + + Rev 1.7 04 Apr 1995 19:22:16 TRI + OS2 Anpassung + + Rev 1.6 24 Mar 1995 14:15:32 TRI + Segmentierung + + Rev 1.5 21 Mar 1995 11:00:06 MO + 242-Aenderungen + + Rev 1.4 05 Mar 1995 05:19:46 TRI + Mac Anpassung + + Rev 1.3 03 Mar 1995 23:02:28 NN + 2.41 Anpassung + + Rev 1.2 16 Feb 1995 10:33:10 NN + Slotmap ohne IDL wegen OS2-Problemen + + Rev 1.1 15 Feb 1995 08:26:54 NN + DummyExec + + Rev 1.0 14 Feb 1995 19:57:34 NN + Initial revision. + +------------------------------------------------------------------------*/ + +#pragma SEG_EOFMODULE + + diff --git a/sc/source/ui/view/tabsplit.cxx b/sc/source/ui/view/tabsplit.cxx new file mode 100644 index 000000000000..a74bdd2e4456 --- /dev/null +++ b/sc/source/ui/view/tabsplit.cxx @@ -0,0 +1,194 @@ +/************************************************************************* + * + * $RCSfile: tabsplit.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// System - Includes ----------------------------------------------------- + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +#ifndef PCH +#include <segmentc.hxx> +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "tabsplit.hxx" +#include "viewdata.hxx" +#include "dbfunc.hxx" + +// STATIC DATA ----------------------------------------------------------- + +SEG_EOFGLOBALS() + + +//================================================================== + +#pragma SEG_FUNCDEF(tabsplit_01) + +ScTabSplitter::ScTabSplitter( Window* pParent, WinBits nWinStyle, ScViewData* pData ) : + Splitter( pParent, nWinStyle ), + pViewData(pData) +{ + SetFixed(FALSE); +} + +#pragma SEG_FUNCDEF(tabsplit_02) + +ScTabSplitter::~ScTabSplitter() +{ +} + +#pragma SEG_FUNCDEF(tabsplit_03) + +void __EXPORT ScTabSplitter::MouseMove( const MouseEvent& rMEvt ) +{ + if (bFixed) + Window::MouseMove( rMEvt ); + else + Splitter::MouseMove( rMEvt ); +} + +#pragma SEG_FUNCDEF(tabsplit_04) + +void __EXPORT ScTabSplitter::MouseButtonUp( const MouseEvent& rMEvt ) +{ + if (bFixed) + Window::MouseButtonUp( rMEvt ); + else + Splitter::MouseButtonUp( rMEvt ); +} + +#pragma SEG_FUNCDEF(tabsplit_05) + +void __EXPORT ScTabSplitter::MouseButtonDown( const MouseEvent& rMEvt ) +{ + if (bFixed) + Window::MouseButtonDown( rMEvt ); + else + Splitter::MouseButtonDown( rMEvt ); +} + +#pragma SEG_FUNCDEF(tabsplit_07) + +void __EXPORT ScTabSplitter::Splitting( Point& rSplitPos ) +{ + Window* pParent = GetParent(); + Point aScreenPos = pParent->OutputToScreenPixel( rSplitPos ); + pViewData->GetView()->SnapSplitPos( aScreenPos ); + Point aNew = pParent->ScreenToOutputPixel( aScreenPos ); + if ( IsHorizontal() ) + rSplitPos.X() = aNew.X(); + else + rSplitPos.Y() = aNew.Y(); +} + +#pragma SEG_FUNCDEF(tabsplit_06) + +void ScTabSplitter::SetFixed(BOOL bSet) +{ + bFixed = bSet; + if (bSet) + SetPointer(POINTER_ARROW); + else if (IsHorizontal()) + SetPointer(POINTER_HSPLIT); + else + SetPointer(POINTER_VSPLIT); +} + +/*------------------------------------------------------------------------ + + $Log: not supported by cvs2svn $ + Revision 1.8 2000/09/17 14:09:34 willem.vandorp + OpenOffice header added. + + Revision 1.7 2000/08/31 16:38:47 willem.vandorp + Header and footer replaced + + Revision 1.6 1997/08/27 10:56:38 TRI + VCL Anpassung + + + Rev 1.5 27 Aug 1997 12:56:38 TRI + VCL Anpassung + + Rev 1.4 24 May 1996 10:58:44 NN + Position einrasten in Splitting + + Rev 1.3 14 Feb 1996 20:32:34 NN + MouseButtonDown, bFixed auswerten + + Rev 1.2 02 Feb 1996 16:28:18 NN + #25064# Freeze wieder raus + + Rev 1.1 27 Oct 1995 18:02:58 NN + Test: Freeze auf rechter Maustaste + + Rev 1.0 25 Oct 1995 16:35:44 NN + Initial revision. + +------------------------------------------------------------------------*/ + +#pragma SEG_EOFMODULE + + diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx new file mode 100644 index 000000000000..52e3abed6c7c --- /dev/null +++ b/sc/source/ui/view/tabview.cxx @@ -0,0 +1,2158 @@ +/************************************************************************* + * + * $RCSfile: tabview.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +//------------------------------------------------------------------ + +#if 0 +#define _MACRODLG_HXX +#define _BIGINT_HXX +#define _SVCONTNR_HXX +#define BASIC_NODIALOGS +#define _SFXMNUITEM_HXX +#define _SVDXOUT_HXX +#define _SVDATTR_HXX +#define _SFXMNUITEM_HXX +#define _DLGCFG_HXX +#define _SFXMNUMGR_HXX +#define _SFXBASIC_HXX +#define _MODALDLG_HXX +#define _SFX_TEMPLDLG_HXX +#define _SFXSTBMGR_HXX +#define _SFXTBXMGR_HXX +#define _BASE_DLGS_HXX +#define _SFXIMGMGR_HXX +#define _SFXMNUMGR_HXX +#define _SFXSTBITEM_HXX +#define _SFXTBXCTRL_HXX +#define _PASSWD_HXX +//#define _SFXFILEDLG_HXX +//#define _SFXREQUEST_HXX +#define _SFXOBJFACE_HXX + +#define _SDR_NOTRANSFORM +#define _SVDXOUT_HXX +#endif +/////////////////////////////////////////////////////////////////////////// +// NODRAW.HXX +// Erweiterte Konstanten, um CLOKs mit SVDRAW.HXX zu vermeiden +// Die u.a. Aenderungen nehmen vorgeschlagene Konstante vorweg +/////////////////////////////////////////////////////////////////////////// + +#if 0 +#define _SDR_NOTRANSFORM // Transformationen, selten verwendet +#define _SDR_NOTOUCH // Hit-Tests, selten verwendet + +#define _SDR_NOEXTDEV // ExtOutputDevice +#define _SDR_NOUNDO // Undo-Objekte +#define _SDR_NOSURROGATEOBJ // SdrObjSurrogate +#define _SDR_NOPAGEOBJ // SdrPageObj +#define _SDR_NOVIRTOBJ // SdrVirtObj +#define _SDR_NOGROUPOBJ // SdrGroupObj +#define _SDR_NOTEXTOBJ // SdrTextObj +#define _SDR_NOPATHOBJ // SdrPathObj +#define _SDR_NOEDGEOBJ // SdrEdgeObj +#define _SDR_NORECTOBJ // SdrRectObj +#define _SDR_NOCAPTIONOBJ // SdrCaptionObj +#define _SDR_NOCIRCLEOBJ // SdrCircleObj +#define _SDR_NOGRAFOBJ // SdrGrafObj +#define _SDR_NOOLE2OBJ // SdrOle2Obj +#endif + +// Dieses define entfernt die VCControls aus SI.HXX + +#define _SI_HXX // VCControls + +////////////////////// Umsetzen der Standard-Defines ////////////////////// + +#ifdef _SDR_NOEXTDEV + #define _SDVXOUT_HXX + #undef _SDR_NOEXTDEV +#endif + +//#define _SVDDRAG_HXX // SdrDragStat +#define _SVDPAGE_HXX // SdrPage + +#ifdef _SDR_NOSURROGATEOBJ + #undef _SDR_NOSURROGATEOBJ + #define _SVDSURO_HXX +#endif + +#ifdef _SDR_NOPAGEOBJ + #undef _SDR_NOPAGEOBJ + #define _SVDOPAGE_HXX +#endif + +#ifdef _SDR_NOVIRTOBJ + #undef _SDR_NOVIRTOBJ + #define _SVDOVIRT_HXX +#endif + +#ifdef _SDR_NOGROUPOBJ + #undef _SDR_NOGROUPOBJ + #define _SVDOGRP_HXX +#endif + +#ifdef _SDR_NOTEXTOBJ + #undef _SDR_NOTEXTOBJ + #define _SVDOTEXT_HXX +#endif + +#ifdef _SDR_NOPATHOBJ + #undef _SDR_NOPATHOBJ + #define _SVDOPATH_HXX +#endif + +#ifdef _SDR_NOEDGEOBJ + #undef _SDR_NOEDGEOBJ + #define _SVDOEDGE_HXX +#endif + +#ifdef _SDR_NORECTOBJ + #undef _SDR_NORECTOBJ + #define _SVDORECT_HXX +#else + #undef _SDVOTEXT_OBJ +#endif + +#ifdef _SDR_NOCAPTIONOBJ + #undef _SDR_NOCAPTIONOBJ + #define _SVDCAPT_HXX +#endif + +#ifdef _SDR_NOCIRCLEOBJ + #undef _SDR_NOCIRCLEOBJ + #define _SVDOCIRC_HXX +#endif + +#ifdef _SDR_NOGRAFOBJ + #undef _SDR_NOGRAFOBJ + #define _SVDOGRAF_HXX +#else + #undef _SVDOTEXT_HXX + #undef _SVDORECT_HXX +#endif + +#ifdef _SDR_NOOLE2OBJ + #undef _SDR_NOOLE2OBJ + #define _SVDOOLE2_HXX +#else + #undef _SVDOTEXT_HXX + #undef _SVDORECT_HXX +#endif + +//#ifdef _SDR_NOVIEWS +// #define _SVDDRAG_HXX +//#endif + +////////////////////// Ende der SVDRAW-Modifikationen ///////////////////// + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <sfx2/ipfrm.hxx> +#include <sfx2/bindings.hxx> +#include <vcl/help.hxx> + +#include "tabview.hxx" +#include "tabvwsh.hxx" +#include "document.hxx" +#include "gridwin.hxx" +#include "olinewin.hxx" +#include "olinetab.hxx" +#include "tabsplit.hxx" +#include "colrowba.hxx" +#include "tabcont.hxx" +#include "scmod.hxx" +#include "sc.hrc" +#include "viewutil.hxx" +#include "globstr.hrc" +#include "drawview.hxx" + +#define SPLIT_MARGIN 30 +#define SC_ICONSIZE 36 + +#define SC_SCROLLBAR_MIN 30 +#define SC_TABBAR_MIN 6 + +// fuer Rad-Maus +#define SC_DELTA_ZOOM 10 + +// STATIC DATA ----------------------------------------------------------- + + +//================================================================== + +// Corner-Button + +ScCornerButton::ScCornerButton( Window* pParent, ScViewData* pData, BOOL bAdditional ) : + Window( pParent, WinBits( 0 ) ), + pViewData( pData ), + bAdd( bAdditional ) +{ + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + SetBackground( rStyleSettings.GetFaceColor() ); +} + +__EXPORT ScCornerButton::~ScCornerButton() +{ +} + +void __EXPORT ScCornerButton::Paint( const Rectangle& rRect ) +{ + Size aSize = GetOutputSizePixel(); + long nPosX = aSize.Width()-1; + long nPosY = aSize.Height()-1; + + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + + Window::Paint(rRect); + + if (bAdd) + { + SetLineColor( rStyleSettings.GetDarkShadowColor() ); + DrawLine( Point(0,nPosY), Point(nPosX,nPosY) ); + DrawLine( Point(nPosX,0), Point(nPosX,nPosY) ); + } + else + { + SetLineColor( rStyleSettings.GetLightColor() ); + DrawLine( Point(0,0), Point(0,nPosY) ); + DrawLine( Point(0,0), Point(nPosX,0) ); +// SetLineColor( Color( SC_SMALL3DSHADOW ) ); + SetLineColor( rStyleSettings.GetDarkShadowColor() ); + DrawLine( Point(0,nPosY), Point(nPosX,nPosY) ); + DrawLine( Point(nPosX,0), Point(nPosX,nPosY) ); + } +} + +void ScCornerButton::StateChanged( StateChangedType nType ) +{ + Window::StateChanged( nType ); + + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + SetBackground( rStyleSettings.GetFaceColor() ); + Invalidate(); +} + +// ----------------------------------------------------------------------- + +void ScCornerButton::DataChanged( const DataChangedEvent& rDCEvt ) +{ + Window::DataChanged( rDCEvt ); + + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + SetBackground( rStyleSettings.GetFaceColor() ); + Invalidate(); +} + + +void __EXPORT ScCornerButton::Resize() +{ + Invalidate(); +} + +void __EXPORT ScCornerButton::MouseButtonDown( const MouseEvent& rMEvt ) +{ + ScModule* pScMod = SC_MOD(); + BOOL bDisable = pScMod->IsFormulaMode() || pScMod->IsModalMode(); + if (!bDisable) + { + ScTabViewShell* pViewSh = pViewData->GetViewShell(); + pViewSh->SetActive(); // Appear und SetViewFrame + pViewSh->ActiveGrabFocus(); + + BOOL bControl = rMEvt.IsMod1(); + pViewSh->SelectAll( bControl ); + } +} + +//================================================================== + +BOOL lcl_HasColOutline( const ScViewData& rViewData ) +{ + const ScOutlineTable* pTable = rViewData.GetDocument()->GetOutlineTable(rViewData.GetTabNo()); + if (pTable) + { + const ScOutlineArray* pArray = pTable->GetColArray(); + if ( pArray->GetDepth() > 0 ) + return TRUE; + } + return FALSE; +} + +BOOL lcl_HasRowOutline( const ScViewData& rViewData ) +{ + const ScOutlineTable* pTable = rViewData.GetDocument()->GetOutlineTable(rViewData.GetTabNo()); + if (pTable) + { + const ScOutlineArray* pArray = pTable->GetRowArray(); + if ( pArray->GetDepth() > 0 ) + return TRUE; + } + return FALSE; +} + +//================================================================== + +// Init und Konstruktoren +// ScTabView::Init() in tabview5.cxx wegen out of keys + + +#define TABVIEW_INIT \ + aFunctionSet( &aViewData ), \ + aHdrFunc( &aViewData ), \ + aHScrollLeft( pFrameWin, WinBits( WB_HSCROLL | WB_DRAG ) ), \ + aHScrollRight( pFrameWin, WinBits( WB_HSCROLL | WB_DRAG ) ), \ + aVScrollTop( pFrameWin, WinBits( WB_VSCROLL | WB_DRAG ) ), \ + aVScrollBottom( pFrameWin, WinBits( WB_VSCROLL | WB_DRAG ) ), \ + aCornerButton( pFrameWin, &aViewData, FALSE ), \ + aTopButton( pFrameWin, &aViewData, TRUE ), \ + aScrollBarBox( pFrameWin, WB_SIZEABLE ), \ + pInputHintWindow( NULL ), \ + pPageBreakData( NULL ), \ + pHighlightRanges( NULL ), \ + bDragging( FALSE ), \ + bIsBlockMode( FALSE ), \ + bBlockNeg( FALSE ), \ + bBlockCols( FALSE ), \ + bBlockRows( FALSE ), \ + nTipVisible( 0 ), \ + pDrawView( NULL ), \ + bDrawSelMode( FALSE ), \ + bMinimized( FALSE ), \ + pTimerWindow( NULL ), \ + pSelEngine( NULL ), \ + pHdrSelEng( NULL ), \ + bInUpdateHeader( FALSE ), \ + bInActivatePart( FALSE ), \ + bInZoomUpdate( FALSE ), \ + bMoveIsShift( FALSE ) + + +ScTabView::ScTabView( Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell ) : + pFrameWin( pParent ), + aViewData( &rDocSh, pViewShell ), + eZoomType( SVX_ZOOM_PERCENT ), + TABVIEW_INIT +{ + Init(); +} + +ScTabView::ScTabView( Window* pParent, const ScTabView& rScTabView, ScTabViewShell* pViewShell ) : + pFrameWin( pParent ), + aViewData( rScTabView.aViewData ), + eZoomType( rScTabView.eZoomType ), + TABVIEW_INIT +{ + aViewData.SetViewShell( pViewShell ); + Init(); + + UpdateShow(); + if ( aViewData.GetActivePart() != SC_SPLIT_BOTTOMLEFT ) + pGridWin[SC_SPLIT_BOTTOMLEFT]->Show(); + + InvalidateSplit(); +} + +void ScTabView::InitScrollBar( ScrollBar& rScrollBar, long nMaxVal ) +{ + rScrollBar.SetRange( Range( 0, nMaxVal ) ); + rScrollBar.SetLineSize( 1 ); + rScrollBar.SetPageSize( 1 ); // wird getrennt abgefragt + rScrollBar.SetVisibleSize( 10 ); // wird bei Resize neu gesetzt + + rScrollBar.SetScrollHdl( LINK(this, ScTabView, ScrollHdl) ); + rScrollBar.SetEndScrollHdl( LINK(this, ScTabView, EndScrollHdl) ); +} + +// Scroll-Timer + +void ScTabView::SetTimer( ScGridWindow* pWin, const MouseEvent& rMEvt ) +{ + pTimerWindow = pWin; + aTimerMEvt = rMEvt; + aScrollTimer.Start(); +} + +void ScTabView::ResetTimer() +{ + aScrollTimer.Stop(); + pTimerWindow = NULL; +} + +IMPL_LINK( ScTabView, TimerHdl, Timer*, pTimer ) +{ + DBG_ASSERT( pTimer == &aScrollTimer, "Unbekannter Timer" ); + +// aScrollTimer.Stop(); + if (pTimerWindow) + pTimerWindow->MouseMove( aTimerMEvt ); + + return 0; +} + +// --- Resize --------------------------------------------------------------------- + +void ScTabView::DoResize( const Point& rOffset, const Size& rSize, BOOL bInner ) +{ + HideListBox(); + + BOOL bHasHint = ( pInputHintWindow != NULL ); + if (bHasHint) + RemoveHintWindow(); + + BOOL bVScroll = aViewData.IsVScrollMode(); + BOOL bHScroll = aViewData.IsHScrollMode(); + BOOL bTabControl = aViewData.IsTabMode(); + BOOL bHeaders = aViewData.IsHeaderMode(); + BOOL bOutlMode = aViewData.IsOutlineMode(); + BOOL bHOutline = bOutlMode && lcl_HasColOutline(aViewData); + BOOL bVOutline = bOutlMode && lcl_HasRowOutline(aViewData); + + // Scrollbar-Einstellungen koennen vom Sfx ueberschrieben werden: + SfxScrollingMode eMode = aViewData.GetViewShell()->GetScrollingMode(); + if ( eMode == SCROLLING_NO ) + bHScroll = bVScroll = FALSE; + else if ( eMode == SCROLLING_YES || eMode == SCROLLING_AUTO ) //! Auto ??? + bHScroll = bVScroll = TRUE; + + long nBarX = 0; + long nBarY = 0; + long nOutlineX; + long nOutlineY; + long nOutPosX; + long nOutPosY; + + long nPosX = rOffset.X(); + long nPosY = rOffset.Y(); + long nSizeX = rSize.Width(); + long nSizeY = rSize.Height(); + long nSize1; + + bMinimized = ( nSizeX<=SC_ICONSIZE || nSizeY<=SC_ICONSIZE ); + if ( bMinimized ) + return; + + long nSplitSizeX = SPLIT_HANDLE_SIZE; + if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX ) + nSplitSizeX = 1; + long nSplitSizeY = SPLIT_HANDLE_SIZE; + if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX ) + nSplitSizeY = 1; + + const long nOverlap = 0; // ScrollBar::GetWindowOverlapPixel(); + + aBorderPos = rOffset; + aFrameSize = rSize; + + if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE ) + if ( aViewData.GetHSplitPos() > nSizeX - SPLIT_MARGIN ) + { + aViewData.SetHSplitMode( SC_SPLIT_NONE ); + if ( WhichH( aViewData.GetActivePart() ) == SC_SPLIT_RIGHT ) + ActivatePart( SC_SPLIT_BOTTOMLEFT ); + InvalidateSplit(); +// UpdateShow(); + } + if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE ) + if ( aViewData.GetVSplitPos() > nSizeY - SPLIT_MARGIN ) + { + aViewData.SetVSplitMode( SC_SPLIT_NONE ); + if ( WhichV( aViewData.GetActivePart() ) == SC_SPLIT_TOP ) + ActivatePart( SC_SPLIT_BOTTOMLEFT ); + InvalidateSplit(); +// UpdateShow(); + } + + UpdateShow(); + + if (bHScroll || bVScroll) // Scrollbars horizontal oder vertikal + { + if (bVScroll) + { + nBarX = aVScrollBottom.GetSizePixel().Width(); + nSizeX -= nBarX - nOverlap; + } + if (bHScroll) + { + nBarY = aHScrollLeft.GetSizePixel().Height(); + nSizeY -= nBarY - nOverlap; + } + + // Fenster rechts unten + aScrollBarBox.SetPosSizePixel( Point( nPosX+nSizeX, nPosY+nSizeY ), Size( nBarX, nBarY ) ); + + if (bHScroll) // Scrollbars horizontal + { + long nSizeLt; // linker Scrollbar + long nSizeRt; // rechter Scrollbar + long nSizeSp; // Splitter + + switch (aViewData.GetHSplitMode()) + { + case SC_SPLIT_NONE: + nSizeSp = nSplitSizeX; + nSizeLt = nSizeX - nSizeSp + nOverlap; // Ecke ueberdecken + break; + case SC_SPLIT_NORMAL: + nSizeSp = nSplitSizeX; + nSizeLt = aViewData.GetHSplitPos(); + break; + case SC_SPLIT_FIX: + nSizeSp = 0; + nSizeLt = 0; + break; + } + nSizeRt = nSizeX - nSizeLt - nSizeSp; + + long nTabSize = 0; + if (bTabControl) + { + nTabSize = pTabControl->GetSizePixel().Width()-nOverlap; + + if ( aViewData.GetHSplitMode() != SC_SPLIT_FIX ) // bei linkem Scrollbar + { + if (nTabSize > nSizeLt-SC_SCROLLBAR_MIN) nTabSize = nSizeLt-SC_SCROLLBAR_MIN; + if (nTabSize < SC_TABBAR_MIN) nTabSize = SC_TABBAR_MIN; + nSizeLt -= nTabSize; + } + else // bei rechtem Scrollbar + { + if (nTabSize > nSizeRt-SC_SCROLLBAR_MIN) nTabSize = nSizeRt-SC_SCROLLBAR_MIN; + if (nTabSize < SC_TABBAR_MIN) nTabSize = SC_TABBAR_MIN; + nSizeRt -= nTabSize; + } + } + + pTabControl->SetPosSizePixel( Point(nPosX-nOverlap, nPosY+nSizeY), + Size(nTabSize+nOverlap, nBarY) ); + + aHScrollLeft.SetPosSizePixel( Point(nPosX+nTabSize-nOverlap, nPosY+nSizeY), + Size(nSizeLt+2*nOverlap, nBarY) ); + pHSplitter->SetPosPixel( Point( nPosX+nTabSize+nSizeLt, nPosY+nSizeY ) ); + aHScrollRight.SetPosSizePixel( Point(nPosX+nTabSize+nSizeLt+nSizeSp-nOverlap, + nPosY+nSizeY), + Size(nSizeRt+2*nOverlap, nBarY) ); + + pHSplitter->SetSizePixel( Size( nSizeSp, nBarY ) ); + // SetDragRectPixel ist unten + } + + if (bVScroll) // Scrollbars vertikal + { + long nSizeUp; // oberer Scrollbar + long nSizeSp; // Splitter + long nSizeDn; // unterer Scrollbar + + switch (aViewData.GetVSplitMode()) + { + case SC_SPLIT_NONE: + nSizeUp = 0; + nSizeSp = nSplitSizeY; + break; + case SC_SPLIT_NORMAL: + nSizeUp = aViewData.GetVSplitPos(); + nSizeSp = nSplitSizeY; + break; + case SC_SPLIT_FIX: + nSizeUp = 0; + nSizeSp = 0; + break; + } + nSizeDn = nSizeY - nSizeUp - nSizeSp; + + aVScrollTop.SetPosSizePixel( Point(nPosX+nSizeX, nPosY-nOverlap), + Size(nBarX,nSizeUp+2*nOverlap) ); + pVSplitter->SetPosPixel( Point( nPosX+nSizeX, nPosY+nSizeUp ) ); + aVScrollBottom.SetPosSizePixel( Point(nPosX+nSizeX, + nPosY+nSizeUp+nSizeSp-nOverlap), + Size(nBarX, nSizeDn+2*nOverlap) ); + + pVSplitter->SetSizePixel( Size( nBarX, nSizeSp ) ); + // SetDragRectPixel ist unten + } + } + + // SetDragRectPixel auch ohne Scrollbars etc., wenn schon gesplittet ist + if ( bHScroll || aViewData.GetHSplitMode() != SC_SPLIT_NONE ) + pHSplitter->SetDragRectPixel( + Rectangle( nPosX, nPosY, nPosX+nSizeX, nPosY+nSizeY ), pFrameWin ); + if ( bVScroll || aViewData.GetVSplitMode() != SC_SPLIT_NONE ) + pVSplitter->SetDragRectPixel( + Rectangle( nPosX, nPosY, nPosX+nSizeX, nPosY+nSizeY ), pFrameWin ); + + if (bTabControl && ! bHScroll ) + { + nBarY = aHScrollLeft.GetSizePixel().Height(); + nBarX = aVScrollBottom.GetSizePixel().Width(); + + nSize1 = nSizeX + nOverlap; + + long nTabSize = nSize1; + if (nTabSize < 0) nTabSize = 0; + + pTabControl->SetPosSizePixel( Point(nPosX-nOverlap, nPosY+nSizeY-nBarY), + Size(nTabSize+nOverlap, nBarY) ); + nSizeY -= nBarY - nOverlap; + aScrollBarBox.SetPosSizePixel( Point( nPosX+nSizeX, nPosY+nSizeY ), Size( nBarX, nBarY ) ); + + if( bVScroll ) + { + Size aVScrSize = aVScrollBottom.GetSizePixel(); + aVScrSize.Height() -= nBarY; + aVScrollBottom.SetSizePixel( aVScrSize ); + } + } + + nOutPosX = nPosX; + nOutPosY = nPosY; + + // Outline-Controls + if (bVOutline && pRowOutline[SC_SPLIT_BOTTOM]) + { + nOutlineX = pRowOutline[SC_SPLIT_BOTTOM]->GetDepthSize(); + nSizeX -= nOutlineX; + nPosX += nOutlineX; + } + if (bHOutline && pColOutline[SC_SPLIT_LEFT]) + { + nOutlineY = pColOutline[SC_SPLIT_LEFT]->GetDepthSize(); + nSizeY -= nOutlineY; + nPosY += nOutlineY; + } + + if (bHeaders) // Spalten/Zeilen-Header + { + nBarX = pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width(); + nBarY = pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height(); + nSizeX -= nBarX; + nSizeY -= nBarY; + nPosX += nBarX; + nPosY += nBarY; + } + else + nBarX = nBarY = 0; + + // + // Splitter auswerten + // + + long nLeftSize = nSizeX; + long nRightSize = 0; + long nTopSize = 0; + long nBottomSize = nSizeY; + long nSplitPosX = nPosX; + long nSplitPosY = nPosY; + + if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE ) + { + long nSplitHeight = rSize.Height(); + if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX ) + { + // Fixier-Splitter nicht mit Scrollbar/TabBar ueberlappen lassen + if ( bHScroll ) + nSplitHeight -= aHScrollLeft.GetSizePixel().Height(); + else if ( bTabControl && pTabControl ) + nSplitHeight -= pTabControl->GetSizePixel().Height(); + } + nSplitPosX = aViewData.GetHSplitPos(); + pHSplitter->SetPosSizePixel( + Point( nSplitPosX, nOutPosY ), Size( nSplitSizeX, nSplitHeight ) ); + nLeftSize = nSplitPosX - nPosX; + nSplitPosX += nSplitSizeX; + nRightSize = nSizeX - nLeftSize - nSplitSizeX; + } + if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE ) + { + long nSplitWidth = rSize.Width(); + if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX && bVScroll ) + nSplitWidth -= aVScrollBottom.GetSizePixel().Width(); + nSplitPosY = aViewData.GetVSplitPos(); + pVSplitter->SetPosSizePixel( + Point( nOutPosX, nSplitPosY ), Size( nSplitWidth, nSplitSizeY ) ); + nTopSize = nSplitPosY - nPosY; + nSplitPosY += nSplitSizeY; + nBottomSize = nSizeY - nTopSize - nSplitSizeY; + } + + // ShowHide fuer pColOutline / pRowOutline passiert in UpdateShow + + if (bHOutline) // Outline-Controls + { + if (pColOutline[SC_SPLIT_LEFT]) + { + pColOutline[SC_SPLIT_LEFT]->SetHeaderSize( (USHORT) nBarX ); + pColOutline[SC_SPLIT_LEFT]->SetPosSizePixel( + Point(nPosX-nBarX,nOutPosY), Size(nLeftSize+nBarX,nOutlineY) ); + } + if (pColOutline[SC_SPLIT_RIGHT]) + pColOutline[SC_SPLIT_RIGHT]->SetPosSizePixel( + Point(nSplitPosX,nOutPosY), Size(nRightSize,nOutlineY) ); + } + if (bVOutline) + { + if (nTopSize) + { + if (pRowOutline[SC_SPLIT_TOP] && pRowOutline[SC_SPLIT_BOTTOM]) + { + pRowOutline[SC_SPLIT_TOP]->SetHeaderSize( (USHORT) nBarY ); + pRowOutline[SC_SPLIT_TOP]->SetPosSizePixel( + Point(nOutPosX,nPosY-nBarY), Size(nOutlineX,nTopSize+nBarY) ); + pRowOutline[SC_SPLIT_BOTTOM]->SetHeaderSize( 0 ); + pRowOutline[SC_SPLIT_BOTTOM]->SetPosSizePixel( + Point(nOutPosX,nSplitPosY), Size(nOutlineX,nBottomSize) ); + } + } + else if (pRowOutline[SC_SPLIT_BOTTOM]) + { + pRowOutline[SC_SPLIT_BOTTOM]->SetHeaderSize( (USHORT) nBarY ); + pRowOutline[SC_SPLIT_BOTTOM]->SetPosSizePixel( + Point(nOutPosX,nSplitPosY-nBarY), Size(nOutlineX,nBottomSize+nBarY) ); + } + } + if (bHOutline && bVOutline) + { + aTopButton.SetPosSizePixel( Point(nOutPosX,nOutPosY), Size(nOutlineX,nOutlineY) ); + aTopButton.Show(); + } + else + aTopButton.Hide(); + + if (bHeaders) // Spalten/Zeilen-Header + { + pColBar[SC_SPLIT_LEFT]->SetPosSizePixel( + Point(nPosX,nPosY-nBarY), Size(nLeftSize,nBarY) ); + if (pColBar[SC_SPLIT_RIGHT]) + pColBar[SC_SPLIT_RIGHT]->SetPosSizePixel( + Point(nSplitPosX,nPosY-nBarY), Size(nRightSize,nBarY) ); + + if (pRowBar[SC_SPLIT_TOP]) + pRowBar[SC_SPLIT_TOP]->SetPosSizePixel( + Point(nPosX-nBarX,nPosY), Size(nBarX,nTopSize) ); + pRowBar[SC_SPLIT_BOTTOM]->SetPosSizePixel( + Point(nPosX-nBarX,nSplitPosY), Size(nBarX,nBottomSize) ); + + aCornerButton.SetPosSizePixel( Point(nPosX-nBarX,nPosY-nBarY), Size(nBarX,nBarY) ); + aCornerButton.Show(); + pColBar[SC_SPLIT_LEFT]->Show(); + pRowBar[SC_SPLIT_BOTTOM]->Show(); + } + else + { + aCornerButton.Hide(); + pColBar[SC_SPLIT_LEFT]->Hide(); // immer da + pRowBar[SC_SPLIT_BOTTOM]->Hide(); + } + + + // Grid-Windows + + if (bInner) + { + pGridWin[SC_SPLIT_BOTTOMLEFT]->SetPosPixel( Point(nPosX,nSplitPosY) ); + } + else + { + pGridWin[SC_SPLIT_BOTTOMLEFT]->SetPosSizePixel( + Point(nPosX,nSplitPosY), Size(nLeftSize,nBottomSize) ); + if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE ) + pGridWin[SC_SPLIT_BOTTOMRIGHT]->SetPosSizePixel( + Point(nSplitPosX,nSplitPosY), Size(nRightSize,nBottomSize) ); + if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE ) + pGridWin[SC_SPLIT_TOPLEFT]->SetPosSizePixel( + Point(nPosX,nPosY), Size(nLeftSize,nTopSize) ); + if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE && aViewData.GetVSplitMode() != SC_SPLIT_NONE ) + pGridWin[SC_SPLIT_TOPRIGHT]->SetPosSizePixel( + Point(nSplitPosX,nPosY), Size(nRightSize,nTopSize) ); + } + + // + // Scrollbars updaten + // + + if (!bInUpdateHeader) + { + UpdateScrollBars(); // Scrollbars nicht beim Scrollen neu setzen + UpdateHeaderWidth(); + + InterpretVisible(); // #69343# have everything calculated before painting + } + + if (bHasHint) + TestHintWindow(); // neu positionieren + + UpdateVarZoom(); // update variable zoom types (after resizing GridWindows) +} + +void ScTabView::UpdateVarZoom() +{ + // update variable zoom types + + if ( eZoomType != SVX_ZOOM_PERCENT && !bInZoomUpdate ) + { + bInZoomUpdate = TRUE; + const Fraction& rOldX = GetViewData()->GetZoomX(); + const Fraction& rOldY = GetViewData()->GetZoomY(); + long nOldPercent = ( rOldY.GetNumerator() * 100 ) / rOldY.GetDenominator(); + USHORT nNewZoom = CalcZoom( eZoomType, (USHORT)nOldPercent ); + Fraction aNew( nNewZoom, 100 ); + + if ( aNew != rOldX || aNew != rOldY ) + { + SetZoom( aNew, aNew ); + PaintGrid(); + PaintTop(); + PaintLeft(); + aViewData.GetViewShell()->GetViewFrame()->GetBindings(). + Invalidate( SID_ATTR_ZOOM ); + } + bInZoomUpdate = FALSE; + } +} + +void ScTabView::UpdateFixPos() +{ + BOOL bResize = FALSE; + if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX ) + if (aViewData.UpdateFixX()) + bResize = TRUE; + if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX ) + if (aViewData.UpdateFixY()) + bResize = TRUE; + if (bResize) + RepeatResize(FALSE); +} + +void ScTabView::RepeatResize( BOOL bUpdateFix ) +{ + if ( bUpdateFix ) + { + if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX ) + aViewData.UpdateFixX(); + if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX ) + aViewData.UpdateFixY(); + } + + DoResize( aBorderPos, aFrameSize ); + + //! Border muss neu gesetzt werden ??? +} + +void ScTabView::GetBorderSize( SvBorder& rBorder, const Size& rSize ) +{ + BOOL bScrollBars = aViewData.IsVScrollMode(); + BOOL bTabControl = aViewData.IsTabMode(); + BOOL bHeaders = aViewData.IsHeaderMode(); + BOOL bOutlMode = aViewData.IsOutlineMode(); + BOOL bHOutline = bOutlMode && lcl_HasColOutline(aViewData); + BOOL bVOutline = bOutlMode && lcl_HasRowOutline(aViewData); + + rBorder = SvBorder(); + + if (bScrollBars) // Scrollbars horizontal oder vertikal + { + rBorder.Right() += aVScrollBottom.GetSizePixel().Width(); + rBorder.Bottom() += aHScrollLeft.GetSizePixel().Height(); + } + + // Outline-Controls + if (bVOutline && pRowOutline[SC_SPLIT_BOTTOM]) + rBorder.Left() += pRowOutline[SC_SPLIT_BOTTOM]->GetDepthSize(); + if (bHOutline && pColOutline[SC_SPLIT_LEFT]) + rBorder.Top() += pColOutline[SC_SPLIT_LEFT]->GetDepthSize(); + + if (bHeaders) // Spalten/Zeilen-Header + { + rBorder.Left() += pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width(); + rBorder.Top() += pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height(); + } +} + +IMPL_LINK( ScTabView, TabBarResize, void*, EMPTY_ARG ) +{ + BOOL bHScrollMode = aViewData.IsHScrollMode(); + + // Scrollbar-Einstellungen koennen vom Sfx ueberschrieben werden: + SfxScrollingMode eMode = aViewData.GetViewShell()->GetScrollingMode(); + if ( eMode == SCROLLING_NO ) + bHScrollMode = FALSE; + else if ( eMode == SCROLLING_YES || eMode == SCROLLING_AUTO ) //! Auto ??? + bHScrollMode = TRUE; + + if( bHScrollMode ) + { + const long nOverlap = 0; // ScrollBar::GetWindowOverlapPixel(); + long nSize = pTabControl->GetSplitSize(); + + if (aViewData.GetHSplitMode() != SC_SPLIT_FIX) + { + long nMax = pHSplitter->GetPosPixel().X() - 1; + if (nSize>nMax) nSize = nMax; + } + + if ( nSize != pTabControl->GetSizePixel().Width() ) + { + pTabControl->SetSizePixel( Size( nSize+nOverlap, + pTabControl->GetSizePixel().Height() ) ); + RepeatResize(); + } + } + + return 0; +} + +void ScTabView::SetTabBarWidth( long nNewWidth ) +{ + Size aSize = pTabControl->GetSizePixel(); + + if ( aSize.Width() != nNewWidth ) + { + aSize.Width() = nNewWidth; + pTabControl->SetSizePixel( aSize ); + } +} + +long ScTabView::GetTabBarWidth() +{ + return pTabControl->GetSizePixel().Width(); +} + +Window* ScTabView::GetActiveWin() +{ + ScSplitPos ePos = aViewData.GetActivePart(); + DBG_ASSERT(pGridWin[ePos],"kein aktives Fenster"); + return pGridWin[ePos]; +} + +Window* ScTabView::GetWindowByPos( ScSplitPos ePos ) +{ + return pGridWin[ePos]; +} + +void ScTabView::SetActivePointer( const Pointer& rPointer ) +{ + for (USHORT i=0; i<4; i++) + if (pGridWin[i]) + pGridWin[i]->SetPointer( rPointer ); + +/* ScSplitPos ePos = aViewData.GetActivePart(); + if (pGridWin[ePos]) + pGridWin[ePos]->SetPointer( rPointer ); +*/ +} + +void ScTabView::SetActivePointer( const ResId& rId ) +{ +#ifdef VCL + DBG_ERRORFILE( "keine Pointer mit ResId!" ); +#else + for (USHORT i=0; i<4; i++) + if (pGridWin[i]) + pGridWin[i]->SetPointer( rId ); + +/* ScSplitPos ePos = aViewData.GetActivePart(); + if (pGridWin[ePos]) + pGridWin[ePos]->SetPointer( rId ); +*/ +#endif +} + +void ScTabView::ActiveGrabFocus() +{ + ScSplitPos ePos = aViewData.GetActivePart(); + if (pGridWin[ePos]) + pGridWin[ePos]->GrabFocus(); +} + +void ScTabView::ActiveCaptureMouse() +{ + ScSplitPos ePos = aViewData.GetActivePart(); + if (pGridWin[ePos]) + pGridWin[ePos]->CaptureMouse(); +} + +void ScTabView::ActiveReleaseMouse() +{ + ScSplitPos ePos = aViewData.GetActivePart(); + if (pGridWin[ePos]) + pGridWin[ePos]->ReleaseMouse(); +} + +Point ScTabView::ActivePixelToLogic( const Point& rDevicePoint ) +{ + ScSplitPos ePos = aViewData.GetActivePart(); + if (pGridWin[ePos]) + return pGridWin[ePos]->PixelToLogic(rDevicePoint); + else + return Point(); +} + +ScSplitPos ScTabView::FindWindow( Window* pWindow ) const +{ + ScSplitPos eVal = SC_SPLIT_BOTTOMLEFT; // Default + for (USHORT i=0; i<4; i++) + if ( pGridWin[i] == pWindow ) + eVal = (ScSplitPos) i; + + return eVal; +} + +Point ScTabView::GetGridOffset() const +{ + Point aPos; + + // Groessen hier wie in DoResize + + BOOL bHeaders = aViewData.IsHeaderMode(); + BOOL bOutlMode = aViewData.IsOutlineMode(); + BOOL bHOutline = bOutlMode && lcl_HasColOutline(aViewData); + BOOL bVOutline = bOutlMode && lcl_HasRowOutline(aViewData); + + // Outline-Controls + if (bVOutline && pRowOutline[SC_SPLIT_BOTTOM]) + aPos.X() += pRowOutline[SC_SPLIT_BOTTOM]->GetDepthSize(); + if (bHOutline && pColOutline[SC_SPLIT_LEFT]) + aPos.Y() += pColOutline[SC_SPLIT_LEFT]->GetDepthSize(); + + if (bHeaders) // Spalten/Zeilen-Header + { + if (pRowBar[SC_SPLIT_BOTTOM]) + aPos.X() += pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width(); + if (pColBar[SC_SPLIT_LEFT]) + aPos.Y() += pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height(); + } + + return aPos; +} + +// --- Scroll-Bars -------------------------------------------------------- + +BOOL ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos ) +{ + HideNoteMarker(); + + BOOL bDone = FALSE; + const CommandWheelData* pData = rCEvt.GetWheelData(); + if ( pData && pData->GetMode() == COMMAND_WHEEL_ZOOM ) + { + const Fraction& rOldY = aViewData.GetZoomY(); + long nOld = (USHORT)(( rOldY.GetNumerator() * 100 ) / rOldY.GetDenominator()); + long nNew = nOld; + if ( pData->GetDelta() < 0 ) + nNew = Max( (long) MINZOOM, (long)( nOld - SC_DELTA_ZOOM ) ); + else + nNew = Min( (long) MAXZOOM, (long)( nOld + SC_DELTA_ZOOM ) ); + + if ( nNew != nOld ) + { + //! Zoom an AppOptions merken ??? + + SetZoomType( SVX_ZOOM_PERCENT ); + Fraction aFract( nNew, 100 ); + SetZoom( aFract, aFract ); + PaintGrid(); + PaintTop(); + PaintLeft(); + SFX_BINDINGS().Invalidate( SID_ATTR_ZOOM ); + } + + bDone = TRUE; + } + else + { + ScHSplitPos eHPos = WhichH(ePos); + ScVSplitPos eVPos = WhichV(ePos); + ScrollBar* pHScroll = ( eHPos == SC_SPLIT_LEFT ) ? &aHScrollLeft : &aHScrollRight; + ScrollBar* pVScroll = ( eVPos == SC_SPLIT_TOP ) ? &aVScrollTop : &aVScrollBottom; + if ( pGridWin[ePos] ) + bDone = pGridWin[ePos]->HandleScrollCommand( rCEvt, pHScroll, pVScroll ); + } + return bDone; +} + +IMPL_LINK( ScTabView, EndScrollHdl, ScrollBar*, pScroll ) +{ + BOOL bOnlineScroll = TRUE; //! Optionen + + if ( bDragging ) + { + if ( bOnlineScroll ) // nur Ranges aktualisieren + UpdateScrollBars(); + else + { + long nScrollMin = 0; // RangeMin simulieren + if ( aViewData.GetHSplitMode()==SC_SPLIT_FIX && pScroll == &aHScrollRight ) + nScrollMin = aViewData.GetFixPosX(); + if ( aViewData.GetVSplitMode()==SC_SPLIT_FIX && pScroll == &aVScrollBottom ) + nScrollMin = aViewData.GetFixPosY(); + + if ( pScroll == &aHScrollLeft || pScroll == &aHScrollRight ) + { + ScHSplitPos eWhich = (pScroll == &aHScrollLeft) ? SC_SPLIT_LEFT : SC_SPLIT_RIGHT; + long nDelta = pScroll->GetThumbPos() + nScrollMin - aViewData.GetPosX(eWhich); + if (nDelta) ScrollX( nDelta, eWhich ); + } + else // VScroll... + { + ScVSplitPos eWhich = (pScroll == &aVScrollTop) ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM; + long nDelta = pScroll->GetThumbPos() + nScrollMin - aViewData.GetPosY(eWhich); + if (nDelta) ScrollY( nDelta, eWhich ); + } + } + bDragging = FALSE; + } + return 0; +} + +IMPL_LINK( ScTabView, ScrollHdl, ScrollBar*, pScroll ) +{ + BOOL bOnlineScroll = TRUE; //! Optionen + + BOOL bHoriz = ( pScroll == &aHScrollLeft || pScroll == &aHScrollRight ); + long nViewPos; + if ( bHoriz ) + nViewPos = aViewData.GetPosX( (pScroll == &aHScrollLeft) ? + SC_SPLIT_LEFT : SC_SPLIT_RIGHT ); + else + nViewPos = aViewData.GetPosY( (pScroll == &aVScrollTop) ? + SC_SPLIT_TOP : SC_SPLIT_BOTTOM ); + + ScrollType eType = pScroll->GetType(); + if ( eType == SCROLL_DRAG ) + { + if (!bDragging) + { + bDragging = TRUE; + nPrevDragPos = nViewPos; + } + + // Scroll-Position anzeigen + // (nur QuickHelp, in der Statuszeile gibt es keinen Eintrag dafuer) + + if (Help::IsQuickHelpEnabled()) + { +#ifdef VCL + Point aMousePos = pScroll->OutputToScreenPixel(pScroll->GetPointerPosPixel()); +#else + Point aMousePos = Pointer::GetPosPixel(); +#endif + long nScrollMin = 0; // RangeMin simulieren + if ( aViewData.GetHSplitMode()==SC_SPLIT_FIX && pScroll == &aHScrollRight ) + nScrollMin = aViewData.GetFixPosX(); + if ( aViewData.GetVSplitMode()==SC_SPLIT_FIX && pScroll == &aVScrollBottom ) + nScrollMin = aViewData.GetFixPosY(); + + String aHelpStr; + long nScrollPos = pScroll->GetThumbPos() + nScrollMin; + Point aPos = pScroll->GetParent()->OutputToScreenPixel(pScroll->GetPosPixel()); + Size aSize = pScroll->GetSizePixel(); + Rectangle aRect; + USHORT nAlign; + if (bHoriz) + { + aHelpStr = ScGlobal::GetRscString(STR_COLUMN); + aHelpStr += ' '; + aHelpStr += ColToAlpha((USHORT) nScrollPos); + + aRect.Left() = aMousePos.X(); + aRect.Top() = aPos.Y() - 4; + nAlign = QUICKHELP_BOTTOM|QUICKHELP_CENTER; + } + else + { + aHelpStr = ScGlobal::GetRscString(STR_ROW); + aHelpStr += ' '; + aHelpStr += String::CreateFromInt32(nScrollPos + 1); + + aRect.Left() = aPos.X() - 8; + aRect.Top() = aMousePos.Y(); + nAlign = QUICKHELP_RIGHT|QUICKHELP_VCENTER; + } + aRect.Right() = aRect.Left(); + aRect.Bottom() = aRect.Top(); + + Help::ShowQuickHelp(pScroll->GetParent(), aRect, aHelpStr, nAlign); + } + } + + if ( bOnlineScroll || eType != SCROLL_DRAG ) + { + long nDelta = pScroll->GetDelta(); + switch ( eType ) + { + case SCROLL_LINEUP: + nDelta = -1; + break; + case SCROLL_LINEDOWN: + nDelta = 1; + break; + case SCROLL_PAGEUP: + if ( pScroll == &aHScrollLeft ) nDelta = -(long) aViewData.PrevCellsX( SC_SPLIT_LEFT ); + if ( pScroll == &aHScrollRight ) nDelta = -(long) aViewData.PrevCellsX( SC_SPLIT_RIGHT ); + if ( pScroll == &aVScrollTop ) nDelta = -(long) aViewData.PrevCellsY( SC_SPLIT_TOP ); + if ( pScroll == &aVScrollBottom ) nDelta = -(long) aViewData.PrevCellsY( SC_SPLIT_BOTTOM ); + if (nDelta==0) nDelta=-1; + break; + case SCROLL_PAGEDOWN: + if ( pScroll == &aHScrollLeft ) nDelta = aViewData.VisibleCellsX( SC_SPLIT_LEFT ); + if ( pScroll == &aHScrollRight ) nDelta = aViewData.VisibleCellsX( SC_SPLIT_RIGHT ); + if ( pScroll == &aVScrollTop ) nDelta = aViewData.VisibleCellsY( SC_SPLIT_TOP ); + if ( pScroll == &aVScrollBottom ) nDelta = aViewData.VisibleCellsY( SC_SPLIT_BOTTOM ); + if (nDelta==0) nDelta=1; + break; + case SCROLL_DRAG: + { + // nur in die richtige Richtung scrollen, nicht um ausgeblendete + // Bereiche herumzittern + + long nScrollMin = 0; // RangeMin simulieren + if ( aViewData.GetHSplitMode()==SC_SPLIT_FIX && pScroll == &aHScrollRight ) + nScrollMin = aViewData.GetFixPosX(); + if ( aViewData.GetVSplitMode()==SC_SPLIT_FIX && pScroll == &aVScrollBottom ) + nScrollMin = aViewData.GetFixPosY(); + + long nScrollPos = pScroll->GetThumbPos() + nScrollMin; + nDelta = nScrollPos - nViewPos; + if ( nScrollPos > nPrevDragPos ) + { + if (nDelta<0) nDelta=0; + } + else if ( nScrollPos < nPrevDragPos ) + { + if (nDelta>0) nDelta=0; + } + else + nDelta = 0; + nPrevDragPos = nScrollPos; + } + break; + } + + if (nDelta) + { + BOOL bUpdate = ( eType != SCROLL_DRAG ); // bei Drag die Ranges nicht aendern + if ( bHoriz ) + ScrollX( nDelta, (pScroll == &aHScrollLeft) ? SC_SPLIT_LEFT : SC_SPLIT_RIGHT, bUpdate ); + else + ScrollY( nDelta, (pScroll == &aVScrollTop) ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM, bUpdate ); + } + } + + return 0; +} + +void ScTabView::ScrollX( long nDeltaX, ScHSplitPos eWhich, BOOL bUpdBars ) +{ + BOOL bHasHint = ( pInputHintWindow != NULL ); + if (bHasHint) + RemoveHintWindow(); + + USHORT nOldX = aViewData.GetPosX(eWhich); + short nNewX = ((short) nOldX) + (short) nDeltaX; + if ( nNewX < 0 ) + { + nDeltaX -= nNewX; + nNewX = 0; + } + if ( nNewX > MAXCOL ) + { + nDeltaX -= nNewX - MAXCOL; + nNewX = MAXCOL; + } + + short nDir = ( nDeltaX > 0 ) ? 1 : -1; + ScDocument* pDoc = aViewData.GetDocument(); + USHORT nTab = aViewData.GetTabNo(); + while ( ( pDoc->GetColFlags( nNewX, nTab ) & CR_HIDDEN ) && + nNewX+nDir >= 0 && nNewX+nDir <= MAXCOL ) + nNewX += nDir; + + // Fixierung + + if (aViewData.GetHSplitMode() == SC_SPLIT_FIX) + { + if (eWhich == SC_SPLIT_LEFT) + nNewX = (short) nOldX; // links immer stehenlassen + else + { + short nFixX = (short)aViewData.GetFixPosX(); + if (nNewX < nFixX) + nNewX = nFixX; + } + } + if (nNewX == (short) nOldX) + return; + + HideAllCursors(); + + if ( nNewX >= 0 && nNewX <= MAXCOL && nDeltaX ) + { + USHORT nTrackX = max( nOldX, (USHORT) nNewX ); + + // Auf dem Mac wird in Window::Scroll vor dem Scrollen Update gerufen, + // so dass mit den neuen Variablen an die alte Position ausgegeben wuerde. + // Deshalb ein Update vorneweg (vor SetPosX), auf welches Fenster ist beim Mac egal. +#ifdef MAC + pGridWin[SC_SPLIT_BOTTOMLEFT]->Update(); +#endif + // Mit VCL wirkt Update() im Moment immer auf alle Fenster, beim Update + // nach dem Scrollen des GridWindow's wuerde darum der Col-/RowBar evtl. + // mit schon geaenderter Pos. gepainted werden - + // darum vorher einmal Update am Col-/RowBar +#ifdef VCL + if (pColBar[eWhich]) + pColBar[eWhich]->Update(); +#endif + + long nOldPos = aViewData.GetScrPos( nTrackX, 0, eWhich ).X(); + aViewData.SetPosX( eWhich, (USHORT) nNewX ); + long nDiff = aViewData.GetScrPos( nTrackX, 0, eWhich ).X() - nOldPos; + + if ( eWhich==SC_SPLIT_LEFT ) + { + pGridWin[SC_SPLIT_BOTTOMLEFT]->ScrollPixel( nDiff, 0 ); + if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE ) + pGridWin[SC_SPLIT_TOPLEFT]->ScrollPixel( nDiff, 0 ); + } + else + { + pGridWin[SC_SPLIT_BOTTOMRIGHT]->ScrollPixel( nDiff, 0 ); + if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE ) + pGridWin[SC_SPLIT_TOPRIGHT]->ScrollPixel( nDiff, 0 ); + } + if (pColBar[eWhich]) { pColBar[eWhich]->Scroll( nDiff,0 ); pColBar[eWhich]->Update(); } + if (pColOutline[eWhich]) pColOutline[eWhich]->ScrollPixel( nDiff ); + if (bUpdBars) + UpdateScrollBars(); + } + + if (nDeltaX==1 || nDeltaX==-1) + pGridWin[aViewData.GetActivePart()]->Update(); + + ShowAllCursors(); + + SetNewVisArea(); // MapMode muss schon gesetzt sein + + if (bHasHint) + TestHintWindow(); // neu positionieren +} + +void ScTabView::ScrollY( long nDeltaY, ScVSplitPos eWhich, BOOL bUpdBars ) +{ + BOOL bHasHint = ( pInputHintWindow != NULL ); + if (bHasHint) + RemoveHintWindow(); + + USHORT nOldY = aViewData.GetPosY(eWhich); + short nNewY = ((short) nOldY) + (short) nDeltaY; + if ( nNewY < 0 ) + { + nDeltaY -= nNewY; + nNewY = 0; + } + if ( nNewY > MAXROW ) + { + nDeltaY -= nNewY - MAXROW; + nNewY = MAXROW; + } + + short nDir = ( nDeltaY > 0 ) ? 1 : -1; + ScDocument* pDoc = aViewData.GetDocument(); + USHORT nTab = aViewData.GetTabNo(); + while ( ( pDoc->GetRowFlags( nNewY, nTab ) & CR_HIDDEN ) && + nNewY+nDir >= 0 && nNewY+nDir <= MAXROW ) + nNewY += nDir; + + // Fixierung + + if (aViewData.GetVSplitMode() == SC_SPLIT_FIX) + { + if (eWhich == SC_SPLIT_TOP) + nNewY = (short) nOldY; // oben immer stehenlassen + else + { + short nFixY = (short)aViewData.GetFixPosY(); + if (nNewY < nFixY) + nNewY = nFixY; + } + } + if (nNewY == (short) nOldY) + return; + + HideAllCursors(); + + if ( nNewY >= 0 && nNewY <= MAXROW && nDeltaY ) + { + USHORT nTrackY = max( nOldY, (USHORT) nNewY ); + + // Zeilenkoepfe anpassen vor dem eigentlichen Scrolling, damit nicht + // doppelt gepainted werden muss + // PosY darf dann auch noch nicht umgesetzt sein, neuen Wert uebergeben + USHORT nUNew = (USHORT) nNewY; + UpdateHeaderWidth( &eWhich, &nUNew ); // Zeilenkoepfe anpassen + +#ifdef MAC + pGridWin[SC_SPLIT_BOTTOMLEFT]->Update(); +#endif +#ifdef VCL + if (pRowBar[eWhich]) + pRowBar[eWhich]->Update(); +#endif + + long nOldPos = aViewData.GetScrPos( 0, nTrackY, eWhich ).Y(); + aViewData.SetPosY( eWhich, (USHORT) nNewY ); + long nDiff = aViewData.GetScrPos( 0, nTrackY, eWhich ).Y() - nOldPos; + + if ( eWhich==SC_SPLIT_TOP ) + { + pGridWin[SC_SPLIT_TOPLEFT]->ScrollPixel( 0, nDiff ); + if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE ) + pGridWin[SC_SPLIT_TOPRIGHT]->ScrollPixel( 0, nDiff ); + } + else + { + pGridWin[SC_SPLIT_BOTTOMLEFT]->ScrollPixel( 0, nDiff ); + if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE ) + pGridWin[SC_SPLIT_BOTTOMRIGHT]->ScrollPixel( 0, nDiff ); + } + if (pRowBar[eWhich]) { pRowBar[eWhich]->Scroll( 0,nDiff ); pRowBar[eWhich]->Update(); } + if (pRowOutline[eWhich]) pRowOutline[eWhich]->ScrollPixel( nDiff ); + if (bUpdBars) + UpdateScrollBars(); + } + + if (nDeltaY==1 || nDeltaY==-1) + pGridWin[aViewData.GetActivePart()]->Update(); + + ShowAllCursors(); + + SetNewVisArea(); // MapMode muss schon gesetzt sein + + if (bHasHint) + TestHintWindow(); // neu positionieren +} + +void ScTabView::ScrollLines( long nDeltaX, long nDeltaY ) +{ + ScSplitPos eWhich = aViewData.GetActivePart(); + if (nDeltaX) + ScrollX(nDeltaX,WhichH(eWhich)); + if (nDeltaY) + ScrollY(nDeltaY,WhichV(eWhich)); +} + +USHORT lcl_LastVisible( ScViewData& rViewData ) +{ + // wenn am Dokumentende viele Zeilen ausgeblendet sind (welcher Trottel macht sowas?), + // soll dadurch nicht auf breite Zeilenkoepfe geschaltet werden + //! als Member ans Dokument ??? + + ScDocument* pDoc = rViewData.GetDocument(); + USHORT nTab = rViewData.GetTabNo(); + + USHORT nVis = MAXROW; + while ( nVis > 0 && pDoc->FastGetRowHeight( nVis, nTab ) == 0 ) + --nVis; + return nVis; +} + +void ScTabView::UpdateHeaderWidth( const ScVSplitPos* pWhich, const USHORT* pPosY ) +{ + if ( !pRowBar[SC_SPLIT_BOTTOM] || MAXROW < 10000 ) + return; + + USHORT nEndPos = MAXROW; + if ( !aViewData.GetViewShell()->GetViewFrame()->ISA(SfxInPlaceFrame) ) + { + // fuer OLE Inplace immer MAXROW + + if ( pWhich && *pWhich == SC_SPLIT_BOTTOM && pPosY ) + nEndPos = *pPosY; + else + nEndPos = aViewData.GetPosY( SC_SPLIT_BOTTOM ); + nEndPos += aViewData.CellsAtY( nEndPos, 1, SC_SPLIT_BOTTOM, SC_SIZE_NONE ); // VisibleCellsY + if (nEndPos > MAXROW) + nEndPos = lcl_LastVisible( aViewData ); + + if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE ) + { + USHORT nTopEnd; + if ( pWhich && *pWhich == SC_SPLIT_TOP && pPosY ) + nTopEnd = *pPosY; + else + nTopEnd = aViewData.GetPosY( SC_SPLIT_TOP ); + nTopEnd += aViewData.CellsAtY( nTopEnd, 1, SC_SPLIT_TOP, SC_SIZE_NONE );// VisibleCellsY + if (nTopEnd > MAXROW) + nTopEnd = lcl_LastVisible( aViewData ); + + if ( nTopEnd > nEndPos ) + nEndPos = nTopEnd; + } + } + + long nSmall = pRowBar[SC_SPLIT_BOTTOM]->GetSmallWidth(); + long nBig = pRowBar[SC_SPLIT_BOTTOM]->GetBigWidth(); + long nDiff = nBig - nSmall; + + if (nEndPos>10000) + nEndPos = 10000; + long nWidth = nBig - ( 10000 - nEndPos ) * nDiff / 10000; + + if ( nWidth != pRowBar[SC_SPLIT_BOTTOM]->GetWidth() && !bInUpdateHeader ) + { + bInUpdateHeader = TRUE; + + pRowBar[SC_SPLIT_BOTTOM]->SetWidth( nWidth ); + if (pRowBar[SC_SPLIT_TOP]) + pRowBar[SC_SPLIT_TOP]->SetWidth( nWidth ); + + RepeatResize(); + + // auf VCL gibt's Update ohne Ende (jedes Update gilt fuer alle Fenster) +#ifndef VCL + aCornerButton.Update(); // der bekommt sonst nie ein Update +#endif + + bInUpdateHeader = FALSE; + } +} + +inline void ShowHide( Window* pWin, BOOL bShow ) +{ + DBG_ASSERT(pWin || !bShow, "Fenster ist nicht da"); + if (pWin) + pWin->Show(bShow); +} + +void ScTabView::UpdateShow() +{ + BOOL bHScrollMode = aViewData.IsHScrollMode(); + BOOL bVScrollMode = aViewData.IsVScrollMode(); + BOOL bTabMode = aViewData.IsTabMode(); + BOOL bOutlMode = aViewData.IsOutlineMode(); + BOOL bHOutline = bOutlMode && lcl_HasColOutline(aViewData); + BOOL bVOutline = bOutlMode && lcl_HasRowOutline(aViewData); + BOOL bHeader = aViewData.IsHeaderMode(); + + BOOL bShowH = ( aViewData.GetHSplitMode() != SC_SPLIT_NONE ); + BOOL bShowV = ( aViewData.GetVSplitMode() != SC_SPLIT_NONE ); + + // Scrollbar-Einstellungen koennen vom Sfx ueberschrieben werden: + SfxScrollingMode eMode = aViewData.GetViewShell()->GetScrollingMode(); + if ( eMode == SCROLLING_NO ) + bHScrollMode = bVScrollMode = FALSE; + else if ( eMode == SCROLLING_YES || eMode == SCROLLING_AUTO ) //! Auto ??? + bHScrollMode = bVScrollMode = TRUE; + + // + // Windows anlegen + // + + if (bShowH && !pGridWin[SC_SPLIT_BOTTOMRIGHT]) + { + pGridWin[SC_SPLIT_BOTTOMRIGHT] = new ScGridWindow( pFrameWin, &aViewData, SC_SPLIT_BOTTOMRIGHT ); + DoAddWin( pGridWin[SC_SPLIT_BOTTOMRIGHT] ); + } + if (bShowV && !pGridWin[SC_SPLIT_TOPLEFT]) + { + pGridWin[SC_SPLIT_TOPLEFT] = new ScGridWindow( pFrameWin, &aViewData, SC_SPLIT_TOPLEFT ); + DoAddWin( pGridWin[SC_SPLIT_TOPLEFT] ); + } + if (bShowH && bShowV && !pGridWin[SC_SPLIT_TOPRIGHT]) + { + pGridWin[SC_SPLIT_TOPRIGHT] = new ScGridWindow( pFrameWin, &aViewData, SC_SPLIT_TOPRIGHT ); + DoAddWin( pGridWin[SC_SPLIT_TOPRIGHT] ); + } + + if (bHOutline && !pColOutline[SC_SPLIT_LEFT]) + pColOutline[SC_SPLIT_LEFT] = new ScOutlineWindow( pFrameWin, SC_OUTLINE_HOR, &aViewData, SC_SPLIT_BOTTOMLEFT ); + if (bShowH && bHOutline && !pColOutline[SC_SPLIT_RIGHT]) + pColOutline[SC_SPLIT_RIGHT] = new ScOutlineWindow( pFrameWin, SC_OUTLINE_HOR, &aViewData, SC_SPLIT_BOTTOMRIGHT ); + + if (bVOutline && !pRowOutline[SC_SPLIT_BOTTOM]) + pRowOutline[SC_SPLIT_BOTTOM] = new ScOutlineWindow( pFrameWin, SC_OUTLINE_VER, &aViewData, SC_SPLIT_BOTTOMLEFT ); + if (bShowV && bVOutline && !pRowOutline[SC_SPLIT_TOP]) + pRowOutline[SC_SPLIT_TOP] = new ScOutlineWindow( pFrameWin, SC_OUTLINE_VER, &aViewData, SC_SPLIT_TOPLEFT ); + + if (bShowH && bHeader && !pColBar[SC_SPLIT_RIGHT]) + pColBar[SC_SPLIT_RIGHT] = new ScColBar( pFrameWin, &aViewData, SC_SPLIT_RIGHT, + &aHdrFunc, pHdrSelEng ); + if (bShowV && bHeader && !pRowBar[SC_SPLIT_TOP]) + pRowBar[SC_SPLIT_TOP] = new ScRowBar( pFrameWin, &aViewData, SC_SPLIT_TOP, + &aHdrFunc, pHdrSelEng ); + + // + // Windows anzeigen + // + + ShowHide( &aHScrollLeft, bHScrollMode ); + ShowHide( &aHScrollRight, bShowH && bHScrollMode ); + ShowHide( &aVScrollBottom, bVScrollMode ); + ShowHide( &aVScrollTop, bShowV && bVScrollMode ); + ShowHide( &aScrollBarBox, bVScrollMode || bHScrollMode ); + + ShowHide( pHSplitter, bHScrollMode || bShowH ); // immer angelegt + ShowHide( pVSplitter, bVScrollMode || bShowV ); + ShowHide( pTabControl, bTabMode ); + + // ab hier dynamisch angelegte + + ShowHide( pGridWin[SC_SPLIT_BOTTOMRIGHT], bShowH ); + ShowHide( pGridWin[SC_SPLIT_TOPLEFT], bShowV ); + ShowHide( pGridWin[SC_SPLIT_TOPRIGHT], bShowH && bShowV ); + + ShowHide( pColOutline[SC_SPLIT_LEFT], bHOutline ); + ShowHide( pColOutline[SC_SPLIT_RIGHT], bShowH && bHOutline ); + + ShowHide( pRowOutline[SC_SPLIT_BOTTOM], bVOutline ); + ShowHide( pRowOutline[SC_SPLIT_TOP], bShowV && bVOutline ); + + ShowHide( pColBar[SC_SPLIT_RIGHT], bShowH && bHeader ); + ShowHide( pRowBar[SC_SPLIT_TOP], bShowV && bHeader ); + + + //! neue Gridwindows eintragen +} + +// --- Splitter -------------------------------------------------------- + +IMPL_LINK( ScTabView, SplitHdl, Splitter*, pSplitter ) +{ + if ( pSplitter == pHSplitter ) + DoHSplit( pHSplitter->GetSplitPosPixel() ); + else + DoVSplit( pVSplitter->GetSplitPosPixel() ); + + if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX || aViewData.GetVSplitMode() == SC_SPLIT_FIX ) + FreezeSplitters( TRUE ); + + DoResize( aBorderPos, aFrameSize ); + + return 0; +} + +void ScTabView::DoHSplit(long nSplitPos) +{ + long nMinPos; + long nMaxPos; + USHORT nOldDelta; + USHORT nNewDelta; + + nMinPos = SPLIT_MARGIN; + if ( pRowBar[SC_SPLIT_BOTTOM] && pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width() >= nMinPos ) + nMinPos = pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width() + 1; + nMaxPos = aFrameSize.Width() - SPLIT_MARGIN; + + ScSplitMode aOldMode = aViewData.GetHSplitMode(); + ScSplitMode aNewMode = SC_SPLIT_NORMAL; + + aViewData.SetHSplitPos( nSplitPos ); + if ( nSplitPos < nMinPos || nSplitPos > nMaxPos ) + aNewMode = SC_SPLIT_NONE; + + aViewData.SetHSplitMode( aNewMode ); + + if ( aNewMode != aOldMode ) + { + UpdateShow(); // vor ActivatePart !! + + if ( aNewMode == SC_SPLIT_NONE ) + { + if (aViewData.GetActivePart() == SC_SPLIT_TOPRIGHT) + ActivatePart( SC_SPLIT_TOPLEFT ); + if (aViewData.GetActivePart() == SC_SPLIT_BOTTOMRIGHT) + ActivatePart( SC_SPLIT_BOTTOMLEFT ); + } + else + { + nOldDelta = aViewData.GetPosX( SC_SPLIT_LEFT ); +// aViewData.SetPosX( SC_SPLIT_LEFT, nOldDelta ); + long nLeftWidth = nSplitPos - pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width(); + if ( nLeftWidth < 0 ) nLeftWidth = 0; + nNewDelta = nOldDelta + aViewData.CellsAtX( nOldDelta, 1, SC_SPLIT_LEFT, + (USHORT) nLeftWidth ); + if ( nNewDelta > MAXCOL ) + nNewDelta = MAXCOL; + aViewData.SetPosX( SC_SPLIT_RIGHT, nNewDelta ); + if ( nNewDelta > aViewData.GetCurX() ) + ActivatePart( (WhichV(aViewData.GetActivePart()) == SC_SPLIT_BOTTOM) ? + SC_SPLIT_BOTTOMLEFT : SC_SPLIT_TOPLEFT ); + else + ActivatePart( (WhichV(aViewData.GetActivePart()) == SC_SPLIT_BOTTOM) ? + SC_SPLIT_BOTTOMRIGHT : SC_SPLIT_TOPRIGHT ); + } + + // #61410# Form-Layer muss den sichtbaren Ausschnitt aller Fenster kennen + // dafuer muss hier schon der MapMode stimmen + for (USHORT i=0; i<4; i++) + if (pGridWin[i]) + pGridWin[i]->SetMapMode( pGridWin[i]->GetDrawMapMode() ); + SetNewVisArea(); + + PaintGrid(); + PaintTop(); + + InvalidateSplit(); + } +} + +void ScTabView::DoVSplit(long nSplitPos) +{ + long nMinPos; + long nMaxPos; + USHORT nOldDelta; + USHORT nNewDelta; + + nMinPos = SPLIT_MARGIN; + if ( pColBar[SC_SPLIT_LEFT] && pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height() >= nMinPos ) + nMinPos = pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height() + 1; + nMaxPos = aFrameSize.Height() - SPLIT_MARGIN; + + ScSplitMode aOldMode = aViewData.GetVSplitMode(); + ScSplitMode aNewMode = SC_SPLIT_NORMAL; + + aViewData.SetVSplitPos( nSplitPos ); + if ( nSplitPos < nMinPos || nSplitPos > nMaxPos ) + aNewMode = SC_SPLIT_NONE; + + aViewData.SetVSplitMode( aNewMode ); + + if ( aNewMode != aOldMode ) + { + UpdateShow(); // vor ActivatePart !! + + if ( aNewMode == SC_SPLIT_NONE ) + { + nOldDelta = aViewData.GetPosY( SC_SPLIT_TOP ); + aViewData.SetPosY( SC_SPLIT_BOTTOM, nOldDelta ); + + if (aViewData.GetActivePart() == SC_SPLIT_TOPLEFT) + ActivatePart( SC_SPLIT_BOTTOMLEFT ); + if (aViewData.GetActivePart() == SC_SPLIT_TOPRIGHT) + ActivatePart( SC_SPLIT_BOTTOMRIGHT ); + } + else + { + if ( aOldMode == SC_SPLIT_NONE ) + nOldDelta = aViewData.GetPosY( SC_SPLIT_BOTTOM ); + else + nOldDelta = aViewData.GetPosY( SC_SPLIT_TOP ); + + aViewData.SetPosY( SC_SPLIT_TOP, nOldDelta ); + long nTopHeight = nSplitPos - pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height(); + if ( nTopHeight < 0 ) nTopHeight = 0; + nNewDelta = nOldDelta + aViewData.CellsAtY( nOldDelta, 1, SC_SPLIT_TOP, + (USHORT) nTopHeight ); + if ( nNewDelta > MAXROW ) + nNewDelta = MAXROW; + aViewData.SetPosY( SC_SPLIT_BOTTOM, nNewDelta ); + if ( nNewDelta > aViewData.GetCurY() ) + ActivatePart( (WhichH(aViewData.GetActivePart()) == SC_SPLIT_LEFT) ? + SC_SPLIT_TOPLEFT : SC_SPLIT_TOPRIGHT ); + else + ActivatePart( (WhichH(aViewData.GetActivePart()) == SC_SPLIT_LEFT) ? + SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT ); + } + + // #61410# Form-Layer muss den sichtbaren Ausschnitt aller Fenster kennen + // dafuer muss hier schon der MapMode stimmen + for (USHORT i=0; i<4; i++) + if (pGridWin[i]) + pGridWin[i]->SetMapMode( pGridWin[i]->GetDrawMapMode() ); + SetNewVisArea(); + + PaintGrid(); + PaintLeft(); + + InvalidateSplit(); + } +} + +Point ScTabView::GetInsertPos() +{ + ScDocument* pDoc = aViewData.GetDocument(); + USHORT nCol = aViewData.GetCurX(); + USHORT nRow = aViewData.GetCurY(); + USHORT nTab = aViewData.GetTabNo(); + USHORT i; + long nPosX = 0; + for (i=0; i<nCol; i++) + nPosX += pDoc->GetColWidth(i,nTab); + nPosX = (long)(nPosX * HMM_PER_TWIPS); + long nPosY = 0; + for (i=0; i<nRow; i++) + nPosY += pDoc->GetRowHeight(i,nTab); + nPosY = (long)(nPosY * HMM_PER_TWIPS); + return Point(nPosX,nPosY); +} + +void ScTabView::LockModifiers( USHORT nModifiers ) +{ + pSelEngine->LockModifiers( nModifiers ); +} + +USHORT ScTabView::GetLockedModifiers() const +{ + return pSelEngine->GetLockedModifiers(); +} + +Point ScTabView::GetMousePosPixel() +{ + Point aPos; + ScGridWindow* pWin = (ScGridWindow*)GetActiveWin(); + + if ( pWin ) + aPos = pWin->GetMousePosPixel(); + + return aPos; +} + +BOOL lcl_MouseIsOverWin( const Point& rScreenPosPixel, Window* pWin ) +{ + if (pWin) + { + // SPLIT_HANDLE_SIZE draufaddieren, damit das Einrasten genau + // auf dem Splitter nicht aussetzt + + Point aRel = pWin->ScreenToOutputPixel( rScreenPosPixel ); + Size aWinSize = pWin->GetOutputSizePixel(); + if ( aRel.X() >= 0 && aRel.X() < aWinSize.Width() + SPLIT_HANDLE_SIZE && + aRel.Y() >= 0 && aRel.Y() < aWinSize.Height() + SPLIT_HANDLE_SIZE ) + return TRUE; + } + return FALSE; +} + +void ScTabView::SnapSplitPos( Point& rScreenPosPixel ) +{ + BOOL bOverWin = FALSE; + USHORT i; + for (i=0; i<4; i++) + if (lcl_MouseIsOverWin(rScreenPosPixel,pGridWin[i])) + bOverWin = TRUE; + + if (!bOverWin) + return; + + // #74761# don't snap to cells if the scale will be modified afterwards + if ( eZoomType != SVX_ZOOM_PERCENT ) + return; + + ScSplitPos ePos = SC_SPLIT_BOTTOMLEFT; + if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE ) + ePos = SC_SPLIT_TOPLEFT; + + Window* pWin = pGridWin[ePos]; + if (!pWin) + { + DBG_ERROR("Window NULL"); + return; + } + + Point aMouse = pWin->ScreenToOutputPixel( rScreenPosPixel ); + short nPosX; + short nPosY; + // #52949# bNextIfLarge=FALSE: nicht auf naechste Zelle, wenn ausserhalb des Fensters + aViewData.GetPosFromPixel( aMouse.X(), aMouse.Y(), ePos, nPosX, nPosY, TRUE, FALSE, FALSE ); + BOOL bLeft; + BOOL bTop; + aViewData.GetMouseQuadrant( aMouse, ePos, nPosX, nPosY, bLeft, bTop ); + if (!bLeft) + ++nPosX; + if (!bTop) + ++nPosY; + aMouse = aViewData.GetScrPos( (USHORT)nPosX, (USHORT)nPosY, ePos, TRUE ); + rScreenPosPixel = pWin->OutputToScreenPixel( aMouse ); +} + +void ScTabView::FreezeSplitters( BOOL bFreeze ) +{ + ScSplitMode eOldH = aViewData.GetHSplitMode(); + ScSplitMode eOldV = aViewData.GetVSplitMode(); + + ScSplitPos ePos = SC_SPLIT_BOTTOMLEFT; + if ( eOldV != SC_SPLIT_NONE ) + ePos = SC_SPLIT_TOPLEFT; + Window* pWin = pGridWin[ePos]; + + if ( bFreeze ) + { + Point aWinStart = pWin->GetPosPixel(); + + Point aSplit; + short nPosX; + short nPosY; + if (eOldH != SC_SPLIT_NONE || eOldV != SC_SPLIT_NONE) + { + if (eOldH != SC_SPLIT_NONE) + aSplit.X() = aViewData.GetHSplitPos() - aWinStart.X(); + if (eOldV != SC_SPLIT_NONE) + aSplit.Y() = aViewData.GetVSplitPos() - aWinStart.Y(); + + aViewData.GetPosFromPixel( aSplit.X(), aSplit.Y(), ePos, nPosX, nPosY ); + BOOL bLeft; + BOOL bTop; + aViewData.GetMouseQuadrant( aSplit, ePos, nPosX, nPosY, bLeft, bTop ); + if (!bLeft) + ++nPosX; + if (!bTop) + ++nPosY; + } + else + { + nPosX = (short) aViewData.GetCurX(); + nPosY = (short) aViewData.GetCurY(); + } + + USHORT nLeftPos = aViewData.GetPosX(SC_SPLIT_LEFT); + USHORT nTopPos = aViewData.GetPosY(SC_SPLIT_BOTTOM); + USHORT nRightPos = nPosX; + USHORT nBottomPos = nPosY; + if (eOldH != SC_SPLIT_NONE) + if (aViewData.GetPosX(SC_SPLIT_RIGHT) > nRightPos) + nRightPos = aViewData.GetPosX(SC_SPLIT_RIGHT); + if (eOldV != SC_SPLIT_NONE) + { + nTopPos = aViewData.GetPosY(SC_SPLIT_TOP); + if (aViewData.GetPosY(SC_SPLIT_BOTTOM) > nBottomPos) + nBottomPos = aViewData.GetPosY(SC_SPLIT_BOTTOM); + } + + aSplit = aViewData.GetScrPos( (USHORT)nPosX, (USHORT)nPosY, ePos, TRUE ); + if (aSplit.X() > 0) + { + aViewData.SetHSplitMode( SC_SPLIT_FIX ); + aViewData.SetHSplitPos( aSplit.X() + aWinStart.X() ); + aViewData.SetFixPosX( nPosX ); + + aViewData.SetPosX(SC_SPLIT_LEFT, nLeftPos); + aViewData.SetPosX(SC_SPLIT_RIGHT, nRightPos); + } + else + aViewData.SetHSplitMode( SC_SPLIT_NONE ); + if (aSplit.Y() > 0) + { + aViewData.SetVSplitMode( SC_SPLIT_FIX ); + aViewData.SetVSplitPos( aSplit.Y() + aWinStart.Y() ); + aViewData.SetFixPosY( nPosY ); + + aViewData.SetPosY(SC_SPLIT_TOP, nTopPos); + aViewData.SetPosY(SC_SPLIT_BOTTOM, nBottomPos); + } + else + aViewData.SetVSplitMode( SC_SPLIT_NONE ); + } + else // Fixierung aufheben + { + if ( eOldH == SC_SPLIT_FIX ) + aViewData.SetHSplitMode( SC_SPLIT_NORMAL ); + if ( eOldV == SC_SPLIT_FIX ) + aViewData.SetVSplitMode( SC_SPLIT_NORMAL ); + } + + // #61410# Form-Layer muss den sichtbaren Ausschnitt aller Fenster kennen + // dafuer muss hier schon der MapMode stimmen + for (USHORT i=0; i<4; i++) + if (pGridWin[i]) + pGridWin[i]->SetMapMode( pGridWin[i]->GetDrawMapMode() ); + SetNewVisArea(); + + RepeatResize(FALSE); + + UpdateShow(); + PaintLeft(); + PaintTop(); + PaintGrid(); + + InvalidateSplit(); +} + +void ScTabView::RemoveSplit() +{ + DoHSplit( 0 ); + DoVSplit( 0 ); + RepeatResize(); +} + +void ScTabView::SplitAtCursor() +{ + ScSplitPos ePos = SC_SPLIT_BOTTOMLEFT; + if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE ) + ePos = SC_SPLIT_TOPLEFT; + Window* pWin = pGridWin[ePos]; + Point aWinStart = pWin->GetPosPixel(); + + USHORT nPosX = aViewData.GetCurX(); + USHORT nPosY = aViewData.GetCurY(); + Point aSplit = aViewData.GetScrPos( nPosX, nPosY, ePos, TRUE ); + if ( nPosX > 0 ) + DoHSplit( aSplit.X() + aWinStart.X() ); + else + DoHSplit( 0 ); + if ( nPosY > 0 ) + DoVSplit( aSplit.Y() + aWinStart.Y() ); + else + DoVSplit( 0 ); + RepeatResize(); +} + +void ScTabView::SplitAtPixel( const Point& rPixel, BOOL bHor, BOOL bVer ) // fuer API +{ + // Pixel ist auf die ganze View bezogen, nicht auf das erste GridWin + + if (bHor) + { + if ( rPixel.X() > 0 ) + DoHSplit( rPixel.X() ); + else + DoHSplit( 0 ); + } + if (bVer) + { + if ( rPixel.Y() > 0 ) + DoVSplit( rPixel.Y() ); + else + DoVSplit( 0 ); + } + RepeatResize(); +} + +void ScTabView::InvalidateSplit() +{ + SfxBindings& rBindings = SFX_BINDINGS(); + rBindings.Invalidate( SID_WINDOW_SPLIT ); + rBindings.Invalidate( SID_WINDOW_FIX ); + + pHSplitter->SetFixed( aViewData.GetHSplitMode() == SC_SPLIT_FIX ); + pVSplitter->SetFixed( aViewData.GetVSplitMode() == SC_SPLIT_FIX ); +} + +void ScTabView::SetNewVisArea() +{ + // #63854# fuer die Controls muss bei VisAreaChanged der Draw-MapMode eingestellt sein + // (auch wenn ansonsten der Edit-MapMode gesetzt ist) + MapMode aOldMode[4]; + MapMode aDrawMode[4]; + USHORT i; + for (i=0; i<4; i++) + if (pGridWin[i]) + { + aOldMode[i] = pGridWin[i]->GetMapMode(); + aDrawMode[i] = pGridWin[i]->GetDrawMapMode(); + if (aDrawMode[i] != aOldMode[i]) + pGridWin[i]->SetMapMode(aDrawMode[i]); + } + + Window* pActive = pGridWin[aViewData.GetActivePart()]; + if (pActive) + aViewData.GetViewShell()->VisAreaChanged( + pActive->PixelToLogic(Rectangle(Point(),pActive->GetOutputSizePixel())) ); + if (pDrawView) + pDrawView->VisAreaChanged(); // kein Window uebergeben -> alle Fenster + + for (i=0; i<4; i++) + if (pGridWin[i] && aDrawMode[i] != aOldMode[i]) + pGridWin[i]->SetMapMode(aOldMode[i]); +} + +void ScTabView::StartDataSelect() +{ + ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()]; + USHORT nCol = aViewData.GetCurX(); + USHORT nRow = aViewData.GetCurY(); + if (pWin) + pWin->DoAutoFilterMenue( nCol, nRow, TRUE ); +} + +void ScTabView::EnableRefInput(BOOL bFlag) +{ + aHScrollLeft.EnableInput(bFlag); + aHScrollRight.EnableInput(bFlag); + aVScrollBottom.EnableInput(bFlag); + aVScrollTop.EnableInput(bFlag); + aScrollBarBox.EnableInput(bFlag); + + // ab hier dynamisch angelegte + + if(pTabControl!=NULL) pTabControl->EnableInput(bFlag,TRUE); + + if(pGridWin[SC_SPLIT_BOTTOMLEFT]!=NULL) + pGridWin[SC_SPLIT_BOTTOMLEFT]->EnableInput(bFlag,FALSE); + if(pGridWin[SC_SPLIT_BOTTOMRIGHT]!=NULL) + pGridWin[SC_SPLIT_BOTTOMRIGHT]->EnableInput(bFlag,FALSE); + if(pGridWin[SC_SPLIT_TOPLEFT]!=NULL) + pGridWin[SC_SPLIT_TOPLEFT]->EnableInput(bFlag,FALSE); + if(pGridWin[SC_SPLIT_TOPRIGHT]!=NULL) + pGridWin[SC_SPLIT_TOPRIGHT]->EnableInput(bFlag,FALSE); + if(pColBar[SC_SPLIT_RIGHT]!=NULL) + pColBar[SC_SPLIT_RIGHT]->EnableInput(bFlag,FALSE); + if(pRowBar[SC_SPLIT_TOP]!=NULL) + pRowBar[SC_SPLIT_TOP]->EnableInput(bFlag,FALSE); +} + + + diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx new file mode 100644 index 000000000000..26d95223617c --- /dev/null +++ b/sc/source/ui/view/tabview2.cxx @@ -0,0 +1,761 @@ +/************************************************************************* + * + * $RCSfile: tabview2.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" + +#include <vcl/timer.hxx> +#include <vcl/msgbox.hxx> +#include <sfx2/app.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/childwin.hxx> + +#include "pagedata.hxx" +#include "tabview.hxx" +#include "tabvwsh.hxx" +#include "printfun.hxx" +#include "stlpool.hxx" +#include "docsh.hxx" +#include "gridwin.hxx" +#include "olinewin.hxx" +#include "uiitems.hxx" +#include "sc.hrc" +#include "viewutil.hxx" +#include "colrowba.hxx" +#include "waitoff.hxx" +#include "globstr.hrc" + +#define SC_BLOCKMODE_NONE 0 +#define SC_BLOCKMODE_NORMAL 1 +#define SC_BLOCKMODE_OWN 2 + + + +// +// Markier - Funktionen +// + +void ScTabView::PaintMarks(USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow ) +{ + if (nStartCol > MAXCOL) nStartCol = MAXCOL; + if (nStartRow > MAXROW) nStartRow = MAXROW; + if (nEndCol > MAXCOL) nEndCol = MAXCOL; + if (nEndRow > MAXROW) nEndRow = MAXROW; + + BOOL bLeft = (nStartCol==0 && nEndCol==MAXCOL); + BOOL bTop = (nStartRow==0 && nEndRow==MAXROW); + + if (bLeft) + PaintLeftArea( nStartRow, nEndRow ); + if (bTop) + PaintTopArea( nStartCol, nEndCol ); + + aViewData.GetDocument()->ExtendMerge( nStartCol, nStartRow, nEndCol, nEndRow, + aViewData.GetTabNo() ); + PaintArea( nStartCol, nStartRow, nEndCol, nEndRow, SC_UPDATE_MARKS ); +} + +BOOL ScTabView::IsMarking( USHORT nCol, USHORT nRow, USHORT nTab ) const +{ + return bIsBlockMode + && nBlockStartX == nCol + && nBlockStartY == nRow + && nBlockStartZ == nTab; +} + +void ScTabView::InitOwnBlockMode() +{ + if (!bIsBlockMode) + { + // Wenn keine (alte) Markierung mehr da ist, Anker in SelectionEngine loeschen: + + ScMarkData& rMark = aViewData.GetMarkData(); + if (!rMark.IsMarked() && !rMark.IsMultiMarked()) + GetSelEngine()->CursorPosChanging( FALSE, FALSE ); + +// bIsBlockMode = TRUE; + bIsBlockMode = SC_BLOCKMODE_OWN; //! Variable umbenennen! + nBlockStartX = 0; + nBlockStartY = 0; + nBlockStartZ = 0; + nBlockEndX = 0; + nBlockEndY = 0; + nBlockEndZ = 0; + + SelectionChanged(); // Status wird mit gesetzer Markierung abgefragt + } +} + +void ScTabView::InitBlockMode( USHORT nCurX, USHORT nCurY, USHORT nCurZ, + BOOL bTestNeg, BOOL bCols, BOOL bRows ) +{ + if (!bIsBlockMode) + { + if (nCurX > MAXCOL) nCurX = MAXCOL; + if (nCurY > MAXROW) nCurY = MAXROW; + + ScMarkData& rMark = aViewData.GetMarkData(); + USHORT nTab = aViewData.GetTabNo(); + + // Teil von Markierung aufheben? + if (bTestNeg) + { + if ( bCols ) + bBlockNeg = rMark.IsColumnMarked( nCurX ); + else if ( bRows ) + bBlockNeg = rMark.IsRowMarked( nCurY ); + else + bBlockNeg = rMark.IsCellMarked( nCurX, nCurY ); + } + else + bBlockNeg = FALSE; + rMark.SetMarkNegative(bBlockNeg); + +// bIsBlockMode = TRUE; + bIsBlockMode = SC_BLOCKMODE_NORMAL; //! Variable umbenennen! + bBlockCols = bCols; + bBlockRows = bRows; + nBlockStartX = nCurX; + nBlockStartY = nCurY; + nBlockStartZ = nCurZ; + nBlockEndX = nBlockStartX; + nBlockEndY = nBlockStartY; + nBlockEndZ = nBlockStartZ; + if (bBlockCols) + { + nBlockStartY = 0; + nBlockEndY = MAXROW; + } + if (bBlockRows) + { + nBlockStartX = 0; + nBlockEndX = MAXCOL; + } + rMark.SetMarkArea( ScRange( nBlockStartX,nBlockStartY, nTab, nBlockEndX,nBlockEndY, nTab ) ); + InvertBlockMark( nBlockStartX,nBlockStartY,nBlockEndX,nBlockEndY ); + } +} + +void ScTabView::DoneBlockMode( BOOL bContinue ) // Default FALSE +{ + // Wenn zwischen Tabellen- und Header SelectionEngine gewechselt wird, + // wird evtl. DeselectAll gerufen, weil die andere Engine keinen Anker hat. + // Mit bMoveIsShift wird verhindert, dass dann die Selektion aufgehoben wird. + + if (bIsBlockMode && !bMoveIsShift) + { + ScMarkData& rMark = aViewData.GetMarkData(); + BOOL bFlag = rMark.GetMarkingFlag(); + rMark.SetMarking(FALSE); + + if (bBlockNeg && !bContinue) + rMark.MarkToMulti(); + + if (bContinue) + rMark.MarkToMulti(); + else + { + // Die Tabelle kann an dieser Stelle ungueltig sein, weil DoneBlockMode + // aus SetTabNo aufgerufen wird + // (z.B. wenn die aktuelle Tabelle von einer anderen View aus geloescht wird) + + USHORT nTab = aViewData.GetTabNo(); + ScDocument* pDoc = aViewData.GetDocument(); + if ( pDoc->HasTable(nTab) ) + PaintBlock( TRUE ); // TRUE -> Block loeschen + else + rMark.ResetMark(); + } +// bIsBlockMode = FALSE; + bIsBlockMode = SC_BLOCKMODE_NONE; //! Variable umbenennen! + + rMark.SetMarking(bFlag); + rMark.SetMarkNegative(FALSE); + } +} + +void ScTabView::MarkCursor( USHORT nCurX, USHORT nCurY, USHORT nCurZ, BOOL bCols, BOOL bRows ) +{ + if (nCurX > MAXCOL) nCurX = MAXCOL; + if (nCurY > MAXROW) nCurY = MAXROW; + + if (!bIsBlockMode) + { + DBG_ERROR( "MarkCursor nicht im BlockMode" ); + InitBlockMode( nCurX, nCurY, nCurZ, FALSE, bCols, bRows ); + } + + if (bBlockCols) + nCurY = MAXROW; + if (bBlockRows) + nCurX = MAXCOL; + + ScMarkData& rMark = aViewData.GetMarkData(); + DBG_ASSERT(rMark.IsMarked() || rMark.IsMultiMarked(), "MarkCursor, !IsMarked()"); + ScRange aMarkRange; + rMark.GetMarkArea(aMarkRange); + if (( aMarkRange.aStart.Col() != nBlockStartX && aMarkRange.aEnd.Col() != nBlockStartX ) || + ( aMarkRange.aStart.Row() != nBlockStartY && aMarkRange.aEnd.Row() != nBlockStartY ) || + ( bIsBlockMode == SC_BLOCKMODE_OWN )) + { + // Markierung ist veraendert worden + // (z.B. MarkToSimple, wenn per negativ alles bis auf ein Rechteck geloescht wurde) + // oder nach InitOwnBlockMode wird mit Shift-Klick weitermarkiert... + + BOOL bOldShift = bMoveIsShift; + bMoveIsShift = FALSE; // wirklich umsetzen + DoneBlockMode(FALSE); //! direkt Variablen setzen? (-> kein Geflacker) + bMoveIsShift = bOldShift; + + InitBlockMode( aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), + nBlockStartZ, rMark.IsMarkNegative(), bCols, bRows ); + } + + USHORT nOldCurX = nBlockEndX; + USHORT nOldCurY = nBlockEndY; + + if ( nCurX != nOldCurX || nCurY != nOldCurY ) + { + USHORT nTab = nCurZ; + + USHORT nDrawStartCol; + USHORT nDrawStartRow; + USHORT nDrawEndCol; + USHORT nDrawEndRow; + + ScUpdateRect aRect( nBlockStartX, nBlockStartY, nOldCurX, nOldCurY ); + aRect.SetNew( nBlockStartX, nBlockStartY, nCurX, nCurY ); + + BOOL bCont; + BOOL bDraw = aRect.GetXorDiff( nDrawStartCol, nDrawStartRow, + nDrawEndCol, nDrawEndRow, bCont ); + nBlockEndX = nCurX; + nBlockEndY = nCurY; + rMark.SetMarkArea( ScRange( nBlockStartX, nBlockStartY, nTab, nBlockEndX, nBlockEndY, nTab ) ); + + if ( bDraw ) + { +//? PutInOrder( nDrawStartCol, nDrawEndCol ); +//? PutInOrder( nDrawStartRow, nDrawEndRow ); + + HideAllCursors(); + InvertBlockMark( nDrawStartCol, nDrawStartRow, nDrawEndCol, nDrawEndRow ); + if (bCont) + { + aRect.GetContDiff( nDrawStartCol, nDrawStartRow, nDrawEndCol, nDrawEndRow ); + InvertBlockMark( nDrawStartCol, nDrawStartRow, nDrawEndCol, nDrawEndRow ); + } + ShowAllCursors(); + } + + aViewData.GetViewShell()->UpdateInputHandler(); +// InvalidateAttribs(); + } +} + +//! +//! PaintBlock in zwei Methoden aufteilen: RepaintBlock und RemoveBlock o.ae. +//! + +void ScTabView::PaintBlock( BOOL bReset ) +{ + ScDocument* pDoc = aViewData.GetDocument(); + ScMarkData& rMark = aViewData.GetMarkData(); + USHORT nTab = aViewData.GetTabNo(); + BOOL bMark = rMark.IsMarked(); + BOOL bMulti = rMark.IsMultiMarked(); + if (bMark || bMulti) + { + ScRange aMarkRange; + HideAllCursors(); + BOOL bWasMulti = bMulti; + if (bMulti) + { + BOOL bFlag = rMark.GetMarkingFlag(); + rMark.SetMarking(FALSE); + rMark.MarkToMulti(); + rMark.GetMultiMarkArea(aMarkRange); + rMark.MarkToSimple(); + rMark.SetMarking(bFlag); + + bMark = rMark.IsMarked(); + bMulti = rMark.IsMultiMarked(); + } + else + rMark.GetMarkArea(aMarkRange); + + nBlockStartX = aMarkRange.aStart.Col(); + nBlockStartY = aMarkRange.aStart.Row(); + nBlockStartZ = aMarkRange.aStart.Tab(); + nBlockEndX = aMarkRange.aEnd.Col(); + nBlockEndY = aMarkRange.aEnd.Row(); + nBlockEndZ = aMarkRange.aEnd.Tab(); + + BOOL bDidReset = FALSE; + + if ( nTab>=nBlockStartZ && nTab<=nBlockEndZ ) + { + if ( bReset ) + { + // Invertieren beim Loeschen nur auf aktiver View + if ( aViewData.IsActive() ) + { + USHORT i; + if ( bMulti ) + { + for (i=0; i<4; i++) + if (pGridWin[i] && pGridWin[i]->IsVisible()) + pGridWin[i]->InvertSimple( nBlockStartX, nBlockStartY, + nBlockEndX, nBlockEndY, + TRUE, TRUE ); + rMark.ResetMark(); + bDidReset = TRUE; + } + else + { + // (mis)use InvertBlockMark to remove all of the selection + // -> set bBlockNeg (like when removing parts of a selection) + // and convert everything to Multi + + rMark.MarkToMulti(); + BOOL bOld = bBlockNeg; + bBlockNeg = TRUE; + // #73130# (negative) MarkArea must be set in case of repaint + rMark.SetMarkArea( ScRange( nBlockStartX,nBlockStartY, nTab, + nBlockEndX,nBlockEndY, nTab ) ); + + InvertBlockMark( nBlockStartX, nBlockStartY, nBlockEndX, nBlockEndY ); + + bBlockNeg = bOld; + rMark.ResetMark(); + + bDidReset = TRUE; + } + + // repaint if controls are touched (#69680# in both cases) + + Rectangle aMMRect = pDoc->GetMMRect(nBlockStartX,nBlockStartY,nBlockEndX,nBlockEndY, nTab); + if (pDoc->HasControl( nTab, aMMRect )) + { + for (i=0; i<4; i++) + if (pGridWin[i] && pGridWin[i]->IsVisible()) + { + // MapMode muss logischer (1/100mm) sein !!! + pDoc->InvalidateControls( pGridWin[i], nTab, aMMRect ); + pGridWin[i]->Update(); + } + } + } + } + else + PaintMarks( nBlockStartX, nBlockStartY, nBlockEndX, nBlockEndY ); + } + + if ( bReset && !bDidReset ) + rMark.ResetMark(); + + ShowAllCursors(); + } +} + +void ScTabView::SelectAll( BOOL bContinue ) +{ + ScMarkData& rMark = aViewData.GetMarkData(); + USHORT nTab = aViewData.GetTabNo(); + + if (rMark.IsMarked()) + { + ScRange aMarkRange; + rMark.GetMarkArea( aMarkRange ); + if ( aMarkRange == ScRange( 0,0,nTab, MAXCOL,MAXROW,nTab ) ) + return; + } + + DoneBlockMode( bContinue ); + InitBlockMode( 0,0,nTab ); + MarkCursor( MAXCOL,MAXROW,nTab ); + + SelectionChanged(); +} + +void ScTabView::SelectAllTables() +{ + ScDocument* pDoc = aViewData.GetDocument(); + ScMarkData& rMark = aViewData.GetMarkData(); + USHORT nTab = aViewData.GetTabNo(); + USHORT nCount = pDoc->GetTableCount(); + + if (nCount>1) + { + for (USHORT i=0; i<nCount; i++) + rMark.SelectTable( i, TRUE ); + + // Markierungen werden per Default nicht pro Tabelle gehalten +// pDoc->ExtendMarksFromTable( nTab ); + + aViewData.GetDocShell()->PostPaintExtras(); + SFX_BINDINGS().Invalidate( FID_FILL_TAB ); + } +} + +BOOL lcl_FitsInWindow( double fScaleX, double fScaleY, USHORT nZoom, + long nWindowX, long nWindowY, ScDocument* pDoc, USHORT nTab, + USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow ) +{ + double fZoomFactor = (double)Fraction(nZoom,100); + fScaleX *= fZoomFactor; + fScaleY *= fZoomFactor; + + long nBlockX = 0; + for (USHORT nCol=nStartCol; nCol<=nEndCol; nCol++) + { + USHORT nColTwips = pDoc->GetColWidth( nCol, nTab ); + if (nColTwips) + { + nBlockX += (long)(nColTwips * fScaleX); + if (nBlockX > nWindowX) + return FALSE; + } + } + long nBlockY = 0; + for (USHORT nRow=nStartRow; nRow<=nEndRow; nRow++) + { + USHORT nRowTwips = pDoc->GetRowHeight( nRow, nTab ); + if (nRowTwips) + { + nBlockY += (long)(nRowTwips * fScaleY); + if (nBlockY > nWindowY) + return FALSE; + } + } + return TRUE; +} + +USHORT ScTabView::CalcZoom( SvxZoomType eType, USHORT nOldZoom ) +{ + USHORT nZoom = 0; // Ergebnis + + switch ( eType ) + { + case SVX_ZOOM_PERCENT: // rZoom ist kein besonderer prozentualer Wert + nZoom = nOldZoom; + break; + + case SVX_ZOOM_OPTIMAL: // nZoom entspricht der optimalen Gr"o\se + { + ScMarkData& rMark = aViewData.GetMarkData(); + ScDocument* pDoc = aViewData.GetDocument(); + + if (!rMark.IsMarked()) + nZoom = 100; // nichts markiert + else + { + USHORT nTab = aViewData.GetTabNo(); + ScRange aMarkRange; + if ( !aViewData.GetSimpleArea( aMarkRange ) ) + rMark.GetMultiMarkArea( aMarkRange ); + + USHORT nStartCol = aMarkRange.aStart.Col(); + USHORT nStartRow = aMarkRange.aStart.Row(); + USHORT nStartTab = aMarkRange.aStart.Tab(); + USHORT nEndCol = aMarkRange.aEnd.Col(); + USHORT nEndRow = aMarkRange.aEnd.Row(); + USHORT nEndTab = aMarkRange.aEnd.Tab(); + + if ( nTab < nStartTab && nTab > nEndTab ) + nTab = nStartTab; + + // Wegen der Pixel-Rundungs-Arie kann man zuverlaessig nur nachrechnen, + // ob ein bestimmter Zoom in das Fenster passt - darum wird geschachtelt + + Size aWinSize = pGridWin[aViewData.GetActivePart()]->GetOutputSizePixel(); + + ScDocShell* pDocSh = aViewData.GetDocShell(); + double nPPTX = ScGlobal::nScreenPPTX / pDocSh->GetOutputFactor(); + double nPPTY = ScGlobal::nScreenPPTY; + + USHORT nMin = MINZOOM; + USHORT nMax = MAXZOOM; + while ( nMax > nMin ) + { + USHORT nTest = (nMin+nMax+1)/2; + if ( lcl_FitsInWindow( + nPPTX, nPPTY, nTest, aWinSize.Width(), aWinSize.Height(), + pDoc, nTab, nStartCol, nStartRow, nEndCol, nEndRow ) ) + nMin = nTest; + else + nMax = nTest-1; + } + DBG_ASSERT( nMin == nMax, "Schachtelung ist falsch" ); + nZoom = nMin; + + // 1 paar {} wg compiler bug + if ( nZoom != nOldZoom ) + { for (USHORT i=0; i<2; i++) + { + aViewData.SetPosX( (ScHSplitPos) i, nStartCol ); + aViewData.SetPosY( (ScVSplitPos) i, nStartRow ); + } + } + } + } + break; + + case SVX_ZOOM_WHOLEPAGE: // nZoom entspricht der ganzen Seite oder + case SVX_ZOOM_PAGEWIDTH: // nZoom entspricht der Seitenbreite + { + USHORT nCurTab = aViewData.GetTabNo(); + ScDocument* pDoc = aViewData.GetDocument(); + ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool(); + SfxStyleSheetBase* pStyleSheet = + pStylePool->Find( pDoc->GetPageStyle( nCurTab ), + SFX_STYLE_FAMILY_PAGE ); + + DBG_ASSERT( pStyleSheet, "PageStyle not found :-/" ); + + if ( pStyleSheet ) + { + ScPrintFunc aPrintFunc( aViewData.GetDocShell(), + aViewData.GetViewShell()->GetPrinter(), + nCurTab ); + + Size aPageSize = aPrintFunc.GetDataSize(); + + // use the size of the largest GridWin for normal split, + // or both combined for frozen panes, with the (document) size + // of the frozen part added to the page size + // (with frozen panes, the size of the individual parts + // depends on the scale that is to be calculated) + + if ( !pGridWin[SC_SPLIT_BOTTOMLEFT] ) return 0; + Size aWinSize = pGridWin[SC_SPLIT_BOTTOMLEFT]->GetOutputSizePixel(); + ScSplitMode eHMode = aViewData.GetHSplitMode(); + if ( eHMode != SC_SPLIT_NONE && pGridWin[SC_SPLIT_BOTTOMRIGHT] ) + { + long nOtherWidth = pGridWin[SC_SPLIT_BOTTOMRIGHT]-> + GetOutputSizePixel().Width(); + if ( eHMode == SC_SPLIT_FIX ) + { + aWinSize.Width() += nOtherWidth; + for ( USHORT nCol = aViewData.GetPosX(SC_SPLIT_LEFT); + nCol < aViewData.GetFixPosX(); nCol++ ) + aPageSize.Width() += pDoc->GetColWidth( nCol, nCurTab ); + } + else if ( nOtherWidth > aWinSize.Width() ) + aWinSize.Width() = nOtherWidth; + } + ScSplitMode eVMode = aViewData.GetVSplitMode(); + if ( eVMode != SC_SPLIT_NONE && pGridWin[SC_SPLIT_TOPLEFT] ) + { + long nOtherHeight = pGridWin[SC_SPLIT_TOPLEFT]-> + GetOutputSizePixel().Height(); + if ( eVMode == SC_SPLIT_FIX ) + { + aWinSize.Height() += nOtherHeight; + for ( USHORT nRow = aViewData.GetPosY(SC_SPLIT_TOP); + nRow < aViewData.GetFixPosY(); nRow++ ) + aPageSize.Height() += pDoc->GetRowHeight( nRow, nCurTab ); + } + else if ( nOtherHeight > aWinSize.Height() ) + aWinSize.Height() = nOtherHeight; + } + + double nPPTX = ScGlobal::nScreenPPTX / aViewData.GetDocShell()->GetOutputFactor(); + double nPPTY = ScGlobal::nScreenPPTY; + + long nZoomX = (long) ( aWinSize.Width() * 100 / + ( aPageSize.Width() * nPPTX ) ); + long nZoomY = (long) ( aWinSize.Height() * 100 / + ( aPageSize.Height() * nPPTY ) ); + long nNew = nZoomX; + + if (eType == SVX_ZOOM_WHOLEPAGE && nZoomY < nNew) + nNew = nZoomY; + + nZoom = (USHORT) nNew; + } + } + break; + + default: + DBG_ERROR("Unknown Zoom-Revision"); + nZoom = 0; + } + + return nZoom; +} + +// wird z.B. gerufen, wenn sich das View-Fenster verschiebt: + +void ScTabView::StopMarking() +{ + ScSplitPos eActive = aViewData.GetActivePart(); + if (pGridWin[eActive]) + pGridWin[eActive]->StopMarking(); + + ScHSplitPos eH = WhichH(eActive); + if (pColBar[eH]) + pColBar[eH]->StopMarking(); + + ScVSplitPos eV = WhichV(eActive); + if (pRowBar[eV]) + pRowBar[eV]->StopMarking(); +} + +void ScTabView::HideNoteMarker() +{ + for (USHORT i=0; i<4; i++) + if (pGridWin[i] && pGridWin[i]->IsVisible()) + pGridWin[i]->HideNoteMarker(); +} + +void ScTabView::MakeDrawLayer() +{ + if (!pDrawView) + { + aViewData.GetDocShell()->MakeDrawLayer(); + + // pDrawView wird per Notify gesetzt + DBG_ASSERT(pDrawView,"ScTabView::MakeDrawLayer funktioniert nicht"); + } +} + +void ScTabView::ErrorMessage( USHORT nGlobStrId ) +{ + StopMarking(); // falls per Focus aus MouseButtonDown aufgerufen + + Window* pParent = aViewData.GetDialogParent(); + ScWaitCursorOff aWaitOff( pParent ); + BOOL bFocus = pParent && pParent->HasFocus(); + + if(nGlobStrId==STR_PROTECTIONERR) + { + if(aViewData.GetDocShell()->IsReadOnly()) + { + nGlobStrId=STR_READONLYERR; + } + } + + InfoBox aBox( pParent, ScGlobal::GetRscString( nGlobStrId ) ); + aBox.Execute(); + if (bFocus) + pParent->GrabFocus(); +} + +Window* ScTabView::GetParentOrChild( USHORT nChildId ) +{ + SfxViewFrame* pViewFrm = aViewData.GetViewShell()->GetViewFrame(); + + if ( pViewFrm->HasChildWindow(nChildId) ) + { + SfxChildWindow* pChild = pViewFrm->GetChildWindow(nChildId); + if (pChild) + { + Window* pWin = pChild->GetWindow(); + if (pWin && pWin->IsVisible()) + return pWin; + } + } + + return aViewData.GetDialogParent(); +} + +void ScTabView::UpdatePageBreakData( BOOL bForcePaint ) +{ + ScPageBreakData* pNewData = NULL; + + if (aViewData.IsPagebreakMode()) + { + ScDocShell* pDocSh = aViewData.GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + USHORT nTab = aViewData.GetTabNo(); + + USHORT nCount = pDoc->GetPrintRangeCount(nTab); + if (!nCount) + nCount = 1; + pNewData = new ScPageBreakData(nCount); + + ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab, 0,0,NULL, pNewData ); + // ScPrintFunc fuellt im ctor die PageBreakData + if ( nCount > 1 ) + { + aPrintFunc.ResetBreaks(nTab); + pNewData->AddPages(); + } + + // Druckbereiche veraendert? + if ( bForcePaint || ( pPageBreakData && !pPageBreakData->IsEqual( *pNewData ) ) ) + PaintGrid(); + } + + delete pPageBreakData; + pPageBreakData = pNewData; +} + + + diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx new file mode 100644 index 000000000000..93532c92c15f --- /dev/null +++ b/sc/source/ui/view/tabview3.cxx @@ -0,0 +1,2476 @@ +/************************************************************************* + * + * $RCSfile: tabview3.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:09 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// System - Includes ----------------------------------------------------- + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- +#include <rangelst.hxx> +#include "scitems.hxx" +#include <svx/brshitem.hxx> +#include <svx/editview.hxx> +#include <svx/fmshell.hxx> +#include <sfx2/bindings.hxx> +#include <vcl/cursor.hxx> +#include <sch/schdll.hxx> // ChartSelectionInfo +#include <sch/memchrt.hxx> + +#include "tabview.hxx" +#include "tabvwsh.hxx" +#include "docsh.hxx" +#include "gridwin.hxx" +#include "olinewin.hxx" +#include "colrowba.hxx" +#include "tabcont.hxx" +#include "scmod.hxx" +#include "uiitems.hxx" +#include "sc.hrc" +#include "viewutil.hxx" +#include "inputhdl.hxx" +#include "inputwin.hxx" +#include "validat.hxx" +#include "hintwin.hxx" +#include "inputopt.hxx" +#include "rfindlst.hxx" +#include "hiranges.hxx" +#include "viewuno.hxx" +#include "chartarr.hxx" +#include "anyrefdg.hxx" +#include "dpobject.hxx" +#include "patattr.hxx" +#include "dociter.hxx" +//! hier und output2.cxx in irgendein Headerfile verschieben! +#define SC_CLIPMARK_SIZE 64 + +using namespace com::sun::star; + +// ----------------------------------------------------------------------- + +// helper class for DoChartSelection + +#define SC_BGCOLLECT_FIRST 0 +#define SC_BGCOLLECT_FOUND 1 +#define SC_BGCOLLECT_AMBIGUOUS 2 + +class ScBackgroundCollector +{ +private: + ScDocument* pDoc; + BOOL bTransparent; + Color aBackColor; + USHORT nMode; +public: + ScBackgroundCollector( ScDocument* pD ); + void AddRange( const ScRange& rRange ); + Color GetHighlightColor() const; +}; + +ScBackgroundCollector::ScBackgroundCollector( ScDocument* pD ) : + pDoc( pD ), + bTransparent( FALSE ), + nMode( SC_BGCOLLECT_FIRST ) +{ +} + +void ScBackgroundCollector::AddRange( const ScRange& rRange ) +{ + if ( nMode == SC_BGCOLLECT_AMBIGUOUS ) + return; // nothing more to do + + ScDocAttrIterator aIter( pDoc, rRange.aStart.Tab(), + rRange.aStart.Col(), rRange.aStart.Row(), + rRange.aEnd.Col(), rRange.aEnd.Row() ); + USHORT nCol, nRow1, nRow2; + const ScPatternAttr* pPattern = aIter.GetNext( nCol, nRow1, nRow2 ); + while ( pPattern ) + { + //! look at conditional formats? + const Color& rAttrColor = ((const SvxBrushItem&)pPattern->GetItem(ATTR_BACKGROUND)).GetColor(); + BOOL bAttrTransp = ( rAttrColor.GetTransparency() != 0 ); + + if ( nMode == SC_BGCOLLECT_FIRST ) + { + // just copy first background + bTransparent = bAttrTransp; + aBackColor = rAttrColor; + nMode = SC_BGCOLLECT_FOUND; + } + else if ( nMode == SC_BGCOLLECT_FOUND ) + { + BOOL bEqual = ( bTransparent == bAttrTransp ); + if ( bEqual && !bTransparent ) + bEqual = ( aBackColor == rAttrColor ); + if ( !bEqual ) + { + nMode = SC_BGCOLLECT_AMBIGUOUS; // different backgrounds found + return; // dont need to continue + } + } + + pPattern = aIter.GetNext( nCol, nRow1, nRow2 ); + } +} + +Color ScBackgroundCollector::GetHighlightColor() const +{ + if ( nMode == SC_BGCOLLECT_FOUND && !bTransparent ) + { + // everything formatted with a single background color + // -> use contrasting color (blue or yellow) + + Color aBlue( COL_LIGHTBLUE ); + Color aYellow( COL_YELLOW ); + + if ( aBackColor.GetColorError(aBlue) >= aBackColor.GetColorError(aYellow) ) + return aBlue; + else + return aYellow; + } + else + return Color( COL_LIGHTBLUE ); // default for transparent or ambiguous background +} + +// ----------------------------------------------------------------------- + +// +// --- Public-Funktionen +// + +void ScTabView::ClickCursor( USHORT nPosX, USHORT nPosY, BOOL bControl ) +{ + ScDocument* pDoc = aViewData.GetDocument(); + USHORT nTab = aViewData.GetTabNo(); + while (pDoc->IsHorOverlapped( nPosX, nPosY, nTab )) //! ViewData !!! + --nPosX; + while (pDoc->IsVerOverlapped( nPosX, nPosY, nTab )) + --nPosY; + + BOOL bRefMode = SC_MOD()->IsFormulaMode(); + + if ( bRefMode ) + { + DoneRefMode( FALSE ); + + USHORT nTab = aViewData.GetTabNo(); + ScDocument* pDoc = aViewData.GetDocument(); + if (bControl) + SC_MOD()->AddRefEntry(); + + InitRefMode( nPosX, nPosY, nTab, SC_REFTYPE_REF ); + } + else + { + DoneBlockMode( bControl ); + aViewData.ResetOldCursor(); + SetCursor( (USHORT) nPosX, (USHORT) nPosY ); + } +} + +void ScTabView::UpdateAutoFillMark() +{ + ScRange aMarkRange; + BOOL bMarked = aViewData.GetSimpleArea( aMarkRange, TRUE ); // einfach oder nur Cursor + + USHORT i; + for (i=0; i<4; i++) + if (pGridWin[i] && pGridWin[i]->IsVisible()) + pGridWin[i]->UpdateAutoFillMark( bMarked, aMarkRange ); + + for (i=0; i<2; i++) + { + if (pColBar[i] && pColBar[i]->IsVisible()) + pColBar[i]->SetMark( bMarked, aMarkRange.aStart.Col(), aMarkRange.aEnd.Col() ); + if (pRowBar[i] && pRowBar[i]->IsVisible()) + pRowBar[i]->SetMark( bMarked, aMarkRange.aStart.Row(), aMarkRange.aEnd.Row() ); + } +} + +void ScTabView::FakeButtonUp( ScSplitPos eWhich ) +{ + if (pGridWin[eWhich]) + pGridWin[eWhich]->FakeButtonUp(); +} + +void ScTabView::HideAllCursors() +{ + for (USHORT i=0; i<4; i++) + if (pGridWin[i]) + if (pGridWin[i]->IsVisible()) + { + Cursor* pCur = pGridWin[i]->GetCursor(); + if (pCur) + if (pCur->IsVisible()) + pCur->Hide(); + pGridWin[i]->HideCursor(); + } +} + +void ScTabView::ShowAllCursors() +{ + for (USHORT i=0; i<4; i++) + if (pGridWin[i]) + if (pGridWin[i]->IsVisible()) + pGridWin[i]->ShowCursor(); +} + +void ScTabView::HideCursor() +{ + pGridWin[aViewData.GetActivePart()]->HideCursor(); +} + +void ScTabView::ShowCursor() +{ + pGridWin[aViewData.GetActivePart()]->ShowCursor(); +} + +void ScTabView::InvalidateAttribs() +{ + SfxBindings& rBindings = SFX_BINDINGS(); + + rBindings.Invalidate( SID_STYLE_APPLY ); + rBindings.Invalidate( SID_STYLE_FAMILY2 ); + // StarCalc kennt nur Absatz- bzw. Zellformat-Vorlagen + + rBindings.Invalidate( SID_ATTR_CHAR_FONT ); + rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT ); + rBindings.Invalidate( SID_ATTR_CHAR_COLOR ); + + rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT ); + rBindings.Invalidate( SID_ATTR_CHAR_POSTURE ); + rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE ); + rBindings.Invalidate( SID_ULINE_VAL_NONE ); + rBindings.Invalidate( SID_ULINE_VAL_SINGLE ); + rBindings.Invalidate( SID_ULINE_VAL_DOUBLE ); + rBindings.Invalidate( SID_ULINE_VAL_DOTTED ); + + rBindings.Invalidate( SID_ALIGNLEFT ); + rBindings.Invalidate( SID_ALIGNRIGHT ); + rBindings.Invalidate( SID_ALIGNBLOCK ); + rBindings.Invalidate( SID_ALIGNCENTERHOR ); + + rBindings.Invalidate( SID_ALIGNTOP ); + rBindings.Invalidate( SID_ALIGNBOTTOM ); + rBindings.Invalidate( SID_ALIGNCENTERVER ); + + rBindings.Invalidate( SID_BACKGROUND_COLOR ); + + rBindings.Invalidate( SID_ATTR_ALIGN_LINEBREAK ); + rBindings.Invalidate( SID_NUMBER_FORMAT ); + +// rBindings.Invalidate( SID_RANGE_VALUE ); +// rBindings.Invalidate( SID_RANGE_FORMULA ); +} + +// SetCursor - Cursor setzen, zeichnen, InputWin updaten +// oder Referenz verschicken +// ohne Optimierung wegen BugId 29307 + +#ifdef WNT +#pragma optimize ( "", off ) +#endif + +void ScTabView::SetCursor( USHORT nPosX, USHORT nPosY, BOOL bNew ) +{ + USHORT nOldX = aViewData.GetCurX(); + USHORT nOldY = aViewData.GetCurY(); + + // DeactivateIP nur noch bei MarkListHasChanged + + if ( nPosX != nOldX || nPosY != nOldY || bNew ) + { + if ( aViewData.HasEditView(aViewData.GetActivePart()) && + !SC_MOD()->IsFormulaMode() ) // 23259 oder so + UpdateInputLine(); + + HideAllCursors(); + + aViewData.SetCurX( nPosX ); + aViewData.SetCurY( nPosY ); + + ShowAllCursors(); + + CursorPosChanged(); + } +} + +#ifdef WNT +#pragma optimize ( "", on ) +#endif + +// Eingabezeile / Menues updaten +// CursorPosChanged ruft SelectionChanged +// SelectionChanged ruft CellContentChanged + +void ScTabView::CellContentChanged() +{ + SfxBindings& rBindings = SFX_BINDINGS(); + + rBindings.Invalidate( SID_ATTR_SIZE ); // -> Fehlermeldungen anzeigen + rBindings.Invalidate( SID_THESAURUS ); + rBindings.Invalidate( SID_HYPERLINK_GETLINK ); + + InvalidateAttribs(); // Attribut-Updates + TestHintWindow(); // Eingabemeldung (Gueltigkeit) + + aViewData.GetViewShell()->UpdateInputHandler(); +} + +void ScTabView::SelectionChanged() +{ + SfxViewFrame* pViewFrame = aViewData.GetViewShell()->GetViewFrame(); + if (pViewFrame) + { + SfxFrame* pFrame = pViewFrame->GetFrame(); + if (pFrame) + { + uno::Reference<frame::XController> xController = pFrame->GetController(); + if (xController.is()) + { + ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController ); + if (pImp) + pImp->SelectionChanged(); + } + } + } + + UpdateAutoFillMark(); + + SfxBindings& rBindings = SFX_BINDINGS(); + + rBindings.Invalidate( SID_CURRENTCELL ); // -> Navigator + rBindings.Invalidate( SID_AUTO_FILTER ); // -> Menue + rBindings.Invalidate( FID_NOTE_VISIBLE ); + + // Funktionen, die evtl disabled werden muessen + + rBindings.Invalidate( FID_INS_ROWBRK ); + rBindings.Invalidate( FID_INS_COLBRK ); + rBindings.Invalidate( FID_DEL_ROWBRK ); + rBindings.Invalidate( FID_DEL_COLBRK ); + rBindings.Invalidate( FID_MERGE_ON ); + rBindings.Invalidate( FID_MERGE_OFF ); + rBindings.Invalidate( SID_AUTOFILTER_HIDE ); + rBindings.Invalidate( SID_UNFILTER ); +// rBindings.Invalidate( SID_IMPORT_DATA ); // jetzt wieder immer moeglich + rBindings.Invalidate( SID_REIMPORT_DATA ); + rBindings.Invalidate( SID_REFRESH_DBAREA ); + rBindings.Invalidate( SID_OUTLINE_SHOW ); + rBindings.Invalidate( SID_OUTLINE_HIDE ); + rBindings.Invalidate( SID_OUTLINE_REMOVE ); + rBindings.Invalidate( FID_FILL_TO_BOTTOM ); + rBindings.Invalidate( FID_FILL_TO_RIGHT ); + rBindings.Invalidate( FID_FILL_TO_TOP ); + rBindings.Invalidate( FID_FILL_TO_LEFT ); + rBindings.Invalidate( FID_FILL_SERIES ); + rBindings.Invalidate( SID_SCENARIOS ); + rBindings.Invalidate( SID_AUTOFORMAT ); + rBindings.Invalidate( SID_OPENDLG_TABOP ); + rBindings.Invalidate( SID_DATA_SELECT ); + + rBindings.Invalidate( SID_CUT ); + rBindings.Invalidate( SID_COPY ); + rBindings.Invalidate( SID_PASTE ); + rBindings.Invalidate( FID_PASTE_CONTENTS ); + + rBindings.Invalidate( FID_INS_ROW ); + rBindings.Invalidate( FID_INS_COLUMN ); + rBindings.Invalidate( FID_INS_CELL ); + rBindings.Invalidate( FID_INS_CELLSDOWN ); + rBindings.Invalidate( FID_INS_CELLSRIGHT ); + + rBindings.Invalidate( FID_CHG_COMMENT ); + + // nur wegen Zellschutz: + + rBindings.Invalidate( SID_CELL_FORMAT_RESET ); + rBindings.Invalidate( SID_DELETE ); + rBindings.Invalidate( SID_DELETE_CONTENTS ); + rBindings.Invalidate( FID_DELETE_CELL ); + rBindings.Invalidate( FID_CELL_FORMAT ); + rBindings.Invalidate( SID_INSERT_POSTIT ); + rBindings.Invalidate( SID_CHARMAP ); + rBindings.Invalidate( SID_OPENDLG_FUNCTION ); +// rBindings.Invalidate( FID_CONDITIONAL_FORMAT ); + rBindings.Invalidate( SID_OPENDLG_CONDFRMT ); + rBindings.Invalidate( FID_VALIDATION ); + + CellContentChanged(); +} + +void ScTabView::CursorPosChanged() +{ + BOOL bRefMode = SC_MOD()->IsFormulaMode(); + if ( !bRefMode ) // Abfrage, damit RefMode bei Tabellenwechsel funktioniert + aViewData.GetDocShell()->Broadcast( SfxSimpleHint( FID_KILLEDITVIEW ) ); + + // Broadcast, damit andere Views des Dokuments auch umschalten + + ScDocument* pDoc = aViewData.GetDocument(); + BOOL bPivot = ( NULL != pDoc->GetPivotAtCursor( aViewData.GetCurX(), + aViewData.GetCurY(), + aViewData.GetTabNo() ) || + NULL != pDoc->GetDPAtCursor( aViewData.GetCurX(), + aViewData.GetCurY(), + aViewData.GetTabNo() ) ); + aViewData.GetViewShell()->SetPivotShell(bPivot); + + // UpdateInputHandler jetzt in CellContentChanged + + SelectionChanged(); + + aViewData.SetTabStartCol( SC_TABSTART_NONE ); +} + +void ScTabView::TestHintWindow() +{ + // Eingabemeldung (Gueltigkeit) + //! per Timer / ControllerItem anzeigen ??? + + ScDocument* pDoc = aViewData.GetDocument(); + const SfxUInt32Item* pItem = (const SfxUInt32Item*) + pDoc->GetAttr( aViewData.GetCurX(), + aViewData.GetCurY(), + aViewData.GetTabNo(), + ATTR_VALIDDATA ); + if ( pItem->GetValue() ) + { + const ScValidationData* pData = pDoc->GetValidationEntry( pItem->GetValue() ); + DBG_ASSERT(pData,"ValidationData nicht gefunden"); + String aTitle, aMessage; + if ( pData && pData->GetInput( aTitle, aMessage ) ) + { + //! Abfrage, ob an gleicher Stelle !!!! + + DELETEZ(pInputHintWindow); + + ScSplitPos eWhich = aViewData.GetActivePart(); + Window* pWin = pGridWin[eWhich]; + USHORT nCol = aViewData.GetCurX(); + USHORT nRow = aViewData.GetCurY(); + Point aPos = aViewData.GetScrPos( nCol, nRow, eWhich ); + Size aWinSize = pWin->GetOutputSizePixel(); + // Cursor sichtbar? + if ( nCol >= aViewData.GetPosX(WhichH(eWhich)) && + nRow >= aViewData.GetPosY(WhichV(eWhich)) && + aPos.X() < aWinSize.Width() && aPos.Y() < aWinSize.Height() ) + { + aPos += pWin->GetPosPixel(); // Position auf Frame + long nSizeXPix; + long nSizeYPix; + aViewData.GetMergeSizePixel( nCol, nRow, nSizeXPix, nSizeYPix ); + + // HintWindow anlegen, bestimmt seine Groesse selbst + pInputHintWindow = new ScHintWindow( pFrameWin, aTitle, aMessage ); + Size aHintSize = pInputHintWindow->GetSizePixel(); + Size aFrameSize = pFrameWin->GetOutputSizePixel(); + + // passende Position finden + // erster Versuch: unter dem Cursor + Point aHintPos( aPos.X() + nSizeXPix / 2, aPos.Y() + nSizeYPix + 3 ); + if ( aHintPos.Y() + aHintSize.Height() > aFrameSize.Height() ) + { + // zweiter Versuch: rechts vom Cursor + aHintPos = Point( aPos.X() + nSizeXPix + 3, aPos.Y() + nSizeYPix / 2 ); + if ( aHintPos.X() + aHintSize.Width() > aFrameSize.Width() ) + { + // dritter Versuch: ueber dem Cursor + aHintPos = Point( aPos.X() + nSizeXPix / 2, + aPos.Y() - aHintSize.Height() - 3 ); + if ( aHintPos.Y() < 0 ) + { + // oben und unten kein Platz - dann Default und abschneiden + aHintPos = Point( aPos.X() + nSizeXPix / 2, aPos.Y() + nSizeYPix + 3 ); + aHintSize.Height() = aFrameSize.Height() - aHintPos.Y(); + pInputHintWindow->SetSizePixel( aHintSize ); + } + } + } + + // X anpassen + if ( aHintPos.X() + aHintSize.Width() > aFrameSize.Width() ) + aHintPos.X() = aFrameSize.Width() - aHintSize.Width(); + // Y anpassen + if ( aHintPos.Y() + aHintSize.Height() > aFrameSize.Height() ) + aHintPos.Y() = aFrameSize.Height() - aHintSize.Height(); + + pInputHintWindow->SetPosPixel( aHintPos ); + pInputHintWindow->ToTop(); + pInputHintWindow->Show(); + } + } + else + DELETEZ(pInputHintWindow); + } + else + DELETEZ(pInputHintWindow); +} + +void ScTabView::RemoveHintWindow() +{ + DELETEZ(pInputHintWindow); +} + + +// find window that should not be over the cursor +Window* lcl_GetCareWin(SfxViewFrame* pViewFrm) +{ + //! auch Spelling ??? (dann beim Aufruf Membervariable setzen) + + // Suchen & Ersetzen + if ( pViewFrm->HasChildWindow(SID_SEARCH_DLG) ) + { + SfxChildWindow* pChild = pViewFrm->GetChildWindow(SID_SEARCH_DLG); + if (pChild) + { + Window* pWin = pChild->GetWindow(); + if (pWin && pWin->IsVisible()) + return pWin; + } + } + + // Aenderungen uebernehmen + if ( pViewFrm->HasChildWindow(FID_CHG_ACCEPT) ) + { + SfxChildWindow* pChild = pViewFrm->GetChildWindow(FID_CHG_ACCEPT); + if (pChild) + { + Window* pWin = pChild->GetWindow(); + if (pWin && pWin->IsVisible()) + return pWin; + } + } + + return NULL; +} + + // + // Bildschirm an Cursorposition anpassen + // + +void ScTabView::AlignToCursor( short nCurX, short nCurY, ScFollowMode eMode, + const ScSplitPos* pWhich ) +{ + // + // aktiven Teil umschalten jetzt hier + // + + ScSplitPos eActive = aViewData.GetActivePart(); + ScHSplitPos eActiveX = WhichH(eActive); + ScVSplitPos eActiveY = WhichV(eActive); + BOOL bHFix = (aViewData.GetHSplitMode() == SC_SPLIT_FIX); + BOOL bVFix = (aViewData.GetVSplitMode() == SC_SPLIT_FIX); + if (bHFix) + if (eActiveX == SC_SPLIT_LEFT && nCurX >= (short)aViewData.GetFixPosX()) + { + ActivatePart( (eActiveY==SC_SPLIT_TOP) ? SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT ); + eActiveX = SC_SPLIT_RIGHT; + } + if (bVFix) + if (eActiveY == SC_SPLIT_TOP && nCurY >= (short)aViewData.GetFixPosY()) + { + ActivatePart( (eActiveX==SC_SPLIT_LEFT) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT ); + eActiveY = SC_SPLIT_BOTTOM; + } + + // + // eigentliches Align + // + + if ( eMode != SC_FOLLOW_NONE ) + { + ScSplitPos eAlign; + if (pWhich) + eAlign = *pWhich; + else + eAlign = aViewData.GetActivePart(); + ScHSplitPos eAlignX = WhichH(eAlign); + ScVSplitPos eAlignY = WhichV(eAlign); + + short nDeltaX = (short) aViewData.GetPosX(eAlignX); + short nDeltaY = (short) aViewData.GetPosY(eAlignY); + short nSizeX = (short) aViewData.VisibleCellsX(eAlignX); + short nSizeY = (short) aViewData.VisibleCellsY(eAlignY); + + // VisibleCellsY == CellsAtY( GetPosY( eWhichY ), 1, eWhichY ) + + //------------------------------------------------------------------------------- + // falls z.B. Suchen-Dialog offen ist, Cursor nicht hinter den Dialog stellen + // wenn moeglich, die Zeile mit dem Cursor oberhalb oder unterhalb des Dialogs + + //! nicht, wenn schon komplett sichtbar + + if ( eMode == SC_FOLLOW_JUMP ) + { + Window* pCare = lcl_GetCareWin( aViewData.GetViewShell()->GetViewFrame() ); + if (pCare) + { + BOOL bLimit = FALSE; + Rectangle aDlgPixel; + Size aWinSize; + Window* pWin = GetActiveWin(); + if (pWin) + { + aDlgPixel = Rectangle( + pWin->ScreenToOutputPixel( pCare->GetPosPixel() ), + pCare->GetSizePixel() ); + aWinSize = pWin->GetOutputSizePixel(); + // ueberdeckt der Dialog das GridWin? + if ( aDlgPixel.Right() >= 0 && aDlgPixel.Left() < aWinSize.Width() ) + { + if ( nCurX < nDeltaX || nCurX >= nDeltaX+nSizeX || + nCurY < nDeltaY || nCurY >= nDeltaY+nSizeY ) + bLimit = TRUE; // es wird sowieso gescrollt + else + { + // Cursor ist auf dem Bildschirm + Point aStart = aViewData.GetScrPos( nCurX, nCurY, eAlign ); + long nCSX, nCSY; + aViewData.GetMergeSizePixel( nCurX, nCurY, nCSX, nCSY ); + Rectangle aCursor( aStart, Size( nCSX, nCSY ) ); + if ( aCursor.IsOver( aDlgPixel ) ) + bLimit = TRUE; // Zelle vom Dialog ueberdeckt + } + } + } + + if (bLimit) + { + BOOL bBottom = FALSE; + long nTopSpace = aDlgPixel.Top(); + long nBotSpace = aWinSize.Height() - aDlgPixel.Bottom(); + if ( nBotSpace > 0 && nBotSpace > nTopSpace ) + { + long nDlgBot = aDlgPixel.Bottom(); + short nWPosX, nWPosY; + aViewData.GetPosFromPixel( 0,nDlgBot, eAlign, nWPosX, nWPosY ); + ++nWPosY; // unter der letzten betroffenen Zelle + + short nDiff = nWPosY - nDeltaY; + if ( nCurY >= nDiff ) // Pos. kann nicht negativ werden + { + nSizeY -= nDiff; + nDeltaY = nWPosY; + bBottom = TRUE; + } + } + if ( !bBottom && nTopSpace > 0 ) + { + short nWPosX, nWPosY; + aViewData.GetPosFromPixel( 0,nTopSpace, eAlign, nWPosX, nWPosY ); + nSizeY = nWPosY - nDeltaY; + } + } + } + } + //------------------------------------------------------------------------------- + + short nNewDeltaX = nDeltaX; + short nNewDeltaY = nDeltaY; + BOOL bDoLine = FALSE; + + switch (eMode) + { + case SC_FOLLOW_JUMP: + if ( nCurX < nDeltaX || nCurX >= nDeltaX+nSizeX ) + { + nNewDeltaX = nCurX - (nSizeX / 2); + if (nNewDeltaX < 0) nNewDeltaX = 0; + nSizeX = (short) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX ); + } + if ( nCurY < nDeltaY || nCurY >= nDeltaY+nSizeY ) + { + nNewDeltaY = nCurY - (nSizeY / 2); + if (nNewDeltaY < 0) nNewDeltaY = 0; + nSizeY = (short) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY ); + } + bDoLine = TRUE; + break; + + case SC_FOLLOW_LINE: + bDoLine = TRUE; + break; + + case SC_FOLLOW_FIX: + if ( nCurX < nDeltaX || nCurX >= nDeltaX+nSizeX ) + { + nNewDeltaX = nDeltaX + nCurX - aViewData.GetCurX(); + nSizeX = (short) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX ); + } + if ( nCurY < nDeltaY || nCurY >= nDeltaY+nSizeY ) + { + nNewDeltaY = nDeltaY + nCurY - aViewData.GetCurY(); + nSizeY = (short) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY ); + } + + // wie SC_FOLLOW_JUMP: + + if ( nCurX < nNewDeltaX || nCurX >= nNewDeltaX+nSizeX ) + { + nNewDeltaX = nCurX - (nSizeX / 2); + if (nNewDeltaX < 0) nNewDeltaY = 0; + nSizeX = (short) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX ); + } + if ( nCurY < nNewDeltaY || nCurY >= nNewDeltaY+nSizeY ) + { + nNewDeltaY = nCurY - (nSizeY / 2); + if (nNewDeltaY < 0) nNewDeltaY = 0; + nSizeY = (short) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY ); + } + + bDoLine = TRUE; + break; + + case SC_FOLLOW_NONE: + break; + default: + DBG_ERROR("Falscher Cursormodus"); + break; + } + + if (bDoLine) + { + while ( nCurX >= nNewDeltaX+nSizeX ) + { + nNewDeltaX = nCurX-nSizeX+1; + ScDocument* pDoc = aViewData.GetDocument(); + USHORT nTab = aViewData.GetTabNo(); + while ( nNewDeltaX < MAXCOL && !pDoc->GetColWidth( nNewDeltaX, nTab ) ) + ++nNewDeltaX; + nSizeX = (short) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX ); + } + while ( nCurY >= nNewDeltaY+nSizeY ) + { + nNewDeltaY = nCurY-nSizeY+1; + ScDocument* pDoc = aViewData.GetDocument(); + USHORT nTab = aViewData.GetTabNo(); + while ( nNewDeltaY < MAXROW && !pDoc->GetRowHeight( nNewDeltaY, nTab ) ) + ++nNewDeltaY; + nSizeY = (short) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY ); + } + if ( nCurX < nNewDeltaX ) nNewDeltaX = nCurX; + if ( nCurY < nNewDeltaY ) nNewDeltaY = nCurY; + } + + if ( nNewDeltaX != nDeltaX ) + nSizeX = (short) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX ); + if (nNewDeltaX+nSizeX-1 > MAXCOL) nNewDeltaX = MAXCOL-nSizeX+1; + if (nNewDeltaX < 0) nNewDeltaX = 0; + + if ( nNewDeltaY != nDeltaY ) + nSizeY = (short) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY ); + if (nNewDeltaY+nSizeY-1 > MAXROW) nNewDeltaY = MAXROW-nSizeY+1; + if (nNewDeltaY < 0) nNewDeltaY = 0; + + if ( nNewDeltaX != nDeltaX ) ScrollX( nNewDeltaX - nDeltaX, eAlignX ); + if ( nNewDeltaY != nDeltaY ) ScrollY( nNewDeltaY - nDeltaY, eAlignY ); + } + + // + // nochmal aktiven Teil umschalten + // + + if (bHFix) + if (eActiveX == SC_SPLIT_RIGHT && nCurX < (short)aViewData.GetFixPosX()) + { + ActivatePart( (eActiveY==SC_SPLIT_TOP) ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT ); + eActiveX = SC_SPLIT_LEFT; + } + if (bVFix) + if (eActiveY == SC_SPLIT_BOTTOM && nCurY < (short)aViewData.GetFixPosY()) + { + ActivatePart( (eActiveX==SC_SPLIT_LEFT) ? SC_SPLIT_TOPLEFT : SC_SPLIT_TOPRIGHT ); + eActiveY = SC_SPLIT_TOP; + } +} + +BOOL ScTabView::SelMouseButtonDown( const MouseEvent& rMEvt ) +{ + BOOL bRet = FALSE; + if ( pSelEngine ) + { + bMoveIsShift = rMEvt.IsShift(); + bRet = pSelEngine->SelMouseButtonDown( rMEvt ); + bMoveIsShift = FALSE; + } + return bRet; +} + + // + // MoveCursor - mit Anpassung des Bildausschnitts + // + +void ScTabView::MoveCursorAbs( short nCurX, short nCurY, ScFollowMode eMode, + BOOL bShift, BOOL bControl, BOOL bKeepOld, BOOL bKeepSel ) +{ + if (!bKeepOld) + aViewData.ResetOldCursor(); + + if (nCurX < 0) nCurX = 0; + if (nCurY < 0) nCurY = 0; + if (nCurX > MAXCOL) nCurX = MAXCOL; + if (nCurY > MAXROW) nCurY = MAXROW; + + HideAllCursors(); + + // aktiven Teil umschalten jetzt in AlignToCursor + + AlignToCursor( nCurX, nCurY, eMode ); + //! auf OS/2: SC_FOLLOW_JUMP statt SC_FOLLOW_LINE, um Nachlaufen zu verhindern ??? + + if (bKeepSel) + SetCursor( nCurX, nCurY ); // Markierung stehenlassen + else + { + BOOL bSame = ( nCurX == aViewData.GetCurX() && nCurY == aViewData.GetCurY() ); + bMoveIsShift = bShift; + pSelEngine->CursorPosChanging( bShift, bControl ); + bMoveIsShift = FALSE; + aFunctionSet.SetCursorAtCell( nCurX, nCurY, FALSE ); + + // Wenn der Cursor nicht bewegt wurde, muss das SelectionChanged fuer das + // Aufheben der Selektion hier einzeln passieren: + if (bSame) + SelectionChanged(); + } + + ShowAllCursors(); +} + +void ScTabView::MoveCursorRel( short nMovX, short nMovY, ScFollowMode eMode, + BOOL bShift, BOOL bKeepSel ) +{ + ScDocument* pDoc = aViewData.GetDocument(); + USHORT nTab = aViewData.GetTabNo(); + + short nOldX; + short nOldY; + short nCurX; + short nCurY; + if ( aViewData.IsRefMode() ) + { + nOldX = (short) aViewData.GetRefEndX(); + nOldY = (short) aViewData.GetRefEndY(); + nCurX = nOldX + nMovX; + nCurY = nOldY + nMovY; + } + else + { + nOldX = (short) aViewData.GetCurX(); + nOldY = (short) aViewData.GetCurY(); + nCurX = nMovX ? nOldX+nMovX : (short) aViewData.GetOldCurX(); + nCurY = nMovY ? nOldY+nMovY : (short) aViewData.GetOldCurY(); + } + + BOOL bHidden; + aViewData.ResetOldCursor(); + + if (nMovX && VALIDCOLROW(nCurX,nCurY)) + { + BOOL bHFlip = FALSE; + do + { + BYTE nColFlags = pDoc->GetColFlags( nCurX, nTab ); + bHidden = (nColFlags & CR_HIDDEN) || pDoc->IsHorOverlapped( nCurX, nCurY, nTab ); + if (bHidden) + { + if ( nCurX<=0 || nCurX>=MAXCOL ) + { + if (bHFlip) + { + nCurX = nOldX; + bHidden = FALSE; + } + else + { + nMovX = -nMovX; + if (nMovX > 0) ++nCurX; else --nCurX; // zuruecknehmen + bHFlip = TRUE; + } + } + else + if (nMovX > 0) ++nCurX; else --nCurX; + } + } + while (bHidden); + if (pDoc->IsVerOverlapped( nCurX, nCurY, nTab )) + { + aViewData.SetOldCursor( nCurX,nCurY ); + while (pDoc->IsVerOverlapped( nCurX, nCurY, nTab )) + --nCurY; + } + } + + if (nMovY && VALIDCOLROW(nCurX,nCurY)) + { + BOOL bVFlip = FALSE; + do + { + BYTE nRowFlags = pDoc->GetRowFlags( nCurY, nTab ); + bHidden = (nRowFlags & CR_HIDDEN) || pDoc->IsVerOverlapped( nCurX, nCurY, nTab ); + if (bHidden) + { + if ( nCurY<=0 || nCurY>=MAXROW ) + { + if (bVFlip) + { + nCurY = nOldY; + bHidden = FALSE; + } + else + { + nMovY = -nMovY; + if (nMovY > 0) ++nCurY; else --nCurY; // zuruecknehmen + bVFlip = TRUE; + } + } + else + if (nMovY > 0) ++nCurY; else --nCurY; + } + } + while (bHidden); + if (pDoc->IsHorOverlapped( nCurX, nCurY, nTab )) + { + aViewData.SetOldCursor( nCurX,nCurY ); + while (pDoc->IsHorOverlapped( nCurX, nCurY, nTab )) + --nCurX; + } + } + + MoveCursorAbs( nCurX, nCurY, eMode, bShift, FALSE, TRUE, bKeepSel ); +} + +void ScTabView::MoveCursorPage( short nMovX, short nMovY, ScFollowMode eMode, BOOL bShift ) +{ + USHORT nCurX; + USHORT nCurY; + aViewData.GetMoveCursor( nCurX,nCurY ); + + ScSplitPos eWhich = aViewData.GetActivePart(); + ScHSplitPos eWhichX = WhichH( eWhich ); + ScVSplitPos eWhichY = WhichV( eWhich ); + + short nPageX; + short nPageY; + if (nMovX >= 0) + nPageX = ((short) aViewData.CellsAtX( nCurX, 1, eWhichX )) * nMovX; + else + nPageX = ((short) aViewData.CellsAtX( nCurX, -1, eWhichX )) * nMovX; + + if (nMovY >= 0) + nPageY = ((short) aViewData.CellsAtY( nCurY, 1, eWhichY )) * nMovY; + else + nPageY = ((short) aViewData.CellsAtY( nCurY, -1, eWhichY )) * nMovY; + + if (nMovX && !nPageX) nPageX = (nMovX>0) ? 1 : -1; + if (nMovY && !nPageY) nPageY = (nMovY>0) ? 1 : -1; + + MoveCursorRel( nPageX, nPageY, eMode, bShift ); +} + +void ScTabView::MoveCursorArea( short nMovX, short nMovY, ScFollowMode eMode, BOOL bShift ) +{ + USHORT nCurX; + USHORT nCurY; + aViewData.GetMoveCursor( nCurX,nCurY ); + USHORT nNewX = nCurX; + USHORT nNewY = nCurY; + + ScDocument* pDoc = aViewData.GetDocument(); + USHORT nTab = aViewData.GetTabNo(); + + // FindAreaPos kennt nur -1 oder 1 als Richtung + + short i; + if ( nMovX > 0 ) + for ( i=0; i<nMovX; i++ ) + pDoc->FindAreaPos( nNewX, nNewY, nTab, 1, 0 ); + if ( nMovX < 0 ) + for ( i=0; i<-nMovX; i++ ) + pDoc->FindAreaPos( nNewX, nNewY, nTab, -1, 0 ); + if ( nMovY > 0 ) + for ( i=0; i<nMovY; i++ ) + pDoc->FindAreaPos( nNewX, nNewY, nTab, 0, 1 ); + if ( nMovY < 0 ) + for ( i=0; i<-nMovY; i++ ) + pDoc->FindAreaPos( nNewX, nNewY, nTab, 0, -1 ); + + if (eMode==SC_FOLLOW_JUMP) // unten/rechts nicht zuviel grau anzeigen + { + if (nMovX != 0 && nNewX == MAXCOL) + eMode = SC_FOLLOW_LINE; + if (nMovY != 0 && nNewY == MAXROW) + eMode = SC_FOLLOW_LINE; + } + + MoveCursorRel( ((short)nNewX)-(short)nCurX, ((short)nNewY)-(short)nCurY, eMode, bShift ); +} + +void ScTabView::MoveCursorEnd( short nMovX, short nMovY, ScFollowMode eMode, BOOL bShift ) +{ + ScDocument* pDoc = aViewData.GetDocument(); + USHORT nTab = aViewData.GetTabNo(); + + USHORT nCurX; + USHORT nCurY; + aViewData.GetMoveCursor( nCurX,nCurY ); + USHORT nNewX = nCurX; + USHORT nNewY = nCurY; + + USHORT nUsedX = 0; + USHORT nUsedY = 0; + if ( nMovX > 0 || nMovY > 0 ) + pDoc->GetPrintArea( nTab, nUsedX, nUsedY ); // Ende holen + + if (nMovX<0) + nNewX=0; + else if (nMovX>0) + nNewX=nUsedX; // letzter benutzter Bereich + + if (nMovY<0) + nNewY=0; + else if (nMovY>0) + nNewY=nUsedY; + + aViewData.ResetOldCursor(); + MoveCursorRel( ((short)nNewX)-(short)nCurX, ((short)nNewY)-(short)nCurY, eMode, bShift ); +} + +void ScTabView::MoveCursorScreen( short nMovX, short nMovY, ScFollowMode eMode, BOOL bShift ) +{ + ScDocument* pDoc = aViewData.GetDocument(); + USHORT nTab = aViewData.GetTabNo(); + + USHORT nCurX; + USHORT nCurY; + aViewData.GetMoveCursor( nCurX,nCurY ); + USHORT nNewX = nCurX; + USHORT nNewY = nCurY; + + ScSplitPos eWhich = aViewData.GetActivePart(); + USHORT nPosX = aViewData.GetPosX( WhichH(eWhich) ); + USHORT nPosY = aViewData.GetPosY( WhichV(eWhich) ); + + USHORT nAddX = aViewData.VisibleCellsX( WhichH(eWhich) ); + if (nAddX) + --nAddX; + USHORT nAddY = aViewData.VisibleCellsY( WhichV(eWhich) ); + if (nAddY) + --nAddY; + + if (nMovX<0) + nNewX=nPosX; + else if (nMovX>0) + nNewX=nPosX+nAddX; + + if (nMovY<0) + nNewY=nPosY; + else if (nMovY>0) + nNewY=nPosY+nAddY; + +// aViewData.ResetOldCursor(); + aViewData.SetOldCursor( nNewX,nNewY ); + + while (pDoc->IsHorOverlapped( nNewX, nNewY, nTab )) + --nNewX; + while (pDoc->IsVerOverlapped( nNewX, nNewY, nTab )) + --nNewY; + + MoveCursorAbs( nNewX, nNewY, eMode, bShift, FALSE, TRUE ); +} + +void ScTabView::MoveCursorEnter( BOOL bShift ) // bShift -> hoch/runter +{ + const ScInputOptions& rOpt = SC_MOD()->GetInputOptions(); + if (!rOpt.GetMoveSelection()) + { + aViewData.UpdateInputHandler(TRUE); + return; + } + + short nMoveX = 0; + short nMoveY = 0; + switch ((ScDirection)rOpt.GetMoveDir()) + { + case DIR_BOTTOM: + nMoveY = bShift ? -1 : 1; + break; + case DIR_RIGHT: + nMoveX = bShift ? -1 : 1; + break; + case DIR_TOP: + nMoveY = bShift ? 1 : -1; + break; + case DIR_LEFT: + nMoveX = bShift ? 1 : -1; + break; + } + + ScMarkData& rMark = aViewData.GetMarkData(); + if (rMark.IsMarked() || rMark.IsMultiMarked()) + { + USHORT nCurX; + USHORT nCurY; + aViewData.GetMoveCursor( nCurX,nCurY ); + USHORT nNewX = nCurX; + USHORT nNewY = nCurY; + USHORT nTab = aViewData.GetTabNo(); + + ScDocument* pDoc = aViewData.GetDocument(); + pDoc->GetNextPos( nNewX,nNewY, nTab, nMoveX,nMoveY, TRUE,FALSE, rMark ); + + MoveCursorRel( ((short)nNewX)-(short)nCurX, ((short)nNewY)-(short)nCurY, + SC_FOLLOW_LINE, FALSE, TRUE ); + + // update input line even if cursor was not moved + if ( nNewX == nCurX && nNewY == nCurY ) + aViewData.UpdateInputHandler(TRUE); + } + else + { + if ( nMoveY && !nMoveX && rOpt.GetUseTabCol() ) + { + // nach Tab und Enter wieder zur Ausgangsspalte + USHORT nTabCol = aViewData.GetTabStartCol(); + if (nTabCol != SC_TABSTART_NONE) + { + USHORT nCurX; + USHORT nCurY; + aViewData.GetMoveCursor( nCurX,nCurY ); + nMoveX = ((short)nTabCol)-(short)nCurX; + } + } + + MoveCursorRel( nMoveX,nMoveY, SC_FOLLOW_LINE, FALSE ); + } +} + + // naechste/vorherige nicht geschuetzte Zelle +void ScTabView::FindNextUnprot( BOOL bShift, BOOL bInSelection ) +{ + short nMove = bShift ? -1 : 1; + + ScMarkData& rMark = aViewData.GetMarkData(); + BOOL bMarked = bInSelection && (rMark.IsMarked() || rMark.IsMultiMarked()); + + USHORT nCurX; + USHORT nCurY; + aViewData.GetMoveCursor( nCurX,nCurY ); + USHORT nNewX = nCurX; + USHORT nNewY = nCurY; + USHORT nTab = aViewData.GetTabNo(); + + ScDocument* pDoc = aViewData.GetDocument(); + pDoc->GetNextPos( nNewX,nNewY, nTab, nMove,0, bMarked,TRUE, rMark ); + + USHORT nTabCol = aViewData.GetTabStartCol(); + if ( nTabCol == SC_TABSTART_NONE ) + nTabCol = nCurX; // auf diese Spalte zurueck bei Enter + + MoveCursorRel( ((short)nNewX)-(short)nCurX, ((short)nNewY)-(short)nCurY, + SC_FOLLOW_LINE, FALSE, TRUE ); + + // in MoveCursorRel wird die TabCol zurueckgesetzt... + aViewData.SetTabStartCol( nTabCol ); +} + +void ScTabView::MarkColumns() +{ + USHORT nStartCol; + USHORT nEndCol; + + ScMarkData& rMark = aViewData.GetMarkData(); + if (rMark.IsMarked()) + { + ScRange aMarkRange; + rMark.GetMarkArea( aMarkRange ); + nStartCol = aMarkRange.aStart.Col(); + nEndCol = aMarkRange.aEnd.Col(); + } + else + { + USHORT nDummy; + aViewData.GetMoveCursor( nStartCol, nDummy ); + nEndCol=nStartCol; + } + + USHORT nTab = aViewData.GetTabNo(); + DoneBlockMode(); + InitBlockMode( nStartCol,0, nTab ); + MarkCursor( nEndCol,MAXROW, nTab ); + SelectionChanged(); +} + +void ScTabView::MarkRows() +{ + USHORT nStartRow; + USHORT nEndRow; + + ScMarkData& rMark = aViewData.GetMarkData(); + if (rMark.IsMarked()) + { + ScRange aMarkRange; + rMark.GetMarkArea( aMarkRange ); + nStartRow = aMarkRange.aStart.Row(); + nEndRow = aMarkRange.aEnd.Row(); + } + else + { + USHORT nDummy; + aViewData.GetMoveCursor( nDummy, nStartRow ); + nEndRow=nStartRow; + } + + USHORT nTab = aViewData.GetTabNo(); + DoneBlockMode(); + InitBlockMode( 0,nStartRow, nTab ); + MarkCursor( MAXCOL,nEndRow, nTab ); + SelectionChanged(); +} + +void ScTabView::MarkDataArea( BOOL bIncludeCursor ) +{ + ScDocument* pDoc = aViewData.GetDocument(); + USHORT nTab = aViewData.GetTabNo(); + USHORT nStartCol = aViewData.GetCurX(); + USHORT nStartRow = aViewData.GetCurY(); + USHORT nEndCol = nStartCol; + USHORT nEndRow = nStartRow; + + pDoc->GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, bIncludeCursor ); + + HideAllCursors(); + DoneBlockMode(); + InitBlockMode( nStartCol, nStartRow, nTab ); + MarkCursor( nEndCol, nEndRow, nTab ); + ShowAllCursors(); + + SelectionChanged(); +} + +void ScTabView::MarkRange( const ScRange& rRange, BOOL bSetCursor ) +{ + USHORT nTab = rRange.aStart.Tab(); + SetTabNo( nTab ); + + HideAllCursors(); + DoneBlockMode(); // alte Markierung aufheben vor dem Align + if (bSetCursor) // Wenn Cursor gesetzt wird, immer auch alignen + { + USHORT nAlignX = rRange.aStart.Col(); + USHORT nAlignY = rRange.aStart.Row(); + if ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == MAXCOL ) + nAlignX = aViewData.GetPosX(WhichH(aViewData.GetActivePart())); + if ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW ) + nAlignY = aViewData.GetPosY(WhichV(aViewData.GetActivePart())); + AlignToCursor( nAlignX, nAlignY, SC_FOLLOW_JUMP ); + } + InitBlockMode( rRange.aStart.Col(), rRange.aStart.Row(), nTab ); + MarkCursor( rRange.aEnd.Col(), rRange.aEnd.Row(), nTab ); + if (bSetCursor) + { + USHORT nPosX = rRange.aStart.Col(); + USHORT nPosY = rRange.aStart.Row(); + ScDocument* pDoc = aViewData.GetDocument(); + + while (pDoc->IsHorOverlapped( nPosX, nPosY, nTab )) //! ViewData !!! + --nPosX; + while (pDoc->IsVerOverlapped( nPosX, nPosY, nTab )) + --nPosY; + + aViewData.ResetOldCursor(); + SetCursor( nPosX, nPosY ); + } + ShowAllCursors(); + + SelectionChanged(); +} + +void ScTabView::Unmark() +{ + ScMarkData& rMark = aViewData.GetMarkData(); + if ( rMark.IsMarked() || rMark.IsMultiMarked() ) + { + USHORT nCurX; + USHORT nCurY; + aViewData.GetMoveCursor( nCurX,nCurY ); + MoveCursorAbs( nCurX, nCurY, SC_FOLLOW_NONE, FALSE, FALSE ); + + SelectionChanged(); + } +} + +void ScTabView::SelectNextTab( short nDir ) +{ + if (!nDir) return; + DBG_ASSERT( nDir==-1 || nDir==1, "SelectNextTab: falscher Wert"); + + ScDocument* pDoc = aViewData.GetDocument(); + USHORT nTab = aViewData.GetTabNo(); + if (nDir<0) + { + if (!nTab) return; + --nTab; + while (!pDoc->IsVisible(nTab)) + { + if (!nTab) return; + --nTab; + } + } + else + { + USHORT nCount = pDoc->GetTableCount(); + ++nTab; + if (nTab >= nCount) return; + while (!pDoc->IsVisible(nTab)) + { + ++nTab; + if (nTab >= nCount) return; + } + } + + SetTabNo(nTab); + PaintExtras(); +} + + +// SetTabNo - angezeigte Tabelle + +void ScTabView::SetTabNo( USHORT nTab, BOOL bNew ) +{ + if ( nTab > MAXTAB ) + { + DBG_ERROR("SetTabNo: falsche Tabelle"); + return; + } + + if ( nTab != aViewData.GetTabNo() || bNew ) + { + // #57724# Die FormShell moechte vor dem Umschalten benachrichtigt werden + FmFormShell* pFormSh = aViewData.GetViewShell()->GetFormShell(); + if (pFormSh) + { + BOOL bAllowed = pFormSh->PrepareClose( TRUE ); + if (!bAllowed) + { + //! Fehlermeldung? oder macht das die FormShell selber? + //! Fehler-Flag zurueckgeben und Aktionen abbrechen + + return; // Die FormShell sagt, es kann nicht umgeschaltet werden + } + } + + // nicht InputEnterHandler wegen Referenzeingabe ! + + ScDocument* pDoc = aViewData.GetDocument(); + pDoc->MakeTable( nTab ); + + USHORT nTabCount = pDoc->GetTableCount(); + USHORT nOldPos = nTab; + while (!pDoc->IsVisible(nTab)) // naechste sichtbare suchen + { + BOOL bUp = (nTab>=nOldPos); + if (bUp) + { + ++nTab; + if (nTab>=nTabCount) + { + nTab = nOldPos; + bUp = FALSE; + } + } + + if (!bUp) + { + if (nTab) + --nTab; + else + { + DBG_ERROR("keine sichtbare Tabelle"); + pDoc->SetVisible( 0, TRUE ); + } + } + } + + BOOL bRefMode = SC_MOD()->IsFormulaMode(); + if ( !bRefMode ) // Abfrage, damit RefMode bei Tabellenwechsel funktioniert + { + DoneBlockMode(); + aViewData.SetRefTabNo( nTab ); + } + + aViewData.SetTabNo( nTab ); + // UpdateShow noch vor SetCursor, damit UpdateAutoFillMark die richtigen + // Fenster findet (wird aus SetCursor gerufen) + UpdateShow(); + aViewData.ResetOldCursor(); + SetCursor( aViewData.GetCurX(), aViewData.GetCurY(), TRUE ); + + if ( bRefMode ) // evtl. EditView verstecken (nach aViewData.SetTabNo !) + { + for ( USHORT i=0; i<4; i++ ) + if ( pGridWin[i] ) + if ( pGridWin[i]->IsVisible() ) + pGridWin[i]->UpdateEditViewPos(); + } + + SfxBindings& rBindings = SFX_BINDINGS(); + ScMarkData& rMark = aViewData.GetMarkData(); + if (!rMark.GetTableSelect(nTab)) + { + rMark.SelectOneTable( nTab ); + + rBindings.Invalidate( FID_FILL_TAB ); + } + + TabChanged(); // DrawView + aViewData.GetViewShell()->WindowChanged(); // falls das aktive Fenster anders ist + aViewData.GetViewShell()->DisconnectAllClients(); // wichtig fuer Floating Frames + + // Fixierungen + + BOOL bResize = FALSE; + if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX ) + if (aViewData.UpdateFixX()) + bResize = TRUE; + if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX ) + if (aViewData.UpdateFixY()) + bResize = TRUE; + if (bResize) + RepeatResize(); + InvalidateSplit(); + + if ( aViewData.IsPagebreakMode() ) + UpdatePageBreakData(); //! asynchron ?? + + // #53551# Form-Layer muss den sichtbaren Ausschnitt der neuen Tabelle kennen + // dafuer muss hier schon der MapMode stimmen + for (USHORT i=0; i<4; i++) + if (pGridWin[i]) + pGridWin[i]->SetMapMode( pGridWin[i]->GetDrawMapMode() ); + SetNewVisArea(); + + PaintGrid(); + PaintTop(); + PaintLeft(); + PaintExtras(); + + DoResize( aBorderPos, aFrameSize ); + rBindings.Invalidate( SID_DELETE_PRINTAREA ); // Menue + rBindings.Invalidate( FID_DEL_MANUALBREAKS ); + rBindings.Invalidate( FID_RESET_PRINTZOOM ); + rBindings.Invalidate( SID_STATUS_DOCPOS ); // Statusbar + rBindings.Invalidate( SID_STATUS_PAGESTYLE ); // Statusbar + rBindings.Invalidate( SID_CURRENTTAB ); // Navigator + rBindings.Invalidate( SID_STYLE_FAMILY2 ); // Gestalter + rBindings.Invalidate( SID_STYLE_FAMILY4 ); // Gestalter + rBindings.Invalidate( SID_TABLES_COUNT ); + + ScModule* pScMod = SC_MOD(); + + if(pScMod->IsRefDialogOpen()) + { + USHORT nCurRefDlgId=pScMod->GetCurRefDlgId(); + SfxViewFrame* pViewFrm = aViewData.GetViewShell()->GetViewFrame(); + SfxChildWindow* pChildWnd = pViewFrm->GetChildWindow( nCurRefDlgId ); + if ( pChildWnd ) + { + ScAnyRefDlg* pRefDlg = (ScAnyRefDlg*)pChildWnd->GetWindow(); + pRefDlg->ViewShellChanged(NULL); + } + } + } +} + +// +// Paint-Funktionen - nur fuer diese View +// + +void ScTabView::MakeEditView( ScEditEngineDefaulter* pEngine, USHORT nCol, USHORT nRow ) +{ + DrawDeselectAll(); + + if (pDrawView) + DrawEnableAnim( FALSE ); + + for (USHORT i=0; i<4; i++) + if (pGridWin[i]) + if ( pGridWin[i]->IsVisible() && !aViewData.HasEditView((ScSplitPos)i) ) + { + ScHSplitPos eHWhich = WhichH( (ScSplitPos) i ); + ScVSplitPos eVWhich = WhichV( (ScSplitPos) i ); + USHORT nScrX = aViewData.GetPosX( eHWhich ); + USHORT nScrY = aViewData.GetPosY( eVWhich ); + + if ( nCol >= nScrX && nCol <= nScrX + aViewData.VisibleCellsX(eHWhich) + 1 && + nRow >= nScrY && nRow <= nScrY + aViewData.VisibleCellsY(eVWhich) + 1 ) + { + pGridWin[i]->HideCursor(); + + // MapMode nach HideCursor setzen + + pGridWin[i]->SetMapMode(aViewData.GetLogicMode()); + + aViewData.SetEditEngine( (ScSplitPos) i, pEngine, pGridWin[i], nCol, nRow ); + } + } +} + +void ScTabView::UpdateEditView() +{ + ScSplitPos eActive = aViewData.GetActivePart(); + for (USHORT i=0; i<4; i++) + if (aViewData.HasEditView( (ScSplitPos) i )) + { + EditView* pEditView = aViewData.GetEditView( (ScSplitPos) i ); + aViewData.SetEditEngine( (ScSplitPos) i, + (ScEditEngineDefaulter*) pEditView->GetEditEngine(), + pGridWin[i], GetViewData()->GetCurX(), GetViewData()->GetCurY() ); + if ( (ScSplitPos)i == eActive ) + pEditView->ShowCursor( FALSE ); + } +} + +void ScTabView::KillEditView( BOOL bNoPaint ) +{ + USHORT i; + USHORT nCol1 = aViewData.GetEditViewCol(); + USHORT nRow1 = aViewData.GetEditViewRow(); + USHORT nCol2 = aViewData.GetEditEndCol(); + USHORT nRow2 = aViewData.GetEditEndRow(); + BOOL bPaint[4]; + + BOOL bExtended = nRow1 != nRow2; // Col wird sowieso bis zum Ende gezeichnet + BOOL bAtCursor = nCol1 == aViewData.GetCurX() && + nRow1 == aViewData.GetCurY(); + for (i=0; i<4; i++) + bPaint[i] = aViewData.HasEditView( (ScSplitPos) i ); + aViewData.ResetEditView(); + for (i=0; i<4; i++) + if (pGridWin[i] && bPaint[i]) + if (pGridWin[i]->IsVisible()) + { + pGridWin[i]->ShowCursor(); + + if (bExtended || ( bAtCursor && !bNoPaint )) + pGridWin[i]->Draw( nCol1, nRow1, nCol2, nRow2 ); + else + pGridWin[i]->SetMapMode(pGridWin[i]->GetDrawMapMode()); + } + + if (pDrawView) + DrawEnableAnim( TRUE ); + + // GrabFocus immer dann, wenn diese View aktiv ist und + // die Eingabezeile den Focus hat + + BOOL bGrabFocus = FALSE; + if (aViewData.IsActive()) + { + ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl(); + if ( pInputHdl ) + { + ScInputWindow* pInputWin = pInputHdl->GetInputWindow(); + if (pInputWin && pInputWin->IsActive()) + bGrabFocus = TRUE; + } + } + + if (bGrabFocus) + { +// So soll es gemacht werden, damit der Sfx es mitbekommt, klappt aber nicht: +//! aViewData.GetViewShell()->GetViewFrame()->GetWindow().GrabFocus(); +// deshalb erstmal so: + GetActiveWin()->GrabFocus(); + } + + // Cursor-Abfrage erst nach GrabFocus + + for (i=0; i<4; i++) + if (pGridWin[i] && pGridWin[i]->IsVisible()) + { + Cursor* pCur = pGridWin[i]->GetCursor(); + if (pCur && pCur->IsVisible()) + pCur->Hide(); + } +} + +void ScTabView::UpdateFormulas() +{ + if ( aViewData.GetDocument()->IsAutoCalcShellDisabled() ) + return ; + + USHORT i; + for (i=0; i<4; i++) + if (pGridWin[i]) + if (pGridWin[i]->IsVisible()) + pGridWin[i]->UpdateFormulas(); + + if ( aViewData.IsPagebreakMode() ) + UpdatePageBreakData(); //! asynchron + + UpdateHeaderWidth(); +} + +// PaintCell - einzelne Zelle neu zeichnen + +void ScTabView::PaintCell( USHORT nCol, USHORT nRow, USHORT nTab ) +{ + if ( aViewData.GetTabNo() == nTab ) + { + USHORT i; + for (i=0; i<4; i++) + if (pGridWin[i]) + if (pGridWin[i]->IsVisible()) + pGridWin[i]->Draw( nCol, nRow, nCol, nRow ); + } +} + +// PaintArea -Block neu zeichnen + +void ScTabView::PaintArea( USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow, + ScUpdateMode eMode ) +{ + USHORT i; + USHORT nCol1; + USHORT nRow1; + USHORT nCol2; + USHORT nRow2; + + PutInOrder( nStartCol, nEndCol ); + PutInOrder( nStartRow, nEndRow ); + + for (i=0; i<4; i++) + if (pGridWin[i]) + if (pGridWin[i]->IsVisible()) + { + ScHSplitPos eHWhich = WhichH( (ScSplitPos) i ); + ScVSplitPos eVWhich = WhichV( (ScSplitPos) i ); + BOOL bOut = FALSE; + + nCol1 = nStartCol; + nRow1 = nStartRow; + nCol2 = nEndCol; + nRow2 = nEndRow; + + USHORT nScrX = aViewData.GetPosX( eHWhich ); + USHORT nScrY = aViewData.GetPosY( eVWhich ); + if (nCol1 < nScrX) nCol1 = nScrX; + if (nCol2 < nScrX) bOut = TRUE; // ausserhalb + if (nRow1 < nScrY) nRow1 = nScrY; + if (nRow2 < nScrY) bOut = TRUE; + + USHORT nLastX = nScrX + aViewData.VisibleCellsX( eHWhich ) + 1; + USHORT nLastY = nScrY + aViewData.VisibleCellsY( eVWhich ) + 1; + if (nCol1 > nLastX) bOut = TRUE; + if (nCol2 > nLastX) nCol2 = nLastX; + if (nRow1 > nLastY) bOut = TRUE; + if (nRow2 > nLastY) nRow2 = nLastY; + + if (!bOut) + { + if ( eMode == SC_UPDATE_CHANGED ) + pGridWin[i]->Draw( nCol1, nRow1, nCol2, nRow2, eMode ); + else // ALL oder MARKS + { + Point aStart = aViewData.GetScrPos( nCol1, nRow1, (ScSplitPos) i ); + Point aEnd = aViewData.GetScrPos( nCol2+1, nRow2+1, (ScSplitPos) i ); + if ( eMode == SC_UPDATE_ALL ) + aEnd.X() = pGridWin[i]->GetOutputSizePixel().Width(); + aEnd.X() -= 1; + aEnd.Y() -= 1; + + BOOL bShowChanges = TRUE; //! ... + if (bShowChanges) + { + aStart.X() -= 1; // auch Change-Markierung + aStart.Y() -= 1; + } + + BOOL bMarkClipped = aViewData.GetOptions().GetOption( VOPT_CLIPMARKS ); + if (bMarkClipped) + { + // dazu muesste ScColumn::IsEmptyBlock optimiert werden + // (auf Search() umstellen) + //!if ( nCol1 > 0 && !aViewData.GetDocument()->IsBlockEmpty( + //! aViewData.GetTabNo(), + //! 0, nRow1, nCol1-1, nRow2 ) ) + { + long nMarkPixel = (long)( SC_CLIPMARK_SIZE * aViewData.GetPPTX() ); + aStart.X() -= nMarkPixel; + if (!bShowChanges) + aStart.X() -= 1; // Zellgitter + } + } + + pGridWin[i]->Invalidate( pGridWin[i]->PixelToLogic( Rectangle( aStart,aEnd ) ) ); + } + } + } +} + +void ScTabView::PaintRangeFinder( long nNumber ) +{ + ScInputHandler* pHdl = SC_MOD()->GetInputHdl( aViewData.GetViewShell() ); + if (pHdl) + { + ScRangeFindList* pRangeFinder = pHdl->GetRangeFindList(); + if ( pRangeFinder && pRangeFinder->GetDocName() == aViewData.GetDocShell()->GetTitle() ) + { + BOOL bHide = pRangeFinder->IsHidden(); + + USHORT nTab = aViewData.GetTabNo(); + USHORT nCount = (USHORT)pRangeFinder->Count(); + for (USHORT i=0; i<nCount; i++) + if ( nNumber < 0 || nNumber == i ) + { + ScRangeFindData* pData = pRangeFinder->GetObject(i); + if (pData) + { + ScRange aRef = pData->aRef; + aRef.Justify(); // Justify fuer die Abfragen unten + + if ( aRef.aStart == aRef.aEnd ) //! Tab ignorieren? + aViewData.GetDocument()->ExtendMerge(aRef); + + if ( aRef.aStart.Tab() >= nTab && aRef.aEnd.Tab() <= nTab ) + { + USHORT nCol1 = aRef.aStart.Col(); + USHORT nRow1 = aRef.aStart.Row(); + USHORT nCol2 = aRef.aEnd.Col(); + USHORT nRow2 = aRef.aEnd.Row(); + if ( bHide ) + { + // wegnehmen -> Repaint + // SC_UPDATE_MARKS: Invalidate, nicht bis zum Zeilenende + + if ( nCol2 - nCol1 > 1 && nRow2 - nRow1 > 1 ) + { + // nur an den Raendern entlang + PaintArea( nCol1, nRow1, nCol2, nRow1, SC_UPDATE_MARKS ); + PaintArea( nCol1, nRow1+1, nCol1, nRow2-1, SC_UPDATE_MARKS ); + PaintArea( nCol2, nRow1+1, nCol2, nRow2-1, SC_UPDATE_MARKS ); + PaintArea( nCol1, nRow2, nCol2, nRow2, SC_UPDATE_MARKS ); + } + else // alles am Stueck + PaintArea( nCol1, nRow1, nCol2, nRow2, SC_UPDATE_MARKS ); + } + else + { + // neuen Rahmen zeichnen + + for (USHORT nWin=0; nWin<4; nWin++) + if (pGridWin[nWin] && pGridWin[nWin]->IsVisible()) + pGridWin[nWin]->DrawRefMark( nCol1, nRow1, nCol2, nRow2, + Color( ScRangeFindList::GetColorName( i ) ), + TRUE ); + } + } + } + } + } + } +} + +// fuer Chart-Daten-Markierung + +void ScTabView::AddHighlightRange( const ScRange& rRange, const Color& rColor ) +{ + if (!pHighlightRanges) + pHighlightRanges = new ScHighlightRanges; + pHighlightRanges->Insert( new ScHighlightEntry( rRange, rColor ) ); + //! auf doppelte testen?? + + USHORT nTab = aViewData.GetTabNo(); + if ( nTab >= rRange.aStart.Tab() && nTab <= rRange.aEnd.Tab() ) + PaintArea( rRange.aStart.Col(), rRange.aStart.Row(), + rRange.aEnd.Col(), rRange.aEnd.Row(), SC_UPDATE_MARKS ); +} + +void ScTabView::ClearHighlightRanges() +{ + if (pHighlightRanges) + { + ScHighlightRanges* pTemp = pHighlightRanges; + pHighlightRanges = NULL; // Repaint ohne Highlight + + USHORT nTab = aViewData.GetTabNo(); + ULONG nCount = pTemp->Count(); + for (ULONG i=0; i<nCount; i++) + { + ScHighlightEntry* pEntry = pTemp->GetObject( i ); + if (pEntry) + { + ScRange aRange = pEntry->aRef; + if ( nTab >= aRange.aStart.Tab() && nTab <= aRange.aEnd.Tab() ) + PaintArea( aRange.aStart.Col(), aRange.aStart.Row(), + aRange.aEnd.Col(), aRange.aEnd.Row(), SC_UPDATE_MARKS ); + } + } + delete pTemp; + } +} + +long ScTabView::DoChartSelection( ChartSelectionInfo &rInfo, const SchMemChart& rMemChart ) +{ + long nFlags = rInfo.nSelection; + if ( nFlags & CHART_SEL_QUERYSUPPORT ) + return nFlags & ( CHART_SEL_NONE | CHART_SEL_ALL | CHART_SEL_COL | + CHART_SEL_ROW | CHART_SEL_POINT | CHART_SEL_COLOR ); + + long nRet = 0; + ScChartArray aArr( aViewData.GetDocument(), rMemChart ); + if (aArr.IsValid()) + { + if ( nFlags & CHART_SEL_NONE ) + { + ClearHighlightRanges(); + nRet |= CHART_SEL_NONE; + } + + Color aSelColor( COL_LIGHTBLUE ); // Default + BOOL bManualColor = ( ( nFlags & CHART_SEL_COLOR ) != 0 ); + bManualColor = FALSE; //! Test !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + if ( bManualColor ) + { + aSelColor = rInfo.aSelectionColor; + nRet |= CHART_SEL_COLOR; + } + + if ( nFlags & CHART_SEL_ALL ) + { + ScRangeListRef xRanges = aArr.GetRangeList(); + if (xRanges.Is()) + { + USHORT nCount = xRanges->Count(); + USHORT i; + if (!bManualColor) + { + ScBackgroundCollector aColl( aViewData.GetDocument() ); + for (i=0; i<nCount; i++) + aColl.AddRange( *xRanges->GetObject(i) ); + aSelColor = aColl.GetHighlightColor(); + } + for (i=0; i<nCount; i++) + AddHighlightRange( *xRanges->GetObject(i), aSelColor ); + nRet |= CHART_SEL_ALL; + } + } + + if ( nFlags & ( CHART_SEL_COL | CHART_SEL_ROW | CHART_SEL_POINT ) ) + { + // irgendwelche Teile selektieren -> PositionMap holen + const ScChartPositionMap* pPosMap = aArr.GetPositionMap(); + if (pPosMap) + { + if ( nFlags & CHART_SEL_COL ) + { + ScRangeListRef xRanges = ((ScChartPositionMap*)pPosMap)->GetColRanges( rInfo.nCol ); + if (xRanges.Is()) + { + USHORT nCount = xRanges->Count(); + USHORT i; + if (!bManualColor) + { + ScBackgroundCollector aColl( aViewData.GetDocument() ); + for (i=0; i<nCount; i++) + aColl.AddRange( *xRanges->GetObject(i) ); + aSelColor = aColl.GetHighlightColor(); + } + for (i=0; i<nCount; i++) + AddHighlightRange( *xRanges->GetObject(i), aSelColor ); + nRet |= CHART_SEL_COL; + } + } + if ( nFlags & CHART_SEL_ROW ) + { + ScRangeListRef xRanges = ((ScChartPositionMap*)pPosMap)->GetRowRanges( rInfo.nRow ); + if (xRanges.Is()) + { + USHORT nCount = xRanges->Count(); + USHORT i; + if (!bManualColor) + { + ScBackgroundCollector aColl( aViewData.GetDocument() ); + for (i=0; i<nCount; i++) + aColl.AddRange( *xRanges->GetObject(i) ); + aSelColor = aColl.GetHighlightColor(); + } + for (i=0; i<nCount; i++) + AddHighlightRange( *xRanges->GetObject(i), aSelColor ); + nRet |= CHART_SEL_ROW; + } + } + if ( nFlags & CHART_SEL_POINT ) + { + const ScAddress* pPos = pPosMap->GetPosition( rInfo.nCol, rInfo.nRow ); + if (pPos) + { + if (!bManualColor) + { + ScBackgroundCollector aColl( aViewData.GetDocument() ); + aColl.AddRange( ScRange(*pPos) ); + aSelColor = aColl.GetHighlightColor(); + } + AddHighlightRange( ScRange(*pPos), aSelColor ); + nRet |= CHART_SEL_POINT; + } + } + } + } + } + + return nRet; +} + +// DrawDragRect - Drag&Drop-Rechteck zeichnen (XOR) + +void ScTabView::DrawDragRect( USHORT nStartX, USHORT nStartY, USHORT nEndX, USHORT nEndY, + ScSplitPos ePos ) +{ + if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX || aViewData.GetVSplitMode() == SC_SPLIT_FIX ) + { + for (USHORT i=0; i<4; i++) + if (pGridWin[i]) + if (pGridWin[i]->IsVisible()) + pGridWin[i]->DrawDragRect( nStartX, nStartY, nEndX, nEndY ); + } + else + pGridWin[ePos]->DrawDragRect( nStartX, nStartY, nEndX, nEndY ); +} + +// PaintGrid - Datenbereiche neu zeichnen + +void ScTabView::PaintGrid() +{ + USHORT i; + for (i=0; i<4; i++) + if (pGridWin[i]) + if (pGridWin[i]->IsVisible()) + pGridWin[i]->Invalidate(); +} + +// PaintTop - obere Kontrollelemente neu zeichnen + +void ScTabView::PaintTop() +{ + USHORT i; + for (i=0; i<2; i++) + { + if (pColBar[i]) + pColBar[i]->Invalidate(); + if (pColOutline[i]) + pColOutline[i]->Invalidate(); + } +} + +void ScTabView::CreateAnchorHandles(SdrHdlList& rHdl, const ScAddress& rAddress) +{ + UINT16 i; + + for(i=0; i<4; i++) + { + if(pGridWin[i]) + { + if(pGridWin[i]->IsVisible()) + { + pGridWin[i]->CreateAnchorHandle(rHdl, rAddress); + } + } + } +} + +void ScTabView::PaintTopCol( USHORT nCol ) +{ + PaintTopArea( nCol, nCol ); +} + +void ScTabView::PaintTopArea( USHORT nStartCol, USHORT nEndCol ) +{ + // Pixel-Position der linken Kante + + if ( nStartCol < aViewData.GetPosX(SC_SPLIT_LEFT) || + nStartCol < aViewData.GetPosX(SC_SPLIT_RIGHT) ) + aViewData.RecalcPixPos(); + + // Fixierung anpassen (UpdateFixX setzt HSplitPos neu) + + if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX && nStartCol < aViewData.GetFixPosX() ) + if (aViewData.UpdateFixX()) + RepeatResize(); + + // zeichnen + + if (nStartCol>0) + --nStartCol; //! allgemeiner ? + + for (USHORT i=0; i<2; i++) + { + ScHSplitPos eWhich = (ScHSplitPos) i; + if (pColBar[eWhich]) + { + Size aWinSize = pColBar[eWhich]->GetSizePixel(); + long nStartX = aViewData.GetScrPos( nStartCol, 0, eWhich ).X(); + long nEndX; + if (nEndCol >= MAXCOL) + nEndX = aWinSize.Width()-1; + else + nEndX = aViewData.GetScrPos( nEndCol+1, 0, eWhich ).X() - 1; + pColBar[eWhich]->Invalidate( + Rectangle( nStartX, 0, nEndX, aWinSize.Height()-1 ) ); + } + if (pColOutline[eWhich]) + pColOutline[eWhich]->Invalidate(); + } +} + + +// PaintLeft - linke Kontrollelemente neu zeichnen + +void ScTabView::PaintLeft() +{ + USHORT i; + for (i=0; i<2; i++) + { + if (pRowBar[i]) + pRowBar[i]->Invalidate(); + if (pRowOutline[i]) + pRowOutline[i]->Invalidate(); + } +} + +void ScTabView::PaintLeftRow( USHORT nRow ) +{ + PaintLeftArea( nRow, nRow ); +} + +void ScTabView::PaintLeftArea( USHORT nStartRow, USHORT nEndRow ) +{ + // Pixel-Position der oberen Kante + + if ( nStartRow < aViewData.GetPosY(SC_SPLIT_TOP) || + nStartRow < aViewData.GetPosY(SC_SPLIT_BOTTOM) ) + aViewData.RecalcPixPos(); + + // Fixierung anpassen (UpdateFixY setzt VSplitPos neu) + + if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX && nStartRow < aViewData.GetFixPosY() ) + if (aViewData.UpdateFixY()) + RepeatResize(); + + // zeichnen + + if (nStartRow>0) + --nStartRow; + + for (USHORT i=0; i<2; i++) + { + ScVSplitPos eWhich = (ScVSplitPos) i; + if (pRowBar[eWhich]) + { + Size aWinSize = pRowBar[eWhich]->GetSizePixel(); + long nStartY = aViewData.GetScrPos( 0, nStartRow, eWhich ).Y(); + long nEndY; + if (nEndRow >= MAXROW) + nEndY = aWinSize.Height()-1; + else + nEndY = aViewData.GetScrPos( 0, nEndRow+1, eWhich ).Y() - 1; + pRowBar[eWhich]->Invalidate( + Rectangle( 0, nStartY, aWinSize.Width()-1, nEndY ) ); + } + if (pRowOutline[eWhich]) + pRowOutline[eWhich]->Invalidate(); + } +} + +// InvertBlockMark - Block invertieren + +void ScTabView::InvertBlockMark(USHORT nBlockStartX, USHORT nBlockStartY, + USHORT nBlockEndX, USHORT nBlockEndY) +{ + if ( !aViewData.IsActive() ) + return; // invertiert wird nur auf aktiver View + + PutInOrder( nBlockStartX, nBlockEndX ); + PutInOrder( nBlockStartY, nBlockEndY ); + + ScMarkData& rMark = aViewData.GetMarkData(); + ScDocument* pDoc = aViewData.GetDocument(); + USHORT nTab = aViewData.GetTabNo(); + +#ifdef MAC + BOOL bSingle = TRUE; +#else + BOOL bSingle = rMark.IsMultiMarked(); +#endif + + BOOL bMerge = pDoc->HasAttrib( nBlockStartX, nBlockStartY, nTab, nBlockEndX, nBlockEndY, nTab, + HASATTR_MERGED | HASATTR_OVERLAPPED ); + + USHORT i; + if ( bMerge || bSingle ) + { + for (i=0; i<4; i++) + if (pGridWin[i]) + if (pGridWin[i]->IsVisible()) + pGridWin[i]->InvertSimple( nBlockStartX, nBlockStartY, nBlockEndX, nBlockEndY, + bMerge, bBlockNeg ); + } + else + { + for (i=0; i<4; i++) + if (pGridWin[i]) + if (pGridWin[i]->IsVisible()) + { + ScSplitPos ePos = (ScSplitPos) i; + Point aStartPoint = aViewData.GetScrPos( nBlockStartX, nBlockStartY, ePos ); + Point aEndPoint = aViewData.GetScrPos( nBlockEndX+1, nBlockEndY+1, ePos ); + aEndPoint.X() -= 1; + aEndPoint.Y() -= 1; + if ( aEndPoint.X() >= aStartPoint.X() && aEndPoint.Y() >= aStartPoint.Y() ) + { + MapMode aOld = pGridWin[ePos]->GetMapMode(); + pGridWin[ePos]->SetMapMode(MAP_PIXEL); + pGridWin[ePos]->Invert( Rectangle(aStartPoint,aEndPoint), INVERT_HIGHLIGHT ); + pGridWin[ePos]->SetMapMode(aOld); + pGridWin[ePos]->CheckInverted(); + } + } + } + + // + // wenn Controls betroffen, neu malen + // + + BOOL bHide = TRUE; // wird Teil der Markierung aufgehoben ? + if (rMark.IsMarked()) + { + ScRange aMarkRange; + rMark.GetMarkArea( aMarkRange ); + if ( aMarkRange.aStart.Col() <= nBlockStartX && aMarkRange.aEnd.Col() >= nBlockEndX && + aMarkRange.aStart.Row() <= nBlockStartY && aMarkRange.aEnd.Row() >= nBlockEndY ) + { + bHide = FALSE; // der ganze Bereich ist markiert + } + } + + Rectangle aMMRect = pDoc->GetMMRect(nBlockStartX,nBlockStartY,nBlockEndX,nBlockEndY, nTab); + BOOL bPaint = bHide && pDoc->HasControl( nTab, aMMRect ); + + if (bPaint) + { + for (i=0; i<4; i++) + if (pGridWin[i]) + if (pGridWin[i]->IsVisible()) + { + // MapMode muss logischer (1/100mm) sein !!! + pDoc->InvalidateControls( pGridWin[i], nTab, aMMRect ); + pGridWin[i]->Update(); + } + } +} + +BOOL ScTabView::PaintExtras() +{ + BOOL bRet = FALSE; + ScDocument* pDoc = aViewData.GetDocument(); + USHORT nTab = aViewData.GetTabNo(); + if (!pDoc->HasTable(nTab)) // Tabelle geloescht ? + { + USHORT nCount = pDoc->GetTableCount(); + aViewData.SetTabNo(nCount-1); + bRet = TRUE; + } + pTabControl->UpdateStatus(); // TRUE = active + return bRet; +} + +void ScTabView::ActivateView( BOOL bActivate, BOOL bFirst ) +{ + if ( bActivate == aViewData.IsActive() && !bFirst ) + { + // keine Assertion mehr - kommt vor, wenn vorher im Drag&Drop + // auf ein anderes Dokument umgeschaltet wurde + return; + } + + // wird nur bei MDI-(De)Activate gerufen + // aViewData.Activate hinten wegen Cursor-Show bei KillEditView + // Markierung nicht mehr loeschen - wenn an der ViewData Activate(FALSE) gesetzt ist, + // wird die Markierung nicht ausgegeben + + if (!bActivate) + { + ScModule* pScMod = SC_MOD(); + BOOL bRefMode = pScMod->IsFormulaMode(); + + // Referenzeingabe nicht abbrechen, um Referenzen auf + // andere Dokumente zuzulassen + + if (!bRefMode) + { + pScMod->InputEnterHandler(); + } + } + pTabControl->ActivateView(bActivate); + PaintExtras(); + + aViewData.Activate(bActivate); + + PaintBlock(FALSE); // Repaint, Markierung je nach Active-Status + + if (!bActivate) + HideAllCursors(); // Cursor + else if (!bFirst) + ShowAllCursors(); + + if (pDrawView) + DrawShowMarkHdl(bActivate); // Drawing-Markierung + + if (bActivate) + { + if ( bFirst ) + { + ScSplitPos eWin = aViewData.GetActivePart(); + DBG_ASSERT( pGridWin[eWin], "rottes Dokument, nicht alle SplitPos in GridWin" ); + if ( !pGridWin[eWin] ) + { + eWin = SC_SPLIT_BOTTOMLEFT; + if ( !pGridWin[eWin] ) + { + short i; + for ( i=0; i<4; i++ ) + { + if ( pGridWin[i] ) + { + eWin = (ScSplitPos) i; + break; // for + } + } + DBG_ASSERT( i<4, "und BUMM" ); + } + aViewData.SetActivePart( eWin ); + } + } + // hier nicht mehr selber GrabFocus rufen! + // Wenn das Doc bearbeitet wird, ruft der Sfx selber GrabFocus am Fenster der Shell. + // Wenn es z.B. ein Mailbody ist, darf es den Focus nicht bekommen (Bug #43638#) + } + else + pGridWin[aViewData.GetActivePart()]->ClickExtern(); +} + +void ScTabView::ActivatePart( ScSplitPos eWhich ) +{ + ScSplitPos eOld = aViewData.GetActivePart(); + if ( eOld != eWhich ) + { + bInActivatePart = TRUE; + + // #40565# die HasEditView Abfrage bei SetCursor geht sonst schief + if ( aViewData.HasEditView(eOld) && !SC_MOD()->IsFormulaMode() ) + UpdateInputLine(); + + ScHSplitPos eOldH = WhichH(eOld); + ScVSplitPos eOldV = WhichV(eOld); + ScHSplitPos eNewH = WhichH(eWhich); + ScVSplitPos eNewV = WhichV(eWhich); + BOOL bTopCap = pColBar[eOldH] && pColBar[eOldH]->IsMouseCaptured(); + BOOL bLeftCap = pRowBar[eOldV] && pRowBar[eOldV]->IsMouseCaptured(); + + BOOL bFocus = pGridWin[eOld]->HasFocus(); + BOOL bCapture = pGridWin[eOld]->IsMouseCaptured(); + if (bCapture) + pGridWin[eOld]->ReleaseMouse(); + pGridWin[eOld]->ClickExtern(); + pGridWin[eOld]->HideCursor(); + pGridWin[eWhich]->HideCursor(); + aViewData.SetActivePart( eWhich ); + + ScTabViewShell* pShell = aViewData.GetViewShell(); + pShell->WindowChanged(); + + pSelEngine->SetWindow(pGridWin[eWhich]); + pSelEngine->SetWhich(eWhich); + pSelEngine->SetVisibleArea( Rectangle(Point(), pGridWin[eWhich]->GetOutputSizePixel()) ); + + pGridWin[eOld]->MoveMouseStatus(*pGridWin[eWhich]); + + if ( bCapture || pGridWin[eWhich]->IsMouseCaptured() ) + { + // Tracking statt CaptureMouse, damit sauber abgebrochen werden kann + // (SelectionEngine ruft CaptureMouse beim SetWindow) + //! Irgendwann sollte die SelectionEngine selber StartTracking rufen!?! + pGridWin[eWhich]->ReleaseMouse(); + pGridWin[eWhich]->StartTracking(); + } + + if ( bTopCap && pColBar[eNewH] ) + { + pColBar[eOldH]->SetIgnoreMove(TRUE); + pColBar[eNewH]->SetIgnoreMove(FALSE); + pHdrSelEng->SetWindow( pColBar[eNewH] ); + long nWidth = pColBar[eNewH]->GetOutputSizePixel().Width(); + pHdrSelEng->SetVisibleArea( Rectangle( 0, LONG_MIN, nWidth-1, LONG_MAX ) ); + pColBar[eNewH]->CaptureMouse(); + } + if ( bLeftCap && pRowBar[eNewV] ) + { + pRowBar[eOldV]->SetIgnoreMove(TRUE); + pRowBar[eNewV]->SetIgnoreMove(FALSE); + pHdrSelEng->SetWindow( pRowBar[eNewV] ); + long nHeight = pRowBar[eNewV]->GetOutputSizePixel().Height(); + pHdrSelEng->SetVisibleArea( Rectangle( LONG_MIN, 0, LONG_MAX, nHeight-1 ) ); + pRowBar[eNewV]->CaptureMouse(); + } + aHdrFunc.SetWhich(eWhich); + + pGridWin[eOld]->ShowCursor(); + pGridWin[eWhich]->ShowCursor(); + + aViewData.GetViewShell()->SetWindow( pGridWin[eWhich] ); + if ( bFocus && !aViewData.IsAnyFillMode() && !SC_MOD()->IsFormulaMode() ) + { + // GrabFocus nur, wenn vorher das andere GridWindow den Focus hatte + // (z.B. wegen Suchen & Ersetzen) +//! aViewData.GetViewShell()->GetViewFrame()->GetWindow().GrabFocus(); + pGridWin[eWhich]->GrabFocus(); + } + + bInActivatePart = FALSE; + } +} + +void ScTabView::HideListBox() +{ + for (USHORT i=0; i<4; i++) + if (pGridWin[i]) + pGridWin[i]->ClickExtern(); +} + + +// GetGridWidth - Breite eines Ausgabebereichs (fuer ViewData) + +long ScTabView::GetGridWidth( ScHSplitPos eWhich ) +{ + ScSplitPos eGridWhich = ( eWhich == SC_SPLIT_LEFT ) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT; + if (pGridWin[eGridWhich]) + return pGridWin[eGridWhich]->GetSizePixel().Width(); + else + return 0; +} + +// GetGridHeight - Hoehe eines Ausgabebereichs (fuer ViewData) + +long ScTabView::GetGridHeight( ScVSplitPos eWhich ) +{ + ScSplitPos eGridWhich = ( eWhich == SC_SPLIT_TOP ) ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT; + if (pGridWin[eGridWhich]) + return pGridWin[eGridWhich]->GetSizePixel().Height(); + else + return 0; +} + +void ScTabView::UpdateInputLine() +{ + SC_MOD()->InputEnterHandler(); +} + +void ScTabView::ZoomChanged() +{ + ScInputHandler* pHdl = SC_MOD()->GetInputHdl(aViewData.GetViewShell()); + if (pHdl) + pHdl->SetRefScale( aViewData.GetZoomX(), aViewData.GetZoomY() ); + + UpdateFixPos(); + + UpdateScrollBars(); + + // VisArea... + ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()]; + if (pWin) + { + pWin->SetMapMode( pWin->GetDrawMapMode() ); // mit neuem Zoom + SetNewVisArea(); // benutzt den gesetzten MapMode + } + + InterpretVisible(); // #69343# have everything calculated before painting + + SfxBindings& rBindings = SFX_BINDINGS(); + rBindings.Invalidate( SID_ATTR_ZOOM ); +} + +void ScTabView::CheckNeedsRepaint() +{ + USHORT i; + for (i=0; i<4; i++) + if ( pGridWin[i] && pGridWin[i]->IsVisible() ) + pGridWin[i]->CheckNeedsRepaint(); +} + + + + + diff --git a/sc/source/ui/view/tabview4.cxx b/sc/source/ui/view/tabview4.cxx new file mode 100644 index 000000000000..50bdf0650bee --- /dev/null +++ b/sc/source/ui/view/tabview4.cxx @@ -0,0 +1,597 @@ +/************************************************************************* + * + * $RCSfile: tabview4.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +#define _MACRODLG_HXX +#define _BIGINT_HXX +#define _SVCONTNR_HXX +#define BASIC_NODIALOGS +#define _SFXMNUITEM_HXX +#define _SVDXOUT_HXX +#define _SVDATTR_HXX +#define _SFXMNUITEM_HXX +#define _DLGCFG_HXX +#define _SFXMNUMGR_HXX +#define _SFXBASIC_HXX +#define _MODALDLG_HXX +#define _SFX_TEMPLDLG_HXX +#define _SFXSTBMGR_HXX +#define _SFXTBXMGR_HXX +#define _BASE_DLGS_HXX +#define _SFXIMGMGR_HXX +#define _SFXMNUMGR_HXX +#define _SFXSTBITEM_HXX +#define _SFXTBXCTRL_HXX +#define _PASSWD_HXX +//#define _SFXFILEDLG_HXX +//#define _SFXREQUEST_HXX +#define _SFXOBJFACE_HXX + +// INCLUDE --------------------------------------------------------------- + +#include <vcl/help.hxx> + +#include "tabview.hxx" +#include "document.hxx" +#include "docsh.hxx" +#include "scmod.hxx" +#include "gridwin.hxx" +#include "globstr.hrc" +#include "cell.hxx" +#include "dociter.hxx" + +extern USHORT nScFillModeMouseModifier; // global.cxx + +// STATIC DATA ----------------------------------------------------------- + +//================================================================== + +// +// --- Referenz-Eingabe / Fill-Cursor +// + +void ScTabView::HideTip() +{ + if ( nTipVisible ) + { + Help::HideTip( nTipVisible ); + nTipVisible = 0; + } +} + +void ScTabView::ShowRefTip() +{ + BOOL bDone = FALSE; + if ( aViewData.GetRefType() == SC_REFTYPE_REF && Help::IsQuickHelpEnabled() ) + { + USHORT nStartX = aViewData.GetRefStartX(); + USHORT nStartY = aViewData.GetRefStartY(); + USHORT nEndX = aViewData.GetRefEndX(); + USHORT nEndY = aViewData.GetRefEndY(); + if ( nEndX != nStartX || nEndY != nStartY ) // nicht fuer einzelne Zelle + { + BOOL bLeft = ( nEndX < nStartX ); + BOOL bTop = ( nEndY < nStartY ); + PutInOrder( nStartX, nEndX ); + PutInOrder( nStartY, nEndY ); + USHORT nCols = nEndX+1-nStartX; + USHORT nRows = nEndY+1-nStartY; + + String aHelp = ScGlobal::GetRscString( STR_QUICKHELP_REF ); + aHelp.SearchAndReplace( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("%1")), + String::CreateFromInt32(nRows) ); + aHelp.SearchAndReplace( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("%2")), + String::CreateFromInt32(nCols) ); + + ScSplitPos eWhich = aViewData.GetActivePart(); + Window* pWin = pGridWin[eWhich]; + if ( pWin ) + { + Point aStart = aViewData.GetScrPos( nStartX, nStartY, eWhich ); + Point aEnd = aViewData.GetScrPos( nEndX+1, nEndY+1, eWhich ); + + Point aPos( bLeft ? aStart.X() : ( aEnd.X() + 3 ), + bTop ? aStart.Y() : ( aEnd.Y() + 3 ) ); + USHORT nFlags = ( bLeft ? QUICKHELP_RIGHT : QUICKHELP_LEFT ) | + ( bTop ? QUICKHELP_BOTTOM : QUICKHELP_TOP ); + + // nicht ueber die editierte Formel + if ( !bTop && aViewData.HasEditView( eWhich ) && + nEndY+1 == aViewData.GetEditViewRow() ) + { + // dann an der oberen Kante der editierten Zelle ausrichten + aPos.Y() -= 2; // die 3 von oben + nFlags = ( nFlags & ~QUICKHELP_TOP ) | QUICKHELP_BOTTOM; + } + + Rectangle aRect( pWin->OutputToScreenPixel( aPos ), Size(1,1) ); + + //! Test, ob geaendert ?? + + HideTip(); + nTipVisible = Help::ShowTip( pWin, aRect, aHelp, nFlags ); + bDone = TRUE; + } + } + } + + if (!bDone) + HideTip(); +} + +void ScTabView::StopRefMode() +{ + // SC_FOLLOW_NONE: nur aktiven Part umschalten + // auch ohne IsRefMode, fuer RangeFinder-Verschieberei + AlignToCursor( aViewData.GetCurX(), aViewData.GetCurY(), SC_FOLLOW_NONE ); + + if (aViewData.IsRefMode()) + { + aViewData.SetRefMode( FALSE, SC_REFTYPE_NONE ); + + HideTip(); + + if ( aViewData.GetTabNo() >= aViewData.GetRefStartZ() && + aViewData.GetTabNo() <= aViewData.GetRefEndZ() ) + { + ScDocument* pDoc = aViewData.GetDocument(); + USHORT nStartX = aViewData.GetRefStartX(); + USHORT nStartY = aViewData.GetRefStartY(); + USHORT nEndX = aViewData.GetRefEndX(); + USHORT nEndY = aViewData.GetRefEndY(); + if ( nStartX == nEndX && nStartY == nEndY ) + pDoc->ExtendMerge( nStartX, nStartY, nEndX, nEndY, aViewData.GetTabNo() ); + + PaintArea( nStartX,nStartY,nEndX,nEndY, SC_UPDATE_MARKS ); + } + + pSelEngine->Reset(); + pSelEngine->SetAddMode( FALSE ); //! sollte das nicht bei Reset passieren? + + ScSplitPos eOld = pSelEngine->GetWhich(); + ScSplitPos eNew = aViewData.GetActivePart(); + if ( eNew != eOld ) + { + pSelEngine->SetWindow( pGridWin[ eNew ] ); + pSelEngine->SetWhich( eNew ); + pSelEngine->SetVisibleArea( Rectangle(Point(), + pGridWin[eNew]->GetOutputSizePixel()) ); + pGridWin[eOld]->MoveMouseStatus(*pGridWin[eNew]); + } + } +} + +void ScTabView::DoneRefMode( BOOL bContinue ) +{ + ScDocument* pDoc = aViewData.GetDocument(); + if ( aViewData.GetRefType() == SC_REFTYPE_REF && bContinue ) + SC_MOD()->AddRefEntry(); + + BOOL bWasRef = aViewData.IsRefMode(); + aViewData.SetRefMode( FALSE, SC_REFTYPE_NONE ); + + HideTip(); + + // Paint: + if ( bWasRef && aViewData.GetTabNo() >= aViewData.GetRefStartZ() && + aViewData.GetTabNo() <= aViewData.GetRefEndZ() ) + { + USHORT nStartX = aViewData.GetRefStartX(); + USHORT nStartY = aViewData.GetRefStartY(); + USHORT nEndX = aViewData.GetRefEndX(); + USHORT nEndY = aViewData.GetRefEndY(); + if ( nStartX == nEndX && nStartY == nEndY ) + pDoc->ExtendMerge( nStartX, nStartY, nEndX, nEndY, aViewData.GetTabNo() ); + + PaintArea( nStartX,nStartY,nEndX,nEndY, SC_UPDATE_MARKS ); + } +} + +void ScTabView::UpdateRef( USHORT nCurX, USHORT nCurY, USHORT nCurZ ) +{ + ScDocument* pDoc = aViewData.GetDocument(); + + if (!aViewData.IsRefMode()) + { + // Das kommt vor, wenn bei einem Referenz-Dialog als erstes mit Control in die + // die Tabelle geklickt wird. Dann die neue Referenz an den alten Inhalt anhaengen: + + ScModule* pScMod = SC_MOD(); + if (pScMod->IsFormulaMode()) + pScMod->AddRefEntry(); + + InitRefMode( nCurX, nCurY, nCurZ, SC_REFTYPE_REF ); + } + + if ( nCurX != aViewData.GetRefEndX() || nCurY != aViewData.GetRefEndY() || + nCurZ != aViewData.GetRefEndZ() ) + { + ScMarkData& rMark = aViewData.GetMarkData(); + USHORT nTab = aViewData.GetTabNo(); + + USHORT nStartX = aViewData.GetRefStartX(); + USHORT nStartY = aViewData.GetRefStartY(); + USHORT nEndX = aViewData.GetRefEndX(); + USHORT nEndY = aViewData.GetRefEndY(); + if ( nStartX == nEndX && nStartY == nEndY ) + pDoc->ExtendMerge( nStartX, nStartY, nEndX, nEndY, nTab ); + ScUpdateRect aRect( nStartX, nStartY, nEndX, nEndY ); + + aViewData.SetRefEnd( nCurX, nCurY, nCurZ ); + + nStartX = aViewData.GetRefStartX(); + nStartY = aViewData.GetRefStartY(); + nEndX = aViewData.GetRefEndX(); + nEndY = aViewData.GetRefEndY(); + if ( nStartX == nEndX && nStartY == nEndY ) + pDoc->ExtendMerge( nStartX, nStartY, nEndX, nEndY, nTab ); + aRect.SetNew( nStartX, nStartY, nEndX, nEndY ); + + ScRefType eType = aViewData.GetRefType(); + if ( eType == SC_REFTYPE_REF ) + { + ScRange aRef( + aViewData.GetRefStartX(), aViewData.GetRefStartY(), aViewData.GetRefStartZ(), + aViewData.GetRefEndX(), aViewData.GetRefEndY(), aViewData.GetRefEndZ() ); + SC_MOD()->SetReference( aRef, pDoc, &rMark ); + ShowRefTip(); + } + else if ( eType == SC_REFTYPE_EMBED_LT || eType == SC_REFTYPE_EMBED_RB ) + { + PutInOrder(nStartX,nEndX); + PutInOrder(nStartY,nEndY); + pDoc->SetEmbedded( ScTripel(nStartX,nStartY,nTab), ScTripel(nEndX,nEndY,nTab) ); + ScDocShell* pDocSh = aViewData.GetDocShell(); + pDocSh->UpdateOle( &aViewData, TRUE ); + pDocSh->SetDocumentModified(); + } + + USHORT nPaintStartX; + USHORT nPaintStartY; + USHORT nPaintEndX; + USHORT nPaintEndY; + if (aRect.GetDiff( nPaintStartX, nPaintStartY, nPaintEndX, nPaintEndY )) + PaintArea( nPaintStartX, nPaintStartY, nPaintEndX, nPaintEndY, SC_UPDATE_MARKS ); + } + + // Tip-Hilfe fuer Auto-Fill + + if ( aViewData.GetRefType() == SC_REFTYPE_FILL && Help::IsQuickHelpEnabled() ) + { + String aHelpStr; + ScRange aMarkRange; + aViewData.GetSimpleArea( aMarkRange ); + USHORT nEndX = aViewData.GetRefEndX(); + USHORT nEndY = aViewData.GetRefEndY(); + ScRange aDelRange; + if ( aViewData.GetFillMode() == SC_FILL_MATRIX && !(nScFillModeMouseModifier & KEY_MOD1) ) + { + aHelpStr = ScGlobal::GetRscString( STR_TIP_RESIZEMATRIX ); + USHORT nCols = nEndX + 1 - aViewData.GetRefStartX(); // Reihenfolge ist richtig + USHORT nRows = nEndY + 1 - aViewData.GetRefStartY(); + aHelpStr.SearchAndReplace( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("%1")), + String::CreateFromInt32(nRows) ); + aHelpStr.SearchAndReplace( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("%2")), + String::CreateFromInt32(nCols) ); + } + else if ( aViewData.GetDelMark( aDelRange ) ) + aHelpStr = ScGlobal::GetRscString( STR_QUICKHELP_DELETE ); + else if ( nEndX != aMarkRange.aEnd.Col() || nEndY != aMarkRange.aEnd.Row() ) + aHelpStr = pDoc->GetAutoFillPreview( aMarkRange, nEndX, nEndY ); + + // je nach Richtung die obere oder untere Ecke: + USHORT nAddX = ( nEndX >= aMarkRange.aEnd.Col() ) ? 1 : 0; + USHORT nAddY = ( nEndY >= aMarkRange.aEnd.Row() ) ? 1 : 0; + Point aPos = aViewData.GetScrPos( nEndX+nAddX, nEndY+nAddY, aViewData.GetActivePart() ); + aPos.X() += 8; + aPos.Y() += 4; + Window* pWin = GetActiveWin(); + if ( pWin ) + aPos = pWin->OutputToScreenPixel( aPos ); + Rectangle aRect( aPos, aPos ); + USHORT nAlign = QUICKHELP_LEFT|QUICKHELP_TOP; + Help::ShowQuickHelp(pWin, aRect, aHelpStr, nAlign); + } +} + +void ScTabView::InitRefMode( USHORT nCurX, USHORT nCurY, USHORT nCurZ, ScRefType eType, BOOL bPaint ) +{ + ScDocument* pDoc = aViewData.GetDocument(); + ScMarkData& rMark = aViewData.GetMarkData(); + if (!aViewData.IsRefMode()) + { + aViewData.SetRefMode( TRUE, eType ); + aViewData.SetRefStart( nCurX, nCurY, nCurZ ); + aViewData.SetRefEnd( nCurX, nCurY, nCurZ ); + + if (nCurZ == aViewData.GetTabNo() && bPaint) + { + USHORT nStartX = nCurX; + USHORT nStartY = nCurY; + USHORT nEndX = nCurX; + USHORT nEndY = nCurY; + pDoc->ExtendMerge( nStartX, nStartY, nEndX, nEndY, aViewData.GetTabNo() ); + + //! nur Markierung ueber Inhalte zeichnen! + PaintArea( nStartX,nStartY,nEndX,nEndY, SC_UPDATE_MARKS ); + + // SetReference ohne Merge-Anpassung + ScRange aRef( nCurX,nCurY,nCurZ, nCurX,nCurY,nCurZ ); + SC_MOD()->SetReference( aRef, pDoc, &rMark ); + } + } +} + +void ScTabView::EndSelection() +{ + ScModule* pScMod = SC_MOD(); + BOOL bRefMode = pScMod->IsFormulaMode(); + if ( bRefMode ) + pScMod->EndReference(); +} + +// UpdateScrollBars - sichtbaren Bereich und Scrollweite der Scrollbars einstellen + +long lcl_UpdateBar( ScrollBar& rScroll, USHORT nSize ) // Size = (komplette) Zellen +{ + long nOldPos; + long nNewPos; + + nOldPos = rScroll.GetThumbPos(); + rScroll.SetPageSize( nSize ); + nNewPos = rScroll.GetThumbPos(); +#ifndef UNX + rScroll.SetPageSize( 1 ); // immer moeglich ! +#endif + + return nNewPos - nOldPos; +} + +void lcl_SetScrollRange( ScrollBar& rBar, USHORT nDocEnd, USHORT nPos, USHORT nVis, + USHORT nMax, USHORT nStart ) +{ + ++nVis; + ++nMax; // fuer teilweise sichtbare Zellen + USHORT nEnd = Max(nDocEnd, (USHORT)(nPos+nVis)) + nVis; + if (nEnd > nMax) + nEnd = nMax; + + rBar.SetRangeMax( nEnd - nStart ); // RangeMin muss selber verwaltet werden +} + +void ScTabView::UpdateScrollBars() +{ + long nDiff; + BOOL bTop = ( aViewData.GetVSplitMode() != SC_SPLIT_NONE ); + BOOL bRight = ( aViewData.GetHSplitMode() != SC_SPLIT_NONE ); + ScDocument* pDoc = aViewData.GetDocument(); + USHORT nTab = aViewData.GetTabNo(); + USHORT nUsedX; + USHORT nUsedY; + pDoc->GetTableArea( nTab, nUsedX, nUsedY ); //! cachen !!!!!!!!!!!!!!! + + USHORT nVisXL = 0; + USHORT nVisXR = 0; + USHORT nVisYB = 0; + USHORT nVisYT = 0; + + USHORT nStartX = 0; + USHORT nStartY = 0; + if (aViewData.GetHSplitMode()==SC_SPLIT_FIX) + nStartX = aViewData.GetFixPosX(); + if (aViewData.GetVSplitMode()==SC_SPLIT_FIX) + nStartY = aViewData.GetFixPosY(); + + nVisXL = aViewData.VisibleCellsX( SC_SPLIT_LEFT ); + lcl_SetScrollRange( aHScrollLeft, nUsedX, aViewData.GetPosX(SC_SPLIT_LEFT), nVisXL, + MAXCOL, 0 ); + aHScrollLeft.SetVisibleSize( nVisXL ); + aHScrollLeft.SetThumbPos( aViewData.GetPosX( SC_SPLIT_LEFT ) ); + + nVisYB = aViewData.VisibleCellsY( SC_SPLIT_BOTTOM ); + lcl_SetScrollRange( aVScrollBottom, nUsedY, aViewData.GetPosY(SC_SPLIT_BOTTOM), nVisYB, + MAXROW, nStartY ); + aVScrollBottom.SetVisibleSize( nVisYB ); + aVScrollBottom.SetThumbPos( aViewData.GetPosY( SC_SPLIT_BOTTOM ) - nStartY ); + + if (bRight) + { + nVisXR = aViewData.VisibleCellsX( SC_SPLIT_RIGHT ); + lcl_SetScrollRange( aHScrollRight, nUsedX, aViewData.GetPosX(SC_SPLIT_RIGHT), nVisXR, + MAXCOL, nStartX ); + aHScrollRight.SetVisibleSize( nVisXR ); + aHScrollRight.SetThumbPos( aViewData.GetPosX( SC_SPLIT_RIGHT ) - nStartX ); + } + + if (bTop) + { + nVisYT = aViewData.VisibleCellsY( SC_SPLIT_TOP ); + lcl_SetScrollRange( aVScrollTop, nUsedY, aViewData.GetPosY(SC_SPLIT_TOP), nVisYT, + MAXROW, 0 ); + aVScrollTop.SetVisibleSize( nVisYT ); + aVScrollTop.SetThumbPos( aViewData.GetPosY( SC_SPLIT_TOP ) ); + } + + // Bereich testen + + nDiff = lcl_UpdateBar( aHScrollLeft, nVisXL ); + if (nDiff) ScrollX( nDiff, SC_SPLIT_LEFT ); + if (bRight) + { + nDiff = lcl_UpdateBar( aHScrollRight, nVisXR ); + if (nDiff) ScrollX( nDiff, SC_SPLIT_RIGHT ); + } + + nDiff = lcl_UpdateBar( aVScrollBottom, nVisYB ); + if (nDiff) ScrollY( nDiff, SC_SPLIT_BOTTOM ); + if (bTop) + { + nDiff = lcl_UpdateBar( aVScrollTop, nVisYT ); + if (nDiff) ScrollY( nDiff, SC_SPLIT_TOP ); + } + + // set visible area for online spelling + + if ( aViewData.IsActive() ) + { + ScSplitPos eActive = aViewData.GetActivePart(); + ScHSplitPos eHWhich = WhichH( eActive ); + ScVSplitPos eVWhich = WhichV( eActive ); + USHORT nPosX = aViewData.GetPosX(eHWhich); + USHORT nPosY = aViewData.GetPosY(eVWhich); + USHORT nEndX = nPosX + ( ( eHWhich == SC_SPLIT_LEFT ) ? nVisXL : nVisXR ); + USHORT nEndY = nPosY + ( ( eVWhich == SC_SPLIT_TOP ) ? nVisYT : nVisYB ); + if ( nEndX > MAXCOL ) nEndX = MAXCOL; + if ( nEndY > MAXROW ) nEndY = MAXROW; + ScRange aVisible( nPosX, nPosY, nTab, nEndX, nEndY, nTab ); + if ( pDoc->SetVisibleSpellRange( aVisible ) ) + SC_MOD()->AnythingChanged(); // if visible area has changed + } +} + +#ifndef HDR_SLIDERSIZE +#define HDR_SLIDERSIZE 2 +#endif + +void ScTabView::InvertHorizontal( ScVSplitPos eWhich, long nDragPos ) +{ + for (USHORT i=0; i<4; i++) + if (WhichV((ScSplitPos)i)==eWhich) + { + ScGridWindow* pWin = pGridWin[i]; + if (pWin) + { + Rectangle aRect( 0,nDragPos, pWin->GetOutputSizePixel().Width()-1,nDragPos+HDR_SLIDERSIZE-1 ); + pWin->Update(); + pWin->DoInvertRect( aRect ); // Pixel + } + } +} + +void ScTabView::InvertVertical( ScHSplitPos eWhich, long nDragPos ) +{ + for (USHORT i=0; i<4; i++) + if (WhichH((ScSplitPos)i)==eWhich) + { + ScGridWindow* pWin = pGridWin[i]; + if (pWin) + { + Rectangle aRect( nDragPos,0, nDragPos+HDR_SLIDERSIZE-1,pWin->GetOutputSizePixel().Height()-1 ); + pWin->Update(); + pWin->DoInvertRect( aRect ); // Pixel + } + } +} + +//================================================================== + +void ScTabView::InterpretVisible() +{ + // make sure all visible cells are interpreted, + // so the next paint will not execute a macro function + + ScDocument* pDoc = aViewData.GetDocument(); + if ( !pDoc->GetAutoCalc() ) + return; + + USHORT nTab = aViewData.GetTabNo(); + for (USHORT i=0; i<4; i++) + { + // rely on gridwin pointers to find used panes + // no IsVisible test in case the whole view is not yet shown + + if (pGridWin[i]) + { + ScHSplitPos eHWhich = WhichH( ScSplitPos(i) ); + ScVSplitPos eVWhich = WhichV( ScSplitPos(i) ); + + USHORT nX1 = aViewData.GetPosX( eHWhich ); + USHORT nY1 = aViewData.GetPosY( eVWhich ); + USHORT nX2 = nX1 + aViewData.VisibleCellsX( eHWhich ); + USHORT nY2 = nY1 + aViewData.VisibleCellsY( eVWhich ); + + if (nX2 > MAXCOL) nX2 = MAXCOL; + if (nY2 > MAXROW) nY2 = MAXROW; + + ScCellIterator aIter( pDoc, nX1, nY1, nTab, nX2, nY2, nTab ); + ScBaseCell* pCell = aIter.GetFirst(); + while ( pCell ) + { + if ( pCell->GetCellType() == CELLTYPE_FORMULA && ((ScFormulaCell*)pCell)->GetDirty() ) + ((ScFormulaCell*)pCell)->Interpret(); + + pCell = aIter.GetNext(); + } + } + } +} + + + + + diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx new file mode 100644 index 000000000000..6eea7194573d --- /dev/null +++ b/sc/source/ui/view/tabview5.cxx @@ -0,0 +1,891 @@ +/************************************************************************* + * + * $RCSfile: tabview5.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +#ifndef OS2 +#define _MACRODLG_HXX +#define _BIGINT_HXX +#define _SVCONTNR_HXX +#define BASIC_NODIALOGS +#define _SFXMNUITEM_HXX +#define _SFXMNUITEM_HXX +#define _DLGCFG_HXX +#define _SFXMNUMGR_HXX +#define _SFXBASIC_HXX +#define _MODALDLG_HXX +#define _SFX_TEMPLDLG_HXX +#define _SFXSTBMGR_HXX +#define _SFXTBXMGR_HXX +#define _BASE_DLGS_HXX +#define _SFXIMGMGR_HXX +#define _SFXMNUMGR_HXX +#define _SFXSTBITEM_HXX +#define _SFXTBXCTRL_HXX +#define _PASSWD_HXX +//#define _SFXFILEDLG_HXX +//#define _SFXREQUEST_HXX +#define _SFXOBJFACE_HXX + +// TOOLS +#define _BIGINT_HXX +#define _SFXMULTISEL_HXX +#define _STACK_HXX +#define _QUEUE_HXX +#define _DYNARR_HXX +#define _TREELIST_HXX +#define _CACHESTR_HXX + +//SV +//#define _CLIP_HXX +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _FONTDLG_HXX +#define _PRVWIN_HXX +//#define _COLOR_HXX +//#define _PAL_HXX +//#define _BITMAP_HXX +//#define _GDIOBJ_HXX +//#define _POINTR_HXX +//#define _ICON_HXX +//#define _IMAGE_HXX +//#define _KEYCOD_HXX +//#define _EVENT_HXX +#define _HELP_HXX +//#define _APP_HXX +//#define _MDIAPP_HXX +//#define _TIMER_HXX +//#define _METRIC_HXX +//#define _REGION_HXX +//#define _OUTDEV_HXX +//#define _SYSTEM_HXX +//#define _VIRDEV_HXX +//#define _JOBSET_HXX +//#define _PRINT_HXX +//#define _WINDOW_HXX +//#define _SYSWIN_HXX +//#define _WRKWIN_HXX +#define _MDIWIN_HXX +//#define _FLOATWIN_HXX +//#define _DOCKWIN_HXX +//#define _CTRL_HXX +//#define _SCRBAR_HXX +//#define _BUTTON_HXX +//#define _IMAGEBTN_HXX +//#define _FIXED_HXX +//#define _GROUP_HXX +//#define _EDIT_HXX +//#define _COMBOBOX_HXX +#define _LSTBOX_HXX //??? +//#define _SELENG_HXX *** +//#define _SPLIT_HXX *** +#define _SPIN_HXX +//#define _FIELD_HXX *** +//#define _MOREBTN_HXX *** +#define _TOOLBOX_HXX //??? +//#define _STATUS_HXX *** +//#define _DIALOG_HXX *** +#define _MSGBOX_HXX //??? +#define _SYSDLG_HXX //??? +#define _FILDLG_HXX +#define _PRNDLG_HXX //??? +#define _COLDLG_HXX +#define _TABDLG_HXX //??? +#ifdef WIN +#define _MENU_HXX +#endif +//#define _GDIMTF_HXX *** +//#define _POLY_HXX *** +#define _ACCEL_HXX //??? +#define _GRAPH_HXX //??? +#define _SOUND_HXX + + + +#ifdef WIN +#define _MENUBTN_HXX +#endif + +//svtools +#define _SCRWIN_HXX +#define _RULER_HXX +//#define _TABBAR_HXX *** +#define _VALUESET_HXX //??? +#define _STDMENU_HXX +#define _STDCTRL_HXX +#define _CTRLBOX_HXX +#define _CTRLTOOL_HXX +#define _EXTATTR_HXX +#define _FRM3D_HXX + +//SVTOOLS +#define _SVTREELIST_HXX +#define _FILTER_HXX +#define _SVLBOXITM_HXX +#define _SVTREEBOX_HXX +#define _SVICNVW_HXX +#define _SVTABBX_HXX + +#define _SFX_DOCFILT_HXX //??? +#define _SFX_PRNMON_HXX +#define _SFX_RESMGR_HXX +#define _SFX_TEMPLDLG_HXX +#define _SFXAPPWIN_HXX +#define _SFXBASIC_HXX +#define _SFXCTRLITEM +#define _SFXDLGCFG_HXX +//#define _SFXDISPATCH_HXX *** +#define _SFXDOCFILE_HXX +#define _SFXDOCMAN_HXX +#define _SFXDOCMGR_HXX +#define _SFXDOCTDLG_HXX +#define _SFXFILEDLG_HXX +#define _SFXIMGMGR_HXX +#define _SFXIPFRM_HXX +#define _SFX_MACRO_HXX +#define _SFXMNUITEM_HXX +#define _SFXMNUMGR_HXX +#define _SFXMULTISEL_HXX +//#define _SFXMSG_HXX *** +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFX_MINFITEM_HXX +#define _SFXOBJFACE_HXX +//#define _SFXOBJFAC_HXX ??? +#define _SFX_SAVEOPT_HXX +#define _SFXSTBITEM_HXX +#define _SFXSTBMGR_HXX +#define _SFXTBXCTRL_HXX +#define _SFXTBXMGR_HXX + +//sfxdoc.hxx +//#define _SFX_OBJSH_HXX *** +//#define _SFX_CLIENTSH_HXX *** +#define _SFXDOCINF_HXX //??? +#define _SFX_DOCFILT_HXX +//#define _SFXDOCFILE_HXX *** +//#define _VIEWFAC_HXX ??? +//#define _SFXVIEWFRM_HXX *** +//#define _SFXVIEWSH_HXX *** +//#define _MDIFRM_HXX *** +#define _SFX_IPFRM_HXX +#define _SFX_INTERNO_HXX + +//sfxdlg.hxx +//#define _SFXTABDLG_HXX *** +//#define _BASEDLGS_HXX *** +#define _SFX_DINFDLG_HXX +#define _SFXDINFEDT_HXX +#define _SFX_MGETEMPL_HXX +#define _SFX_TPLPITEM_HXX +#define _SFX_STYLEDLG_HXX +#define _NEWSTYLE_HXX +//#define _SFXDOCTEMPL_HXX *** +//#define _SFXDOCTDLG_HXX *** +//#define _SFX_TEMPLDLG_HXX *** +//#define _SFXNEW_HXX *** +#define _SFXDOCMAN_HXX +//#define _SFXDOCKWIN_HXX *** + +//sfxitems.hxx +#define _SFX_WHMAP_HXX +#define _ARGS_HXX +//#define _SFXPOOLITEM_HXX *** +//#define _SFXINTITEM_HXX *** +//#define _SFXENUMITEM_HXX *** +#define _SFXFLAGITEM_HXX +//#define _SFXSTRITEM_HXX *** +#define _SFXPTITEM_HXX +#define _SFXRECTITEM_HXX +//#define _SFXITEMPOOL_HXX *** +//#define _SFXITEMSET_HXX *** +#define _SFXITEMITER_HXX +#define _SFX_WHITER_HXX +#define _SFXPOOLCACH_HXX +#define _AEITEM_HXX +#define _SFXRNGITEM_HXX +#define _SFXSLSTITM_HXX +//#define _SFXSTYLE_HXX *** + +//xout.hxx +//#define _XENUM_HXX +//#define _XPOLY_HXX +//#define _XATTR_HXX +#define _XOUTX_HXX +//#define _XPOOL_HXX *** +#define _XTABLE_HXX + +//svdraw.hxx +#define _SDR_NOITEMS +#define _SDR_NOTOUCH +#define _SDR_NOTRANSFORM +#define _SDR_NOOBJECTS +//#define _SDR_NOVIEWS *** + +//#define _VCATTR_HXX +#define _VCONT_HXX +#define _SI_NOOTHERFORMS +#define _VCTRLS_HXX +#define _SI_NOCONTROL +#define _SETBRW_HXX +#define _VCBRW_HXX +#define _SI_NOSBXCONTROLS +#define _SVBOXITM_HXX + +#define _SVDRAG_HXX +#define _SVINCVW_HXX +#define _SV_MULTISEL_HXX +#define _SVRTV_HXX +#define _SVTABBX_HXX + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_THESDLG_HXX + +//#define _SI_HXX +#define _SI_DLL_HXX +#define _SIDLL_HXX +#define _SI_NOITEMS +#define _SI_NOOTHERFORMS +#define _SI_NOSBXCONTROLS +#define _SINOSBXCONTROLS +#define _SI_NOCONTROL +#define _VCBRW_HXX +#define _VCTRLS_HXX +#define _VCONT_HXX +#define _VDRWOBJ_HXX +#define _VCATTR_HXX +#define _VCONT_HXX + +#define _SDR_NOTRANSFORM +#define _SDR_NOITEMS +#define _SDR_NOOBJECTS +#define _SVDXOUT_HXX +#endif + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <svx/fmshell.hxx> +#include <svx/svdobj.hxx> +#include <svx/svdoutl.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/objsh.hxx> +#include <tools/ref.hxx> + +#include "tabview.hxx" +#include "tabvwsh.hxx" +#include "document.hxx" +#include "gridwin.hxx" +#include "olinewin.hxx" +#include "tabsplit.hxx" +#include "colrowba.hxx" +#include "tabcont.hxx" +#include "hintwin.hxx" +#include "sc.hrc" +#include "pagedata.hxx" +#include "hiranges.hxx" +#include "drawview.hxx" +#include "drwlayer.hxx" +#include "fusel.hxx" // Start-Function + + +// STATIC DATA ----------------------------------------------------------- + + +void __EXPORT ScTabView::Init() +{ + USHORT i; + + aScrollTimer.SetTimeout(10); + aScrollTimer.SetTimeoutHdl( LINK( this, ScTabView, TimerHdl ) ); + + for (i=0; i<4; i++) + pGridWin[i] = NULL; + pGridWin[SC_SPLIT_BOTTOMLEFT] = new ScGridWindow( pFrameWin, &aViewData, SC_SPLIT_BOTTOMLEFT ); + + pSelEngine = new ScViewSelectionEngine( pGridWin[SC_SPLIT_BOTTOMLEFT], this, + SC_SPLIT_BOTTOMLEFT ); + aFunctionSet.SetSelectionEngine( pSelEngine ); + + pHdrSelEng = new ScHeaderSelectionEngine( pFrameWin, &aHdrFunc ); + + pColBar[SC_SPLIT_LEFT] = new ScColBar( pFrameWin, &aViewData, SC_SPLIT_LEFT, + &aHdrFunc, pHdrSelEng ); + pColBar[SC_SPLIT_RIGHT] = NULL; + pRowBar[SC_SPLIT_BOTTOM] = new ScRowBar( pFrameWin, &aViewData, SC_SPLIT_BOTTOM, + &aHdrFunc, pHdrSelEng ); + pRowBar[SC_SPLIT_TOP] = NULL; + for (i=0; i<2; i++) + pColOutline[i] = pRowOutline[i] = NULL; + + pHSplitter = new ScTabSplitter( pFrameWin, WinBits( WB_HSCROLL ), &aViewData ); + pVSplitter = new ScTabSplitter( pFrameWin, WinBits( WB_VSCROLL ), &aViewData ); + + pTabControl = new ScTabControl( pFrameWin, &aViewData ); + //MI: nie! das war mal eine MUSS-Aenderung von MBA + //if (!aViewData.IsBasicView()) + // pTabControl->ToTop(); // ueber dem Splitter + + InitScrollBar( aHScrollLeft, MAXCOL+1 ); + InitScrollBar( aHScrollRight, MAXCOL+1 ); + InitScrollBar( aVScrollTop, MAXROW+1 ); + InitScrollBar( aVScrollBottom, MAXROW+1 ); + + // Hier noch nichts anzeigen (Show), weil noch falsch angeordnet ist + // Show kommt dann aus UpdateShow beim ersten Resize + // pTabControl, pGridWin, aHScrollLeft, aVScrollBottom, + // aCornerButton, aScrollBarBox, pHSplitter, pVSplitter + + // Splitter + + pHSplitter->SetSplitHdl( LINK( this, ScTabView, SplitHdl ) ); + pVSplitter->SetSplitHdl( LINK( this, ScTabView, SplitHdl ) ); + + // UpdateShow kommt beim Resize, oder bei Kopie einer bestehenden View aus dem ctor + + pDrawActual = NULL; + pDrawOld = NULL; + + // DrawView darf nicht im TabView - ctor angelegt werden, + // wenn die ViewShell noch nicht konstruiert ist... + // Das gilt auch fuer ViewOptionsHasChanged() + + TestHintWindow(); +} + +__EXPORT ScTabView::~ScTabView() +{ + USHORT i; + + DELETEZ(pPageBreakData); + DELETEZ(pHighlightRanges); + + DELETEZ(pDrawOld); + DELETEZ(pDrawActual); + + aViewData.KillEditView(); // solange GridWin's noch existieren + + DELETEZ(pInputHintWindow); + + if (pDrawView) + { + for (i=0; i<4; i++) + if (pGridWin[i]) + { + pDrawView->VCRemoveWin(pGridWin[i]); + pDrawView->DelWin(pGridWin[i]); + } + + pDrawView->HidePagePvNum(0); + delete pDrawView; + } + + delete pSelEngine; + + for (i=0; i<4; i++) + delete pGridWin[i]; + + delete pHdrSelEng; + + for (i=0; i<2; i++) + { + delete pColBar[i]; + delete pRowBar[i]; + delete pColOutline[i]; + delete pRowOutline[i]; + } + + delete pHSplitter; + delete pVSplitter; + + delete pTabControl; +} + +void ScTabView::MakeDrawView() +{ + if (!pDrawView) + { + ScDrawLayer* pLayer = aViewData.GetDocument()->GetDrawLayer(); + DBG_ASSERT(pLayer, "wo ist der DrawLayer ??"); + + USHORT i; + pDrawView = new ScDrawView( pGridWin[SC_SPLIT_BOTTOMLEFT], &aViewData ); + for (i=0; i<4; i++) + if (pGridWin[i]) + { + if ( SC_SPLIT_BOTTOMLEFT != (ScSplitPos)i ) + pDrawView->AddWin(pGridWin[i]); + pDrawView->VCAddWin(pGridWin[i]); + } + pDrawView->RecalcScale(); + for (i=0; i<4; i++) + if (pGridWin[i]) + { + pGridWin[i]->SetMapMode(pGridWin[i]->GetDrawMapMode()); + + pGridWin[i]->Update(); // wegen Invalidate im DrawView ctor (ShowPage), + // damit gleich gezeichnet werden kann + } + SfxRequest aSfxRequest(SID_OBJECT_SELECT, 0,aViewData.GetViewShell()->GetPool()); + SetDrawFuncPtr(new FuSelection( aViewData.GetViewShell(), GetActiveWin(), pDrawView, + pLayer,aSfxRequest)); + + // an der FormShell anmelden + FmFormShell* pFormSh = aViewData.GetViewShell()->GetFormShell(); + if (pFormSh) + pFormSh->SetView(pDrawView); + } +} + +void ScTabView::DoAddWin( ScGridWindow* pWin ) +{ + if (pDrawView) + { + pDrawView->AddWin(pWin); + pDrawView->VCAddWin(pWin); + } +} + +//================================================================== + +void ScTabView::TabChanged() +{ + if (pDrawView) + { + DrawDeselectAll(); // beendet auch Text-Edit-Modus + + USHORT i; + for (i=0; i<4; i++) + if (pGridWin[i]) + pDrawView->VCRemoveWin(pGridWin[i]); // fuer alte Page + + USHORT nTab = aViewData.GetTabNo(); + pDrawView->HideAllPages(); + pDrawView->ShowPagePgNum( nTab, Point() ); + + UpdateLayerLocks(); + + pDrawView->RecalcScale(); + pDrawView->UpdateWorkArea(); // #54782# PageSize ist pro Page unterschiedlich + + for (i=0; i<4; i++) + if (pGridWin[i]) + pDrawView->VCAddWin(pGridWin[i]); // fuer neue Page + } + + SfxBindings& rBindings = SFX_BINDINGS(); + + // Es gibt keine einfache Moeglichkeit, alle Slots der FormShell zu invalidieren + // (fuer disablete Slots auf geschuetzten Tabellen), darum hier einfach alles... + rBindings.InvalidateAll(FALSE); + +#if 0 + rBindings.Invalidate( SID_SELECT_SCENARIO ); + rBindings.Invalidate( FID_PROTECT_TABLE ); + rBindings.Invalidate( FID_DELETE_TABLE ); + rBindings.Invalidate( FID_TABLE_SHOW ); + rBindings.Invalidate( FID_TABLE_HIDE ); + + // Auswirkungen von geschuetzten Tabellen. + rBindings.Invalidate( FID_TAB_RENAME ); + rBindings.Invalidate( FID_TAB_MOVE ); + rBindings.Invalidate( SID_DEL_ROWS ); + rBindings.Invalidate( SID_DEL_COLS ); + rBindings.Invalidate( FID_INS_ROW ); + rBindings.Invalidate( FID_INS_COLUMN ); + rBindings.Invalidate( FID_INS_CELL ); + rBindings.Invalidate( FID_INS_CELLSDOWN ); + rBindings.Invalidate( FID_INS_CELLSRIGHT ); + rBindings.Invalidate( FID_DELETE_CELL ); + + rBindings.Invalidate( SID_OPENDLG_CHART ); + rBindings.Invalidate( SID_INSERT_OBJECT ); + rBindings.Invalidate( SID_INSERT_DIAGRAM ); + rBindings.Invalidate( SID_INSERT_SIMAGE ); + rBindings.Invalidate( SID_INSERT_SMATH ); + rBindings.Invalidate( SID_INSERT_GRAPHIC ); +#endif +} + +void ScTabView::UpdateLayerLocks() +{ + if (pDrawView) + { + USHORT nTab = aViewData.GetTabNo(); + BOOL bEx = aViewData.GetViewShell()->IsDrawSelMode(); + BOOL bProt = aViewData.GetDocument()->IsTabProtected( nTab ) || + aViewData.GetSfxDocShell()->IsReadOnly(); + + SdrLayer* pLayer; + SdrLayerAdmin& rAdmin = pDrawView->GetModel()->GetLayerAdmin(); + pLayer = rAdmin.GetLayerPerID(SC_LAYER_BACK); + if (pLayer) + pDrawView->SetLayerLocked( pLayer->GetName(), bProt || !bEx ); + pLayer = rAdmin.GetLayerPerID(SC_LAYER_INTERN); + if (pLayer) + pDrawView->SetLayerLocked( pLayer->GetName(), TRUE ); + pLayer = rAdmin.GetLayerPerID(SC_LAYER_FRONT); + if (pLayer) + pDrawView->SetLayerLocked( pLayer->GetName(), bProt ); + pLayer = rAdmin.GetLayerPerID(SC_LAYER_CONTROLS); + if (pLayer) + pDrawView->SetLayerLocked( pLayer->GetName(), bProt ); + } +} + +void ScTabView::DrawDeselectAll() +{ + if (pDrawView) + { + ScTabViewShell* pViewSh = aViewData.GetViewShell(); + if ( pDrawActual && + ( pViewSh->IsDrawTextShell() || pDrawActual->GetSlotID() == SID_DRAW_NOTEEDIT ) ) + { + // end text edit (as if escape pressed, in FuDraw) + SFX_DISPATCHER().Execute( pDrawActual->GetSlotID(), + SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD ); + } + + pDrawView->ScEndTextEdit(); + pDrawView->UnmarkAll(); + + if (!pViewSh->IsDrawSelMode()) + pViewSh->SetDrawShell( FALSE ); + } +} + +BOOL ScTabView::IsDrawTextEdit() const +{ + if (pDrawView) + return pDrawView->IsTextEdit(); + else + return FALSE; +} + +String ScTabView::GetSelectedChartName() const +{ + if (pDrawView) + return pDrawView->GetSelectedChartName(); + else + return EMPTY_STRING; +} + +void ScTabView::SetZoom( const Fraction& rNewX, const Fraction& rNewY ) +{ + aViewData.SetZoom(rNewX,rNewY); + if (pDrawView) + pDrawView->RecalcScale(); + ZoomChanged(); // einzeln wegen CLOOKs +} + +void ScTabView::SetPagebreakMode( BOOL bSet ) +{ + aViewData.SetPagebreakMode(bSet); + if (pDrawView) + pDrawView->RecalcScale(); + ZoomChanged(); // einzeln wegen CLOOKs +} + +void ScTabView::ResetDrawDragMode() +{ + if (pDrawView) + pDrawView->SetDragMode( SDRDRAG_MOVE ); +} + +void ScTabView::ViewOptionsHasChanged( BOOL bHScrollChanged, BOOL bGraphicsChanged ) +{ + // DrawView erzeugen, wenn Gitter angezeigt werden soll + if ( !pDrawView && aViewData.GetOptions().GetGridOptions().GetGridVisible() ) + MakeDrawLayer(); + + if (pDrawView) + pDrawView->UpdateUserViewOptions(); + + if (bGraphicsChanged) + DrawEnableAnim(TRUE); // DrawEnableAnim checks the options state + + // if TabBar is set to visible, make sure its size is not 0 + BOOL bGrow = ( aViewData.IsTabMode() && pTabControl->GetSizePixel().Width() <= 0 ); + + // if ScrollBar is set to visible, TabBar must make room + BOOL bShrink = ( bHScrollChanged && aViewData.IsTabMode() && aViewData.IsHScrollMode() && + pTabControl->GetSizePixel().Width() > SC_TABBAR_DEFWIDTH ); + + if ( bGrow || bShrink ) + { + Size aSize = pTabControl->GetSizePixel(); + aSize.Width() = SC_TABBAR_DEFWIDTH; // initial size + pTabControl->SetSizePixel(aSize); // DoResize is called later... + } +} + +// Helper-Funktion gegen das Include des Drawing Layers + +SdrView* ScTabView::GetSdrView() +{ + return pDrawView; +} + +void ScTabView::DrawMarkListHasChanged() +{ + if ( pDrawView ) + pDrawView->MarkListHasChanged(); +} + +void ScTabView::UpdateAnchorHandles() +{ + if ( pDrawView ) + pDrawView->AdjustMarkHdl(); +} + +void ScTabView::UpdateIMap( SdrObject* pObj ) +{ + if ( pDrawView ) + pDrawView->UpdateIMap( pObj ); +} + +void ScTabView::DrawMarkRect( const Rectangle& rRect ) +{ + //! store rectangle for repaint during drag + + for (USHORT i=0; i<4; i++) + { + if ( pGridWin[i] && pGridWin[i]->IsVisible() ) + { + RasterOp aROp = pGridWin[i]->GetRasterOp(); + BOOL bHasLine = pGridWin[i]->IsLineColor(); + Color aLine = pGridWin[i]->GetLineColor(); + BOOL bHasFill = pGridWin[i]->IsFillColor(); + Color aFill = pGridWin[i]->GetFillColor(); + + pGridWin[i]->SetRasterOp( ROP_INVERT ); + pGridWin[i]->SetLineColor( COL_BLACK ); + pGridWin[i]->SetFillColor(); + + pGridWin[i]->DrawRect(rRect); + + pGridWin[i]->SetRasterOp(aROp); + if (bHasLine) + pGridWin[i]->SetLineColor(aLine); + else + pGridWin[i]->SetLineColor(); + if (bHasFill) + pGridWin[i]->SetFillColor(aFill); + else + pGridWin[i]->SetFillColor(); + } + } +} + +void ScTabView::DrawEnableAnim(BOOL bSet) +{ + USHORT i; + if ( pDrawView ) + { + // #71040# dont start animations if display of graphics is disabled + // graphics are controlled by VOBJ_TYPE_OLE + if ( bSet && aViewData.GetOptions().GetObjMode(VOBJ_TYPE_OLE) == VOBJ_MODE_SHOW ) + { + if ( !pDrawView->IsAnimationEnabled() ) + { + pDrawView->SetAnimationEnabled(TRUE); + + // Animierte GIFs muessen wieder gestartet werden: + ScDocument* pDoc = aViewData.GetDocument(); + for (i=0; i<4; i++) + if ( pGridWin[i] && pGridWin[i]->IsVisible() ) + pDoc->StartAnimations( aViewData.GetTabNo(), pGridWin[i] ); + } + } + else + { + pDrawView->SetAnimationEnabled(FALSE); + // StopAnimations am Dokument ist nicht mehr noetig + } + } +} + +void ScTabView::DrawShowMarkHdl(BOOL bShow) +{ + if (!pDrawView) + return; + + if (bShow) + { + if (!pDrawView->IsDisableHdl()) + pDrawView->ShowMarkHdl(NULL); + } + else + pDrawView->HideMarkHdl(NULL); +} + +void ScTabView::UpdateDrawTextOutliner() +{ + if ( pDrawView ) + { + Outliner* pOL = pDrawView->GetTextEditOutliner(); + if (pOL) + aViewData.UpdateOutlinerFlags( *pOL ); + } +} + +//--------------------------------------------------------------- + +void ScTabView::ScrollToObject( SdrObject* pDrawObj ) +{ + if ( pDrawObj ) + MakeVisible( pDrawObj->GetLogicRect() ); +} + +void ScTabView::MakeVisible( const Rectangle& rHMMRect ) +{ + Window* pWin = GetActiveWin(); + Size aWinSize = pWin->GetOutputSizePixel(); + USHORT nTab = aViewData.GetTabNo(); + + Rectangle aRect = pWin->LogicToPixel( rHMMRect ); + + long nScrollX=0, nScrollY=0; // Pixel + + if ( aRect.Right() >= aWinSize.Width() ) // rechts raus + { + nScrollX = aRect.Right() - aWinSize.Width() + 1; // rechter Rand sichtbar + if ( aRect.Left() < nScrollX ) + nScrollX = aRect.Left(); // links sichtbar (falls zu gross) + } + if ( aRect.Bottom() >= aWinSize.Height() ) // unten raus + { + nScrollY = aRect.Bottom() - aWinSize.Height() + 1; // unterer Rand sichtbar + if ( aRect.Top() < nScrollY ) + nScrollY = aRect.Top(); // oben sichtbar (falls zu gross) + } + + if ( aRect.Left() < 0 ) // links raus + nScrollX = aRect.Left(); // linker Rand sichtbar + if ( aRect.Top() < 0 ) // oben raus + nScrollY = aRect.Top(); // oberer Rand sichtbar + + if (nScrollX || nScrollY) + { + ScDocument* pDoc = aViewData.GetDocument(); + double nPPTX = aViewData.GetPPTX(); + double nPPTY = aViewData.GetPPTY(); + ScSplitPos eWhich = aViewData.GetActivePart(); + USHORT nPosX = aViewData.GetPosX(WhichH(eWhich)); + USHORT nPosY = aViewData.GetPosY(WhichV(eWhich)); + + long nLinesX=0, nLinesY=0; // Spalten/Zeilen - um mindestens nScrollX/Y scrollen + + if (nScrollX > 0) + while (nScrollX > 0 && nPosX < MAXCOL) + { + nScrollX -= (long) ( pDoc->GetColWidth(nPosX, nTab) * nPPTX ); + ++nPosX; + ++nLinesX; + } + else if (nScrollX < 0) + while (nScrollX < 0 && nPosX > 0) + { + --nPosX; + nScrollX += (long) ( pDoc->GetColWidth(nPosX, nTab) * nPPTX ); + --nLinesX; + } + + if (nScrollY > 0) + while (nScrollY > 0 && nPosY < MAXROW) + { + nScrollY -= (long) ( pDoc->FastGetRowHeight(nPosY, nTab) * nPPTY ); + ++nPosY; + ++nLinesY; + } + else if (nScrollY < 0) + while (nScrollY < 0 && nPosY > 0) + { + --nPosY; + nScrollY += (long) ( pDoc->FastGetRowHeight(nPosY, nTab) * nPPTY ); + --nLinesY; + } + + ScrollLines( nLinesX, nLinesY ); // ausfuehren + } +} + + + diff --git a/sc/source/ui/view/tabvwsh.cxx b/sc/source/ui/view/tabvwsh.cxx new file mode 100644 index 000000000000..2f0f266ddb64 --- /dev/null +++ b/sc/source/ui/view/tabvwsh.cxx @@ -0,0 +1,326 @@ +/************************************************************************* + * + * $RCSfile: tabvwsh.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +#if !defined OS2 && !defined WNT +//#define _BUTTON_HXX +#endif + +#define _SETBRW_HXX +#define _STACK_HXX +//#define _STATUS_HXX +#define _STDMENU_HXX +#define _TABBAR_HXX +#define _VCBRW_HXX +#define _VCTRLS_HXX +#define _VCSBX_HXX +#define _VCONT_HXX +#define _VDRWOBJ_HXX + +#define _BASE_DLGS_HXX +#define _BIGINT_HXX +#define _CACHESTR_HXX +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _CTRLTOOL_HXX +#define _DLGCFG_HXX +#define _DYNARR_HXX +#define _EXTATTR_HXX +#define _FILDLG_HXX +#define _FONTDLG_HXX +#define _FRM3D_HXX +#define _INTRO_HXX +#define _ISETBWR_HXX +#define _NO_SVRTF_PARSER_HXX +#define _MACRODLG_HXX +#define _MODALDLG_HXX +#define _MOREBUTTON_HXX +#define _OUTLINER_HXX +#define _PASSWD_HXX +//#define _PRNDLG_HXX +//#define _POLY_HXX +#define _PVRWIN_HXX +#define _QUEUE_HXX +#define _RULER_HXX +#define _SCRWIN_HXX +#define _STACK_HXX +#define _SETBRW_HXX +#define _STACK_HXX +//#define _STATUS_HXX +#define _STDMENU_HXX +#define _TABBAR_HXX +#define _VCBRW_HXX +#define _VCTRLS_HXX +#define _VCSBX_HXX +#define _VCONT_HXX +#define _VDRWOBJ_HXX + +#define _SVDXOUT_HXX +#define _SVDATTR_HXX +#define _SVDETC_HXX +#define _SVDIO_HXX +#define _SVDRAG_HXX +#define _SVDLAYER_HXX + +//#define _SFX_BINDINGS_HXX +#define _SFXFILEDLG_HXX +#define _SFX_MACRO_HXX +#define _SFXMNUITEM_HXX +#define _SFXMNUMGR_HXX +#define _SFXMSGPOOL_HXX +#define _SFXMULTISEL_HXX +#define _SFXBASIC_HXX +#define _SFXSTBMGR_HXX +//#define _SFXTBXCTRL_HXX +//#define _SFXTBXMGR_HXX +//#define _SFXIMGMGR_HXX + +#define _SI_DLL_HXX +#define _SIDLL_HXX +#define _SI_NOITEMS +#define _SI_NOOTHERFORMS +#define _SI_NOSBXCONTROLS +#define _SINOSBXCONTROLS +#define _SI_NODRW +#define _SI_NOCONTROL + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_THESDLG_HXX + +// INCLUDE --------------------------------------------------------------- + +#define GLOBALOVERFLOW +#include <segmentc.hxx> + +#include "scitems.hxx" +#include <basctl/idetemp.hxx> +#include <svx/imapdlg.hxx> +#include <svx/srchitem.hxx> +#include <offmgr/sbasltid.hrc> +#include <sfx2/templdlg.hxx> + +#include "tabvwsh.hxx" +#include "docsh.hxx" +#include "reffact.hxx" +#include "scresid.hxx" +#include "dwfunctr.hxx" +#include "sc.hrc" // -> SID_TOOL_xxx +#include "drawattr.hxx" // -> SvxDrawToolItem + + +#define ScTabViewShell +#include "scslots.hxx" + +#define SearchSettings +#include <svx/svxslots.hxx> + +SEG_EOFGLOBALS() + +#pragma SEG_SEGCLASS(SFXMACROS_SEG,STARTWORK_CODE) + +TYPEINIT2(ScTabViewShell,SfxViewShell,SfxListener); + +SFX_IMPL_INTERFACE(ScTabViewShell,SfxViewShell,ScResId(SCSTR_TABVIEWSHELL)) +{ + SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_TOOLS | SFX_VISIBILITY_STANDARD | + SFX_VISIBILITY_FULLSCREEN | SFX_VISIBILITY_SERVER, + ScResId(RID_OBJECTBAR_TOOLS) ); + + SFX_CHILDWINDOW_REGISTRATION(FID_INPUTLINE_STATUS); + SFX_CHILDWINDOW_REGISTRATION(SfxTemplateDialogWrapper::GetChildWindowId()); + SFX_CHILDWINDOW_CONTEXT_REGISTRATION(SID_NAVIGATOR); + SFX_CHILDWINDOW_REGISTRATION(ScNameDlgWrapper::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(ScSolverDlgWrapper::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(ScPivotLayoutWrapper::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(ScTabOpDlgWrapper::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(ScFilterDlgWrapper::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(ScSpecialFilterDlgWrapper::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(ScDbNameDlgWrapper::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(ScConsolidateDlgWrapper::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(ScChartDlgWrapper::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(ScPrintAreasDlgWrapper::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(ScCondFormatDlgWrapper::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(ScColRowNameRangesDlgWrapper::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(ScFormulaDlgWrapper::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(SvxIMapDlgChildWindow::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(ScFunctionChildWindow::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(ScFormulaDlgWrapper::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(ScAcceptChgDlgWrapper::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(ScHighlightChgDlgWrapper::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(ScSimpleRefDlgWrapper::GetChildWindowId()); + SFX_CHILDWINDOW_REGISTRATION(SID_SEARCH_DLG); + SFX_CHILDWINDOW_REGISTRATION(SID_HYPERLINK_DIALOG); +} + +SFX_IMPL_VIEWFACTORY( ScTabViewShell, ScResId(STR_NONAME) ) +{ + SFX_VIEW_REGISTRATION(ScDocShell); +} + +//------------------------------------------------------------------ + + +/*------------------------------------------------------------------------ + + $Log: not supported by cvs2svn $ + Revision 1.305 2000/09/17 14:09:35 willem.vandorp + OpenOffice header added. + + Revision 1.304 2000/09/04 13:31:53 tbe + basicide, isetbrw, si, vcdlged moved from svx to basctl + + Revision 1.303 2000/08/31 16:38:48 willem.vandorp + Header and footer replaced + + Revision 1.302 2000/05/09 18:30:15 nn + use IMPL_INTERFACE macro without IDL + + Revision 1.301 2000/05/09 17:37:21 nn + old Basic removed + + Revision 1.300 2000/04/14 08:31:38 nn + unicode changes + + Revision 1.299 2000/02/09 09:57:30 nn + #72165# child window registration for hyperlink dialog + + Revision 1.298 1999/06/07 15:30:30 ANK + #66547# Searchsettings aktiviert + + + Rev 1.297 07 Jun 1999 17:30:30 ANK + #66547# Searchsettings aktiviert + + Rev 1.296 02 Jun 1999 21:42:26 ANK + #66547# SubShells + + Rev 1.295 09 Apr 1998 21:58:40 ANK + Redlining Erweiterungen + + Rev 1.294 13 Mar 1998 12:58:24 ANK + Changes + + Rev 1.293 08 Mar 1998 20:38:28 ANK + Redlining + + Rev 1.292 05 Dec 1997 19:22:38 NN + Includes + + Rev 1.291 20 Nov 1997 20:30:56 NN + includes angepasst + + Rev 1.290 14 Oct 1997 19:58:56 ANK + Neue Funktionsbox + + Rev 1.289 23 May 1997 20:32:30 NN + ScFormulaDlgWrapper registrieren + + Rev 1.288 08 Apr 1997 17:34:42 HJS + includes, defines + + Rev 1.287 18 Nov 1996 19:11:58 ER + new: ScColRowNameRangesDlg + + Rev 1.286 14 Nov 1996 22:00:44 NN + CHILDWINDOW_CONTEXT_REGISTRATION fuer Navigator + + Rev 1.285 29 Oct 1996 13:36:20 NN + ueberall ScResId statt ResId + + Rev 1.284 16 Oct 1996 16:24:52 RJ + Einbindung des Dialogs fuer bedingte Formatierung + + Rev 1.283 09 Aug 1996 20:35:02 NN + Svx-Includes aus scitems.hxx raus + + Rev 1.282 10 Jul 1996 14:21:18 KA + gallery entfernt, da jetzt im Explorer + + Rev 1.281 05 Jul 1996 17:25:26 NN + SearchSettings aus svxslots, bei GetSbxObject anlegen + + Rev 1.280 20 Jun 1996 19:04:08 NN + Werkzeugleiste registrieren + +------------------------------------------------------------------------*/ + +#pragma SEG_EOFMODULE + + diff --git a/sc/source/ui/view/tabvwsh2.cxx b/sc/source/ui/view/tabvwsh2.cxx new file mode 100644 index 000000000000..300ca094398f --- /dev/null +++ b/sc/source/ui/view/tabvwsh2.cxx @@ -0,0 +1,634 @@ +/************************************************************************* + * + * $RCSfile: tabvwsh2.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +// TOOLS +#define _BIGINT_HXX +#define _SFXMULTISEL_HXX +#define _STACK_HXX +#define _QUEUE_HXX +#define _DYNARR_HXX +#define _TREELIST_HXX +#define _CACHESTR_HXX + +//SV +//#define _CLIP_HXX +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _FONTDLG_HXX +#define _PRVWIN_HXX + +#define _SVDRAG_HXX +#define _SVINCVW_HXX +#define _SV_MULTISEL_HXX +#define _SVRTV_HXX +#define _SVTABBX_HXX + +//#define _BASE_DLGS_HXX +#define _BIGINT_HXX +#define _CACHESTR_HXX +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _CTRLTOOL_HXX +#define _DLGCFG_HXX +#define _DYNARR_HXX +#define _EXTATTR_HXX +#define _FILDLG_HXX +#define _FONTDLG_HXX +#define _FRM3D_HXX +#define _INTRO_HXX +#define _ISETBWR_HXX +#define _NO_SVRTF_PARSER_HXX +#define _MACRODLG_HXX +#define _MODALDLG_HXX +#define _MOREBUTTON_HXX +#define _OUTLINER_HXX +#define _PASSWD_HXX +#define _SOUND_HXX + +#if defined WIN +#define _MENUBTN_HXX +#endif + +//svtools +#define _SCRWIN_HXX +#define _RULER_HXX +#define _TABBAR_HXX +#define _VALUESET_HXX +#define _STDMENU_HXX +#define _STDCTRL_HXX +#define _CTRLBOX_HXX +#define _CTRLTOOL_HXX +#define _EXTATTR_HXX +#define _FRM3D_HXX + +//SVTOOLS +#define _SVTREELIST_HXX +#define _FILTER_HXX +#define _SVLBOXITM_HXX +#define _SVTREEBOX_HXX +#define _SVICNVW_HXX +#define _SVTABBX_HXX + +// SFX +//#define _BASEDLGS_HXX +#define _DLGCFG_HXX +#define _SFXBASIC_HXX +#define _SFXFILEDLG_HXX +#define _SFXMNUMGR_HXX +#define _SFXMNUITEM_HXX +#define _SFXMSG_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFXOBJFACE_HXX +//#define _SFXREQUEST_HXX +#define _SFXSTBMGR_HXX +#define _SFX_TEMPLDLG_HXX +#define _SFXSTBITEM_HXX +//#define _SFXTBXCTRL_HXX +#define _PASSWD_HXX +#define _SFXFILEDLG_HXX +//#define _SFXREQUEST_HXX +#define _SFXOBJFACE_HXX +#define _SFXMSGPOOL_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSG_HXX +#define _INTRO_HXX +#define _SFX_PRNMON_HXX +//#define _SFXDISPATCH_HXX +//#define _SFXCTRLITEM_HXX +//#define _SFX_BINDINGS_HXX +#define _SFX_MINFITEM_HXX +#define _SFX_MACRO_HXX +#define _SFX_CHOR +#define _SFXEVENT_HXX +#define _SFX_MINFITEM_HXX + +//sfxdoc.hxx +//#define _SFX_OBJSH_HXX +//#define _SFX_CLIENTSH_HXX +//#define _SFXDOCINF_HXX +//#define _SFX_OBJFAC_HXX +#define _SFX_DOCFILT_HXX +#define _SFXDOCFILE_HXX +//#define _VIEWFAC_HXX +//#define _SFXVIEWFRM_HXX +//#define _SFXVIEWSH_HXX +#define _MDIFRM_HXX +//#define _SFX_IPFRM_HXX //* +//#define _SFX_INTERNO_HXX + +//#define SI_NOITEMS +//#define SI_NODRW +#define _SI_NOSBXCONTROLS +//#define _VCATTR_HXX +#define _VCONT_HXX +//#define _VCSBX_HXX +#define _SI_NOOTHERFORMS +//#define _VCTRLS_HXX +//#define _VCDRWOBJ_HXX +#define _SI_NOCONTROL +#define _SETBRW_HXX +#define _VCBRW_HXX +#define _SI_NOSBXCONTROLS +//#define _VCSBX_HXX +#define _SIDLL_HXX + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_THESDLG_HXX + +// soui.hxx +#define _IPWIN_HXX +#define _IPMENU_HXX +#define _PASTEDLG_HXX + +// basicsh.hxx +#define _BASIDESH_HXX +#define _TBXCTL_HXX + +//xout.hxx +//#define _XENUM_HXX +//#define _XPOLY_HXX +//#define _XATTR_HXX *** +#define _XOUTX_HXX //* +//#define _XPOOL_HXX *** +#define _XTABLE_HXX //* + + +#define _SDR_NOVIEWMARKER +#define _SDR_NODRAGMETHODS +#define _SDR_NOXOUTDEV +//#define _SDR_NOOBJECTS +//#define _SDR_NOVIEWS + + +#define _SDR_NOITEMS +#define _SVDXOUT_HXX +#define _SDR_NOTRANSFORM // Transformationen, selten verwendet +#define _SDR_NOTOUCH // Hit-Tests, selten verwendet +#define _SDR_NOEXTDEV // ExtOutputDevice +//#define _SDR_NOUNDO // Undo-Objekte +#define _SDR_NOSURROGATEOBJ // SdrObjSurrogate +#define _SDR_NOPAGEOBJ // SdrPageObj +#define _SDR_NOVIRTOBJ // SdrVirtObj +#define _SDR_NOGROUPOBJ // SdrGroupObj +//#define _SDR_NOTEXTOBJ // SdrTextObj +#define _SDR_NOPATHOBJ // SdrPathObj +#define _SDR_NOEDGEOBJ // SdrEdgeObj +#define _SDR_NORECTOBJ // SdrRectObj +#define _SDR_NOCAPTIONOBJ // SdrCaptionObj +#define _SDR_NOCIRCLEOBJ // SdrCircleObj +#define _SDR_NOGRAFOBJ // SdrGrafObj +#define _SDR_NOOLE2OBJ // SdrOle2Obj + +// INCLUDE --------------------------------------------------------------- + +#ifdef WNT +#pragma optimize ("", off) +#endif + +#include <basctl/idetemp.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/ipfrm.hxx> +#include <svtools/aeitem.hxx> +#include <svtools/whiter.hxx> +#include <sfx2/dispatch.hxx> + +#include "tabvwsh.hxx" +#include "drawattr.hxx" +#include "drawsh.hxx" +#include "drawview.hxx" +#include "fupoor.hxx" +#include "fuconrec.hxx" +#include "fuconpol.hxx" +#include "fuconarc.hxx" +#include "fuconctl.hxx" +#include "fuconuno.hxx" +#include "fusel.hxx" +#include "futext.hxx" +#include "fumark.hxx" +#include "global.hxx" +#include "sc.hrc" +#include "scmod.hxx" + + +// ----------------------------------------------------------------------- + +SdrView* __EXPORT ScTabViewShell::GetDrawView() const +{ + return ((ScTabViewShell*)this)->GetScDrawView(); // GetScDrawView ist nicht-const +} + +void ScTabViewShell::WindowChanged() +{ + Window* pWin = GetActiveWin(); + + ScDrawView* pDrView = GetScDrawView(); + if (pDrView) + pDrView->SetActualWin(pWin); + + FuPoor* pFunc = GetDrawFuncPtr(); + if (pFunc) + pFunc->SetWindow(pWin); +} + +void ScTabViewShell::ExecDraw(SfxRequest& rReq) +{ + SC_MOD()->InputEnterHandler(); + UpdateInputHandler(); + + MakeDrawLayer(); + + ScTabView* pTabView = GetViewData()->GetView(); + USHORT nTab = GetViewData()->GetTabNo(); + SfxBindings& rBindings = SFX_BINDINGS(); + + Window* pWin = pTabView->GetActiveWin(); + SdrView* pView = pTabView->GetSdrView(); + SdrModel* pDoc = pView->GetModel(); + + const SfxItemSet *pArgs = rReq.GetArgs(); + USHORT nNewId = rReq.GetSlot(); + + // + // Pseudo-Slots von Draw-Toolbox auswerten + //! wird das ueberhaupt noch gebraucht ????? + // + + if (nNewId == SID_INSERT_DRAW && pArgs) + { + const SfxPoolItem* pItem; + if ( pArgs->GetItemState( SID_INSERT_DRAW, TRUE, &pItem ) == SFX_ITEM_SET && + pItem->ISA( SvxDrawToolItem ) ) + { + SvxDrawToolEnum eSel = (SvxDrawToolEnum)((const SvxDrawToolItem*)pItem)->GetValue(); + switch (eSel) + { + case SVX_SNAP_DRAW_SELECT: nNewId = SID_OBJECT_SELECT; break; + case SVX_SNAP_DRAW_LINE: nNewId = SID_DRAW_LINE; break; + case SVX_SNAP_DRAW_RECT: nNewId = SID_DRAW_RECT; break; + case SVX_SNAP_DRAW_ELLIPSE: nNewId = SID_DRAW_ELLIPSE; break; + case SVX_SNAP_DRAW_POLYGON_NOFILL: nNewId = SID_DRAW_POLYGON_NOFILL; break; + case SVX_SNAP_DRAW_BEZIER_NOFILL: nNewId = SID_DRAW_BEZIER_NOFILL; break; + case SVX_SNAP_DRAW_FREELINE_NOFILL: nNewId = SID_DRAW_FREELINE_NOFILL; break; + case SVX_SNAP_DRAW_ARC: nNewId = SID_DRAW_ARC; break; + case SVX_SNAP_DRAW_PIE: nNewId = SID_DRAW_PIE; break; + case SVX_SNAP_DRAW_CIRCLECUT: nNewId = SID_DRAW_CIRCLECUT; break; + case SVX_SNAP_DRAW_TEXT: nNewId = SID_DRAW_TEXT; break; + case SVX_SNAP_DRAW_TEXT_MARQUEE: nNewId = SID_DRAW_TEXT_MARQUEE; break; + case SVX_SNAP_DRAW_CAPTION: nNewId = SID_DRAW_CAPTION; break; + } + } + else // USHORT-Item vom Controller + { + rReq.Done(); + return; + } + } + + // + // Pseudo-Slots von Control-Toolbox auswerten + // + + if (nNewId == SID_CHOOSE_CONTROLS && pArgs) + { + const SvxChooseControlItem* pItem = (const SvxChooseControlItem*)&pArgs->Get( SID_CHOOSE_CONTROLS ); + SvxChooseControlEnum eSel = (SvxChooseControlEnum) pItem->GetValue(); + + nCtrlSfxId = ((USHORT)eSel==nCtrlSfxId) ? USHRT_MAX : (USHORT) eSel; + + if( (eSel == SVX_SNAP_PREVIEW)) // || (eSel==SVX_SNAP_URLBUTTON)) + { + rReq.Done(); + return; + } + switch (eSel) + { + case SVX_SNAP_PUSHBUTTON: nNewId = SID_INSERT_PUSHBUTTON; break; + case SVX_SNAP_CHECKBOX: nNewId = SID_INSERT_CHECKBOX; break; + case SVX_SNAP_RADIOBUTTON: nNewId = SID_INSERT_RADIOBUTTON;break; + case SVX_SNAP_SPINBUTTON: nNewId = SID_INSERT_SPINBUTTON; break; + case SVX_SNAP_FIXEDTEXT: nNewId = SID_INSERT_FIXEDTEXT; break; + case SVX_SNAP_GROUPBOX: nNewId = SID_INSERT_GROUPBOX; break; + case SVX_SNAP_LISTBOX: nNewId = SID_INSERT_LISTBOX; break; + case SVX_SNAP_COMBOBOX: nNewId = SID_INSERT_COMBOBOX; break; + case SVX_SNAP_EDIT: nNewId = SID_INSERT_EDIT; break; + case SVX_SNAP_HSCROLLBAR: nNewId = SID_INSERT_HSCROLLBAR; break; + case SVX_SNAP_VSCROLLBAR: nNewId = SID_INSERT_VSCROLLBAR; break; + case SVX_SNAP_URLBUTTON: nNewId = SID_INSERT_URLBUTTON; break; + case SVX_SNAP_SELECT: nNewId = SID_OBJECT_SELECT; break; + } + } + + if ( nNewId == SID_DRAW_SELECT ) + nNewId = SID_OBJECT_SELECT; + + USHORT nNewFormId = 0; + if ( nNewId == SID_FM_CREATE_CONTROL && pArgs ) + { + const SfxPoolItem* pItem; + if ( pArgs->GetItemState( SID_FM_CONTROL_IDENTIFIER, TRUE, &pItem ) == SFX_ITEM_SET && + pItem->ISA( SfxUInt16Item ) ) + nNewFormId = ((const SfxUInt16Item*)pItem)->GetValue(); + } + + if (nNewId == SID_INSERT_FRAME) // vom Tbx-Button + nNewId = SID_DRAW_TEXT; + + BOOL bEx = IsDrawSelMode(); + if ( nNewId == nDrawSfxId && ( nNewId != SID_FM_CREATE_CONTROL || + nNewFormId == nFormSfxId || nNewFormId == 0 ) ) + { + // SID_FM_CREATE_CONTROL mit nNewFormId==0 (ohne Parameter) kommt beim Deaktivieren + // aus FuConstruct::SimpleMouseButtonUp + // #59280# Execute fuer die Form-Shell, um im Controller zu deselektieren + if ( nNewId == SID_FM_CREATE_CONTROL ) + { + SFX_DISPATCHER().Execute(SID_FM_LEAVE_CREATE); + SFX_BINDINGS().InvalidateAll(FALSE); + //! was fuer einen Slot braucht der komische Controller wirklich, um das anzuzeigen???? + } + + bEx = !bEx; + nNewId = SID_OBJECT_SELECT; + } + else + bEx = TRUE; + + if ( nDrawSfxId == SID_FM_CREATE_CONTROL && nNewId != nDrawSfxId ) + { + // Wechsel von Control- zu Zeichenfunktion -> im Control-Controller deselektieren + SFX_DISPATCHER().Execute(SID_FM_LEAVE_CREATE); + SFX_BINDINGS().InvalidateAll(FALSE); + //! was fuer einen Slot braucht der komische Controller wirklich, um das anzuzeigen???? + } + + SetDrawSelMode(bEx); + + SdrLayer* pLayer = pView->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_BACK); + if (pLayer) + pView->SetLayerLocked( pLayer->GetName(), !bEx ); + + nDrawSfxId = nNewId; + + if ( nNewId != SID_DRAW_CHART ) // Chart nicht mit DrawShell + { + if ( nNewId == SID_DRAW_TEXT || nNewId == SID_DRAW_TEXT_MARQUEE || nNewId == SID_DRAW_NOTEEDIT ) + SetDrawTextShell( TRUE ); + else + { + if (bEx) + { + SetDrawShell( TRUE ); + } + else + { + SetDrawShell( pView->GetMarkList().GetMarkCount() != 0 ); + nCtrlSfxId = USHRT_MAX;// hier pfuschte JN + } + } + } + + if (pTabView->GetDrawFuncPtr()) + { + if (pTabView->GetDrawFuncOldPtr() != pTabView->GetDrawFuncPtr()) + delete pTabView->GetDrawFuncOldPtr(); + + pTabView->GetDrawFuncPtr()->Deactivate(); + pTabView->SetDrawFuncOldPtr(pTabView->GetDrawFuncPtr()); + pTabView->SetDrawFuncPtr(NULL); + } + + SfxRequest aNewReq(rReq); + aNewReq.SetSlot(nDrawSfxId); + + switch (nNewId) + { + case SID_OBJECT_SELECT: + //@#70206# Nicht immer zurueckschalten + if(pView->GetMarkList().GetMarkCount() == 0) SetDrawShell(bEx); + pTabView->SetDrawFuncPtr(new FuSelection(this, pWin, pView, pDoc, aNewReq)); + break; + + case SID_DRAW_LINE: + case SID_DRAW_RECT: + case SID_DRAW_ELLIPSE: + pTabView->SetDrawFuncPtr(new FuConstRectangle(this, pWin, pView, pDoc, aNewReq)); + break; + + case SID_DRAW_CAPTION: + pTabView->SetDrawFuncPtr(new FuConstRectangle(this, pWin, pView, pDoc, aNewReq)); + pView->SetFrameDragSingles( FALSE ); + rBindings.Invalidate( SID_BEZIER_EDIT ); + break; + + case SID_DRAW_POLYGON: + case SID_DRAW_POLYGON_NOFILL: + case SID_DRAW_BEZIER_NOFILL: + case SID_DRAW_FREELINE_NOFILL: + pTabView->SetDrawFuncPtr(new FuConstPolygon(this, pWin, pView, pDoc, aNewReq)); + break; + + case SID_DRAW_ARC: + case SID_DRAW_PIE: + case SID_DRAW_CIRCLECUT: + pTabView->SetDrawFuncPtr(new FuConstArc(this, pWin, pView, pDoc, aNewReq)); + break; + + case SID_DRAW_TEXT: + case SID_DRAW_TEXT_MARQUEE: + case SID_DRAW_NOTEEDIT: + pTabView->SetDrawFuncPtr(new FuText(this, pWin, pView, pDoc, aNewReq)); + break; + + case SID_INSERT_PUSHBUTTON: + case SID_INSERT_CHECKBOX: + case SID_INSERT_RADIOBUTTON: + case SID_INSERT_SPINBUTTON: + case SID_INSERT_FIXEDTEXT: + case SID_INSERT_GROUPBOX: + case SID_INSERT_LISTBOX: + case SID_INSERT_COMBOBOX: + case SID_INSERT_EDIT: + case SID_INSERT_HSCROLLBAR: + case SID_INSERT_VSCROLLBAR: + case SID_INSERT_URLBUTTON: + pTabView->SetDrawFuncPtr(new FuConstControl(this, pWin, pView, pDoc, aNewReq)); + break; + + case SID_FM_CREATE_CONTROL: + SetDrawFormShell(TRUE); + pTabView->SetDrawFuncPtr(new FuConstUnoControl(this, pWin, pView, pDoc, aNewReq)); + nFormSfxId = nNewFormId; + break; + + case SID_DRAW_CHART: + bChartDlgIsEdit = FALSE; + pTabView->SetDrawFuncPtr(new FuMarkRect(this, pWin, pView, pDoc, aNewReq)); + break; + + default: + break; + } + + if (pTabView->GetDrawFuncPtr()) + pTabView->GetDrawFuncPtr()->Activate(); + + rReq.Done(); + + rBindings.Invalidate( SID_INSERT_DRAW ); + rBindings.Invalidate( SID_CHOOSE_CONTROLS ); + + rBindings.Update( SID_INSERT_DRAW ); + rBindings.Update( SID_CHOOSE_CONTROLS ); +} + +void ScTabViewShell::GetDrawState(SfxItemSet &rSet) +{ + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + + while ( nWhich ) + { + switch ( nWhich ) + { + case SID_INSERT_DRAW: + { + // SID_OBJECT_SELECT nur, wenn "harter" Selektionsmodus + USHORT nPutId = nDrawSfxId; + if ( nPutId == SID_OBJECT_SELECT && !IsDrawSelMode() ) + nPutId = USHRT_MAX; + // nur die Images, die auch auf dem Controller liegen + if ( nPutId != SID_OBJECT_SELECT && + nPutId != SID_DRAW_LINE && + nPutId != SID_DRAW_RECT && + nPutId != SID_DRAW_ELLIPSE && + nPutId != SID_DRAW_POLYGON_NOFILL && + nPutId != SID_DRAW_BEZIER_NOFILL && + nPutId != SID_DRAW_FREELINE_NOFILL && + nPutId != SID_DRAW_ARC && + nPutId != SID_DRAW_PIE && + nPutId != SID_DRAW_CIRCLECUT && + nPutId != SID_DRAW_TEXT && + nPutId != SID_DRAW_TEXT_MARQUEE && + nPutId != SID_DRAW_CAPTION ) + nPutId = USHRT_MAX; + SfxAllEnumItem aItem( nWhich, nPutId ); + rSet.Put( aItem ); + } + break; + case SID_CHOOSE_CONTROLS: + if (nCtrlSfxId != USHRT_MAX) + { + SfxAllEnumItem aItem( nWhich, nCtrlSfxId ); + rSet.Put( aItem ); + } + break; + + case SID_DRAW_CHART: + { + BOOL bOle = GetViewFrame()->ISA(SfxInPlaceFrame); + if ( bOle || !SFX_APP()->HasFeature(SFX_FEATURE_SCHART) ) + rSet.DisableItem( nWhich ); + } + break; + + case SID_OBJECT_SELECT: // wichtig fuer den ollen Control-Controller + rSet.Put( SfxBoolItem( nWhich, nDrawSfxId == SID_OBJECT_SELECT && IsDrawSelMode() ) ); + break; + } + nWhich = aIter.NextWhich(); + } +} + +BOOL ScTabViewShell::SelectObject( const String& rName ) +{ + ScDrawView* pView = GetViewData()->GetScDrawView(); + if (!pView) + return FALSE; + + BOOL bFound = pView->SelectObject( rName ); + // DrawShell etc. is handled in MarkListHasChanged + + return bFound; +} + + + diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx new file mode 100644 index 000000000000..dd8848603a3d --- /dev/null +++ b/sc/source/ui/view/tabvwsh3.cxx @@ -0,0 +1,1005 @@ +/************************************************************************* + * + * $RCSfile: tabvwsh3.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <svx/zoom.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/passwd.hxx> +#include <sfx2/request.hxx> +#include <sfx2/topfrm.hxx> +#include <svtools/ptitem.hxx> +#include <svtools/stritem.hxx> + +#ifdef VCL /* Comp.- Mode */ +#include <vcl/msgbox.hxx> +#include <vcl/fonttype.hxx> +#else +#include <vcl/msgbox.hxx> +#include <vcl/gdiobj.hxx> +#endif + +#include "globstr.hrc" +#include "scmod.hxx" +#include "appoptio.hxx" +#include "tabvwsh.hxx" +#include "document.hxx" +#include "sc.hrc" +#include "inputwin.hxx" +#include "scresid.hxx" +#include "printfun.hxx" +#include "docsh.hxx" +#include "rangelst.hxx" +#include "prevwsh.hxx" +#include "rangeutl.hxx" +#include "reffact.hxx" +#include "uiitems.hxx" +#include "cell.hxx" +#include "inputhdl.hxx" +#include "scendlg.hxx" +#include "mtrindlg.hxx" +#include "autoform.hxx" +#include "autofmt.hxx" +#include "dwfunctr.hxx" + +#define IS_EDITMODE() GetViewData()->HasEditView( GetViewData()->GetActivePart() ) +#define IS_AVAILABLE(WhichId,ppItem) \ + (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET) +#define GET_STRING(nid) ((const SfxStringItem&)pReqArgs->Get(nid)).GetValue() +#define GET_UINT16(nid) ((const SfxUInt16Item&)pReqArgs->Get(nid)).GetValue() +#define RECALC_PAGE(pDocSh) ScPrintFunc( pDocSh, GetPrinter(), nCurTab ).UpdatePages() + +//------------------------------------------------------------------ + +void ScTabViewShell::Execute( SfxRequest& rReq ) +{ + SfxViewFrame* pThisFrame = GetViewFrame(); + SfxBindings& rBindings = pThisFrame->GetBindings(); + SfxApplication* pSfxApp = SFX_APP(); + ScModule* pScMod = SC_MOD(); + const SfxItemSet* pReqArgs = rReq.GetArgs(); + USHORT nSlot = rReq.GetSlot(); + + if (nSlot != SID_CURRENTCELL) // der kommt beim MouseButtonUp + HideListBox(); // Autofilter-DropDown-Listbox + + switch ( nSlot ) + { + case FID_INSERT_FILE: + { + const SfxPoolItem* pItem; + if ( pReqArgs && + pReqArgs->GetItemState(FID_INSERT_FILE,TRUE,&pItem) == SFX_ITEM_SET ) + { + String aFileName = ((const SfxStringItem*)pItem)->GetValue(); + + // Einfuege-Position + + Point aInsertPos; + if ( pReqArgs->GetItemState(FN_PARAM_1,TRUE,&pItem) == SFX_ITEM_SET ) + aInsertPos = ((const SfxPointItem*)pItem)->GetValue(); + else + aInsertPos = GetInsertPos(); + + // als Link? + + BOOL bAsLink = FALSE; + if ( pReqArgs->GetItemState(FN_PARAM_2,TRUE,&pItem) == SFX_ITEM_SET ) + bAsLink = ((const SfxBoolItem*)pItem)->GetValue(); + + // ausfuehren + + PasteFile( aInsertPos, aFileName, bAsLink ); + } + } + break; + + case SID_OPENDLG_EDIT_PRINTAREA: + { + USHORT nId = ScPrintAreasDlgWrapper::GetChildWindowId(); + SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId ); + + pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE ); + } + break; + + case SID_CHANGE_PRINTAREA: + { + if ( pReqArgs ) // OK aus Dialog + { + String aPrintStr = GET_STRING( SID_CHANGE_PRINTAREA ); + String aRowStr = GET_STRING( FN_PARAM_2 ); + String aColStr = GET_STRING( FN_PARAM_3 ); + + SetPrintRanges( &aPrintStr, &aColStr, &aRowStr, FALSE ); + + rReq.Done(); + } + } + break; + + case SID_ADD_PRINTAREA: + case SID_DEFINE_PRINTAREA: // Menue oder Basic + { + BOOL bAdd = ( nSlot == SID_ADD_PRINTAREA ); + if ( pReqArgs ) + { + String aPrintStr = GET_STRING( SID_DEFINE_PRINTAREA ); + SetPrintRanges( &aPrintStr, NULL, NULL, bAdd ); + } + else + { + SetPrintRanges( NULL, NULL, NULL, bAdd ); // aus Selektion + rReq.Done(); + } + } + break; + + case SID_DELETE_PRINTAREA: + { + String aEmpty; + SetPrintRanges( &aEmpty, NULL, NULL, FALSE ); // Druckbereich loeschen + rReq.Done(); + } + break; + + case FID_DEL_MANUALBREAKS: + RemoveManualBreaks(); + rReq.Done(); + break; + + case FID_ADJUST_PRINTZOOM: + AdjustPrintZoom(); + rReq.Done(); + break; + + case FID_RESET_PRINTZOOM: + SetPrintZoom( 100, 0 ); // 100%, nicht auf Seiten + rReq.Done(); + break; + + case SID_FORMATPAGE: + case SID_STATUS_PAGESTYLE: + case SID_HFEDIT: + GetViewData()->GetDocShell()-> + ExecutePageStyle( *this, rReq, GetViewData()->GetTabNo() ); + break; + + case SID_JUMPTOMARK: + case SID_CURRENTCELL: + if ( pReqArgs ) + { + String aAddress; + const SfxPoolItem* pItem; + if ( pReqArgs->GetItemState( nSlot, TRUE, &pItem ) == SFX_ITEM_SET ) + aAddress = ((const SfxStringItem*)pItem)->GetValue(); + else if ( nSlot == SID_JUMPTOMARK && pReqArgs->GetItemState( + ID_VAL_DUMMY0, TRUE, &pItem ) == SFX_ITEM_SET ) + aAddress = ((const SfxStringItem*)pItem)->GetValue(); + // SID_JUMPTOMARK steht in der IDL mit ID_VAL_DUMMY0 als Parameter + + BOOL bUnmark = FALSE; + if ( pReqArgs->GetItemState( FN_PARAM_1, TRUE, &pItem ) == SFX_ITEM_SET ) + bUnmark = ((const SfxBoolItem*)pItem)->GetValue(); + + BOOL bFound = FALSE; + ScViewData* pViewData = GetViewData(); + ScDocument* pDoc = pViewData->GetDocument(); + ScMarkData& rMark = pViewData->GetMarkData(); + ScRange aScRange; + ScAddress aScAddress; + USHORT nResult = aScRange.Parse( aAddress, pDoc ); + USHORT nTab = pViewData->GetTabNo(); + BOOL bMark = TRUE; + + // Ist es ein Bereich ? + if( nResult & SCA_VALID ) + { + if ( nResult & SCA_TAB_3D ) + { + if( aScRange.aStart.Tab() != nTab ) + SetTabNo( nTab = aScRange.aStart.Tab() ); + } + else + { + aScRange.aStart.SetTab( nTab ); + aScRange.aEnd.SetTab( nTab ); + } + } + // Ist es eine Zelle ? + else if( (nResult=aScAddress.Parse( aAddress, pDoc )) & SCA_VALID ) + { + if ( nResult & SCA_TAB_3D ) + { + if( aScAddress.Tab() != nTab ) + SetTabNo( nTab = aScAddress.Tab() ); + } + else + aScAddress.SetTab( nTab ); + + aScRange = ScRange( aScAddress, aScAddress ); + // Zellen sollen nicht markiert werden + bMark = FALSE; + } + // Ist es benahmster Bereich (erst Namen dann DBBereiche) ? + else + { + ScRangeUtil aRangeUtil; + if( aRangeUtil.MakeRangeFromName( aAddress, pDoc, nTab, aScRange, RUTL_NAMES ) || + aRangeUtil.MakeRangeFromName( aAddress, pDoc, nTab, aScRange, RUTL_DBASE ) ) + { + nResult |= SCA_VALID; + if( aScRange.aStart.Tab() != nTab ) + SetTabNo( nTab = aScRange.aStart.Tab() ); + } + } + + if ( !(nResult & SCA_VALID) && + ByteString(aAddress, RTL_TEXTENCODING_ASCII_US).IsNumericAscii() ) + { + sal_Int32 nNumeric = aAddress.ToInt32(); + if ( nNumeric > 0 && nNumeric <= MAXROW+1 ) + { + // 1-basierte Zeilennummer + + aScAddress.SetRow( (USHORT)(nNumeric - 1) ); + aScAddress.SetCol( pViewData->GetCurX() ); + aScAddress.SetTab( nTab ); + aScRange = ScRange( aScAddress, aScAddress ); + bMark = FALSE; + nResult = SCA_VALID; + } + } + + if ( aScRange.aStart.Row() > MAXROW || aScRange.aEnd.Row() > MAXROW ) + nResult = 0; + + // wir haben was gefunden + if( nResult & SCA_VALID ) + { + bFound = TRUE; + USHORT nCol = aScRange.aStart.Col(); + USHORT nRow = aScRange.aStart.Row(); + BOOL bNothing = ( pViewData->GetCurX()==nCol && pViewData->GetCurY()==nRow ); + + // markieren + if( bMark ) + { + if (rMark.IsMarked()) // ist derselbe Bereich schon markiert? + { + ScRange aOldMark; + rMark.GetMarkArea( aOldMark ); + aOldMark.Justify(); + ScRange aCurrent = aScRange; + aCurrent.Justify(); + bNothing = ( aCurrent == aOldMark ); + } + else + bNothing = FALSE; + + if (!bNothing) + MarkRange( aScRange, FALSE ); // Cursor kommt hinterher... + } + else + { + // aus dem Navigator die Selektion nur aufheben, wenn Parameter da + if( rReq.IsAPI() || bUnmark ) + { + MoveCursorAbs( nCol, nRow, + SC_FOLLOW_NONE, FALSE, FALSE ); + } + } + + // und Cursor setzen + + // zusammengefasste Zellen beruecksichtigen: + while ( pDoc->IsHorOverlapped( nCol, nRow, nTab ) ) //! ViewData !!! + --nCol; + while ( pDoc->IsVerOverlapped( nCol, nRow, nTab ) ) + --nRow; + + // Navigator-Aufrufe sind nicht API!!! + + if( bNothing ) + { + if (rReq.IsAPI()) + rReq.Ignore(); // wenn Makro, dann gar nix + else + rReq.Done(); // sonst wenigstens aufzeichnen + } + else + { + pViewData->ResetOldCursor(); + SetCursor( nCol, nRow ); + AlignToCursor( nCol, nRow, SC_FOLLOW_JUMP ); + rBindings.Invalidate( SID_CURRENTCELL ); + rBindings.Update( nSlot ); + + if (!rReq.IsAPI()) + rReq.Done(); + } + + rReq.SetReturnValue( SfxStringItem( SID_CURRENTCELL, aAddress ) ); + } + + if (!bFound) // kein gueltiger Bereich + { + // wenn es ein Tabellenname ist, umschalten (fuer Navigator/URL's) + + USHORT nNameTab; + if ( pDoc->GetTable( aAddress, nNameTab ) ) + { + bFound = TRUE; + if ( nNameTab != nTab ) + SetTabNo( nNameTab ); + } + } + + if ( !bFound && nSlot == SID_JUMPTOMARK ) + { + // Grafik-Objekte probieren (nur bei URL's) + + bFound = SelectObject( aAddress ); + } + + if (!bFound && !rReq.IsAPI()) + ErrorMessage( STR_ERR_INVALID_AREA ); + } + break; + + case SID_CURRENTOBJECT: + if ( pReqArgs ) + { + String aName = ((const SfxStringItem&)pReqArgs->Get(nSlot)).GetValue(); + SelectObject( aName ); + } + break; + + case SID_CURRENTTAB: + if ( pReqArgs ) + { + // Tabelle fuer Basic ist 1-basiert + USHORT nTab = ((const SfxUInt16Item&)pReqArgs->Get(nSlot)).GetValue() - 1; + ScDocument* pDoc = GetViewData()->GetDocument(); + if ( nTab < pDoc->GetTableCount() ) + { + SetTabNo( nTab ); + rBindings.Update( nSlot ); + + if( ! rReq.IsAPI() ) + rReq.Done(); + } + //! sonst Fehler ? + } + break; + + case SID_CURRENTDOC: + if ( pReqArgs ) + { + String aStrDocName( ((const SfxStringItem&)pReqArgs-> + Get(nSlot)).GetValue() ); + + SfxViewFrame* pFrame = NULL; + ScDocShell* pDocSh = (ScDocShell*)SfxObjectShell::GetFirst(); + BOOL bFound = FALSE; + + // zu aktivierenden ViewFrame suchen + + while ( pDocSh && !bFound ) + { + if ( pDocSh->GetTitle() == aStrDocName ) + { + pFrame = SfxViewFrame::GetFirst( pDocSh, TYPE(SfxTopViewFrame) ); + bFound = ( NULL != pFrame ); + } + + pDocSh = (ScDocShell*)SfxObjectShell::GetNext( *pDocSh ); + } + + if ( bFound ) + if ( pFrame->ISA(SfxTopViewFrame) ) + pFrame->GetFrame()->Appear(); + + rReq.Ignore();//XXX wird von SFX erledigt + } + + case SID_ATTR_SIZE://XXX ??? + break; + + + case SID_PRINTPREVIEW: + { + if ( !pThisFrame->ISA( SfxInPlaceFrame ) ) // nicht bei OLE + { + // print preview is now always in the same frame as the tab view + // -> always switch this frame back to normal view + // (ScPreviewShell ctor reads view data) + + pThisFrame->GetBindings().Execute( SID_VIEWSHELL1, + NULL, 0, SFX_CALLMODE_ASYNCHRON ); + } + // else Fehler (z.B. Ole) + } + break; + + case SID_DETECTIVE_DEL_ALL: + DetectiveDelAll(); + rReq.Done(); + break; + + // SID_TABLE_ACTIVATE und SID_MARKAREA werden von Basic aus an der versteckten + // View aufgerufen, um auf der sichtbaren View zu markieren/umzuschalten: + + case SID_TABLE_ACTIVATE: + DBG_ERROR("old slot SID_TABLE_ACTIVATE"); + break; + + case SID_REPAINT: + PaintGrid(); + PaintTop(); + PaintLeft(); + PaintExtras(); + rReq.Done(); + break; + + case FID_PAGEBREAKMODE: + { + BOOL bSet = !GetViewData()->IsPagebreakMode(); + const SfxPoolItem* pItem; + if ( pReqArgs && pReqArgs-> + GetItemState(FID_PAGEBREAKMODE, TRUE, &pItem) == SFX_ITEM_SET ) + bSet = ((const SfxBoolItem*)pItem)->GetValue(); + SetPagebreakMode( bSet ); + UpdatePageBreakData(); + SetCurSubShell( GetCurObjectSelectionType(), TRUE ); + PaintGrid(); + PaintTop(); + PaintLeft(); + rBindings.Invalidate( FID_PAGEBREAKMODE ); + rReq.Done(); + } + break; + + case FID_FUNCTION_BOX: + { + if ( rReq.GetArgs() ) + pThisFrame->SetChildWindow(ScFunctionChildWindow::GetChildWindowId(), + ((const SfxBoolItem&) (rReq.GetArgs()-> + Get(FID_FUNCTION_BOX))).GetValue()); + else + pThisFrame->ToggleChildWindow(ScFunctionChildWindow::GetChildWindowId() ); + + SFX_BINDINGS().Invalidate(FID_FUNCTION_BOX); + rReq.Done (); + } + break; + + + case FID_TOGGLESYNTAX: + { + BOOL bSet = !GetViewData()->IsSyntaxMode(); + const SfxPoolItem* pItem; + if ( pReqArgs && pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET ) + bSet = ((const SfxBoolItem*)pItem)->GetValue(); + GetViewData()->SetSyntaxMode( bSet ); + PaintGrid(); + rBindings.Invalidate( FID_TOGGLESYNTAX ); + rReq.Done(); + } + break; + case FID_TOGGLEHEADERS: + { + BOOL bSet = !GetViewData()->IsHeaderMode(); + const SfxPoolItem* pItem; + if ( pReqArgs && pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET ) + bSet = ((const SfxBoolItem*)pItem)->GetValue(); + GetViewData()->SetHeaderMode( bSet ); + RepeatResize(); + rBindings.Invalidate( FID_TOGGLEHEADERS ); + rReq.Done(); + } + break; + case FID_TOGGLEINPUTLINE: + { + USHORT nId = ScInputWindowWrapper::GetChildWindowId(); + SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId ); + BOOL bSet = ( pWnd == NULL ); + const SfxPoolItem* pItem; + if ( pReqArgs && pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET ) + bSet = ((const SfxBoolItem*)pItem)->GetValue(); + + pThisFrame->SetChildWindow( nId, bSet ); + + rBindings.Invalidate( FID_TOGGLEINPUTLINE ); + } + break; + + case SID_ATTR_ZOOM: // Statuszeile + case FID_SCALE: + { + SvxZoomType eOldZoomType = GetZoomType(); + SvxZoomType eZoomType = eOldZoomType; + const Fraction& rOldY = GetViewData()->GetZoomY(); // Y wird angezeigt + USHORT nOldZoom = (USHORT)(( rOldY.GetNumerator() * 100 ) + / rOldY.GetDenominator()); + USHORT nZoom = nOldZoom; + BOOL bCancel = FALSE; + + if ( pReqArgs ) + { + const SvxZoomItem& rZoomItem = (const SvxZoomItem&) + pReqArgs->Get(SID_ATTR_ZOOM); + + eZoomType = rZoomItem.GetType(); + nZoom = rZoomItem.GetValue(); + } + else + { + SfxItemSet aSet ( GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM ); + SvxZoomItem aZoomItem( eOldZoomType, nOldZoom, SID_ATTR_ZOOM ); + SvxZoomDialog* pDlg = NULL; + ScMarkData& rMark = GetViewData()->GetMarkData(); + USHORT nBtnFlags = SVX_ZOOM_ENABLE_50 + | SVX_ZOOM_ENABLE_75 + | SVX_ZOOM_ENABLE_100 + | SVX_ZOOM_ENABLE_150 + | SVX_ZOOM_ENABLE_200 + | SVX_ZOOM_ENABLE_WHOLEPAGE + | SVX_ZOOM_ENABLE_PAGEWIDTH; + + if ( rMark.IsMarked() ) + nBtnFlags = nBtnFlags | SVX_ZOOM_ENABLE_OPTIMAL; + + aZoomItem.SetValueSet( nBtnFlags ); + aSet.Put( aZoomItem ); + pDlg = new SvxZoomDialog( GetDialogParent(), aSet ); + pDlg->SetLimits( MINZOOM, MAXZOOM ); + + bCancel = ( RET_CANCEL == pDlg->Execute() ); + + if ( !bCancel ) + { + const SvxZoomItem& rZoomItem = (const SvxZoomItem&) + pDlg->GetOutputItemSet()-> + Get( SID_ATTR_ZOOM ); + + eZoomType = rZoomItem.GetType(); + nZoom = rZoomItem.GetValue(); + } + + delete pDlg; + } + + if ( !bCancel ) + { + if ( eZoomType == SVX_ZOOM_PERCENT ) + { + if ( nZoom < MINZOOM ) nZoom = MINZOOM; + if ( nZoom > MAXZOOM ) nZoom = MAXZOOM; + } + else + { + nZoom = CalcZoom( eZoomType, nOldZoom ); + bCancel = nZoom == 0; + } + + switch ( eZoomType ) + { + case SVX_ZOOM_WHOLEPAGE: + case SVX_ZOOM_PAGEWIDTH: + SetZoomType( eZoomType ); + break; + + default: + SetZoomType( SVX_ZOOM_PERCENT ); + } + } + + if ( nZoom != nOldZoom && !bCancel ) + { + if (!GetViewData()->IsPagebreakMode()) + { + ScModule* pScMod = SC_MOD(); + ScAppOptions aNewOpt = pScMod->GetAppOptions(); + aNewOpt.SetZoom( nZoom ); + aNewOpt.SetZoomType( GetZoomType() ); + pScMod->SetAppOptions( aNewOpt ); + } + Fraction aFract( nZoom, 100 ); + SetZoom( aFract, aFract ); + PaintGrid(); + PaintTop(); + PaintLeft(); + rBindings.Invalidate( SID_ATTR_ZOOM ); + rReq.Done(); + } + } + break; + + case SID_OPENDLG_MODCHART: + { + bChartDlgIsEdit = ( nSlot == SID_OPENDLG_MODCHART ); + if (bChartDlgIsEdit) + { + aEditChartName = GetSelectedChartName(); + DrawDeselectAll(); // flackert sonst bei Ref-Input + } + + ResetChartArea(); + + USHORT nId = ScChartDlgWrapper::GetChildWindowId(); + SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId ); + + pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE ); + } + break; + + + + //---------------------------------------------------------------- + + case FID_TAB_SELECTALL: + SelectAllTables(); + rReq.Done(); + break; + + + + case SID_OUTLINE_DELETEALL: + RemoveAllOutlines(); + rReq.Done(); + break; + + case SID_AUTO_OUTLINE: + AutoOutline(); + rReq.Done(); + break; + + + case SID_WINDOW_SPLIT: + { + ScSplitMode eHSplit = GetViewData()->GetHSplitMode(); + ScSplitMode eVSplit = GetViewData()->GetVSplitMode(); + if ( eHSplit == SC_SPLIT_NORMAL || eVSplit == SC_SPLIT_NORMAL ) // aufheben + RemoveSplit(); + else if ( eHSplit == SC_SPLIT_FIX || eVSplit == SC_SPLIT_FIX ) // normal + FreezeSplitters( FALSE ); + else // erzeugen + SplitAtCursor(); + rReq.Done(); + + InvalidateSplit(); + } + break; + + case SID_WINDOW_FIX: + { + ScSplitMode eHSplit = GetViewData()->GetHSplitMode(); + ScSplitMode eVSplit = GetViewData()->GetVSplitMode(); + if ( eHSplit == SC_SPLIT_FIX || eVSplit == SC_SPLIT_FIX ) // aufheben + RemoveSplit(); + else + FreezeSplitters( TRUE ); // erzeugen oder fixieren + rReq.Done(); + + InvalidateSplit(); + } + break; + + // ---------------------------------------------------------------- + + case FID_CHG_SHOW: + { + USHORT nId = ScHighlightChgDlgWrapper::GetChildWindowId(); + SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId ); + + pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE ); + } + break; + + case FID_CHG_ACCEPT: + { + pThisFrame->ToggleChildWindow(ScAcceptChgDlgWrapper::GetChildWindowId()); + SFX_BINDINGS().Invalidate(FID_CHG_ACCEPT); + rReq.Done (); + + /* + USHORT nId = ScAcceptChgDlgWrapper::GetChildWindowId(); + SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId ); + + pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE ); + */ + } + break; + + case FID_CHG_COMMENT: + { + ScViewData* pData = GetViewData(); + ScAddress aCursorPos( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() ); + ScDocShell* pDocSh = pData->GetDocShell(); + + ScChangeAction* pAction = pDocSh->GetChangeAction( aCursorPos ); + if ( pAction ) + { + const SfxPoolItem* pItem; + if ( pReqArgs && + pReqArgs->GetItemState( nSlot, TRUE, &pItem ) == SFX_ITEM_SET && + pItem->ISA( SfxStringItem ) ) + { + String aComment = ((const SfxStringItem*)pItem)->GetValue(); + pDocSh->SetChangeComment( pAction, aComment ); + rReq.Done(); + } + else + { + pDocSh->ExecuteChangeCommentDialog( pAction, GetDialogParent() ); + rReq.Done(); + } + } + } + break; + + case SID_CREATE_SW_DRAWVIEW: + // wird von den Forms gerufen, wenn die DrawView mit allem Zubehoer + // angelegt werden muss + if (!GetScDrawView()) + { + GetViewData()->GetDocShell()->MakeDrawLayer(); + rBindings.InvalidateAll(FALSE); + } + break; + + case SID_STATUS_DOCPOS: + { + //! Navigator an-/ausschalten (wie im Writer) ??? + //!SFX_DISPATCHER().Execute( SID_NAVIGATOR, + //! SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD ); + } + break; + + case FID_PROTECT_DOC: + { + ScDocument* pDoc = GetViewData()->GetDocument(); + SfxPasswordDialog* pDlg; + + if (pDoc->IsDocProtected()) + { + BOOL bCancel = FALSE; + String aPassword; + + if (pDoc->GetDocPassword().Len()) + { + String aText( ScResId(SCSTR_PASSWORD) ); + + pDlg = new SfxPasswordDialog( GetDialogParent(), &aText ); + pDlg->SetText( ScResId(SCSTR_UNPROTECTDOC) ); + pDlg->SetMinLen( 0 ); + pDlg->SetHelpId( FID_PROTECT_DOC ); + pDlg->SetEditHelpId( HID_PASSWD_DOC ); + + if (pDlg->Execute() == RET_OK) + aPassword = pDlg->GetPassword(); + else + bCancel = TRUE; + delete pDlg; + } + if (!bCancel) + { + Unprotect( TABLEID_DOC, aPassword ); + rReq.Done(); + } + } + else + { + String aText( ScResId(SCSTR_PASSWORDOPT) ); + + pDlg = new SfxPasswordDialog( GetDialogParent(), &aText ); + pDlg->SetText( ScResId(SCSTR_PROTECTDOC) ); + pDlg->SetMinLen( 0 ); + pDlg->SetHelpId( FID_PROTECT_DOC ); + pDlg->SetEditHelpId( HID_PASSWD_DOC ); + pDlg->ShowExtras( SHOWEXTRAS_CONFIRM ); + + if (pDlg->Execute() == RET_OK) + { + String aPassword = pDlg->GetPassword(); + BOOL bOk = FALSE; + + if ( aPassword.Len() ) + { + // compare strings + if ( aPassword == pDlg->GetConfirm() ) + bOk = TRUE; + else + { + InfoBox aBox( GetDialogParent(), + String( ScResId( SCSTR_WRONGPASSWORD ) ) ); + aBox.Execute(); + } + } + else + bOk = TRUE; // ohne Passwort + + if (bOk) + { + Protect( TABLEID_DOC, aPassword ); + rReq.Done(); + } + } + + delete pDlg; + } + rBindings.Invalidate( FID_PROTECT_DOC ); + } + break; + + + case FID_PROTECT_TABLE: + { + ScDocument* pDoc = GetViewData()->GetDocument(); + USHORT nTab = GetViewData()->GetTabNo(); + SfxPasswordDialog* pDlg; + String aPassword; + BOOL bCancel = FALSE; + BOOL bOldProtection = pDoc->IsTabProtected(nTab); + BOOL bNewProtection = ! bOldProtection; + + if( pReqArgs ) + { + const SfxPoolItem* pItem; + if( IS_AVAILABLE( FN_PARAM_1, &pItem ) ) + aPassword = ((const SfxStringItem*)pItem)->GetValue(); + if( IS_AVAILABLE( FID_PROTECT_TABLE, &pItem ) ) + bNewProtection = ((const SfxBoolItem*)pItem)->GetValue(); + } + + if( ! rReq.IsAPI() ) + { + if (bOldProtection) + { + if (pDoc->GetTabPassword(nTab).Len()) + { + String aText( ScResId(SCSTR_PASSWORD) ); + + pDlg = new SfxPasswordDialog( GetDialogParent(), &aText ); + pDlg->SetText( ScResId(SCSTR_UNPROTECTTAB) ); + pDlg->SetMinLen( 0 ); + pDlg->SetHelpId( FID_PROTECT_TABLE ); + pDlg->SetEditHelpId( HID_PASSWD_TABLE ); + + if (pDlg->Execute() == RET_OK) + aPassword = pDlg->GetPassword(); + else + bCancel = TRUE; + + delete pDlg; + } + } + else + { + String aText( ScResId(SCSTR_PASSWORDOPT) ); + + pDlg = new SfxPasswordDialog( GetDialogParent(), &aText ); + pDlg->SetText( ScResId(SCSTR_PROTECTTAB) ); + pDlg->SetMinLen( 0 ); + pDlg->SetHelpId( FID_PROTECT_TABLE ); + pDlg->SetEditHelpId( HID_PASSWD_TABLE ); + pDlg->ShowExtras( SHOWEXTRAS_CONFIRM ); + + if (pDlg->Execute() == RET_OK) + { + aPassword = pDlg->GetPassword(); + if ( aPassword.Len() ) + { + // compare strings + if ( aPassword != pDlg->GetConfirm() ) + { + InfoBox aBox( GetDialogParent(), + String( ScResId( SCSTR_WRONGPASSWORD ) ) ); + aBox.Execute(); + bCancel = TRUE; + } + } + } + else + bCancel = TRUE; + + delete pDlg; + } + } + + if( ! bCancel && bNewProtection!=bOldProtection ) + { + if ( bOldProtection ) + Unprotect( nTab, aPassword ); + else + Protect( nTab, aPassword ); + + if( ! rReq.IsAPI() ) + { + rReq.AppendItem( SfxBoolItem( FID_PROTECT_TABLE, bNewProtection ) ); + rReq.AppendItem( SfxStringItem( FN_PARAM_1, aPassword ) ); + rReq.Done(); + } + } + + TabChanged(); + UpdateInputHandler(TRUE); // damit sofort wieder eingegeben werden kann + SelectionChanged(); + } + break; + + default: + DBG_ERROR("Unbekannter Slot bei ScTabViewShell::Execute"); + break; + } +} + + + diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx new file mode 100644 index 000000000000..ea6305982f0a --- /dev/null +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -0,0 +1,1700 @@ +/************************************************************************* + * + * $RCSfile: tabvwsh4.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include <sfx2/topfrm.hxx> +#include "scitems.hxx" +#include <svx/boxitem.hxx> +#include <svx/fmshell.hxx> +#include <svx/sizeitem.hxx> +#include <svx/boxitem.hxx> +#include <svx/prtqry.hxx> +#include <sfx2/request.hxx> +#include <sfx2/dispatch.hxx> +#include <svtools/printdlg.hxx> +#include <svtools/whiter.hxx> + +#ifndef _URLOBJ_HXX //autogen +#include <tools/urlobj.hxx> +#endif +#ifndef _SFXDOCFILE_HXX //autogen +#include <sfx2/docfile.hxx> +#endif + +#include "tabvwsh.hxx" +#include "sc.hrc" +#include "globstr.hrc" +#include "stlpool.hxx" +#include "stlsheet.hxx" +#include "docsh.hxx" +#include "scmod.hxx" +#include "appoptio.hxx" +#include "rangeutl.hxx" +#include "printfun.hxx" +#include "drawsh.hxx" +#include "drformsh.hxx" +#include "editsh.hxx" +#include "pivotsh.hxx" +#include "auditsh.hxx" +#include "drtxtob.hxx" +#include "inputhdl.hxx" +#include "editutil.hxx" +#include "inputopt.hxx" +#include "inputwin.hxx" +#include "scresid.hxx" +#include "dbcolect.hxx" // fuer ReImport +#include "reffact.hxx" +#include "viewuno.hxx" +#include "anyrefdg.hxx" +#include "chgtrack.hxx" +#include "cellsh.hxx" +#include "oleobjsh.hxx" +#include "chartsh.hxx" +#include "graphsh.hxx" +#include "pgbrksh.hxx" +#include "dpobject.hxx" +#include "prevwsh.hxx" + + +void ActivateOlk( ScViewData* pViewData ); +void DeActivateOlk( ScViewData* pViewData ); + +extern SfxViewShell* pScActiveViewShell; // global.cxx + +using namespace com::sun::star; + +// STATIC DATA ----------------------------------------------------------- + +USHORT ScTabViewShell::nInsertCtrlState = SID_INSERT_GRAPHIC; +USHORT ScTabViewShell::nInsCellsCtrlState = 0; +USHORT ScTabViewShell::nInsObjCtrlState = SID_DRAW_CHART; + +// ----------------------------------------------------------------------- + +void __EXPORT ScTabViewShell::Activate(BOOL bMDI) +{ + SfxViewShell::Activate(bMDI); + + // hier kein GrabFocus, sonst gibt's Probleme wenn etwas inplace editiert wird! + + if ( bMDI ) + { + // fuer Eingabezeile (ClearCache) + ScModule* pScMod = SC_MOD(); + pScMod->ViewShellChanged(); + + ActivateView( TRUE, bFirstActivate ); + ActivateOlk( GetViewData() ); + + // #56870# AutoCorrect umsetzen, falls der Writer seins neu angelegt hat + UpdateDrawTextOutliner(); + + // RegisterNewTargetNames gibts nicht mehr + + SfxViewFrame* pThisFrame = GetViewFrame(); + if ( pInputHandler && pThisFrame->HasChildWindow(FID_INPUTLINE_STATUS) ) + { + // eigentlich nur beim Reload (letzte Version) noetig: + // Das InputWindow bleibt stehen, aber die View mitsamt InputHandler wird + // neu angelegt, darum muss der InputHandler am InputWindow gesetzt werden. + SfxChildWindow* pChild = pThisFrame->GetChildWindow(FID_INPUTLINE_STATUS); + if (pChild) + { + ScInputWindow* pWin = (ScInputWindow*)pChild->GetWindow(); + if (pWin && pWin->IsVisible()) + { + + ScInputHandler* pOldHdl=pWin->GetInputHandler(); + + TypeId aScType = TYPE(ScTabViewShell); + + SfxViewShell* pSh = SfxViewShell::GetFirst( &aScType ); + while ( pSh!=NULL && pOldHdl!=NULL) + { + if (((ScTabViewShell*)pSh)->GetInputHandler() == pOldHdl) + { + pOldHdl->ResetDelayTimer(); + break; + } + pSh = SfxViewShell::GetNext( *pSh, &aScType ); + } + + pWin->SetInputHandler( pInputHandler ); + } + } + } + + UpdateInputHandler( TRUE ); + + if ( bFirstActivate ) + { + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_NAVIGATOR_UPDATEALL ) ); + bFirstActivate = FALSE; + } + + pScActiveViewShell = this; + + ScInputHandler* pHdl = pScMod->GetInputHdl(this); + if (pHdl) + { + pHdl->SetRefScale( GetViewData()->GetZoomX(), GetViewData()->GetZoomY() ); + } + + // Aenderungs-Dialog aktualisieren + + if ( pThisFrame->HasChildWindow(FID_CHG_ACCEPT) ) + { + SfxChildWindow* pChild = pThisFrame->GetChildWindow(FID_CHG_ACCEPT); + if (pChild) + { + ((ScAcceptChgDlgWrapper*)pChild)->ReInitDlg(); + } + } + + if(pScMod->IsRefDialogOpen()) + { + USHORT nCurRefDlgId=pScMod->GetCurRefDlgId(); + SfxChildWindow* pChildWnd = pThisFrame->GetChildWindow( nCurRefDlgId ); + if ( pChildWnd ) + { + ScAnyRefDlg* pRefDlg = (ScAnyRefDlg*)pChildWnd->GetWindow(); + pRefDlg->ViewShellChanged(this); + } + } + } + + // Wenn Referenzeingabe-Tip-Hilfe hier wieder angezeigt werden soll (ShowRefTip), + // muss sie beim Verschieben der View angepasst werden (gibt sonst Probleme unter OS/2 + // beim Umschalten zwischen Dokumenten) +} + +void __EXPORT ScTabViewShell::Deactivate(BOOL bMDI) +{ + HideTip(); + + ScDocument* pDoc=GetViewData()->GetDocument(); + + ScChangeTrack* pChanges=pDoc->GetChangeTrack(); + + if(pChanges!=NULL) + { + Link aLink; + pChanges->SetModifiedLink(aLink); + } + + SfxViewShell::Deactivate(bMDI); + + ScInputHandler* pHdl = SC_MOD()->GetInputHdl(this); + + if( bMDI ) + { + DeActivateOlk( GetViewData() ); + ActivateView( FALSE, FALSE ); + + if ( GetViewFrame()->ISA(SfxInPlaceFrame) ) // inplace + GetViewData()->GetDocShell()->UpdateOle(GetViewData(),TRUE); + + if ( pHdl ) + pHdl->NotifyChange( NULL, TRUE ); // Timer-verzoegert wg. Dokumentwechsel + + if (pScActiveViewShell == this) + pScActiveViewShell = NULL; + } + else + { + HideNoteMarker(); // Notiz-Anzeige + + if ( pHdl ) + pHdl->HideTip(); // Formel-AutoEingabe-Tip abschalten + } +} + +void ScTabViewShell::SetActive() +{ + // Die Sfx-View moechte sich gerne selbst aktivieren, weil dabei noch + // magische Dinge geschehen (z.B. stuerzt sonst evtl. der Gestalter ab) + ActiveGrabFocus(); + +#if 0 + SfxViewFrame* pFrame = GetViewFrame(); + if ( pFrame->ISA(SfxTopViewFrame) ) + pFrame->GetFrame()->Appear(); + + SFX_APP()->SetViewFrame( pFrame ); // immer erst Appear, dann SetViewFrame (#29290#) +#endif +} + +USHORT __EXPORT ScTabViewShell::PrepareClose(BOOL bUI, BOOL bForBrowsing) +{ + if ( pFormShell ) + { + USHORT nRet = pFormShell->PrepareClose(bUI, bForBrowsing); + if (nRet!=TRUE) + return nRet; + } + return SfxViewShell::PrepareClose(bUI,bForBrowsing); +} + +//------------------------------------------------------------------ + +Size __EXPORT ScTabViewShell::GetOptimalSizePixel() const +{ + Size aOptSize; + + USHORT nCurTab = GetViewData()->GetTabNo(); + ScDocument* pDoc = GetViewData()->GetDocument(); + ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool(); + SfxStyleSheetBase* pStyleSheet = pStylePool->Find( + pDoc->GetPageStyle( nCurTab ), + SFX_STYLE_FAMILY_PAGE ); + + DBG_ASSERT( pStyleSheet, "PageStyle not found :-/" ); + + if ( pStyleSheet ) + { + const SfxItemSet& rSet = pStyleSheet->GetItemSet(); + const SvxSizeItem& rItem = (const SvxSizeItem&)rSet.Get( ATTR_PAGE_SIZE ); + const Size& rPageSize = rItem.GetSize(); + + aOptSize.Width() = (long) (rPageSize.Width() * GetViewData()->GetPPTX()); + aOptSize.Height() = (long) (rPageSize.Height() * GetViewData()->GetPPTY()); + } + + return aOptSize; +} + +//------------------------------------------------------------------ + +// Zoom fuer In-Place berechnen +// aus Verhaeltnis von VisArea und Fenstergroesse des GridWin + +void ScTabViewShell::UpdateOleZoom() +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ) + { + Size aObjSize = ((SfxInPlaceObject*)pDocSh)->GetVisArea().GetSize(); + Window* pWin = GetActiveWin(); + Size aWinHMM = pWin->PixelToLogic( pWin->GetOutputSizePixel(), MAP_100TH_MM ); + SetZoomFactor( Fraction( aWinHMM.Width(),aObjSize.Width() ), + Fraction( aWinHMM.Height(),aObjSize.Height() ) ); + } +} + +void __EXPORT ScTabViewShell::AdjustPosSizePixel( const Point &rPos, const Size &rSize ) +{ + OuterResizePixel( rPos, rSize ); +} + +void __EXPORT ScTabViewShell::InnerResizePixel( const Point &rOfs, const Size &rSize ) +{ + SvBorder aBorder; + GetBorderSize( aBorder, rSize ); + SetBorderPixel( aBorder ); + + Size aNewSize( rSize ); + aNewSize.Width() += aBorder.Left() + aBorder.Right(); + aNewSize.Height() += aBorder.Top() + aBorder.Bottom(); + + DoResize( rOfs, aNewSize, TRUE ); // rSize = Groesse von gridwin + + UpdateOleZoom(); // Zoom fuer In-Place berechnen + +// GetViewData()->GetDocShell()->UpdateOle( GetViewData() ); + GetViewData()->GetDocShell()->SetDocumentModified(); +} + +void __EXPORT ScTabViewShell::OuterResizePixel( const Point &rOfs, const Size &rSize ) +{ + SvBorder aBorder; + GetBorderSize( aBorder, rSize ); + SetBorderPixel( aBorder ); + + DoResize( rOfs, rSize ); // Position und Groesse von tabview wie uebergeben + + // ForceMove als Ersatz fuer den Sfx-Move-Mechanismus + // (aWinPos muss aktuell gehalten werden, damit ForceMove beim Ole-Deaktivieren klappt) + + ForceMove(); +} + +void __EXPORT ScTabViewShell::SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY ) +{ + // fuer OLE... + + Fraction aFrac20( 1,5 ); + Fraction aFrac400( 4,1 ); + + Fraction aNewX( rZoomX ); + if ( aNewX < aFrac20 ) + aNewX = aFrac20; + if ( aNewX > aFrac400 ) + aNewX = aFrac400; + Fraction aNewY( rZoomY ); + if ( aNewY < aFrac20 ) + aNewY = aFrac20; + if ( aNewY > aFrac400 ) + aNewY = aFrac400; + + GetViewData()->UpdateScreenZoom( aNewX, aNewY ); + SetZoom( aNewX, aNewY ); + + PaintGrid(); + PaintTop(); + PaintLeft(); + + SfxViewShell::SetZoomFactor( rZoomX, rZoomY ); +} + +void __EXPORT ScTabViewShell::QueryObjAreaPixel( Rectangle& rRect ) const +{ + // auf ganze Zellen anpassen (in 1/100 mm) + + Size aPixelSize = rRect.GetSize(); + Window* pWin = ((ScTabViewShell*)this)->GetActiveWin(); + Size aLogicSize = pWin->PixelToLogic( aPixelSize ); + + const ScViewData* pViewData = GetViewData(); + ScDocument* pDoc = pViewData->GetDocument(); + ScSplitPos ePos = pViewData->GetActivePart(); + USHORT nCol = pViewData->GetPosX(WhichH(ePos)); + USHORT nRow = pViewData->GetPosY(WhichV(ePos)); + USHORT nTab = pViewData->GetTabNo(); + Rectangle aLogicRect = pDoc->GetMMRect( nCol, nRow, nCol, nRow, nTab ); + aLogicRect.SetSize( aLogicSize ); + + pDoc->SnapVisArea( aLogicRect ); + + rRect.SetSize( pWin->LogicToPixel( aLogicRect.GetSize() ) ); + +#if 0 + // auf ganze Zellen anpassen (in Pixeln) + + ScViewData* pViewData = ((ScTabViewShell*)this)->GetViewData(); + Size aSize = rRect.GetSize(); + + ScSplitPos ePos = pViewData->GetActivePart(); + Window* pWin = ((ScTabViewShell*)this)->GetActiveWin(); + + Point aTest( aSize.Width(), aSize.Height() ); + short nPosX; + short nPosY; + pViewData->GetPosFromPixel( aTest.X(), aTest.Y(), ePos, nPosX, nPosY ); + BOOL bLeft; + BOOL bTop; + pViewData->GetMouseQuadrant( aTest, ePos, nPosX, nPosY, bLeft, bTop ); + if (!bLeft) + ++nPosX; + if (!bTop) + ++nPosY; + aTest = pViewData->GetScrPos( (USHORT)nPosX, (USHORT)nPosY, ePos, TRUE ); + + rRect.SetSize(Size(aTest.X(),aTest.Y())); +#endif +} + +//------------------------------------------------------------------ + +void __EXPORT ScTabViewShell::Move() +{ + Point aNewPos = GetViewFrame()->GetWindow().OutputToScreenPixel(Point()); + + if (aNewPos != aWinPos) + { + StopMarking(); + aWinPos = aNewPos; + } +} + +//------------------------------------------------------------------ + +void __EXPORT ScTabViewShell::ShowCursor(FASTBOOL bOn) +{ +/*!!! ShowCursor wird nicht paarweise wie im gridwin gerufen. + Der CursorLockCount am Gridwin muss hier direkt auf 0 gesetzt werden + + if (bOn) + ShowAllCursors(); + else + HideAllCursors(); +*/ +} + +//------------------------------------------------------------------ + +void __EXPORT ScTabViewShell::WriteUserData(String& rData, BOOL bBrowse) +{ + GetViewData()->WriteUserData(rData); +} + +void __EXPORT ScTabViewShell::ReadUserData(const String& rData, BOOL bBrowse) +{ + DoReadUserData( rData ); +} + +// DoReadUserData is also called from ctor when switching from print preview + +void ScTabViewShell::DoReadUserData( const String& rData ) +{ + Window* pOldWin = GetActiveWin(); + BOOL bFocus = pOldWin && pOldWin->HasFocus(); + + GetViewData()->ReadUserData(rData); + SetTabNo( GetViewData()->GetTabNo(), TRUE ); + + if ( GetViewData()->IsPagebreakMode() ) + SetCurSubShell( GetCurObjectSelectionType(), TRUE ); + + Window* pNewWin = GetActiveWin(); + if (pNewWin && pNewWin != pOldWin) + { + SetWindow( pNewWin ); //! ist diese ViewShell immer aktiv??? + if (bFocus) + pNewWin->GrabFocus(); + WindowChanged(); // Drawing-Layer (z.B. #56771#) + } + + if (GetViewData()->GetHSplitMode() == SC_SPLIT_FIX || + GetViewData()->GetVSplitMode() == SC_SPLIT_FIX) + { + InvalidateSplit(); + } + + ZoomChanged(); + + TestHintWindow(); + + //! if ViewData has more tables than document, remove tables in ViewData +} + + +//------------------------------------------------------------------ + +void ScTabViewShell::TestFunction( USHORT nPar ) +{ +/* switch (nPar) + { + } +*/ +} + +//------------------------------------------------------------------ + +void ScTabViewShell::ExecuteShowNIY( SfxRequest& rReq ) +{ + ErrorMessage(STR_BOX_YNI); +} + +//------------------------------------------------------------------ + +void ScTabViewShell::StateDisabled( SfxItemSet& rSet ) +{ + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + + while ( nWhich ) + { + rSet.DisableItem( nWhich ); + nWhich = aIter.NextWhich(); + } +} + +void ScTabViewShell::SetDrawShellOrSub() +{ + bActiveDrawSh = TRUE; + + if(bActiveDrawFormSh) + { + SetCurSubShell(OST_DrawForm); + } + else if(bActiveGraphicSh) + { + SetCurSubShell(OST_Graphic); + } + else if(bActiveChartSh) + { + SetCurSubShell(OST_Chart); + } + else if(bActiveOleObjectSh) + { + SetCurSubShell(OST_OleObject); + } + else + { + SetCurSubShell(OST_Drawing); + } +} + +void ScTabViewShell::SetDrawShell( BOOL bActive ) +{ + if(bActive) + { + SetCurSubShell(OST_Drawing); + } + else + { + if(bActiveDrawFormSh || bActiveDrawSh || + bActiveGraphicSh || bActiveOleObjectSh|| + bActiveChartSh || bActiveDrawTextSh) + { + SetCurSubShell(OST_Cell); + } + bActiveDrawFormSh=FALSE; + bActiveGraphicSh=FALSE; + bActiveOleObjectSh=FALSE; + bActiveChartSh=FALSE; + } + + BOOL bWasDraw = bActiveDrawSh || bActiveDrawTextSh; + + bActiveDrawSh = bActive; + bActiveDrawTextSh = FALSE; + + if ( !bActive ) + { + ResetDrawDragMode(); // Mirror / Rotate aus + + if (bWasDraw && (GetViewData()->GetHSplitMode() == SC_SPLIT_FIX || + GetViewData()->GetVSplitMode() == SC_SPLIT_FIX)) + { + // Aktiven Teil an Cursor anpassen, etc. + MoveCursorAbs( GetViewData()->GetCurX(), GetViewData()->GetCurY(), + SC_FOLLOW_NONE, FALSE, FALSE, TRUE ); + } + } +} + +void ScTabViewShell::SetDrawTextShell( BOOL bActive ) +{ + bActiveDrawTextSh = bActive; + if ( bActive ) + { + bActiveDrawFormSh=FALSE; + bActiveGraphicSh=FALSE; + bActiveOleObjectSh=FALSE; + bActiveChartSh=FALSE; + bActiveDrawSh = FALSE; + SetCurSubShell(OST_DrawText); + } + else + SetCurSubShell(OST_Cell); + +} + +void ScTabViewShell::SetPivotShell( BOOL bActive ) +{ + bActivePivotSh = bActive; + + // #68771# #76198# SetPivotShell is called from CursorPosChanged every time + // -> don't change anything except switching between cell and pivot shell + + if ( eCurOST == OST_Pivot || eCurOST == OST_Cell ) + { + if ( bActive ) + { + bActiveDrawTextSh = bActiveDrawSh = FALSE; + bActiveDrawFormSh=FALSE; + bActiveGraphicSh=FALSE; + bActiveOleObjectSh=FALSE; + bActiveChartSh=FALSE; + SetCurSubShell(OST_Pivot); + } + else + SetCurSubShell(OST_Cell); + } +} + +void ScTabViewShell::SetAuditShell( BOOL bActive ) +{ + bActiveAuditingSh = bActive; + if ( bActive ) + { + bActiveDrawTextSh = bActiveDrawSh = FALSE; + bActiveDrawFormSh=FALSE; + bActiveGraphicSh=FALSE; + bActiveOleObjectSh=FALSE; + bActiveChartSh=FALSE; + SetCurSubShell(OST_Auditing); + } + else + SetCurSubShell(OST_Cell); +} + +void ScTabViewShell::SetDrawFormShell( BOOL bActive ) +{ + bActiveDrawFormSh = bActive; + + if(bActiveDrawFormSh) + SetCurSubShell(OST_DrawForm); +} +void ScTabViewShell::SetChartShell( BOOL bActive ) +{ + bActiveChartSh = bActive; + + if(bActiveChartSh) + SetCurSubShell(OST_Chart); +} + +void ScTabViewShell::SetGraphicShell( BOOL bActive ) +{ + bActiveGraphicSh = bActive; + + if(bActiveGraphicSh) + SetCurSubShell(OST_Graphic); +} + +void ScTabViewShell::SetOleObjectShell( BOOL bActive ) +{ + bActiveOleObjectSh = bActive; + + if(bActiveOleObjectSh) + SetCurSubShell(OST_OleObject); + else + SetCurSubShell(OST_Cell); +} + +void ScTabViewShell::SetEditShell(EditView* pView, BOOL bActive ) +{ + if(bActive) + { + if (pEditShell) + pEditShell->SetEditView( pView ); + else + pEditShell = new ScEditShell( pView, GetViewData() ); + + SetCurSubShell(OST_Editing); + } + else if(bActiveEditSh) + { + SetCurSubShell(OST_Cell); + } + bActiveEditSh = bActive; +} + +void ScTabViewShell::SetCurSubShell(ObjectSelectionType eOST, BOOL bForce) +{ + ScViewData* pViewData = GetViewData(); + ScDocShell* pDocSh = pViewData->GetDocShell(); + SfxShell* pCurSubSh = NULL; + + if(bDontSwitch) return; + + if(!pCellShell) //Wird eh immer gebraucht. + { + pCellShell = new ScCellShell( GetViewData() ); + pCellShell->SetRepeatTarget( &aTarget ); + } + + BOOL bPgBrk=pViewData->IsPagebreakMode(); + + if(bPgBrk && !pPageBreakShell) + { + pPageBreakShell = new ScPageBreakShell( this ); + pPageBreakShell->SetRepeatTarget( &aTarget ); + } + + + if ( eOST!=eCurOST || bForce ) + { + if(eCurOST!=OST_NONE) RemoveSubShell(); + + if(pFormShell) AddSubShell(*pFormShell); + + + switch(eOST) + { + case OST_Cell: + { + AddSubShell(*pCellShell); + if(bPgBrk) AddSubShell(*pPageBreakShell); + } + break; + case OST_Editing: + { + AddSubShell(*pCellShell); + if(bPgBrk) AddSubShell(*pPageBreakShell); + + if(pEditShell) + { + AddSubShell(*pEditShell); + } + } + break; + case OST_DrawText: + { + if ( !pDrawTextShell ) + { + pDocSh->MakeDrawLayer(); + pDrawTextShell = new ScDrawTextObjectBar( GetViewData() ); + } + AddSubShell(*pDrawTextShell); + } + break; + case OST_Drawing: + { + if ( !pDrawShell ) + { + pDocSh->MakeDrawLayer(); + pDrawShell = new ScDrawShell( GetViewData() ); + pDrawShell->SetRepeatTarget( &aTarget ); + } + AddSubShell(*pDrawShell); + } + break; + + case OST_DrawForm: + { + if ( !pDrawFormShell ) + { + pDocSh->MakeDrawLayer(); + pDrawFormShell = new ScDrawFormShell( GetViewData() ); + pDrawFormShell->SetRepeatTarget( &aTarget ); + } + AddSubShell(*pDrawFormShell); + } + break; + + case OST_Chart: + { + if ( !pChartShell ) + { + pDocSh->MakeDrawLayer(); + pChartShell = new ScChartShell( GetViewData() ); + pChartShell->SetRepeatTarget( &aTarget ); + } + AddSubShell(*pChartShell); + } + break; + + case OST_OleObject: + { + if ( !pOleObjectShell ) + { + pDocSh->MakeDrawLayer(); + pOleObjectShell = new ScOleObjectShell( GetViewData() ); + pOleObjectShell->SetRepeatTarget( &aTarget ); + } + AddSubShell(*pOleObjectShell); + } + break; + + case OST_Graphic: + { + if ( !pGraphicShell) + { + pDocSh->MakeDrawLayer(); + pGraphicShell = new ScGraphicShell( GetViewData() ); + pGraphicShell->SetRepeatTarget( &aTarget ); + } + AddSubShell(*pGraphicShell); + } + break; + + case OST_Pivot: + { + AddSubShell(*pCellShell); + if(bPgBrk) AddSubShell(*pPageBreakShell); + + if ( !pPivotShell ) + { + pPivotShell = new ScPivotShell( this ); + pPivotShell->SetRepeatTarget( &aTarget ); + } + AddSubShell(*pPivotShell); + } + break; + case OST_Auditing: + { + AddSubShell(*pCellShell); + if(bPgBrk) AddSubShell(*pPageBreakShell); + + if ( !pAuditingShell ) + { + pDocSh->MakeDrawLayer(); // die Wartezeit lieber jetzt als beim Klick + + pAuditingShell = new ScAuditingShell( GetViewData() ); + pAuditingShell->SetRepeatTarget( &aTarget ); + } + AddSubShell(*pAuditingShell); + } + break; + default: + DBG_ERROR("Falsche Shell angefordert"); + break; + } + eCurOST=eOST; + } +} + +ObjectSelectionType ScTabViewShell::GetCurObjectSelectionType() +{ + return eCurOST; +} + +// GetMySubShell / SetMySubShell: altes Verhalten simulieren, +// dass es nur eine SubShell gibt (nur innerhalb der 5 eignenen SubShells) + +SfxShell* ScTabViewShell::GetMySubShell() const +{ + // GetSubShell() war frueher const, und GetSubShell(USHORT) sollte es auch sein... + + USHORT nPos = 0; + SfxShell* pSub = ((ScTabViewShell*)this)->GetSubShell(nPos); + while (pSub) + { + if ( pSub == pDrawShell || pSub == pDrawTextShell || pSub == pEditShell || + pSub == pPivotShell || pSub == pAuditingShell || pSub == pDrawFormShell || + pSub == pCellShell || pSub == pOleObjectShell|| pSub == pChartShell || + pSub == pGraphicShell || pSub == pPageBreakShell) + return pSub; // gefunden + + pSub = ((ScTabViewShell*)this)->GetSubShell(++nPos); + } + return NULL; // keine von meinen dabei +} + +void ScTabViewShell::SetMySubShell( SfxShell* pShell ) +{ + SfxShell* pOld = GetMySubShell(); + if ( pOld != pShell ) + { + if (pOld) + RemoveSubShell(pOld); // alte SubShell entfernen + if (pShell) + AddSubShell(*pShell); // neue setzen + } +} + +BOOL ScTabViewShell::IsDrawTextShell() const +{ + return ( pDrawTextShell && ( GetMySubShell() == pDrawTextShell ) ); +} + +BOOL ScTabViewShell::IsAuditShell() const +{ + return ( pAuditingShell && ( GetMySubShell() == pAuditingShell ) ); +} + +void ScTabViewShell::SetDrawTextUndo( SfxUndoManager* pUndoMgr ) +{ + // Default: Undo-Manager der DocShell + if (!pUndoMgr) + pUndoMgr = GetViewData()->GetDocShell()->GetUndoManager(); + + if (pDrawTextShell) + pDrawTextShell->SetUndoManager(pUndoMgr); + else + DBG_ERROR("SetDrawTextUndo ohne DrawTextShell"); +} + +//------------------------------------------------------------------ + +ScTabViewShell* ScTabViewShell::GetActiveViewShell() +{ + return PTR_CAST(ScTabViewShell,Current()); +} + +//------------------------------------------------------------------ + +SfxPrinter* __EXPORT ScTabViewShell::GetPrinter( BOOL bCreate ) +{ + // Drucker ist immer da (wird fuer die FontListe schon beim Starten angelegt) + return GetViewData()->GetDocShell()->GetPrinter(); +} + +USHORT __EXPORT ScTabViewShell::SetPrinter( SfxPrinter *pNewPrinter, USHORT nDiffFlags ) +{ + return GetViewData()->GetDocShell()->SetPrinter( pNewPrinter, nDiffFlags ); +} + +PrintDialog* __EXPORT ScTabViewShell::CreatePrintDialog( Window *pParent ) +{ + ScDocShell* pDocShell = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocShell->GetDocument(); + + pDoc->SetPrintOptions(); // Optionen aus OFA am Printer setzen + SfxPrinter* pPrinter = GetPrinter(); + + String aStrRange; +#ifndef VCL + PrintDialog* pDlg = new PrintDialog( pParent, + WinBits(WB_SVLOOK|WB_STDMODAL) ); +#else + PrintDialog* pDlg = new PrintDialog( pParent); +#endif + USHORT i; + USHORT nTabCount = pDoc->GetTableCount(); + long nDocPageMax = 0; + + for ( i=0; i<nTabCount; i++ ) + { + ScPrintFunc aPrintFunc( pDocShell, pPrinter, i ); + nDocPageMax += aPrintFunc.GetTotalPages(); + } + + if ( nDocPageMax > 0 ) + { + aStrRange = '1'; + if ( nDocPageMax > 1 ) + { + aStrRange += '-'; + aStrRange += String::CreateFromInt32( nDocPageMax ); + } + } + + pDlg->SetRangeText ( aStrRange ); + pDlg->EnableRange ( PRINTDIALOG_ALL ); + pDlg->EnableRange ( PRINTDIALOG_SELECTION ); + pDlg->EnableRange ( PRINTDIALOG_RANGE ); + pDlg->SetFirstPage ( 1 ); + pDlg->SetMinPage ( 1 ); + pDlg->SetLastPage ( (USHORT)nDocPageMax ); + pDlg->SetMaxPage ( (USHORT)nDocPageMax ); + pDlg->EnableCollate (); + + return pDlg; +} + +void __EXPORT ScTabViewShell::PreparePrint( PrintDialog* pPrintDialog ) +{ + ScDocShell* pDocShell = GetViewData()->GetDocShell(); + + SfxViewShell::PreparePrint( pPrintDialog ); + pDocShell->PreparePrint( pPrintDialog, &GetViewData()->GetMarkData() ); +} + +ErrCode ScTabViewShell::DoPrint( SfxPrinter *pPrinter, + PrintDialog *pPrintDialog, BOOL bSilent ) +{ + // #72527# if SID_PRINTDOCDIRECT is executed and there's a selection, + // ask if only the selection should be printed + + const ScMarkData& rMarkData = GetViewData()->GetMarkData(); + if ( !pPrintDialog && !bSilent && ( rMarkData.IsMarked() || rMarkData.IsMultiMarked() ) ) + { + SvxPrtQryBox aQuery( GetDialogParent() ); + short nBtn = aQuery.Execute(); + + if ( nBtn == RET_CANCEL ) + return ERRCODE_IO_ABORT; + + if ( nBtn == RET_OK ) + bPrintSelected = TRUE; + } + + // SfxViewShell::DoPrint calls Print (after StartJob etc.) + ErrCode nRet = SfxViewShell::DoPrint( pPrinter, pPrintDialog, bSilent ); + + bPrintSelected = FALSE; + + return nRet; +} + +USHORT __EXPORT ScTabViewShell::Print( SfxProgress& rProgress, + PrintDialog* pPrintDialog ) +{ + ScDocShell* pDocShell = GetViewData()->GetDocShell(); + pDocShell->GetDocument()->SetPrintOptions(); // Optionen aus OFA am Printer setzen + + SfxViewShell::Print( rProgress, pPrintDialog ); + pDocShell->Print( rProgress, pPrintDialog, &GetViewData()->GetMarkData(), bPrintSelected ); + + return 0; +} + +void ScTabViewShell::StopEditShell() +{ + if ( pEditShell != NULL && !bDontSwitch ) + SetEditShell(NULL, FALSE ); +} + +//------------------------------------------------------------------ + +BOOL ScTabViewShell::TabKeyInput(const KeyEvent& rKEvt) +{ + ScModule* pScMod = SC_MOD(); + + SfxViewFrame* pThisFrame = GetViewFrame(); + if ( pThisFrame->GetChildWindow( SID_OPENDLG_FUNCTION ) ) + return FALSE; + + KeyCode aCode = rKEvt.GetKeyCode(); + BOOL bShift = aCode.IsShift(); + BOOL bControl = aCode.IsMod1(); + BOOL bAlt = aCode.IsMod2(); + USHORT nCode = aCode.GetCode(); + BOOL bUsed = FALSE; + BOOL bInPlace = pScMod->IsEditMode(); // Editengine bekommt alles + BOOL bAnyEdit = pScMod->IsInputMode(); // nur Zeichen & Backspace + BOOL bDraw = IsDrawTextEdit(); + + HideNoteMarker(); // Notiz-Anzeige + + BOOL bHideCursor = ( nCode == KEY_RETURN && bInPlace ) || + nCode == KEY_TAB; + + if (bHideCursor) + HideAllCursors(); + + ScDocument* pDoc = GetViewData()->GetDocument(); + if ( pDoc ) + pDoc->KeyInput( rKEvt ); // TimerDelays etc. + + if( bInPlace ) + { + bUsed = pScMod->InputKeyEvent( rKEvt ); // Eingabe + if( !bUsed ) + bUsed = SfxViewShell::KeyInput( rKEvt ); // Acceleratoren + } + else if( bAnyEdit ) + { + BOOL bIsType = FALSE; + USHORT nModi = aCode.GetModifier(); + USHORT nGroup = aCode.GetGroup(); + + if ( nGroup == KEYGROUP_NUM || nGroup == KEYGROUP_ALPHA || nGroup == 0 ) + if ( !bControl && !bAlt ) + bIsType = TRUE; + + if ( nGroup == KEYGROUP_MISC ) + switch ( nCode ) + { + case KEY_RETURN: + bIsType = bControl && !bAlt; // Control, Shift-Control-Return + if ( !bIsType && nModi == 0 ) + { + // Will der InputHandler auch ein einfaches Return? + + ScInputHandler* pHdl = pScMod->GetInputHdl(this); + bIsType = pHdl && pHdl->TakesReturn(); + } + break; + case KEY_SPACE: + bIsType = !bControl && !bAlt; // ohne Modifier oder Shift-Space + break; + case KEY_ESCAPE: + case KEY_BACKSPACE: + bIsType = (nModi == 0); // nur ohne Modifier + break; + default: + bIsType = TRUE; + } + + if( bIsType ) + bUsed = pScMod->InputKeyEvent( rKEvt ); // Eingabe + + if( !bUsed ) + bUsed = SfxViewShell::KeyInput( rKEvt ); // Acceleratoren + + if ( !bUsed && !bIsType && nCode != KEY_RETURN ) // Eingabe nochmal hinterher + bUsed = pScMod->InputKeyEvent( rKEvt ); + } + else + { + // #51889# Spezialfall: Copy/Cut bei Mehrfachselektion -> Fehlermeldung + // (Slot ist disabled, SfxViewShell::KeyInput wuerde also kommentarlos verschluckt) + KeyFuncType eFunc = aCode.GetFunction(); + if ( eFunc == KEYFUNC_COPY || eFunc == KEYFUNC_CUT ) + { + ScRange aDummy; + if ( !GetViewData()->GetSimpleArea( aDummy, TRUE ) ) //! macht TRUE aerger ? + { + ErrorMessage(STR_NOMULTISELECT); + bUsed = TRUE; + } + } + if (!bUsed) + bUsed = SfxViewShell::KeyInput( rKEvt ); // Acceleratoren + + // #74696# during inplace editing, some slots are handled by the + // container app and are executed during Window::KeyInput. + // -> don't pass keys to input handler that would be used there + // but should call slots instead. + BOOL bParent = ( GetViewFrame()->ISA(SfxInPlaceFrame) && eFunc != KEYFUNC_DONTKNOW ); + + if( !bUsed && !bDraw && nCode != KEY_RETURN && !bParent ) + bUsed = pScMod->InputKeyEvent( rKEvt, TRUE ); // Eingabe + } + + if (!bInPlace && !bUsed && !bDraw) + { + switch (nCode) + { + case KEY_RETURN: + { + BOOL bNormal = !bControl && !bAlt; + if ( !bAnyEdit && bNormal ) + { + // je nach Optionen mit Enter in den Edit-Modus schalten + + const ScInputOptions& rOpt = pScMod->GetInputOptions(); + if ( rOpt.GetEnterEdit() ) + { + pScMod->SetInputMode( SC_INPUT_TABLE ); + bUsed = TRUE; + } + } + + BOOL bEditReturn = bControl && !bShift; // An Edit-Engine weiter + if ( !bUsed && !bEditReturn ) + { + HideAllCursors(); + + BYTE nMode = SC_ENTER_NORMAL; + if ( bShift && bControl ) + nMode = SC_ENTER_MATRIX; + else if ( bAlt ) + nMode = SC_ENTER_BLOCK; + pScMod->InputEnterHandler(nMode); + + if (nMode == SC_ENTER_NORMAL) + { + if( bShift ) + SFX_DISPATCHER().Execute( SID_CURSORENTERUP, + SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD ); + else + SFX_DISPATCHER().Execute( SID_CURSORENTERDOWN, + SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD ); + } + else + UpdateInputHandler(TRUE); + + ShowAllCursors(); + + // hier kein UpdateInputHandler, weil bei Referenzeingabe auf ein + // anderes Dokument diese ViewShell nicht die ist, auf der eingegeben + // wird! + + bUsed = TRUE; + } + } + break; + } + } + + // Alt-Cursortasten hart codiert, weil Alt nicht konfigurierbar ist + + if ( !bUsed && bAlt && !bControl ) + { + USHORT nSlotId = 0; + switch (nCode) + { + case KEY_UP: + ModifyCellSize( DIR_TOP, bShift ); + bUsed = TRUE; + break; + case KEY_DOWN: + ModifyCellSize( DIR_BOTTOM, bShift ); + bUsed = TRUE; + break; + case KEY_LEFT: + ModifyCellSize( DIR_LEFT, bShift ); + bUsed = TRUE; + break; + case KEY_RIGHT: + ModifyCellSize( DIR_RIGHT, bShift ); + bUsed = TRUE; + break; + case KEY_PAGEUP: + nSlotId = bShift ? SID_CURSORPAGELEFT_SEL : SID_CURSORPAGELEFT_; + break; + case KEY_PAGEDOWN: + nSlotId = bShift ? SID_CURSORPAGERIGHT_SEL : SID_CURSORPAGERIGHT_; + break; + } + if ( nSlotId ) + { + SFX_DISPATCHER().Execute( nSlotId, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD ); + bUsed = TRUE; + } + } + + if (bHideCursor) + ShowAllCursors(); + + return bUsed; +} + +BOOL ScTabViewShell::SfxKeyInput(const KeyEvent& rKeyEvent) +{ + return SfxViewShell::KeyInput( rKeyEvent ); +} + +FASTBOOL __EXPORT ScTabViewShell::KeyInput( const KeyEvent &rKeyEvent ) +{ +// return SfxViewShell::KeyInput( rKeyEvent ); + return TabKeyInput( rKeyEvent ); +} + +//------------------------------------------------------------------ + +// SfxViewShell( pViewFrame, SFX_VIEW_MAXIMIZE_FIRST | SFX_VIEW_DISABLE_ACCELS ), + +#define __INIT_ScTabViewShell \ + SfxViewShell( pViewFrame, SFX_VIEW_MAXIMIZE_FIRST | SFX_VIEW_CAN_PRINT ), \ + nDrawSfxId(0), \ + nCtrlSfxId(USHRT_MAX), \ + eCurOST(OST_NONE), \ + nFormSfxId(USHRT_MAX), \ + pCellShell(NULL), \ + pPageBreakShell(NULL), \ + pDrawShell(NULL), \ + pDrawFormShell(NULL), \ + pOleObjectShell(NULL), \ + pChartShell(NULL), \ + pGraphicShell(NULL), \ + pDrawTextShell(NULL), \ + pEditShell(NULL), \ + pPivotShell(NULL), \ + pAuditingShell(NULL), \ + pFormShell(NULL), \ + pInputHandler(NULL), \ + pCurFrameLine(NULL), \ + bActiveChartSh(FALSE), \ + bActiveDrawSh(FALSE), \ + bActiveDrawTextSh(FALSE), \ + bActiveGraphicSh(FALSE), \ + bActivePivotSh(FALSE), \ + bActiveAuditingSh(FALSE), \ + bActiveDrawFormSh(FALSE), \ + bActiveOleObjectSh(FALSE), \ + bDontSwitch(FALSE), \ + bInFormatDialog(FALSE), \ + bPrintSelected(FALSE), \ + bReadOnly(FALSE), \ + pScSbxObject(NULL), \ + bChartAreaValid(FALSE), \ + bChartDlgIsEdit(FALSE), \ + pDialogDPObject(NULL), \ + aTarget( this ) + + +//------------------------------------------------------------------ + +void ScTabViewShell::Construct() +{ + SfxApplication* pSfxApp = SFX_APP(); + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + + bReadOnly = pDocSh->IsReadOnly(); + + SetName( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("View")) ); // fuer SBX + Color aColBlack( COL_BLACK ); +// SetPool( &pSfxApp->GetPool() ); + SetPool( &SC_MOD()->GetPool() ); + SetWindow( GetActiveWin() ); + + pCurFrameLine = new SvxBorderLine( &aColBlack, 20, 0, 0 ); + pPivotSource = new ScArea; + StartListening(*GetViewData()->GetDocShell()); + StartListening(*GetViewFrame()); + StartListening(*pSfxApp,TRUE); // SfxViewShell hoert da schon zu? + + SfxViewFrame* pFirst = SfxViewFrame::GetFirst(pDocSh); + BOOL bFirstView = !pFirst + || (pFirst == GetViewFrame() && !SfxViewFrame::GetNext(*pFirst,pDocSh)); + + if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ) + { + Rectangle aVisArea = ((SfxInPlaceObject*)pDocSh)->GetVisArea(); + + USHORT nVisTab = pDoc->GetVisibleTab(); + if (!pDoc->HasTable(nVisTab)) + { + nVisTab = 0; + pDoc->SetVisibleTab(nVisTab); + } + SetTabNo( nVisTab ); + GetViewData()->SetScreenPos( aVisArea.TopLeft() ); // richtige Stelle zeigen + + if ( GetViewFrame()->ISA(SfxInPlaceFrame) ) // inplace + { + pDocSh->SetInplace( TRUE ); // schon so initialisiert + if (pDoc->IsEmbedded()) + pDoc->ResetEmbedded(); // keine blaue Markierung + } + else if ( bFirstView ) + { + pDocSh->SetInplace( FALSE ); + GetViewData()->SetZoom( // PPT neu berechnen + GetViewData()->GetZoomX(), + GetViewData()->GetZoomY()); + if (!pDoc->IsEmbedded()) + pDoc->SetEmbedded( aVisArea ); // VisArea markieren + } + } + + // ViewInputHandler + // #48721# jeder Task hat neuerdings sein eigenes InputWindow, + // darum muesste eigentlich entweder jeder Task seinen InputHandler bekommen, + // oder das InputWindow muesste sich beim App-InputHandler anmelden, wenn der + // Task aktiv wird, oder das InputWindow muesste sich den InputHandler selbst + // anlegen (dann immer ueber das InputWindow suchen, und nur wenn das nicht da + // ist, den InputHandler von der App nehmen). + // Als Sofortloesung bekommt erstmal jede View ihren Inputhandler, das gibt + // nur noch Probleme, wenn zwei Views in einem Task-Fenster sind. + + pInputHandler = new ScInputHandler; + + // Alte Version: + // if ( !GetViewFrame()->ISA(SfxTopViewFrame) ) // OLE oder Plug-In + // pInputHandler = new ScInputHandler; + + // FormShell vor MakeDrawView anlegen, damit die DrawView auf jeden Fall + // an der FormShell angemeldet werden kann + // Gepusht wird die FormShell im ersten Activate + pFormShell = new FmFormShell(this); + + // DrawView darf nicht im TabView - ctor angelegt werden, + // wenn die ViewShell noch nicht kostruiert ist... + if (pDoc->GetDrawLayer()) + MakeDrawView(); + ViewOptionsHasChanged(FALSE); // legt auch evtl. DrawView an + + SetUndoManager( pDocSh->GetUndoManager() ); + pFormShell->SetUndoManager( pDocSh->GetUndoManager() ); + SetRepeatTarget( &aTarget ); + pFormShell->SetRepeatTarget( &aTarget ); + SetHelpId( HID_SCSHELL_TABVWSH ); + + if ( bFirstView ) + { // erste View? + + // Tabellen anhaengen? (nicht bei OLE) + if ( pDocSh->IsEmpty() && + pDocSh->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) + { + USHORT nInitTabCount = 3; //! konfigurierbar !!! + for (USHORT i=1; i<nInitTabCount; i++) + pDoc->MakeTable(i); + } + + const ScExtDocOptions* pExtOpt = pDoc->GetExtDocOptions(); + if (pExtOpt) + { + GetViewData()->ReadExtOptions(*pExtOpt); // Excel-View Optionen + SetTabNo( GetViewData()->GetTabNo(), TRUE ); + //! alles von ReadUserData auch hier + } + + // Link-Update nicht verschachteln + if ( pDocSh->GetCreateMode() != SFX_CREATE_MODE_INTERNAL ) + { + BOOL bLink = FALSE; // Links updaten + USHORT nTabCount = pDoc->GetTableCount(); + for (USHORT i=0; i<nTabCount && !bLink; i++) + if (pDoc->IsLinked(i)) + bLink = TRUE; + if (!bLink) + if (pDoc->HasDdeLinks() || pDoc->HasAreaLinks()) + bLink = TRUE; + if (bLink) + { + if ( !pFirst ) + pFirst = GetViewFrame(); + + if(SC_MOD()->GetCurRefDlgId()==0) + { + pFirst->GetDispatcher()->Execute( SID_UPDATETABLINKS, + SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD ); + } + } + + BOOL bReImport = FALSE; // importierte Daten aktualisieren + ScDBCollection* pDBColl = pDoc->GetDBCollection(); + if ( pDBColl ) + { + USHORT nCount = pDBColl->GetCount(); + for (USHORT i=0; i<nCount && !bReImport; i++) + { + ScDBData* pData = (*pDBColl)[i]; + if ( pData->IsStripData() && + pData->HasImportParam() && !pData->HasImportSelection() ) + bReImport = TRUE; + } + } + if (bReImport) + { + if ( !pFirst ) + pFirst = GetViewFrame(); + if(SC_MOD()->GetCurRefDlgId()==0) + { + pFirst->GetDispatcher()->Execute( SID_REIMPORT_AFTER_LOAD, + SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD ); + } + } + } + } + + UpdateAutoFillMark(); + + bFirstActivate = TRUE; // NavigatorUpdate aufschieben bis Activate() +} + +//------------------------------------------------------------------ + +ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame, + const ScTabViewShell& rWin ) : + __INIT_ScTabViewShell, + ScDBFunc( &pViewFrame->GetWindow(), rWin, this ) +{ + Construct(); + + UpdatePageBreakData(); + + uno::Reference<frame::XFrame> xFrame = pViewFrame->GetFrame()->GetFrameInterface(); + if (xFrame.is()) + xFrame->setComponent( uno::Reference<awt::XWindow>(), new ScTabViewObj( this ) ); + + SetCurSubShell(OST_Cell); +} + +//------------------------------------------------------------------ + +ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame, + SfxViewShell* pOldSh ) : + __INIT_ScTabViewShell, + ScDBFunc( &pViewFrame->GetWindow(), (ScDocShell&)*pViewFrame->GetObjectShell(), this ) +{ + const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions(); + + Construct(); + + Fraction aFract( rAppOpt.GetZoom(), 100 ); + SetZoom( aFract, aFract ); + SetZoomType( rAppOpt.GetZoomType() ); + + uno::Reference<frame::XFrame> xFrame = pViewFrame->GetFrame()->GetFrameInterface(); + if (xFrame.is()) + xFrame->setComponent( uno::Reference<awt::XWindow>(), new ScTabViewObj( this ) ); + + SetCurSubShell(OST_Cell); + + // if switching back from print preview, + // restore the view settings that were active when creating the preview + + if ( pOldSh && pOldSh->ISA( ScPreviewShell ) ) + { + String aOldData = ((ScPreviewShell*)pOldSh)->GetSourceData(); + if ( aOldData.Len() ) + { + // restore old view settings + // (DoReadUserData also sets SubShell, current Window etc.) + DoReadUserData( aOldData ); + } + } +} + +#undef __INIT_ScTabViewShell + +//------------------------------------------------------------------ + +__EXPORT ScTabViewShell::~ScTabViewShell() +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + EndListening(*pDocSh); + EndListening(*GetViewFrame()); + + SC_MOD()->ViewShellGone(this); + + RemoveSubShell(); // alle + SetWindow(0); + + // #54104# alles auf NULL, falls aus dem TabView-dtor noch darauf zugegriffen wird + //! (soll eigentlich nicht !??!?!) + + DELETEZ(pCellShell); + DELETEZ(pPageBreakShell); + DELETEZ(pDrawShell); + DELETEZ(pDrawFormShell); + DELETEZ(pOleObjectShell); + DELETEZ(pChartShell); + DELETEZ(pGraphicShell); + DELETEZ(pDrawTextShell); + DELETEZ(pEditShell); + DELETEZ(pPivotShell); + DELETEZ(pAuditingShell); + DELETEZ(pCurFrameLine); + DELETEZ(pInputHandler); + DELETEZ(pPivotSource); + DELETEZ(pDialogDPObject); + + DELETEZ(pFormShell); +} + +//------------------------------------------------------------------ + +void ScTabViewShell::SetDialogDPObject( const ScDPObject* pObj ) +{ + delete pDialogDPObject; + if (pObj) + pDialogDPObject = new ScDPObject( *pObj ); + else + pDialogDPObject = NULL; +} + +//------------------------------------------------------------------ + +void ScTabViewShell::FillFieldData( ScHeaderFieldData& rData ) +{ + ScDocShell* pDocShell = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocShell->GetDocument(); + USHORT nTab = GetViewData()->GetTabNo(); + pDoc->GetName( nTab, rData.aTabName ); + + rData.aTitle = pDocShell->GetTitle(); + rData.aLongDocName = pDocShell->GetMedium()->GetName(); + if ( !rData.aLongDocName.Len() ) + rData.aLongDocName = rData.aTitle; + rData.aShortDocName = INetURLObject( rData.aLongDocName ).GetName(); + rData.nPageNo = 1; + rData.nTotalPages = 99; + + // eNumType kennt der Dialog selber +} + +//------------------------------------------------------------------ + +void ScTabViewShell::SetChartArea( const ScRangeListRef& rSource, const Rectangle& rDest ) +{ + bChartAreaValid = TRUE; + aChartSource = rSource; + aChartPos = rDest; + nChartDestTab = GetViewData()->GetTabNo(); +} + +void ScTabViewShell::ResetChartArea() +{ + bChartAreaValid = FALSE; +} + +BOOL ScTabViewShell::GetChartArea( ScRangeListRef& rSource, Rectangle& rDest, USHORT& rTab ) const +{ + rSource = aChartSource; + rDest = aChartPos; + rTab = nChartDestTab; + return bChartAreaValid; +} + +BOOL ScTabViewShell::IsChartDlgEdit() const +{ + return bChartDlgIsEdit; +} + +const String& ScTabViewShell::GetEditChartName() const +{ + return aEditChartName; +} + +//------------------------------------------------------------------ + +void ScTabViewShell::ExecTbx( SfxRequest& rReq ) +{ + const SfxItemSet* pReqArgs = rReq.GetArgs(); + USHORT nSlot = rReq.GetSlot(); + const SfxPoolItem* pItem = NULL; + if ( pReqArgs ) + pReqArgs->GetItemState( nSlot, TRUE, &pItem ); + + switch ( nSlot ) + { + case SID_TBXCTL_INSERT: + if ( pItem ) + nInsertCtrlState = ((const SfxUInt16Item*)pItem)->GetValue(); + break; + case SID_TBXCTL_INSCELLS: + if ( pItem ) + nInsCellsCtrlState = ((const SfxUInt16Item*)pItem)->GetValue(); + break; + case SID_TBXCTL_INSOBJ: + if ( pItem ) + nInsObjCtrlState = ((const SfxUInt16Item*)pItem)->GetValue(); + break; + default: + DBG_ERROR("Slot im Wald"); + } + SFX_BINDINGS().Invalidate( nSlot ); +} + +void ScTabViewShell::GetTbxState( SfxItemSet& rSet ) +{ + rSet.Put( SfxUInt16Item( SID_TBXCTL_INSERT, nInsertCtrlState ) ); + rSet.Put( SfxUInt16Item( SID_TBXCTL_INSCELLS, nInsCellsCtrlState ) ); + + // ohne installiertes Chart darf Chart nicht Default sein... + if ( nInsObjCtrlState == SID_DRAW_CHART && !SFX_APP()->HasFeature(SFX_FEATURE_SCHART) ) + nInsObjCtrlState = SID_INSERT_OBJECT; + + rSet.Put( SfxUInt16Item( SID_TBXCTL_INSOBJ, nInsObjCtrlState ) ); +} + + + + + diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx new file mode 100644 index 000000000000..8c76947bd5cb --- /dev/null +++ b/sc/source/ui/view/tabvwsh5.cxx @@ -0,0 +1,459 @@ +/************************************************************************* + * + * $RCSfile: tabvwsh5.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- +#define _ZFORLIST_DECLARE_TABLE +#include "scitems.hxx" +#include <svtools/smplhint.hxx> +#include <svtools/zforlist.hxx> +#include <svx/numfmtsh.hxx> +#include <svx/numinf.hxx> +#include <svx/svxids.hrc> +#include <sfx2/dispatch.hxx> +#include <sfx2/objsh.hxx> + +#include "tabvwsh.hxx" +#include "sc.hrc" +#include "global.hxx" +#include "document.hxx" +#include "cell.hxx" +#include "globstr.hrc" +#include "scmod.hxx" +#include "uiitems.hxx" +#include "editsh.hxx" +#include "hints.hxx" + + +//================================================================== + +void __EXPORT ScTabViewShell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, + const SfxHint& rHint, const TypeId& rHintType ) +{ + if (rHint.ISA(SfxSimpleHint)) // ohne Parameter + { + ULONG nSlot = ((SfxSimpleHint&)rHint).GetId(); + switch ( nSlot ) + { + case FID_DATACHANGED: + UpdateFormulas(); + break; + + case FID_REFMODECHANGED: + { + BOOL bRefMode = SC_MOD()->IsFormulaMode(); + if (!bRefMode) + StopRefMode(); + else + { + GetSelEngine()->Reset(); + GetFunctionSet()->SetAnchorFlag(TRUE); + // AnchorFlag, damit gleich mit Control angehaengt werden kann + } + } + break; + + case FID_KILLEDITVIEW: + case FID_KILLEDITVIEW_NOPAINT: + StopEditShell(); + KillEditView( nSlot == FID_KILLEDITVIEW_NOPAINT ); + break; + + case SFX_HINT_DOCCHANGED: + { + ScDocument* pDoc = GetViewData()->GetDocument(); + if (!pDoc->HasTable( GetViewData()->GetTabNo() )) + { + SetTabNo(0); + } + } + break; + + case SC_HINT_DRWLAYER_NEW: + MakeDrawView(); + break; + + case SC_HINT_DOC_SAVED: + { + // beim "Save as" kann ein vorher schreibgeschuetztes Dokument + // bearbeitbar werden, deshalb die Layer-Locks neu (#39884#) + // (Invalidate etc. passiert schon vom Sfx her) + // #42091# bei SID_EDITDOC kommt kein SFX_HINT_TITLECHANGED, darum + // der eigene Hint aus DoSaveCompleted + //! was ist mit SFX_HINT_SAVECOMPLETED ? + + UpdateLayerLocks(); + + // #54891# Design-Modus bei jedem Speichern anzupassen, waere zuviel + // (beim Speichern unter gleichem Namen soll er unveraendert bleiben) + // Darum nur bei SFX_HINT_MODECHANGED (vom ViewFrame) + } + break; + + case SFX_HINT_MODECHANGED: + // #54891#/#58510# Da man sich nicht mehr darauf verlassen kann, woher + // dieser Hint kommt, den Design-Modus immer dann umschalten, wenn der + // ReadOnly-Status sich wirklich geaendert hat: + + if ( GetViewData()->GetSfxDocShell()->IsReadOnly() != bReadOnly ) + { + bReadOnly = GetViewData()->GetSfxDocShell()->IsReadOnly(); + + SfxBoolItem aItem( SID_FM_DESIGN_MODE, !bReadOnly); + SFX_DISPATCHER().Execute( SID_FM_DESIGN_MODE, SFX_CALLMODE_ASYNCHRON, + &aItem, 0L ); + } + break; + + case SC_HINT_SHOWRANGEFINDER: + PaintRangeFinder(); + break; + + case SC_HINT_FORCESETTAB: + SetTabNo( GetViewData()->GetTabNo(), TRUE ); + break; + + default: + break; + } + } + else if (rHint.ISA(ScPaintHint)) // neu zeichnen + { + ScPaintHint* pHint = (ScPaintHint*) &rHint; + USHORT nParts = pHint->GetParts(); + USHORT nTab = GetViewData()->GetTabNo(); + if (pHint->GetStartTab() <= nTab && pHint->GetEndTab() >= nTab) + { + if (nParts & PAINT_EXTRAS) // zuerst, falls Tabelle weg ist !!! + if (PaintExtras()) + nParts = PAINT_ALL; + + if (nParts & PAINT_SIZE) + RepeatResize(); //! InvalidateBorder ??? + if (nParts & PAINT_GRID) + PaintArea( pHint->GetStartCol(), pHint->GetStartRow(), + pHint->GetEndCol(), pHint->GetEndRow() ); + if (nParts & PAINT_MARKS) + PaintArea( pHint->GetStartCol(), pHint->GetStartRow(), + pHint->GetEndCol(), pHint->GetEndRow(), SC_UPDATE_MARKS ); + if (nParts & PAINT_LEFT) + PaintLeftArea( pHint->GetStartRow(), pHint->GetEndRow() ); + if (nParts & PAINT_TOP) + PaintTopArea( pHint->GetStartCol(), pHint->GetEndCol() ); + if (nParts & PAINT_INVERT) + InvertBlockMark( pHint->GetStartCol(), pHint->GetStartRow(), + pHint->GetEndCol(), pHint->GetEndRow() ); + } + } + else if (rHint.ISA(ScEditViewHint)) // Edit-View anlegen + { + // ScEditViewHint kommt nur an aktiver View an + + ScEditViewHint* pHint = (ScEditViewHint*) &rHint; + USHORT nTab = GetViewData()->GetTabNo(); + if ( pHint->GetTab() == nTab ) + { + ScDocument* pDoc = GetViewData()->GetDocument(); + USHORT nCol = pHint->GetCol(); + USHORT nRow = pHint->GetRow(); +#if 0 +// Abfrage ist ueberfluessig, passiert bereits in ScInputHandler StartTable +// if (pDoc->IsSelectionOrBlockEditable( nTab, nCol,nRow, nCol,nRow )) +#endif + { + MakeEditView( pHint->GetEngine(), nCol, nRow ); + + StopEditShell(); // sollte nicht gesetzt sein + + ScSplitPos eActive = GetViewData()->GetActivePart(); + if ( GetViewData()->HasEditView(eActive) ) + { + // MakeEditView geht schief, wenn der Cursor ausserhalb des + // Bildschirms steht. GetEditView gibt dann eine nicht aktive + // View zurueck, darum die Abfrage HasEditView. + + EditView* pView = GetViewData()->GetEditView(eActive); // ist nicht 0 + + SetEditShell(pView ,TRUE); + } + } +#if 0 +// else +// if (GetViewData()->IsActive()) +// ErrorMessage(STR_PROTECTIONERR); +#endif + } + } + else if (rHint.ISA(ScTablesHint)) // Tabelle eingefuegt / geloescht + { + // aktuelle Tabelle zuerst holen (kann bei DeleteTab an ViewData geaendert werden) + USHORT nActiveTab = GetViewData()->GetTabNo(); + + const ScTablesHint& rTabHint = (const ScTablesHint&)rHint; + USHORT nTab1 = rTabHint.GetTab1(); + USHORT nTab2 = rTabHint.GetTab2(); + USHORT nId = rTabHint.GetId(); + switch (nId) + { + case SC_TAB_INSERTED: + GetViewData()->InsertTab( nTab1 ); + break; + case SC_TAB_DELETED: + GetViewData()->DeleteTab( nTab1 ); + break; + case SC_TAB_MOVED: + GetViewData()->MoveTab( nTab1, nTab2 ); + break; + case SC_TAB_COPIED: + GetViewData()->CopyTab( nTab1, nTab2 ); + break; + case SC_TAB_HIDDEN: + break; + default: + DBG_ERROR("unbekannter ScTablesHint"); + } + + // hier keine Abfrage auf IsActive() mehr, weil die Aktion von Basic ausgehen + // kann und dann auch die aktive View umgeschaltet werden muss. + + USHORT nNewTab = nActiveTab; + BOOL bForce = FALSE; + switch (nId) + { + case SC_TAB_INSERTED: + if ( nTab1 <= nNewTab ) // vorher eingefuegt + ++nNewTab; + break; + case SC_TAB_DELETED: + if ( nTab1 < nNewTab ) // vorher geloescht + --nNewTab; + else if ( nTab1 == nNewTab ) // aktuelle geloescht + bForce = TRUE; + break; + case SC_TAB_MOVED: + if ( nNewTab == nTab1 ) // verschobene Tabelle + nNewTab = nTab2; + else if ( nTab1 < nTab2 ) // nach hinten verschoben + { + if ( nNewTab > nTab1 && nNewTab <= nTab2 ) // nachrueckender Bereich + --nNewTab; + } + else // nach vorne verschoben + { + if ( nNewTab >= nTab2 && nNewTab < nTab1 ) // nachrueckender Bereich + ++nNewTab; + } + break; + case SC_TAB_COPIED: + if ( nNewTab >= nTab2 ) // vorher eingefuegt + ++nNewTab; + break; + case SC_TAB_HIDDEN: + if ( nTab1 == nNewTab ) // aktuelle ausgeblendet + bForce = TRUE; + break; + } + + ScDocument* pDoc = GetViewData()->GetDocument(); + if ( nNewTab >= pDoc->GetTableCount() ) + nNewTab = pDoc->GetTableCount() - 1; + + SetTabNo( nNewTab, bForce ); + } + else if (rHint.ISA(ScIndexHint)) + { + const ScIndexHint& rIndexHint = (const ScIndexHint&)rHint; + USHORT nId = rIndexHint.GetId(); + USHORT nIndex = rIndexHint.GetIndex(); + switch (nId) + { + case SC_HINT_SHOWRANGEFINDER: + PaintRangeFinder( nIndex ); + break; + } + } + + SfxViewShell::SFX_NOTIFY( rBC, rBCType, rHint, rHintType ); +} + +//------------------------------------------------------------------ + +void ScTabViewShell::MakeNumberInfoItem( ScDocument* pDoc, + ScViewData* pViewData, + SvxNumberInfoItem** ppItem ) +{ + //------------------------------ + // NumberInfo-Item konstruieren: + //------------------------------ + ScBaseCell* pCell = NULL; + SvxNumberValueType eValType = SVX_VALUE_TYPE_UNDEFINED; + double nCellValue = 0; + String aCellString; + + pDoc->GetCell( pViewData->GetCurX(), + pViewData->GetCurY(), + pViewData->GetTabNo(), + pCell ); + + if ( pCell ) + { + switch ( pCell->GetCellType() ) + { + case CELLTYPE_VALUE: + { + nCellValue = ((ScValueCell*)pCell)->GetValue(); + eValType = SVX_VALUE_TYPE_NUMBER; + aCellString.Erase(); + } + break; + + case CELLTYPE_STRING: + { + ((ScStringCell*)pCell)->GetString( aCellString ); + eValType = SVX_VALUE_TYPE_STRING; + } + break; + + case CELLTYPE_FORMULA: + { + if ( ((ScFormulaCell*)pCell)->IsValue() ) + { + nCellValue = ((ScFormulaCell*)pCell)->GetValue(); + eValType = SVX_VALUE_TYPE_NUMBER; + } + else + { + nCellValue = 0; + eValType = SVX_VALUE_TYPE_UNDEFINED; + } + aCellString.Erase(); + } + break; + + default: + nCellValue = 0; + eValType = SVX_VALUE_TYPE_UNDEFINED; + aCellString.Erase(); + } + } + else // Zelle noch leer (== nicht erzeugt) + { + nCellValue = 0; + eValType = SVX_VALUE_TYPE_UNDEFINED; + aCellString.Erase(); + } + + switch ( eValType ) + { + case SVX_VALUE_TYPE_STRING: + *ppItem = new SvxNumberInfoItem( + pDoc->GetFormatTable(), + aCellString, + SID_ATTR_NUMBERFORMAT_INFO ); + break; + + case SVX_VALUE_TYPE_NUMBER: + *ppItem = new SvxNumberInfoItem( + pDoc->GetFormatTable(), + nCellValue, + SID_ATTR_NUMBERFORMAT_INFO ); + break; + + case SVX_VALUE_TYPE_UNDEFINED: + default: + *ppItem = new SvxNumberInfoItem( + pDoc->GetFormatTable(), + (const USHORT) + SID_ATTR_NUMBERFORMAT_INFO ); + } +} + +//------------------------------------------------------------------ + +void ScTabViewShell::UpdateNumberFormatter( + ScDocument* pDoc, + const SvxNumberInfoItem& rInfoItem ) +{ + const ULONG nDelCount = rInfoItem.GetDelCount(); + + if ( nDelCount > 0 ) + { + const ULONG* pDelArr = rInfoItem.GetDelArray(); + + for ( USHORT i=0; i<nDelCount; i++ ) + rInfoItem.GetNumberFormatter()->DeleteEntry( pDelArr[i] ); + } + + // sollte besser UpdateNumberFormats() heissen ? + pDoc->DeleteNumberFormat( rInfoItem.GetDelArray(), + rInfoItem.GetDelCount() ); +} + + + + + + diff --git a/sc/source/ui/view/tabvwsh8.cxx b/sc/source/ui/view/tabvwsh8.cxx new file mode 100644 index 000000000000..156ee6d70aba --- /dev/null +++ b/sc/source/ui/view/tabvwsh8.cxx @@ -0,0 +1,128 @@ +/************************************************************************* + * + * $RCSfile: tabvwsh8.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <svx/boxitem.hxx> + +#include "tabvwsh.hxx" +#include "document.hxx" + + +//------------------------------------------------------------------ + +void ScTabViewShell::SetDefaultFrameLine( const SvxBorderLine* pLine ) +{ + if ( pLine ) + { + delete pCurFrameLine; + pCurFrameLine = new SvxBorderLine( &pLine->GetColor(), + pLine->GetOutWidth(), + pLine->GetInWidth(), + pLine->GetDistance() ); + } + else if ( pCurFrameLine ) + { + delete pCurFrameLine; + pCurFrameLine = NULL; + } +} + +//------------------------------------------------------------------ + +BOOL __EXPORT ScTabViewShell::HasSelection( BOOL bText ) const +{ + BOOL bHas = FALSE; + ScViewData* pData = (ScViewData*)GetViewData(); // const weggecasted + if ( bText ) + { + // Text enthalten: Anzahl2 >= 1 + ScDocument* pDoc = pData->GetDocument(); + ScMarkData& rMark = pData->GetMarkData(); + ScAddress aCursor( pData->GetCurX(), pData->GetCurX(), pData->GetTabNo() ); + double fVal = 0.0; + if ( pDoc->GetSelectionFunction( SUBTOTAL_FUNC_CNT2, aCursor, rMark, fVal ) ) + bHas = ( fVal > 0.5 ); + } + else + { + ScRange aRange; + if ( pData->GetSimpleArea( aRange ) ) + bHas = ( aRange.aStart != aRange.aEnd ); // mehr als 1 Zelle + else + bHas = TRUE; // Mehrfachselektion + } + return bHas; +} + +//------------------------------------------------------------------ + + + + + diff --git a/sc/source/ui/view/tabvwsh9.cxx b/sc/source/ui/view/tabvwsh9.cxx new file mode 100644 index 000000000000..f53b2038768f --- /dev/null +++ b/sc/source/ui/view/tabvwsh9.cxx @@ -0,0 +1,563 @@ +/************************************************************************* + * + * $RCSfile: tabvwsh9.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +// TOOLS +#define _BIGINT_HXX +#define _SFXMULTISEL_HXX +#define _STACK_HXX +#define _QUEUE_HXX +#define _DYNARR_HXX +#define _TREELIST_HXX +#define _CACHESTR_HXX +#define _NEW_HXX +//#define _SHL_HXX +//#define _LINK_HXX +//#define _ERRCODE_HXX +//#define _GEN_HXX +//#define _FRACT_HXX +//#define _STRING_HXX +//#define _MTF_HXX +//#define _CONTNR_HXX +//#define _LIST_HXX +//#define _TABLE_HXX +#define _DYNARY_HXX +//#define _UNQIDX_HXX +#define _SVMEMPOOL_HXX +//#define _UNQID_HXX +//#define _DEBUG_HXX +//#define _DATE_HXX +//#define _TIME_HXX +//#define _DATETIME_HXX +//#define _INTN_HXX +//#define _WLDCRD_HXX +//#define _FSYS_HXX +//#define _STREAM_HXX +#define _CACHESTR_HXX +#define _SV_MULTISEL_HXX + +//SV +//#define _CLIP_HXX *** +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _FONTDLG_HXX +#define _PRVWIN_HXX +//#define _COLOR_HXX +//#define _PAL_HXX +//#define _BITMAP_HXX +//#define _GDIOBJ_HXX +//#define _POINTR_HXX +//#define _ICON_HXX +//#define _IMAGE_HXX +//#define _KEYCOD_HXX +//#define _EVENT_HXX +#define _HELP_HXX +//#define _APP_HXX +//#define _MDIAPP_HXX +//#define _TIMER_HXX +//#define _METRIC_HXX +//#define _REGION_HXX +//#define _OUTDEV_HXX +//#define _SYSTEM_HXX +//#define _VIRDEV_HXX +//#define _JOBSET_HXX +//#define _PRINT_HXX +//#define _WINDOW_HXX +//#define _SYSWIN_HXX +//#define _WRKWIN_HXX +#define _MDIWIN_HXX +//#define _FLOATWIN_HXX +//#define _DOCKWIN_HXX +//#define _CTRL_HXX +//#define _SCRBAR_HXX +//#define _BUTTON_HXX +//#define _IMAGEBTN_HXX +//#define _FIXED_HXX +//#define _GROUP_HXX +//#define _EDIT_HXX +//#define _COMBOBOX_HXX +//#define _LSTBOX_HXX +//#define _SELENG_HXX *** +//#define _SPLIT_HXX +#define _SPIN_HXX +//#define _FIELD_HXX +//#define _MOREBTN_HXX *** +//#define _TOOLBOX_HXX +//#define _STATUS_HXX *** +//#define _DIALOG_HXX +//#define _MSGBOX_HXX +//#define _SYSDLG_HXX +//#define _FILDLG_HXX +//#define _PRNDLG_HXX +#define _COLDLG_HXX +//#define _TABDLG_HXX +//#define _MENU_HXX +//#define _GDIMTF_HXX +//#define _POLY_HXX +//#define _ACCEL_HXX +//#define _GRAPH_HXX +#define _SOUND_HXX + +#if defined WIN +#define _MENUBTN_HXX +#endif + +//svtools +#define _SCRWIN_HXX +#define _RULER_HXX +//#define _TABBAR_HXX +//#define _VALUESET_HXX +#define _STDMENU_HXX +//#define _STDCTRL_HXX +//#define _CTRLBOX_HXX +#define _CTRLTOOL_HXX +#define _EXTATTR_HXX +#define _FRM3D_HXX +#define _EXTATTR_HXX + +//SVTOOLS +//#define _SVTREELIST_HXX *** +#define _FILTER_HXX +//#define _SVLBOXITM_HXX *** +//#define _SVTREEBOX_HXX *** +#define _SVICNVW_HXX +#define _SVTABBX_HXX + +//sfxcore.hxx +//#define _SFXINIMGR_HXX *** +//#define _SFXCFGITEM_HXX +//#define _SFX_PRINTER_HXX +#define _SFXGENLINK_HXX +#define _SFXHINTPOST_HXX +//#define _SFXDOCINF_HXX *** +#define _SFXLINKHDL_HXX +//#define _SFX_PROGRESS_HXX + +//sfxsh.hxx +//#define _SFX_SHELL_HXX +//#define _SFXAPP_HXX +//#define _SFX_BINDINGS_HXX +#define _SFXDISPATCH_HXX //??? +//#define _SFXMSG_HXX *** +//#define _SFXOBJFACE_HXX *** +//#define _SFXREQUEST_HXX +#define _SFXMACRO_HXX + +// SFX +//#define _SFXAPPWIN_HXX *** +#define _SFX_SAVEOPT_HXX +//#define _SFX_CHILDWIN_HXX +//#define _SFXCTRLITEM_HXX +#define _SFXPRNMON_HXX +#define _INTRO_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFXFILEDLG_HXX +#define _PASSWD_HXX +#define _SFXTBXCTRL_HXX +#define _SFXSTBITEM_HXX +#define _SFXMNUITEM_HXX +#define _SFXIMGMGR_HXX +#define _SFXTBXMGR_HXX +#define _SFXSTBMGR_HXX +#define _SFX_MINFITEM_HXX +#define _SFXEVENT_HXX + +//sfxitems.hxx +#define _SFX_WHMAP_HXX +#define _ARGS_HXX +//#define _SFXPOOLITEM_HXX +//#define _SFXINTITEM_HXX +//#define _SFXENUMITEM_HXX +//#define _SFXFLAGITEM_HXX +//#define _SFXSTRITEM_HXX +#define _SFXPTITEM_HXX +#define _SFXRECTITEM_HXX +//#define _SFXITEMPOOL_HXX *** +//#define _SFXITEMSET_HXX *** +#define _SFXITEMITER_HXX +//#define _SFX_WHITER_HXX *** +#define _SFXPOOLCACH_HXX +#define _AEITEM_HXX //??? +#define _SFXRNGITEM_HXX +#define _SFXSLSTITM_HXX //??? +#define _SFXSTYLE_HXX + +//sfxdlg.hxx +//#define _SFXDLG_HXX *** +//#define _SFXTABDLG_HXX *** +//#define _BASEDLGS_HXX *** +#define _DINFDLG_HXX +#define _SFXDINFEDT_HXX +#define _SFX_MGETEMPL_HXX +#define _SFX_TPLPITEM_HXX +#define _SFX_STYLEDLG_HXX +#define _NEWSTYLE_HXX +#define _SFXDOCTEMPL_HXX +#define _SFXDOCTDLG_HXX +//#define _SFXDOCKWIN_HXX *** +#define _SFX_TEMPLDLG_HXX +#define _SFXNEW_HXX +#define _SFXDOCMAN_HXX + +//sfxdoc.hxx +//#define _SFXDOC_HXX *** +//#define _SFX_OBJSH_HXX *** +//#define _SFX_CLIENTSH_HXX *** +#define _SFX_DOCFILT_HACK_HXX +#define _SFX_FCONTNR_HXX +#define _SFXDOCFILE_HXX +//#define _SFXFRAME_HXX *** +//#define _SFXVIEWFRM_HXX *** +//#define _SFXVIEWSH_HXX *** +#define _MDIFRM_HXX +#define _SFX_IPFRM_HXX +#define _SFX_INTERNO_HXX +#define _FSETOBJSH_HXX + +//xout.hxx +//#define _XENUM_HXX *** +//#define _XPOLY_HXX *** +//#define _XATTR_HXX *** +#define _XOUTX_HXX +//#define _XPOOL_HXX *** +//#define _XTABLE_HXX *** + +//si.hxx +//#define _SI_HXX *** +#define _SIDLL_HXX +#define _VCATTR_HXX +#define _VCONT_HXX +#define _VCSBX_HXX +#define _SI_NOVCSBXFORM +#define SI_NOOTHERFORMS +#define _SI_NOVCSBXBUTTON +#define _SI_NOVCSBXCHECKBOX +#define _SI_NOVCSBXRADIOBUTTON +#define _SI_NOVCSBXPUSHBUTTON +#define _SI_NOVCSBXSPINBUTTON +#define _SI_NOVCSBXFIXEDTEXT +#define _SI_NOVCSBXGROUPBOX +#define _SI_NOVCSBXLISTBOX +#define _SI_NOVCSBXCOMBOBOX +#define _SI_NOVCSBXEDIT +#define _SI_NOVCSBXSCROLLBAR +#define _SI_NOVCSBXHSCROLLBAR +#define _SI_BOVCSBXVSCROLLBAR +#define _SI_NOVCSBXPREVIEW +#define _SI_NOVCSBXURLBUTTON +#define _VCTRLS_HXX +//#define _VCDRWOBJ_HXX *** +//#define _SI_NOVCDRAWMODEL *** +#define _SI_NOVCDRAWPAGE +#define _SI_NOVCDRAWVIEW +#define _VCBRW_HXX +#define _VCFORM_HXX + +//svdraw.hxx +//#define _SVDRAW_HXX *** +#define _SDR_NOITEMS +#define _SDR_NOTOUCH +#define _SDR_NOTRANSFORM +//#define _SDR_NOOBJECTS *** +//#define _SDR_NOVIEWS *** +#define _SDR_NOVIEWMARKER +#define _SDR_NODRAGMETHODS +//#define _SDR_NOUNDO *** +#define _SDR_NOXOUTDEV + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_THESDLG_HXX + +//drawdlgs.hxx +//#define _SVX_DRAWDLGS_HXX *** +//#define _SVX_DLG_CTRL_HXX *** +#define _SVX_DLG_NAME_HXX +#define _SVX_TAB_AREA_HXX +#define _SVX_TAB_LINE_HXX +#define _SVX_TRANSFRM_HXX + +class SbxArray; + +// INCLUDE --------------------------------------------------------------- + +#include <svx/svdmark.hxx> +#include <svx/svdview.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/request.hxx> +#include <sfx2/viewfrm.hxx> +#include <svtools/whiter.hxx> + +#include "tabvwsh.hxx" +#include "viewdata.hxx" +#include "tabview.hxx" +#include "drwlayer.hxx" +#include "userdat.hxx" + +// forwards -> galwrap.cxx (wg. CLOOKs) + +USHORT GallerySGA_FORMAT_GRAPHIC(); +Graphic GalleryGetGraphic (); +BOOL GalleryIsLinkage (); +String GalleryGetFullPath (); +String GalleryGetFilterName (); + +// forwards -> imapwrap.cxx (wg. CLOOKs) + +class SvxIMapDlg; + +USHORT ScIMapChildWindowId(); +SvxIMapDlg* ScGetIMapDlg(); +const void* ScIMapDlgGetObj( SvxIMapDlg* pDlg ); +const ImageMap& ScIMapDlgGetMap( SvxIMapDlg* pDlg ); + +//------------------------------------------------------------------ + + +//------------------------------------------------------------------ + +void ScTabViewShell::ExecGallery( SfxRequest& rReq ) +{ + const SfxItemSet* pArgs = rReq.GetArgs(); + + if ( pArgs ) + { + const SfxPoolItem* pItem = NULL; + SfxItemState eState = pArgs->GetItemState(SID_GALLERY_FORMATS, TRUE, &pItem); + if ( eState == SFX_ITEM_SET ) + { + UINT32 nFormats = ((const SfxUInt32Item*)pItem)->GetValue(); + + /****************************************************************** + * Graphik einfuegen + ******************************************************************/ + if ( nFormats & GallerySGA_FORMAT_GRAPHIC() ) + { + MakeDrawLayer(); + + Graphic aGraphic = GalleryGetGraphic(); + Point aPos = GetInsertPos(); + + String aPath, aFilter; + if ( GalleryIsLinkage() ) // als Link einfuegen? + { + aPath = GalleryGetFullPath(); + aFilter = GalleryGetFilterName(); + } + + PasteGraphic( aPos, aGraphic, aPath, aFilter ); + } + } + } +} + +void ScTabViewShell::GetGalleryState( SfxItemSet& rSet ) +{ +} + +//------------------------------------------------------------------ + +ScInputHandler* ScTabViewShell::GetInputHandler() const +{ + return pInputHandler; +} + +//------------------------------------------------------------------ + +String __EXPORT ScTabViewShell::GetDescription() const +{ + return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(" ** Test ** ")); +} + +void ScTabViewShell::ExecImageMap( SfxRequest& rReq ) +{ + USHORT nSlot = rReq.GetSlot(); + switch(nSlot) + { + case SID_IMAP: + { + SfxViewFrame* pThisFrame = GetViewFrame(); + USHORT nId = ScIMapChildWindowId(); + pThisFrame->ToggleChildWindow( nId ); + SFX_BINDINGS().Invalidate( SID_IMAP ); + + if ( pThisFrame->HasChildWindow( nId ) ) + { + SvxIMapDlg* pDlg = ScGetIMapDlg(); + if ( pDlg ) + { + SdrView* pDrView = GetSdrView(); + if ( pDrView ) + { + const SdrMarkList& rMarkList = pDrView->GetMarkList(); + if ( rMarkList.GetMarkCount() == 1 ) + UpdateIMap( rMarkList.GetMark( 0 )->GetObj() ); + } + } + } + + rReq.Ignore(); + } + break; + + case SID_IMAP_EXEC: + { + SdrView* pDrView = GetSdrView(); + SdrMark* pMark = pDrView ? pDrView->GetMarkList().GetMark(0) : 0; + + if ( pMark ) + { + SdrObject* pSdrObj = pMark->GetObj(); + SvxIMapDlg* pDlg = ScGetIMapDlg(); + + if ( ScIMapDlgGetObj(pDlg) == (void*) pSdrObj ) + { + const ImageMap& rImageMap = ScIMapDlgGetMap(pDlg); + ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo( pSdrObj ); + + if ( !pIMapInfo ) + pSdrObj->InsertUserData( new ScIMapInfo( rImageMap ) ); + else + pIMapInfo->SetImageMap( rImageMap ); + } + } + } + break; + } +} + +void ScTabViewShell::GetImageMapState( SfxItemSet& rSet ) +{ + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + while ( nWhich ) + { + switch ( nWhich ) + { + case SID_IMAP: + { + // Disabled wird nicht mehr... + + BOOL bThere = FALSE; + SfxViewFrame* pThisFrame = GetViewFrame(); + USHORT nId = ScIMapChildWindowId(); + if ( pThisFrame->KnowsChildWindow(nId) ) + if ( pThisFrame->HasChildWindow(nId) ) + bThere = TRUE; + + ObjectSelectionType eType=GetCurObjectSelectionType(); + BOOL bEnable=(eType==OST_OleObject) ||(eType==OST_Graphic); + if(!bThere && !bEnable) + { + rSet.DisableItem( nWhich ); + } + else + { + rSet.Put( SfxBoolItem( nWhich, bThere ) ); + } + } + break; + + case SID_IMAP_EXEC: + { + BOOL bDisable = TRUE; + + SdrView* pDrView = GetSdrView(); + if ( pDrView ) + { + const SdrMarkList& rMarkList = pDrView->GetMarkList(); + if ( rMarkList.GetMarkCount() == 1 ) + if ( ScIMapDlgGetObj(ScGetIMapDlg()) == + (void*) rMarkList.GetMark(0)->GetObj() ) + bDisable = FALSE; + } + + rSet.Put( SfxBoolItem( SID_IMAP_EXEC, bDisable ) ); + } + break; + } + + nWhich = aIter.NextWhich(); + } +} + + + + diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx new file mode 100644 index 000000000000..75d4d704b343 --- /dev/null +++ b/sc/source/ui/view/tabvwsha.cxx @@ -0,0 +1,650 @@ +/************************************************************************* + * + * $RCSfile: tabvwsha.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#define _ZFORLIST_DECLARE_TABLE +#include "scitems.hxx" +#include <svtools/stritem.hxx> +#include <svtools/whiter.hxx> +#include <svtools/zformat.hxx> +#include <svx/boxitem.hxx> +#include <svx/numinf.hxx> +#include <svx/srchitem.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/request.hxx> +#include <vcl/msgbox.hxx> + +#include "global.hxx" +#include "attrib.hxx" +#include "patattr.hxx" +#include "document.hxx" +#include "cell.hxx" // Input Status Edit-Zellen +#include "globstr.hrc" +#include "scmod.hxx" +#include "inputhdl.hxx" +#include "inputwin.hxx" +#include "docsh.hxx" +#include "viewdata.hxx" +#include "attrdlg.hxx" +#include "appoptio.hxx" +#include "sc.hrc" +#include "stlpool.hxx" +#include "tabvwsh.hxx" +#include "dwfunctr.hxx" + + + +BOOL ScTabViewShell::GetFunction( String& rFuncStr ) +{ + String aStr; + + ScSubTotalFunc eFunc = (ScSubTotalFunc) SC_MOD()->GetAppOptions().GetStatusFunc(); + + USHORT nGlobStrId = 0; + switch (eFunc) + { + case SUBTOTAL_FUNC_AVE: nGlobStrId = STR_FUN_TEXT_AVG; break; + case SUBTOTAL_FUNC_CNT: nGlobStrId = STR_FUN_TEXT_COUNT; break; + case SUBTOTAL_FUNC_CNT2: nGlobStrId = STR_FUN_TEXT_COUNT2; break; + case SUBTOTAL_FUNC_MAX: nGlobStrId = STR_FUN_TEXT_MAX; break; + case SUBTOTAL_FUNC_MIN: nGlobStrId = STR_FUN_TEXT_MIN; break; + case SUBTOTAL_FUNC_SUM: nGlobStrId = STR_FUN_TEXT_SUM; break; + } + if (nGlobStrId) + { + ScViewData* pViewData = GetViewData(); + ScDocument* pDoc = pViewData->GetDocument(); + ScMarkData& rMark = pViewData->GetMarkData(); + USHORT nPosX = pViewData->GetCurX(); + USHORT nPosY = pViewData->GetCurY(); + USHORT nTab = pViewData->GetTabNo(); + + aStr = ScGlobal::GetRscString(nGlobStrId); + aStr += '='; + + // Anzahl im Standardformat, die anderen nach Cursorposition + ULONG nNumFmt = 0; + SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + if ( eFunc != SUBTOTAL_FUNC_CNT && eFunc != SUBTOTAL_FUNC_CNT2 ) + { + // Zahlformat aus Attributen oder Formel + pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt ); + if ( (nNumFmt % SV_COUNTRY_LANGUAGE_OFFSET) == 0 ) + { + ScBaseCell* pCell; + pDoc->GetCell( nPosX, nPosY, nTab, pCell ); + if (pCell && pCell->GetCellType() == CELLTYPE_FORMULA) + nNumFmt = ((ScFormulaCell*)pCell)->GetStandardFormat( + *pFormatter, nNumFmt ); + } + } + ScAddress aCursor( nPosX, nPosY, nTab ); + double nVal; + if ( pDoc->GetSelectionFunction( eFunc, aCursor, rMark, nVal ) ) + { + String aValStr; + Color* pDummy; + pFormatter->GetOutputString( nVal, nNumFmt, aValStr, &pDummy ); + aStr += aValStr; + } + + rFuncStr = aStr; + return TRUE; + } + + return FALSE; +} + + + +// Funktionen, die je nach Selektion disabled sind +// Default: +// SID_DELETE, +// SID_DELETE_CONTENTS, +// FID_DELETE_CELL +// FID_VALIDATION + + +void __EXPORT ScTabViewShell::GetState( SfxItemSet& rSet ) +{ + ScViewData* pViewData = GetViewData(); + ScDocument* pDoc = pViewData->GetDocument(); + ScMarkData& rMark = pViewData->GetMarkData(); + USHORT nPosX = pViewData->GetCurX(); + USHORT nPosY = pViewData->GetCurY(); + USHORT nTab = pViewData->GetTabNo(); + USHORT nMyId = 0; + + SfxViewFrame* pThisFrame = GetViewFrame(); + BOOL bOle = pThisFrame->ISA(SfxInPlaceFrame); + + USHORT nTabCount = pDoc->GetTableCount(); + USHORT nTabSelCount = rMark.GetSelectCount(); + + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + + while ( nWhich ) + { + switch ( nWhich ) + { + case FID_CHG_COMMENT: + { + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScAddress aPos( nPosX, nPosY, nTab ); + if ( pDocSh->IsReadOnly() || !pDocSh->GetChangeAction(aPos) ) + rSet.DisableItem( nWhich ); + } + break; + + case SID_DELETE_PRINTAREA: + if ( !pDoc->GetPrintRangeCount( nTab ) ) + rSet.DisableItem( nWhich ); + break; + + case SID_STATUS_PAGESTYLE: + case SID_HFEDIT: + GetViewData()->GetDocShell()->GetStatePageStyle( *this, rSet, nTab ); + break; + + case SID_SEARCH_ITEM: + rSet.Put( ScGlobal::GetSearchItem() ); + break; + + case SID_SEARCH_OPTIONS: + { + USHORT nOptions = 0xffff; // alles erlaubt + // wenn ReadOnly, kein Ersetzen: + if (GetViewData()->GetDocShell()->IsReadOnly()) + nOptions &= ~( SEARCH_OPTIONS_REPLACE | SEARCH_OPTIONS_REPLACE_ALL ); + rSet.Put( SfxUInt16Item( nWhich, nOptions ) ); + } + break; + + case SID_CURRENTCELL: + { + ScAddress aScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), 0 ); + String aAddr; + aScAddress.Format( aAddr, SCA_ABS ); + SfxStringItem aPosItem( SID_CURRENTCELL, aAddr ); + + rSet.Put( aPosItem ); + } + break; + + case SID_CURRENTTAB: + // Tabelle fuer Basic ist 1-basiert + rSet.Put( SfxUInt16Item( nWhich, GetViewData()->GetTabNo() + 1 ) ); + break; + + case SID_CURRENTDOC: + rSet.Put( SfxStringItem( nWhich, GetViewData()->GetDocShell()->GetTitle() ) ); + break; + + case FID_TOGGLEINPUTLINE: + { + USHORT nId = ScInputWindowWrapper::GetChildWindowId(); + + if ( pThisFrame->KnowsChildWindow( nId ) ) + { + SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId ); + rSet.Put( SfxBoolItem( nWhich, pWnd ? TRUE : FALSE ) ); + } + else + rSet.DisableItem( nWhich ); + } + break; + + case FID_DEL_MANUALBREAKS: + if (!pDoc->HasManualBreaks(nTab)) + rSet.DisableItem( nWhich ); + break; + + case FID_RESET_PRINTZOOM: + { + // disablen, wenn schon Default eingestellt + + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + USHORT nTab = GetViewData()->GetTabNo(); + String aStyleName = pDoc->GetPageStyle( nTab ); + ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool(); + SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName, + SFX_STYLE_FAMILY_PAGE ); + DBG_ASSERT( pStyleSheet, "PageStyle not found" ); + if ( pStyleSheet ) + { + SfxItemSet& rStyleSet = pStyleSheet->GetItemSet(); + USHORT nScale = ((const SfxUInt16Item&) + rStyleSet.Get(ATTR_PAGE_SCALE)).GetValue(); + USHORT nPages = ((const SfxUInt16Item&) + rStyleSet.Get(ATTR_PAGE_SCALETOPAGES)).GetValue(); + if ( nScale == 100 && nPages == 0 ) + rSet.DisableItem( nWhich ); + } + } + break; + + case FID_SCALE: + case SID_ATTR_ZOOM: + if ( bOle ) + rSet.DisableItem( nWhich ); + else + { + const Fraction& rOldY = GetViewData()->GetZoomY(); + USHORT nZoom = (USHORT)(( rOldY.GetNumerator() * 100 ) + / rOldY.GetDenominator()); + rSet.Put( SvxZoomItem( SVX_ZOOM_PERCENT, nZoom, nWhich ) ); + } + break; + + case FID_TOGGLESYNTAX: + rSet.Put(SfxBoolItem(nWhich, GetViewData()->IsSyntaxMode())); + break; + + case FID_TOGGLEHEADERS: + rSet.Put(SfxBoolItem(nWhich, GetViewData()->IsHeaderMode())); + break; + + case FID_PAGEBREAKMODE: + if ( bOle ) + rSet.DisableItem( nWhich ); + else + rSet.Put(SfxBoolItem(nWhich, GetViewData()->IsPagebreakMode())); + break; + + case FID_FUNCTION_BOX: + nMyId = ScFunctionChildWindow::GetChildWindowId(); + rSet.Put(SfxBoolItem(FID_FUNCTION_BOX, pThisFrame->HasChildWindow(nMyId))); + break; + + case FID_PROTECT_DOC: + rSet.Put(SfxBoolItem(nWhich, pDoc->IsDocProtected())); + break; + + case FID_PROTECT_TABLE: + rSet.Put(SfxBoolItem(nWhich, pDoc->IsTabProtected(nTab))); + break; + + case SID_AUTO_OUTLINE: + { + ScMarkData& rMark = GetViewData()->GetMarkData(); + + if (pDoc->GetChangeTrack()!=NULL || rMark.IsMultiMarked()) + { + rSet.DisableItem( nWhich ); + } + } + break; + + case SID_OUTLINE_DELETEALL: + { + ScDocument* pDoc = GetViewData()->GetDocument(); + USHORT nOlTab = GetViewData()->GetTabNo(); + ScOutlineTable* pOlTable = pDoc->GetOutlineTable( nOlTab ); + if (pOlTable == NULL) + rSet.DisableItem( nWhich ); + } + break; + + case SID_WINDOW_SPLIT: + rSet.Put(SfxBoolItem(nWhich, + pViewData->GetHSplitMode() == SC_SPLIT_NORMAL || + pViewData->GetVSplitMode() == SC_SPLIT_NORMAL )); + break; + + case SID_WINDOW_FIX: + rSet.Put(SfxBoolItem(nWhich, + pViewData->GetHSplitMode() == SC_SPLIT_FIX || + pViewData->GetVSplitMode() == SC_SPLIT_FIX )); + break; + + case FID_CHG_SHOW: + { + if(pDoc->GetChangeTrack()==NULL) + rSet.DisableItem( nWhich); + } + break; + case FID_CHG_ACCEPT: + { + rSet.Put(SfxBoolItem(FID_CHG_ACCEPT, + pThisFrame->HasChildWindow(FID_CHG_ACCEPT))); + if(pDoc->GetChangeTrack()==NULL) + { + if ( !pThisFrame->HasChildWindow(FID_CHG_ACCEPT) ) + { + rSet.DisableItem( nWhich); + } + } + } + break; + + case SID_FORMATPAGE: + //! bei geschuetzten Tabellen ??? + if (GetViewData()->GetDocShell()->IsReadOnly()) + rSet.DisableItem( nWhich ); + break; + + case SID_PRINTPREVIEW: + // #58924# Toggle-Slot braucht einen State + rSet.Put( SfxBoolItem( nWhich, FALSE ) ); + break; + + } // switch ( nWitch ) + nWhich = aIter.NextWhich(); + } // while ( nWitch ) +} + +//------------------------------------------------------------------ +void ScTabViewShell::ExecuteCellFormatDlg( SfxRequest& rReq, USHORT nTabPage ) +{ + ScAttrDlg* pDlg = NULL; + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = GetViewData()->GetDocument(); + + SvxBoxItem aLineOuter( ATTR_BORDER ); + SvxBoxInfoItem aLineInner( ATTR_BORDER_INNER ); + + SvxNumberInfoItem* pNumberInfoItem = NULL; + const ScPatternAttr* pOldAttrs = GetSelectionPattern(); + SfxItemSet* pOldSet = new SfxItemSet( + pOldAttrs->GetItemSet() ); + + + // Umrandungs-Items holen und in den Set packen: + GetSelectionFrame( aLineOuter, aLineInner ); + pOldSet->Put( aLineOuter ); + pOldSet->Put( aLineInner ); + + // NumberFormat Value aus Value und Language erzeugen und eintueten + pOldSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT, + pOldAttrs->GetNumberFormat( pDoc->GetFormatTable() ) ) ); + + MakeNumberInfoItem( pDoc, GetViewData(), &pNumberInfoItem ); + + pOldSet->MergeRange( SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO ); + pOldSet->Put(*pNumberInfoItem ); + + bInFormatDialog = TRUE; + pDlg = new ScAttrDlg( GetViewFrame(), GetDialogParent(), pOldSet ); + if ( nTabPage != 0xffff ) + pDlg->SetCurPageId( nTabPage ); + short nResult = pDlg->Execute(); + bInFormatDialog = FALSE; + + if ( nResult == RET_OK ) + { + const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); + + const SfxPoolItem* pItem=NULL; + if(pOutSet->GetItemState(SID_ATTR_NUMBERFORMAT_INFO,TRUE,&pItem)==SFX_ITEM_SET) + { + + UpdateNumberFormatter( pDoc,(const SvxNumberInfoItem&)*pItem); + } + + ApplyAttributes( pOutSet, pOldSet ); + + rReq.Done( *pOutSet ); + } + delete pOldSet; + delete pNumberInfoItem; + delete pDlg; +} + +//------------------------------------------------------------------ +void ScTabViewShell::ExecuteInputDirect() +{ + ScModule* pScMod = SC_MOD(); + if( !pScMod->IsFormulaMode() ) + pScMod->InputEnterHandler(); +} + +//------------------------------------------------------------------ + +void ScTabViewShell::UpdateInputHandler( BOOL bForce /* = FALSE */ ) +{ + ScInputHandler* pHdl = pInputHandler ? pInputHandler : SC_MOD()->GetInputHdl(); + + if ( pHdl ) + { + String aString; + const EditTextObject* pObject = NULL; + ScViewData* pViewData = GetViewData(); + ScDocument* pDoc = pViewData->GetDocument(); + CellType eType; + USHORT nPosX = pViewData->GetCurX(); + USHORT nPosY = pViewData->GetCurY(); + USHORT nTab = pViewData->GetTabNo(); + USHORT nStartTab = 0; + USHORT nEndTab = 0; + USHORT nStartCol = 0; + USHORT nStartRow = 0; + USHORT nEndCol = 0; + USHORT nEndRow = 0; + + pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab, + nEndCol, nEndRow, nEndTab, FALSE ); + + PutInOrder( nStartCol, nEndCol ); + PutInOrder( nStartRow, nEndRow ); + PutInOrder( nStartTab, nEndTab ); + + BOOL bHideFormula = FALSE; + BOOL bHideAll = FALSE; + + if (pDoc->IsTabProtected(nTab)) + { + const ScProtectionAttr* pProt = (const ScProtectionAttr*) + pDoc->GetAttr( nPosX,nPosY,nTab, + ATTR_PROTECTION); + bHideFormula = pProt->GetHideFormula(); + bHideAll = pProt->GetHideCell(); + } + + if (!bHideAll) + { + pDoc->GetCellType( nPosX, nPosY, nTab, eType ); + if (eType == CELLTYPE_FORMULA) + { + if (!bHideFormula) + pDoc->GetFormula( nPosX, nPosY, nTab, aString ); + } + else if (eType == CELLTYPE_EDIT) + { + ScBaseCell* pCell; + pDoc->GetCell( nPosX, nPosY, nTab, pCell ); + ((ScEditCell*)pCell)->GetData( pObject ); + } + else + { + pDoc->GetInputString( nPosX, nPosY, nTab, aString ); + if (eType == CELLTYPE_STRING) + { + // Bei Bedarf ein ' vorneweg, damit der String nicht ungewollt + // als Zahl interpretiert wird, und um dem Benutzer zu zeigen, + // dass es ein String ist (#35060#). + //! Auch bei Zahlformat "Text"? -> dann beim Editieren wegnehmen + + SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + ULONG nNumFmt; + pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt ); + double fDummy; + if ( pFormatter->IsNumberFormat(aString, nNumFmt, fDummy) ) + aString.Insert('\'',0); + } + } + } + + ScInputHdlState aState( ScAddress( nPosX, nPosY, nTab ), + ScAddress( nStartCol, nStartRow, nTab ), + ScAddress( nEndCol, nEndRow, nTab ), + aString, + pObject ); + + pHdl->NotifyChange( &aState, bForce ); + } + + SfxBindings& rBindings = SFX_BINDINGS(); + rBindings.Invalidate( SID_STATUS_SUM ); // immer zusammen mit Eingabezeile + rBindings.Invalidate( SID_ATTR_SIZE ); +} + +//------------------------------------------------------------------ + +void __EXPORT ScTabViewShell::ExecuteSave( SfxRequest& rReq ) +{ + // nur SID_SAVEDOC / SID_SAVEASDOC + + // Eingabe auf jeden Fall abschliessen, auch wenn eine Formel bearbeitet wird + SC_MOD()->InputEnterHandler(); + + // ansonsten normal weiter + GetViewData()->GetDocShell()->ExecuteSlot( rReq ); +} + +void __EXPORT ScTabViewShell::GetSaveState( SfxItemSet& rSet ) +{ + SfxShell* pDocSh = GetViewData()->GetDocShell(); + + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + while( nWhich ) + { + // Status von der DocShell holen + pDocSh->GetSlotState( nWhich, NULL, &rSet ); + nWhich = aIter.NextWhich(); + } +} + +//------------------------------------------------------------------ + +void ScTabViewShell::ExecDrawOpt( SfxRequest& rReq ) +{ + ScViewOptions aViewOptions = GetViewData()->GetOptions(); + ScGridOptions aGridOptions = aViewOptions.GetGridOptions(); + + SfxBindings& rBindings = SFX_BINDINGS(); + const SfxItemSet* pArgs = rReq.GetArgs(); + const SfxPoolItem* pItem; + USHORT nSlotId = rReq.GetSlot(); + switch (nSlotId) + { + case SID_GRID_VISIBLE: + if ( pArgs && pArgs->GetItemState(nSlotId,TRUE,&pItem) == SFX_ITEM_SET ) + { + aGridOptions.SetGridVisible( ((const SfxBoolItem*)pItem)->GetValue() ); + aViewOptions.SetGridOptions(aGridOptions); + rBindings.Invalidate(SID_GRID_VISIBLE); + } + break; + + case SID_GRID_USE: + if ( pArgs && pArgs->GetItemState(nSlotId,TRUE,&pItem) == SFX_ITEM_SET ) + { + aGridOptions.SetUseGridSnap( ((const SfxBoolItem*)pItem)->GetValue() ); + aViewOptions.SetGridOptions(aGridOptions); + rBindings.Invalidate(SID_GRID_USE); + } + break; + + case SID_HELPLINES_MOVE: + if ( pArgs && pArgs->GetItemState(nSlotId,TRUE,&pItem) == SFX_ITEM_SET ) + { + aViewOptions.SetOption( VOPT_HELPLINES, ((const SfxBoolItem*)pItem)->GetValue() ); + rBindings.Invalidate(SID_HELPLINES_MOVE); + } + break; + } + + GetViewData()->SetOptions(aViewOptions); +} + +void ScTabViewShell::GetDrawOptState( SfxItemSet& rSet ) +{ + SfxBoolItem aBool; + + const ScViewOptions& rViewOptions = GetViewData()->GetOptions(); + const ScGridOptions& rGridOptions = rViewOptions.GetGridOptions(); + + aBool.SetValue(rGridOptions.GetGridVisible()); + aBool.SetWhich( SID_GRID_VISIBLE ); + rSet.Put( aBool ); + + aBool.SetValue(rGridOptions.GetUseGridSnap()); + aBool.SetWhich( SID_GRID_USE ); + rSet.Put( aBool ); + + aBool.SetValue(rViewOptions.GetOption( VOPT_HELPLINES )); + aBool.SetWhich( SID_HELPLINES_MOVE ); + rSet.Put( aBool ); +} + + + + diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx new file mode 100644 index 000000000000..d4c1ccdfbce1 --- /dev/null +++ b/sc/source/ui/view/tabvwshb.cxx @@ -0,0 +1,468 @@ +/************************************************************************* + * + * $RCSfile: tabvwshb.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +#ifdef WNT +#pragma optimize ("", off) +#endif + +// INCLUDE --------------------------------------------------------------- + +#include <svx/pfiledlg.hxx> +#include <svx/svdmark.hxx> +#include <svx/svdograf.hxx> +#include <svx/svdoole2.hxx> +#include <svx/svdview.hxx> +#include <svx/linkmgr.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <so3/ipenv.hxx> +#include <so3/ipobj.hxx> +#include <so3/linkdlg.hxx> +#include <so3/svstor.hxx> +#include <so3/soerr.hxx> +#include <svtools/rectitem.hxx> +#include <svtools/whiter.hxx> +#include <sim2/simdll.hxx> +#include <sch/schdll.hxx> +#include <sch/memchrt.hxx> +#include <sch/schdll0.hxx> + + + +#ifndef SO2_DECL_SVINPLACEOBJECT_DEFINED +#define SO2_DECL_SVINPLACEOBJECT_DEFINED +SO2_DECL_REF(SvInPlaceObject) +#endif +#ifndef SO2_DECL_SVSTORAGE_DEFINED +#define SO2_DECL_SVSTORAGE_DEFINED +SO2_DECL_REF(SvStorage) +#endif + +#include "tabvwsh.hxx" +#include "globstr.hrc" +#include "scmod.hxx" +#include "document.hxx" +#include "sc.hrc" +#include "client.hxx" +#include "fuinsert.hxx" +#include "docsh.hxx" + +// STATIC DATA ----------------------------------------------------------- + +void ScTabViewShell::ConnectObject( SdrOle2Obj* pObj ) +{ + // wird aus dem Paint gerufen + + SvInPlaceObjectRef xIPObj = pObj->GetObjRef(); + Window* pWin = GetActiveWin(); + + // #41412# wenn schon connected ist, nicht nochmal SetObjArea/SetSizeScale + + SfxInPlaceClientRef xClient = FindIPClient( xIPObj, pWin ); + if ( !xClient.Is() ) + { + xClient = new ScClient( this, pWin, GetSdrView()->GetModel() ); + + ErrCode nErr = xIPObj->DoConnect( xClient ); + if (nErr != ERRCODE_NONE) + ErrorHandler::HandleError(nErr); + + Rectangle aRect = pObj->GetLogicRect(); + Size aDrawSize = aRect.GetSize(); + Size aOleSize = xIPObj->GetVisArea().GetSize(); + + // sichtbarer Ausschnitt wird nur inplace veraendert! + aRect.SetSize( aOleSize ); + xClient->GetEnv()->SetObjArea( aRect ); + + Fraction aScaleWidth (aDrawSize.Width(), aOleSize.Width() ); + Fraction aScaleHeight(aDrawSize.Height(), aOleSize.Height() ); + aScaleWidth.ReduceInaccurate(10); // kompatibel zum SdrOle2Obj + aScaleHeight.ReduceInaccurate(10); + xClient->GetEnv()->SetSizeScale(aScaleWidth,aScaleHeight); + + ((ScClient*)(SfxInPlaceClient*)xClient)->SetGrafEdit( NULL ); + } +} + +BOOL ScTabViewShell::ActivateObject( SdrOle2Obj* pObj, long nVerb ) +{ + // #41081# Gueltigkeits-Hinweisfenster nicht ueber dem Objekt stehenlassen + RemoveHintWindow(); + + SvInPlaceObjectRef xIPObj = pObj->GetObjRef(); + Window* pWin = GetActiveWin(); + ErrCode nErr = ERRCODE_NONE; + BOOL bErrorShown = FALSE; + + if ( xIPObj->IsLink() ) + nErr = xIPObj->DoVerb(nVerb); // gelinkt -> ohne Client etc. + else + { + SfxInPlaceClientRef xClient = FindIPClient( xIPObj, pWin ); + if ( !xClient.Is() ) + xClient = new ScClient( this, pWin, GetSdrView()->GetModel() ); + nErr = xIPObj->DoConnect( xClient ); + + if ( !(nErr & ERRCODE_ERROR_MASK) ) + { + Rectangle aRect = pObj->GetLogicRect(); + Size aDrawSize = aRect.GetSize(); + Size aOleSize = xIPObj->GetVisArea().GetSize(); + aOleSize = OutputDevice::LogicToLogic( aOleSize, + xIPObj->GetMapUnit(), MAP_100TH_MM ); + + // sichtbarer Ausschnitt wird nur inplace veraendert! + aRect.SetSize( aOleSize ); + xClient->GetEnv()->SetObjArea( aRect ); + + Fraction aScaleWidth (aDrawSize.Width(), aOleSize.Width() ); + Fraction aScaleHeight(aDrawSize.Height(), aOleSize.Height() ); + aScaleWidth.ReduceInaccurate(10); // kompatibel zum SdrOle2Obj + aScaleHeight.ReduceInaccurate(10); + xClient->GetEnv()->SetSizeScale(aScaleWidth,aScaleHeight); + + ((ScClient*)(SfxInPlaceClient*)xClient)->SetGrafEdit( NULL ); + + // Link fuer Daten-Highlighting im Chart setzen + if ( SFX_APP()->HasFeature(SFX_FEATURE_SCHART) ) + { + SvGlobalName aObjClsId = *xIPObj->GetSvFactory(); + if (SchModuleDummy::HasID( aObjClsId )) + { + SchMemChart* pMemChart = SchDLL::GetChartData(xIPObj); + if (pMemChart) + pMemChart->SetSelectionHdl( LINK( GetViewData()->GetDocShell(), + ScDocShell, ChartSelectionHdl ) ); + } + } + + nErr = SfxViewShell::DoVerb( xClient, nVerb ); + bErrorShown = TRUE; + // SfxViewShell::DoVerb zeigt seine Fehlermeldungen selber an + } + } + if (nErr != ERRCODE_NONE && !bErrorShown) + ErrorHandler::HandleError(nErr); + + //! SetDocumentName sollte schon im Sfx passieren ??? + xIPObj->SetDocumentName( GetViewData()->GetDocShell()->GetTitle() ); + + return ( !(nErr & ERRCODE_ERROR_MASK) ); +} + +ErrCode __EXPORT ScTabViewShell::DoVerb(long nVerb) +{ + SdrView* pView = GetSdrView(); + if (!pView) + return ERRCODE_SO_NOTIMPL; // soll nicht sein + + SdrOle2Obj* pOle2Obj = NULL; + SdrGrafObj* pGrafObj = NULL; + SdrObject* pObj = NULL; + ErrCode nErr = ERRCODE_NONE; + + const SdrMarkList& rMarkList = pView->GetMarkList(); + if (rMarkList.GetMarkCount() == 1) + { + pObj = rMarkList.GetMark(0)->GetObj(); + if (pObj->GetObjIdentifier() == OBJ_OLE2) + pOle2Obj = (SdrOle2Obj*) pObj; + else if (pObj->GetObjIdentifier() == OBJ_GRAF) + { + pGrafObj = (SdrGrafObj*) pObj; + } + } + + if (pOle2Obj) + { + ActivateObject( pOle2Obj, nVerb ); + } + else if ( pGrafObj && SFX_APP()->HasFeature(SFX_FEATURE_SIMAGE) ) + { + /********************************************************** + * OLE-Objekt erzeugen, StarImage starten + * Grafik-Objekt loeschen (durch OLE-Objekt ersetzt) + **********************************************************/ + + pView->HideMarkHdl(NULL); + + String aEmtpyString; + SvStorageRef aStor = new SvStorage(String()); + SvInPlaceObjectRef aNewIPObj = +#ifndef SO3 + &SvInPlaceObject::ClassFactory()->CreateAndInit( + *SIM_MOD()->pSimDrawDocShellFactory, aStor ); +#else + &((SvFactory*)SvInPlaceObject::ClassFactory())->CreateAndInit( + *SIM_MOD()->pSimDrawDocShellFactory, aStor ); +#endif + if ( aNewIPObj.Is() ) + { + SdrGrafObj* pTempSdrGrafObj = (SdrGrafObj*) pObj->Clone (); + pView->BegUndo( ScGlobal::GetRscString( STR_UNDO_GRAFEDIT ) ); + + SvEmbeddedInfoObject* pInfo = + GetViewFrame()->GetObjectShell()-> + InsertObject( aNewIPObj, String() ); + String aName; + if( pInfo ) + aName = pInfo->GetObjName(); + + Rectangle aRect = pObj->GetLogicRect(); + SdrOle2Obj* pSdrOle2Obj = new SdrOle2Obj( aNewIPObj, aName, aRect ); + + SdrPageView* pPV = pView->GetPageViewPvNum(0); + pView->ReplaceObject(pObj, *pPV, pSdrOle2Obj); + pSdrOle2Obj->SetLogicRect(aRect); // erst nach InsertObject !!! + aNewIPObj->SetVisAreaSize( aRect.GetSize() ); + + const Graphic& rGraphic = pTempSdrGrafObj->GetGraphic(); + SimDLL::Update(aNewIPObj, rGraphic, GetActiveWin() ); + +// pView->EndUndo(); + // passendes EndUndo in ScDrawView::MarkListHasChanged + + ActivateObject( pSdrOle2Obj, SVVERB_SHOW ); + + ScClient* pClient = (ScClient*) GetIPClient(); + pClient->SetGrafEdit( pTempSdrGrafObj ); + } + } + else + DBG_ERROR("kein Objekt fuer Verb gefunden"); + + return nErr; +} + +void ScTabViewShell::ExecDrawIns(SfxRequest& rReq) +{ + USHORT nSlot = rReq.GetSlot(); + if (nSlot != SID_OBJECTRESIZE ) + { + SC_MOD()->InputEnterHandler(); + UpdateInputHandler(); + } + + // Rahmen fuer Chart einfuegen wird abgebrochen: + FuPoor* pPoor = GetDrawFuncPtr(); + if ( pPoor && pPoor->GetSlotID() == SID_DRAW_CHART ) + SFX_DISPATCHER().Execute(SID_DRAW_CHART, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); + + MakeDrawLayer(); + + SfxBindings& rBindings = GetViewFrame()->GetBindings(); + ScTabView* pTabView = GetViewData()->GetView(); + Window* pWin = pTabView->GetActiveWin(); + SdrView* pView = pTabView->GetSdrView(); + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); +// SdrModel* pDrModel = pDocSh->MakeDrawLayer(); + SdrModel* pDrModel = pView->GetModel(); + + switch ( nSlot ) + { + case SID_INSERT_GRAPHIC: + FuInsertGraphic(this, pWin, pView, pDrModel, rReq); + // shell is set in MarkListHasChanged + break; + + case SID_INSERT_DIAGRAM: + FuInsertChart(this, pWin, pView, pDrModel, rReq); +//? SC_MOD()->SetFunctionDlg( NULL );//XXX + break; + + case SID_INSERT_OBJECT: + case SID_INSERT_PLUGIN: + case SID_INSERT_SOUND: + case SID_INSERT_VIDEO: + case SID_INSERT_APPLET: + case SID_INSERT_SIMAGE: + case SID_INSERT_SMATH: + case SID_INSERT_FLOATINGFRAME: + FuInsertOLE(this, pWin, pView, pDrModel, rReq); + break; + + case SID_OBJECTRESIZE: + { + // Der Server moechte die Clientgrosse verandern + + SfxInPlaceClient* pIPClient = GetIPClient(); + + if ( pIPClient && pIPClient->IsInPlaceActive() ) + { + const SfxRectangleItem& rRect = + (SfxRectangleItem&)rReq.GetArgs()->Get(SID_OBJECTRESIZE); + Rectangle aRect( pWin->PixelToLogic( rRect.GetValue() ) ); + + if ( pView->HasMarkedObj() ) + { + const SdrMarkList& rMarkList = pView->GetMarkList(); + + if (rMarkList.GetMarkCount() == 1) + { + SdrMark* pMark = rMarkList.GetMark(0); + SdrObject* pObj = pMark->GetObj(); + + UINT16 nSdrObjKind = pObj->GetObjIdentifier(); + + if (nSdrObjKind == OBJ_OLE2) + { + SvInPlaceObjectRef aIPObj = + ( (SdrOle2Obj*) pObj)->GetObjRef(); + + if ( aIPObj.Is() ) + { + pObj->SetLogicRect(aRect); + } + } + } + } + } + } + break; + + case SID_LINKS: + { + SvBaseLinksDialog( pWin, pDoc->GetLinkManager() ).Execute(); + rBindings.Invalidate( nSlot ); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); // Navigator + rReq.Done(); + } + } +} + +void ScTabViewShell::GetDrawInsState(SfxItemSet &rSet) +{ + BOOL bOle = GetViewFrame()->ISA(SfxInPlaceFrame); + BOOL bTabProt = GetViewData()->GetDocument()->IsTabProtected(GetViewData()->GetTabNo()); + SfxApplication* pSfxApp = SFX_APP(); + + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + while ( nWhich ) + { + switch ( nWhich ) + { + case SID_INSERT_DIAGRAM: + case SID_OPENDLG_CHART: + if ( bOle || bTabProt || !pSfxApp->HasFeature(SFX_FEATURE_SCHART) ) + rSet.DisableItem( nWhich ); + break; + + case SID_INSERT_SIMAGE: + if ( bOle || bTabProt || !pSfxApp->HasFeature(SFX_FEATURE_SIMAGE) ) + rSet.DisableItem( nWhich ); + break; + + case SID_INSERT_SMATH: + if ( bOle || bTabProt || !pSfxApp->HasFeature(SFX_FEATURE_SMATH) ) + rSet.DisableItem( nWhich ); + break; + + case SID_INSERT_OBJECT: + case SID_INSERT_PLUGIN: + case SID_INSERT_FLOATINGFRAME: + if (bOle || bTabProt) + rSet.DisableItem( nWhich ); + break; + + case SID_INSERT_SOUND: + case SID_INSERT_VIDEO: + if (bOle || bTabProt || !SvxPluginFileDlg::IsAvailable(nWhich)) + rSet.DisableItem( nWhich ); + break; + + case SID_INSERT_APPLET: + // wenn SOLAR_JAVA nicht definiert ist, immer disablen +#ifdef SOLAR_JAVA + if (bOle || bTabProt) +#endif + rSet.DisableItem( nWhich ); + break; + + case SID_INSERT_GRAPHIC: + if (bTabProt) + rSet.DisableItem( nWhich ); + break; + + case SID_LINKS: + { + if (GetViewData()->GetDocument()->GetLinkManager()->GetLinks().Count() == 0 ) + rSet.DisableItem( SID_LINKS ); + } + break; + } + nWhich = aIter.NextWhich(); + } +} + + + + diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx new file mode 100644 index 000000000000..9056841fd5b1 --- /dev/null +++ b/sc/source/ui/view/tabvwshc.cxx @@ -0,0 +1,492 @@ +/************************************************************************* + * + * $RCSfile: tabvwshc.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +#define _SI_DLL_HXX +#define _SIDLL_HXX +#define _SI_NOITEMS +#define _SI_NOOTHERFORMS +#define _SI_NOSBXCONTROLS +#define _SINOSBXCONTROLS +#define _SI_NODRW // +#define _SI_NOCONTROL +#define _SVBOXITM_HXX +//#define _SVCONTNR_HXX +#define _SVDATTR_HXX +#define _SVDXOUT_HXX +#define _SVDEC_HXX +#define _SVDIO_HXX +#define _SVDLAYER_HXX +#define _SVDRAG_HXX +#define _SVINCVW_HXX +#define _SV_MULTISEL_HXX +#define _SVRTV_HXX +//#define _SVTABBX_HXX +//#define _SVTREEBOX_HXX +//#define _SVTREELIST_HXX + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_THESDLG_HXX + + +// INCLUDE --------------------------------------------------------------- +#include "scitems.hxx" +#include <vcl/msgbox.hxx> +#include <sfx2/childwin.hxx> + +#include "tabvwsh.hxx" +#include "sc.hrc" +#include "globstr.hrc" +#include "global.hxx" +#include "scmod.hxx" +#include "docsh.hxx" +#include "document.hxx" +#include "uiitems.hxx" +#include "pivot.hxx" +#include "namedlg.hxx" +#include "solvrdlg.hxx" +#include "tabopdlg.hxx" +#include "autoform.hxx" // Core +#include "autofmt.hxx" // Dialog +#include "consdlg.hxx" +#include "sortdlg.hxx" +#include "filtdlg.hxx" +#include "dbnamdlg.hxx" +#include "pvlaydlg.hxx" +#include "chartdlg.hxx" +#include "areasdlg.hxx" +#include "condfrmt.hxx" +#include "rangeutl.hxx" +#include "crnrdlg.hxx" +#include "formula.hxx" +#include "cell.hxx" // Input Status Edit-Zellen +#include "acredlin.hxx" +#include "highred.hxx" +#include "simpref.hxx" +#include "dpobject.hxx" + +// ----------------------------------------------------------------------- + +//! nach document verschieben !!! + +BOOL lcl_IsValueCol( ScDocument* pDoc, USHORT nCol, USHORT nRow1, USHORT nRow2, USHORT nTab ) +{ + BOOL bVal = TRUE; + for (USHORT nRow=nRow1; nRow<=nRow2 && bVal; nRow++) + if (pDoc->HasStringData( nCol, nRow, nTab )) + bVal = FALSE; + return bVal; +} + +//------------------------------------------------------------------ + +SfxModelessDialog* ScTabViewShell::CreateRefDialog( + SfxBindings* pB, SfxChildWindow* pCW, SfxChildWinInfo* pInfo, + Window* pParent, USHORT nSlotId ) +{ + // Dialog nur aufmachen, wenn ueber ScModule::SetRefDialog gerufen, damit + // z.B. nach einem Absturz offene Ref-Dialoge nicht wiederkommen (#42341#). + + if ( SC_MOD()->GetCurRefDlgId() != nSlotId ) + return NULL; + + SfxModelessDialog* pResult = 0; + + if(pCW) + pCW->SetHideNotDelete(TRUE); + + switch( nSlotId ) + { + case FID_DEFINE_NAME: + pResult = new ScNameDlg( pB, pCW, pParent, GetViewData(), + ScAddress( GetViewData()->GetCurX(), + GetViewData()->GetCurY(), + GetViewData()->GetTabNo() ) ); + break; + + case SID_DEFINE_COLROWNAMERANGES: + { + pResult = new ScColRowNameRangesDlg( pB, pCW, pParent, GetViewData() ); + } + break; + + case SID_OPENDLG_CHART: + { + pResult = new ScChartDlg( pB, pCW, pParent, GetViewData() ); + } + break; + + case SID_OPENDLG_CONSOLIDATE: + { + SfxItemSet aArgSet( GetPool(), + SCITEM_CONSOLIDATEDATA, + SCITEM_CONSOLIDATEDATA ); + + const ScConsolidateParam* pDlgData = + GetViewData()->GetDocument()->GetConsolidateDlgData(); + + if ( !pDlgData ) + { + ScConsolidateParam aConsParam; + USHORT nStartCol, nStartRow, nStartTab, + nEndCol, nEndRow, nEndTab; + + GetViewData()->GetSimpleArea( nStartCol, nStartRow, nStartTab, + nEndCol, nEndRow, nEndTab ); + + PutInOrder( nStartCol, nEndCol ); + PutInOrder( nStartRow, nEndRow ); + PutInOrder( nStartTab, nEndTab ); + + aConsParam.nCol = nStartCol; + aConsParam.nRow = nStartRow; + aConsParam.nTab = nStartTab; + + aArgSet.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA, + &aConsParam ) ); + } + else + { + aArgSet.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA, pDlgData ) ); + } + pResult = new ScConsolidateDlg( pB, pCW, pParent, aArgSet ); + } + break; + + case SID_DEFINE_DBNAME: + { + // wenn auf einem bestehenden Bereich aufgerufen, den markieren + GetDBData( TRUE, SC_DB_OLD ); + if ( !GetViewData()->GetMarkData().IsMarked() ) + MarkDataArea( FALSE ); + + pResult = new ScDbNameDlg( pB, pCW, pParent, GetViewData() ); + } + break; + + case SID_SPECIAL_FILTER: + { + ScQueryParam aQueryParam; + SfxItemSet aArgSet( GetPool(), + SCITEM_QUERYDATA, + SCITEM_QUERYDATA ); + + ScDBData* pDBData = GetDBData(); + pDBData->GetQueryParam( aQueryParam ); + + ScQueryItem aItem( SCITEM_QUERYDATA, GetViewData(), &aQueryParam ); + ScRange aAdvSource; + if (pDBData->GetAdvancedQuerySource(aAdvSource)) + aItem.SetAdvancedQuerySource( &aAdvSource ); + + aArgSet.Put( aItem ); + + // aktuelle Tabelle merken (wg. RefInput im Dialog) + GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() ); + + pResult = new ScSpecialFilterDlg( pB, pCW, pParent, aArgSet ); + } + break; + + case SID_FILTER: + { + + ScQueryParam aQueryParam; + SfxItemSet aArgSet( GetPool(), + SCITEM_QUERYDATA, + SCITEM_QUERYDATA ); + + ScDBData* pDBData = GetDBData(); + pDBData->GetQueryParam( aQueryParam ); + + aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA, + GetViewData(), + &aQueryParam ) ); + + // aktuelle Tabelle merken (wg. RefInput im Dialog) + GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() ); + + pResult = new ScFilterDlg( pB, pCW, pParent, aArgSet ); + } + break; + + case SID_OPENDLG_TABOP: + { + ScViewData* pViewData = GetViewData(); + ScRefTripel aCurPos ( pViewData->GetCurX(), + pViewData->GetCurY(), + pViewData->GetTabNo(), + FALSE, FALSE, FALSE ); + + pResult = new ScTabOpDlg( pB, pCW, pParent, pViewData->GetDocument(), aCurPos ); + } + break; + + case SID_OPENDLG_SOLVE: + { + ScViewData* pViewData = GetViewData(); + ScRefTripel aCurPos ( pViewData->GetCurX(), + pViewData->GetCurY(), + pViewData->GetTabNo(), + FALSE, FALSE, FALSE ); + + pResult = new ScSolverDlg( pB, pCW, pParent, pViewData->GetDocument(), aCurPos ); + } + break; + + case SID_OPENDLG_PIVOTTABLE: + { + // all settings must be in pDialogDPObject + + GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() ); + pResult = new ScPivotLayoutDlg( pB, pCW, pParent, pDialogDPObject ); + +#if 0 + ScDocument* pDoc = GetViewData()->GetDocument(); + USHORT nTab = 0; + USHORT nCol1 = 0; + USHORT nCol2 = 0; + USHORT nRow1 = 0; + USHORT nRow2 = 0; + + ScPivot* pPivot = pDoc->GetPivotAtCursor( + GetViewData()->GetCurX(), + GetViewData()->GetCurY(), + GetViewData()->GetTabNo() ); + ScDPObject* pDPObj = pDoc->GetDPAtCursor( + GetViewData()->GetCurX(), + GetViewData()->GetCurY(), + GetViewData()->GetTabNo() ); + ScPivotParam aPivotParam; + + if ( pPivot ) // befinden wir uns auf einer Pivot-Tabelle? + { + ScArea aArea; + ScQueryParam aQuery; + pPivot->GetParam( aPivotParam, aQuery, aArea ); + pPivot->GetSrcArea( nCol1, nRow1, nCol2, nRow2, nTab); + + // Quelldatenbereich markieren + if ( nTab == GetViewData()->GetTabNo() ) + MarkRange( ScRange( nCol1,nRow1,nTab, nCol2,nRow2,nTab ) ); + } + else if ( pDPObj && pDPObj->IsSheetData() ) + { + // get (old) ScPivotParam + + pDPObj->FillOldParam( aPivotParam ); + ScRange aSource = pDPObj->GetSourceRange(); + nCol1 = aSource.aStart.Col(); + nRow1 = aSource.aStart.Row(); + nCol2 = aSource.aEnd.Col(); + nRow2 = aSource.aEnd.Row(); + nTab = aSource.aStart.Tab(); + + if ( nTab == GetViewData()->GetTabNo() ) + MarkRange( ScRange( nCol1,nRow1,nTab, nCol2,nRow2,nTab ) ); + } + else // neue Pivot-Tabelle erzeugen + { + ScDBData* pDBData = GetDBData(); + String aErrMsg; + + pDBData->GetArea( nTab, nCol1, nRow1, nCol2, nRow2 ); + + + if (nRow2+2 <= MAXROW - 4) // Default-Ausgabebereich + { // min. Tabelle hat 5 Zeilen + aPivotParam.nCol = nCol1; + aPivotParam.nRow = nRow2+2; + aPivotParam.nTab = nTab; + } + else + { + aPivotParam.nCol = 0; + aPivotParam.nRow = 0; + aPivotParam.nTab = MAXTAB+1; + } + + } + + SfxItemSet aArgSet( GetPool(), + SCITEM_PIVOTDATA, + SCITEM_PIVOTDATA ); + + // Ermitteln der Ueberschriften: + String aFieldName; + USHORT nLabelCount = nCol2-nCol1+1; + short nCol = nCol1; + BOOL bIsValue = FALSE; + LabelData** aLabelArr = new LabelData*[nLabelCount]; + + for ( USHORT i=0; i<nLabelCount; i++ ) + { + pDoc->GetString( nCol, nRow1, nTab, aFieldName ); + if ( !aFieldName ) + aFieldName = ColToAlpha( nCol ); + bIsValue = lcl_IsValueCol( pDoc, nCol, nRow1+1, nRow2, nTab ); + aLabelArr[i] = new LabelData( aFieldName, nCol, bIsValue ); + nCol++; + } + + aPivotParam.SetLabelData( aLabelArr, nLabelCount ); + aArgSet.Put( ScPivotItem( SCITEM_PIVOTDATA, &aPivotParam ) ); + + // aktuelle Tabelle merken (wg. RefInput im Dialog) + GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() ); + + *pPivotSource = ScArea( nTab, nCol1,nRow1, nCol2,nRow2 ); + pResult = new ScPivotLayoutDlg( pB, pCW, pParent, aArgSet ); + + + for ( USHORT p=0; p<nLabelCount; p++ ) + delete aLabelArr[p]; + delete [] aLabelArr; +#endif + } + break; + + case SID_OPENDLG_EDIT_PRINTAREA: + { + pResult = new ScPrintAreasDlg( pB, pCW, pParent ); + } + break; + + case SID_OPENDLG_CONDFRMT: + { + ScViewData* pViewData = GetViewData(); + + ScDocument* pDoc = pViewData->GetDocument(); + const ScConditionalFormat* pForm = pDoc->GetCondFormat( + pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() ); + + // aktuelle Tabelle merken (wg. RefInput im Dialog) + pViewData->SetRefTabNo( pViewData->GetTabNo() ); + + pResult = new ScConditionalFormatDlg( pB, pCW, pParent, pDoc, pForm ); + } + break; + + case SID_OPENDLG_FUNCTION: + { + // Dialog schaut selber, was in der Zelle steht + + pResult = new ScFormulaDlg( pB, pCW, pParent, GetViewData() ); + } + break; + + case FID_CHG_SHOW: + { + // Dialog schaut selber, was in der Zelle steht + + pResult = new ScHighlightChgDlg( pB, pCW, pParent, GetViewData() ); + } + break; + + case WID_SIMPLE_REF: + { + // Dialog schaut selber, was in der Zelle steht + + pResult = new ScSimpleRefDlg( pB, pCW, pParent, GetViewData() ); + } + break; + + + default: + DBG_ERROR( "ScTabViewShell::CreateRefDialog: unbekannte ID" ); + break; + } + + if (pResult) + { + // Die Dialoge gehen immer mit eingeklapptem Zusaetze-Button auf, + // darum muss die Groesse ueber das Initialize gerettet werden + // (oder den Zusaetze-Status mit speichern !!!) + + Size aSize = pResult->GetSizePixel(); + pResult->Initialize( pInfo ); + pResult->SetSizePixel(aSize); + } + + return pResult; +} + + + diff --git a/sc/source/ui/view/tabvwshd.cxx b/sc/source/ui/view/tabvwshd.cxx new file mode 100644 index 000000000000..e3c04fd91287 --- /dev/null +++ b/sc/source/ui/view/tabvwshd.cxx @@ -0,0 +1,121 @@ +/************************************************************************* + * + * $RCSfile: tabvwshd.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +#ifdef WNT +#pragma optimize ("", off) +#endif + +// INCLUDE --------------------------------------------------------------- + +#include <sfx2/request.hxx> +#include <sfx2/topfrm.hxx> +#include <so3/ipenv.hxx> +#include <vcl/svapp.hxx> +#include <vcl/wrkwin.hxx> + +#include "tabvwsh.hxx" +#include "global.hxx" +#include "scmod.hxx" +#include "docsh.hxx" +#include "sc.hrc" + + +// STATIC DATA ----------------------------------------------------------- + +//------------------------------------------------------------------ + +#define IS_AVAILABLE(WhichId,ppItem) \ + (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET) + +//! Parent-Window fuer Dialoge +//! Problem: OLE Server! + +Window* ScTabViewShell::GetDialogParent() +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + if ( pDocSh->IsOle() ) + { + SvInPlaceEnvironment* pEnv = pDocSh->GetIPEnv(); + if (pEnv) + return pEnv->GetEditWin(); + } +#if 0 + else if ( !GetViewFrame()->ISA(SfxTopViewFrame) ) // z.B. PlugIn + { + return GetActiveWin(); + } +#endif + + return GetActiveWin(); // for normal views, too +} + + + + + diff --git a/sc/source/ui/view/tabvwshe.cxx b/sc/source/ui/view/tabvwshe.cxx new file mode 100644 index 000000000000..e3f4174e1aaa --- /dev/null +++ b/sc/source/ui/view/tabvwshe.cxx @@ -0,0 +1,338 @@ +/************************************************************************* + * + * $RCSfile: tabvwshe.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#ifndef _EEITEM_HXX //autogen +#include <svx/eeitem.hxx> +#endif + +#include "scitems.hxx" +#define ITEMID_FIELD EE_FEATURE_FIELD +#include <svx/editview.hxx> +#include <svx/flditem.hxx> +#include <svx/hlnkitem.hxx> +#include <svx/srchitem.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/viewfrm.hxx> +#include <sfx2/request.hxx> +#include <sfx2/objface.hxx> +#include <svtools/stritem.hxx> + +#include "tabvwsh.hxx" +#include "sc.hrc" +#include "scmod.hxx" +#include "impex.hxx" +#include "editsh.hxx" +#include "dociter.hxx" +#include "inputhdl.hxx" + +//================================================================== + +String __EXPORT ScTabViewShell::GetSelectionText( BOOL bWholeWord ) +{ + String aStrSelection; + + if ( pEditShell && pEditShell == GetMySubShell() ) + { + aStrSelection = pEditShell->GetSelectionText( bWholeWord ); + } + else + { + ScRange aRange; + + if ( GetViewData()->GetSimpleArea( aRange ) ) + { + ScDocument* pDoc = GetViewData()->GetDocument(); + if ( bInFormatDialog && aRange.aStart.Row() != aRange.aEnd.Row() ) + { + // Range auf eine Datenzeile begrenzen + // (#48613# nur wenn der Aufruf aus einem Format-Dialog kommt) + ScHorizontalCellIterator aIter( pDoc, aRange.aStart.Tab(), + aRange.aStart.Col(), aRange.aStart.Row(), + aRange.aEnd.Col(), aRange.aEnd.Row() ); + USHORT nCol, nRow; + if ( aIter.GetNext( nCol, nRow ) ) + { + aRange.aStart.SetCol( nCol ); + aRange.aStart.SetRow( nRow ); + aRange.aEnd.SetRow( nRow ); + } + else + aRange.aEnd = aRange.aStart; + } + + ScImportExport aObj( pDoc, aRange ); + aObj.SetFormulas( GetViewData()->GetOptions().GetOption( VOPT_FORMULAS ) ); + aObj.ExportString( aStrSelection ); + + aStrSelection.ConvertLineEnd( LINEEND_CR ); + + // Tab/CR durch Space ersetzen, wenn fuer Dialog oder per Basic/SelectionTextExt, + // oder wenn es eine einzelne Zeile ist. + // Sonst mehrzeilig mit Tabs beibehalten (z.B. Mail oder Basic/SelectionText). + // Fuer Mail werden die Tabs dann spaeter in (mehrere) Spaces gewandelt. + + if ( bInFormatDialog || bWholeWord || aRange.aEnd.Row() == aRange.aStart.Row() ) + { + xub_StrLen nAt; + while ( (nAt = aStrSelection.Search( CHAR_CR )) != STRING_NOTFOUND ) + aStrSelection.SetChar( nAt, ' ' ); + while ( (nAt = aStrSelection.Search( '\t' )) != STRING_NOTFOUND ) + aStrSelection.SetChar( nAt, ' ' ); + + aStrSelection.EraseTrailingChars( ' ' ); + } + } + } + + return aStrSelection; +} + +//------------------------------------------------------------------------ + +void ScTabViewShell::InsertURL( const String& rName, const String& rURL, const String& rTarget, + USHORT nMode ) +{ + SvxLinkInsertMode eMode = (SvxLinkInsertMode) nMode; + BOOL bAsText = ( eMode != HLINK_BUTTON ); // Default ist jetzt Text + + if ( bAsText ) + { + // InsertBookmark ? + InsertURLField( rName, rURL, rTarget ); + } + else + { + SC_MOD()->InputEnterHandler(); + InsertURLButton( rName, rURL, rTarget ); + } +} + +//------------------------------------------------------------------------ + +// wenn CLOOKs: -> mit <editview.hxx> <flditem.hxx>in neue tabvwsh + +void lcl_SelectFieldAfterInsert( EditView& rView ) +{ + ESelection aSel = rView.GetSelection(); + if ( aSel.nStartPos == aSel.nEndPos && aSel.nStartPos > 0 ) + { + // Cursor is behind the inserted field -> extend selection to the left + + --aSel.nStartPos; + rView.SetSelection( aSel ); + } +} + +void ScTabViewShell::InsertURLField( const String& rName, const String& rURL, const String& rTarget ) +{ + SvxURLField aURLField( rURL, rName, SVXURLFORMAT_REPR ); + aURLField.SetTargetFrame( rTarget ); + SvxFieldItem aURLItem( aURLField ); + + ScViewData* pViewData = GetViewData(); + ScTabView* pView = pViewData->GetView(); + ScModule* pScMod = SC_MOD(); + ScInputHandler* pHdl = pScMod->GetInputHdl(); + + BOOL bSelectFirst = FALSE; + if ( !pScMod->IsEditMode() ) + { + // single url in cell is shown in the dialog and replaced + bSelectFirst = HasBookmarkAtCursor( NULL ); + pScMod->SetInputMode( SC_INPUT_TABLE ); + } + + EditView* pTopView = pHdl->GetTopView(); + EditView* pTableView = pHdl->GetTableView(); + DBG_ASSERT( pTopView || pTableView, "No EditView" ); + + if ( bSelectFirst ) + { + if ( pTopView ) + pTopView->SetSelection( ESelection(0,0,0,1) ); + if ( pTableView ) + pTableView->SetSelection( ESelection(0,0,0,1) ); + } + + pHdl->DataChanging(); + + if ( pTopView ) + { + pTopView->InsertField( aURLItem ); + lcl_SelectFieldAfterInsert( *pTopView ); + } + if ( pTableView ) + { + pTableView->InsertField( aURLItem ); + lcl_SelectFieldAfterInsert( *pTableView ); + } + + pHdl->DataChanged(); +} + +void ScTabViewShell::ExecSearch( SfxRequest& rReq ) +{ + SfxBindings& rBindings = GetViewFrame()->GetBindings(); + const SfxItemSet* pReqArgs = rReq.GetArgs(); + USHORT nSlot = rReq.GetSlot(); + const SfxPoolItem* pItem; + + switch ( nSlot ) + { + case FID_SEARCH_NOW: + { + const SfxPoolItem* pItem; + if ( pReqArgs && + SFX_ITEM_SET == pReqArgs->GetItemState(SID_SEARCH_ITEM, FALSE, &pItem) ) + { + DBG_ASSERT( pItem->ISA(SvxSearchItem), "falsches Item" ); + const SvxSearchItem* pSearchItem = (const SvxSearchItem*) pItem; + + ScGlobal::SetSearchItem( *pSearchItem ); + SearchAndReplace( pSearchItem, TRUE, rReq.IsAPI() ); + rReq.Done(); + } + } + break; + + case SID_SEARCH_ITEM: + if (pReqArgs && SFX_ITEM_SET == + pReqArgs->GetItemState(SID_SEARCH_ITEM, FALSE, &pItem)) + { + // Search-Item merken + DBG_ASSERT( pItem->ISA(SvxSearchItem), "falsches Item" ); + ScGlobal::SetSearchItem( *(const SvxSearchItem*) pItem ); + } + else + DBG_ERROR("SID_SEARCH_ITEM ohne Parameter"); + break; + case FID_SEARCH: + case FID_REPLACE: + case FID_REPLACE_ALL: + case FID_SEARCH_ALL: + { + if (pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState(nSlot, FALSE, &pItem)) + { + // SearchItem holen + + SvxSearchItem aSearchItem = ScGlobal::GetSearchItem(); + + // SearchItem fuellen + + aSearchItem.SetSearchString(((SfxStringItem*)pItem)->GetValue()); + if(SFX_ITEM_SET == pReqArgs->GetItemState(FN_PARAM_1, FALSE, &pItem)) + aSearchItem.SetReplaceString(((SfxStringItem*)pItem)->GetValue()); + + if (nSlot == FID_SEARCH) + aSearchItem.SetCommand(SVX_SEARCHCMD_FIND); + else if(nSlot == FID_REPLACE) + aSearchItem.SetCommand(SVX_SEARCHCMD_REPLACE); + else if(nSlot == FID_REPLACE_ALL) + aSearchItem.SetCommand(SVX_SEARCHCMD_REPLACE_ALL); + else + aSearchItem.SetCommand(SVX_SEARCHCMD_FIND_ALL); + + // Request ausfuehren (dabei wird das SearchItem gespeichert) + + aSearchItem.SetWhich(SID_SEARCH_ITEM); + SFX_DISPATCHER().Execute( FID_SEARCH_NOW, + rReq.IsAPI() ? SFX_CALLMODE_API|SFX_CALLMODE_SYNCHRON : + SFX_CALLMODE_STANDARD, + &aSearchItem, 0L ); + } + else + { + SFX_DISPATCHER().Execute( + SID_SEARCH_DLG, SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD ); + } + } + break; + case FID_REPEAT_SEARCH: + { + // nochmal mit ScGlobal::GetSearchItem() + + SvxSearchItem aSearchItem = ScGlobal::GetSearchItem(); + aSearchItem.SetWhich(SID_SEARCH_ITEM); + SFX_DISPATCHER().Execute( FID_SEARCH_NOW, + rReq.IsAPI() ? SFX_CALLMODE_API|SFX_CALLMODE_SYNCHRON : + SFX_CALLMODE_STANDARD, + &aSearchItem, 0L ); + } + break; +// case FID_SEARCH_COUNT: + } +} + +//-------------------------------------------------------------------- + + + + + + diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx new file mode 100644 index 000000000000..c587e40ec467 --- /dev/null +++ b/sc/source/ui/view/tabvwshf.cxx @@ -0,0 +1,762 @@ +/************************************************************************* + * + * $RCSfile: tabvwshf.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <sfx2/request.hxx> +#include <basic/sbstar.hxx> +#include <svtools/stritem.hxx> +#include <svtools/whiter.hxx> +#include <vcl/msgbox.hxx> + +#include "tabvwsh.hxx" +#include "sc.hrc" +#include "docsh.hxx" +#include "document.hxx" +#include "shtabdlg.hxx" +#include "scresid.hxx" +#include "instbdlg.hxx" +#include "globstr.hrc" +#include "strindlg.hxx" +#include "mvtabdlg.hxx" + + + +#define IS_AVAILABLE(WhichId,ppItem) \ + (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET) + +//------------------------------------------------------------------ + +void ScTabViewShell::ExecuteTable( SfxRequest& rReq ) +{ + ScViewData* pViewData = GetViewData(); + ScDocument* pDoc = pViewData->GetDocument(); + + USHORT nCurrentTab = pViewData->GetTabNo(); + USHORT nTabCount = pDoc->GetTableCount(); + USHORT nSlot = rReq.GetSlot(); + const SfxItemSet* pReqArgs = rReq.GetArgs(); + + HideListBox(); // Autofilter-DropDown-Listbox + + switch ( nSlot ) + { + case FID_TABLE_VISIBLE: + { + USHORT nTabNr = pViewData->GetTabNo(); + String aName; + pDoc->GetName( nCurrentTab, aName ); + + BOOL bVisible=TRUE; + if( pReqArgs != NULL ) + { + const SfxPoolItem* pItem; + if( IS_AVAILABLE( FID_TABLE_VISIBLE, &pItem ) ) + bVisible = ((const SfxBoolItem*)pItem)->GetValue(); + } + + if( ! bVisible ) // ausblenden + { + ScMarkData& rMark = pViewData->GetMarkData(); + USHORT nTabSelCount = rMark.GetSelectCount(); + USHORT nVis = 0; + for ( USHORT i=0; i < nTabCount && nVis<2; i++ ) + if (pDoc->IsVisible(i)) + ++nVis; + if ( nVis<2 || !pDoc->IsDocEditable() || nTabSelCount > 1 ) + break; + + USHORT nHideTab; + if (pDoc->GetTable( aName, nHideTab )) + HideTable( nHideTab ); + } + else // einblenden + { + ShowTable( aName ); + } + } + break; + + case FID_TABLE_HIDE: + { + ScMarkData& rMark = pViewData->GetMarkData(); + USHORT nTabSelCount = rMark.GetSelectCount(); + USHORT nVis = 0; + for ( USHORT i=0; i < nTabCount && nVis<2; i++ ) + if (pDoc->IsVisible(i)) + ++nVis; + if ( nVis<2 || !pDoc->IsDocEditable() || nTabSelCount > 1 ) + break; + + + String aName; + if( pReqArgs != NULL ) + { + const SfxPoolItem* pItem; + if( IS_AVAILABLE( FID_TABLE_HIDE, &pItem ) ) + aName = ((const SfxStringItem*)pItem)->GetValue(); + } + + if (!aName.Len()) + { + pDoc->GetName( nCurrentTab, aName ); // aktuelle Tabelle + rReq.AppendItem( SfxStringItem( FID_TABLE_HIDE, aName ) ); + } + + USHORT nHideTab; + if (pDoc->GetTable( aName, nHideTab )) + HideTable( nHideTab ); + + if( ! rReq.IsAPI() ) + rReq.Done(); + } + break; + + case FID_TABLE_SHOW: + { + String aName; + if ( pReqArgs ) + { + const SfxPoolItem* pItem; + if( IS_AVAILABLE( FID_TABLE_SHOW, &pItem ) ) + { + aName = ((const SfxStringItem*)pItem)->GetValue(); + + ShowTable( aName ); + + if( ! rReq.IsAPI() ) + rReq.Done(); + } + } + else + { + List aList; + + for ( USHORT i=0; i != nTabCount; i++ ) + { + if (!pDoc->IsVisible(i)) + { + String* pNewEntry = new String; + pDoc->GetName( i, *pNewEntry ); + aList.Insert( pNewEntry ); + } + } + + ScShowTabDlg* pDlg = new ScShowTabDlg( GetDialogParent(), aList ); + if ( pDlg->Execute() == RET_OK ) + { + USHORT nCount = pDlg->GetSelectEntryCount(); + for (USHORT nPos=0; nPos<nCount; nPos++) + { + aName = pDlg->GetSelectEntry(nPos); + ShowTable( aName ); + } + rReq.AppendItem( SfxStringItem( FID_TABLE_SHOW, aName ) ); + rReq.Done(); + } + delete pDlg; + + void* pEntry = aList.First(); + while ( pEntry ) + { + delete (String*) aList.Remove( pEntry ); + pEntry = aList.Next(); + } + } + } + break; + + case FID_INS_TABLE: + { + ScMarkData& rMark = pViewData->GetMarkData(); + USHORT nTabSelCount = rMark.GetSelectCount(); + USHORT nTabNr = nCurrentTab; + + if ( !pDoc->IsDocEditable() ) + break; // gesperrt + + if ( pReqArgs != NULL ) // von Basic + { + BOOL bOk = FALSE; + const SfxPoolItem* pTabItem; + const SfxPoolItem* pNameItem; + String aName; + + if ( IS_AVAILABLE( FN_PARAM_1, &pTabItem ) && + IS_AVAILABLE( nSlot, &pNameItem ) ) + { + // Tabellennr. von Basic: 1-basiert + + aName = ((const SfxStringItem*)pNameItem)->GetValue(); + nTabNr = ((const SfxUInt16Item*)pTabItem)->GetValue() - 1; + if ( nTabNr < nTabCount ) + bOk = InsertTable( aName, nTabNr ); + } + + if (bOk) + rReq.Done( *pReqArgs ); + //! sonst Fehler setzen + } + else // Dialog + { + ScInsertTableDlg* pDlg = new ScInsertTableDlg( + GetDialogParent(), + *pViewData,nTabSelCount); + + if ( RET_OK == pDlg->Execute() ) + { + if (pDlg->GetTablesFromFile()) + { + USHORT nTabs[MAXTAB+1]; + USHORT nCount = 0; + USHORT n = 0; + const String* pStr = pDlg->GetFirstTable( &n ); + while ( pStr ) + { + nTabs[nCount++] = n; + pStr = pDlg->GetNextTable( &n ); + } + BOOL bLink = pDlg->GetTablesAsLink(); + if (nCount) + { + if(pDlg->IsTableBefore()) + { + ImportTables( pDlg->GetDocShellTables(), nCount, nTabs, + bLink,nTabNr ); + } + else + { + USHORT nTabAfter = nTabNr+1; + + for(USHORT j=nCurrentTab+1;j<nTabCount;j++) + { + if(!pDoc->IsScenario(j)) + { + nTabAfter=j; + break; + } + } + + ImportTables( pDlg->GetDocShellTables(), nCount, nTabs, + bLink,nTabAfter ); + } + } + } + else + { + USHORT nCount=pDlg->GetTableCount(); + if(pDlg->IsTableBefore()) + { + if(nCount==1 && pDlg->GetFirstTable()->Len()>0) + InsertTable( *pDlg->GetFirstTable(), nTabNr ); + else + InsertTables( NULL, nTabNr,nCount ); + } + else + { + USHORT nTabAfter = nTabNr+1; + USHORT nSelHigh=0; + + for(int i=0;i<nTabCount;i++) + { + if(rMark.GetTableSelect(i)) + { + nSelHigh=i; + } + } + + for(USHORT j=nSelHigh+1;j<nTabCount;j++) + { + if(!pDoc->IsScenario(j)) + { + nTabAfter=j; + break; + } + } + + if(nCount==1 && pDlg->GetFirstTable()->Len()>0) + { + InsertTable( *pDlg->GetFirstTable(), nTabAfter); + } + else + { + InsertTables( NULL, nTabAfter,nCount); + } + } + } + } + + delete pDlg; + } + } + break; + + case FID_TAB_APPEND: + case FID_TAB_RENAME: + case FID_TAB_MENU_RENAME: + { + // FID_TAB_MENU_RENAME - "umbenennen" im Menu + // FID_TAB_RENAME - "Name"-Property fuer Basic + // Execute ist gleich, aber im GetState wird MENU_RENAME evtl. disabled + + if ( nSlot == FID_TAB_MENU_RENAME ) + nSlot = FID_TAB_RENAME; // Execute ist gleich + + USHORT nTabNr = pViewData->GetTabNo(); + ScMarkData& rMark = pViewData->GetMarkData(); + USHORT nTabSelCount = rMark.GetSelectCount(); + + if ( !pDoc->IsDocEditable() ) + break; // alles gesperrt + + if ( nSlot != FID_TAB_APPEND && + ( pDoc->IsTabProtected( nTabNr ) || nTabSelCount > 1 ) ) + break; // kein Rename + +#if 0 + // ScSbxObject wird nicht mehr benutzt, stattdessen aus dem + // ScSbxTable::Notify die richtige Tabelle an der Basic-View eingestellt + if( rReq.IsAPI() ) + { + SbxObject* pObj = GetScSbxObject(); + ScSbxTable* pSbxTab = PTR_CAST( ScSbxTable, pObj ); + DBG_ASSERT( pSbxTab, "pSbxTab???" ); + + if( pSbxTab ) + nTabNr = pSbxTab->GetTableNr(); + } +#endif + + if( pReqArgs != NULL ) + { + BOOL bDone = FALSE; + const SfxPoolItem* pItem; + String aName; + + if( IS_AVAILABLE( FN_PARAM_1, &pItem ) ) + nTabNr = ((const SfxUInt16Item*)pItem)->GetValue(); + + if( IS_AVAILABLE( nSlot, &pItem ) ) + aName = ((const SfxStringItem*)pItem)->GetValue(); + + switch ( nSlot ) + { + case FID_TAB_APPEND: + bDone = AppendTable( aName ); + break; + case FID_TAB_RENAME: + bDone = RenameTable( aName, nTabNr ); + break; + } + + if( bDone ) + { + rReq.Done( *pReqArgs ); + } + } + else + { + USHORT nRet = RET_OK; + BOOL bDone = FALSE; + String aErrMsg ( ScGlobal::GetRscString( STR_INVALIDTABNAME ) ); + String aName; + String aDlgTitle; + + switch ( nSlot ) + { + case FID_TAB_APPEND: + aDlgTitle = String(ScResId(SCSTR_APDTABLE)); + pDoc->CreateValidTabName( aName ); + break; + + case FID_TAB_RENAME: + aDlgTitle = String(ScResId(SCSTR_RENAMETAB)); + pDoc->GetName( pViewData->GetTabNo(), aName ); + break; + } + + ScStringInputDlg* pDlg = + new ScStringInputDlg( GetDialogParent(), + aDlgTitle, + String(ScResId(SCSTR_NAME)), + aName, + nSlot ); + + while ( !bDone && nRet == RET_OK ) + { + nRet = pDlg->Execute(); + + if ( nRet == RET_OK ) + { + pDlg->GetInputString( aName ); + + + switch ( nSlot ) + { + case FID_TAB_APPEND: + bDone = AppendTable( aName ); + break; + case FID_TAB_RENAME: + bDone = RenameTable( aName, nTabNr ); + break; + } + + if ( bDone ) + { + rReq.AppendItem( SfxStringItem( nSlot, aName ) ); + rReq.Done(); + } + else + { + if( rReq.IsAPI() ) + { + StarBASIC::Error( SbERR_SETPROP_FAILED ); // XXX Fehlerbehandlung??? + } + else + { + nRet = ErrorBox( GetDialogParent(), + WinBits( WB_OK | WB_DEF_OK ), + aErrMsg + ).Execute(); + } + } + } + } + delete pDlg; + } + } + break; + + case FID_TAB_MOVE: + { + if ( pDoc->GetChangeTrack() != NULL ) + break; // bei aktiviertem ChangeTracking kein TabMove + + BOOL bDoIt = FALSE; + USHORT nDoc = 0; + USHORT nTab = pViewData->GetTabNo(); + BOOL bCpy = FALSE; + String aDocName; + + if( pReqArgs != NULL ) + { + USHORT nTableCount = pDoc->GetTableCount(); + const SfxPoolItem* pItem; + + if( IS_AVAILABLE( FID_TAB_MOVE, &pItem ) ) + aDocName = ((const SfxStringItem*)pItem)->GetValue(); + if( IS_AVAILABLE( FN_PARAM_1, &pItem ) ) + { + // Tabelle ist 1-basiert + nTab = ((const SfxUInt16Item*)pItem)->GetValue() - 1; + if ( nTab >= nTableCount ) + nTab = SC_TAB_APPEND; + } + if( IS_AVAILABLE( FN_PARAM_2, &pItem ) ) + bCpy = ((const SfxBoolItem*)pItem)->GetValue(); + + if( aDocName.Len() ) + { + SfxObjectShell* pSh = SfxObjectShell::GetFirst(); + ScDocShell* pScSh = NULL; + USHORT i=0; + + while ( pSh ) + { + pScSh = PTR_CAST( ScDocShell, pSh ); + + if( pScSh ) + { + pScSh->GetTitle(); + + if( pScSh->GetTitle() == aDocName ) + { + nDoc = i; + nTableCount = pScSh->GetDocument()->GetTableCount(); + bDoIt = TRUE; + break; + } + + i++; // nur die ScDocShell's zaehlen + } + pSh = SfxObjectShell::GetNext( *pSh ); + } + } + else // Kein Dokumentname -> neues Dokument + { + nDoc = SC_DOC_NEW; + bDoIt = TRUE; + } + + if ( bDoIt && nTab >= nTableCount ) // ggf. anhaengen + nTab = SC_TAB_APPEND; + } + else + { + ScMoveTableDlg* pDlg = new ScMoveTableDlg( GetDialogParent() ); + + USHORT nTableCount = pDoc->GetTableCount(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + USHORT nTabSelCount = rMark.GetSelectCount(); + + + if(nTableCount==nTabSelCount) + { + pDlg->SetCopyTable(); + pDlg->EnableCopyTable(FALSE); + } + if ( pDlg->Execute() == RET_OK ) + { + nDoc = pDlg->GetSelectedDocument(); + nTab = pDlg->GetSelectedTable(); + bCpy = pDlg->GetCopyTable(); + bDoIt = TRUE; + + String aDocName; + if ( nDoc != SC_DOC_NEW ) + { + ScDocShell* pSh = ScDocShell::GetShellByNum( nDoc ); + if (pSh) + aDocName = pSh->GetTitle(); + } + rReq.AppendItem( SfxStringItem( FID_TAB_MOVE, aDocName ) ); + // Tabelle ist 1-basiert, wenn nicht APPEND + USHORT nBasicTab = ( nTab <= MAXTAB ) ? (nTab+1) : nTab; + rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, nBasicTab ) ); + rReq.AppendItem( SfxBoolItem( FN_PARAM_2, bCpy ) ); + } + delete pDlg; + } + + if( bDoIt ) + { + rReq.Done(); // aufzeichnen, solange das Dokument noch aktiv ist + + MoveTable( nDoc, nTab, bCpy ); + } + } + break; + + case FID_DELETE_TABLE: + { + // Parameter war ueberfluessig, weil die Methode an der Table haengt + + BOOL bDoIt = rReq.IsAPI(); + if( !bDoIt ) + { + // wenn's nicht von Basic kommt, nochmal nachfragen: + + bDoIt = ( RET_YES == + QueryBox( GetDialogParent(), + WinBits( WB_YES_NO | WB_DEF_YES ), + ScGlobal::GetRscString(STR_QUERY_DELTAB) + ).Execute() ); + } + if( bDoIt ) + { + USHORT nNewTab = nCurrentTab; + USHORT nFirstTab=0; + BOOL bTabFlag=FALSE; + ScMarkData& rMark = pViewData->GetMarkData(); + SvUShorts TheTabs; + for(USHORT i=0;i<nTabCount;i++) + { + if(rMark.GetTableSelect(i) &&!pDoc->IsTabProtected(i)) + { + TheTabs.Insert(i,TheTabs.Count()); + bTabFlag=TRUE; + if(nNewTab==i) nNewTab++; + } + if(!bTabFlag) nFirstTab=i; + } + if(nNewTab>=nTabCount) nNewTab=nFirstTab; + + pViewData->SetTabNo(nNewTab); + DeleteTables(TheTabs); + TheTabs.Remove(0,TheTabs.Count()); + rReq.Done(); + } + } + break; + + default: + DBG_ERROR("Unbekannte Message bei ViewShell"); + break; + } +} + +//------------------------------------------------------------------ + +void ScTabViewShell::GetStateTable( SfxItemSet& rSet ) +{ + ScViewData* pViewData = GetViewData(); + ScDocument* pDoc = pViewData->GetDocument(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + USHORT nPosX = pViewData->GetCurX(); + USHORT nPosY = pViewData->GetCurY(); + USHORT nTab = pViewData->GetTabNo(); + + BOOL bOle = GetViewData()->GetDocShell()->IsOle(); + + USHORT nTabCount = pDoc->GetTableCount(); + USHORT nTabSelCount = rMark.GetSelectCount(); + + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + + while ( nWhich ) + { + switch ( nWhich ) + { + + case FID_TABLE_VISIBLE: + rSet.Put( SfxBoolItem( nWhich, pDoc->IsVisible(nTab) )); + break; + + case FID_TABLE_HIDE: + { + USHORT nVis = 0; + for ( USHORT i=0; i < nTabCount && nVis<2; i++ ) + if (pDoc->IsVisible(i)) + ++nVis; + + if ( nVis<2 || !pDoc->IsDocEditable() || nTabSelCount > 1 ) + rSet.DisableItem( nWhich ); + } + break; + + case FID_TABLE_SHOW: + { + BOOL bHasHidden = FALSE; + for ( USHORT i=0; i < nTabCount && !bHasHidden; i++ ) + if (!pDoc->IsVisible(i)) + bHasHidden = TRUE; + if ( !bHasHidden || pDoc->IsDocProtected() || nTabSelCount > 1 ) + rSet.DisableItem( nWhich ); + } + break; + + case FID_DELETE_TABLE: + { + if ( pDoc->GetChangeTrack() ) + rSet.DisableItem( nWhich ); + else + { + USHORT nVis = 0; + for ( USHORT i=0; i < nTabCount && nVis<2; i++ ) + if (pDoc->IsVisible(i)) + ++nVis; + if ( pDoc->IsTabProtected(nTab) + || !pDoc->IsDocEditable() + || nVis < 2 + || nTabSelCount == nTabCount) + rSet.DisableItem( nWhich ); + } + } + break; + + case FID_INS_TABLE: + case FID_TAB_APPEND: + if ( !pDoc->IsDocEditable() + || nTabCount > MAXTAB) + rSet.DisableItem( nWhich ); + break; + + case FID_TAB_MOVE: + if ( !pDoc->IsDocEditable() + || pDoc->GetChangeTrack() != NULL + || nTabCount > MAXTAB) + rSet.DisableItem( nWhich ); + break; + + // FID_TAB_MENU_RENAME - "umbenennen" im Menu + // FID_TAB_RENAME - "Name"-Property fuer Basic + + case FID_TAB_MENU_RENAME: + if ( !pDoc->IsDocEditable() || + pDoc->IsTabProtected(nTab) ||nTabSelCount > 1 ) + rSet.DisableItem( nWhich ); + break; + + case FID_TAB_RENAME: + { + String aTabName; + pDoc->GetName( nTab, aTabName ); + + rSet.Put( SfxStringItem( nWhich, aTabName )); + + } + break; + } + nWhich = aIter.NextWhich(); + } +} + + + + diff --git a/sc/source/ui/view/tabvwshg.cxx b/sc/source/ui/view/tabvwshg.cxx new file mode 100644 index 000000000000..cfe08523e006 --- /dev/null +++ b/sc/source/ui/view/tabvwshg.cxx @@ -0,0 +1,420 @@ +/************************************************************************* + * + * $RCSfile: tabvwshg.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +// TOOLS +#define _BIGINT_HXX +#define _SFXMULTISEL_HXX +#define _STACK_HXX +#define _QUEUE_HXX +#define _DYNARR_HXX +#define _TREELIST_HXX +#define _CACHESTR_HXX +#define _NEW_HXX +//#define _SHL_HXX +//#define _LINK_HXX +//#define _ERRCODE_HXX +//#define _GEN_HXX +//#define _FRACT_HXX +//#define _STRING_HXX +//#define _MTF_HXX +//#define _CONTNR_HXX +//#define _LIST_HXX +//#define _TABLE_HXX +#define _DYNARY_HXX +//#define _UNQIDX_HXX +#define _SVMEMPOOL_HXX +//#define _UNQID_HXX +//#define _DEBUG_HXX +//#define _DATE_HXX +//#define _TIME_HXX +//#define _DATETIME_HXX +//#define _INTN_HXX +//#define _WLDCRD_HXX +//#define _FSYS_HXX +//#define _STREAM_HXX +#define _CACHESTR_HXX +#define _SV_MULTISEL_HXX + +//SV +//#define _CLIP_HXX //*** +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _FONTDLG_HXX +#define _PRVWIN_HXX +//#define _COLOR_HXX +//#define _PAL_HXX +//#define _BITMAP_HXX +//#define _GDIOBJ_HXX +//#define _POINTR_HXX +//#define _ICON_HXX +//#define _IMAGE_HXX +//#define _KEYCOD_HXX +//#define _EVENT_HXX +#define _HELP_HXX +//#define _APP_HXX +//#define _MDIAPP_HXX +//#define _TIMER_HXX +//#define _METRIC_HXX +//#define _REGION_HXX +//#define _OUTDEV_HXX +//#define _SYSTEM_HXX +//#define _VIRDEV_HXX +//#define _JOBSET_HXX +//#define _PRINT_HXX +//#define _WINDOW_HXX +//#define _SYSWIN_HXX +//#define _WRKWIN_HXX +#define _MDIWIN_HXX +//#define _FLOATWIN_HXX +//#define _DOCKWIN_HXX +//#define _CTRL_HXX +//#define _SCRBAR_HXX +//#define _BUTTON_HXX +//#define _IMAGEBTN_HXX +//#define _FIXED_HXX +//#define _GROUP_HXX +//#define _EDIT_HXX +//#define _COMBOBOX_HXX +//#define _LSTBOX_HXX +//#define _SELENG_HXX *** +//#define _SPLIT_HXX +#define _SPIN_HXX +//#define _FIELD_HXX +//#define _MOREBTN_HXX *** +//#define _TOOLBOX_HXX +//#define _STATUS_HXX *** +//#define _DIALOG_HXX +//#define _MSGBOX_HXX +//#define _SYSDLG_HXX +//#define _PRNDLG_HXX +#define _COLDLG_HXX +//#define _TABDLG_HXX +//#define _GDIMTF_HXX +//#define _POLY_HXX +//#define _ACCEL_HXX +#define _SOUND_HXX + +#if defined WIN +#define _MENUBTN_HXX +#endif + +//svtools +#define _SCRWIN_HXX +#define _RULER_HXX +//#define _TABBAR_HXX +//#define _VALUESET_HXX +#define _STDMENU_HXX +//#define _STDCTRL_HXX +//#define _CTRLBOX_HXX +#define _CTRLTOOL_HXX +#define _EXTATTR_HXX +#define _FRM3D_HXX +#define _EXTATTR_HXX + +//SVTOOLS +//#define _SVTREELIST_HXX +#define _FILTER_HXX +//#define _SVLBOXITM_HXX +//#define _SVTREEBOX_HXX +#define _SVICNVW_HXX +#define _SVTABBX_HXX + + +//sfxsh.hxx +//#define _SFXSH_HXX +///#define _PLUGAPPL_HXX +//#define _SFX_SHELL_HXX +//#define _SFXAPP_HXX +//#define _SFX_BINDINGS_HXX +//#define _SFXDISPATCH_HXX +#define _SFXMSG_HXX +#define _SFXOBJFACE_HXX +#define _SFXREQUEST_HXX +#define _SFXMACRO_HXX + + +// SFX +#define _SFX_SAVEOPT_HXX +#define _SFXPRNMON_HXX +#define _INTRO_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFXFILEDLG_HXX +#define _PASSWD_HXX +#define _SFXTBXCTRL_HXX +#define _SFXSTBITEM_HXX +#define _SFXMNUITEM_HXX +#define _SFXIMGMGR_HXX +#define _SFXTBXMGR_HXX +#define _SFXSTBMGR_HXX +#define _SFX_MINFITEM_HXX +#define _SFXEVENT_HXX +#define _SFX_CHILDALIGN_HXX +#define _SFXAPPWIN_HXX +#define _SFX_CHILDWIN_HXX +#define _SFXCTRLITEM_HXX + + +//sfxdoc.hxx +//#define _SFX_OBJSH_HXX +//#define _SFX_CLIENTSH_HXX +//#define _SFXDOCINF_HXX +//#define _SFX_OBJFAC_HXX +//#define _SFX_DOCFILT_HXX +//#define _SFXDOCFILE_HXX *** +//define _VIEWFAC_HXX +//#define _SFXVIEWFRM_HXX +//#define _SFXVIEWSH_HXX +//#define _MDIFRM_HXX *** +#define _SFX_IPFRM_HXX +//#define _SFX_INTERNO_HXX + +//sfxdoc.hxx +//#define _SFXDOC_HXX +// --- #define _RSCSFX_HXX +//#define SFX_DECL_OBJECTSHELL_DEFINED +//#define _SFX_OBJSH_HXX +//#define _SFX_CLIENTSH_HXX +//#define _SFX_OBJFAC_HXX +#define _SFX_DOCFILT_HACK_HXX +#define _SFX_FCONTNR_HXX +#define STRING_LIST +#define _SFXDOCFILE_HXX +//#define _SFX_INTERNO_HXX + +//sfxdlg.hxx +//#define _SFXDLG_HXX +#define _DOCMGR_HXX +//#define _SFXITEMS_HXX +//#define _SFXTABDLG_HXX +#define _BASEDLGS_HXX +#define _SFX_DINFDLG_HXX +#define _SFXDINFEDT_HXX +#define _SFX_MGETEMPL_HXX +#define _SFX_TPLPITEM_HXX +#define _SFX_STYLEDLG_HXX +#define _NEWSTYLE_HXX +//#define SFX_DECL_OBJECTSHELL_DEFINED +#define _SFXDOCTEMPL_HXX +#define _SFXDOCTDLG_HXX +#define _SFXDOCKWIN_HXX +#define _SFX_TEMPLDLG_HXX +#define _SFXNEW_HXX +#define _SFXDOCMAN_HXX +#define _SFXNAVI_HXX +//sfxitems.hxx +#define _SFX_WHMAP_HXX +#define _ARGS_HXX +//#define _SFXPOOLITEM_HXX +//#define _SFXINTITEM_HXX +//#define _SFXENUMITEM_HXX +#define _SFXFLAGITEM_HXX +//#define _SFXSTRITEM_HXX +#define _SFXPTITEM_HXX +#define _SFXRECTITEM_HXX +//#define _SFXITEMPOOL_HXX +//#define _SFXITEMSET_HXX +#define _SFXITEMITER_HXX +#define _SFX_WHITER_HXX +#define _SFXPOOLCACH_HXX +//#define _AEITEM_HXX +#define _SFXRNGITEM_HXX +//#define _SFXSLSTITM_HXX +//#define _SFXSTYLE_HXX + +//xout.hxx +//#define _XENUM_HXX +//#define _XPOLY_HXX +//#define _XATTR_HXX +//#define _XOUTX_HXX +//#define _XPOOL_HXX +//#define _XTABLE_HXX + +//svdraw.hxx +#define _SDR_NOITEMS +#define _SDR_NOTOUCH +#define _SDR_NOTRANSFORM +#define _SDR_NOOBJECTS //** + +#define _SI_NOSBXCONTROLS +//#define _VCONT_HXX *** +#define _SI_NOOTHERFORMS +#define _SI_NOCONTROL +#define _SETBRW_HXX +#define _VCBRW_HXX +#define _SI_NOSBXCONTROLS +#define _SIDLL_HXX + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_THESDLG_HXX + +// INCLUDE --------------------------------------------------------------- + +//#define SI_VCDRAWOBJ + +#include <tools/urlobj.hxx> +#include <svx/fmglob.hxx> +#include <svx/svdouno.hxx> +#include <svx/svdpagv.hxx> + +#include <com/sun/star/form/FormButtonType.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/awt/XControlModel.hpp> + +using namespace com::sun::star; + +#include "tabvwsh.hxx" +#include "document.hxx" +#include "drawview.hxx" +#include "globstr.hrc" + +//------------------------------------------------------------------------ + +void ScTabViewShell::InsertURLButton( const String& rName, const String& rURL, + const String& rTarget, + const Point* pInsPos ) +{ + // Tabelle geschuetzt ? + + ScViewData* pViewData = GetViewData(); + if ( pViewData->GetDocument()->IsTabProtected(pViewData->GetTabNo()) ) + { + ErrorMessage(STR_PROTECTIONERR); + return; + } + + MakeDrawLayer(); + + ScTabView* pView = pViewData->GetView(); +// SdrView* pDrView = pView->GetSdrView(); + ScDrawView* pDrView = pView->GetScDrawView(); + SdrModel* pModel = pDrView->GetModel(); + + SdrObject* pObj = SdrObjFactory::MakeNewObject(FmFormInventor, OBJ_FM_BUTTON, + pDrView->GetPageViewPvNum(0)->GetPage(), pModel); + SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, pObj); + + uno::Reference<awt::XControlModel> xControlModel = pUnoCtrl->GetUnoControlModel(); + DBG_ASSERT( xControlModel.is(), "UNO-Control ohne Model" ); + if( !xControlModel.is() ) + return; + + uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY ); + uno::Any aAny; + + aAny <<= rtl::OUString(rName); + xPropSet->setPropertyValue( rtl::OUString::createFromAscii( "Label" ), aAny ); + + aAny <<= rtl::OUString(INetURLObject::RelToAbs(rURL)); + xPropSet->setPropertyValue( rtl::OUString::createFromAscii( "TargetURL" ), aAny ); + + if( rTarget.Len() ) + { + aAny <<= rtl::OUString(rTarget); + xPropSet->setPropertyValue( rtl::OUString::createFromAscii( "TargetFrame" ), aAny ); + } + + form::FormButtonType eButtonType = form::FormButtonType_URL; + aAny <<= eButtonType; + xPropSet->setPropertyValue( rtl::OUString::createFromAscii( "ButtonType" ), aAny ); + + Point aPos; + if (pInsPos) + aPos = *pInsPos; + else + aPos = GetInsertPos(); + + // Groesse wie in 3.1: + Size aSize = GetActiveWin()->PixelToLogic(Size(140, 20)); + + pObj->SetLogicRect(Rectangle(aPos, aSize)); +// pObj->Resize(Point(), Fraction(1, 1), Fraction(1, 1)); + + // am alten VC-Button musste die Position/Groesse nochmal explizit + // gesetzt werden - das scheint mit UnoControls nicht noetig zu sein + + // nicht markieren wenn Ole + pDrView->InsertObjectSafe( pObj, *pDrView->GetPageViewPvNum(0) ); +} + + + + diff --git a/sc/source/ui/view/tabvwshh.cxx b/sc/source/ui/view/tabvwshh.cxx new file mode 100644 index 000000000000..f72a550e7790 --- /dev/null +++ b/sc/source/ui/view/tabvwshh.cxx @@ -0,0 +1,557 @@ +/************************************************************************* + * + * $RCSfile: tabvwshh.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +// TOOLS +#define _BIGINT_HXX +#define _SFXMULTISEL_HXX +#define _STACK_HXX +#define _QUEUE_HXX +#define _DYNARR_HXX +#define _TREELIST_HXX +#define _CACHESTR_HXX +#define _NEW_HXX +//#define _SHL_HXX +//#define _LINK_HXX +//#define _ERRCODE_HXX +//#define _GEN_HXX +//#define _FRACT_HXX +//#define _STRING_HXX +//#define _MTF_HXX +//#define _CONTNR_HXX +//#define _LIST_HXX +//#define _TABLE_HXX +#define _DYNARY_HXX +//#define _UNQIDX_HXX +#define _SVMEMPOOL_HXX +//#define _UNQID_HXX +//#define _DEBUG_HXX +//#define _DATE_HXX +//#define _TIME_HXX +//#define _DATETIME_HXX +//#define _INTN_HXX +//#define _WLDCRD_HXX +//#define _FSYS_HXX +//#define _STREAM_HXX +#define _CACHESTR_HXX +#define _SV_MULTISEL_HXX + +//SV +//#define _CLIP_HXX *** +//#define _CONFIG_HXX +#define _CURSOR_HXX +#define _FONTDLG_HXX +#define _PRVWIN_HXX +//#define _COLOR_HXX +//#define _PAL_HXX +//#define _BITMAP_HXX +//#define _GDIOBJ_HXX +//#define _POINTR_HXX +//#define _ICON_HXX +//#define _IMAGE_HXX +//#define _KEYCOD_HXX +//#define _EVENT_HXX +#define _HELP_HXX +//#define _APP_HXX +//#define _MDIAPP_HXX +//#define _TIMER_HXX +//#define _METRIC_HXX +//#define _REGION_HXX +//#define _OUTDEV_HXX +//#define _SYSTEM_HXX +//#define _VIRDEV_HXX +//#define _JOBSET_HXX +//#define _PRINT_HXX +//#define _WINDOW_HXX +//#define _SYSWIN_HXX +//#define _WRKWIN_HXX +#define _MDIWIN_HXX +//#define _FLOATWIN_HXX +//#define _DOCKWIN_HXX +//#define _CTRL_HXX +//#define _SCRBAR_HXX +//#define _BUTTON_HXX +//#define _IMAGEBTN_HXX +//#define _FIXED_HXX +//#define _GROUP_HXX +//#define _EDIT_HXX +//#define _COMBOBOX_HXX +//#define _LSTBOX_HXX +//#define _SELENG_HXX *** +//#define _SPLIT_HXX +#define _SPIN_HXX +//#define _FIELD_HXX +#define _MOREBTN_HXX +//#define _TOOLBOX_HXX +//#define _STATUS_HXX *** +//#define _DIALOG_HXX +//#define _MSGBOX_HXX +//#define _SYSDLG_HXX +#define _FILDLG_HXX +//#define _PRNDLG_HXX +#define _COLDLG_HXX +//#define _TABDLG_HXX +//#define _MENU_HXX *** +//#define _GDIMTF_HXX +//#define _POLY_HXX +//#define _ACCEL_HXX +//#define _GRAPH_HXX +#define _SOUND_HXX + +#if defined WIN +#define _MENUBTN_HXX +#endif + +//svtools +#define _SCRWIN_HXX +#define _RULER_HXX +//#define _TABBAR_HXX +//#define _VALUESET_HXX +#define _STDMENU_HXX +//#define _STDCTRL_HXX +//#define _CTRLBOX_HXX +#define _CTRLTOOL_HXX +#define _EXTATTR_HXX +#define _FRM3D_HXX +#define _EXTATTR_HXX + +//SVTOOLS +#define _SVTREELIST_HXX +#define _FILTER_HXX +#define _SVLBOXITM_HXX +#define _SVTREEBOX_HXX +#define _SVICNVW_HXX +#define _SVTABBX_HXX + +//sfxcore.hxx +#define _SFXINIMGR_HXX +//#define _SFXCFGITEM_HXX +//#define _SFX_PRINTER_HXX +#define _SFXGENLINK_HXX +#define _SFXHINTPOST_HXX +#define _SFXDOCINF_HXX +#define _SFXLINKHDL_HXX +//#define _SFX_PROGRESS_HXX + +//sfxsh.hxx +//#define _SFX_SHELL_HXX +//#define _SFXAPP_HXX +//#define _SFX_BINDINGS_HXX +//#define _SFXDISPATCH_HXX +#define _SFXMSG_HXX +#define _SFXOBJFACE_HXX +//#define _SFXREQUEST_HXX +#define _SFXMACRO_HXX + +// SFX +#define _SFXAPPWIN_HXX +#define _SFX_SAVEOPT_HXX +//#define _SFX_CHILDWIN_HXX +//#define _SFXCTRLITEM_HXX +#define _SFXPRNMON_HXX +#define _INTRO_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFXFILEDLG_HXX +#define _PASSWD_HXX +#define _SFXTBXCTRL_HXX +#define _SFXSTBITEM_HXX +#define _SFXMNUITEM_HXX +#define _SFXIMGMGR_HXX +#define _SFXTBXMGR_HXX +#define _SFXSTBMGR_HXX +#define _SFX_MINFITEM_HXX +#define _SFXEVENT_HXX + +//sfxdoc.hxx +//#define _SFX_OBJSH_HXX +//#define _SFX_CLIENTSH_HXX +//#define _SFXDOCINF_HXX +//#define _SFX_OBJFAC_HXX +#define _SFX_DOCFILT_HXX +#define _SFXDOCFILE_HXX +//define _VIEWFAC_HXX +//#define _SFXVIEWFRM_HXX +//#define _SFXVIEWSH_HXX +#define _MDIFRM_HXX +//#define _SFX_IPFRM_HXX *** +//#define _SFX_INTERNO_HXX + +//sfxdlg.hxx +//#define _SFXTABDLG_HXX +#define _BASEDLGS_HXX +#define _SFX_DINFDLG_HXX +#define _SFXDINFEDT_HXX +#define _SFX_MGETEMPL_HXX +#define _SFX_TPLPITEM_HXX +//#define _SFX_STYLEDLG_HXX +#define _NEWSTYLE_HXX +#define _SFXDOCTEMPL_HXX +#define _SFXDOCTDLG_HXX +#define _SFX_TEMPLDLG_HXX +#define _SFXNEW_HXX +#define _SFXDOCMAN_HXX +//#define _SFXDOCKWIN_HXX *** + +//sfxitems.hxx +#define _SFX_WHMAP_HXX +//#define _ARGS_HXX *** +//#define _SFXPOOLITEM_HXX +//#define _SFXINTITEM_HXX +//#define _SFXENUMITEM_HXX +#define _SFXFLAGITEM_HXX +//#define _SFXSTRITEM_HXX +#define _SFXPTITEM_HXX +//#define _SFXRECTITEM_HXX *** +//#define _SFXITEMPOOL_HXX +//#define _SFXITEMSET_HXX +#define _SFXITEMITER_HXX +//#define _SFX_WHITER_HXX *** +#define _SFXPOOLCACH_HXX +//#define _AEITEM_HXX +//#define _SFXRNGITEM_HXX *** +//#define _SFXSLSTITM_HXX +//#define _SFXSTYLE_HXX + +//xout.hxx +//#define _XENUM_HXX +//#define _XPOLY_HXX +//#define _XATTR_HXX +//#define _XOUTX_HXX +//#define _XPOOL_HXX +//#define _XTABLE_HXX + +//svdraw.hxx +#define _SDR_NOITEMS +#define _SDR_NOTOUCH +#define _SDR_NOTRANSFORM +//#define _SDR_NOOBJECTS +//#define _SDR_NOVIEWS + +//#define SI_NOITEMS +//#define SI_NODRW +#define _SI_NOSBXCONTROLS +//#define _VCATTR_HXX +#define _VCONT_HXX +//#define _VCSBX_HXX +#define _SI_NOOTHERFORMS +#define _VCTRLS_HXX +//#define _VCDRWOBJ_HXX +#define _SI_NOCONTROL +#define _SETBRW_HXX +#define _VCBRW_HXX +#define _SI_NOSBXCONTROLS +#define _SIDLL_HXX + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_THESDLG_HXX + +// svdraw.hxx +#define _SDR_NOITEMS +#define _SVDXOUT_HXX +#define _SDR_NOTRANSFORM // Transformationen, selten verwendet +#define _SDR_NOTOUCH // Hit-Tests, selten verwendet +#define _SDR_NOEXTDEV // ExtOutputDevice +//#define _SDR_NOUNDO // Undo-Objekte +#define _SDR_NOSURROGATEOBJ // SdrObjSurrogate +#define _SDR_NOPAGEOBJ // SdrPageObj +#define _SDR_NOVIRTOBJ // SdrVirtObj +#define _SDR_NOGROUPOBJ // SdrGroupObj +#define _SDR_NOTEXTOBJ // SdrTextObj //* +#define _SDR_NOPATHOBJ // SdrPathObj +#define _SDR_NOEDGEOBJ // SdrEdgeObj +#define _SDR_NORECTOBJ // SdrRectObj +#define _SDR_NOCAPTIONOBJ // SdrCaptionObj +#define _SDR_NOCIRCLEOBJ // SdrCircleObj +#define _SDR_NOGRAFOBJ // SdrGrafObj +#define _SDR_NOOLE2OBJ // SdrOle2Obj + +// INCLUDE --------------------------------------------------------------- + +#include <svx/svdmark.hxx> +#include <svx/svdoole2.hxx> +#include <svx/svdview.hxx> +#include <sfx2/app.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/request.hxx> +#include <svtools/sbxcore.hxx> +#include <so3/ipobj.hxx> +#include <svtools/whiter.hxx> + +#include "tabvwsh.hxx" +#include "client.hxx" +#include "document.hxx" +#include "docsh.hxx" +#include "sc.hrc" + +//------------------------------------------------------------------ + +void ScTabViewShell::ExecuteSbx( SfxRequest& rReq ) +{ + // SID_RANGE_OFFSET (Offset), + // SID_PIVOT_CREATE (DataPilotCreate) - removed (old Basic) +} + +void ScTabViewShell::GetSbxState( SfxItemSet& rSet ) +{ + // SID_RANGE_REGION (CurrentRegion) - removed (old Basic) +} + +//------------------------------------------------------------------ + +void ScTabViewShell::ExecuteObject( SfxRequest& rReq ) +{ + USHORT nSlotId = rReq.GetSlot(); + const SfxItemSet* pReqArgs = rReq.GetArgs(); + + // Objekte aktivieren/deaktivieren immer auf der sichtbaren View + + ScTabViewShell* pVisibleSh = this; + if ( nSlotId == SID_OLE_SELECT || nSlotId == SID_OLE_ACTIVATE || nSlotId == SID_OLE_DEACTIVATE ) + { + DBG_ERROR("old slot SID_OLE..."); + } + + switch (nSlotId) + { + case SID_OLE_SELECT: + case SID_OLE_ACTIVATE: + { + // in beiden Faellen erstmal auf der sichtbaren View selektieren + + String aName; + SdrView* pDrView = GetSdrView(); + if (pDrView) + { + const SdrMarkList& rMarkList = pDrView->GetMarkList(); + if (rMarkList.GetMarkCount() == 1) + aName = rMarkList.GetMark(0)->GetObj()->GetName(); + } + pVisibleSh->SelectObject( aName ); + + // aktivieren + + if ( nSlotId == SID_OLE_ACTIVATE ) + pVisibleSh->DoVerb( 0 ); + } + break; + case SID_OLE_DEACTIVATE: + { + ScClient* pClient = (ScClient*) pVisibleSh->GetIPClient(); + if ( pClient && pClient->IsInPlaceActive() ) + { + pClient->GetProtocol().Reset2Open(); + SFX_APP()->SetViewFrame(pVisibleSh->GetViewFrame()); + } + } + break; + + case SID_OBJECT_LEFT: + case SID_OBJECT_TOP: + case SID_OBJECT_WIDTH: + case SID_OBJECT_HEIGHT: + { + BOOL bDone = FALSE; + const SfxPoolItem* pItem; + if ( pReqArgs && pReqArgs->GetItemState( nSlotId, TRUE, &pItem ) == SFX_ITEM_SET ) + { + long nNewVal = ((const SfxInt32Item*)pItem)->GetValue(); + if ( nNewVal < 0 ) + nNewVal = 0; + + //! von irgendwas in 1/100mm umrechnen ?????? + + SdrView* pDrView = GetSdrView(); + if ( pDrView ) + { + const SdrMarkList& rMarkList = pDrView->GetMarkList(); + if (rMarkList.GetMarkCount() == 1) + { + SdrObject* pObj = rMarkList.GetMark(0)->GetObj(); + Rectangle aRect = pObj->GetLogicRect(); + + if ( nSlotId == SID_OBJECT_LEFT ) + pDrView->MoveMarkedObj( Size( nNewVal - aRect.Left(), 0 ) ); + else if ( nSlotId == SID_OBJECT_TOP ) + pDrView->MoveMarkedObj( Size( 0, nNewVal - aRect.Top() ) ); + else if ( nSlotId == SID_OBJECT_WIDTH ) + pDrView->ResizeMarkedObj( aRect.TopLeft(), + Fraction( nNewVal, aRect.GetWidth() ), + Fraction( 1, 1 ) ); + else // if ( nSlotId == SID_OBJECT_HEIGHT ) + pDrView->ResizeMarkedObj( aRect.TopLeft(), + Fraction( 1, 1 ), + Fraction( nNewVal, aRect.GetHeight() ) ); + bDone = TRUE; + } + } + } + if (!bDone) + SbxBase::SetError( SbxERR_BAD_PARAMETER ); // Basic-Fehler + } + break; + + } +} + +SvInPlaceObjectRef lcl_GetSelectedObj( SdrView* pDrView ) //! Member von ScDrawView? +{ + SvInPlaceObjectRef xRet; + + if (pDrView) + { + const SdrMarkList& rMarkList = pDrView->GetMarkList(); + if (rMarkList.GetMarkCount() == 1) + { + SdrObject* pObj = rMarkList.GetMark(0)->GetObj(); + if (pObj->GetObjIdentifier() == OBJ_OLE2) + { + SdrOle2Obj* pOle2Obj = (SdrOle2Obj*) pObj; + xRet = pOle2Obj->GetObjRef(); + } + } + } + + return xRet; +} + +void ScTabViewShell::GetObjectState( SfxItemSet& rSet ) +{ + // SID_OLE_OBJECT - removed (old Basic) + + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + while ( nWhich ) + { + switch (nWhich) + { + case SID_ACTIVE_OBJ_NAME: + { + String aName; + SvInPlaceObjectRef xOLE = lcl_GetSelectedObj( GetSdrView() ); + if (xOLE.Is()) + { + SvInfoObject* pInfoObj = GetViewData()->GetSfxDocShell()->Find( xOLE ); + if ( pInfoObj ) + aName = pInfoObj->GetObjName(); + } + rSet.Put( SfxStringItem( nWhich, aName ) ); + } + break; + case SID_OBJECT_LEFT: + case SID_OBJECT_TOP: + case SID_OBJECT_WIDTH: + case SID_OBJECT_HEIGHT: + { + SdrView* pDrView = GetSdrView(); + if ( pDrView ) + { + const SdrMarkList& rMarkList = pDrView->GetMarkList(); + if (rMarkList.GetMarkCount() == 1) + { + SdrObject* pObj = rMarkList.GetMark(0)->GetObj(); + Rectangle aRect = pObj->GetLogicRect(); + + long nVal; + if ( nWhich == SID_OBJECT_LEFT ) + nVal = aRect.Left(); + else if ( nWhich == SID_OBJECT_TOP ) + nVal = aRect.Top(); + else if ( nWhich == SID_OBJECT_WIDTH ) + nVal = aRect.GetWidth(); + else // if ( nWhich == SID_OBJECT_HEIGHT ) + nVal = aRect.GetHeight(); + + //! von 1/100mm in irgendwas umrechnen ?????? + + rSet.Put( SfxInt32Item( nWhich, nVal ) ); + } + } + } + break; + } + nWhich = aIter.NextWhich(); + } +} + + + + + diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx new file mode 100644 index 000000000000..fc6674ac467c --- /dev/null +++ b/sc/source/ui/view/viewdata.cxx @@ -0,0 +1,2117 @@ +/************************************************************************* + * + * $RCSfile: viewdata.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <svx/adjitem.hxx> +#include <svx/algitem.hxx> +#include <svx/brshitem.hxx> +#include <svx/editview.hxx> +#include <svx/editstat.hxx> +#include <svx/outliner.hxx> +#include <offmgr/app.hxx> + +#ifdef ONE_LINGU +#else +#include <offmgr/osplcfg.hxx> +#endif + +#include <vcl/system.hxx> + +#include "viewdata.hxx" +#include "docoptio.hxx" +#include "scmod.hxx" +#include "global.hxx" +#include "document.hxx" +#include "attrib.hxx" +#include "tabview.hxx" +#include "tabvwsh.hxx" +#include "docsh.hxx" +#include "sc.hrc" +#include "patattr.hxx" +#include "editutil.hxx" +#include "scextopt.hxx" + +// STATIC DATA ----------------------------------------------------------- + +#define TAG_TABBARWIDTH "tw:" + +static BOOL bMoveArea = FALSE; //! Member? +USHORT nEditAdjust = SVX_ADJUST_LEFT; //! Member !!! + +//================================================================== + +ScViewDataTable::ScViewDataTable() : + nCurX( 0 ), + nCurY( 0 ), + bOldCurValid( FALSE ), + eHSplitMode( SC_SPLIT_NONE ), + eVSplitMode( SC_SPLIT_NONE ), + nHSplitPos( 0 ), + nVSplitPos( 0 ), + nFixPosX( 0 ), + nFixPosY( 0 ), + eWhichActive( SC_SPLIT_BOTTOMLEFT ) +{ + nPosX[0]=nPosX[1]= + nPosY[0]=nPosY[1]=0; + nTPosX[0]=nTPosX[1]= + nTPosY[0]=nTPosY[1]=0; + nMPosX[0]=nMPosX[1]= + nMPosY[0]=nMPosY[1]=0; + nPixPosX[0]=nPixPosX[1]= + nPixPosY[0]=nPixPosY[1]=0; +} + +ScViewDataTable::ScViewDataTable( const ScViewDataTable& rDataTable ) : + nCurX( rDataTable.nCurX ), + nCurY( rDataTable.nCurY ), + bOldCurValid( rDataTable.bOldCurValid ), + nOldCurX( rDataTable.nOldCurX ), + nOldCurY( rDataTable.nOldCurY ), + eHSplitMode( rDataTable.eHSplitMode ), + eVSplitMode( rDataTable.eVSplitMode ), + nHSplitPos( rDataTable.nHSplitPos ), + nVSplitPos( rDataTable.nVSplitPos ), + nFixPosX( rDataTable.nFixPosX ), + nFixPosY( rDataTable.nFixPosY ), + eWhichActive( rDataTable.eWhichActive ) +{ + nPosX[0]=rDataTable.nPosX[0]; + nPosX[1]=rDataTable.nPosX[1]; + nPosY[0]=rDataTable.nPosY[0]; + nPosY[1]=rDataTable.nPosY[1]; + + nTPosX[0]=rDataTable.nTPosX[0]; + nTPosX[1]=rDataTable.nTPosX[1]; + nTPosY[0]=rDataTable.nTPosY[0]; + nTPosY[1]=rDataTable.nTPosY[1]; + + nMPosX[0]=rDataTable.nMPosX[0]; + nMPosX[1]=rDataTable.nMPosX[1]; + nMPosY[0]=rDataTable.nMPosY[0]; + nMPosY[1]=rDataTable.nMPosY[1]; + + nPixPosX[0]=rDataTable.nPixPosX[0]; + nPixPosX[1]=rDataTable.nPixPosX[1]; + nPixPosY[0]=rDataTable.nPixPosY[0]; + nPixPosY[1]=rDataTable.nPixPosY[1]; +} + +ScViewDataTable::~ScViewDataTable() +{ +} + +//================================================================== + +ScViewData::ScViewData( ScDocShell* pDocSh, ScTabViewShell* pViewSh ) + : pDocShell ( pDocSh ), + pViewShell ( pViewSh ), + pDoc ( NULL ), + pView ( pViewSh ), + pOptions ( new ScViewOptions ), + nTabNo ( 0 ), + nRefTabNo ( 0 ), + aZoomX ( 1,1 ), + aZoomY ( 1,1 ), + aPageZoomX ( 3,5 ), // Page-Default: 60% + aPageZoomY ( 3,5 ), + aLogicMode ( MAP_100TH_MM ), + bIsRefMode ( FALSE ), + eRefType ( SC_REFTYPE_NONE ), + nFillMode ( SC_FILL_NONE ), + bDelMarkValid( FALSE ), + bActive ( TRUE ), //! wie initialisieren? + bPagebreak ( FALSE ), + pSpellingView ( NULL ) +{ + SetGridMode ( TRUE ); + SetSyntaxMode ( FALSE ); + SetHeaderMode ( TRUE ); + SetTabMode ( TRUE ); + SetVScrollMode ( TRUE ); + SetHScrollMode ( TRUE ); + SetOutlineMode ( TRUE ); + + aScrSize = Size( (long) ( STD_COL_WIDTH * PIXEL_PER_TWIPS * OLE_STD_CELLS_X ), + (long) ( ScGlobal::nStdRowHeight * PIXEL_PER_TWIPS * OLE_STD_CELLS_Y ) ); + pTabData[0] = new ScViewDataTable; + for (USHORT i=1; i<=MAXTAB; i++) pTabData[i] = NULL; + pThisTab = pTabData[nTabNo]; + for (i=0; i<4; i++) + { + pEditView[i] = NULL; + bEditActive[i] = FALSE; + } + + nEditEndCol = nEditCol = nEditEndRow = nEditRow = 0; + nTabStartCol = SC_TABSTART_NONE; + + if (pDocShell) + { + pDoc = pDocShell->GetDocument(); + *pOptions = pDoc->GetViewOptions(); + } + + // keine ausgeblendete Tabelle anzeigen: + if (pDoc && !pDoc->IsVisible(nTabNo)) + { + while ( !pDoc->IsVisible(nTabNo) && pDoc->HasTable(nTabNo+1) ) + ++nTabNo; + + pTabData[nTabNo] = new ScViewDataTable; + pThisTab = pTabData[nTabNo]; + } + + CalcPPT(); +} + +ScViewData::ScViewData( const ScViewData& rViewData ) + : pDocShell ( rViewData.pDocShell ), + pViewShell ( rViewData.pViewShell ), + pDoc ( rViewData.pDoc ), + pView ( rViewData.pView ), + pOptions ( new ScViewOptions( *(rViewData.pOptions) ) ), + nTabNo ( rViewData.nTabNo ), + nRefTabNo ( rViewData.nTabNo ), // kein RefMode + aZoomX ( rViewData.aZoomX ), + aZoomY ( rViewData.aZoomY ), + aPageZoomX ( rViewData.aPageZoomX ), + aPageZoomY ( rViewData.aPageZoomY ), + aLogicMode ( rViewData.aLogicMode ), + bIsRefMode ( FALSE ), + eRefType ( SC_REFTYPE_NONE ), + nFillMode ( SC_FILL_NONE ), + bDelMarkValid( FALSE ), + bActive ( TRUE ), //! wie initialisieren? + bPagebreak ( rViewData.bPagebreak ), + pSpellingView ( rViewData.pSpellingView ) +{ + SetGridMode ( rViewData.IsGridMode() ); + SetSyntaxMode ( rViewData.IsSyntaxMode() ); + SetHeaderMode ( rViewData.IsHeaderMode() ); + SetTabMode ( rViewData.IsTabMode() ); + SetVScrollMode ( rViewData.IsVScrollMode() ); + SetHScrollMode ( rViewData.IsHScrollMode() ); + SetOutlineMode ( rViewData.IsOutlineMode() ); + + aScrSize = rViewData.aScrSize; + for (USHORT i=0; i<=MAXTAB; i++) + if (rViewData.pTabData[i]) + pTabData[i] = new ScViewDataTable( *rViewData.pTabData[i] ); + else + pTabData[i] = NULL; + pThisTab = pTabData[nTabNo]; + for (i=0; i<4; i++) + { + pEditView[i] = NULL; + bEditActive[i] = FALSE; + } + + nEditEndCol = nEditCol = nEditEndRow = nEditRow = 0; + nTabStartCol = SC_TABSTART_NONE; + CalcPPT(); +} + +void ScViewData::SetDocShell( ScDocShell* pShell ) +{ + pDocShell = pShell; + pDoc = pDocShell->GetDocument(); + *pOptions = pDoc->GetViewOptions(); + CalcPPT(); +} + +void ScViewData::InitData( ScDocument* pDocument ) +{ + pDoc = pDocument; + *pOptions = pDoc->GetViewOptions(); +} + +void ScViewData::InitFrom( const ScViewData* pRef ) +{ + if (pRef==NULL) + { + DBG_ERROR("ScViewData::InitFrom mit NULL"); + return; + } + + aScrSize = pRef->aScrSize; + nTabNo = pRef->nTabNo; + aZoomX = pRef->aZoomX; + aZoomY = pRef->aZoomY; + aPageZoomX = pRef->aPageZoomX; + aPageZoomY = pRef->aPageZoomY; + bPagebreak = pRef->bPagebreak; + aLogicMode = pRef->aLogicMode; + + SetGridMode ( pRef->IsGridMode() ); + SetSyntaxMode ( pRef->IsSyntaxMode() ); + SetHeaderMode ( pRef->IsHeaderMode() ); + SetTabMode ( pRef->IsTabMode() ); + SetVScrollMode ( pRef->IsVScrollMode() ); + SetHScrollMode ( pRef->IsHScrollMode() ); + SetOutlineMode ( pRef->IsOutlineMode() ); + + for (USHORT i=0; i<=MAXTAB; i++) + { + delete pTabData[i]; + if (pRef->pTabData[i]) + pTabData[i] = new ScViewDataTable( *pRef->pTabData[i] ); + else + pTabData[i] = NULL; + } + pThisTab = pTabData[nTabNo]; + CalcPPT(); +} + +ScDocument* ScViewData::GetDocument() const +{ + if (pDoc) + return pDoc; + else if (pDocShell) + return pDocShell->GetDocument(); + + DBG_ERROR("kein Document an ViewData"); + return NULL; +} + +ScViewData::~ScViewData() +{ + for (USHORT i=0; i<=MAXTAB; i++) + if (pTabData[i]) + delete pTabData[i]; + + KillEditView(); + delete pOptions; +} + +void ScViewData::UpdateThis() +{ + do + { + pThisTab = pTabData[nTabNo]; + if (!pThisTab) + { + if (nTabNo>0) + --nTabNo; + else + pThisTab = pTabData[0] = new ScViewDataTable; + + // hier keine Assertion, weil sonst Paints kommen, bevor alles initialisiert ist! + } + } + while (!pThisTab); +} + +void ScViewData::InsertTab( USHORT nTab ) +{ + delete pTabData[MAXTAB]; + + for (USHORT i=MAXTAB; i>nTab; i--) + pTabData[i] = pTabData[i-1]; + + pTabData[nTab] = new ScViewDataTable; + + UpdateThis(); + aMarkData.InsertTab( nTab ); +} + +void ScViewData::DeleteTab( USHORT nTab ) +{ + delete pTabData[nTab]; + + for (USHORT i=nTab; i<MAXTAB; i++) + pTabData[i] = pTabData[i+1]; + + pTabData[MAXTAB] = NULL; + + UpdateThis(); + aMarkData.DeleteTab( nTab ); +} + +void ScViewData::CopyTab( USHORT nSrcTab, USHORT nDestTab ) +{ + if (nDestTab==SC_TAB_APPEND) + nDestTab = pDoc->GetTableCount() - 1; // am Doc muss vorher kopiert worden sein + + if (nDestTab > MAXTAB) + { + DBG_ERROR("Zuviele Tabellen"); + return; + } + + delete pTabData[MAXTAB]; + + for (USHORT i=MAXTAB; i>nDestTab; i--) + pTabData[i] = pTabData[i-1]; + + if ( pTabData[nSrcTab] ) + pTabData[nDestTab] = new ScViewDataTable( *pTabData[nSrcTab] ); + else + pTabData[nDestTab] = NULL; + + UpdateThis(); + aMarkData.InsertTab( nDestTab ); +} + +void ScViewData::MoveTab( USHORT nSrcTab, USHORT nDestTab ) +{ + if (nDestTab==SC_TAB_APPEND) + nDestTab = pDoc->GetTableCount() - 1; + + USHORT i; + ScViewDataTable* pTab = pTabData[nSrcTab]; + + USHORT nInsTab = nDestTab; + if ( nSrcTab < nDestTab ) + { + --nInsTab; + for (i=nSrcTab; i<nDestTab; i++) + pTabData[i] = pTabData[i+1]; + } + else + for (i=nSrcTab; i>nDestTab; i--) + pTabData[i] = pTabData[i-1]; + + pTabData[nDestTab] = pTab; + + UpdateThis(); + aMarkData.DeleteTab( nSrcTab ); + aMarkData.InsertTab( nInsTab ); // ggf. angepasst +} + +void ScViewData::UpdateOle( ScSplitPos eWhich ) +{ + GetDocShell()->UpdateOle(this); +} + +void ScViewData::SetViewShell( ScTabViewShell* pViewSh ) +{ + if (pViewSh) + { + pViewShell = pViewSh; + pView = pViewSh; + } + else + { + pViewShell = NULL; + pView = NULL; + } +} + +void ScViewData::SetZoom( const Fraction& rNewX, const Fraction& rNewY ) +{ + Fraction aFrac20( 1,5 ); + Fraction aFrac400( 4,1 ); + + Fraction aValidX = rNewX; + if (aValidX<aFrac20) aValidX = aFrac20; + if (aValidX>aFrac400) aValidX = aFrac400; + + Fraction aValidY = rNewY; + if (aValidY<aFrac20) aValidY = aFrac20; + if (aValidY>aFrac400) aValidY = aFrac400; + + if ( bPagebreak ) + { + aPageZoomX = aValidX; + aPageZoomY = aValidY; + } + else + { + aZoomX = aValidX; + aZoomY = aValidY; + } + + CalcPPT(); + RecalcPixPos(); + aScenButSize = Size(0,0); + aLogicMode.SetScaleX( aValidX ); + aLogicMode.SetScaleY( aValidY ); +} + +void ScViewData::SetPagebreakMode( BOOL bSet ) +{ + bPagebreak = bSet; + + CalcPPT(); + RecalcPixPos(); + aScenButSize = Size(0,0); + aLogicMode.SetScaleX( GetZoomX() ); + aLogicMode.SetScaleY( GetZoomY() ); +} + +BOOL ScViewData::GetSimpleArea( USHORT& rStartCol, USHORT& rStartRow, USHORT& rStartTab, + USHORT& rEndCol, USHORT& rEndRow, USHORT& rEndTab, BOOL bMergeMark ) +{ + if ( aMarkData.IsMarked() || aMarkData.IsMultiMarked() ) + { + if ( bMergeMark ) + if ( aMarkData.IsMultiMarked() ) + aMarkData.MarkToSimple(); + + if ( aMarkData.IsMarked() && !aMarkData.IsMultiMarked() ) + { + ScRange aMarkRange; + aMarkData.GetMarkArea( aMarkRange ); + rStartCol = aMarkRange.aStart.Col(); + rStartRow = aMarkRange.aStart.Row(); + rStartTab = aMarkRange.aStart.Tab(); + rEndCol = aMarkRange.aEnd.Col(); + rEndRow = aMarkRange.aEnd.Row(); + rEndTab = aMarkRange.aEnd.Tab(); + } + else + { + rStartCol = rEndCol = GetCurX(); + rStartRow = rEndRow = GetCurY(); + rStartTab = rEndTab = GetTabNo(); + return FALSE; + } + } + else + { + rStartCol = rEndCol = GetCurX(); + rStartRow = rEndRow = GetCurY(); + rStartTab = rEndTab = GetTabNo(); + } + return TRUE; +} + +BOOL ScViewData::GetSimpleArea( ScRange& rRange, BOOL bMergeMark ) +{ + if ( aMarkData.IsMarked() || aMarkData.IsMultiMarked() ) + { + if ( bMergeMark ) + if ( aMarkData.IsMultiMarked() ) + aMarkData.MarkToSimple(); + + if ( aMarkData.IsMarked() && !aMarkData.IsMultiMarked() ) + aMarkData.GetMarkArea( rRange ); + else + { + rRange = ScRange( GetCurX(), GetCurY(), GetTabNo() ); + return FALSE; + } + } + else + { + rRange = ScRange( GetCurX(), GetCurY(), GetTabNo() ); + } + return TRUE; +} + +void ScViewData::GetMultiArea( ScRangeListRef& rRange, BOOL bMergeMark ) +{ + BOOL bMulti = aMarkData.IsMultiMarked(); + if (bMulti && bMergeMark) + { + aMarkData.MarkToSimple(); + bMulti = aMarkData.IsMultiMarked(); + } + if (bMulti) + { + rRange = new ScRangeList; + aMarkData.FillRangeListWithMarks( rRange, FALSE ); + } + else + { + ScRange aSimple; + GetSimpleArea(aSimple,FALSE); + rRange = new ScRangeList; + rRange->Append(aSimple); + } +} + +BOOL ScViewData::SimpleColMarked() +{ + USHORT nStartCol; + USHORT nStartRow; + USHORT nStartTab; + USHORT nEndCol; + USHORT nEndRow; + USHORT nEndTab; + if (GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab)) + if (nStartRow==0 && nEndRow==MAXROW) + return TRUE; + + return FALSE; +} + +BOOL ScViewData::SimpleRowMarked() +{ + USHORT nStartCol; + USHORT nStartRow; + USHORT nStartTab; + USHORT nEndCol; + USHORT nEndRow; + USHORT nEndTab; + if (GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab)) + if (nStartCol==0 && nEndCol==MAXCOL) + return TRUE; + + return FALSE; +} + +void ScViewData::SetFillMode( USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow ) +{ + nFillMode = SC_FILL_FILL; + nFillStartX = nStartCol; + nFillStartY = nStartRow; + nFillEndX = nEndCol; + nFillEndY = nEndRow; +} + +void ScViewData::SetDragMode( USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow, + BYTE nMode ) +{ + nFillMode = nMode; + nFillStartX = nStartCol; + nFillStartY = nStartRow; + nFillEndX = nEndCol; + nFillEndY = nEndRow; +} + +void ScViewData::ResetFillMode() +{ + nFillMode = SC_FILL_NONE; +} + +void ScViewData::GetFillData( USHORT& rStartCol, USHORT& rStartRow, + USHORT& rEndCol, USHORT& rEndRow ) +{ + rStartCol = nFillStartX; + rStartRow = nFillStartY; + rEndCol = nFillEndX; + rEndRow = nFillEndY; +} + +USHORT ScViewData::GetOldCurX() const +{ + if (pThisTab->bOldCurValid) + return pThisTab->nOldCurX; + else + return pThisTab->nCurX; +} + +USHORT ScViewData::GetOldCurY() const +{ + if (pThisTab->bOldCurValid) + return pThisTab->nOldCurY; + else + return pThisTab->nCurY; +} + +void ScViewData::SetOldCursor( USHORT nNewX, USHORT nNewY ) +{ + pThisTab->nOldCurX = nNewX; + pThisTab->nOldCurY = nNewY; + pThisTab->bOldCurValid = TRUE; +} + +void ScViewData::ResetOldCursor() +{ + pThisTab->bOldCurValid = FALSE; +} + +Rectangle ScViewData::GetEditArea( ScSplitPos eWhich, USHORT nPosX, USHORT nPosY, + Window* pWin, const ScPatternAttr* pPattern ) +{ + return ScEditUtil( pDoc, nPosX, nPosY, nTabNo, GetScrPos(nPosX,nPosY,eWhich,TRUE), + pWin, nPPTX, nPPTY, GetZoomX(), GetZoomY() ).GetEditArea( pPattern ); +} + +void ScViewData::SetEditEngine( ScSplitPos eWhich, + ScEditEngineDefaulter* pNewEngine, + Window* pWin, USHORT nNewX, USHORT nNewY ) +{ + ScHSplitPos eHWhich = WhichH(eWhich); + + BOOL bWasThere = FALSE; + if (pEditView[eWhich]) + { + // Wenn die View schon da ist, nichts aufrufen, was die Cursorposition aendert + + if (bEditActive[eWhich]) + bWasThere = TRUE; + else + pEditView[eWhich]->SetEditEngine(pNewEngine); + + if (pEditView[eWhich]->GetWindow() != pWin) + { + pEditView[eWhich]->SetWindow(pWin); + DBG_ERROR("EditView Window geaendert"); + } + } + else + { + pEditView[eWhich] = new EditView( pNewEngine, pWin ); + } + + // bei IdleFormat wird manchmal ein Cursor gemalt, wenn die View schon weg ist (23576) + + ULONG nEC = pNewEngine->GetControlWord(); + pNewEngine->SetControlWord(nEC & ~EE_CNTRL_DOIDLEFORMAT); + + ULONG nVC = pEditView[eWhich]->GetControlWord(); + pEditView[eWhich]->SetControlWord(nVC & ~EV_CNTRL_AUTOSCROLL); + + bEditActive[eWhich] = TRUE; + + const ScPatternAttr* pPattern = pDoc->GetPattern( nNewX, nNewY, nTabNo ); + SvxCellHorJustify eJust = (SvxCellHorJustify)((const SvxHorJustifyItem&) + pPattern->GetItem( ATTR_HOR_JUSTIFY )).GetValue(); + + BOOL bBreak = ( eJust == SVX_HOR_JUSTIFY_BLOCK ) || + ((SfxBoolItem&)pPattern->GetItem(ATTR_LINEBREAK)).GetValue(); + + nEditCol = nNewX; + nEditRow = nNewY; + const ScMergeAttr* pMergeAttr = (ScMergeAttr*)&pPattern->GetItem(ATTR_MERGE); + nEditEndCol = nEditCol; + if (pMergeAttr->GetColMerge() > 1) + nEditEndCol += pMergeAttr->GetColMerge() - 1; + nEditEndRow = nEditRow; + if (pMergeAttr->GetRowMerge() > 1) + nEditEndRow += pMergeAttr->GetRowMerge() - 1; + +// Rectangle aPixRect = GetEditArea( eWhich, nNewX, nNewY, pWin, pPattern ); + Rectangle aPixRect = ScEditUtil( pDoc, nNewX,nNewY,nTabNo, GetScrPos(nNewX,nNewY,eWhich), + pWin, nPPTX,nPPTY,GetZoomX(),GetZoomY() ). + GetEditArea( pPattern ); + + // bei rechtsbuendigem Editieren muss rechts noch Platz fuer den Cursor sein + if ( nEditAdjust == SVX_ADJUST_RIGHT ) + aPixRect.Right() += 1; + + Rectangle aOutputArea = pWin->PixelToLogic( aPixRect, GetLogicMode() ); + pEditView[eWhich]->SetOutputArea( aOutputArea ); + + if ( bActive && eWhich == GetActivePart() ) + { + long nSizeXPix; + if (bBreak) + nSizeXPix = aPixRect.GetWidth(); // Papersize -> kein H-Scrolling + else + { + DBG_ASSERT(pView,"keine View fuer EditView"); + nSizeXPix = pView->GetGridWidth(eHWhich) - aPixRect.Left(); + } + DBG_ASSERT(pView,"keine View fuer EditView"); + long nSizeYPix = pView->GetGridHeight(WhichV(eWhich)) - aPixRect.Top(); + + pNewEngine->SetPaperSize( pView->GetActiveWin()->PixelToLogic( Size( nSizeXPix, nSizeYPix ), + GetLogicMode() ) ); + + // sichtbarer Ausschnitt + Size aPaper = pNewEngine->GetPaperSize(); + Rectangle aVis = pEditView[eWhich]->GetVisArea(); + long nDiff = aVis.Right() - aVis.Left(); + if ( nEditAdjust == SVX_ADJUST_RIGHT ) + { + aVis.Right() = aPaper.Width() - 1; + bMoveArea = TRUE; + } + else if ( nEditAdjust == SVX_ADJUST_CENTER ) + { + aVis.Right() = ( aPaper.Width() - 1 + nDiff ) / 2; + bMoveArea = TRUE; + } + else + { + aVis.Right() = nDiff; + bMoveArea = FALSE; + } + aVis.Left() = aVis.Right() - nDiff; + pEditView[eWhich]->SetVisArea(aVis); + // + + pNewEngine->SetStatusEventHdl( LINK( this, ScViewData, EditEngineHdl ) ); + + EditGrowY(); // an alten Text anpassen + EditGrowX(); + + Point aDocPos = pEditView[eWhich]->GetWindowPosTopLeft(0); + if (aDocPos.Y() < aOutputArea.Top()) + pEditView[eWhich]->Scroll( 0, aOutputArea.Top() - aDocPos.Y() ); + + //! Status (Event) zuruecksetzen + } + + // hier muss bEditActive schon gesetzt sein + // (wegen Map-Mode bei Paint) + if (!bWasThere) + pNewEngine->InsertView(pEditView[eWhich]); + + // Hintergrundfarbe der Zelle + Color aBackCol = ((const SvxBrushItem&)pPattern->GetItem(ATTR_BACKGROUND)).GetColor(); + if ( aBackCol.GetTransparency() > 0 || IsSyntaxMode()) + { + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + aBackCol = rStyleSettings.GetWindowColor(); + } + pEditView[eWhich]->SetBackgroundColor( aBackCol ); + + pEditView[eWhich]->Invalidate(); // noetig ?? + // noetig, wenn Position geaendert +} + +IMPL_LINK_INLINE_START( ScViewData, EmptyEditHdl, EditStatus *, pStatus ) +{ + return 0; +} +IMPL_LINK_INLINE_END( ScViewData, EmptyEditHdl, EditStatus *, pStatus ) + +IMPL_LINK( ScViewData, EditEngineHdl, EditStatus *, pStatus ) +{ + ULONG nStatus = pStatus->GetStatusWord(); + if (nStatus & (EE_STAT_HSCROLL | EE_STAT_TEXTHEIGHTCHANGED | EE_STAT_CURSOROUT)) + { + EditGrowY(); + EditGrowX(); + + if (nStatus & EE_STAT_CURSOROUT) + { + ScSplitPos eWhich = GetActivePart(); + if (pEditView[eWhich]) + pEditView[eWhich]->ShowCursor(FALSE); + } + } + return 0; +} + +void ScViewData::EditGrowX() +{ + ScDocument* pDoc = GetDocument(); + + ScSplitPos eWhich = GetActivePart(); + ScHSplitPos eHWhich = WhichH(eWhich); + EditView* pCurView = pEditView[eWhich]; + + if ( !pCurView || !bEditActive[eWhich]) + return; + + ScEditEngineDefaulter* pEngine = + (ScEditEngineDefaulter*) pCurView->GetEditEngine(); + Window* pWin = pCurView->GetWindow(); + + USHORT nRight = GetPosX(eHWhich) + VisibleCellsX(eHWhich); + + Size aSize = pEngine->GetPaperSize(); + Rectangle aArea = pCurView->GetOutputArea(); + long nOldRight = aArea.Right(); + + // Margin ist schon bei der urspruenglichen Breite beruecksichtigt + long nTextWidth = pEngine->CalcTextWidth(); + + BOOL bChanged = FALSE; + while (aArea.GetWidth() + 0 < nTextWidth && nEditEndCol < nRight) + { + ++nEditEndCol; + long nPix = (long) ( pDoc->GetColWidth( nEditEndCol, nTabNo ) * nPPTX ); + aArea.Right() += pWin->PixelToLogic(Size(nPix,0)).Width(); + + if ( aArea.Right() > aArea.Left() + aSize.Width() - 1 ) + aArea.Right() = aArea.Left() + aSize.Width() - 1; + + bChanged = TRUE; + } + + if (bChanged) + { + if ( bMoveArea ) + { + // hart auf linksbuendig schalten und VisArea wieder nach links setzen + + pEngine->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) ); + + Rectangle aVis = pCurView->GetVisArea(); + long nMove = aVis.Left(); + aVis.Left() = 0; + aVis.Right() -= nMove; + pCurView->SetVisArea( aVis ); + bMoveArea = FALSE; + } + + pCurView->SetOutputArea(aArea); + + aArea.Left() = nOldRight; + pWin->Invalidate(aArea); + } +} + +void ScViewData::EditGrowY() +{ + ScSplitPos eWhich = GetActivePart(); + ScVSplitPos eVWhich = WhichV(eWhich); + EditView* pCurView = pEditView[eWhich]; + + if ( !pCurView || !bEditActive[eWhich]) + return; + + EditEngine* pEngine = pCurView->GetEditEngine(); + Window* pWin = pCurView->GetWindow(); + + USHORT nBottom = GetPosY(eVWhich) + VisibleCellsY(eVWhich); + + Size aSize = pEngine->GetPaperSize(); + Rectangle aArea = pCurView->GetOutputArea(); + long nOldBottom = aArea.Bottom(); + long nTextHeight = pEngine->GetTextHeight(); + + BOOL bChanged = FALSE; + while (aArea.GetHeight() + 100 < nTextHeight && nEditEndRow < nBottom) + { + ++nEditEndRow; + ScDocument* pDoc = GetDocument(); + long nPix = (long) ( pDoc->GetRowHeight( nEditEndRow, nTabNo ) * nPPTY ); + aArea.Bottom() += pWin->PixelToLogic(Size(0,nPix)).Height(); + + if ( aArea.Bottom() > aArea.Top() + aSize.Height() - 1 ) + aArea.Bottom() = aArea.Top() + aSize.Height() - 1; + + bChanged = TRUE; + } + + if (bChanged) + { + pCurView->SetOutputArea(aArea); + + if (nEditEndRow >= nBottom) + { + ULONG nControl = pEditView[eWhich]->GetControlWord(); + if ((nControl & EV_CNTRL_AUTOSCROLL) == 0) + pCurView->SetControlWord( nControl | EV_CNTRL_AUTOSCROLL ); + } + + aArea.Top() = nOldBottom; + pWin->Invalidate(aArea); + } +} + +void ScViewData::ResetEditView() +{ + EditEngine* pEngine = NULL; + for (USHORT i=0; i<4; i++) + if (pEditView[i]) + { + if (bEditActive[i]) + { + pEngine = pEditView[i]->GetEditEngine(); + pEngine->RemoveView(pEditView[i]); +// pEditView[i]->SetSelection(0,0,0,0); + } + bEditActive[i] = FALSE; + } + + if (pEngine) + pEngine->SetStatusEventHdl( LINK( this, ScViewData, EmptyEditHdl ) ); +} + +void ScViewData::KillEditView() +{ + for (USHORT i=0; i<4; i++) + if (pEditView[i]) + { + if (bEditActive[i]) + pEditView[i]->GetEditEngine()->RemoveView(pEditView[i]); + delete pEditView[i]; + pEditView[i] = NULL; + } +} + +void ScViewData::GetEditView( ScSplitPos eWhich, EditView*& rViewPtr, USHORT& rCol, USHORT& rRow ) +{ + rViewPtr = pEditView[eWhich]; + rCol = nEditCol; + rRow = nEditRow; +} + +void ScViewData::SetTabNo( USHORT nNewTab ) +{ + if (nNewTab>MAXTAB) + { + DBG_ERROR("falsche Tabellennummer"); + return; + } + + nTabNo = nNewTab; + if (!pTabData[nTabNo]) + pTabData[nTabNo] = new ScViewDataTable; + pThisTab = pTabData[nTabNo]; + + RecalcPixPos(); //! nicht immer noetig! +} + +void ScViewData::SetActivePart( ScSplitPos eNewActive ) +{ + pThisTab->eWhichActive = eNewActive; +} + +Point ScViewData::GetScrPos( USHORT nWhereX, USHORT nWhereY, ScHSplitPos eWhich ) const +{ + DBG_ASSERT( eWhich==SC_SPLIT_LEFT || eWhich==SC_SPLIT_RIGHT, "Falsche Position" ); + ScSplitPos ePos = ( eWhich == SC_SPLIT_LEFT ) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT; + return GetScrPos( nWhereX, nWhereY, ePos ); +} + +Point ScViewData::GetScrPos( USHORT nWhereX, USHORT nWhereY, ScVSplitPos eWhich ) const +{ + DBG_ASSERT( eWhich==SC_SPLIT_TOP || eWhich==SC_SPLIT_BOTTOM, "Falsche Position" ); + ScSplitPos ePos = ( eWhich == SC_SPLIT_TOP ) ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT; + return GetScrPos( nWhereX, nWhereY, ePos ); +} + +Point ScViewData::GetScrPos( USHORT nWhereX, USHORT nWhereY, ScSplitPos eWhich, + BOOL bAllowNeg ) const +{ + ScHSplitPos eWhichX; + ScVSplitPos eWhichY; + switch( eWhich ) + { + case SC_SPLIT_TOPLEFT: + eWhichX = SC_SPLIT_LEFT; + eWhichY = SC_SPLIT_TOP; + break; + case SC_SPLIT_TOPRIGHT: + eWhichX = SC_SPLIT_RIGHT; + eWhichY = SC_SPLIT_TOP; + break; + case SC_SPLIT_BOTTOMLEFT: + eWhichX = SC_SPLIT_LEFT; + eWhichY = SC_SPLIT_BOTTOM; + break; + case SC_SPLIT_BOTTOMRIGHT: + eWhichX = SC_SPLIT_RIGHT; + eWhichY = SC_SPLIT_BOTTOM; + break; + } + + if (pView) + { + ((ScViewData*)this)->aScrSize.Width() = pView->GetGridWidth(eWhichX); + ((ScViewData*)this)->aScrSize.Height() = pView->GetGridHeight(eWhichY); + } + + USHORT nTSize; + + USHORT nPosX = GetPosX(eWhichX); + USHORT nX; + + long nScrPosX=0; + if (nWhereX >= nPosX) + for (nX=nPosX; nX<nWhereX && (bAllowNeg || nScrPosX<=aScrSize.Width()); nX++) + { + if ( nX > MAXCOL ) + nScrPosX = 65535; + else + { + nTSize = pDoc->GetColWidth( nX, nTabNo ); + if (nTSize) + { + long nSizeXPix = (long) ( nTSize * nPPTX ); + nScrPosX += nSizeXPix; + } + } + } + else if (bAllowNeg) + for (nX=nPosX; nX>nWhereX;) + { + --nX; + nTSize = pDoc->GetColWidth( nX, nTabNo ); + if (nTSize) + { + long nSizeXPix = (long) ( nTSize * nPPTX ); + nScrPosX -= nSizeXPix; + } + } + + USHORT nPosY = GetPosY(eWhichY); + USHORT nY; + + long nScrPosY=0; + if (nWhereY >= nPosY) + for (nY=nPosY; nY<nWhereY && (bAllowNeg || nScrPosY<=aScrSize.Height()); nY++) + { + if ( nY > MAXROW ) + nScrPosY = 65535; + else + { + nTSize = pDoc->FastGetRowHeight( nY, nTabNo ); + if (nTSize) + { + long nSizeYPix = (long) ( nTSize * nPPTY ); + nScrPosY += nSizeYPix; + } + } + } + else if (bAllowNeg) + for (nY=nPosY; nY>nWhereY;) + { + --nY; + nTSize = pDoc->FastGetRowHeight( nY, nTabNo ); + if (nTSize) + { + long nSizeYPix = (long) ( nTSize * nPPTY ); + nScrPosY -= nSizeYPix; + } + } + + if (nScrPosX > 32767) nScrPosX=32767; + if (nScrPosY > 32767) nScrPosY=32767; + return Point( nScrPosX, nScrPosY ); +} + +// +// Anzahl Zellen auf einem Bildschirm +// + +USHORT ScViewData::CellsAtX( short nPosX, short nDir, ScHSplitPos eWhichX, USHORT nScrSizeX ) const +{ + DBG_ASSERT( nDir==1 || nDir==-1, "falscher CellsAt Aufruf" ); + + if (pView) + ((ScViewData*)this)->aScrSize.Width() = pView->GetGridWidth(eWhichX); + + short nX; + USHORT nScrPosX = 0; + if (nScrSizeX == SC_SIZE_NONE) nScrSizeX = (USHORT) aScrSize.Width(); + + if (nDir==1) + nX = nPosX; // vorwaerts + else + nX = nPosX-1; // rueckwaerts + + BOOL bOut = FALSE; + for ( ; nScrPosX<=nScrSizeX && !bOut; nX+=nDir ) + { + short nColNo = nX; + if ( nColNo < 0 || nColNo > MAXCOL ) + bOut = TRUE; + else + { + USHORT nTSize = pDoc->GetColWidth( nColNo, nTabNo ); + if (nTSize) + { + long nSizeXPix = (long) ( nTSize * nPPTX ); + nScrPosX += (USHORT) nSizeXPix; + } + } + } + + if (nDir==1) + nX -= nPosX; + else + nX = (nPosX-1)-nX; + + if (nX>0) --nX; + return nX; +} + +USHORT ScViewData::CellsAtY( short nPosY, short nDir, ScVSplitPos eWhichY, USHORT nScrSizeY ) const +{ + DBG_ASSERT( nDir==1 || nDir==-1, "falscher CellsAt Aufruf" ); + + if (pView) + ((ScViewData*)this)->aScrSize.Height() = pView->GetGridHeight(eWhichY); + + short nY; + USHORT nScrPosY = 0; + + if (nScrSizeY == SC_SIZE_NONE) nScrSizeY = (USHORT) aScrSize.Height(); + + if (nDir==1) + nY = nPosY; // vorwaerts + else + nY = nPosY-1; // rueckwaerts + + BOOL bOut = FALSE; + for ( ; nScrPosY<=nScrSizeY && !bOut; nY+=nDir ) + { + short nRowNo = nY; + if ( nRowNo < 0 || nRowNo > MAXROW ) + bOut = TRUE; + else + { +// USHORT nTSize = pDoc->GetRowHeight( nRowNo, nTabNo ); + USHORT nTSize = pDoc->FastGetRowHeight( nRowNo, nTabNo ); + if (nTSize) + { + long nSizeYPix = (long) ( nTSize * nPPTY ); + nScrPosY += (USHORT) nSizeYPix; + } + } + } + + if (nDir==1) + nY -= nPosY; + else + nY = (nPosY-1)-nY; + + if (nY>0) --nY; + return nY; +} + +USHORT ScViewData::VisibleCellsX( ScHSplitPos eWhichX ) const +{ + return CellsAtX( GetPosX( eWhichX ), 1, eWhichX, SC_SIZE_NONE ); +} + +USHORT ScViewData::VisibleCellsY( ScVSplitPos eWhichY ) const +{ + return CellsAtY( GetPosY( eWhichY ), 1, eWhichY, SC_SIZE_NONE ); +} + +USHORT ScViewData::PrevCellsX( ScHSplitPos eWhichX ) const +{ + return CellsAtX( GetPosX( eWhichX ), -1, eWhichX, SC_SIZE_NONE ); +} + +USHORT ScViewData::PrevCellsY( ScVSplitPos eWhichY ) const +{ + return CellsAtY( GetPosY( eWhichY ), -1, eWhichY, SC_SIZE_NONE ); +} + +USHORT ScViewData::LastCellsX( ScHSplitPos eWhichX ) const +{ + return CellsAtX( MAXCOL+1, -1, eWhichX, SC_SIZE_NONE ); +} + +USHORT ScViewData::LastCellsY( ScVSplitPos eWhichY ) const +{ + return CellsAtY( MAXROW+1, -1, eWhichY, SC_SIZE_NONE ); +} + +BOOL ScViewData::GetMergeSizePixel( USHORT nX, USHORT nY, long& rSizeXPix, long& rSizeYPix ) +{ + const ScMergeAttr* pMerge = (const ScMergeAttr*) pDoc->GetAttr( nX,nY,nTabNo, ATTR_MERGE ); + if ( pMerge->GetColMerge() > 1 || pMerge->GetRowMerge() > 1 ) + { + long nOutWidth = 0; + long nOutHeight = 0; + USHORT i; + USHORT nCountX = pMerge->GetColMerge(); + for (i=0; i<nCountX; i++) + nOutWidth += (long) ( pDoc->GetColWidth(nX+i,nTabNo) * nPPTX ); + USHORT nCountY = pMerge->GetRowMerge(); + for (i=0; i<nCountY; i++) + nOutHeight += (long) ( pDoc->GetRowHeight(nY+i,nTabNo) * nPPTY ); + + rSizeXPix = nOutWidth; + rSizeYPix = nOutHeight; + return TRUE; + } + else + { + rSizeXPix = (long) ( pDoc->GetColWidth( nX, nTabNo ) * nPPTX ); + rSizeYPix = (long) ( pDoc->GetRowHeight( nY, nTabNo ) * nPPTY ); + return FALSE; + } +} + +BOOL ScViewData::GetPosFromPixel( long nClickX, long nClickY, ScSplitPos eWhich, + short& rPosX, short& rPosY, + BOOL bTestMerge, BOOL bRepair, BOOL bNextIfLarge ) +{ + // Hack, damit auch bei "ganzer Bildschirm" ohne Spalten/Zeilenkoepfe + // noch nach links/oben gescrollt werden kann: + if (nClickX == 0) + nClickX = -1; + if (nClickY == 0) + nClickY = -1; + + ScHSplitPos eHWhich = WhichH(eWhich); + ScVSplitPos eVWhich = WhichV(eWhich); + short nStartPosX = GetPosX(eHWhich); + short nStartPosY = GetPosY(eVWhich); + rPosX = nStartPosX; + rPosY = nStartPosY; + long nScrX = 0; + long nScrY = 0; + + if (nClickX > 0) + { + while ( rPosX<=MAXCOL && nClickX >= nScrX ) + { + nScrX += (long) ( pDoc->GetColWidth( rPosX, nTabNo ) * nPPTX ); + ++rPosX; + } + --rPosX; + } + else + { + while ( rPosX>0 && nClickX < nScrX ) + { + --rPosX; + nScrX -= (long) ( pDoc->GetColWidth( rPosX, nTabNo ) * nPPTX ); + } + } + + if (nClickY > 0) + { + while ( rPosY<=MAXROW && nClickY >= nScrY ) + { + nScrY += (long) ( pDoc->FastGetRowHeight( rPosY, nTabNo ) * nPPTY ); + ++rPosY; + } + --rPosY; + } + else + { + while ( rPosY>0 && nClickY < nScrY ) + { + --rPosY; + nScrY -= (long) ( pDoc->FastGetRowHeight( rPosY, nTabNo ) * nPPTY ); + } + } + + if (bNextIfLarge) // zu grosse Zellen ? + { + if ( rPosX == nStartPosX && nClickX > 0 ) + { + if (pView) + aScrSize.Width() = pView->GetGridWidth(eHWhich); + if ( nClickX > aScrSize.Width() ) + ++rPosX; + } + if ( rPosY == nStartPosY && nClickY > 0 ) + { + if (pView) + aScrSize.Height() = pView->GetGridHeight(eVWhich); + if ( nClickY > aScrSize.Height() ) + ++rPosY; + } + } + + if (rPosX<0) rPosX=0; + if (rPosX>MAXCOL) rPosX=MAXCOL; + if (rPosY<0) rPosY=0; + if (rPosY>MAXROW) rPosY=MAXROW; + + if (bTestMerge) + { + //! public Methode um Position anzupassen + + BOOL bHOver = FALSE; + while (pDoc->IsHorOverlapped( rPosX, rPosY, nTabNo )) + { --rPosX; bHOver=TRUE; } + BOOL bVOver = FALSE; + while (pDoc->IsVerOverlapped( rPosX, rPosY, nTabNo )) + { --rPosY; bVOver=TRUE; } + + if ( bRepair && ( bHOver || bVOver ) ) + { + const ScMergeAttr* pMerge = (const ScMergeAttr*) + pDoc->GetAttr( rPosX, rPosY, nTabNo, ATTR_MERGE ); + if ( ( bHOver && pMerge->GetColMerge() <= 1 ) || + ( bVOver && pMerge->GetRowMerge() <= 1 ) ) + { + DBG_ERROR("Merge-Fehler gefunden"); + + pDoc->RemoveFlagsTab( 0,0, MAXCOL,MAXROW, nTabNo, SC_MF_HOR | SC_MF_VER ); + USHORT nEndCol = MAXCOL; + USHORT nEndRow = MAXROW; + pDoc->ExtendMerge( 0,0, nEndCol,nEndRow, nTabNo, TRUE, FALSE ); + if (pDocShell) + pDocShell->PostPaint( ScRange(0,0,nTabNo,MAXCOL,MAXROW,nTabNo), PAINT_GRID ); + } + } + } + + return FALSE; +} + +void ScViewData::GetMouseQuadrant( const Point& rClickPos, ScSplitPos eWhich, + short nPosX, short nPosY, BOOL& rLeft, BOOL& rTop ) +{ + Point aCellStart = GetScrPos( nPosX, nPosY, eWhich, TRUE ); + long nSizeX; + long nSizeY; + GetMergeSizePixel( nPosX, nPosY, nSizeX, nSizeY ); + rLeft = rClickPos.X() - aCellStart.X() <= nSizeX / 2; + rTop = rClickPos.Y() - aCellStart.Y() <= nSizeY / 2; +} + +void ScViewData::SetPosX( ScHSplitPos eWhich, USHORT nNewPosX ) +{ + if (nNewPosX) + { + USHORT nOldPosX = pThisTab->nPosX[eWhich]; + long nTPosX = pThisTab->nTPosX[eWhich]; + long nPixPosX = pThisTab->nPixPosX[eWhich]; + USHORT i; + if ( nNewPosX > nOldPosX ) + for ( i=nOldPosX; i<nNewPosX; i++ ) + { + long nThis = pDoc->GetColWidth( i,nTabNo ); + nTPosX -= nThis; + nPixPosX -= (long)(nThis*nPPTX); + } + else + for ( i=nNewPosX; i<nOldPosX; i++ ) + { + long nThis = pDoc->GetColWidth( i,nTabNo ); + nTPosX += nThis; + nPixPosX += (long)(nThis*nPPTX); + } + + pThisTab->nPosX[eWhich] = nNewPosX; + pThisTab->nTPosX[eWhich] = nTPosX; + pThisTab->nMPosX[eWhich] = (long) (nTPosX * HMM_PER_TWIPS); + pThisTab->nPixPosX[eWhich] = nPixPosX; + } + else + pThisTab->nPixPosX[eWhich] = + pThisTab->nTPosX[eWhich] = + pThisTab->nMPosX[eWhich] = + pThisTab->nPosX[eWhich] = 0; +} + +void ScViewData::SetPosY( ScVSplitPos eWhich, USHORT nNewPosY ) +{ + if (nNewPosY) + { + USHORT nOldPosY = pThisTab->nPosY[eWhich]; + long nTPosY = pThisTab->nTPosY[eWhich]; + long nPixPosY = pThisTab->nPixPosY[eWhich]; + USHORT i; + if ( nNewPosY > nOldPosY ) + for ( i=nOldPosY; i<nNewPosY; i++ ) + { + long nThis = pDoc->FastGetRowHeight( i,nTabNo ); + nTPosY -= nThis; + nPixPosY -= (long)(nThis*nPPTY); + } + else + for ( i=nNewPosY; i<nOldPosY; i++ ) + { + long nThis = pDoc->FastGetRowHeight( i,nTabNo ); + nTPosY += nThis; + nPixPosY += (long)(nThis*nPPTY); + } + + pThisTab->nPosY[eWhich] = nNewPosY; + pThisTab->nTPosY[eWhich] = nTPosY; + pThisTab->nMPosY[eWhich] = (long) (nTPosY * HMM_PER_TWIPS); + pThisTab->nPixPosY[eWhich] = nPixPosY; + } + else + pThisTab->nPixPosY[eWhich] = + pThisTab->nTPosY[eWhich] = + pThisTab->nMPosY[eWhich] = + pThisTab->nPosY[eWhich] = 0; +} + +void ScViewData::RecalcPixPos() // nach Zoom-Aenderungen +{ + USHORT i; + + for (USHORT eWhich=0; eWhich<2; eWhich++) + { + long nPixPosX = 0; + USHORT nPosX = pThisTab->nPosX[eWhich]; + for (i=0; i<nPosX; i++) + nPixPosX -= (long)(pDoc->GetColWidth(i,nTabNo) * nPPTX); + pThisTab->nPixPosX[eWhich] = nPixPosX; + + long nPixPosY = 0; + USHORT nPosY = pThisTab->nPosY[eWhich]; + for (i=0; i<nPosY; i++) + nPixPosY -= (long)(pDoc->FastGetRowHeight(i,nTabNo) * nPPTY); + pThisTab->nPixPosY[eWhich] = nPixPosY; + } +} + +const MapMode& ScViewData::GetLogicMode( ScSplitPos eWhich ) +{ + aLogicMode.SetOrigin( Point( pThisTab->nMPosX[WhichH(eWhich)], + pThisTab->nMPosY[WhichV(eWhich)] ) ); + return aLogicMode; +} + +const MapMode& ScViewData::GetLogicMode() +{ + aLogicMode.SetOrigin( Point() ); + return aLogicMode; +} + +void ScViewData::SetScreen( USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2 ) +{ + USHORT nCol; + USHORT nRow; + USHORT nTSize; + long nSizePix; + long nScrPosX = 0; + long nScrPosY = 0; + + SetActivePart( SC_SPLIT_BOTTOMLEFT ); + SetPosX( SC_SPLIT_LEFT, nCol1 ); + SetPosY( SC_SPLIT_BOTTOM, nRow1 ); + + for (nCol=nCol1; nCol<=nCol2; nCol++) + { + nTSize = pDoc->GetColWidth( nCol, nTabNo ); + if (nTSize) + { + nSizePix = (long) ( nTSize * nPPTX ); + nScrPosX += (USHORT) nSizePix; + } + } + + for (nRow=nRow1; nRow<=nRow2; nRow++) + { + nTSize = pDoc->FastGetRowHeight( nRow, nTabNo ); + if (nTSize) + { + nSizePix = (long) ( nTSize * nPPTY ); + nScrPosY += (USHORT) nSizePix; + } + } + + aScrSize = Size( nScrPosX, nScrPosY ); +} + +void ScViewData::SetScreenPos( const Point& rVisAreaStart ) +{ + long nSize; + long nTwips; + long nAdd; + BOOL bEnd; + + nSize = 0; + nTwips = (long) (rVisAreaStart.X() / HMM_PER_TWIPS); + USHORT nX1 = 0; + bEnd = FALSE; + while (!bEnd) + { + nAdd = (long) pDoc->GetColWidth(nX1,nTabNo); + if (nSize+nAdd <= nTwips+1 && nX1<MAXCOL) + { + nSize += nAdd; + ++nX1; + } + else + bEnd = TRUE; + } + + nSize = 0; + nTwips = (long) (rVisAreaStart.Y() / HMM_PER_TWIPS); + USHORT nY1 = 0; + bEnd = FALSE; + while (!bEnd) + { + nAdd = (long) pDoc->FastGetRowHeight(nY1,nTabNo); + if (nSize+nAdd <= nTwips+1 && nY1<MAXROW) + { + nSize += nAdd; + ++nY1; + } + else + bEnd = TRUE; + } + + SetActivePart( SC_SPLIT_BOTTOMLEFT ); + SetPosX( SC_SPLIT_LEFT, nX1 ); + SetPosY( SC_SPLIT_BOTTOM, nY1 ); + + SetCurX( nX1 ); + SetCurY( nY1 ); +} + +void ScViewData::SetScreen( const Rectangle& rVisArea ) +{ + SetScreenPos( rVisArea.TopLeft() ); + + // hier ohne GetOutputFactor(), weil fuer Ausgabe in Metafile + + aScrSize = rVisArea.GetSize(); + aScrSize.Width() = (long) + ( aScrSize.Width() * ScGlobal::nScreenPPTX / HMM_PER_TWIPS ); + aScrSize.Height() = (long) + ( aScrSize.Height() * ScGlobal::nScreenPPTY / HMM_PER_TWIPS ); +} + +SfxObjectShell* ScViewData::GetSfxDocShell() const +{ + return pDocShell; +} + +Window* ScViewData::GetDialogParent() +{ + DBG_ASSERT( pViewShell, "GetDialogParent() ohne ViewShell" ); + return pViewShell->GetDialogParent(); +} + +Window* ScViewData::GetActiveWin() +{ + DBG_ASSERT( pView, "GetActiveWin() ohne View" ); + return pView->GetActiveWin(); +} + +ScDrawView* ScViewData::GetScDrawView() +{ + DBG_ASSERT( pView, "GetScDrawView() ohne View" ); + return pView->GetScDrawView(); +} + +BOOL ScViewData::IsMinimized() +{ + DBG_ASSERT( pView, "IsMinimized() ohne View" ); + return pView->IsMinimized(); +} + +void ScViewData::UpdateScreenZoom( const Fraction& rNewX, const Fraction& rNewY ) +{ + Fraction aOldX = GetZoomX(); + Fraction aOldY = GetZoomY(); + + SetZoom(rNewX,rNewY); + + Fraction aWidth = GetZoomX(); + aWidth *= Fraction( aScrSize.Width(),1 ); + aWidth /= aOldX; + + Fraction aHeight = GetZoomY(); + aHeight *= Fraction( aScrSize.Height(),1 ); + aHeight /= aOldY; + + aScrSize.Width() = (long) aWidth; + aScrSize.Height() = (long) aHeight; +} + +void ScViewData::CalcPPT() +{ + nPPTX = ScGlobal::nScreenPPTX * (double) GetZoomX(); + if (pDocShell) + nPPTX = nPPTX / pDocShell->GetOutputFactor(); // Faktor ist Drucker zu Bildschirm + nPPTY = ScGlobal::nScreenPPTY * (double) GetZoomY(); +} + +//------------------------------------------------------------------ + +#define SC_OLD_TABSEP '/' +#define SC_NEW_TABSEP '+' + +void ScViewData::WriteUserData(String& rData) +{ + // nZoom (bis 364v) oder nZoom/nPageZoom/bPageMode (ab 364w) + // nTab + // Tab-ControlBreite + // pro Tabelle: + // CursorX/CursorY/HSplitMode/VSplitMode/HSplitPos/VSplitPos/SplitActive/ + // PosX[links]/PosX[rechts]/PosY[oben]/PosY[unten] + // wenn Zeilen groesser 8192, "+" statt "/" + + USHORT nZoom = (USHORT)((aZoomY.GetNumerator() * 100) / aZoomY.GetDenominator()); + rData = String::CreateFromInt32( nZoom ); + rData += '/'; + nZoom = (USHORT)((aPageZoomY.GetNumerator() * 100) / aPageZoomY.GetDenominator()); + rData += String::CreateFromInt32( nZoom ); + rData += '/'; + if (bPagebreak) + rData += '1'; + else + rData += '0'; + + rData += ';'; + rData += String::CreateFromInt32( nTabNo ); + rData += ';'; + rData.AppendAscii(RTL_CONSTASCII_STRINGPARAM( TAG_TABBARWIDTH )); + rData += String::CreateFromInt32( pView->GetTabBarWidth() ); + + USHORT nTabCount = pDoc->GetTableCount(); + for (USHORT i=0; i<nTabCount; i++) + { + rData += ';'; // Numerierung darf auf keinen Fall durcheinanderkommen + if (pTabData[i]) + { + sal_Unicode cTabSep = SC_OLD_TABSEP; // wie 3.1 + if ( pTabData[i]->nCurY > MAXROW_30 || + pTabData[i]->nPosY[0] > MAXROW_30 || pTabData[i]->nPosY[1] > MAXROW_30 || + ( pTabData[i]->eVSplitMode == SC_SPLIT_FIX && + pTabData[i]->nFixPosY > MAXROW_30 ) ) + { + cTabSep = SC_NEW_TABSEP; // um eine 3.1-Version nicht umzubringen + } + + + rData += String::CreateFromInt32( pTabData[i]->nCurX ); + rData += cTabSep; + rData += String::CreateFromInt32( pTabData[i]->nCurY ); + rData += cTabSep; + rData += String::CreateFromInt32( pTabData[i]->eHSplitMode ); + rData += cTabSep; + rData += String::CreateFromInt32( pTabData[i]->eVSplitMode ); + rData += cTabSep; + if ( pTabData[i]->eHSplitMode == SC_SPLIT_FIX ) + rData += String::CreateFromInt32( pTabData[i]->nFixPosX ); + else + rData += String::CreateFromInt32( pTabData[i]->nHSplitPos ); + rData += cTabSep; + if ( pTabData[i]->eVSplitMode == SC_SPLIT_FIX ) + rData += String::CreateFromInt32( pTabData[i]->nFixPosY ); + else + rData += String::CreateFromInt32( pTabData[i]->nVSplitPos ); + rData += cTabSep; + rData += String::CreateFromInt32( pTabData[i]->eWhichActive ); + rData += cTabSep; + rData += String::CreateFromInt32( pTabData[i]->nPosX[0] ); + rData += cTabSep; + rData += String::CreateFromInt32( pTabData[i]->nPosX[1] ); + rData += cTabSep; + rData += String::CreateFromInt32( pTabData[i]->nPosY[0] ); + rData += cTabSep; + rData += String::CreateFromInt32( pTabData[i]->nPosY[1] ); + } + } +} + +void ScViewData::ReadUserData(const String& rData) +{ + if (!rData.Len()) // Leerer String kommt bei "neu Laden" + return; // dann auch ohne Assertion beenden + + xub_StrLen nCount = rData.GetTokenCount(';'); + if ( nCount <= 2 ) + { + // #45208# beim Reload in der Seitenansicht sind evtl. die Preview-UserData + // stehengelassen worden. Den Zoom von der Preview will man hier nicht... + DBG_ERROR("ReadUserData: das sind nicht meine Daten"); + return; + } + + String aTabOpt; + xub_StrLen nTagLen = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(TAG_TABBARWIDTH)).Len(); + + //------------------- + // nicht pro Tabelle: + //------------------- + USHORT nTabStart = 2; + + String aZoomStr = rData.GetToken(0); // Zoom/PageZoom/Modus + USHORT nNormZoom = aZoomStr.GetToken(0,'/').ToInt32(); + if ( nNormZoom >= MINZOOM && nNormZoom <= MAXZOOM ) + aZoomX = aZoomY = Fraction( nNormZoom, 100 ); // "normaler" Zoom (immer) + USHORT nPageZoom = aZoomStr.GetToken(1,'/').ToInt32(); + if ( nPageZoom >= MINZOOM && nPageZoom <= MAXZOOM ) + aPageZoomX = aPageZoomY = Fraction( nPageZoom, 100 ); // Pagebreak-Zoom, wenn gesetzt + sal_Unicode cMode = aZoomStr.GetToken(2,'/').GetChar(0); // 0 oder "0"/"1" + SetPagebreakMode( cMode == '1' ); + // SetPagebreakMode muss immer gerufen werden wegen CalcPPT / RecalcPixPos() + + // + // Tabelle kann ungueltig geworden sein (z.B. letzte Version): + // + USHORT nNewTab = rData.GetToken(1).ToInt32(); + if (pDoc->HasTable( nNewTab )) + SetTabNo(nNewTab); + + // + // wenn vorhanden, TabBar-Breite holen: + // + aTabOpt = rData.GetToken(2); + + if ( nTagLen && aTabOpt.Copy(0,nTagLen).EqualsAscii(TAG_TABBARWIDTH) ) + { + pView->SetTabBarWidth( aTabOpt.Copy(nTagLen).ToInt32() ); + nTabStart = 3; + } + + //------------- + // pro Tabelle: + //------------- + USHORT nPos = 0; + while ( nCount > nPos+nTabStart ) + { + aTabOpt = rData.GetToken(nPos+nTabStart); + if (!pTabData[nPos]) + pTabData[nPos] = new ScViewDataTable; + + sal_Unicode cTabSep = 0; + if (aTabOpt.GetTokenCount(SC_OLD_TABSEP) >= 11) + cTabSep = SC_OLD_TABSEP; +#ifndef SC_LIMIT_ROWS + else if (aTabOpt.GetTokenCount(SC_NEW_TABSEP) >= 11) + cTabSep = SC_NEW_TABSEP; + // '+' ist nur erlaubt, wenn wir mit Zeilen > 8192 umgehen koennen +#endif + + if (cTabSep) + { + pTabData[nPos]->nCurX = aTabOpt.GetToken(0,cTabSep).ToInt32(); + pTabData[nPos]->nCurY = aTabOpt.GetToken(1,cTabSep).ToInt32(); + pTabData[nPos]->eHSplitMode = (ScSplitMode) aTabOpt.GetToken(2,cTabSep).ToInt32(); + pTabData[nPos]->eVSplitMode = (ScSplitMode) aTabOpt.GetToken(3,cTabSep).ToInt32(); + + if ( pTabData[nPos]->eHSplitMode == SC_SPLIT_FIX ) + { + pTabData[nPos]->nFixPosX = aTabOpt.GetToken(4,cTabSep).ToInt32(); + UpdateFixX(nPos); + } + else + pTabData[nPos]->nHSplitPos = aTabOpt.GetToken(4,cTabSep).ToInt32(); + + if ( pTabData[nPos]->eVSplitMode == SC_SPLIT_FIX ) + { + pTabData[nPos]->nFixPosY = aTabOpt.GetToken(5,cTabSep).ToInt32(); + UpdateFixY(nPos); + } + else + pTabData[nPos]->nVSplitPos = aTabOpt.GetToken(5,cTabSep).ToInt32(); + + pTabData[nPos]->eWhichActive = (ScSplitPos) aTabOpt.GetToken(6,cTabSep).ToInt32(); + pTabData[nPos]->nPosX[0] = aTabOpt.GetToken(7,cTabSep).ToInt32(); + pTabData[nPos]->nPosX[1] = aTabOpt.GetToken(8,cTabSep).ToInt32(); + pTabData[nPos]->nPosY[0] = aTabOpt.GetToken(9,cTabSep).ToInt32(); + pTabData[nPos]->nPosY[1] = aTabOpt.GetToken(10,cTabSep).ToInt32(); + + // Test, ob der aktive Teil laut SplitMode ueberhaupt existiert + // (Bug #44516#) + ScSplitPos eTest = pTabData[nPos]->eWhichActive; + if ( ( WhichH( eTest ) == SC_SPLIT_RIGHT && + pTabData[nPos]->eHSplitMode == SC_SPLIT_NONE ) || + ( WhichV( eTest ) == SC_SPLIT_TOP && + pTabData[nPos]->eVSplitMode == SC_SPLIT_NONE ) ) + { + // dann wieder auf Default (unten links) + pTabData[nPos]->eWhichActive = SC_SPLIT_BOTTOMLEFT; + DBG_ERROR("SplitPos musste korrigiert werden"); + } + } + ++nPos; + } + + RecalcPixPos(); +} + +void ScViewData::ReadExtOptions( const ScExtDocOptions& rOpt ) +{ + // fuer Excel-Import + + USHORT nTabCount = pDoc->GetTableCount(); + for (USHORT nTab=0; nTab<nTabCount; nTab++) + { + const ScExtTabOptions* pExtTab = rOpt.GetExtTabOptions( nTab ); + if ( pExtTab ) + { + if (!pTabData[nTab]) + pTabData[nTab] = new ScViewDataTable; + ScViewDataTable* pViewTab = pTabData[nTab]; + +#if 0 + // aDim ist nicht der sichtbare, sondern der belegte Bereich + //! GT sollte mal die linke obere Ecke des sichtbaren Bereichs herausruecken + + if ( pExtTab->bValidDim ) // Scroll-Position muss vor Fixierung kommen + { + ScRange aVisRange = pExtTab->aDim; + pViewTab->nPosX[SC_SPLIT_LEFT] = aVisRange.aStart.Col(); + ScVSplitPos eDefV = pExtTab->nSplitY ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM; + pViewTab->nPosY[eDefV] = aVisRange.aStart.Row(); + } +#endif + + if ( pExtTab->nSplitX || pExtTab->nSplitY ) + { + if ( pExtTab->bFrozen ) + { + if ( pExtTab->nSplitX ) + { + pViewTab->eHSplitMode = SC_SPLIT_FIX; + pViewTab->nFixPosX = pExtTab->nSplitX; + pViewTab->nHSplitPos = 0; + UpdateFixX(nTab); + pViewTab->nPosX[SC_SPLIT_RIGHT] = pExtTab->nLeftSplitCol; + } + if ( pExtTab->nSplitY ) + { + pViewTab->eVSplitMode = SC_SPLIT_FIX; + pViewTab->nFixPosY = pExtTab->nSplitY; + pViewTab->nVSplitPos = 0; + UpdateFixY(nTab); + pViewTab->nPosY[SC_SPLIT_BOTTOM] = pExtTab->nTopSplitRow; + } + } + else + { + Point aPixel = Application::GetDefaultDevice()->LogicToPixel( + Point( pExtTab->nSplitX, pExtTab->nSplitY ), + MapMode( MAP_TWIP ) ); //! Zoom? + if ( pDocShell ) + { + double nFactor = pDocShell->GetOutputFactor(); + aPixel.X() = (long)( aPixel.X() * nFactor + 0.5 ); + } + if ( pExtTab->nSplitX ) + { + pViewTab->eHSplitMode = SC_SPLIT_NORMAL; + pViewTab->nHSplitPos = aPixel.X(); + pViewTab->nPosX[SC_SPLIT_RIGHT] = pExtTab->nLeftSplitCol; + } + if ( pExtTab->nSplitY ) + { + pViewTab->eVSplitMode = SC_SPLIT_NORMAL; + pViewTab->nVSplitPos = aPixel.Y(); + pViewTab->nPosY[SC_SPLIT_BOTTOM] = pExtTab->nTopSplitRow; + } + } + + ScSplitPos ePos = SC_SPLIT_BOTTOMLEFT; + switch ( pExtTab->nActPane ) + { + case 0: ePos = SC_SPLIT_BOTTOMRIGHT; break; + case 1: ePos = SC_SPLIT_TOPRIGHT; break; + case 2: ePos = SC_SPLIT_BOTTOMLEFT; break; + case 3: ePos = SC_SPLIT_TOPLEFT; break; + } + if ( pViewTab->eHSplitMode == SC_SPLIT_NONE ) // hor. nicht geteilt? + { + if (ePos == SC_SPLIT_BOTTOMRIGHT) // dann immer links + ePos = SC_SPLIT_BOTTOMLEFT; + else if (ePos == SC_SPLIT_TOPRIGHT) + ePos = SC_SPLIT_TOPLEFT; + } + if ( pViewTab->eVSplitMode == SC_SPLIT_NONE ) // vert. nicht geteilt? + { + if (ePos == SC_SPLIT_TOPLEFT) // dann immer unten + ePos = SC_SPLIT_BOTTOMLEFT; + else if (ePos == SC_SPLIT_TOPRIGHT) + ePos = SC_SPLIT_BOTTOMRIGHT; + } + pViewTab->eWhichActive = ePos; + } + + if ( pExtTab->bValidSel ) + { + ScRange aSelRange = pExtTab->aLastSel; + pViewTab->nCurX = aSelRange.aStart.Col(); + pViewTab->nCurY = aSelRange.aStart.Row(); + } + } + } + + SetTabNo( rOpt.nActTab ); + + // RecalcPixPos oder so - auch nMPos - auch bei ReadUserData ??!?! +} + +void ScViewData::SetOptions( const ScViewOptions& rOpt ) +{ + // if visibility of horiz. ScrollBar is changed, TabBar may have to be resized... + BOOL bHScrollChanged = ( rOpt.GetOption(VOPT_HSCROLL) != pOptions->GetOption(VOPT_HSCROLL) ); + + // if graphics are turned on or off, animation has to be started or stopped + // graphics are controlled by VOBJ_TYPE_OLE + BOOL bGraphicsChanged = ( pOptions->GetObjMode(VOBJ_TYPE_OLE) != + rOpt.GetObjMode(VOBJ_TYPE_OLE) ); + + *pOptions = rOpt; + DBG_ASSERT( pView, "No View" ); + + if( pView ) + { + pView->ViewOptionsHasChanged( bHScrollChanged, bGraphicsChanged ); + } +} + +Point ScViewData::GetMousePosPixel() +{ + DBG_ASSERT( pView, "GetMousePosPixel() ohne View" ); + return pView->GetMousePosPixel(); +} + +void ScViewData::UpdateInputHandler( BOOL bForce ) +{ + if (pViewShell) + pViewShell->UpdateInputHandler( bForce ); +} + +BOOL ScViewData::IsOle() +{ + return pDocShell && pDocShell->IsOle(); +} + +BOOL ScViewData::UpdateFixX( USHORT nTab ) // TRUE = Wert geaendert +{ + if (nTab>MAXTAB) // Default + nTab=nTabNo; // akuelle Tabelle + + if (!pView || pTabData[nTab]->eHSplitMode != SC_SPLIT_FIX) + return FALSE; + + USHORT nFix = pTabData[nTab]->nFixPosX; + ScDocument* pDoc = GetDocument(); + long nNewPos = 0; + for (USHORT nX=pTabData[nTab]->nPosX[SC_SPLIT_LEFT]; nX<nFix; nX++) + { + USHORT nTSize = pDoc->GetColWidth( nX, nTab ); + if (nTSize) + { + long nPix = (long) ( nTSize * nPPTX ); + nNewPos += nPix; + } + } + nNewPos += pView->GetGridOffset().X(); + if (nNewPos != pTabData[nTab]->nHSplitPos) + { + pTabData[nTab]->nHSplitPos = nNewPos; + if (nTab == nTabNo) + RecalcPixPos(); //! sollte nicht noetig sein !!! + return TRUE; + } + + return FALSE; +} + +BOOL ScViewData::UpdateFixY( USHORT nTab ) // TRUE = Wert geaendert +{ + if (nTab>MAXTAB) // Default + nTab=nTabNo; // akuelle Tabelle + + if (!pView || pTabData[nTab]->eVSplitMode != SC_SPLIT_FIX) + return FALSE; + + USHORT nFix = pTabData[nTab]->nFixPosY; + ScDocument* pDoc = GetDocument(); + long nNewPos = 0; + for (USHORT nY=pTabData[nTab]->nPosY[SC_SPLIT_TOP]; nY<nFix; nY++) + { + USHORT nTSize = pDoc->FastGetRowHeight( nY, nTab ); + if (nTSize) + { + long nPix = (long) ( nTSize * nPPTY ); + nNewPos += nPix; + } + } + nNewPos += pView->GetGridOffset().Y(); + if (nNewPos != pTabData[nTab]->nVSplitPos) + { + pTabData[nTab]->nVSplitPos = nNewPos; + if (nTab == nTabNo) + RecalcPixPos(); //! sollte nicht noetig sein !!! + return TRUE; + } + + return FALSE; +} + +void ScViewData::UpdateOutlinerFlags( Outliner& rOutl ) const +{ + BOOL bOnlineSpell = GetDocument()->GetDocOptions().IsAutoSpell(); + BOOL bHideSpell = GetOptions().IsHideAutoSpell(); + + ULONG nCntrl = rOutl.GetControlWord(); + nCntrl |= EE_CNTRL_URLSFXEXECUTE; + nCntrl |= EE_CNTRL_MARKFIELDS; + nCntrl |= EE_CNTRL_AUTOCORRECT; + if( bHideSpell ) + nCntrl |= EE_CNTRL_NOREDLINES; + else + nCntrl &= ~EE_CNTRL_NOREDLINES; + if( bOnlineSpell ) + nCntrl |= EE_CNTRL_ONLINESPELLING; + else + nCntrl &= ~EE_CNTRL_ONLINESPELLING; + rOutl.SetControlWord(nCntrl); + + rOutl.SetCalcFieldValueHdl( LINK( SC_MOD(), ScModule, CalcFieldValueHdl ) ); + + // #66115# Der Speller muss auch gesetzt werden, wenn Online-Spelling aus ist, + // weil die EditEngine sich vom Speller die Sprache fuer AutoKorrektur holt + +#ifdef ONE_LINGU + //! no way to set the outliner's spelling language? + // (may not bee needed - default language is always used) + + rOutl.SetSpeller( OFF_APP()->GetSpellChecker() ); +#else + SpellCheck& rSpeller = *OFF_APP()->GetSpellChecker(); + if ( bOnlineSpell ) + { + if (!rSpeller.LoadDll()) + { + //! Fehlermeldung? + } + } + // Zeichenobjekt hat keine eigene Sprache... + LanguageType eLang = (LanguageType) rSpeller.GetDefaultLanguage(); + if ( eLang == LANGUAGE_SYSTEM ) + eLang = System::GetLanguage(); // Spelling nie mit SYSTEM + rSpeller.SetActualLanguage( eLang ); + rOutl.SetSpeller(&rSpeller); +#endif +} + +ScAddress ScViewData::GetCurPos() const +{ + return ScAddress( GetCurX(), GetCurY(), GetTabNo() ); +} + + + + diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx new file mode 100644 index 000000000000..081da5158051 --- /dev/null +++ b/sc/source/ui/view/viewfun2.cxx @@ -0,0 +1,2548 @@ +/************************************************************************* + * + * $RCSfile: viewfun2.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#define _SVSTDARR_STRINGS +#include <svx/boxitem.hxx> +#include <svx/fontitem.hxx> +#include <svx/srchitem.hxx> +#include <svx/linkmgr.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/docfilt.hxx> +#include <sfx2/docfile.hxx> +#include <sfx2/objitem.hxx> +#include <sfx2/viewfrm.hxx> +#include <svtools/stritem.hxx> +#include <svtools/zforlist.hxx> +#include <svtools/svstdarr.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/sound.hxx> +#include <vcl/virdev.hxx> +#include <vcl/waitobj.hxx> + +#include "viewfunc.hxx" + +#include "sc.hrc" +#include "globstr.hrc" + +#include "arealink.hxx" +#include "attrib.hxx" +#include "autoform.hxx" +#include "cell.hxx" // EnterAutoSum +#include "compiler.hxx" +#include "docfunc.hxx" +#include "docpool.hxx" +#include "docsh.hxx" +#include "global.hxx" +#include "patattr.hxx" +#include "printfun.hxx" +#include "rangenam.hxx" +#include "rangeutl.hxx" +#include "refundo.hxx" +#include "tablink.hxx" +#include "tabvwsh.hxx" +#include "uiitems.hxx" +#include "undoblk.hxx" +#include "undocell.hxx" +#include "undotab.hxx" + + +// STATIC DATA --------------------------------------------------------------- + + +//---------------------------------------------------------------------------- + +BOOL ScViewFunc::AdjustBlockHeight( BOOL bPaint, ScMarkData* pMarkData ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + if (!pMarkData) + pMarkData = &GetViewData()->GetMarkData(); + + ScDocument* pDoc = pDocSh->GetDocument(); + USHORT* pRanges = new USHORT[MAXROW+1]; + USHORT nRangeCnt = pMarkData->GetMarkRowRanges( pRanges ); + if (!nRangeCnt) + { + pRanges[0] = pRanges[1] = GetViewData()->GetCurY(); + nRangeCnt = 1; + } + + VirtualDevice aVirtDev; + BOOL bAnyChanged = FALSE; + USHORT nTabCount = pDoc->GetTableCount(); + for (USHORT nTab=0; nTab<nTabCount; nTab++) + { + if (pMarkData->GetTableSelect(nTab)) + { + USHORT* pOneRange = pRanges; + BOOL bChanged = FALSE; + USHORT nPaintY; + for (USHORT nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++) + { + USHORT nStartNo = *(pOneRange++); + USHORT nEndNo = *(pOneRange++); + if (pDoc->SetOptimalHeight( nStartNo, nEndNo, nTab, 0, &aVirtDev, + GetViewData()->GetPPTX(), + GetViewData()->GetPPTY(), + GetViewData()->GetZoomX(), + GetViewData()->GetZoomY(), + FALSE )) + { + if (!bChanged) + nPaintY = nStartNo; + bAnyChanged = bChanged = TRUE; + } + } + if ( bPaint && bChanged ) + pDocSh->PostPaint( 0, nPaintY, nTab, MAXCOL, MAXROW, nTab, + PAINT_GRID | PAINT_LEFT ); + } + } + delete[] pRanges; + + if ( bPaint && bAnyChanged ) + pDocSh->UpdateOle(GetViewData()); + + return bAnyChanged; +} + + +//---------------------------------------------------------------------------- + +BOOL ScViewFunc::AdjustRowHeight( USHORT nStartRow, USHORT nEndRow, BOOL bPaint ) +{ + ScDocument* pDoc = GetViewData()->GetDocument(); + USHORT nTab = GetViewData()->GetTabNo(); + double nPPTX = GetViewData()->GetPPTX(); + double nPPTY = GetViewData()->GetPPTY(); + USHORT nOldPixel; + if (nStartRow == nEndRow) + nOldPixel = (USHORT) (pDoc->GetRowHeight(nStartRow,nTab) * nPPTY); + + VirtualDevice aVirtDev; + BOOL bChanged = pDoc->SetOptimalHeight( nStartRow, nEndRow, nTab, 0, &aVirtDev, + nPPTX, nPPTY, + GetViewData()->GetZoomX(), + GetViewData()->GetZoomY(), + FALSE ); + + if (bChanged && ( nStartRow == nEndRow )) + { + USHORT nNewPixel = (USHORT) (pDoc->GetRowHeight(nStartRow,nTab) * nPPTY); + if ( nNewPixel == nOldPixel ) + bChanged = FALSE; + } + + if ( bPaint && bChanged ) + GetViewData()->GetDocShell()->PostPaint( 0, nStartRow, nTab, MAXCOL, MAXROW, nTab, + PAINT_GRID | PAINT_LEFT ); + + return bChanged; +} + + +//---------------------------------------------------------------------------- + +enum ScAutoSum +{ + ScAutoSumNone = 0, + ScAutoSumData, + ScAutoSumSum +}; + + +ScAutoSum lcl_IsAutoSumData( ScDocument* pDoc, USHORT nCol, USHORT nRow, + USHORT nTab, ScDirection eDir, USHORT& nExtend ) +{ + ScBaseCell* pCell; + pDoc->GetCell( nCol, nRow, nTab, pCell ); + if ( pCell && pCell->HasValueData() ) + { + if ( pCell->GetCellType() == CELLTYPE_FORMULA ) + { + ScTokenArray* pCode = ((ScFormulaCell*)pCell)->GetCode(); + if ( pCode && pCode->GetOuterFuncOpCode() == ocSum ) + { + if ( pCode->GetAdjacentExtendOfOuterFuncRefs( nExtend, + ScAddress( nCol, nRow, nTab ), eDir ) ) + return ScAutoSumSum; + } + } + return ScAutoSumData; + } + return ScAutoSumNone; +} + + +//---------------------------------------------------------------------------- + +#define SC_AUTOSUM_MAXCOUNT 20 + +ScAutoSum lcl_SeekAutoSumData( ScDocument* pDoc, USHORT& nCol, USHORT& nRow, + USHORT nTab, ScDirection eDir, USHORT& nExtend ) +{ + USHORT nCount = 0; + while (nCount < SC_AUTOSUM_MAXCOUNT) + { + if ( eDir == DIR_TOP ) + { + if (nRow) + --nRow; + else + return ScAutoSumNone; + } + else + { + if (nCol) + --nCol; + else + return ScAutoSumNone; + } + ScAutoSum eSum; + if ( (eSum = lcl_IsAutoSumData( + pDoc, nCol, nRow, nTab, eDir, nExtend )) != ScAutoSumNone ) + return eSum; + ++nCount; + } + return ScAutoSumNone; +} + +#undef SC_AUTOSUM_MAXCOUNT + + +//---------------------------------------------------------------------------- + +BOOL ScViewFunc::GetAutoSumArea( ScRangeList& rRangeList ) +{ + ScDocument* pDoc = GetViewData()->GetDocument(); + USHORT nTab = GetViewData()->GetTabNo(); + + USHORT nCol = GetViewData()->GetCurX(); + USHORT nRow = GetViewData()->GetCurY(); + + USHORT nStartCol = nCol; + USHORT nStartRow = nRow; + USHORT nEndCol = nCol; + USHORT nEndRow = nRow; + USHORT nSeekCol = nCol; + USHORT nSeekRow = nRow; + USHORT nExtend; // wird per Reference gueltig bei ScAutoSumSum + + BOOL bCol = FALSE; + BOOL bRow = FALSE; + + ScAutoSum eSum; + if ( nRow + && ((eSum = lcl_IsAutoSumData( pDoc, nCol, nRow-1, nTab, + DIR_TOP, nExtend )) == ScAutoSumData ) + && ((eSum = lcl_IsAutoSumData( pDoc, nCol, nRow-1, nTab, + DIR_LEFT, nExtend )) == ScAutoSumData ) + ) + { + bRow = TRUE; + nSeekRow = nRow - 1; + } + else if ( nCol && (eSum = lcl_IsAutoSumData( pDoc, nCol-1, nRow, nTab, + DIR_LEFT, nExtend )) == ScAutoSumData ) + { + bCol = TRUE; + nSeekCol = nCol - 1; + } + else if (eSum = lcl_SeekAutoSumData( pDoc, nCol, nSeekRow, nTab, DIR_TOP, nExtend )) + bRow = TRUE; + else if (eSum = lcl_SeekAutoSumData( pDoc, nSeekCol, nRow, nTab, DIR_LEFT, nExtend )) + bCol = TRUE; + + if ( bCol || bRow ) + { + if ( bRow ) + { + nStartRow = nSeekRow; // nSeekRow evtl. per Reference angepasst + if ( eSum == ScAutoSumSum ) + nEndRow = nStartRow; // nur Summen summieren + else + nEndRow = nRow - 1; // Datenbereich evtl. nach unten erweitern + } + else + { + nStartCol = nSeekCol; // nSeekCol evtl. per Reference angepasst + if ( eSum == ScAutoSumSum ) + nEndCol = nStartCol; // nur Summen summieren + else + nEndCol = nCol - 1; // Datenbereich evtl. nach rechts erweitern + } + BOOL bContinue = FALSE; + do + { + if ( eSum == ScAutoSumData ) + { + if ( bRow ) + { + while ( nStartRow && lcl_IsAutoSumData( pDoc, nCol, + nStartRow-1, nTab, DIR_TOP, nExtend ) == eSum ) + --nStartRow; + } + else + { + while ( nStartCol && lcl_IsAutoSumData( pDoc, nStartCol-1, + nRow, nTab, DIR_LEFT, nExtend ) == eSum ) + --nStartCol; + } + } + rRangeList.Append( + ScRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab ) ); + if ( eSum == ScAutoSumSum ) + { + if ( bRow ) + { + USHORT nTmp = nEndRow = nExtend; + ScAutoSum eSkip; + while ( (eSkip = lcl_IsAutoSumData( pDoc, nCol, + nEndRow, nTab, DIR_TOP, nExtend )) == ScAutoSumData + && nEndRow ) + --nEndRow; + if ( eSkip == ScAutoSumSum && nEndRow < nTmp ) + { + bContinue = TRUE; + nStartRow = nEndRow; + } + else + bContinue = FALSE; + } + else + { + USHORT nTmp = nEndCol = nExtend; + ScAutoSum eSkip; + while ( (eSkip = lcl_IsAutoSumData( pDoc, nEndCol, + nRow, nTab, DIR_LEFT, nExtend )) == ScAutoSumData + && nEndCol ) + --nEndCol; + if ( eSkip == ScAutoSumSum && nEndCol < nTmp ) + { + bContinue = TRUE; + nStartCol = nEndCol; + } + else + bContinue = FALSE; + } + } + } while ( bContinue ); + return TRUE; + } + return FALSE; +} + + +//---------------------------------------------------------------------------- + +void ScViewFunc::EnterAutoSum(const ScRangeList& rRangeList) // Block mit Summen fuellen +{ + ScDocument* pDoc = GetViewData()->GetDocument(); + String aRef; + rRangeList.Format( aRef, SCA_VALID, pDoc ); + + String aFormula = '='; + ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr(); + ScFuncDesc* pDesc = pFuncMgr->Get( SC_OPCODE_SUM ); + if ( pDesc && pDesc->pFuncName ) + { + aFormula += *pDesc->pFuncName; + aFormula += '('; + aFormula += aRef; + aFormula += ')'; + } + + EnterBlock( aFormula, NULL ); +} + + +//---------------------------------------------------------------------------- + +void ScViewFunc::EnterBlock( const String& rString, const EditTextObject* pData ) +{ + // Mehrfachselektion vorher abfragen... + + USHORT nCol = GetViewData()->GetCurX(); + USHORT nRow = GetViewData()->GetCurY(); + USHORT nTab = GetViewData()->GetTabNo(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + if ( rMark.IsMultiMarked() ) + { + rMark.MarkToSimple(); + if ( rMark.IsMultiMarked() ) + { // "Einfuegen auf Mehrfachselektion nicht moeglich" + ErrorMessage(STR_MSSG_PASTEFROMCLIP_0); + + // insert into single cell + if ( pData ) + EnterData( nCol, nRow, nTab, pData ); + else + EnterData( nCol, nRow, nTab, rString ); + return; + } + } + + ScDocument* pDoc = GetViewData()->GetDocument(); + String aNewStr = rString; + if ( pData ) + { + const ScPatternAttr* pOldPattern = pDoc->GetPattern( nCol, nRow, nTab ); + ScTabEditEngine aEngine( *pOldPattern, pDoc->GetEnginePool() ); + aEngine.SetText(*pData); + + ScEditAttrTester aTester( &aEngine ); + if (!aTester.NeedsObject()) + { + aNewStr = aEngine.GetText(); + pData = NULL; + } + } + + // Einfuegen per PasteFromClip + + WaitObject aWait( GetFrameWin() ); + + ScAddress aPos( nCol, nRow, nTab ); + + ScDocument* pInsDoc = new ScDocument( SCDOCMODE_CLIP ); + pInsDoc->ResetClip( pDoc, nTab ); + + if (aNewStr.GetChar(0) == '=') // Formel ? + { + // SetString geht nicht, weil in Clipboard-Dokumenten nicht kompiliert wird! + ScFormulaCell* pFCell = new ScFormulaCell( pDoc, aPos, aNewStr ); + pInsDoc->PutCell( nCol, nRow, nTab, pFCell ); + } + else if ( pData ) + pInsDoc->PutCell( nCol, nRow, nTab, new ScEditCell( pData, pDoc, NULL ) ); + else + pInsDoc->SetString( nCol, nRow, nTab, aNewStr ); + + pInsDoc->SetClipArea( ScRange(aPos) ); + // auf Block einfuegen, mit Undo etc. + if ( PasteFromClip( IDF_CONTENTS, pInsDoc, PASTE_NOFUNC, FALSE, FALSE, + FALSE, INS_NONE, IDF_ATTRIB ) ) + { + const SfxUInt32Item* pItem = (SfxUInt32Item*) pInsDoc->GetAttr( + nCol, nRow, nTab, ATTR_VALUE_FORMAT ); + if ( pItem ) + { // Numberformat setzen wenn inkompatibel + // MarkData wurde bereits in PasteFromClip MarkToSimple'ed + ScMarkData& rMark = GetViewData()->GetMarkData(); + ScRange aRange; + rMark.GetMarkArea( aRange ); + ScPatternAttr* pPattern = new ScPatternAttr( pDoc->GetPool() ); + pPattern->GetItemSet().Put( *pItem ); + short nNewType = pDoc->GetFormatTable()->GetType( pItem->GetValue() ); + pDoc->ApplyPatternIfNumberformatIncompatible( aRange, rMark, + *pPattern, nNewType ); + delete pPattern; + } + } + + delete pInsDoc; +} + + +//---------------------------------------------------------------------------- + +void ScViewFunc::PaintWidthHeight( BOOL bColumns, USHORT nStart, USHORT nEnd ) +{ + USHORT nTab = GetViewData()->GetTabNo(); + ScDocument* pDoc = GetViewData()->GetDocument(); + + USHORT nParts = PAINT_GRID; + USHORT nStartCol = 0; + USHORT nStartRow = 0; + USHORT nEndCol = MAXCOL; // fuer Test auf Merge + USHORT nEndRow = MAXROW; + if ( bColumns ) + { + nParts |= PAINT_TOP; + nStartCol = nStart; + nEndCol = nEnd; + } + else + { + nParts |= PAINT_LEFT; + nStartRow = nStart; + nEndRow = nEnd; + } + if (pDoc->HasAttrib( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab, + HASATTR_MERGED | HASATTR_OVERLAPPED )) + { + nStartCol = 0; + nStartRow = 0; + } + GetViewData()->GetDocShell()->PostPaint( nStartCol,nStartRow,nTab, MAXCOL,MAXROW,nTab, nParts ); +} + + +//---------------------------------------------------------------------------- +// manueller Seitenumbruch + +void ScViewFunc::InsertPageBreak( BOOL bColumn, BOOL bRecord, const ScAddress* pPos, + BOOL bSetModified ) +{ + USHORT nTab = GetViewData()->GetTabNo(); + ScAddress aCursor; + if (pPos) + aCursor = *pPos; + else + aCursor = ScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), nTab ); + + BOOL bSuccess = GetViewData()->GetDocShell()->GetDocFunc(). + InsertPageBreak( bColumn, aCursor, bRecord, bSetModified, FALSE ); + + if ( bSuccess && bSetModified ) + UpdatePageBreakData( TRUE ); // fuer PageBreak-Modus +} + + +//---------------------------------------------------------------------------- + +void ScViewFunc::DeletePageBreak( BOOL bColumn, BOOL bRecord, const ScAddress* pPos, + BOOL bSetModified ) +{ + USHORT nTab = GetViewData()->GetTabNo(); + ScAddress aCursor; + if (pPos) + aCursor = *pPos; + else + aCursor = ScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), nTab ); + + BOOL bSuccess = GetViewData()->GetDocShell()->GetDocFunc(). + RemovePageBreak( bColumn, aCursor, bRecord, bSetModified, FALSE ); + + if ( bSuccess && bSetModified ) + UpdatePageBreakData( TRUE ); // fuer PageBreak-Modus +} + +//---------------------------------------------------------------------------- + +void ScViewFunc::RemoveManualBreaks() +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + USHORT nTab = GetViewData()->GetTabNo(); + + ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, TRUE ); + pDoc->CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, IDF_NONE, FALSE, pUndoDoc ); + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoRemoveBreaks( pDocSh, nTab, pUndoDoc ) ); + + pDoc->RemoveManualBreaks(nTab); + pDoc->UpdatePageBreaks(nTab); + + UpdatePageBreakData( TRUE ); + pDocSh->SetDocumentModified(); + pDocSh->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID ); +} + +//---------------------------------------------------------------------------- + +void ScViewFunc::SetPrintZoom(USHORT nScale, USHORT nPages) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + USHORT nTab = GetViewData()->GetTabNo(); + pDocSh->SetPrintZoom( nTab, nScale, nPages ); +} + +void ScViewFunc::AdjustPrintZoom() +{ + ScRange aRange; + if ( !GetViewData()->GetSimpleArea( aRange, TRUE ) ) + GetViewData()->GetMarkData().GetMultiMarkArea( aRange ); + GetViewData()->GetDocShell()->AdjustPrintZoom( aRange ); +} + +//---------------------------------------------------------------------------- + +void ScViewFunc::SetPrintRanges( const String* pPrint, + const String* pRepCol, const String* pRepRow, + BOOL bAddPrint ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + USHORT nCurTab = GetViewData()->GetTabNo(); + ScRange aRange( 0,0,nCurTab ); // falls Tab im String nicht angegeben + + ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver(); + USHORT nAdd = 0; + if ( bAddPrint ) + nAdd = pDoc->GetPrintRangeCount( nCurTab ); + + // Druckbereiche + + if ( pPrint ) + { + if ( !pPrint->Len() ) + pDoc->SetPrintRangeCount( nCurTab, nAdd ); // loeschen bzw. unveraendert + else + { + USHORT nTCount = pPrint->GetTokenCount(); + pDoc->SetPrintRangeCount( nCurTab, nTCount + nAdd ); + for (USHORT i=0; i<nTCount; i++) + { + String aToken = pPrint->GetToken(i); + if ( aRange.ParseAny( aToken, pDoc ) & SCA_VALID ) + pDoc->SetPrintRange( nCurTab, i + nAdd, aRange ); + } + } + } + else // sonst Selektion (Druckbereich wird immer gesetzt) + { + ScMarkData& rMark = GetViewData()->GetMarkData(); + if ( GetViewData()->GetSimpleArea( aRange, TRUE ) ) + { + pDoc->SetPrintRangeCount( nCurTab, nAdd + 1 ); + pDoc->SetPrintRange( nCurTab, nAdd, aRange ); + } + else if ( rMark.IsMultiMarked() ) + { + ScRangeListRef aList( new ScRangeList ); + rMark.FillRangeListWithMarks( aList, FALSE ); + USHORT nCnt = (USHORT) aList->Count(); + if ( nCnt ) + { + pDoc->SetPrintRangeCount( nCurTab, nCnt + nAdd ); + ScRangePtr pR; + USHORT i; + for ( pR = aList->First(), i=0; i < nCnt; + pR = aList->Next(), i++ ) + { + pDoc->SetPrintRange( nCurTab, i + nAdd, *pR ); + } + } + } + } + + // Wiederholungsspalten + + if ( pRepCol ) + { + if ( !pRepCol->Len() ) + pDoc->SetRepeatColRange( nCurTab, NULL ); + else + if ( aRange.ParseAny( *pRepCol, pDoc ) & SCA_VALID ) + pDoc->SetRepeatColRange( nCurTab, &aRange ); + } + + // Wiederholungszeilen + + if ( pRepRow ) + { + if ( !pRepRow->Len() ) + pDoc->SetRepeatRowRange( nCurTab, NULL ); + else + if ( aRange.ParseAny( *pRepRow, pDoc ) & SCA_VALID ) + pDoc->SetRepeatRowRange( nCurTab, &aRange ); + } + + // Umbrueche und Undo + + ScPrintRangeSaver* pNewRanges = pDoc->CreatePrintRangeSaver(); + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoPrintRange( pDocSh, nCurTab, pOldRanges, pNewRanges ) ); + + ScPrintFunc( pDocSh, pDocSh->GetPrinter(), nCurTab ).UpdatePages(); + + SfxBindings& rBindings = SFX_BINDINGS(); + rBindings.Invalidate( SID_DELETE_PRINTAREA ); + + pDocSh->SetDocumentModified(); +} + +//---------------------------------------------------------------------------- +// Zellen zusammenfassen + +BOOL ScViewFunc::TestMergeCells() // Vorab-Test (fuer Menue) +{ + ScMarkData& rMark = GetViewData()->GetMarkData(); + rMark.MarkToSimple(); + return rMark.IsMarked() && !rMark.IsMultiMarked(); +} + + +//---------------------------------------------------------------------------- + +BOOL ScViewFunc::MergeCells( BOOL bApi, BOOL& rDoContents, BOOL bRecord ) +{ + // Editable- und Verschachtelungs-Abfrage muss vorneweg sein (auch in DocFunc), + // damit dann nicht die Inhalte-QueryBox kommt + if (!SelectionEditable()) + { + ErrorMessage(STR_PROTECTIONERR); + return FALSE; + } + + ScMarkData& rMark = GetViewData()->GetMarkData(); + rMark.MarkToSimple(); + if (!rMark.IsMarked()) + { + ErrorMessage(STR_NOMULTISELECT); + return FALSE; + } + + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + + ScRange aMarkRange; + rMark.GetMarkArea( aMarkRange ); + USHORT nStartCol = aMarkRange.aStart.Col(); + USHORT nStartRow = aMarkRange.aStart.Row(); + USHORT nStartTab = aMarkRange.aStart.Tab(); + USHORT nEndCol = aMarkRange.aEnd.Col(); + USHORT nEndRow = aMarkRange.aEnd.Row(); + USHORT nEndTab = aMarkRange.aEnd.Tab(); + if ( nStartCol == nEndCol && nStartRow == nEndRow ) + { + // nichts zu tun + return TRUE; + } + + if ( pDoc->HasAttrib( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab, + HASATTR_MERGED | HASATTR_OVERLAPPED ) ) + { // "Zusammenfassen nicht verschachteln !" + ErrorMessage(STR_MSSG_MERGECELLS_0); + return FALSE; + } + + BOOL bOk = TRUE; + BOOL bNeedContents = FALSE; + + if ( !pDoc->IsBlockEmpty( nStartTab, nStartCol,nStartRow+1, nStartCol,nEndRow ) || + !pDoc->IsBlockEmpty( nStartTab, nStartCol+1,nStartRow, nEndCol,nEndRow ) ) + { + bNeedContents = TRUE; + if (!bApi) + { + MessBox aBox( GetViewData()->GetDialogParent(), + WinBits(WB_YES_NO_CANCEL | WB_DEF_NO), + ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), + ScGlobal::GetRscString( STR_MERGE_NOTEMPTY ) ); + USHORT nRetVal = aBox.Execute(); + + if ( nRetVal == RET_YES ) + rDoContents = TRUE; + else if ( nRetVal == RET_CANCEL ) + bOk = FALSE; + } + } + + if (bOk) + { + HideCursor(); + bOk = pDocSh->GetDocFunc().MergeCells( aMarkRange, rDoContents, bRecord, bApi ); + ShowCursor(); + + if (bOk) + { + SetCursor( nStartCol, nStartRow ); + //DoneBlockMode( FALSE); + Unmark(); + + pDocSh->UpdateOle(GetViewData()); + UpdateInputLine(); + } + } + + return bOk; +} + + +//---------------------------------------------------------------------------- + +BOOL ScViewFunc::TestRemoveMerge() +{ + BOOL bMerged = FALSE; + ScRange aRange; + if (GetViewData()->GetSimpleArea( aRange )) + { + ScDocument* pDoc = GetViewData()->GetDocument(); + if ( pDoc->HasAttrib( aRange, HASATTR_MERGED ) ) + bMerged = TRUE; + } + return bMerged; +} + + +//---------------------------------------------------------------------------- + +BOOL ScViewFunc::RemoveMerge( BOOL bRecord ) +{ + ScRange aRange; + if (GetViewData()->GetSimpleArea( aRange )) + { + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + HideCursor(); + BOOL bOk = pDocSh->GetDocFunc().UnmergeCells( aRange, bRecord, FALSE ); + ShowCursor(); + if (bOk) + pDocSh->UpdateOle(GetViewData()); + } + return TRUE; //! bOk ?? +} + +//---------------------------------------------------------------------------- + +void ScViewFunc::FillSimple( FillDir eDir, BOOL bRecord ) +{ + ScRange aRange; + if (GetViewData()->GetSimpleArea(aRange)) + { + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + const ScMarkData& rMark = GetViewData()->GetMarkData(); + BOOL bSuccess = pDocSh->GetDocFunc().FillSimple( aRange, &rMark, eDir, bRecord, FALSE ); + if (bSuccess) + { + pDocSh->UpdateOle(GetViewData()); + UpdateScrollBars(); + } + } + else + ErrorMessage(STR_NOMULTISELECT); +} + +//---------------------------------------------------------------------------- + +void ScViewFunc::FillSeries( FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd, + double fStart, double fStep, double fMax, BOOL bRecord ) +{ + ScRange aRange; + if (GetViewData()->GetSimpleArea(aRange)) + { + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + const ScMarkData& rMark = GetViewData()->GetMarkData(); + BOOL bSuccess = pDocSh->GetDocFunc(). + FillSeries( aRange, &rMark, eDir, eCmd, eDateCmd, + fStart, fStep, fMax, bRecord, FALSE ); + if (bSuccess) + { + pDocSh->UpdateOle(GetViewData()); + UpdateScrollBars(); + } + } + else + ErrorMessage(STR_NOMULTISELECT); +} + +//---------------------------------------------------------------------------- + +void ScViewFunc::FillAuto( FillDir eDir, USHORT nStartCol, USHORT nStartRow, + USHORT nEndCol, USHORT nEndRow, USHORT nCount, BOOL bRecord ) +{ + USHORT nTab = GetViewData()->GetTabNo(); + ScRange aRange( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab ); + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + const ScMarkData& rMark = GetViewData()->GetMarkData(); + BOOL bSuccess = pDocSh->GetDocFunc(). + FillAuto( aRange, &rMark, eDir, nCount, bRecord, FALSE ); + if (bSuccess) + { + MarkRange( aRange, FALSE ); // aRange ist in FillAuto veraendert worden + pDocSh->UpdateOle(GetViewData()); + UpdateScrollBars(); + } +} + +//---------------------------------------------------------------------------- + +void ScViewFunc::FillTab( USHORT nFlags, USHORT nFunction, BOOL bSkipEmpty, BOOL bAsLink ) +{ + if (!SelectionEditable()) //! vordere Tabelle darf geschuetzt sein !!! + { + ErrorMessage(STR_PROTECTIONERR); + return; + } + + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + USHORT nTab = GetViewData()->GetTabNo(); + + ScRange aMarkRange; + rMark.MarkToSimple(); + BOOL bMulti = rMark.IsMultiMarked(); + if (bMulti) + rMark.GetMultiMarkArea( aMarkRange ); + else if (rMark.IsMarked()) + rMark.GetMarkArea( aMarkRange ); + else + aMarkRange = ScRange( GetViewData()->GetCurX(), GetViewData()->GetCurY(), nTab ); + + ScDocument* pUndoDoc = NULL; +// if ( bRecord ) + { + pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + pUndoDoc->InitUndo( pDoc, nTab, nTab ); +// pUndoDoc->SelectTable( nTab, TRUE ); // nur fuer Markierung + + USHORT nTabCount = pDoc->GetTableCount(); + for (USHORT i=0; i<nTabCount; i++) + if (i != nTab && rMark.GetTableSelect(i)) + { + pUndoDoc->AddUndoTab( i, i ); + aMarkRange.aStart.SetTab( i ); + aMarkRange.aEnd.SetTab( i ); + pDoc->CopyToDocument( aMarkRange, IDF_ALL, bMulti, pUndoDoc ); +// pUndoDoc->SelectTable( i, TRUE ); + } + } + + if (bMulti) + pDoc->FillTabMarked( nTab, rMark, nFlags, nFunction, bSkipEmpty, bAsLink ); + else + { + aMarkRange.aStart.SetTab( nTab ); + aMarkRange.aEnd.SetTab( nTab ); + pDoc->FillTab( aMarkRange, rMark, nFlags, nFunction, bSkipEmpty, bAsLink ); + } + +// if ( bRecord ) + { //! fuer ChangeTrack erst zum Schluss + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoFillTable( pDocSh, rMark, + aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), nTab, + aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(), nTab, + pUndoDoc, bMulti, nTab, nFlags, nFunction, bSkipEmpty, bAsLink ) ); + } + + pDocSh->PostPaintGridAll(); + pDocSh->PostDataChanged(); +} + + +//---------------------------------------------------------------------------- +// AutoFormat + +ScAutoFormatData* ScViewFunc::CreateAutoFormatData() +{ + ScAutoFormatData* pData = NULL; + USHORT nStartCol; + USHORT nStartRow; + USHORT nStartTab; + USHORT nEndCol; + USHORT nEndRow; + USHORT nEndTab; + if (GetViewData()->GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab)) + { + if ( nEndCol-nStartCol >= 3 && nEndRow-nStartRow >= 3 ) + { + ScDocument* pDoc = GetViewData()->GetDocument(); + pData = new ScAutoFormatData; + pDoc->GetAutoFormatData( nStartTab, nStartCol,nStartRow,nEndCol,nEndRow, *pData ); + } + } + return pData; +} + + +//---------------------------------------------------------------------------- + +void ScViewFunc::AutoFormat( USHORT nFormatNo, BOOL bRecord ) +{ +#if 1 + + ScRange aRange; + if (GetViewData()->GetSimpleArea(aRange)) + { + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + + BOOL bSuccess = pDocSh->GetDocFunc().AutoFormat( aRange, &rMark, nFormatNo, bRecord, FALSE ); + if (bSuccess) + pDocSh->UpdateOle(GetViewData()); + } + else + ErrorMessage(STR_NOMULTISELECT); + +#else + + // nur wegen Matrix nicht editierbar? Attribute trotzdem ok + BOOL bOnlyNotBecauseOfMatrix; + if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix ) + { + ErrorMessage(STR_PROTECTIONERR); + return; + } + + USHORT nStartCol; + USHORT nStartRow; + USHORT nStartTab; + USHORT nEndCol; + USHORT nEndRow; + USHORT nEndTab; + + if (GetViewData()->GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab)) + { + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + BOOL bSize = (*ScGlobal::GetAutoFormat())[nFormatNo]->GetIncludeWidthHeight(); + + ScDocument* pUndoDoc = NULL; + if ( bRecord ) + { + pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + pUndoDoc->InitUndo( pDoc, nStartTab, nEndTab, bSize, bSize ); + pDoc->CopyToDocument( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab, + IDF_ATTRIB, FALSE, pUndoDoc ); + if (bSize) + { + pDoc->CopyToDocument( nStartCol,0,nStartTab, nEndCol,MAXROW,nEndTab, + IDF_NONE, FALSE, pUndoDoc ); + pDoc->CopyToDocument( 0,nStartRow,nStartTab, MAXCOL,nEndRow,nEndTab, + IDF_NONE, FALSE, pUndoDoc ); + } + pDoc->BeginDrawUndo(); + } + + GetFrameWin()->EnterWait(); + pDoc->AutoFormat( nStartCol, nStartRow, nEndCol, nEndRow, nFormatNo, rMark ); + GetFrameWin()->LeaveWait(); + + if (bSize) + { + SetMarkedWidthOrHeight( TRUE, SC_SIZE_VISOPT, STD_EXTRA_WIDTH, FALSE, FALSE ); + SetMarkedWidthOrHeight( FALSE, SC_SIZE_VISOPT, 0, FALSE, FALSE ); + pDocSh->PostPaint( 0,0,nStartTab, MAXCOL,MAXROW,nStartTab, + PAINT_GRID | PAINT_LEFT | PAINT_TOP ); + } + else + { + BOOL bAdj = AdjustBlockHeight( FALSE ); + if (bAdj) + pDocSh->PostPaint( 0,nStartRow,nStartTab, MAXCOL,MAXROW,nStartTab, + PAINT_GRID | PAINT_LEFT ); + else + pDocSh->PostPaint( nStartCol, nStartRow, nStartTab, + nEndCol, nEndRow, nEndTab, PAINT_GRID ); + } + + if ( bRecord ) // Draw-Undo erst jetzt verfuegbar + { + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoAutoFormat( pDocSh, + ScRange(nStartCol,nStartRow,nStartTab, nEndCol,nEndRow,nEndTab), + pUndoDoc, rMark, bSize, nFormatNo ) ); + } + + pDocSh->UpdateOle(GetViewData()); + pDocSh->SetDocumentModified(); + } + else + ErrorMessage(STR_NOMULTISELECT); + +#endif +} + + +//---------------------------------------------------------------------------- +// Suchen & Ersetzen + +void ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem, + BOOL bAddUndo, BOOL bIsApi ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + + USHORT nCol = GetViewData()->GetCurX(); + USHORT nRow = GetViewData()->GetCurY(); + USHORT nTab = GetViewData()->GetTabNo(); + BOOL bAttrib = pSearchItem->GetPattern(); + USHORT nCommand = pSearchItem->GetCommand(); + BOOL bAllTables = pSearchItem->IsAllTables(); + BOOL* pOldSelectedTables = NULL; + USHORT nOldSelectedCount = 0; + USHORT nOldTab = nTab; + USHORT nLastTab = pDoc->GetTableCount() - 1; + USHORT nStartTab, nEndTab; + if ( bAllTables ) + { + nStartTab = 0; + nEndTab = nLastTab; + pOldSelectedTables = new BOOL [ nEndTab + 1 ]; + for ( USHORT j = 0; j <= nEndTab; j++ ) + { + pOldSelectedTables[j] = rMark.GetTableSelect( j ); + if ( pOldSelectedTables[j] ) + ++nOldSelectedCount; + } + } + else + { //! mindestens eine ist immer selektiert + nStartTab = nEndTab = rMark.GetFirstSelected(); + for ( USHORT j = nStartTab + 1; j <= nLastTab; j++ ) + { + if ( rMark.GetTableSelect( j ) ) + nEndTab = j; + } + } + + if ( nCommand == SVX_SEARCHCMD_REPLACE + || nCommand == SVX_SEARCHCMD_REPLACE_ALL ) + { + for ( USHORT j = nStartTab; j <= nEndTab; j++ ) + { + if ( (bAllTables || rMark.GetTableSelect( j )) && + pDoc->IsTabProtected( j ) ) + { + if ( pOldSelectedTables ) + delete [] pOldSelectedTables; + ErrorMessage(STR_PROTECTIONERR); + return; + } + } + } + + if ( nCommand == SVX_SEARCHCMD_FIND + || nCommand == SVX_SEARCHCMD_FIND_ALL) + bAddUndo = FALSE; + + //! bAttrib bei Undo beruecksichtigen !!! + + ScDocument* pUndoDoc = NULL; + ScMarkData* pUndoMark = NULL; + String aUndoStr; + if (bAddUndo) + { + pUndoMark = new ScMarkData( rMark ); // Markierung wird veraendert + if ( nCommand == SVX_SEARCHCMD_REPLACE_ALL ) + { + pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + pUndoDoc->InitUndo( pDoc, nStartTab, nEndTab ); + } + } + + if ( bAllTables ) + { //! alles selektieren, erst nachdem pUndoMark erzeugt wurde + for ( USHORT j = nStartTab; j <= nEndTab; j++ ) + { + rMark.SelectTable( j, TRUE ); + } + } + + DoneBlockMode(TRUE); // Markierung nicht loeschen! + InitOwnBlockMode(); + + // wenn vom Anfang an gesucht wird, nicht nochmal fragen ob vom Anfang gesucht werden soll + BOOL bFirst = TRUE; + if ( nCol == 0 && nRow == 0 && nTab == nStartTab && !pSearchItem->GetBackward() ) + bFirst = FALSE; + + BOOL bFound = FALSE; + while (TRUE) + { + GetFrameWin()->EnterWait(); + if (pDoc->SearchAndReplace( *pSearchItem, nCol, nRow, nTab, rMark, aUndoStr, pUndoDoc ) ) + { + bFound = TRUE; + bFirst = TRUE; + if (bAddUndo) + { + GetViewData()->GetDocShell()->GetUndoManager()->AddUndoAction( + new ScUndoReplace( GetViewData()->GetDocShell(), *pUndoMark, + nCol, nRow, nTab, + aUndoStr, pUndoDoc, pSearchItem ) ); + pUndoDoc = NULL; + } + + break; // Abbruch while True + } + else if ( bFirst && (nCommand == SVX_SEARCHCMD_FIND || + nCommand == SVX_SEARCHCMD_REPLACE) ) + { + bFirst = FALSE; + USHORT nRetVal; + GetFrameWin()->LeaveWait(); + if ( bIsApi ) + nRetVal = RET_NO; + else + { + // Suchen-Dialog als Parent, wenn vorhanden + Window* pParent = GetParentOrChild(SID_SEARCH_DLG); + USHORT nStrId; + if ( pSearchItem->GetBackward() ) + { + if ( nStartTab == nEndTab ) + nStrId = STR_MSSG_SEARCHANDREPLACE_1; + else + nStrId = STR_MSSG_SEARCHANDREPLACE_4; + } + else + { + if ( nStartTab == nEndTab ) + nStrId = STR_MSSG_SEARCHANDREPLACE_2; + else + nStrId = STR_MSSG_SEARCHANDREPLACE_5; + } + MessBox aBox( pParent, WinBits(WB_YES_NO | WB_DEF_YES), + ScGlobal::GetRscString( STR_MSSG_SEARCHANDREPLACE_3 ), + ScGlobal::GetRscString( nStrId ) ); + nRetVal = aBox.Execute(); + } + + if ( nRetVal == RET_YES ) + { + ScDocument::GetSearchAndReplaceStart( *pSearchItem, nCol, nRow ); + if (pSearchItem->GetBackward()) + nTab = nEndTab; + else + nTab = nStartTab; + } + else + { + break; // Abbruch while True + } + } + else // nichts gefunden + { + if ( nCommand == SVX_SEARCHCMD_FIND_ALL || nCommand == SVX_SEARCHCMD_REPLACE_ALL ) + { + pDocSh->PostPaintGridAll(); // Markierung + } + + GetFrameWin()->LeaveWait(); + if (!bIsApi) + { + // Suchen-Dialog als Parent, wenn vorhanden + Window* pParent = GetParentOrChild(SID_SEARCH_DLG); + // "nichts gefunden" + InfoBox aBox( pParent, ScGlobal::GetRscString( STR_MSSG_SEARCHANDREPLACE_0 ) ); + aBox.Execute(); + } + + break; // Abbruch while True + } + } // of while TRUE + + if ( pOldSelectedTables ) + { // urspruenglich selektierte Tabellen wiederherstellen + for ( USHORT j = nStartTab; j <= nEndTab; j++ ) + { + rMark.SelectTable( j, pOldSelectedTables[j] ); + } + if ( bFound ) + { // durch Fundstelle neu selektierte Tabelle bleibt + rMark.SelectTable( nTab, TRUE ); + // wenn vorher nur eine selektiert war, ist es ein Tausch + //! wenn nicht, ist jetzt evtl. eine mehr selektiert + if ( nOldSelectedCount == 1 && nTab != nOldTab ) + rMark.SelectTable( nOldTab, FALSE ); + } + delete [] pOldSelectedTables; + } + if ( bFound ) + { + if ( nTab != GetViewData()->GetTabNo() ) + SetTabNo( nTab ); + + // wenn nichts markiert ist, DoneBlockMode, damit von hier aus + // direkt per Shift-Cursor markiert werden kann: + if (!rMark.IsMarked() && !rMark.IsMultiMarked()) + DoneBlockMode(TRUE); + + AlignToCursor( nCol, nRow, SC_FOLLOW_JUMP ); + SetCursor( nCol, nRow, TRUE ); + + if ( nCommand == SVX_SEARCHCMD_REPLACE + || nCommand == SVX_SEARCHCMD_REPLACE_ALL ) + { + if ( nCommand == SVX_SEARCHCMD_REPLACE ) + pDocSh->PostPaint( nCol,nRow,nTab, nCol,nRow,nTab, PAINT_GRID ); + else + pDocSh->PostPaintGridAll(); + pDocSh->SetDocumentModified(); + } + else if ( nCommand == SVX_SEARCHCMD_FIND_ALL ) + pDocSh->PostPaintGridAll(); // Markierung + GetFrameWin()->LeaveWait(); + } + + delete pUndoDoc; // loeschen wenn nicht benutzt + delete pUndoMark; // kann immer geloescht werden +} + + +//---------------------------------------------------------------------------- +// Zielwertsuche + +void ScViewFunc::Solve( const ScSolveParam& rParam ) +{ + ScDocument* pDoc = GetViewData()->GetDocument(); + + USHORT nDestCol = rParam.aRefVariableCell.Col(); + USHORT nDestRow = rParam.aRefVariableCell.Row(); + USHORT nDestTab = rParam.aRefVariableCell.Tab(); + + if (!pDoc->IsBlockEditable(nDestTab, nDestCol,nDestRow, nDestCol,nDestRow)) + { + ErrorMessage(STR_PROTECTIONERR); + return; + } + + if ( pDoc ) + { + String aTargetValStr; + if ( rParam.pStrTargetVal != NULL ) + aTargetValStr = *(rParam.pStrTargetVal); + + String aMsgStr; + String aResStr; + double nSolveResult; + + GetFrameWin()->EnterWait(); + + BOOL bExact = + pDoc->Solver( + rParam.aRefFormulaCell.Col(), + rParam.aRefFormulaCell.Row(), + rParam.aRefFormulaCell.Tab(), + nDestCol, nDestRow, nDestTab, + aTargetValStr, + nSolveResult ); + + GetFrameWin()->LeaveWait(); + + SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + ULONG nFormat = 0; + const ScPatternAttr* pPattern = pDoc->GetPattern( nDestCol, nDestRow, nDestTab ); + if ( pPattern ) + nFormat = pPattern->GetNumberFormat( pFormatter ); + Color* p; + pFormatter->GetOutputString( nSolveResult, nFormat, aResStr, &p ); + + if ( bExact ) + { + aMsgStr = ScGlobal::GetRscString( STR_MSSG_SOLVE_0 ); + aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_1 ); + aMsgStr += String( aResStr ); + aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_2 ); + } + else + { + aMsgStr = ScGlobal::GetRscString( STR_MSSG_SOLVE_3 ); + aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_4 ); + aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_5 ); + aMsgStr += String( aResStr ); + aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_6 ); + } + + MessBox aBox( GetViewData()->GetDialogParent(), + WinBits(WB_YES_NO | WB_DEF_NO), + ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), aMsgStr ); + USHORT nRetVal = aBox.Execute(); + + if ( RET_YES == nRetVal ) + EnterData( nDestCol, nDestRow, nDestTab, nSolveResult ); + + GetViewData()->GetViewShell()->UpdateInputHandler( TRUE ); + } +} + + +//---------------------------------------------------------------------------- +// Mehrfachoperation + +void ScViewFunc::TabOp( const ScTabOpParam& rParam, BOOL bRecord ) +{ + ScRange aRange; + if (GetViewData()->GetSimpleArea(aRange)) + { + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + pDocSh->GetDocFunc().TabOp( aRange, &rMark, rParam, bRecord, FALSE ); + } + else + ErrorMessage(STR_NOMULTISELECT); +} + + +//---------------------------------------------------------------------------- + +void ScViewFunc::MakeScenario( const String& rName, const String& rComment, + const Color& rColor, USHORT nFlags ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + USHORT nTab = GetViewData()->GetTabNo(); + + USHORT nNewTab = pDocSh->MakeScenario( nTab, rName, rComment, rColor, nFlags, rMark ); + if (nFlags & SC_SCENARIO_COPYALL) + SetTabNo( nNewTab, TRUE ); // SC_SCENARIO_COPYALL -> sichtbar + else + { + SfxBindings& rBindings = SFX_BINDINGS(); + rBindings.Invalidate( SID_STATUS_DOCPOS ); // Statusbar + rBindings.Invalidate( SID_TABLES_COUNT ); + rBindings.Invalidate( SID_SELECT_SCENARIO ); + rBindings.Invalidate( FID_TABLE_SHOW ); + } +} + + +//---------------------------------------------------------------------------- + +void ScViewFunc::ExtendScenario() +{ + if (!SelectionEditable()) + { + ErrorMessage(STR_PROTECTIONERR); + return; + } + + // Undo: Attribute anwenden + + ScDocument* pDoc = GetViewData()->GetDocument(); + ScPatternAttr aPattern( pDoc->GetPool() ); + aPattern.GetItemSet().Put( ScMergeFlagAttr( SC_MF_SCENARIO ) ); + aPattern.GetItemSet().Put( ScProtectionAttr( TRUE ) ); + ApplySelectionPattern(aPattern); +} + + +//---------------------------------------------------------------------------- + +void ScViewFunc::UseScenario( const String& rName ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + USHORT nTab = GetViewData()->GetTabNo(); + + DoneBlockMode(); + InitOwnBlockMode(); + pDocSh->UseScenario( nTab, rName ); +} + + +//---------------------------------------------------------------------------- +// Tabelle einfuegen + +BOOL ScViewFunc::InsertTable( const String& rName, USHORT nTab, BOOL bRecord ) +{ + // Reihenfolge Tabelle/Name ist bei DocFunc umgekehrt + BOOL bSuccess = GetViewData()->GetDocShell()->GetDocFunc(). + InsertTable( nTab, rName, bRecord, FALSE ); + if (bSuccess) + SetTabNo( nTab, TRUE ); + + return bSuccess; +} + +//---------------------------------------------------------------------------- +// Tabellen einfuegen + +BOOL ScViewFunc::InsertTables(SvStrings *pNames, USHORT nTab, + USHORT nCount, BOOL bRecord ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + + SvStrings *pNameList= NULL; + + WaitObject aWait( GetFrameWin() ); + + if (bRecord) + { + pNameList= new SvStrings; + pDoc->BeginDrawUndo(); // InsertTab erzeugt ein SdrUndoNewPage + } + + BOOL bFlag=FALSE; + + String aValTabName; + String *pStr; + + for(int i=0;i<nCount;i++) + { + if(pNames!=NULL) + { + pStr=pNames->GetObject(i); + } + else + { + aValTabName.Erase(); + pDoc->CreateValidTabName( aValTabName); + pStr=&aValTabName; + } + + if(pDoc->InsertTab( nTab+i,*pStr)) + { + bFlag=TRUE; + pDocSh->Broadcast( ScTablesHint( SC_TAB_INSERTED, nTab+i ) ); + } + else + { + break; + } + + if(pNameList!=NULL) + pNameList->Insert(new String(*pStr),pNameList->Count()); + + } + + if (bFlag) + { + if (bRecord) + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoInsertTables( pDocSh, nTab, FALSE, pNameList)); + + // Views updaten: + + SetTabNo( nTab, TRUE ); + pDocSh->PostPaintExtras(); + pDocSh->SetDocumentModified(); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); + return TRUE; + } + else + { + return FALSE; + } +} + + +//---------------------------------------------------------------------------- + +BOOL ScViewFunc::AppendTable( const String& rName, BOOL bRecord ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + + WaitObject aWait( GetFrameWin() ); + + if (bRecord) + pDoc->BeginDrawUndo(); // InsertTab erzeugt ein SdrUndoNewPage + + if (pDoc->InsertTab( SC_TAB_APPEND, rName )) + { + USHORT nTab = pDoc->GetTableCount()-1; + if (bRecord) + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoInsertTab( pDocSh, nTab, TRUE, rName)); + GetViewData()->InsertTab( nTab ); + SetTabNo( nTab, TRUE ); + pDocSh->PostPaintExtras(); + pDocSh->SetDocumentModified(); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); + return TRUE; + } + else + { + return FALSE; + } +} + + +//---------------------------------------------------------------------------- + +BOOL ScViewFunc::DeleteTable( USHORT nTab, BOOL bRecord ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + + BOOL bSuccess = pDocSh->GetDocFunc().DeleteTable( nTab, bRecord, FALSE ); + if (bSuccess) + { + USHORT nNewTab = nTab; + if ( nNewTab >= pDoc->GetTableCount() ) + --nNewTab; + SetTabNo( nNewTab, TRUE ); + } + return bSuccess; +} + +BOOL ScViewFunc::DeleteTables(const SvUShorts &TheTabs, BOOL bRecord ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + USHORT nNewTab = TheTabs[0]; + int i; + WaitObject aWait( GetFrameWin() ); + + BOOL bWasLinked = FALSE; + ScDocument* pUndoDoc = NULL; + ScRefUndoData* pUndoData = NULL; + if (bRecord) + { + pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); +// pUndoDoc->InitDrawLayer( pDocSh ); + USHORT nCount = pDoc->GetTableCount(); + +// pUndoDoc->InitUndo( pDoc, 0, nCount-1 ); // incl. Ref. + + String aOldName; + for(i=0;i<TheTabs.Count();i++) + { + USHORT nTab = TheTabs[i]; + if (i==0) + pUndoDoc->InitUndo( pDoc, nTab,nTab, TRUE,TRUE ); // incl. Spalten/Zeilenflags + else + pUndoDoc->AddUndoTab( nTab,nTab, TRUE,TRUE ); // incl. Spalten/Zeilenflags + + pDoc->CopyToDocument(0,0,nTab, MAXCOL,MAXROW,nTab, IDF_ALL,FALSE, pUndoDoc ); + pDoc->GetName( nTab, aOldName ); + pUndoDoc->RenameTab( nTab, aOldName, FALSE ); + if (pDoc->IsLinked(nTab)) + { + bWasLinked = TRUE; + pUndoDoc->SetLink( nTab, pDoc->GetLinkMode(nTab), pDoc->GetLinkDoc(nTab), + pDoc->GetLinkFlt(nTab), pDoc->GetLinkOpt(nTab), + pDoc->GetLinkTab(nTab) ); + } + if ( pDoc->IsScenario(nTab) ) + { + pUndoDoc->SetScenario( nTab, TRUE ); + String aComment; + Color aColor; + USHORT nScenFlags; + pDoc->GetScenarioData( nTab, aComment, aColor, nScenFlags ); + pUndoDoc->SetScenarioData( nTab, aComment, aColor, nScenFlags ); + BOOL bActive = pDoc->IsActiveScenario( nTab ); + pUndoDoc->SetActiveScenario( nTab, bActive ); + } + + // Drawing-Layer muss sein Undo selbst in der Hand behalten !!! + // pUndoDoc->TransferDrawPage(pDoc, nTab,nTab); + } + + pUndoDoc->AddUndoTab( 0, nCount-1 ); // alle Tabs fuer Referenzen + + pDoc->BeginDrawUndo(); // DeleteTab erzeugt ein SdrUndoDelPage + + pUndoData = new ScRefUndoData( pDoc ); + } + + BOOL bDelError=FALSE; + + for(i=TheTabs.Count()-1;i>=0;i--) + { + if (pDoc->DeleteTab( TheTabs[i], pUndoDoc )) + { + bDelError=TRUE; + pDocSh->Broadcast( ScTablesHint( SC_TAB_DELETED, TheTabs[i] ) ); + } + } + if (bRecord) + { + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoDeleteTab( GetViewData()->GetDocShell(), TheTabs, + pUndoDoc, pUndoData )); + } + + + if(bDelError) + { + if ( nNewTab >= pDoc->GetTableCount() ) + --nNewTab; + + SetTabNo( nNewTab, TRUE ); + if (bWasLinked) + { + pDocSh->UpdateLinks(); // Link-Manager updaten + SFX_BINDINGS().Invalidate(SID_LINKS); + } + + pDocSh->PostPaintExtras(); + pDocSh->SetDocumentModified(); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); + } + else + { + delete pUndoDoc; + delete pUndoData; + } + return bDelError; +} + + +//---------------------------------------------------------------------------- + +BOOL ScViewFunc::RenameTable( const String& rName, USHORT nTab ) +{ + // Reihenfolge Tabelle/Name ist bei DocFunc umgekehrt + BOOL bSuccess = GetViewData()->GetDocShell()->GetDocFunc(). + RenameTable( nTab, rName, TRUE, FALSE ); + if (bSuccess) + { + // Der Tabellenname koennte in einer Formel vorkommen... + GetViewData()->GetViewShell()->UpdateInputHandler(); + } + return bSuccess; +} + + +//---------------------------------------------------------------------------- + +void ScViewFunc::InsertAreaLink( const String& rFile, + const String& rFilter, const String& rOptions, + const String& rSource ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + USHORT nPosX = GetViewData()->GetCurX(); + USHORT nPosY = GetViewData()->GetCurY(); + USHORT nTab = GetViewData()->GetTabNo(); + ScAddress aPos( nPosX, nPosY, nTab ); + + String aFilterName = rFilter; + String aNewOptions = rOptions; + if (!aFilterName.Len()) + ScDocumentLoader::GetFilterName( rFile, aFilterName, aNewOptions ); + + SvxLinkManager* pLinkManager = pDoc->GetLinkManager(); + + ScAreaLink* pLink = new ScAreaLink( pDocSh, rFile, aFilterName, aNewOptions, rSource, aPos ); + pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, rFile, &aFilterName, &rSource ); + + // Undo fuer den leeren Link + + pDocSh->GetUndoManager()->AddUndoAction( new ScUndoInsertAreaLink( pDocSh, + rFile, aFilterName, aNewOptions, + rSource, ScRange(aPos) ) ); + + // Update hat sein eigenes Undo + + pLink->SetDoInsert(FALSE); // beim ersten Update nichts einfuegen + pLink->Update(); // kein SetInCreate -> Update ausfuehren + pLink->SetDoInsert(TRUE); // Default = TRUE + + SfxBindings& rBindings = SFX_BINDINGS(); + rBindings.Invalidate( SID_LINKS ); + + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); // Navigator +} + + +//---------------------------------------------------------------------------- + +void ScViewFunc::InsertTableLink( const String& rFile, + const String& rFilter, const String& rOptions, + const String& rTabName ) +{ + String aFilterName = rFilter; + String aOpt = rOptions; + ScDocumentLoader aLoader( rFile, aFilterName, aOpt ); + if (!aLoader.IsError()) + { + ScDocShell* pSrcSh = aLoader.GetDocShell(); + ScDocument* pSrcDoc = pSrcSh->GetDocument(); + USHORT nTab = MAXTAB+1; + if (!rTabName.Len()) // kein Name angegeben -> erste Tabelle + nTab = 0; + else + { + String aTemp; + USHORT nCount = pSrcDoc->GetTableCount(); + for (USHORT i=0; i<nCount; i++) + { + pSrcDoc->GetName( i, aTemp ); + if ( aTemp == rTabName ) + nTab = i; + } + } + + if ( nTab <= MAXTAB ) + ImportTables( pSrcSh, 1, &nTab, TRUE, + GetViewData()->GetTabNo() ); + } +} + + +//---------------------------------------------------------------------------- +// Tabellen aus anderem Dokument kopieren / linken + +void ScViewFunc::ImportTables( ScDocShell* pSrcShell, + USHORT nCount, const USHORT* pSrcTabs, BOOL bLink,USHORT nTab ) +{ + ScDocument* pSrcDoc = pSrcShell->GetDocument(); + + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + //USHORT nTab = GetViewData()->GetTabNo(); + + BOOL bError = FALSE; + BOOL bRefs = FALSE; + BOOL bName = FALSE; + + if (pSrcDoc->GetDrawLayer()) + pDocSh->MakeDrawLayer(); + + pDoc->BeginDrawUndo(); // drawing layer must do its own undo actions + + USHORT nInsCount = 0; + USHORT i; + for( i=0; i<nCount; i++ ) + { // #63304# insert sheets first and update all references + String aName; + pSrcDoc->GetName( pSrcTabs[i], aName ); + pDoc->CreateValidTabName( aName ); + if ( !pDoc->InsertTab( nTab+i, aName ) ) + { + bError = TRUE; // total error + break; // for + } + ++nInsCount; + } + for (i=0; i<nCount && !bError; i++) + { + USHORT nSrcTab = pSrcTabs[i]; + USHORT nDestTab1=nTab+i; + ULONG nErrVal = pDoc->TransferTab( pSrcDoc, nSrcTab, nDestTab1, + FALSE ); // no insert + + switch (nErrVal) + { + case 0: // interner Fehler oder voll Fehler + bError = TRUE; + break; + case 2: + bRefs = TRUE; + break; + case 3: + bName = TRUE; + break; + case 4: + bRefs = bName = TRUE; + break; + } + + // TransferTab doesn't copy drawing objects with bInsertNew=FALSE + if ( !bError ) + pDoc->TransferDrawPage( pSrcDoc, nSrcTab, nDestTab1 ); + + if(!bError &&pSrcDoc->IsScenario(nSrcTab)) + { + String aComment; + Color aColor; + USHORT nFlags; + + pSrcDoc->GetScenarioData(nSrcTab, aComment,aColor, nFlags); + pDoc->SetScenario( nDestTab1,TRUE); + pDoc->SetScenarioData( nTab+i,aComment,aColor,nFlags); + BOOL bActive = pSrcDoc->IsActiveScenario(nSrcTab ); + pDoc->SetActiveScenario( nDestTab1, bActive ); + BOOL bVisible=pSrcDoc->IsVisible(nSrcTab); + pDoc->SetVisible(nDestTab1,bVisible ); + + } + } + + if (bLink) + { + SvxLinkManager* pLinkManager = pDoc->GetLinkManager(); + + SfxMedium* pMed = pSrcShell->GetMedium(); + String aFileName = pMed->GetName(); + String aFilterName; + if (pMed->GetFilter()) + aFilterName = pMed->GetFilter()->GetFilterName(); + String aOptions = ScDocumentLoader::GetOptions(*pMed); + + BOOL bWasThere = pDoc->HasLink( aFileName, aFilterName, aOptions ); + + String aTabStr; + for (i=0; i<nInsCount; i++) + { + pSrcDoc->GetName( pSrcTabs[i], aTabStr ); + pDoc->SetLink( nTab+i, SC_LINK_NORMAL, + aFileName, aFilterName, aOptions, aTabStr ); + } + + if (!bWasThere) // Link pro Quelldokument nur einmal eintragen + { + ScTableLink* pLink = new ScTableLink( pDocSh, aFileName, aFilterName, aOptions ); + pLink->SetInCreate( TRUE ); + pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, aFileName, &aFilterName ); + pLink->Update(); + pLink->SetInCreate( FALSE ); + + SfxBindings& rBindings = SFX_BINDINGS(); + rBindings.Invalidate( SID_LINKS ); + } + } + + + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoImportTab( pDocSh, nTab, nCount, bLink ) ); + + for (i=0; i<nInsCount; i++) + GetViewData()->InsertTab(nTab); + SetTabNo(nTab,TRUE); + pDocSh->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, + PAINT_GRID | PAINT_TOP | PAINT_LEFT | PAINT_EXTRAS ); + + SfxApplication* pSfxApp = SFX_APP(); + pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); + pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) ); + + pDocSh->PostPaintExtras(); + pDocSh->PostPaintGridAll(); + pDocSh->SetDocumentModified(); + + if (bRefs) + ErrorMessage(STR_ABSREFLOST); + if (bName) + ErrorMessage(STR_NAMECONFLICT); +} + + +//---------------------------------------------------------------------------- +// Tabelle in anderes Dokument verschieben / kopieren + +void ScViewFunc::MoveTable( USHORT nDestDocNo, USHORT nDestTab, BOOL bCopy ) +{ + ScDocument* pDoc = GetViewData()->GetDocument(); + ScDocShell* pDocShell = GetViewData()->GetDocShell(); + ScDocument* pDestDoc = NULL; + ScDocShell* pDestShell = NULL; + ScTabViewShell* pDestViewSh = NULL; + + BOOL bNewDoc = ( nDestDocNo == SC_DOC_NEW ); + if ( bNewDoc ) + { + nDestTab = 0; // als erstes einfügen + + // ohne SFX_CALLMODE_RECORD ausfuehren, weil schon im Move-Befehl enthalten: + + String aUrl = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("private:factory/")); + aUrl.AppendAscii(RTL_CONSTASCII_STRINGPARAM( STRING_SCAPP )); // "scalc4" + SfxStringItem aItem( SID_FILE_NAME, aUrl ); + const SfxObjectItem* pObjItem = (const SfxObjectItem*) SFX_DISPATCHER().Execute( + SID_OPENDOC, SFX_CALLMODE_API|SFX_CALLMODE_SYNCHRON, &aItem, 0L ); + if (pObjItem) + { + pDestShell = PTR_CAST( ScDocShell, pObjItem->GetShell() ); + if (pDestShell) + pDestViewSh = pDestShell->GetBestViewShell(); + } + + // Mit SID_NEWDOCDIRECT geht's diese Woche gerade mal gar nicht, + // weil es ein SfxFrameItem zurueckgibt +#if 0 + //! SID_NEWDOCDIRECT will immer aufzeichnen !!! + //! Mit CALLMODE_API wuerde der Returnwert nicht stimmen (SbxObject statt Frame) + + String aFactory = STRING_SCAPP; // "scalc4" + SfxStringItem aItem( SID_NEWDOCDIRECT, aFactory ); + const SfxViewFrameItem* pViewFrameItem = (const SfxViewFrameItem*) + SFX_DISPATCHER().Execute( SID_NEWDOCDIRECT, SFX_CALLMODE_SYNCHRON, &aItem, 0L ); + + if ( pViewFrameItem ) + { + SfxViewFrame* pFrame = pViewFrameItem->GetFrame(); + if (pFrame) + { + pDestViewSh = PTR_CAST( ScTabViewShell, pFrame->GetViewShell() ); + pDestShell = PTR_CAST( ScDocShell, pFrame->GetObjectShell() ); + } + } +#endif + } + else + pDestShell = ScDocShell::GetShellByNum( nDestDocNo ); + + if (!pDestShell) + { + DBG_ERROR("Dest-Doc nicht gefunden !!!"); + return; + } + + pDestDoc = pDestShell->GetDocument(); + + USHORT nTab = GetViewData()->GetTabNo(); + + if (pDestDoc != pDoc) + { + if (bNewDoc) + { + while (pDestDoc->GetTableCount() > 1) + pDestDoc->DeleteTab(0); + pDestDoc->RenameTab( 0, + String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("______42_____")), + FALSE ); + } + + ScMarkData& rMark = GetViewData()->GetMarkData(); + USHORT nTabCount = pDoc->GetTableCount(); + USHORT nTabSelCount = rMark.GetSelectCount(); + + SvUShorts TheTabs; + + int i; + for(i=0;i<nTabCount;i++) + { + if(rMark.GetTableSelect(i)) + { + String aTabName; + pDoc->GetName( i, aTabName); + TheTabs.Insert(i,TheTabs.Count()); + for(USHORT j=i+1;j<nTabCount;j++) + { + if((!pDoc->IsVisible(j))&&(pDoc->IsScenario(j))) + { + pDoc->GetName( j, aTabName); + TheTabs.Insert(j,TheTabs.Count()); + i=j; + } + else break; + } + } + } + + GetFrameWin()->EnterWait(); + + if (pDoc->GetDrawLayer()) + pDestShell->MakeDrawLayer(); + + if (!bNewDoc) + pDestDoc->BeginDrawUndo(); // drawing layer must do its own undo actions + + ULONG nErrVal =1; + if(nDestTab==0xFFFF) nDestTab=pDestDoc->GetTableCount(); + USHORT nDestTab1=nDestTab; + for( i=0; i<TheTabs.Count(); i++, nDestTab1++ ) + { // #63304# insert sheets first and update all references + String aName; + pDoc->GetName( TheTabs[i], aName ); + pDestDoc->CreateValidTabName( aName ); + if ( !pDestDoc->InsertTab( nDestTab1, aName ) ) + { + nErrVal = 0; // total error + break; // for + } + } + if ( nErrVal > 0 ) + { + nDestTab1 = nDestTab; + for(i=0;i<TheTabs.Count();i++) + { + nErrVal = pDestDoc->TransferTab( pDoc, TheTabs[i], nDestTab1, + FALSE ); // no insert + + // TransferTab doesn't copy drawing objects with bInsertNew=FALSE + if ( nErrVal > 0 ) + pDestDoc->TransferDrawPage( pDoc, TheTabs[i], nDestTab1 ); + + if(nErrVal>0 && pDoc->IsScenario(TheTabs[i])) + { + String aComment; + Color aColor; + USHORT nFlags; + + pDoc->GetScenarioData(TheTabs[i], aComment,aColor, nFlags); + pDestDoc->SetScenario(nDestTab1,TRUE); + pDestDoc->SetScenarioData(nDestTab1,aComment,aColor,nFlags); + BOOL bActive = pDoc->IsActiveScenario(TheTabs[i]); + pDestDoc->SetActiveScenario(nDestTab1, bActive ); + + BOOL bVisible=pDoc->IsVisible(TheTabs[i]); + pDestDoc->SetVisible(nDestTab1,bVisible ); + + } + nDestTab1++; + } + } + String sName; + if (!bNewDoc) + { + pDestDoc->GetName(nDestTab, sName); + pDestShell->GetUndoManager()->AddUndoAction( + new ScUndoImportTab( pDestShell, nDestTab, TheTabs.Count(), FALSE)); + + } + else + { + pDestShell->GetUndoManager()->Clear(); + } + + GetFrameWin()->LeaveWait(); + switch (nErrVal) + { + case 0: // interner Fehler oder voll Fehler + { + ErrorMessage(STR_TABINSERT_ERROR); + return; + } + break; + case 2: + ErrorMessage(STR_ABSREFLOST); + break; + case 3: + ErrorMessage(STR_NAMECONFLICT); + break; + case 4: + { + ErrorMessage(STR_ABSREFLOST); + ErrorMessage(STR_NAMECONFLICT); + } + break; + default: + break; + } + //pDestShell->GetUndoManager()->Clear(); //! Undo implementieren !!! +/* + String sName; + pDestDoc->GetName(nDestTab, sName); + pDestShell->GetUndoManager()->AddUndoAction( + new ScUndoInsertTab( pDestShell, nDestTab, TRUE, sName ) ); +*/ + if (!bCopy) + { + if(nTabCount!=nTabSelCount) + DeleteTables(TheTabs);// incl. Paint & Undo + else + ErrorMessage(STR_TABREMOVE_ERROR); + } + + if (bNewDoc) + { + // ChartListenerCollection must be updated before DeleteTab + if ( pDestDoc->IsChartListenerCollectionNeedsUpdate() ) + pDestDoc->UpdateChartListenerCollection(); + + pDestDoc->DeleteTab(TheTabs.Count()); // alte erste Tabelle +//? pDestDoc->SelectTable(0, TRUE); // neue erste Tabelle selektieren + if (pDestViewSh) + pDestViewSh->TabChanged(); // Pages auf dem Drawing-Layer + pDestShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, + PAINT_GRID | PAINT_TOP | PAINT_LEFT | + PAINT_EXTRAS | PAINT_SIZE ); + // PAINT_SIZE fuer Gliederung + } + else + { + pDestShell->Broadcast( ScTablesHint( SC_TAB_INSERTED, nDestTab ) ); + pDestShell->PostPaintExtras(); + pDestShell->PostPaintGridAll(); + } + + TheTabs.Remove(0,TheTabs.Count()); + + pDestShell->SetDocumentModified(); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); + } + else // innerhalb des Dokuments + { + + ScMarkData& rMark = GetViewData()->GetMarkData(); + USHORT nTabCount = pDoc->GetTableCount(); + USHORT nTabSelCount = rMark.GetSelectCount(); + + SvUShorts TheTabs; + SvUShorts TheDestTabs; + SvStrings TheTabNames; + String aDestName; + String *pString; + + int i; + for(i=0;i<nTabCount;i++) + { + if(rMark.GetTableSelect(i)) + { + String aTabName; + pDoc->GetName( i, aTabName); + TheTabNames.Insert(new String(aTabName),TheTabNames.Count()); + + for(USHORT j=i+1;j<nTabCount;j++) + { + if((!pDoc->IsVisible(j))&&(pDoc->IsScenario(j))) + { + pDoc->GetName( j, aTabName); + TheTabNames.Insert(new String(aTabName),TheTabNames.Count()); + i=j; + } + else break; + } + + } + } + + if (bCopy) + pDoc->BeginDrawUndo(); // drawing layer must do its own undo actions + + pDoc->GetName( nDestTab, aDestName); + USHORT nDestTab1=nDestTab; + USHORT nMovTab=0; + for(i=0;i<TheTabNames.Count();i++) + { + nTabCount = pDoc->GetTableCount(); + pString=TheTabNames[i]; + if(!pDoc->GetTable(*pString,nMovTab)) + { + nMovTab=nTabCount; + } + if(!pDoc->GetTable(aDestName,nDestTab1)) + { + nDestTab1=nTabCount; + } + pDocShell->MoveTable( nMovTab, nDestTab1, bCopy, FALSE ); // Undo ist hier + + if(bCopy && pDoc->IsScenario(nMovTab)) + { + String aComment; + Color aColor; + USHORT nFlags; + + pDoc->GetScenarioData(nMovTab, aComment,aColor, nFlags); + pDoc->SetScenario(nDestTab1,TRUE); + pDoc->SetScenarioData(nDestTab1,aComment,aColor,nFlags); + BOOL bActive = pDoc->IsActiveScenario(nMovTab ); + pDoc->SetActiveScenario( nDestTab1, bActive ); + BOOL bVisible=pDoc->IsVisible(nMovTab); + pDoc->SetVisible(nDestTab1,bVisible ); + } + + TheTabs.Insert(nMovTab,TheTabs.Count()); + + if(!bCopy) + { + if(!pDoc->GetTable(*pString,nDestTab1)) + { + nDestTab1=nTabCount; + } + } + + TheDestTabs.Insert(nDestTab1,TheDestTabs.Count()); + delete pString; + } + + nTab = GetViewData()->GetTabNo(); + + if (bCopy) + { + pDocShell->GetUndoManager()->AddUndoAction( + new ScUndoCopyTab( pDocShell, TheTabs, TheDestTabs)); + } + else + { + pDocShell->GetUndoManager()->AddUndoAction( + new ScUndoMoveTab( pDocShell, TheTabs, TheDestTabs)); + } + + USHORT nNewTab = nDestTab; + if (nNewTab == SC_TAB_APPEND) + nNewTab = pDoc->GetTableCount()-1; + else if (!bCopy && nTab<nDestTab) + nNewTab--; + + SetTabNo( nNewTab, TRUE ); + } +} + + +//---------------------------------------------------------------------------- + +void ScViewFunc::ShowTable( const String& rName ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + BOOL bFound = FALSE; + USHORT nPos = 0; + String aTabName; + USHORT nCount = pDoc->GetTableCount(); + for (USHORT i=0; i<nCount; i++) + { + pDoc->GetName( i, aTabName ); + if ( aTabName == rName ) + { + nPos = i; + bFound = TRUE; + } + } + + if (bFound) + { + pDoc->SetVisible( nPos, TRUE ); + pDocSh->GetUndoManager()->AddUndoAction( new ScUndoShowHideTab( pDocSh, nPos, TRUE ) ); + SetTabNo( nPos, TRUE ); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); + pDocSh->PostPaint(0,0,0,MAXCOL,MAXROW,MAXTAB, PAINT_EXTRAS); + pDocSh->SetDocumentModified(); + } + else + Sound::Beep(); +} + + +//---------------------------------------------------------------------------- + +void ScViewFunc::HideTable( USHORT nTab ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + USHORT nVisible = 0; + USHORT nCount = pDoc->GetTableCount(); + for (USHORT i=0; i<nCount; i++) + { + if (pDoc->IsVisible(i)) + ++nVisible; + } + + if (nVisible > 1) + { + pDoc->SetVisible( nTab, FALSE ); + pDocSh->GetUndoManager()->AddUndoAction( new ScUndoShowHideTab( pDocSh, nTab, FALSE ) ); + + // Views updaten: + pDocSh->Broadcast( ScTablesHint( SC_TAB_HIDDEN, nTab ) ); + + SetTabNo( nTab, TRUE ); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); + pDocSh->PostPaint(0,0,0,MAXCOL,MAXROW,MAXTAB, PAINT_EXTRAS); + pDocSh->SetDocumentModified(); + } + else + Sound::Beep(); +} + + +//---------------------------------------------------------------------------- + +void ScViewFunc::InsertSpecialChar( const String& rStr, const Font& rFont ) +{ + if (!SelectionEditable()) + { + ErrorMessage(STR_PROTECTIONERR); + return; + } + + const sal_Unicode* pChar = rStr.GetBuffer(); + ScTabViewShell* pViewShell = GetViewData()->GetViewShell(); + SvxFontItem aFontItem( rFont.GetFamily(), + rFont.GetName(), + rFont.GetStyleName(), + rFont.GetPitch(), + rFont.GetCharSet(), + ATTR_FONT ); + ApplyAttr( aFontItem ); + + while ( *pChar ) + pViewShell->TabKeyInput( KeyEvent( *(pChar++), KeyCode() ) ); +} + + +//---------------------------------------------------------------------------- + +void ScViewFunc::UpdateLineAttrs( SvxBorderLine& rLine, + const SvxBorderLine* pDestLine, + const SvxBorderLine* pSrcLine, + BOOL bColor ) +{ + if ( pSrcLine && pDestLine ) + { + if ( bColor ) + { + rLine.SetColor ( pSrcLine->GetColor() ); + rLine.SetOutWidth ( pDestLine->GetOutWidth() ); + rLine.SetInWidth ( pDestLine->GetInWidth() ); + rLine.SetDistance ( pDestLine->GetDistance() ); + } + else + { + rLine.SetColor ( pDestLine->GetColor() ); + rLine.SetOutWidth ( pSrcLine->GetOutWidth() ); + rLine.SetInWidth ( pSrcLine->GetInWidth() ); + rLine.SetDistance ( pSrcLine->GetDistance() ); + } + } +} + + +#define SET_LINE_ATTRIBUTES(LINE,BOXLINE) \ + pBoxLine = aBoxItem.Get##LINE(); \ + if ( pBoxLine ) \ + { \ + if ( pLine ) \ + { \ + UpdateLineAttrs( aLine, pBoxLine, pLine, bColorOnly ); \ + aBoxItem.SetLine( &aLine, BOXLINE ); \ + } \ + else \ + aBoxItem.SetLine( NULL, BOXLINE ); \ + } + + +//---------------------------------------------------------------------------- + +void ScViewFunc::SetSelectionFrameLines( const SvxBorderLine* pLine, + BOOL bColorOnly ) +{ + // nur wegen Matrix nicht editierbar? Attribute trotzdem ok + BOOL bOnlyNotBecauseOfMatrix; + if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix ) + { + ErrorMessage(STR_PROTECTIONERR); + return; + } + + ScDocument* pDoc = GetViewData()->GetDocument(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + const ScPatternAttr* pSelAttrs = GetSelectionPattern(); + const SfxPoolItem* pBorderAttr = NULL; + SfxItemState eItemState = + pSelAttrs->GetItemSet(). + GetItemState( ATTR_BORDER, + TRUE, + &pBorderAttr ); + + if ( eItemState != SFX_ITEM_DEFAULT ) + { + if ( eItemState == SFX_ITEM_SET ) + { + DBG_ASSERT( pBorderAttr, "Border-Attr not set!" ); + SvxBoxItem aBoxItem( *(const SvxBoxItem*)pBorderAttr ); + SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER ); + ScDocument* pDoc = GetViewData()->GetDocument(); + SfxItemSet* pOldSet = new SfxItemSet( + *(pDoc->GetPool()), + ATTR_PATTERN_START, + ATTR_PATTERN_END ); + SfxItemSet* pNewSet = new SfxItemSet( + *(pDoc->GetPool()), + ATTR_PATTERN_START, + ATTR_PATTERN_END ); + + //------------------------------------------------------------ + const SvxBorderLine* pBoxLine = NULL; + SvxBorderLine aLine; + + // hier wird die pBoxLine benutzt: + + SET_LINE_ATTRIBUTES(Top,BOX_LINE_TOP) + SET_LINE_ATTRIBUTES(Bottom,BOX_LINE_BOTTOM) + SET_LINE_ATTRIBUTES(Left,BOX_LINE_LEFT) + SET_LINE_ATTRIBUTES(Right,BOX_LINE_RIGHT) + + aBoxInfoItem.SetLine( aBoxItem.GetTop(), BOXINFO_LINE_HORI ); + aBoxInfoItem.SetLine( aBoxItem.GetLeft(), BOXINFO_LINE_VERT ); + aBoxInfoItem.ResetFlags(); // Lines auf Valid setzen + + pOldSet->Put( *pBorderAttr ); + pNewSet->Put( aBoxItem ); + pNewSet->Put( aBoxInfoItem ); + + ApplyAttributes( pNewSet, pOldSet ); + + delete pOldSet; + delete pNewSet; + } + else // if ( eItemState == SFX_ITEM_DONTCARE ) + { + rMark.MarkToMulti(); + pDoc->ApplySelectionLineStyle( rMark, pLine, bColorOnly ); + } + + ScRange aMarkRange; + rMark.GetMultiMarkArea( aMarkRange ); + USHORT nStartCol = aMarkRange.aStart.Col(); + USHORT nStartRow = aMarkRange.aStart.Row(); + USHORT nStartTab = aMarkRange.aStart.Tab(); + USHORT nEndCol = aMarkRange.aEnd.Col(); + USHORT nEndRow = aMarkRange.aEnd.Row(); + USHORT nEndTab = aMarkRange.aEnd.Tab(); + pDocSh->PostPaint( nStartCol, nStartRow, nStartTab, + nEndCol, nEndRow, nEndTab, + PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE ); + + pDocSh->UpdateOle( GetViewData() ); + pDocSh->SetDocumentModified(); + } +} + +#undef SET_LINE_ATTRIBUTES + + +//---------------------------------------------------------------------------- + +void ScViewFunc::SetConditionalFormat( const ScConditionalFormat& rNew ) +{ + ScDocument* pDoc = GetViewData()->GetDocument(); + ULONG nIndex = pDoc->AddCondFormat(rNew); // dafuer gibt's kein Undo + SfxUInt32Item aItem( ATTR_CONDITIONAL, nIndex ); + + ApplyAttr( aItem ); // mit Paint und Undo... +} + + +//---------------------------------------------------------------------------- + +void ScViewFunc::SetValidation( const ScValidationData& rNew ) +{ + ScDocument* pDoc = GetViewData()->GetDocument(); + ULONG nIndex = pDoc->AddValidationEntry(rNew); // dafuer gibt's kein Undo + SfxUInt32Item aItem( ATTR_VALIDDATA, nIndex ); + + ApplyAttr( aItem ); // mit Paint und Undo... +} + + diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx new file mode 100644 index 000000000000..8612f8d2461a --- /dev/null +++ b/sc/source/ui/view/viewfun3.cxx @@ -0,0 +1,1139 @@ +/************************************************************************* + * + * $RCSfile: viewfun3.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//---------------------------------------------------------------------------- + +#define _SV_NOXSOUND + +#ifdef WIN + #define _MENUBTN_HXX +#endif + +#define _BASE_DLGS_HXX +#define _BIGINT_HXX +#define _CACHESTR_HXX +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _CTRLTOOL_HXX +#define _DLGCFG_HXX +#define _DYNARR_HXX +#define _EXTATTR_HXX +#define _FILDLG_HXX +#define _FONTDLG_HXX +#define _FRM3D_HXX +#define _INTRO_HXX +#define _ISETBWR_HXX +#define _NO_SVRTF_PARSER_HXX +#define _MACRODLG_HXX +#define _MODALDLG_HXX +#define _MOREBUTTON_HXX +#define _OUTLINER_HXX +//#define _PRNDLG_HXX +//#define _POLY_HXX +#define _PVRWIN_HXX +//#define _QUEUE_HXX +#define _RULER_HXX +#define _SCRWIN_HXX +#define _SETBRW_HXX +//#define _STACK_HXX +//#define _STATUS_HXX *** +#define _STDCTRL_HXX +#define _STDMENU_HXX +//#define _TAB_HXX +#define _TABBAR_HXX +#define _TREELIST_HXX +#define _VALUESET_HXX +#define _VCATTR_HXX +#define _VCBRW_HXX +#define _VCTRLS_HXX +#define _VCSBX_HXX +#define _VCONT_HXX +#define _VDRWOBJ_HXX + +//#define _SELENG_HXX +//#define _SOUND_HXX +//#define _SYSDLG_HXX + + + + +#define _PASSWD_HXX + +#define _SFX_DOCFILE_HXX +//#define _SFX_DOCFILT_HXX +#define _SFX_DOCINF_HXX +#define _SFX_DOCSH_HXX +#define _SFXDOCFILE_HXX +//#define _SFXDOCFILT_HXX +//#define _SFXDOCINF_HXX +//#define _SFXDOCSH_HXX +#define _SFX_PRNMON_HXX +#define _SFX_RESMGR_HXX +#define _SFX_TEMPLDLG_HXX +//#define _SFXAPPWIN_HXX +#define _SFXBASIC_HXX +#define _SFXCTRLITEM +#define _SFXDLGCFG_HXX +//#define _SFXDISPATCH_HXX +#define _SFXFILEDLG_HXX +//#define _SFXIMGMGR_HXX +#define _SFXIPFRM_HXX +#define _SFX_MACRO_HXX +#define _SFXMNUITEM_HXX +#define _SFXMNUMGR_HXX +#define _SFXMULTISEL_HXX +//#define _SFXMSG_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFX_MINFITEM_HXX +#define _SFXOBJFACE_HXX +#define _SFXOBJFAC_HXX +#define _SFX_SAVEOPT_HXX +#define _SFXSTBITEM_HXX +#define _SFXSTBMGR_HXX +#define _SFXTBXCTRL_HXX +#define _SFXTBXMGR_HXX + +#define _SI_HXX +//#define _SI_DLL_HXX +//#define _SIDLL_HXX +//#define _SI_NOITEMS +//#define _SI_NOOTHERFORMS +//#define _SI_NOSBXCONTROLS +//#define _SINOSBXCONTROLS +//#define _SI_NODRW +//#define _SI_NOCONTROL + +#define _SVBOXITM_HXX +#define _SVCONTNR_HXX // + +#define _SDR_NOTRANSFORM + +#define _SVDRAG_HXX +#define _SVINCVW_HXX +#define _SV_MULTISEL_HXX +#define _SVRTV_HXX +#define _SVTABBX_HXX +#define _SVTREEBOX_HXX +#define _SVTREELIST_HXX + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_LAYCTRL_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SELCTRL_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_STDDLG_HXX +#define _SVX_THESDLG_HXX + +// INCLUDE ------------------------------------------------------------------- + +#include "scitems.hxx" +#include <svx/dbexch.hrc> +#include <svx/svdetc.hxx> +#include <sfx2/dispatch.hxx> +#include <offmgr/app.hxx> +#include <svtools/stritem.hxx> +#include <svtools/ptitem.hxx> +#include <svtools/urlbmk.hxx> +#include <so3/clsids.hxx> +#include <sot/formats.hxx> +#include <vcl/exchange.hxx> +#include <vcl/graph.hxx> +#include <vcl/virdev.hxx> +#include <vcl/msgbox.hxx> + +#include "viewfunc.hxx" +#include "tabvwsh.hxx" +#include "docsh.hxx" +#include "docfunc.hxx" +#include "undoblk.hxx" +#include "refundo.hxx" +#include "globstr.hrc" +#include "global.hxx" +#include "dataobj.hxx" +#include "rangenam.hxx" +#include "dbcolect.hxx" +#include "impex.hxx" // Sylk-ID fuer CB +#include "chgtrack.hxx" +#include "waitoff.hxx" +#include "sc.hrc" + +// STATIC DATA --------------------------------------------------------------- + + +//============================================================================ + +// GlobalName der Writer-DocShell kommt jetzt aus so3/clsids.hxx + +//---------------------------------------------------------------------------- +// C U T + +void ScViewFunc::CutToClip( ScDocument* pClipDoc ) +{ + const BOOL bRecord=TRUE; // Undo/Redo + + UpdateInputLine(); + + if (!SelectionEditable()) // Bereich editierbar? + { + ErrorMessage( STR_PROTECTIONERR ); + return; + } + + ScRange aRange; // zu loeschender Bereich + if ( GetViewData()->GetSimpleArea( aRange ) ) + { + ScDocument* pDoc = GetViewData()->GetDocument(); + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + + ScDocShellModificator aModificator( *pDocSh ); + + if (!rMark.IsMarked()) // Markierung setzen, falls nicht vorhanden + { + DoneBlockMode(); + InitOwnBlockMode(); + rMark.SetMarkArea( aRange ); + } + + CopyToClip( pClipDoc, TRUE ); // Ab ins Clipboard + + ScAddress aOldEnd( aRange.aEnd ); // Zusammengefasste Zellen im Bereich? + pDoc->ExtendMerge( aRange, TRUE ); + + ScDocument* pUndoDoc = NULL; + if ( bRecord ) + { + pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + pUndoDoc->InitUndo( pDoc, aRange.aStart.Tab(), aRange.aEnd.Tab() ); + pDoc->CopyToDocument( aRange, IDF_ALL, FALSE, pUndoDoc ); + pDoc->BeginDrawUndo(); + } + + USHORT nExtFlags = 0; + if ( pDoc->HasAttrib( aRange, HASATTR_PAINTEXT ) ) + nExtFlags |= SC_PF_LINES; + + HideCursor(); // Cursor aendert sich ! + + rMark.MarkToMulti(); + pDoc->DeleteSelection( IDF_ALL, rMark ); + rMark.MarkToSimple(); + + if ( !AdjustRowHeight( aRange.aStart.Row(), aRange.aEnd.Row() ) ) + pDocSh->PostPaint( aRange, PAINT_GRID, nExtFlags ); + + if ( bRecord ) // erst jetzt ist Draw-Undo verfuegbar + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoCut( pDocSh, aRange, aOldEnd, pUndoDoc ) ); + + aModificator.SetDocumentModified(); + ShowCursor(); // Cursor aendert sich ! + pDocSh->UpdateOle(GetViewData()); + + CellContentChanged(); + } + else + ErrorMessage( STR_NOMULTISELECT ); +} + + +//---------------------------------------------------------------------------- +// C O P Y + +void ScViewFunc::CopyToClip( ScDocument* pClipDoc, BOOL bCut ) +{ + UpdateInputLine(); + + BOOL bSysClip = FALSE; + if ( !pClipDoc ) // kein eigenes Clipboard + { + pClipDoc = ScGlobal::GetClipDoc(); // ab ins System! + bSysClip = TRUE; + } + + ScRange aRange; + if ( GetViewData()->GetSimpleArea( aRange ) ) + { + ScDocument* pDoc = GetViewData()->GetDocument(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + if ( !pDoc->HasSelectedBlockMatrixFragment( +/*!*/ aRange.aStart.Col(), aRange.aStart.Row(), + aRange.aEnd.Col(), aRange.aEnd.Row(), + rMark ) ) + { + if (bSysClip) + { +//? Clipboard::Clear(); // loescht ggf. altes ScDataObject und gibt ClipDoc frei + + SvDataObjectRef pDummyObj = new SvDataObject; + pDummyObj->CopyClipboard(); + } + + if ( !bCut ) + { + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->ResetLastCut(); // kein CutMode mehr + } + + pDoc->CopyToClip( aRange.aStart.Col(), aRange.aStart.Row(), +/*!*/ aRange.aEnd.Col(), aRange.aEnd.Row(), + bCut, pClipDoc, FALSE, &rMark ); + ScGlobal::SetClipDocName( pDoc->GetDocumentShell()->GetTitle( SFX_TITLE_FULLNAME ) ); + pClipDoc->ExtendMerge( aRange, TRUE ); + + if (bSysClip) + { + SvDataObjectRef pClipObj = new ScDataObject(pClipDoc,FALSE, + GetViewData()->GetDocShell(), + &GetViewData()->GetOptions()); + pClipObj->CopyClipboard(); + } + } + else + ErrorMessage(STR_MATRIXFRAGMENTERR); + } + else + ErrorMessage(STR_NOMULTISELECT); +} + + +//---------------------------------------------------------------------------- +// P A S T E + +void ScViewFunc::PasteDraw() +{ + ScViewData* pViewData = GetViewData(); + USHORT nPosX = pViewData->GetCurX(); + USHORT nPosY = pViewData->GetCurY(); + Point aPos = GetActiveWin()->PixelToLogic( pViewData->GetScrPos( nPosX, nPosY, + pViewData->GetActivePart() ) ); + PasteDraw( aPos, ScGlobal::GetClipModel() ); +} + +void ScViewFunc::PasteFromSystem() +{ + UpdateInputLine(); + + if (ScGlobal::IsClipCaptured()) + PasteFromClip( IDF_ALL ); + else if (ScGlobal::IsClipDraw()) + PasteDraw(); + else + { + SvDataObjectRef pClipObj = SvDataObject::PasteClipboard(); + if (pClipObj.Is()) + { + ULONG nBiff = Exchange::RegisterFormatName( + String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Biff5"))); + + // als erstes SvDraw-Model, dann Grafik + // (Grafik darf nur bei einzelner Grafik drinstehen) + + if (pClipObj->HasFormat( SOT_FORMATSTR_ID_DRAWING )) + PasteFromSystem( SOT_FORMATSTR_ID_DRAWING ); + else if (pClipObj->HasFormat( SOT_FORMATSTR_ID_SVXB )) + PasteFromSystem( SOT_FORMATSTR_ID_SVXB ); + else if (pClipObj->HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE )) + { + // Wenn es vom Writer kommt, statt OLE RTF einfuegen + + SvObjectDescriptor aDesc( pClipObj ); + // GlobalName vom Writer wie da in docsh.cxx + SvGlobalName aWriterName( SO3_SW_CLASSID ); + SvGlobalName aSwWebName( SO3_SWWEB_CLASSID ); + if ((aDesc.GetClassName() == aWriterName || aDesc.GetClassName() == aSwWebName) && + pClipObj->HasFormat(FORMAT_RTF)) + PasteFromSystem( FORMAT_RTF ); + else + PasteFromSystem( SOT_FORMATSTR_ID_EMBED_SOURCE ); + } + else if (pClipObj->HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE )) + PasteFromSystem( SOT_FORMATSTR_ID_LINK_SOURCE ); + else if (pClipObj->HasFormat(FORMAT_PRIVATE)) + PasteFromClip( IDF_ALL ); + else if (pClipObj->HasFormat(nBiff)) // before xxx_OLE formats + PasteFromSystem(nBiff); + else if (pClipObj->HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE )) + PasteFromSystem( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ); + else if (pClipObj->HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE_OLE )) + PasteFromSystem( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ); + else if (pClipObj->HasFormat(FORMAT_RTF)) + PasteFromSystem(FORMAT_RTF); + else if (pClipObj->HasFormat(SOT_FORMATSTR_ID_HTML)) + PasteFromSystem(SOT_FORMATSTR_ID_HTML); + else if (pClipObj->HasFormat(SOT_FORMATSTR_ID_HTML_SIMPLE)) + PasteFromSystem(SOT_FORMATSTR_ID_HTML_SIMPLE); + else if (pClipObj->HasFormat(SOT_FORMATSTR_ID_SYLK)) + PasteFromSystem(SOT_FORMATSTR_ID_SYLK); + else if (pClipObj->HasFormat(FORMAT_STRING)) + PasteFromSystem(FORMAT_STRING); + else if (pClipObj->HasFormat(FORMAT_GDIMETAFILE)) + PasteFromSystem(FORMAT_GDIMETAFILE); + else if (pClipObj->HasFormat(FORMAT_BITMAP)) + PasteFromSystem(FORMAT_BITMAP); +// else +// ErrorMessage(STR_PASTE_ERROR); + } +// else +// ErrorMessage(STR_PASTE_ERROR); + } + + // keine Fehlermeldung, weil SID_PASTE in der idl das FastCall-Flag hat, + // also auch gerufen wird, wenn nichts im Clipboard steht (#42531#) +} + +BOOL ScViewFunc::PasteFromSystem( ULONG nFormatId, BOOL bApi ) +{ + UpdateInputLine(); + + BOOL bRet = TRUE; + if ( nFormatId == 0 && ScGlobal::IsClipCaptured() ) + PasteFromClip( IDF_ALL ); + else + { + SvDataObjectRef pClipObj = SvDataObject::PasteClipboard(); + if (!pClipObj.Is()) + return FALSE; + + bRet = PasteDataFormat( nFormatId, pClipObj, + GetViewData()->GetCurX(), GetViewData()->GetCurY() ); + + if ( !bRet && !bApi ) + ErrorMessage(STR_PASTE_ERROR); + } + return bRet; +} + + +//---------------------------------------------------------------------------- +// P A S T E + +// Drag & Drop +BOOL ScViewFunc::PasteDataObject( SvDataObject* pObject, USHORT nPosX, USHORT nPosY, + Window* pWin, Point* pLogicPos ) +{ + ULONG nFormatId = 0; + + ULONG nSba = SOT_FORMATSTR_ID_SBA_DATAEXCHANGE; + ULONG nField = Exchange::RegisterFormatName( + String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(SBA_FIELDEXCHANGE_FORMAT))); + ULONG nDDE = SOT_FORMATSTR_ID_LINK; + ULONG nBiff = Exchange::RegisterFormatName( + String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Biff5"))); + + // eine DB-Tabelle aus dem Explorer hat Sba und Bookmark -> Bookmark nur wenn nicht Sba + + if ( INetBookmark::HasFormat(*pObject) && !pObject->HasFormat(nSba) ) + if (PasteBookmark( pObject, nPosX, nPosY )) + return TRUE; + + // als erstes SvDraw-Model, dann Grafik (darf nur bei einzelner Grafik drinstehen) + + if (pObject->HasFormat(SOT_FORMATSTR_ID_DRAWING)) + nFormatId = SOT_FORMATSTR_ID_DRAWING; + else if (pObject->HasFormat(SOT_FORMATSTR_ID_SVXB)) + nFormatId = SOT_FORMATSTR_ID_SVXB; + else if (pObject->HasFormat(SOT_FORMATSTR_ID_EMBED_SOURCE)) + { + // Wenn es vom Writer kommt, statt OLE RTF einfuegen + + SvObjectDescriptor aDesc( pObject ); + // GlobalName vom Writer wie da in docsh.cxx + SvGlobalName aWriterName( SO3_SW_CLASSID ); + SvGlobalName aSwWebName( SO3_SWWEB_CLASSID ); + if ((aDesc.GetClassName() == aWriterName || aDesc.GetClassName() == aSwWebName) && + pObject->HasFormat(FORMAT_RTF)) + nFormatId = FORMAT_RTF; + else + nFormatId = SOT_FORMATSTR_ID_EMBED_SOURCE; + } + else if (pObject->HasFormat(SOT_FORMATSTR_ID_LINK_SOURCE)) + nFormatId = SOT_FORMATSTR_ID_LINK_SOURCE; + else if (pObject->HasFormat(nSba)) // Sba muss vor RTF kommen, damit bei Daten aus dem + nFormatId = nSba; // Beamer importiert wird (RTF kopiert nur die Inhalte) + else if (pObject->HasFormat(nField)) + nFormatId = nField; + else if (pObject->HasFormat(nBiff)) // before xxx_OLE formats + nFormatId = nBiff; + else if (pObject->HasFormat(SOT_FORMATSTR_ID_EMBED_SOURCE_OLE)) + nFormatId = SOT_FORMATSTR_ID_EMBED_SOURCE_OLE; + else if (pObject->HasFormat(SOT_FORMATSTR_ID_LINK_SOURCE_OLE)) + nFormatId = SOT_FORMATSTR_ID_LINK_SOURCE_OLE; + else if (pObject->HasFormat(FORMAT_RTF)) + nFormatId = FORMAT_RTF; + else if (pObject->HasFormat(SOT_FORMATSTR_ID_HTML)) + nFormatId = SOT_FORMATSTR_ID_HTML; + else if (pObject->HasFormat(SOT_FORMATSTR_ID_HTML_SIMPLE)) + nFormatId = SOT_FORMATSTR_ID_HTML_SIMPLE; + else if (pObject->HasFormat(SOT_FORMATSTR_ID_SYLK)) + nFormatId = SOT_FORMATSTR_ID_SYLK; + else if (pObject->HasFormat(nDDE)) + nFormatId = nDDE; + else if (pObject->HasFormat(FORMAT_STRING)) + nFormatId = FORMAT_STRING; + else if (pObject->HasFormat(FORMAT_GDIMETAFILE)) + nFormatId = FORMAT_GDIMETAFILE; + else if (pObject->HasFormat(FORMAT_BITMAP)) + nFormatId = FORMAT_BITMAP; + else if (pObject->HasFormat(FORMAT_FILE)) + nFormatId = FORMAT_FILE; + + if (nFormatId) + return PasteDataFormat( nFormatId, pObject, nPosX, nPosY, pWin, pLogicPos ); + else + return FALSE; +} + +// Drag & Drop als Link +BOOL ScViewFunc::LinkDataObject( SvDataObject* pObject, USHORT nPosX, USHORT nPosY, + Window* pWin, Point* pLogicPos ) +{ + ULONG nFormatId = 0; + + // Links: nur OLE-Link / DDE + //! bei OLE-Link auch Unterscheidung, ob's vom Writer kommt ??? + + ULONG nDDE = SOT_FORMATSTR_ID_LINK; + + if (pObject->HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE )) + nFormatId = SOT_FORMATSTR_ID_LINK_SOURCE; + else if (pObject->HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE_OLE )) + nFormatId = SOT_FORMATSTR_ID_LINK_SOURCE_OLE; + else if (pObject->HasFormat(nDDE)) + nFormatId = nDDE; + + if (nFormatId) + return PasteDataFormat( nFormatId, pObject, nPosX, nPosY, pWin, pLogicPos ); + + if (pObject->HasFormat(FORMAT_FILE)) + { + SvData aData( FORMAT_FILE ); + if (pObject->GetData( &aData )) + { + // Datei als Link einfuegen + + String aFile; + aData.GetData( aFile ); + SfxStringItem aNameItem( FID_INSERT_FILE, aFile ); + Point aPos; + if (pLogicPos) aPos = *pLogicPos; + SfxPointItem aPosItem( FN_PARAM_1, aPos ); + SfxBoolItem aLinkItem( FN_PARAM_2, TRUE ); + SfxDispatcher* pDisp = GetViewData()->GetViewShell()->GetViewFrame()->GetDispatcher(); + if (pDisp) + pDisp->Execute( FID_INSERT_FILE, SFX_CALLMODE_ASYNCHRON, + &aNameItem, &aPosItem, &aLinkItem, 0L ); + return TRUE; + } + } + + // #66028# Internet Explorer draggt URLs als Link + if ( INetBookmark::HasFormat(*pObject) ) + if (PasteBookmark( pObject, nPosX, nPosY )) + return TRUE; + + return FALSE; +} + +BOOL ScViewFunc::PasteOnDrawObject( SvDataObject* pObject, SdrObject* pHitObj, BOOL bLink ) +{ + BOOL bRet = FALSE; + if ( bLink ) + { + if ( pObject->HasFormat(SOT_FORMATSTR_ID_SVXB) ) + { + SvData aData(SOT_FORMATSTR_ID_SVXB); + if ( pObject->GetData( &aData ) ) + { + Graphic* pGraphic = NULL; + if ( aData.GetData( (SvDataCopyStream**) &pGraphic, + Graphic::StaticType(), TRANSFER_MOVE ) ) + { + bRet = ApplyGraphicToObject( pHitObj, *pGraphic ); + } + delete pGraphic; + } + } + else if ( pObject->HasFormat(FORMAT_GDIMETAFILE) ) + { + SvData aData(FORMAT_GDIMETAFILE); + if ( pObject->GetData( &aData ) ) + { + GDIMetaFile* pMtf = NULL; + if (aData.GetData(&pMtf, TRANSFER_MOVE)) + { + bRet = ApplyGraphicToObject( pHitObj, Graphic(*pMtf) ); + } + delete pMtf; + } + } + else if ( pObject->HasFormat(FORMAT_BITMAP) ) + { + SvData aData(FORMAT_BITMAP); + if ( pObject->GetData( &aData ) ) + { + Bitmap* pBmp = NULL; + if (aData.GetData(&pBmp, TRANSFER_MOVE)) + { + bRet = ApplyGraphicToObject( pHitObj, Graphic(*pBmp) ); + } + delete pBmp; + } + } + } + else + { + // ham' wa noch nich + } + return bRet; +} + +// +// Einfuegen auf Tabelle: +// + +// internes Paste + +BOOL ScViewFunc::PasteFromClip( USHORT nFlags, ScDocument* pClipDoc, + USHORT nFunction, BOOL bSkipEmpty, + BOOL bTranspose, BOOL bAsLink, + InsCellCmd eMoveMode, USHORT nUndoExtraFlags ) +{ + if (!pClipDoc) + pClipDoc = ScGlobal::GetClipDoc(); + + // fuer Undo etc. immer alle oder keine Inhalte sichern + USHORT nContFlags = IDF_NONE; + if (nFlags & IDF_CONTENTS) + nContFlags |= IDF_CONTENTS; + if (nFlags & IDF_ATTRIB) + nContFlags |= IDF_ATTRIB; + // evtl. Attribute ins Undo ohne sie vom Clip ins Doc zu kopieren + USHORT nUndoFlags = nContFlags; + if (nUndoExtraFlags & IDF_ATTRIB) + nUndoFlags |= IDF_ATTRIB; + + BOOL bCutMode = pClipDoc->IsCutMode(); // bei Transpose aus dem Original-Clipdoc + + ScDocument* pOrigClipDoc = NULL; + ScDocument* pTransClip = NULL; + if ( bTranspose ) + { + USHORT nX,nY; + pClipDoc->GetClipArea( nX, nY ); + if ( nY > MAXCOL ) // zuviele Zeilen zum Transponieren + { + ErrorMessage(STR_PASTE_FULL); + return FALSE; + } + pOrigClipDoc = pClipDoc; // fuer Referenzen + + pTransClip = new ScDocument( SCDOCMODE_CLIP ); + pClipDoc->TransposeClip( pTransClip, nFlags, bAsLink ); + pClipDoc = pTransClip; + } + + const BOOL bRecord = TRUE; + + USHORT nStartCol; + USHORT nStartRow; + USHORT nStartTab; + USHORT nEndCol; + USHORT nEndRow; + USHORT nEndTab; + USHORT nClipSizeX; + USHORT nClipSizeY; + pClipDoc->GetClipArea( nClipSizeX, nClipSizeY ); + + ScDocument* pDoc = GetViewData()->GetDocument(); + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + SfxUndoManager* pUndoMgr = pDocSh->GetUndoManager(); + + ScDocShellModificator aModificator( *pDocSh ); + + if ( rMark.IsMultiMarked() ) + { + rMark.MarkToSimple(); + if ( rMark.IsMultiMarked() ) + { // "Einfuegen auf Mehrfachselektion nicht moeglich" + ErrorMessage(STR_MSSG_PASTEFROMCLIP_0); + delete pTransClip; + return FALSE; + } + } + + USHORT nMarkAddX = 0; + USHORT nMarkAddY = 0; + + if ( rMark.IsMarked() ) + { + ScRange aMarkRange; + rMark.GetMarkArea( aMarkRange ); + nStartCol = aMarkRange.aStart.Col(); + nStartRow = aMarkRange.aStart.Row(); + nStartTab = aMarkRange.aStart.Tab(); + nEndCol = aMarkRange.aEnd.Col(); + nEndRow = aMarkRange.aEnd.Row(); + nEndTab = aMarkRange.aEnd.Tab(); + USHORT nBlockAddX = nEndCol-nStartCol; + USHORT nBlockAddY = nEndRow-nStartRow; + + // #58422# Nachfrage, wenn die Selektion groesser als 1 Zeile/Spalte, aber kleiner + // als das Clipboard ist (dann wird ueber die Selektion hinaus eingefuegt) + + // ClipSize ist nicht Groesse, sondern Differenz + if ( ( nBlockAddX && nBlockAddX < nClipSizeX ) || + ( nBlockAddY && nBlockAddY < nClipSizeY ) ) + { + ScWaitCursorOff aWaitOff( GetFrameWin() ); + String aMessage = ScGlobal::GetRscString( STR_PASTE_BIGGER ); + QueryBox aBox( GetViewData()->GetDialogParent(), + WinBits(WB_YES_NO | WB_DEF_NO), aMessage ); + if ( aBox.Execute() != RET_YES ) + { + delete pTransClip; + return FALSE; + } + } + + if (nBlockAddX > nClipSizeX) + nMarkAddX = nBlockAddX - nClipSizeX; // fuer Merge-Test + else + nEndCol = nStartCol + nClipSizeX; + + if (nBlockAddY > nClipSizeY) + nMarkAddY = nBlockAddY - nClipSizeY; // fuer Merge-Test + else + nEndRow = nStartRow + nClipSizeY; + } + else + { + nStartCol = GetViewData()->GetCurX(); + nStartRow = GetViewData()->GetCurY(); + nStartTab = GetViewData()->GetTabNo(); + nEndCol = nStartCol + nClipSizeX; + nEndRow = nStartRow + nClipSizeY; + nEndTab = nStartTab; + } + + // Zielbereich, wie er angezeigt wird: + ScRange aUserRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab ); + + // Sollen Zellen eingefuegt werden? + // (zu grosse nEndCol/nEndRow werden weiter unten erkannt) + BOOL bInsertCells = ( eMoveMode != INS_NONE && nEndCol <= MAXCOL && nEndRow <= MAXROW ); + if ( bInsertCells ) + { + String aUndo = ScGlobal::GetRscString( STR_UNDO_PASTE ); + pUndoMgr->EnterListAction( aUndo, aUndo ); + + MarkRange( aUserRange ); // wird vor CopyFromClip sowieso gesetzt + + // #72930# CutMode is reset on insertion of cols/rows but needed again on cell move + BOOL bCut = pClipDoc->IsCutMode(); + if (!InsertCells( eMoveMode )) // kann eingefuegt werden? + { + delete pTransClip; // abbrechen + pUndoMgr->LeaveListAction(); + return FALSE; + } + if ( bCut ) + pClipDoc->SetCutMode( bCut ); + } + + USHORT nClipStartX; // Clipboard-Bereich erweitern + USHORT nClipStartY; + pClipDoc->GetClipStart( nClipStartX, nClipStartY ); + USHORT nUndoEndCol = nClipStartX + nClipSizeX; + USHORT nUndoEndRow = nClipStartY + nClipSizeY; + BOOL bClipOver = pClipDoc-> + ExtendMerge( nClipStartX,nClipStartY, nUndoEndCol,nUndoEndRow, nStartTab, FALSE ); + nUndoEndCol -= nClipStartX + nClipSizeX; + nUndoEndRow -= nClipStartY + nClipSizeY; + nUndoEndCol += nEndCol; + nUndoEndRow += nEndRow; // Bereich in Zielkoordinaten + +// if (nUndoEndCol < nEndCol) nUndoEndCol = nEndCol; +// if (nUndoEndRow < nEndRow) nUndoEndRow = nEndRow; + +// nUndoEndCol += nMarkAddX; +// nUndoEndRow += nMarkAddY; + + if (nUndoEndCol>MAXCOL || nUndoEndRow>MAXROW) + { + ErrorMessage(STR_PASTE_FULL); + delete pTransClip; + if ( bInsertCells ) + pUndoMgr->LeaveListAction(); + return FALSE; + } + + pDoc->ExtendMerge( nStartCol,nStartRow, nUndoEndCol,nUndoEndRow, nStartTab, FALSE ); + + // Test auf Zellschutz + + if (!pDoc->IsBlockEditable( nStartTab, nStartCol,nStartRow, nUndoEndCol,nUndoEndRow )) + { + ErrorMessage(STR_PROTECTIONERR); + delete pTransClip; + if ( bInsertCells ) + pUndoMgr->LeaveListAction(); + return FALSE; + } + + //! Test auf Ueberlappung + //! nur wirkliche Schnittmenge testen !!!!!!! + + // pDoc->HasCommonAttr( StartCol,nStartRow, nUndoEndCol,nUndoEndRow, nStartTab, + // pClipDoc, nClipStartX, nClipStartY ); + + if (bClipOver) + if (pDoc->HasAttrib( nStartCol,nStartRow,nStartTab, nUndoEndCol,nUndoEndRow,nStartTab, + HASATTR_OVERLAPPED )) + { // "Zusammenfassen nicht verschachteln !" + ErrorMessage(STR_MSSG_PASTEFROMCLIP_1); + delete pTransClip; + if ( bInsertCells ) + pUndoMgr->LeaveListAction(); + return FALSE; + } + + if ( !bCutMode ) + { + ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); + if ( pChangeTrack ) + pChangeTrack->ResetLastCut(); // kein CutMode mehr + } + + BOOL bColInfo = ( nStartRow==0 && nEndRow==MAXROW ); + BOOL bRowInfo = ( nStartCol==0 && nEndCol==MAXCOL ); + + ScDocument* pUndoDoc = NULL; + ScDocument* pRefUndoDoc = NULL; + ScDocument* pRedoDoc = NULL; + ScRangeName* pUndoRange = NULL; + ScRangeName* pRedoRange = NULL; + ScDBCollection* pUndoDB = NULL; + ScDBCollection* pRedoDB = NULL; + + if ( bRecord ) + { + pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + pUndoDoc->InitUndo( pDoc, nStartTab, nEndTab, bColInfo, bRowInfo ); + pDoc->CopyToDocument( nStartCol, nStartRow, nStartTab, nUndoEndCol, nUndoEndRow, nEndTab, + nUndoFlags, FALSE, pUndoDoc ); + + if ( bCutMode ) + { + pRefUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + pRefUndoDoc->InitUndo( pDoc, 0, pDoc->GetTableCount()-1, FALSE, FALSE ); + + ScRangeName* pDocRange = pDoc->GetRangeName(); + if (pDocRange->GetCount()) + pUndoRange = new ScRangeName( *pDocRange ); + ScDBCollection* pDocDB = pDoc->GetDBCollection(); + if (pDocDB->GetCount()) + pUndoDB = new ScDBCollection( *pDocDB ); + } + } + + // waren vorher Linien da? + USHORT nExtFlags = 0; + if (pDoc->HasAttrib( nStartCol,nStartRow,nStartTab, nEndCol,nEndRow,nEndTab, HASATTR_PAINTEXT )) + nExtFlags |= SC_PF_LINES; + + if (GetViewData()->IsActive()) + { + DoneBlockMode(); + InitOwnBlockMode(); + } + rMark.SetMarkArea( aUserRange ); + + HideCursor(); // Cursor aendert sich ! + + // + // Aus Clipboard kopieren, + // wenn gerechnet werden soll, Originaldaten merken + // + + ScDocument* pMixDoc = NULL; + if ( bSkipEmpty || nFunction ) + { + if ( nFlags & IDF_CONTENTS ) + { + pMixDoc = new ScDocument( SCDOCMODE_UNDO ); + pMixDoc->InitUndo( pDoc, nStartTab, nEndTab ); + pDoc->CopyToDocument( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab, + IDF_CONTENTS, FALSE, pMixDoc ); + } + } + + if (!bAsLink) + { + // normal kopieren + pDoc->CopyFromClip( aUserRange, rMark, nFlags, pRefUndoDoc, pClipDoc ); // Original-Bereich + + // bei Transpose Referenzen per Hand anpassen + if ( bTranspose && bCutMode && (nFlags & IDF_CONTENTS) ) + pDoc->UpdateTranspose( aUserRange.aStart, pOrigClipDoc, rMark, pRefUndoDoc ); + } + else if (!bTranspose) + { + // kopieren mit bAsLink=TRUE + pDoc->CopyFromClip( aUserRange, rMark, nFlags, pRefUndoDoc, pClipDoc, TRUE, TRUE ); + } + else + { + // alle Inhalte kopieren (im TransClipDoc stehen nur Formeln) + pDoc->CopyFromClip( aUserRange, rMark, nContFlags, pRefUndoDoc, pClipDoc ); + } + pDoc->ExtendMerge( nStartCol, nStartRow, nEndCol, nEndRow, nStartTab, TRUE ); // Refresh + // und Bereich neu + + if ( pMixDoc ) // Rechenfunktionen mit Original-Daten auszufuehren ? + { + pDoc->MixDocument( aUserRange, nFunction, bSkipEmpty, pMixDoc ); + } + delete pMixDoc; + + // + // + // + + // sind hinterher Linien da? + if (!nExtFlags & SC_PF_LINES) + if (pDoc->HasAttrib( nStartCol,nStartRow,nStartTab, nEndCol,nEndRow,nEndTab, HASATTR_PAINTEXT )) + nExtFlags |= SC_PF_LINES; + + // ggf. Autofilter-Koepfe loeschen + if (bCutMode) + if (pDoc->RefreshAutoFilter( nClipStartX,nClipStartY, nClipStartX+nClipSizeX, + nClipStartY+nClipSizeY, nStartTab )) + pDocSh->PostPaint( nClipStartX,nClipStartY,nStartTab, + nClipStartX+nClipSizeX,nClipStartY,nStartTab, + PAINT_GRID ); + + ShowCursor(); // Cursor aendert sich ! + + //! Block-Bereich bei RefUndoDoc weglassen !!! + + if ( bRecord ) + { + // Redo-Daten werden erst beim ersten Undo kopiert + // ohne RefUndoDoc muss das Redo-Doc noch nicht angelegt werden + + if (pRefUndoDoc) + { + pRedoDoc = new ScDocument( SCDOCMODE_UNDO ); + pRedoDoc->InitUndo( pDoc, nStartTab, nEndTab, bColInfo, bRowInfo ); + + // angepasste Referenzen ins Redo-Doc + + USHORT nTabCount = pDoc->GetTableCount(); + pRedoDoc->AddUndoTab( 0, nTabCount-1 ); + pDoc->CopyUpdated( pRefUndoDoc, pRedoDoc ); + + // alte Referenzen ins Undo-Doc + + //! Tabellen selektieren ? + pUndoDoc->AddUndoTab( 0, nTabCount-1 ); + pRefUndoDoc->DeleteArea( nStartCol, nStartRow, nEndCol, nEndRow, rMark, IDF_ALL ); + pRefUndoDoc->CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTabCount-1, + IDF_FORMULA, FALSE, pUndoDoc ); + delete pRefUndoDoc; + } + + if ( bCutMode ) + { + if ( pUndoRange ) + pRedoRange = new ScRangeName( *pDoc->GetRangeName() ); + if ( pUndoDB ) + pRedoDB = new ScDBCollection( *pDoc->GetDBCollection() ); + } + + //! testen, ob Bereich wirklich geaendert + + pUndoMgr->AddUndoAction( + new ScUndoPaste( pDocSh, + nStartCol, nStartRow, nStartTab, + nUndoEndCol, nUndoEndRow, nEndTab, rMark, + pUndoDoc, pRedoDoc, nFlags | nUndoFlags, + pUndoRange, pRedoRange, pUndoDB, pRedoDB, + FALSE ) ); // FALSE = Redo-Daten sind nicht kopiert + } + + if ( bInsertCells ) + pUndoMgr->LeaveListAction(); + + USHORT nPaint = PAINT_GRID; + if (bColInfo) + { + nPaint |= PAINT_TOP; + nUndoEndCol = MAXCOL; // nur zum Zeichnen ! + } + if (bRowInfo) + { + nPaint |= PAINT_LEFT; + nUndoEndRow = MAXROW; // nur zum Zeichnen ! + } + pDocSh->PostPaint( nStartCol, nStartRow, nStartTab, + nUndoEndCol, nUndoEndRow, nEndTab, nPaint, nExtFlags ); + AdjustBlockHeight(); //! Paint/Undo ? + aModificator.SetDocumentModified(); + pDocSh->UpdateOle(GetViewData()); + + SelectionChanged(); + + delete pTransClip; + return TRUE; +} + + +//---------------------------------------------------------------------------- +// D R A G A N D D R O P +// +// innerhalb des Dokuments + +void ScViewFunc::MoveBlockTo( const ScRange& rSource, const ScAddress& rDestPos, + BOOL bCut, BOOL bRecord, BOOL bPaint ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + HideAllCursors(); // wegen zusammengefassten + BOOL bSuccess = pDocSh->GetDocFunc().MoveBlock( + rSource, rDestPos, bCut, bRecord, bPaint, FALSE ); + ShowAllCursors(); + if (bSuccess) + { + // Zielbereich markieren + ScAddress aDestEnd( + rDestPos.Col() + rSource.aEnd.Col() - rSource.aStart.Col(), + rDestPos.Row() + rSource.aEnd.Row() - rSource.aStart.Row(), + rDestPos.Tab() ); + MarkRange( ScRange( rDestPos, aDestEnd ), FALSE ); //! FALSE ??? + + pDocSh->UpdateOle(GetViewData()); + SelectionChanged(); + } +} + +// Link innerhalb des Dokuments + +void ScViewFunc::LinkBlock( const ScRange& rSource, const ScAddress& rDestPos ) +{ + // Test auf Ueberlappung + + if ( rSource.aStart.Tab() == rDestPos.Tab() ) + { + USHORT nDestEndCol = rDestPos.Col() + ( rSource.aEnd.Col() - rSource.aStart.Col() ); + USHORT nDestEndRow = rDestPos.Row() + ( rSource.aEnd.Row() - rSource.aStart.Row() ); + + if ( rSource.aStart.Col() <= nDestEndCol && rDestPos.Col() <= rSource.aEnd.Col() && + rSource.aStart.Row() <= nDestEndRow && rDestPos.Row() <= rSource.aEnd.Row() ) + { + ErrorMessage( STR_ERR_LINKOVERLAP ); + return; + } + } + + // Ausfuehren per Paste + + ScDocument* pDoc = GetViewData()->GetDocument(); + ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP ); + pDoc->CopyTabToClip( rSource.aStart.Col(), rSource.aStart.Row(), + rSource.aEnd.Col(), rSource.aEnd.Row(), + rSource.aStart.Tab(), pClipDoc ); + + // Zielbereich markieren (Cursor setzen, keine Markierung) + + if ( GetViewData()->GetTabNo() != rDestPos.Tab() ) + SetTabNo( rDestPos.Tab() ); + + MoveCursorAbs( rDestPos.Col(), rDestPos.Row(), SC_FOLLOW_NONE, FALSE, FALSE ); + + // Paste + + PasteFromClip( IDF_ALL, pClipDoc, PASTE_NOFUNC, FALSE, FALSE, TRUE ); // als Link + + delete pClipDoc; +} + + + + diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx new file mode 100644 index 000000000000..e1c910c25a70 --- /dev/null +++ b/sc/source/ui/view/viewfun4.cxx @@ -0,0 +1,765 @@ +/************************************************************************* + * + * $RCSfile: viewfun4.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" + +#ifndef _EEITEM_HXX //autogen +#include <svx/eeitem.hxx> +#endif + +#define ITEMID_FIELD EE_FEATURE_FIELD +#include <svx/editobj.hxx> +#include <svx/editstat.hxx> +#include <svx/editview.hxx> +#include <svx/flditem.hxx> +#include <svx/hlnkitem.hxx> +#include <svx/langitem.hxx> +#include <svx/langtab.hxx> +#include <svx/svxerr.hxx> +#include <svx/impgrf.hxx> +#include <so3/ipobj.hxx> +#include <so3/svstor.hxx> +#include <offmgr/app.hxx> + +#ifdef ONE_LINGU +#else +#include <offmgr/osplcfg.hxx> +#endif + +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/docfile.hxx> +#include <sfx2/fcontnr.hxx> +#include <sfx2/inimgr.hxx> +#include <svtools/filter.hxx> +#include <svtools/iniman.hxx> +#include <svtools/stritem.hxx> +#include <svtools/urlbmk.hxx> +#include <vcl/drag.hxx> +#include <vcl/system.hxx> +#include <vcl/msgbox.hxx> +#ifndef _URLOBJ_HXX +#include <tools/urlobj.hxx> +#endif + +#include "viewfunc.hxx" +#include "docsh.hxx" +#include "docsh.hxx" +#include "document.hxx" +#include "docpool.hxx" +#include "globstr.hrc" +#include "global.hxx" +#include "undoblk.hxx" +#include "undocell.hxx" +#include "cell.hxx" +#include "scmod.hxx" +#include "spelleng.hxx" +#include "patattr.hxx" +#include "sc.hrc" +#include "tabvwsh.hxx" +#include "impex.hxx" +#include "editutil.hxx" + +// STATIC DATA ----------------------------------------------------------- + +BOOL bPasteIsDrop = FALSE; + +//================================================================== + +void ScViewFunc::PasteRTF( USHORT nStartCol, USHORT nStartRow, SvDataObject* pObject ) +{ + if ( pObject->HasFormat( EditEngine::RegisterClipboardFormatName() ) ) + { // EditEngine eigen wg. Drag&Drop und PasteSpecial + HideAllCursors(); + + const BOOL bRecord = TRUE; + ScDocument* pUndoDoc = NULL; + + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + USHORT nTab = GetViewData()->GetTabNo(); + + const ScPatternAttr* pPattern = pDoc->GetPattern( nStartCol, nStartRow, nTab ); + ScTabEditEngine* pEngine = new ScTabEditEngine( *pPattern, pDoc->GetEnginePool() ); + pEngine->EnableUndo( FALSE ); + + Window* pActWin = GetActiveWin(); + if (pActWin) + { + pEngine->SetPaperSize(Size(100000,100000)); + Window aWin( pActWin ); + EditView aEditView( pEngine, &aWin ); + aEditView.SetOutputArea(Rectangle(0,0,100000,100000)); + + if (bPasteIsDrop) + { + DropEvent aDropEvt; + if (aEditView.QueryDrop( aDropEvt )) + aEditView.Drop( aDropEvt ); + } + else + aEditView.PasteSpecial(); + } + + ULONG nParCnt = pEngine->GetParagraphCount(); + if (nParCnt) + { + USHORT nEndRow = nStartRow + (USHORT) nParCnt - 1; + if (nEndRow > MAXROW) + nEndRow = MAXROW; + + if (bRecord) + { + pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + pUndoDoc->InitUndo( pDoc, nTab, nTab ); + pDoc->CopyToDocument( nStartCol,nStartRow,nTab, nStartCol,nEndRow,nTab, IDF_ALL, FALSE, pUndoDoc ); + } + + USHORT nRow = nStartRow; + for( USHORT n = 0; n < nParCnt; n++ ) + { + EditTextObject* pObject = pEngine->CreateTextObject( n ); + EnterData( nStartCol, nRow, nTab, pObject, FALSE, TRUE ); + // kein Undo, auf einfache Strings testen + delete pObject; + if( ++nRow > MAXROW ) + break; + } + + if (bRecord) + { + ScDocument* pRedoDoc = new ScDocument( SCDOCMODE_UNDO ); + pRedoDoc->InitUndo( pDoc, nTab, nTab ); + pDoc->CopyToDocument( nStartCol,nStartRow,nTab, nStartCol,nEndRow,nTab, IDF_ALL, FALSE, pRedoDoc ); + + ScMarkData aDestMark; + aDestMark.SelectOneTable( nTab ); + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoPaste( pDocSh, nStartCol,nStartRow,nTab, nStartCol,nEndRow,nTab, + aDestMark, + pUndoDoc, pRedoDoc, IDF_ALL, NULL,NULL,NULL,NULL ) ); + } + } + + delete pEngine; + + ShowAllCursors(); + } + else + { + SvData aData( FORMAT_RTF ); + if (pObject->GetData( &aData )) + { + HideAllCursors(); + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScImportExport aImpEx( pDocSh->GetDocument(), + ScAddress( nStartCol, nStartRow, GetViewData()->GetTabNo() ) ); + aImpEx.ImportData( aData ); + AdjustRowHeight( nStartRow, aImpEx.GetRange().aEnd.Row() ); + pDocSh->UpdateOle(GetViewData()); + ShowAllCursors(); + } + } +} + +// Thesaurus - Undo ok +void ScViewFunc::DoThesaurus( BOOL bRecord ) +{ + USHORT nCol, nRow, nTab; + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + ScSplitPos eWhich = GetViewData()->GetActivePart(); + LanguageType eLnge; + CellType eCellType; + EESpellState eState; + String sOldText, sNewString; + EditTextObject* pOldTObj = NULL; + const EditTextObject* pTObject = NULL; + ScBaseCell* pCell = NULL; + EditView* pEditView = NULL; + ESelection* pEditSel = NULL; + ScEditEngineDefaulter* pThesaurusEngine; + BOOL bIsEditMode = GetViewData()->HasEditView(eWhich); + if (bIsEditMode) // Edit-Mode aktiv + { + GetViewData()->GetEditView(eWhich, pEditView, nCol, nRow); + pEditSel = new ESelection(pEditView->GetSelection()); + SC_MOD()->InputEnterHandler(); + SFX_BINDINGS().Update(); // sonst kommt der Sfx durcheinander... + } + else + { + nCol = GetViewData()->GetCurX(); + nRow = GetViewData()->GetCurY(); + } + nTab = GetViewData()->GetTabNo(); + + if (!pDoc->IsSelectedBlockEditable( nCol, nRow, nCol, nRow, rMark )) + { + ErrorMessage(STR_PROTECTIONERR); + delete pEditSel; + return; + } + pDoc->GetCellType(nCol, nRow, nTab, eCellType); + if (eCellType != CELLTYPE_STRING && eCellType != CELLTYPE_EDIT) + { + ErrorMessage(STR_THESAURUS_NO_STRING); + return; + } + +#ifdef ONE_LINGU + com::sun::star::uno::Reference<com::sun::star::linguistic::XSpellChecker1> + xSpeller = OFF_APP()->GetSpellChecker(); + //! test if thesaurus is available? (STR_EXPORT_ASCII_WARNING) +#else + SpellCheck& rOptSpellCheck = *OFF_APP()->GetSpellChecker(); + if(!rOptSpellCheck.LoadDll()) // Speller da? + { + ErrorMessage(STR_EXPORT_ASCII_WARNING); //! haeh ??? + delete pEditSel; + return; + } +#endif + + const SfxPoolItem* pItem = pDoc->GetAttr(nCol, nRow, nTab, ATTR_FONT_LANGUAGE); + SvxLanguageItem* pLangIt = PTR_CAST( SvxLanguageItem, pItem ); + if (pLangIt) + { + eLnge = (LanguageType) pLangIt->GetValue(); +#ifdef ONE_LINGU + if (eLnge == LANGUAGE_DONTKNOW) //! can this happen? + eLnge = pDoc->GetLanguage(); +#else + if (eLnge == LANGUAGE_DONTKNOW) + eLnge = (LanguageType) rOptSpellCheck.GetDefaultLanguage(); +#endif + } + else + eLnge = LANGUAGE_ENGLISH_US; + if ( eLnge == LANGUAGE_SYSTEM ) + eLnge = System::GetLanguage(); // Spelling nie mit SYSTEM + + pThesaurusEngine = new ScEditEngineDefaulter( pDoc->GetEnginePool() ); + pThesaurusEngine->SetEditTextObjectPool( pDoc->GetEditPool() ); + pThesaurusEngine->SetRefDevice(GetViewData()->GetActiveWin()); +#ifdef ONE_LINGU + pThesaurusEngine->SetSpeller(xSpeller); +#else + pThesaurusEngine->SetSpeller(&rOptSpellCheck); +#endif + MakeEditView(pThesaurusEngine, nCol, nRow ); + const ScPatternAttr* pPattern = NULL; + SfxItemSet* pEditDefaults = new SfxItemSet(pThesaurusEngine->GetEmptyItemSet()); + pPattern = pDoc->GetPattern(nCol, nRow, nTab); + if (pPattern ) + { + pPattern->FillEditItemSet( pEditDefaults ); + pThesaurusEngine->SetDefaults( *pEditDefaults ); + } + + if (eCellType == CELLTYPE_STRING) + { + pDoc->GetString(nCol, nRow, nTab, sOldText); + pThesaurusEngine->SetText(sOldText); + } + else if (eCellType == CELLTYPE_EDIT) + { + pDoc->GetCell(nCol, nRow, nTab, pCell); + if (pCell) + { + ((ScEditCell*) pCell)->GetData(pTObject); + pOldTObj = pTObject->Clone(); + if (pTObject) + pThesaurusEngine->SetText(*pTObject); + } + } + else + { + DBG_ERROR("DoThesaurus: Keine String oder Editzelle"); + } + pEditView = GetViewData()->GetEditView(GetViewData()->GetActivePart());; + if (pEditSel) + pEditView->SetSelection(*pEditSel); + else + pEditView->SetSelection(ESelection(0,0,0,0)); + + pThesaurusEngine->ClearModifyFlag(); + + eState = pEditView->StartThesaurus( eLnge ); + DBG_ASSERT(eState != EE_SPELL_NOSPELLER, "No SpellChecker"); + + if (eState == EE_SPELL_ERRORFOUND) // sollte spaeter durch Wrapper geschehen! + { + SvxLanguageTable aLangTab; + String aErr = aLangTab.GetString(eLnge); + aErr += ScGlobal::GetRscString( STR_SPELLING_NO_LANG ); + InfoBox aBox( GetViewData()->GetDialogParent(), aErr ); + aBox.Execute(); + } + if (pThesaurusEngine->IsModified()) + { + EditTextObject* pNewTObj = NULL; + if (pCell && pTObject) + { + pNewTObj = pThesaurusEngine->CreateTextObject(); + pCell = new ScEditCell( pNewTObj, pDoc, + pThesaurusEngine->GetEditTextObjectPool() ); + pDoc->PutCell( nCol, nRow, nTab, pCell ); + } + else + { + sNewString = pThesaurusEngine->GetText(); + pDoc->SetString(nCol, nRow, nTab, sNewString); + } +// erack! it's broadcasted +// pDoc->SetDirty(); + pDocSh->SetDocumentModified(); + if (bRecord) + { + GetViewData()->GetDocShell()->GetUndoManager()->AddUndoAction( + new ScUndoThesaurus( GetViewData()->GetDocShell(), + nCol, nRow, nTab, + sOldText, pOldTObj, sNewString, pNewTObj)); + } + delete pNewTObj; + } + KillEditView(TRUE); + delete pEditDefaults; + delete pThesaurusEngine; + delete pOldTObj; + delete pEditSel; + pDocSh->PostPaintGridAll(); +} + +// Spelling Checker - Undo ok +void ScViewFunc::DoSpellingChecker( BOOL bRecord ) +{ + USHORT nCol, nRow, nTab; + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + ScSplitPos eWhich = GetViewData()->GetActivePart(); + EESpellState eState; + EditView* pEditView = NULL; + ESelection* pEditSel = NULL; + ScSpellingEngine* pSpellingEngine = NULL; + BOOL bIsEditMode = GetViewData()->HasEditView(eWhich); + if (bIsEditMode) // Edit-Mode aktiv + { + GetViewData()->GetEditView(eWhich, pEditView, nCol, nRow); + pEditSel = new ESelection(pEditView->GetSelection()); + SC_MOD()->InputEnterHandler(); + } + else + { + nCol = GetViewData()->GetCurX(); + nRow = GetViewData()->GetCurY(); + + AlignToCursor( nCol, nRow, SC_FOLLOW_JUMP); + } + nTab = GetViewData()->GetTabNo(); + + rMark.MarkToMulti(); + BOOL bMarked = rMark.IsMultiMarked(); + if (bMarked && !pDoc->IsSelectionEditable(rMark)) + { + ErrorMessage(STR_PROTECTIONERR); + delete pEditSel; + return; + } + + ScDocument* pUndoDoc = NULL; + ScDocument* pRedoDoc = NULL; + if (bRecord) + { + pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + pUndoDoc->InitUndo( pDoc, nTab, nTab ); + pRedoDoc = new ScDocument( SCDOCMODE_UNDO ); + pRedoDoc->InitUndo( pDoc, nTab, nTab ); + + if ( rMark.GetSelectCount() > 1 ) + { + USHORT nTabCount = pDoc->GetTableCount(); + for (USHORT i=0; i<nTabCount; i++) + if ( rMark.GetTableSelect(i) && i != nTab ) + { + pUndoDoc->AddUndoTab( i, i ); + pRedoDoc->AddUndoTab( i, i ); + } + } + } + +#ifdef ONE_LINGU + //! no way to set a spelling error handler + com::sun::star::uno::Reference<com::sun::star::linguistic::XSpellChecker1> + xSpeller = OFF_APP()->GetSpellChecker(); +#else + SpellCheck& rOptSpellCheck = *OFF_APP()->GetSpellChecker(); + if(!rOptSpellCheck.LoadDll()) + { + ErrorMessage(STR_IMPORT_ERROR); //! haeh? + delete pEditSel; + delete pUndoDoc; + delete pRedoDoc; + return; + } +#endif + + // ab hier kein return mehr + + BOOL bOldDis = pDoc->IsIdleDisabled(); + pDoc->DisableIdle(TRUE); // nicht mit Online-Spelling durcheinanderkommen (#42726#) + +#ifdef ONE_LINGU +#else + // ErrorLink setzen, alten merken + Link aOldLnk = rOptSpellCheck.ChgErrorLink( + LINK(this, ScViewFunc, SpellError)); +#endif + pSpellingEngine = new ScSpellingEngine( pDoc->GetEnginePool(), + GetViewData(), pUndoDoc, pRedoDoc, + nCol, nRow, nTab, + bMarked, LANGUAGE_ENGLISH_US, pEditSel); +#ifdef ONE_LINGU + pSpellingEngine->SetSpeller(xSpeller); +#else + pSpellingEngine->SetSpeller(&rOptSpellCheck); +#endif + MakeEditView(pSpellingEngine, nCol, nRow ); + pSpellingEngine->SetRefDevice(GetViewData()->GetActiveWin()); + // dummy Zelle simulieren: + pEditView = GetViewData()->GetEditView(GetViewData()->GetActivePart()); + GetViewData()->SetSpellingView(pEditView); + Rectangle aRect(Point(0,0), Point(0,0)); + pEditView->SetOutputArea(aRect); + pSpellingEngine->SetControlWord( EE_CNTRL_USECHARATTRIBS ); + pSpellingEngine->EnableUndo( FALSE ); + pSpellingEngine->SetPaperSize( aRect.GetSize() ); + pSpellingEngine->SetText(EMPTY_STRING); + + pSpellingEngine->ClearModifyFlag(); + BOOL bFound = pSpellingEngine->SpellNextDocument(); // erste Zelle holen + + if (bFound) + eState = pEditView->StartSpeller( pSpellingEngine->GetLanguage(), TRUE ); + else + eState = EE_SPELL_OK; // Bereich war leer + + DBG_ASSERT(eState != EE_SPELL_NOSPELLER, "No SpellChecker"); + if (eState == EE_SPELL_NOLANGUAGE) + { + ErrorMessage(STR_NOLANGERR); + } + if (pSpellingEngine->IsModifiedAtAll()) + { + if (bRecord) + { + USHORT nNewCol = GetViewData()->GetCurX(); + USHORT nNewRow = GetViewData()->GetCurY(); + GetViewData()->GetDocShell()->GetUndoManager()->AddUndoAction( + new ScUndoSpelling( GetViewData()->GetDocShell(), + rMark, + nCol, nRow, nTab, + pUndoDoc, + nNewCol, nNewRow, nTab, + pRedoDoc ) ); + } + pDoc->SetDirty(); + pDocSh->SetDocumentModified(); + } + else + { + delete pUndoDoc; + delete pRedoDoc; + } +#ifdef ONE_LINGU +#else + // alten ErrorLink wiederherstellen + rOptSpellCheck.ChgErrorLink( aOldLnk ); +#endif + GetViewData()->SetSpellingView( NULL ); + KillEditView(TRUE); + delete pSpellingEngine; + delete pEditSel; + pDocSh->PostPaintGridAll(); + GetViewData()->GetViewShell()->UpdateInputHandler(); + pDoc->DisableIdle(bOldDis); +} + +IMPL_LINK_INLINE_START( ScViewFunc, SpellError, void *, nLang ) +{ + SvxLanguageTable aLangTab; + String aErr = aLangTab.GetString((LanguageType) (ULONG) nLang); + ErrorHandler::HandleError(*new StringErrorInfo( + ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS, aErr) ); + + return 0; +} +IMPL_LINK_INLINE_END( ScViewFunc, SpellError, void *, nLang ) + +// Pasten von FORMAT_FILE-Items +// wird nicht direkt aus Drop aufgerufen, sondern asynchron -> Dialoge sind erlaubt + +BOOL ScViewFunc::PasteFile( const Point& rPos, const String& rFile, BOOL bLink ) +{ + if (!bLink) // bei bLink nur Grafik oder URL + { + // 1. Kann ich die Datei oeffnen? + const SfxFilter* pFlt = NULL; + + // nur nach eigenen Filtern suchen, ohne Auswahlbox (wie in ScDocumentLoader) + SfxFilterMatcher aMatcher( ScDocShell::Factory().GetFilterContainer() ); + SfxMedium aSfxMedium( rFile, (STREAM_READ | STREAM_SHARE_DENYNONE), FALSE ); + ErrCode nErr = aMatcher.GuessFilter( aSfxMedium, &pFlt ); + + if ( pFlt && !nErr ) + { + // Code aus dem SFX geklaut! + SfxDispatcher &rDispatcher = SFX_DISPATCHER(); + SfxStringItem aFileNameItem( SID_FILE_NAME, rFile ); + SfxStringItem aFilterItem( SID_FILTER_NAME, pFlt->GetName() ); + + // Asynchron oeffnen, kann naemlich auch aus D&D heraus passieren + // und das bekommt dem MAC nicht so gut ... + return BOOL( 0 != rDispatcher.Execute( SID_OPENDOC, + SFX_CALLMODE_ASYNCHRON, &aFileNameItem, &aFilterItem, 0L) ); + } + } + + // 2. Kann die Datei ueber die Grafik-Filter eingefuegt werden? + // (als Link, weil Gallery das so anbietet) + + USHORT nFilterFormat; + Graphic aGraphic; + GraphicFilter* pGraphicFilter = ::GetGrfFilter(); + +// GraphicProgress aGraphicProgress(&aGraphicFilter); + + INetURLObject aURL; + aURL.SetSmartURL( rFile ); + if (!pGraphicFilter->ImportGraphic(aGraphic, aURL, + GRFILTER_FORMAT_DONTKNOW, &nFilterFormat )) + { + String aFltName = pGraphicFilter->GetImportFormatName(nFilterFormat); + return PasteGraphic( rPos, aGraphic, rFile, aFltName ); + } + + if (bLink) // bei bLink alles, was nicht Grafik ist, als URL + { + Rectangle aRect( rPos, Size(0,0) ); + ScRange aRange = GetViewData()->GetDocument()-> + GetRange( GetViewData()->GetTabNo(), aRect ); + USHORT nPosX = aRange.aStart.Col(); + USHORT nPosY = aRange.aStart.Row(); + + InsertBookmark( rFile, rFile, nPosX, nPosY ); + return TRUE; + } + else + { + // 3. Kann die Datei als OLE eingefuegt werden? + // auch nicht-Storages, z.B. Sounds (#38282#) + +// BOOL bIsStg = SvStorage::IsStorageFile( rFile ); + SvStorageRef refStor = new SvStorage( EMPTY_STRING ); +#ifndef SO3 + SvObjectRef refOleObj = + SvInPlaceObject::ClassFactory()->CreateAndInit( rFile, refStor, bLink ); +#else + SvObjectRef refOleObj = + ((SvFactory*)SvInPlaceObject::ClassFactory())->CreateAndInit( rFile, refStor, bLink ); +#endif + SvInPlaceObjectRef refObj( &refOleObj ); + if( refObj.Is() ) + return PasteObject( rPos, refObj ); + } + + // Ich geb auf! Soll hier noch ne MsgBox hin? + return FALSE; +} + +BOOL ScViewFunc::PasteBookmark( SvDataObject* pObject, USHORT nPosX, USHORT nPosY ) +{ + ULONG nFormat = INetBookmark::HasFormat(*pObject); + INetBookmark aBookmark; + BOOL bFound = aBookmark.Paste(*pObject,nFormat); + if ( !bFound ) + { + USHORT nCount = DragServer::GetItemCount(); + for( USHORT i = 0; i < nCount && !bFound; i++ ) + if ( aBookmark.PasteDragServer(i) ) + bFound = TRUE; + } + if ( !bFound ) + return FALSE; // gibt kein Bookmark (keine Assertion - + // bei Datenauszuegen vom Desktop wird FALSE zurueckgegeben) + + InsertBookmark( aBookmark.GetDescription(), aBookmark.GetURL(), nPosX, nPosY ); + return TRUE; + + //! aus DragServer ggf. noch weitere Items einfuegen !!!! +} + +void ScViewFunc::InsertBookmark( const String& rDescription, const String& rURL, + USHORT nPosX, USHORT nPosY, const String* pTarget ) +{ + ScViewData* pViewData = GetViewData(); + if ( pViewData->HasEditView( pViewData->GetActivePart() ) && + nPosX >= pViewData->GetEditViewCol() && nPosX <= pViewData->GetEditEndCol() && + nPosY >= pViewData->GetEditViewRow() && nPosY <= pViewData->GetEditEndRow() ) + { + // in die gerade editierte Zelle einfuegen + + String aTargetFrame; + if (pTarget) + aTargetFrame = *pTarget; + pViewData->GetViewShell()->InsertURLField( rDescription, rURL, aTargetFrame ); + return; + } + + // in nicht editierte Zelle einfuegen + + ScDocument* pDoc = GetViewData()->GetDocument(); + USHORT nTab = GetViewData()->GetTabNo(); + ScAddress aCellPos( nPosX, nPosY, nTab ); + ScBaseCell* pCell = pDoc->GetCell( aCellPos ); + EditEngine aEngine( pDoc->GetEnginePool() ); + if (pCell) + { + if (pCell->GetCellType() == CELLTYPE_EDIT) + { + const EditTextObject* pOld = ((ScEditCell*)pCell)->GetData(); + if (pOld) + aEngine.SetText(*pOld); + } + else + { + String aOld; + pDoc->GetInputString( nPosX, nPosY, nTab, aOld ); + if (aOld.Len()) + aEngine.SetText(aOld); + } + } + + USHORT nPara = aEngine.GetParagraphCount(); + if (nPara) + --nPara; + xub_StrLen nTxtLen = aEngine.GetTextLen(nPara); + ESelection aInsSel( nPara, nTxtLen, nPara, nTxtLen ); + + SvxURLField aField( rURL, rDescription, SVXURLFORMAT_APPDEFAULT ); + if (pTarget) + aField.SetTargetFrame(*pTarget); + aEngine.QuickInsertField( SvxFieldItem( aField ), aInsSel ); + + EditTextObject* pData = aEngine.CreateTextObject(); + EnterData( nPosX, nPosY, nTab, pData ); + delete pData; +} + +BOOL ScViewFunc::HasBookmarkAtCursor( SvxHyperlinkItem* pContent ) +{ + ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ); + ScDocument* pDoc = GetViewData()->GetDocShell()->GetDocument(); + + ScBaseCell* pCell = pDoc->GetCell( aPos ); + if ( pCell && pCell->GetCellType() == CELLTYPE_EDIT ) + { + const EditTextObject* pData = ((ScEditCell*)pCell)->GetData(); + if (pData) + { + BOOL bField = pData->IsFieldObject(); + if (bField) + { + const SvxFieldItem* pFieldItem = pData->GetField(); + if (pFieldItem) + { + const SvxFieldData* pField = pFieldItem->GetField(); + if ( pField && pField->ISA(SvxURLField) ) + { + if (pContent) + { + const SvxURLField* pURLField = (const SvxURLField*)pField; + pContent->SetName( pURLField->GetRepresentation() ); + pContent->SetURL( pURLField->GetURL() ); + pContent->SetTargetFrame( pURLField->GetTargetFrame() ); + } + return TRUE; + } + } + } + } + } + return FALSE; +} + + + + diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx new file mode 100644 index 000000000000..3a53d795ae3d --- /dev/null +++ b/sc/source/ui/view/viewfun5.cxx @@ -0,0 +1,952 @@ +/************************************************************************* + * + * $RCSfile: viewfun5.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +// TOOLS +#define _BIGINT_HXX +#define _SFXMULTISEL_HXX +#define _STACK_HXX +#define _QUEUE_HXX +#define _DYNARR_HXX +#define _TREELIST_HXX +#define _CACHESTR_HXX +#define _NEW_HXX +//#define _SHL_HXX +//#define _LINK_HXX +//#define _ERRCODE_HXX +//#define _GEN_HXX +//#define _FRACT_HXX +//#define _STRING_HXX +//#define _MTF_HXX +//#define _CONTNR_HXX +//#define _LIST_HXX +//#define _TABLE_HXX +#define _DYNARY_HXX +//#define _UNQIDX_HXX +#define _SVMEMPOOL_HXX +//#define _UNQID_HXX +//#define _DEBUG_HXX +//#define _DATE_HXX +//#define _TIME_HXX +//#define _DATETIME_HXX +//#define _INTN_HXX +//#define _WLDCRD_HXX +//#define _FSYS_HXX +//#define _STREAM_HXX +#define _CACHESTR_HXX +#define _SV_MULTISEL_HXX + +//SV +//#define _CLIP_HXX *** +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _FONTDLG_HXX +#define _PRVWIN_HXX +//#define _COLOR_HXX +//#define _PAL_HXX +//#define _BITMAP_HXX +//#define _GDIOBJ_HXX +//#define _POINTR_HXX +//#define _ICON_HXX +//#define _IMAGE_HXX +//#define _KEYCOD_HXX +//#define _EVENT_HXX +#define _HELP_HXX +//#define _APP_HXX +//#define _MDIAPP_HXX +//#define _TIMER_HXX +//#define _METRIC_HXX +//#define _REGION_HXX +//#define _OUTDEV_HXX +//#define _SYSTEM_HXX +//#define _VIRDEV_HXX +//#define _JOBSET_HXX +//#define _PRINT_HXX +//#define _WINDOW_HXX +//#define _SYSWIN_HXX +//#define _WRKWIN_HXX +#define _MDIWIN_HXX +//#define _FLOATWIN_HXX +//#define _DOCKWIN_HXX +//#define _CTRL_HXX +//#define _SCRBAR_HXX +//#define _BUTTON_HXX +//#define _IMAGEBTN_HXX +//#define _FIXED_HXX +//#define _GROUP_HXX +//#define _EDIT_HXX +//#define _COMBOBOX_HXX +//#define _LSTBOX_HXX +//#define _SELENG_HXX *** +//#define _SPLIT_HXX +#define _SPIN_HXX +//#define _FIELD_HXX +//#define _MOREBTN_HXX *** +//#define _TOOLBOX_HXX +//#define _STATUS_HXX *** +//#define _DIALOG_HXX +//#define _MSGBOX_HXX +//#define _SYSDLG_HXX +#define _FILDLG_HXX +//#define _PRNDLG_HXX +#define _COLDLG_HXX +//#define _TABDLG_HXX +#define _MENU_HXX +//#define _GDIMTF_HXX +//#define _POLY_HXX +//#define _ACCEL_HXX +//#define _GRAPH_HXX +#define _SOUND_HXX + +#if defined WIN +#define _MENUBTN_HXX +#endif + +//svtools +#define _SCRWIN_HXX +#define _RULER_HXX +//#define _TABBAR_HXX +//#define _VALUESET_HXX +#define _STDMENU_HXX +//#define _STDCTRL_HXX +//#define _CTRLBOX_HXX +#define _CTRLTOOL_HXX +#define _EXTATTR_HXX +#define _FRM3D_HXX +#define _EXTATTR_HXX + +//SVTOOLS +//#define _SVTREELIST_HXX *** +#define _FILTER_HXX +//#define _SVLBOXITM_HXX *** +//#define _SVTREEBOX_HXX *** +#define _SVICNVW_HXX +#define _SVTABBX_HXX + +//sfxcore.hxx +//#define _SFXINIMGR_HXX *** +//#define _SFXCFGITEM_HXX +//#define _SFX_PRINTER_HXX +#define _SFXGENLINK_HXX +#define _SFXHINTPOST_HXX +//#define _SFXDOCINF_HXX +#define _SFXLINKHDL_HXX +//#define _SFX_PROGRESS_HXX + +//sfxsh.hxx +//#define _SFXSH_HXX +///#define _PLUGAPPL_HXX +//#define _SFX_SHELL_HXX +//#define _SFXAPP_HXX +//#define _SFX_BINDINGS_HXX +//#define _SFXDISPATCH_HXX +#define _SFXMSG_HXX +#define _SFXOBJFACE_HXX +#define _SFXREQUEST_HXX +#define _SFXMACRO_HXX + + +// SFX +#define _SFX_SAVEOPT_HXX +#define _SFXPRNMON_HXX +#define _INTRO_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFXFILEDLG_HXX +#define _PASSWD_HXX +#define _SFXTBXCTRL_HXX +#define _SFXSTBITEM_HXX +#define _SFXMNUITEM_HXX +#define _SFXIMGMGR_HXX +#define _SFXTBXMGR_HXX +#define _SFXSTBMGR_HXX +#define _SFX_MINFITEM_HXX +#define _SFXEVENT_HXX +#define _SFX_CHILDALIGN_HXX +#define _SFXAPPWIN_HXX +#define _SFX_CHILDWIN_HXX +#define _SFXCTRLITEM_HXX + + +//sfxdoc.hxx +//#define _SFX_OBJSH_HXX +//#define _SFX_CLIENTSH_HXX +//#define _SFXDOCINF_HXX +//#define _SFX_OBJFAC_HXX +//#define _SFX_DOCFILT_HXX +//#define _SFXDOCFILE_HXX *** +//define _VIEWFAC_HXX +//#define _SFXVIEWFRM_HXX +//#define _SFXVIEWSH_HXX +//#define _MDIFRM_HXX *** +#define _SFX_IPFRM_HXX +//#define _SFX_INTERNO_HXX + +//sfxdoc.hxx +//#define _SFXDOC_HXX +// --- #define _RSCSFX_HXX +//#define SFX_DECL_OBJECTSHELL_DEFINED +//#define _SFX_OBJSH_HXX +//#define _SFX_CLIENTSH_HXX +//#define _SFX_OBJFAC_HXX +#define _SFX_DOCFILT_HACK_HXX +#define _SFX_FCONTNR_HXX +#define STRING_LIST +//#define _SFXDOCFILE_HXX +//#define _SFX_INTERNO_HXX + +//sfxdlg.hxx +//#define _SFXDLG_HXX +#define _DOCMGR_HXX +//#define _SFXITEMS_HXX +//#define _SFXTABDLG_HXX +#define _BASEDLGS_HXX +#define _SFX_DINFDLG_HXX +#define _SFXDINFEDT_HXX +#define _SFX_MGETEMPL_HXX +#define _SFX_TPLPITEM_HXX +#define _SFX_STYLEDLG_HXX +#define _NEWSTYLE_HXX +//#define SFX_DECL_OBJECTSHELL_DEFINED +#define _SFXDOCTEMPL_HXX +#define _SFXDOCTDLG_HXX +#define _SFXDOCKWIN_HXX +#define _SFX_TEMPLDLG_HXX +#define _SFXNEW_HXX +#define _SFXDOCMAN_HXX +#define _SFXNAVI_HXX + + +//sfxitems.hxx +#define _SFX_WHMAP_HXX +//#define _ARGS_HXX +//#define _SFXPOOLITEM_HXX +//#define _SFXINTITEM_HXX +//#define _SFXENUMITEM_HXX +#define _SFXFLAGITEM_HXX +//#define _SFXSTRITEM_HXX +//#define _SFXPTITEM_HXX +#define _SFXRECTITEM_HXX +//#define _SFXITEMPOOL_HXX +//#define _SFXITEMSET_HXX +#define _SFXITEMITER_HXX +#define _SFX_WHITER_HXX +#define _SFXPOOLCACH_HXX +//#define _AEITEM_HXX +#define _SFXRNGITEM_HXX +//#define _SFXSLSTITM_HXX +//#define _SFXSTYLE_HXX + +//xout.hxx +//#define _XENUM_HXX +//#define _XPOLY_HXX +//#define _XATTR_HXX +//#define _XOUTX_HXX +//#define _XPOOL_HXX +//#define _XTABLE_HXX + +//svdraw.hxx +#define _SDR_NOITEMS +#define _SDR_NOTOUCH +#define _SDR_NOTRANSFORM +#define _SDR_NOOBJECTS //* +//#define _SDR_NOVIEWS + +//#define SI_NOITEMS +//#define SI_NODRW +#define _SI_NOSBXCONTROLS +//#define _VCATTR_HXX +#define _VCONT_HXX +//#define _VCSBX_HXX +#define _SI_NOOTHERFORMS +#define _VCTRLS_HXX +//#define _VCDRWOBJ_HXX +#define _SI_NOCONTROL +#define _SETBRW_HXX +#define _VCBRW_HXX +#define _SI_NOSBXCONTROLS +//#define _SIDLL_HXX *** + +#ifdef WIN +#define _VCSBX_HXX +#define _VCDRWOBJ_HXX +#define _SBX_HXX +#endif + +//view3d.hxx +//#define _E3D_VIEW3D_HXX + +//obj3d.hxx +//#define _E3D_OBJ3D_HXX + +//volume3d.hxx +//#define _VOLUME3D_HXX + + + + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_THESDLG_HXX + + +//------------------------------------------------------------------ + +#include <svx/dbexch.hrc> +#include <svx/fmmodel.hxx> +#include <svx/svdetc.hxx> +#include <svx/svditer.hxx> +#include <svx/svdobj.hxx> +#include <svx/svdogrp.hxx> +#include <svx/svdouno.hxx> +#include <svx/svdpage.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/docfile.hxx> +#include <so3/ipobj.hxx> +#include <so3/svstor.hxx> +#include <offmgr/app.hxx> +#include <so3/clsids.hxx> +#include <sot/formats.hxx> +#include <svtools/iniman.hxx> +#include <svtools/ptitem.hxx> +#include <svtools/stritem.hxx> +#include <vcl/drag.hxx> +#include <vcl/graph.hxx> + +#include <sot/formats.hxx> +#define SOT_FORMATSTR_ID_STARCALC_CURRENT SOT_FORMATSTR_ID_STARCALC_50 + +#ifndef SO2_DECL_SVINPLACEOBJECT_DEFINED +#define SO2_DECL_SVINPLACEOBJECT_DEFINED +SO2_DECL_REF(SvInPlaceObject) +#endif +#ifndef SO2_DECL_SVSTORAGE_DEFINED +#define SO2_DECL_SVSTORAGE_DEFINED +SO2_DECL_REF(SvStorage) +#endif + +#include "viewfunc.hxx" +#include "docsh.hxx" +#include "drawview.hxx" +#include "impex.hxx" +#include "dbfunc.hxx" +#include "dbcolect.hxx" +#include "sc.hrc" +#include "filter.hxx" +#include "scextopt.hxx" +#include "tabvwsh.hxx" // wegen GetViewFrame +#include "compiler.hxx" + +#ifndef _SFXVIEWFRM_HXX //autogen +#include <sfx2/viewfrm.hxx> +#endif + + +// STATIC DATA ----------------------------------------------------------- + +//================================================================== + +BOOL ScViewFunc::PasteDataFormat( ULONG nFormatId, SvDataObject* pObject, + USHORT nPosX, USHORT nPosY, + Window* pWin, Point* pLogicPos ) +{ + //! pWin wird nicht mehr benutzt + + Point aPos; // Einfuege-Position (1/100 mm) + if (pLogicPos) + aPos = *pLogicPos; + else + { + // Bei Text-Formaten muss die Position nicht berechnet werden + + if ( !ScImportExport::IsFormatSupported( nFormatId ) + && nFormatId != FORMAT_RTF ) + { + // MapMode des Fensters ist hier noch nicht auf Drawing initialisiert, + // wenn der Drawing-Layer noch nicht angelegt ist + + ScDocument* pDoc = GetViewData()->GetDocument(); + USHORT nTab = GetViewData()->GetTabNo(); + USHORT i; + long nXT = 0; + for (i=0; i<nPosX; i++) + nXT += pDoc->GetColWidth(i,nTab); + long nYT = 0; + for (i=0; i<nPosY; i++) + nYT += pDoc->FastGetRowHeight(i,nTab); + aPos = Point( (long)(nXT * HMM_PER_TWIPS), (long)(nYT * HMM_PER_TWIPS) ); + } + } + + ULONG nSba = SOT_FORMATSTR_ID_SBA_DATAEXCHANGE; + ULONG nField = Exchange::RegisterFormatName( + String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(SBA_FIELDEXCHANGE_FORMAT))); + ULONG nBiff = Exchange::RegisterFormatName( + String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Biff5"))); + + BOOL bRet = FALSE; + + if ( nFormatId == SOT_FORMATSTR_ID_EMBED_SOURCE || + nFormatId == SOT_FORMATSTR_ID_LINK_SOURCE || + nFormatId == SOT_FORMATSTR_ID_EMBED_SOURCE_OLE || + nFormatId == SOT_FORMATSTR_ID_LINK_SOURCE_OLE ) + { + // DLLs hier doch nicht initialisieren, ist schon in Main::Init passiert + + BOOL bStorFilled; + const ULONG nScFormat = SOT_FORMATSTR_ID_STARCALC_CURRENT; + + SvStorageRef aStor = new SvStorage( EMPTY_STRING, STREAM_STD_READWRITE ); + if( SvFactory::IsOwnFormat( bStorFilled, pObject, nScFormat, &aStor ) ) + { + if (bStorFilled) + { + // Eigenes Format + + ScDocShellRef xDocShRef = new ScDocShell(SFX_CREATE_MODE_EMBEDDED); + if (xDocShRef->DoLoad(aStor)) + { + ScDocument* pSrcDoc = xDocShRef->GetDocument(); + USHORT nSrcTab = pSrcDoc->GetVisibleTab(); + if (!pSrcDoc->HasTable(nSrcTab)) + nSrcTab = 0; + + ScMarkData aSrcMark; + aSrcMark.SelectOneTable( nSrcTab ); // fuer CopyToClip + ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP ); + + USHORT nFirstCol, nFirstRow, nLastCol, nLastRow; + pSrcDoc->GetDataStart( nSrcTab, nFirstCol, nFirstRow ); + pSrcDoc->GetCellArea( nSrcTab, nLastCol, nLastRow ); + pSrcDoc->CopyToClip( nFirstCol, nFirstRow, nLastCol, nLastRow, + FALSE, pClipDoc, FALSE, &aSrcMark ); + ScGlobal::SetClipDocName( xDocShRef->GetTitle( SFX_TITLE_FULLNAME ) ); + + SetCursor( nPosX, nPosY ); + Unmark(); + PasteFromClip( IDF_ALL, pClipDoc ); + delete pClipDoc; + bRet = TRUE; + } + ((SfxInPlaceObject*)xDocShRef)->DoClose(); + xDocShRef.Clear(); + } + } + else + { + BOOL bIsLink = ( nFormatId == SOT_FORMATSTR_ID_LINK_SOURCE || + nFormatId == SOT_FORMATSTR_ID_LINK_SOURCE_OLE ); +#ifndef SO3 + SvInPlaceObjectRef aIPObj = (SvInPlaceObjectRef)SvInPlaceObject::ClassFactory() +#else + SvInPlaceObjectRef aIPObj = &((SvFactory*)SvInPlaceObject::ClassFactory()) +#endif + ->CreateAndInit( pObject, aStor, bIsLink, bStorFilled ); + if ( aIPObj.Is() ) + { + PasteObject( aPos, aIPObj, pObject ); + bRet = TRUE; + } + else + DBG_ERROR("Fehler bei CreateAndInit"); + } + } + else if ( nFormatId == SOT_FORMATSTR_ID_LINK ) + { + //! warum ist Link bei ScImportExport eingetragen ??? + + bRet = PasteDDE( pObject ); + } + else if( ScImportExport::IsFormatSupported( nFormatId ) ) + { + SvData aData( nFormatId ); + if (pObject->GetData( &aData )) + { + ScDocument* pDoc = GetViewData()->GetDocument(); + ScAddress aPos( nPosX, nPosY, GetViewData()->GetTabNo() ); + ScImportExport aObj( GetViewData()->GetDocument(), aPos ); + bRet = aObj.ImportData( aData ); + InvalidateAttribs(); + GetViewData()->UpdateInputHandler(); + } + } + else if (nFormatId == SOT_FORMATSTR_ID_SVXB) + { + SvData aData( SOT_FORMATSTR_ID_SVXB ); + if (pObject->GetData( &aData )) + { + Graphic* pGraphic; + if ( aData.GetData( (SvDataCopyStream**) &pGraphic, + Graphic::StaticType(), TRANSFER_MOVE ) ) + bRet = PasteGraphic( aPos, *pGraphic, EMPTY_STRING, EMPTY_STRING ); + } + } + else if (nFormatId == SOT_FORMATSTR_ID_DRAWING) // SvDraw Model + { + SvData aData( SOT_FORMATSTR_ID_DRAWING ); + if (pObject->GetData( &aData )) + { + SvStorageStreamRef aStrm; + + if ( aData.GetData(aStrm) ) + { + MakeDrawLayer(); // vorher, damit die 3D-Factory angelegt ist + + String aPath = SFX_APP()->GetAppIniManager()->Get(SFX_KEY_PALETTE_PATH); + FmFormModel* pModel = new FmFormModel( + aPath, NULL, GetViewData()->GetDocShell() ); + pModel->GetItemPool().FreezeIdRanges(); + aStrm->Seek(0); + aStrm->SetVersion(SOFFICE_FILEFORMAT_NOW); + pModel->SetStreamingSdrModel(TRUE); + pModel->GetItemPool().Load(*aStrm); + *aStrm >> *pModel; + pModel->SetStreamingSdrModel(FALSE); + + // alles auf passenden Layer setzen: + ULONG nObjCount = 0; + USHORT nPages = pModel->GetPageCount(); + for (USHORT i=0; i<nPages; i++) + { + SdrPage* pPage = pModel->GetPage(i); + SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS ); + SdrObject* pObject = aIter.Next(); + while (pObject) + { + ++nObjCount; + if ( pObject->ISA(SdrUnoObj) ) + pObject->NbcSetLayer(SC_LAYER_CONTROLS); + else + pObject->NbcSetLayer(SC_LAYER_FRONT); + pObject = aIter.Next(); + } + } + + PasteDraw( aPos, pModel, (nObjCount > 1) ); // gruppiert, wenn mehr als 1 + delete pModel; + bRet = TRUE; + } + } + } + else if (nFormatId == nSba) + { + //! char or sal_Unicode from sba ??? + + ULONG nLen = DragServer::GetDataLen(0, nSba); + char* pTxt = new char[nLen]; + DragServer::PasteData(0, pTxt, nLen, nSba); // String ist 0-terminiert + String sDataDesc = String::CreateFromAscii(pTxt); + delete[] pTxt; + SfxStringItem aDataDesc(SID_SBA_IMPORT, sDataDesc); + + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + USHORT nTab = GetViewData()->GetTabNo(); + + ClickCursor(nPosX, nPosY, FALSE); // Cursor setzen + + // Datenbank-Bereich "Import1" wird hier nicht mehr angelegt, + // sondern erst beim Slot-Execute an der DocShell, damit er ins + // Undo aufgenommen werden kann. + + ScDBData* pDBData = pDocSh->GetDBData( ScRange(nPosX,nPosY,nTab), SC_DB_OLD, FALSE ); + String sTarget; + if (pDBData) + sTarget = pDBData->GetName(); + else + { + ScAddress aPos( nPosX,nPosY,nTab ); + aPos.Format( sTarget, SCA_ABS_3D, pDoc ); + } + SfxStringItem aTarget(FN_PARAM_1, sTarget); + + BOOL bAreaIsNew = !pDBData; + SfxBoolItem aAreaNew(FN_PARAM_2, bAreaIsNew); + + // asynchron, damit nicht der ganze Import im Drop-Handler passiert + // nicht SFX_DISPATCHER, weil die View beim Drag&Drop nicht aktiv sein muss + SfxDispatcher* pDisp = + GetViewData()->GetViewShell()->GetViewFrame()->GetDispatcher(); + if (pDisp) + pDisp->Execute(SID_SBA_IMPORT, SFX_CALLMODE_ASYNCHRON, + &aDataDesc, &aTarget, &aAreaNew, 0L ); + + bRet = TRUE; + } + else if (nFormatId == nField) + { + SvData aData(nFormatId); + if ( pObject->GetData(&aData) ) + { + String aString; + if ( aData.GetData(aString) ) + { + MakeDrawLayer(); + ScDrawView* pDrawView = GetScDrawView(); + SdrObject* pObj = pDrawView->CreateFieldControl(aString); + if (pObj) + { + Point aInsPos = aPos; + Rectangle aRect(pObj->GetLogicRect()); + aInsPos.X() -= aRect.GetSize().Width() / 2; + aInsPos.Y() -= aRect.GetSize().Height() / 2; + if ( aInsPos.X() < 0 ) aInsPos.X() = 0; + if ( aInsPos.Y() < 0 ) aInsPos.Y() = 0; + aRect.SetPos(aInsPos); + pObj->SetLogicRect(aRect); + + if ( pObj->ISA(SdrUnoObj) ) + pObj->NbcSetLayer(SC_LAYER_CONTROLS); + else + pObj->NbcSetLayer(SC_LAYER_FRONT); + if (pObj->ISA(SdrObjGroup)) + { + SdrObjListIter aIter( *pObj, IM_DEEPWITHGROUPS ); + SdrObject* pSubObj = aIter.Next(); + while (pSubObj) + { + if ( pSubObj->ISA(SdrUnoObj) ) + pSubObj->NbcSetLayer(SC_LAYER_CONTROLS); + else + pSubObj->NbcSetLayer(SC_LAYER_FRONT); + pSubObj = aIter.Next(); + } + } + + pDrawView->InsertObjectSafe(pObj, *pDrawView->GetPageViewPvNum(0)); + + GetViewData()->GetViewShell()->SetDrawShell( TRUE ); + bRet = TRUE; + } + } + } + } + else if (nFormatId == nBiff) + { + // Excel-Import in ein Clipboard-Dokument... + + SvData aData( nBiff, MEDIUM_STORAGE ); + if (pObject->GetData( &aData )) + { + SvStorageRef pStor; + if ( aData.GetData( pStor, TRANSFER_REFERENCE ) && pStor.Is() ) + { +#if 0 + SvStorage aDest( "d:\\test.xls" ); // wenn man sich ansehen will, + pStor->CopyTo( &aDest ); // was da wirklich im Clipboard steht +#endif + ScDocument* pDoc = GetViewData()->GetDocument(); + ScDocument* pInsDoc = new ScDocument( SCDOCMODE_CLIP ); + USHORT nSrcTab = 0; // Biff5 im Clipboard: immer Tabelle 0 + pInsDoc->ResetClip( pDoc, nSrcTab ); + + SfxMedium aMed( pStor, TRUE ); + FltError eErr = ScImportExcel( aMed, pInsDoc, EIF_AUTO ); + if ( eErr == eERR_OK ) + { + ScRange aSource; + const ScExtDocOptions* pExtOpt = pInsDoc->GetExtDocOptions(); + const ScExtTabOptions* pTabOpt = pExtOpt ? + pExtOpt->GetExtTabOptions(nSrcTab) : NULL; + if ( pTabOpt && pTabOpt->bValidDim && + pTabOpt->aDim.aEnd.Col() > pTabOpt->aDim.aStart.Col() && + pTabOpt->aDim.aEnd.Row() > pTabOpt->aDim.aStart.Row() ) + { + // das Ende zeigt direkt hinter den Datenbereich + aSource = ScRange( + pTabOpt->aDim.aStart.Col(), pTabOpt->aDim.aStart.Row(), nSrcTab, + pTabOpt->aDim.aEnd.Col()-1, pTabOpt->aDim.aEnd.Row()-1, nSrcTab ); + // die Selektion kann groesser als der belegte Bereich sein + if ( pTabOpt->bValidSel ) + { + if ( pTabOpt->aLastSel.aStart.Col() < aSource.aStart.Col() ) + aSource.aStart.SetCol( pTabOpt->aLastSel.aStart.Col() ); + if ( pTabOpt->aLastSel.aStart.Row() < aSource.aStart.Row() ) + aSource.aStart.SetRow( pTabOpt->aLastSel.aStart.Row() ); + // in der Selektion ist das Ende wirklich das Ende + if ( pTabOpt->aLastSel.aEnd.Col() > aSource.aEnd.Col() ) + aSource.aEnd.SetCol( pTabOpt->aLastSel.aEnd.Col() ); + if ( pTabOpt->aLastSel.aEnd.Row() > aSource.aEnd.Row() ) + aSource.aEnd.SetRow( pTabOpt->aLastSel.aEnd.Row() ); + } + } + else + { + DBG_ERROR("keine Dimension"); //! kann das vorkommen? + USHORT nFirstCol, nFirstRow, nLastCol, nLastRow; + pInsDoc->GetDataStart( nSrcTab, nFirstCol, nFirstRow ); + pInsDoc->GetCellArea( nSrcTab, nLastCol, nLastRow ); + aSource = ScRange( nFirstCol, nFirstRow, nSrcTab, + nLastCol, nLastRow, nSrcTab ); + } + + if ( pLogicPos ) + { + // Position angegeben (Drag&Drop) - Selektion umsetzen + MoveCursorAbs( nPosX, nPosY, SC_FOLLOW_NONE, FALSE, FALSE ); + Unmark(); + } + + pInsDoc->SetClipArea( aSource ); + PasteFromClip(IDF_ALL, pInsDoc); + delete pInsDoc; + + bRet = TRUE; + } + } + } + } + else switch (nFormatId) + { + case FORMAT_RTF: + PasteRTF( nPosX, nPosY, pObject ); // -> viewfun4 //! Cursor + bRet = TRUE; + InvalidateAttribs(); + GetViewData()->UpdateInputHandler(); + break; + + case FORMAT_BITMAP: + { + SvData aData( FORMAT_BITMAP ); + if (pObject->GetData( &aData )) + { + Bitmap* pBitmap = NULL; + aData.GetData(&pBitmap, TRANSFER_MOVE); + if( pBitmap ) + bRet = PasteBitmap( aPos, *pBitmap ); + } + } + break; + + case FORMAT_GDIMETAFILE: + { + SvData aData( FORMAT_GDIMETAFILE ); + if (pObject->GetData( &aData )) + { + GDIMetaFile* pMtf = NULL; +// aData.GetData(&pMtf, TRANSFER_MOVE); + aData.GetData(&pMtf, TRANSFER_REFERENCE); + if( pMtf ) + bRet = PasteMetaFile( aPos, *pMtf ); + } + } + break; + + case FORMAT_FILE: + { + USHORT nCount = DragServer::GetItemCount(); + if (nCount == 0) // nur wenn nicht ueber D&D + { + SvData aData( FORMAT_FILE ); + if (pObject->GetData( &aData )) + { + String aFile; + aData.GetData( aFile ); + bRet = PasteFile( aPos, aFile ); + } + } + else + { + // Vielleicht kann MM das Format ja eines Tages... + for( USHORT i = 0; i < nCount ; i++ ) + { +// PasteFile( aPos, DragServer::PasteFile( i ) ); + + String aFile = DragServer::PasteFile( i ); + SfxStringItem aNameItem( FID_INSERT_FILE, aFile ); + SfxPointItem aPosItem( FN_PARAM_1, aPos ); + SfxDispatcher* pDisp = + GetViewData()->GetViewShell()->GetViewFrame()->GetDispatcher(); + if (pDisp) + pDisp->Execute( FID_INSERT_FILE, SFX_CALLMODE_ASYNCHRON, + &aNameItem, &aPosItem, (void*)0 ); + + aPos.X() += 400; + aPos.Y() += 400; + } + bRet = TRUE; + } + } + break; + + default: + { + DBG_ERROR("PasteDataFormat - unbekanntes Format"); + } + } + + return bRet; +} + +BOOL ScViewFunc::PasteDDE( SvDataObject* pObject ) +{ + const SvDataTypeList& rTypeLst = pObject->GetTypeList(); + + // Groesse testen (nur wenn auch String angeboten) + + USHORT nCols = 1; + USHORT nRows = 1; + if ( rTypeLst.Get( FORMAT_STRING ) ) + { + SvData aSizeData( FORMAT_STRING ); + if (pObject->GetData( &aSizeData )) + { + String aDataStr; + aSizeData.GetData( aDataStr ); + + // Groesse aus String hier genauso wie in ScDdeLink::DataChanged + + aDataStr.ConvertLineEnd(LINEEND_LF); + xub_StrLen nLen = aDataStr.Len(); + if (nLen && aDataStr.GetChar(nLen-1) == '\n') + aDataStr.Erase(nLen-1); + + if (aDataStr.Len()) + { + nRows = aDataStr.GetTokenCount( '\n' ); + String aLine = aDataStr.GetToken( 0, '\n' ); + if (aLine.Len()) + nCols = aLine.GetTokenCount( '\t' ); + } + } + } + + // Formel zusammenbauen + + SvData aData( SOT_FORMATSTR_ID_LINK ); + if ( !pObject->GetData( &aData ) ) + { + DBG_ERROR("DDE Data not found."); + return FALSE; + } + + void *pData; + if( !aData.GetData( &pData, TRANSFER_REFERENCE ) ) + { + DBG_ERROR("DDE Falsches Medium."); + return FALSE; + } + + //! char or sal_Unicode from dde ??? + + rtl_TextEncoding eSysEnc = gsl_getSystemTextEncoding(); + String aApp ( (char*)pData, eSysEnc ); + String aTopic( (char*)pData + aApp.Len() + 1, eSysEnc ); + String aItem ( (char*)pData + aApp.Len() + aTopic.Len() + 2, eSysEnc ); + + if (!ScCompiler::pSymbolTableNative) + { + DBG_ERROR("ScCompiler::pSymbolTableNative missing"); + return FALSE; + } + + //! use tokens + String aFormula( '=' ); + aFormula += ScCompiler::pSymbolTableNative[SC_OPCODE_DDE]; + aFormula.AppendAscii(RTL_CONSTASCII_STRINGPARAM("(\"")); + aFormula += aApp; + aFormula.AppendAscii(RTL_CONSTASCII_STRINGPARAM("\";\"")); + aFormula += aTopic; + aFormula.AppendAscii(RTL_CONSTASCII_STRINGPARAM("\";\"")); + aFormula += aItem; + aFormula.AppendAscii(RTL_CONSTASCII_STRINGPARAM("\")")); + + // Block markieren + + USHORT nTab = GetViewData()->GetTabNo(); + USHORT nCurX = GetViewData()->GetCurX(); + USHORT nCurY = GetViewData()->GetCurY(); + HideAllCursors(); + DoneBlockMode(); + InitBlockMode( nCurX, nCurY, nTab ); + MarkCursor( nCurX+nCols-1, nCurY+nRows-1, nTab ); + ShowAllCursors(); + + // Formel eingeben + + EnterMatrix( aFormula ); + CursorPosChanged(); + + return TRUE; +} + + + + + diff --git a/sc/source/ui/view/viewfun6.cxx b/sc/source/ui/view/viewfun6.cxx new file mode 100644 index 000000000000..59aa35282a42 --- /dev/null +++ b/sc/source/ui/view/viewfun6.cxx @@ -0,0 +1,341 @@ +/************************************************************************* + * + * $RCSfile: viewfun6.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +#ifdef WIN +#define _MENUBTN_HXX +#endif + +//#define _SFX_DOCFILT_HXX +#define _SFX_PRNMON_HXX +#define _SFX_RESMGR_HXX +#define _SFX_TEMPLDLG_HXX +#define _SFXAPPWIN_HXX +#define _SFXBASIC_HXX +#define _SFXCTRLITEM +#define _SFXDLGCFG_HXX +//#define _SFXDISPATCH_HXX +#define _SFXDOCFILE_HXX +#define _SFXDOCMAN_HXX +#define _SFXDOCMGR_HXX +#define _SFXDOCTDLG_HXX +#define _SFXFILEDLG_HXX +#define _SFXIMGMGR_HXX +#define _SFXIPFRM_HXX +#define _SFX_MACRO_HXX +#define _SFXMNUITEM_HXX +#define _SFXMNUMGR_HXX +#define _SFXMULTISEL_HXX +#define _SFXMSG_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFX_MINFITEM_HXX +#define _SFXOBJFACE_HXX +#define _SFXOBJFAC_HXX +#define _SFX_SAVEOPT_HXX +#define _SFXSTBITEM_HXX +#define _SFXSTBMGR_HXX +#define _SFXTBXCTRL_HXX +#define _SFXTBXMGR_HXX + +#define _SI_DLL_HXX +#define _SIDLL_HXX +#define _SI_NOITEMS +#define _SI_NOOTHERFORMS +#define _SI_NOSBXCONTROLS +#define _SINOSBXCONTROLS +#define _SI_NOCONTROL +#define _VCBRW_HXX +#define _VCTRLS_HXX +//#define _VCSBX_HXX +#define _VCONT_HXX +#define _VDRWOBJ_HXX +#define _VCATTR_HXX +#define _VCONT_HXX + +#define _SDR_NOTRANSFORM +#define _SDR_NOITEMS +#define _SDR_NOOBJECTS +#define _SVDXOUT_HXX + +//------------------------------------------------------------------ + +#include <svx/svdundo.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/sound.hxx> + +#include "viewfunc.hxx" +#include "detfunc.hxx" +#include "detdata.hxx" +#include "viewdata.hxx" +#include "drwlayer.hxx" +#include "docsh.hxx" +#include "undocell.hxx" +#include "futext.hxx" +#include "docfunc.hxx" +#include "globstr.hrc" +#include "sc.hrc" + + +// STATIC DATA ----------------------------------------------------------- + +//================================================================== + +void ScViewFunc::DetectiveAddPred() +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + BOOL bDone = pDocSh->GetDocFunc(). + DetectiveAddPred( GetViewData()->GetCurPos() ); + if (!bDone) + Sound::Beep(); +} + +void ScViewFunc::DetectiveDelPred() +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + BOOL bDone = pDocSh->GetDocFunc(). + DetectiveDelPred( GetViewData()->GetCurPos() ); + if (!bDone) + Sound::Beep(); +} + +void ScViewFunc::DetectiveAddSucc() +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + BOOL bDone = pDocSh->GetDocFunc(). + DetectiveAddSucc( GetViewData()->GetCurPos() ); + if (!bDone) + Sound::Beep(); +} + +void ScViewFunc::DetectiveDelSucc() +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + BOOL bDone = pDocSh->GetDocFunc(). + DetectiveDelSucc( GetViewData()->GetCurPos() ); + if (!bDone) + Sound::Beep(); +} + +void ScViewFunc::DetectiveAddError() +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + BOOL bDone = pDocSh->GetDocFunc(). + DetectiveAddError( GetViewData()->GetCurPos() ); + if (!bDone) + Sound::Beep(); +} + +void ScViewFunc::DetectiveDelAll() +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + BOOL bDone = pDocSh->GetDocFunc(). + DetectiveDelAll( GetViewData()->GetTabNo() ); + if (!bDone) + Sound::Beep(); +} + +void ScViewFunc::DetectiveMarkInvalid() +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + BOOL bDone = pDocSh->GetDocFunc(). + DetectiveMarkInvalid( GetViewData()->GetTabNo() ); + if (!bDone) + Sound::Beep(); +} + +void ScViewFunc::DetectiveRefresh() +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + BOOL bDone = pDocSh->GetDocFunc().DetectiveRefresh(); + if (!bDone) + Sound::Beep(); +} + +//--------------------------------------------------------------------------- + +void ScViewFunc::ShowNote() +{ + // permanent einblenden + + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + USHORT nCol = GetViewData()->GetCurX(); + USHORT nRow = GetViewData()->GetCurY(); + USHORT nTab = GetViewData()->GetTabNo(); + + ScPostIt aNote; + if ( pDoc->GetNote( nCol, nRow, nTab, aNote ) && + !pDoc->HasNoteObject( nCol, nRow, nTab ) ) + { + pDocSh->MakeDrawLayer(); + ScDrawLayer* pModel = pDoc->GetDrawLayer(); + + pModel->BeginCalcUndo(); + SdrObject* pObject = ScDetectiveFunc( pDoc,nTab ).ShowComment( nCol, nRow, FALSE ); + SdrUndoGroup* pUndo = pModel->GetCalcUndo(); + if (pObject) + { + aNote.SetShown( TRUE ); + pDoc->SetNote( nCol, nRow, nTab, aNote ); + if (pUndo) + pDocSh->GetUndoManager()->AddUndoAction( new ScUndoNote( pDocSh, + TRUE, ScAddress(nCol,nRow,nTab), pUndo ) ); + + pDocSh->SetDocumentModified(); + } + else + { + delete pUndo; + Sound::Beep(); + } + } +} + +void ScViewFunc::HideNote() +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + ScDrawLayer* pModel = pDoc->GetDrawLayer(); + if (!pModel) + return; // da is nix + + USHORT nCol = GetViewData()->GetCurX(); + USHORT nRow = GetViewData()->GetCurY(); + USHORT nTab = GetViewData()->GetTabNo(); + + ScPostIt aNote; + if ( pDoc->GetNote( nCol, nRow, nTab, aNote ) && + pDoc->HasNoteObject( nCol, nRow, nTab ) ) + { + pModel->BeginCalcUndo(); + BOOL bDone = ScDetectiveFunc( pDoc,nTab ).HideComment( nCol, nRow ); + SdrUndoGroup* pUndo = pModel->GetCalcUndo(); + if (bDone) + { + aNote.SetShown( FALSE ); + pDoc->SetNote( nCol, nRow, nTab, aNote ); + if (pUndo) + pDocSh->GetUndoManager()->AddUndoAction( new ScUndoNote( pDocSh, + FALSE, ScAddress(nCol,nRow,nTab), pUndo ) ); + + pDocSh->SetDocumentModified(); + } + else + { + delete pUndo; + Sound::Beep(); + } + } +} + +void ScViewFunc::EditNote() +{ + // zum Editieren einblenden und aktivieren + + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + USHORT nCol = GetViewData()->GetCurX(); + USHORT nRow = GetViewData()->GetCurY(); + USHORT nTab = GetViewData()->GetTabNo(); + + ScPostIt aNote; + BOOL bFound = pDoc->GetNote( nCol, nRow, nTab, aNote ); + if ( !bFound || !pDoc->HasNoteObject( nCol, nRow, nTab ) ) // neu oder versteckt + { + pDocSh->MakeDrawLayer(); + ScDrawLayer* pModel = pDoc->GetDrawLayer(); + + pModel->BeginCalcUndo(); + // TRUE -> auch neu anlegen + SdrObject* pObject = ScDetectiveFunc( pDoc,nTab ).ShowComment( nCol, nRow, TRUE ); + + // Undo-Action (pModel->GetCalcUndo) wird beim StopEditMode abgeholt + + if (pObject) + { + // Shown-Flag nicht veraendern + + // Objekt aktivieren (wie in FuSelection::TestComment) + SFX_DISPATCHER().Execute(SID_DRAW_NOTEEDIT, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD); + // jetzt den erzeugten FuText holen und in den EditModus setzen + FuPoor* pPoor = GetDrawFuncPtr(); + if ( pPoor && pPoor->GetSlotID() == SID_DRAW_NOTEEDIT ) // hat keine RTTI + { + ScrollToObject( pObject ); // Objekt komplett sichtbar machen + FuText* pText = (FuText*)pPoor; + pText->SetInEditMode( pObject ); + } + } + } +} + + + diff --git a/sc/source/ui/view/viewfun7.cxx b/sc/source/ui/view/viewfun7.cxx new file mode 100644 index 000000000000..4c2d58f90dcd --- /dev/null +++ b/sc/source/ui/view/viewfun7.cxx @@ -0,0 +1,704 @@ +/************************************************************************* + * + * $RCSfile: viewfun7.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +#define _SV_NOXSOUND + +#ifdef WIN + #define _MENUBTN_HXX +#endif + +#define _BASE_DLGS_HXX +#define _BIGINT_HXX +#define _CACHESTR_HXX +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _CTRLTOOL_HXX +#define _DLGCFG_HXX +#define _DYNARR_HXX +#define _EXTATTR_HXX +#define _FILDLG_HXX +#define _FONTDLG_HXX +#define _FRM3D_HXX +#define _INTRO_HXX +#define _ISETBWR_HXX +#define _NO_SVRTF_PARSER_HXX +#define _MACRODLG_HXX +#define _MODALDLG_HXX +#define _MOREBUTTON_HXX +#define _OUTLINER_HXX +//#define _PRNDLG_HXX +//#define _POLY_HXX +#define _PVRWIN_HXX +#define _QUEUE_HXX +#define _RULER_HXX +#define _SCRWIN_HXX +#define _SETBRW_HXX +#define _STACK_HXX +//#define _STATUS_HXX +#define _STDCTRL_HXX +#define _STDMENU_HXX +//#define _TAB_HXX +#define _TABBAR_HXX +#define _TREELIST_HXX +#define _VALUESET_HXX +#define _VCATTR_HXX +#define _VCBRW_HXX +#define _VCTRLS_HXX +//#define _VCSBX_HXX +#define _VCONT_HXX +#define _VDRWOBJ_HXX + + +//SV +//#define _CLIP_HXX *** +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _FONTDLG_HXX +#define _PRVWIN_HXX +//#define _COLOR_HXX +//#define _PAL_HXX +//#define _BITMAP_HXX +//#define _GDIOBJ_HXX +//#define _POINTR_HXX +//#define _ICON_HXX +//#define _IMAGE_HXX +//#define _KEYCOD_HXX +//#define _EVENT_HXX +#define _HELP_HXX +//#define _APP_HXX +//#define _MDIAPP_HXX +//#define _TIMER_HXX +//#define _METRIC_HXX +//#define _REGION_HXX +//#define _OUTDEV_HXX +//#define _SYSTEM_HXX +//#define _VIRDEV_HXX +//#define _JOBSET_HXX +//#define _PRINT_HXX +//#define _WINDOW_HXX +//#define _SYSWIN_HXX +//#define _WRKWIN_HXX +#define _MDIWIN_HXX +//#define _FLOATWIN_HXX +//#define _DOCKWIN_HXX +//#define _CTRL_HXX +//#define _SCRBAR_HXX +//#define _BUTTON_HXX +//#define _IMAGEBTN_HXX +//#define _FIXED_HXX +//#define _GROUP_HXX +//#define _EDIT_HXX +//#define _COMBOBOX_HXX +//#define _LSTBOX_HXX +//#define _SELENG_HXX *** +//#define _SPLIT_HXX +#define _SPIN_HXX +//#define _FIELD_HXX +//#define _MOREBTN_HXX *** +//#define _TOOLBOX_HXX +//#define _STATUS_HXX *** +//#define _DIALOG_HXX +//#define _MSGBOX_HXX +//#define _SYSDLG_HXX +#define _FILDLG_HXX +//#define _PRNDLG_HXX +#define _COLDLG_HXX +//#define _TABDLG_HXX +#ifdef WIN +#define _MENU_HXX +#endif +//#define _GDIMTF_HXX +//#define _POLY_HXX +//#define _ACCEL_HXX +//#define _GRAPH_HXX +#define _SOUND_HXX + + +#define _PASSWD_HXX + +#define _SFX_DOCFILE_HXX +#define _SFX_DOCFILT_HXX +#define _SFX_DOCSH_HXX +#define _SFXDOCFILE_HXX +#define _SFXDOCFILT_HXX +//#define _SFXDOCINF_HXX +//#define _SFXDOCSH_HXX +#define _SFX_PRNMON_HXX +#define _SFX_RESMGR_HXX +#define _SFX_TEMPLDLG_HXX +//#define _SFXAPPWIN_HXX +#define _SFXBASIC_HXX +#define _SFXCTRLITEM +#define _SFXDLGCFG_HXX +#define _SFXDISPATCH_HXX +#define _SFXFILEDLG_HXX +//#define _SFXIMGMGR_HXX +#define _SFXIPFRM_HXX +#define _SFX_MACRO_HXX +#define _SFXMNUITEM_HXX +#define _SFXMNUMGR_HXX +#define _SFXMULTISEL_HXX +//#define _SFXMSG_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFX_MINFITEM_HXX +#define _SFXOBJFACE_HXX +#define _SFXOBJFAC_HXX +#define _SFX_SAVEOPT_HXX +#define _SFXSTBITEM_HXX +#define _SFXSTBMGR_HXX +#define _SFXTBXCTRL_HXX +#define _SFXTBXMGR_HXX + +//sfxdoc.hxx +//#define _SFX_OBJSH_HXX +//#define _SFX_CLIENTSH_HXX +//#define _SFXDOCINF_HXX +//#define _SFX_OBJFAC_HXX +#define _SFX_DOCFILT_HXX +//#define _SFXDOCFILE_HXX *** +//define _VIEWFAC_HXX +//#define _SFXVIEWFRM_HXX *** +//#define _SFXVIEWSH_HXX *** +//#define _MDIFRM_HXX *** +#define _SFX_IPFRM_HXX +//#define _SFX_INTERNO_HXX + +//sfxdlg.hxx +//#define _SFXTABDLG_HXX *** +//#define _BASEDLGS_HXX *** +#define _SFX_DINFDLG_HXX +#define _SFXDINFEDT_HXX +#define _SFX_MGETEMPL_HXX +#define _SFX_TPLPITEM_HXX +#define _SFX_STYLEDLG_HXX +#define _NEWSTYLE_HXX +//#define _SFXDOCTEMPL_HXX *** +//#define _SFXDOCTDLG_HXX *** +//#define _SFX_TEMPLDLG_HXX *** +//#define _SFXNEW_HXX *** +#define _SFXDOCMAN_HXX +//#define _SFXDOCKWIN_HXX + +//sfxitems.hxx +#define _SFX_WHMAP_HXX +#define _ARGS_HXX +//#define _SFXPOOLITEM_HXX +//#define _SFXINTITEM_HXX +//#define _SFXENUMITEM_HXX +#define _SFXFLAGITEM_HXX +//#define _SFXSTRITEM_HXX *** +#define _SFXPTITEM_HXX +#define _SFXRECTITEM_HXX +//#define _SFXITEMPOOL_HXX *** +//#define _SFXITEMSET_HXX *** +#define _SFXITEMITER_HXX +#define _SFX_WHITER_HXX +#define _SFXPOOLCACH_HXX +#define _AEITEM_HXX +#define _SFXRNGITEM_HXX +#define _SFXSLSTITM_HXX +#define _SFXSTYLE_HXX + +//xout.hxx +//#define _XENUM_HXX *** +//#define _XPOLY_HXX *** +//#define _XATTR_HXX *** +#define _XOUTX_HXX +//#define _XPOOL_HXX *** +#define _XTABLE_HXX + +//svdraw.hxx +//#define _SVDRAW_HXX +#define _SDR_NOITEMS +#define _SDR_NOTOUCH +#define _SDR_NOTRANSFORM +#define _SDR_NOVIEWMARKER +#define _SDR_NODRAGMETHODS +//#define _SDR_NOUNDO *** +#define _SDR_NOXOUTDEV +//#define _SDR_NOOBJECTS *** +//#define _SDR_NOVIEWS *** + +//inet +#define _INETINDP_HXX +#define _INETIMP_HXX +#define _INETWRAP_HXX +#define _INETKEEP_HXX +#define _PLUGMGR_HXX +#define _URLOBJ_HXX //* + +#define SFX_NOCLOOKS + +#define _SI_DLL_HXX +#define _SIDLL_HXX +#define _SI_NOITEMS +#define _SI_NOOTHERFORMS +#define _SI_NOSBXCONTROLS +#define _SINOSBXCONTROLS +#define _SI_NODRW +#define _SI_NOCONTROL +#define _SVBOXITM_HXX +#define _SVCONTNR_HXX +//#define _SVDATTR_HXX *** +#define _SVDEC_HXX +#define _SVDIO_HXX +#define _SVDRAG_HXX +#define _SVINCVW_HXX +#define _SV_MULTISEL_HXX +#define _SVRTV_HXX +#define _SVTABBX_HXX +#define _SVTREEBOX_HXX +#define _SVTREELIST_HXX + +#define _SVX_DAILDLL_HXX +#define _SVX_HYPHEN_HXX +#define _SVX_IMPGRF_HXX +#define _SVX_LAYCTRL_HXX +#define _SVX_OPTITEMS_HXX +#define _SVX_OPTGERL_HXX +#define _SVX_OPTSAVE_HXX +#define _SVX_OPTSPELL_HXX +#define _SVX_OPTPATH_HXX +#define _SVX_OPTLINGU_HXX +#define _SVX_RULER_HXX +#define _SVX_RULRITEM_HXX +#define _SVX_SELCTRL_HXX +#define _SVX_SPLWRAP_HXX +#define _SVX_SPLDLG_HXX +#define _SVX_STDDLG_HXX +#define _SVX_THESDLG_HXX + + +#define SI_NOITEMS +//#define SI_NODRW +#define _SI_NOSBXCONTROLS +#define _VCATTR_HXX +#define _VCONT_HXX +//#define _VCSBX_HXX +#define _SI_NOOTHERFORMS +#define _VCTRLS_HXX +//#define _VCDRWOBJ_HXX +#define _SI_NOCONTROL +#define _SETBRW_HXX +#define _VCBRW_HXX +#define _SI_NOSBXCONTROLS +#define _SIDLL_HXX + +//#define _SI_HXX +#define _SDR_NOTRANSFORM +#define _SDR_NOTOUCH +#define _SVDOPAGE_HXX // SdrPageObj +#define _SVDSURO_HXX // SdrObjSurrogate +#define _SVDOVIRT_HXX // SdrVirtObj +#define _SVDOGRP_HXX // SdrGroupObj +//#define _SVDOTEXT_HXX // SdrTextObj +#define _SVDOPATH_HXX // SdrPathObj +//#define _SVDOEDGE_HXX // SdrEdgeObj +//#define _SVDORECT_HXX // SdrRectObj (+SdrTextObj) +#define _SVDCAPT_HXX // SdrCaptionObj +#define _SVDOCIRC_HXX // SdrCircleObj +//#define _SVDOGRAF_HXX // SdrGrafObj (+SdrRectObj) +//#define _SVDOOLE2_HXX // SdrOle2Obj (+SdrRectObj) + + +// INCLUDE --------------------------------------------------------------- + +#include <so3/ipobj.hxx> +#include <svx/svditer.hxx> +#include <svx/svdograf.hxx> +#include <svx/svdoole2.hxx> +#include <svx/svdouno.hxx> +#include <svx/svdpage.hxx> +#include <svx/svdpagv.hxx> +#include <svx/svdundo.hxx> +#include <svx/xbitmap.hxx> +#include <svx/xbtmpit.hxx> +#include <svx/xoutbmp.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/viewfrm.hxx> + +#include "document.hxx" // fuer MapMode Initialisierung in PasteDraw +#include "viewfunc.hxx" +#include "tabvwsh.hxx" +#include "drawview.hxx" +#include "scmod.hxx" +#include "drwlayer.hxx" +#include "globstr.hrc" + +extern Point aDragStartDiff; + +// STATIC DATA ----------------------------------------------------------- + +BOOL bPasteIsMove = FALSE; + +//================================================================== + +void lcl_AdjustInsertPos( ScViewData* pData, Point& rPos, Size& rSize ) +{ +// SdrPage* pPage = pData->GetDocument()->GetDrawLayer()->GetPage( pData->GetTabNo() ); + SdrPage* pPage = pData->GetScDrawView()->GetModel()->GetPage( pData->GetTabNo() ); + DBG_ASSERT(pPage,"pPage ???"); + Size aPgSize( pPage->GetSize() ); + long x = aPgSize.Width() - rPos.X() - rSize.Width(); + long y = aPgSize.Height() - rPos.Y() - rSize.Height(); + // ggf. Ajustments (80/200) fuer Pixel-Rundungsfehler + if( x < 0 ) + rPos.X() += x + 80; + if( y < 0 ) + rPos.Y() += y + 200; + rPos.X() += rSize.Width() / 2; // Position bei Paste gibt Mittelpunkt an + rPos.Y() += rSize.Height() / 2; +} + +void ScViewFunc::PasteDraw( const Point& rLogicPos, SdrModel* pModel, BOOL bGroup ) +{ + MakeDrawLayer(); + Point aPos( rLogicPos ); + + // #64184# MapMode am Outliner-RefDevice muss stimmen (wie in FuText::MakeOutliner) + //! mit FuText::MakeOutliner zusammenfassen? + MapMode aOldMapMode; + OutputDevice* pRef = GetViewData()->GetDocument()->GetDrawLayer()->GetRefDevice(); + if (pRef) + { + aOldMapMode = pRef->GetMapMode(); + pRef->SetMapMode( MapMode(MAP_100TH_MM) ); + } + + SdrView* pDragEditView = SC_MOD()->GetDragData().pSdrView; + if (pDragEditView) + { + aPos -= aDragStartDiff; + if (aPos.X() < 0) aPos.X() = 0; + if (aPos.Y() < 0) aPos.Y() = 0; + } + + ScDrawView* pDrawView = GetScDrawView(); + if (bGroup) + pDrawView->BegUndo( ScGlobal::GetRscString( STR_UNDO_PASTE ) ); + + BOOL bSameDoc = ( pDragEditView && pDragEditView->GetModel() == pDrawView->GetModel() ); + if (bSameDoc) + { + // lokal kopieren - incl. Charts + + Point aSourceStart = pDragEditView->GetAllMarkedRect().TopLeft(); + long nDiffX = aPos.X() - aSourceStart.X(); + long nDiffY = aPos.Y() - aSourceStart.Y(); + + // innerhalb einer Page verschieben? + + if ( bPasteIsMove && + pDrawView->GetPageViewPvNum(0)->GetPage() == + pDragEditView->GetPageViewPvNum(0)->GetPage() ) + { + pDragEditView->MoveAllMarked(Size(nDiffX,nDiffY), FALSE); + } + else + { + SdrModel* pModel = pDragEditView->GetModel(); + SdrPage* pDestPage = pModel->GetPage( GetViewData()->GetTabNo() ); + DBG_ASSERT(pDestPage,"nanu, Page?"); + + SdrMarkList aMark = pDragEditView->GetMarkList(); + aMark.ForceSort(); + ULONG nMarkAnz=aMark.GetMarkCount(); + for (ULONG nm=0; nm<nMarkAnz; nm++) { + const SdrMark* pM=aMark.GetMark(nm); + const SdrObject* pObj=pM->GetObj(); + SdrObject* pNeuObj=pObj->Clone(pDestPage,pModel); + if (pNeuObj!=NULL) + { + // #68787# copy graphics within the same model - always needs new name + if ( pNeuObj->ISA(SdrGrafObj) && !bPasteIsMove ) + pNeuObj->SetName(((ScDrawLayer*)pModel)->GetNewGraphicName()); + + if (nDiffX!=0 || nDiffY!=0) + pNeuObj->NbcMove(Size(nDiffX,nDiffY)); + pDestPage->InsertObject( pNeuObj ); + pDrawView->AddUndo(new SdrUndoInsertObj( *pNeuObj )); + + // Chart braucht nicht mehr getrennt behandelt zu werden, + // weil es seine Daten jetzt selber hat + } + } + + if (bPasteIsMove) + pDragEditView->DeleteMarked(); + } + } + else + { + bPasteIsMove = FALSE; // kein internes Verschieben passiert + + SdrMarkView aView(pModel); + SdrPageView* pPv = aView.ShowPagePgNum(0,Point()); + aView.MarkAll(pPv); + Size aSize = aView.GetAllMarkedRect().GetSize(); + lcl_AdjustInsertPos( GetViewData(), aPos, aSize ); + + // #41333# Markierung nicht aendern, wenn Ole-Objekt aktiv + // (bei Drop aus Ole-Objekt wuerde sonst mitten im ExecuteDrag deaktiviert!) + + ULONG nOptions = 0; + SfxInPlaceClient* pClient = GetViewData()->GetViewShell()->GetIPClient(); + if ( pClient && pClient->IsInPlaceActive() ) + nOptions |= SDRINSERT_DONTMARK; + + pDrawView->Paste( *pModel, aPos, NULL, nOptions ); + + // #68991# Paste puts all objects on the active (front) layer + // controls must be on SC_LAYER_CONTROLS + + USHORT nTab = GetViewData()->GetTabNo(); + SdrPage* pPage = pDrawView->GetModel()->GetPage(nTab); + DBG_ASSERT(pPage,"Page?"); + if (pPage) + { + SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS ); + SdrObject* pObject = aIter.Next(); + while (pObject) + { + if ( pObject->ISA(SdrUnoObj) && pObject->GetLayer() != SC_LAYER_CONTROLS ) + pObject->NbcSetLayer(SC_LAYER_CONTROLS); + pObject = aIter.Next(); + } + } + + // #75299# all graphics objects must have names + GetViewData()->GetDocument()->EnsureGraphicNames(); + } + + if (bGroup) + { + pDrawView->GroupMarked(); + pDrawView->EndUndo(); + } + + if (pRef) + pRef->SetMapMode( aOldMapMode ); + + GetViewData()->GetViewShell()->SetDrawShell( TRUE ); +} + +BOOL ScViewFunc::PasteObject( const Point& rPos, SvInPlaceObject* pObj, + SvDataObject* pDataObject ) +{ + MakeDrawLayer(); + if ( pObj ) + { + SvEmbeddedInfoObject* pInfoObj = GetViewData()->GetViewShell()-> + GetViewFrame()->GetObjectShell()-> + InsertObject(pObj, String()); + String aName = pInfoObj->GetObjName(); + + MapMode aMap100( MAP_100TH_MM ); + MapMode aMapObj( pObj->GetMapUnit() ); + + Size aSize; + if (pDataObject) // Size aus DataObject in IPObject uebernehmen + { + SvObjectDescriptor aDesc(pDataObject); + Size aDescSize = aDesc.GetSize(); + if( aDescSize.Width() && aDescSize.Height() ) + pObj->SetVisAreaSize(OutputDevice::LogicToLogic( aDescSize, aMap100, aMapObj )); + } + + aSize = pObj->GetVisArea().GetSize(); + aSize = OutputDevice::LogicToLogic( aSize, aMapObj, aMap100 ); // fuer SdrOle2Obj + + if( aSize.Height() == 0 || aSize.Width() == 0 ) + { + DBG_ERROR("SvObjectDescriptor::GetSize == 0"); + aSize.Width() = 5000; + aSize.Height() = 5000; + aSize = OutputDevice::LogicToLogic( aSize, aMap100, aMapObj ); + pObj->SetVisAreaSize(aSize); + } + // kein AdjustInsertPos + Rectangle aRect( rPos, aSize ); + + ScDrawView* pDrView = GetScDrawView(); + SdrOle2Obj* pSdrObj = new SdrOle2Obj( pObj, aName, aRect ); + SdrPageView* pPV = pDrView->GetPageViewPvNum(0); + pDrView->InsertObjectSafe( pSdrObj, *pPV ); // nicht markieren wenn Ole + pSdrObj->SetOleLink(pInfoObj); + GetViewData()->GetViewShell()->SetDrawShell( TRUE ); + return TRUE; + } + else + return FALSE; +} + +BOOL ScViewFunc::PasteBitmap( const Point& rPos, const Bitmap& rBmp ) +{ + String aEmpty; + Graphic aGraphic(rBmp); + return PasteGraphic( rPos, aGraphic, aEmpty, aEmpty ); +} + +BOOL ScViewFunc::PasteMetaFile( const Point& rPos, const GDIMetaFile& rMtf ) +{ + String aEmpty; + Graphic aGraphic(rMtf); + return PasteGraphic( rPos, aGraphic, aEmpty, aEmpty ); +} + +BOOL ScViewFunc::PasteGraphic( const Point& rPos, const Graphic& rGraphic, + const String& rFile, const String& rFilter ) +{ + MakeDrawLayer(); + ScDrawView* pDrawView = GetScDrawView(); + + Point aPos( rPos ); + Window* pWin = GetActiveWin(); + MapMode aSourceMap = rGraphic.GetPrefMapMode(); + MapMode aDestMap( MAP_100TH_MM ); + + if (aSourceMap.GetMapUnit() == MAP_PIXEL) + { + // Pixel-Korrektur beruecksichtigen, damit Bitmap auf dem Bildschirm stimmt + + Fraction aScaleX, aScaleY; + pDrawView->CalcNormScale( aScaleX, aScaleY ); + aDestMap.SetScaleX(aScaleX); + aDestMap.SetScaleY(aScaleY); + } + + Size aSize = pWin->LogicToLogic( rGraphic.GetPrefSize(), &aSourceMap, &aDestMap ); +// lcl_AdjustInsertPos( GetViewData(), aPos, aSize ); + GetViewData()->GetViewShell()->SetDrawShell( TRUE ); + + Rectangle aRect(aPos, aSize); + SdrGrafObj* pGrafObj = new SdrGrafObj(rGraphic, aRect); + + if (rFile.Len()) + pGrafObj->SetGraphicLink( rFile, rFilter ); + + // #49961# Pfad wird nicht mehr als Name der Grafik gesetzt + + ScDrawLayer* pLayer = (ScDrawLayer*) pDrawView->GetModel(); + String aName = pLayer->GetNewGraphicName(); // "Grafik x" + pGrafObj->SetName(aName); + + // nicht markieren wenn Ole + pDrawView->InsertObjectSafe(pGrafObj, *pDrawView->GetPageViewPvNum(0)); + return TRUE; +} + +BOOL ScViewFunc::ApplyGraphicToObject( SdrObject* pPickObj, const Graphic& rGraphic ) +{ + BOOL bRet = FALSE; + SdrGrafObj* pNewGrafObj = NULL; + + ScDrawView* pDrawView = GetScDrawView(); + if ( pDrawView && pPickObj ) + { + /********************************************************************** + * Objekt neu attributieren + **********************************************************************/ + SdrPageView* pPV = pDrawView->GetPageViewPvNum(0); + if (pPickObj->ISA(SdrGrafObj)) + { + /****************************************************************** + * Das Graphik-Objekt bekommt eine neue Graphik + ******************************************************************/ + pNewGrafObj = (SdrGrafObj*) pPickObj->Clone(); + pNewGrafObj->SetGraphic(rGraphic); + + pDrawView->BegUndo(ScGlobal::GetRscString(STR_UNDO_DRAGDROP)); + pDrawView->ReplaceObject(pPickObj, *pPV, pNewGrafObj); + pDrawView->EndUndo(); + + bRet = TRUE; + } + else if (pPickObj->IsClosedObj() && !pPickObj->ISA(SdrOle2Obj)) + { + /****************************************************************** + * Das Objekt wird mit der Graphik gefuellt + ******************************************************************/ + //pDrawView->BegUndo(ScGlobal::GetRscString(STR_UNDO_DRAGDROP)); + pDrawView->AddUndo(new SdrUndoAttrObj(*pPickObj)); + //pDrawView->EndUndo(); + + XOBitmap aXOBitmap( XOutBitmap::GetBitmapFromGraphic( rGraphic ) ); + SfxItemSet aSet( pDrawView->GetModel()->GetItemPool(), + XATTR_FILLSTYLE, XATTR_FILLBITMAP ); + aSet.Put(XFillStyleItem(XFILL_BITMAP)); + aSet.Put(XFillBitmapItem(String(), aXOBitmap)); + pPickObj->SetAttributes(aSet, FALSE); + + bRet = TRUE; + } + } + return bRet; +} + + diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx new file mode 100644 index 000000000000..c2bde13e58d1 --- /dev/null +++ b/sc/source/ui/view/viewfunc.cxx @@ -0,0 +1,2511 @@ +/************************************************************************* + * + * $RCSfile: viewfunc.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------ + +#define _MACRODLG_HXX +#define _BIGINT_HXX +#define _SVDXOUT_HXX +#define _SVDATTR_HXX +#define _SVDSURO_HXX + +// INCLUDE --------------------------------------------------------------- + +#include "scitems.hxx" +#include <svx/algitem.hxx> +#include <svx/boxitem.hxx> +#include <svx/editobj.hxx> +#include <svx/editview.hxx> +#include <svx/eeitem.hxx> +#include <svx/langitem.hxx> +#include <sfx2/bindings.hxx> +#include <svtools/zforlist.hxx> +#include <svtools/zformat.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/sound.hxx> +#include <vcl/virdev.hxx> +#include <vcl/waitobj.hxx> +#include <vcl/wrkwin.hxx> +#include <stdlib.h> // qsort + +#include "viewfunc.hxx" +#include "tabvwsh.hxx" +#include "docsh.hxx" +#include "attrib.hxx" +#include "patattr.hxx" +#include "docpool.hxx" +#include "uiitems.hxx" +#include "sc.hrc" +#include "undocell.hxx" +#include "undoblk.hxx" +#include "undotab.hxx" +#include "refundo.hxx" +#include "dbcolect.hxx" +#include "olinetab.hxx" +#include "rangeutl.hxx" +#include "rangenam.hxx" +#include "globstr.hrc" +#include "global.hxx" +#include "stlsheet.hxx" +#include "editutil.hxx" +#include "namecrea.hxx" // wegen Flags +#include "cell.hxx" +#include "scresid.hxx" +#include "inputhdl.hxx" +#include "scmod.hxx" +#include "inputopt.hxx" +#include "compiler.hxx" +#include "docfunc.hxx" +#include "appoptio.hxx" + +// STATIC DATA ----------------------------------------------------------- + + +//================================================================== + +ScViewFunc::ScViewFunc( Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell ) : + ScTabView( pParent, rDocSh, pViewShell ), + bFormatValid( FALSE ) +{ +} + +ScViewFunc::ScViewFunc( Window* pParent, const ScViewFunc& rViewFunc, ScTabViewShell* pViewShell ) : + ScTabView( pParent, rViewFunc, pViewShell ), + bFormatValid( FALSE ) +{ +} + +ScViewFunc::~ScViewFunc() +{ +} + +//------------------------------------------------------------------------------------ + +void ScViewFunc::StartFormatArea() +{ + // ueberhaupt aktiviert? + if ( !SC_MOD()->GetInputOptions().GetExtendFormat() ) + return; + + USHORT nTab = GetViewData()->GetTabNo(); + ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), nTab ); + BOOL bOk = TRUE; + + ScMarkData& rMark = GetViewData()->GetMarkData(); + if ( rMark.IsMultiMarked() ) + rMark.MarkToSimple(); + if ( rMark.IsMultiMarked() ) + bOk = FALSE; + else if ( rMark.IsMarked() ) + { + ScRange aMarkRange; + rMark.GetMarkArea( aMarkRange ); + if ( aMarkRange.aStart == aMarkRange.aEnd ) + aPos = aMarkRange.aStart; + else + bOk = FALSE; + } + + if (bOk) + { + bFormatValid = TRUE; + aFormatSource = aPos; + aFormatArea = ScRange( aPos ); + } + else + bFormatValid = FALSE; // keinen alten Bereich behalten +} + +BOOL ScViewFunc::TestFormatArea( USHORT nCol, USHORT nRow, USHORT nTab, BOOL bAttrChanged ) +{ + // ueberhaupt aktiviert? + if ( !SC_MOD()->GetInputOptions().GetExtendFormat() ) + return FALSE; + + // Test: Eingabe mit Zahlformat (bAttrChanged) immer als neue Attributierung behandeln + // (alte Area verwerfen). Wenn das nicht gewollt ist, den if-Teil weglassen: + if ( bAttrChanged ) + { + StartFormatArea(); + return FALSE; + } + + //! Abfrage, ob Zelle leer war ??? + + BOOL bFound = FALSE; + ScRange aNewRange = aFormatArea; + if ( bFormatValid && nTab == aFormatSource.Tab() ) + { + if ( nRow >= aFormatArea.aStart.Row() && nRow <= aFormatArea.aEnd.Row() ) + { + // innerhalb ? + if ( nCol >= aFormatArea.aStart.Col() && nCol <= aFormatArea.aEnd.Col() ) + { + bFound = TRUE; // Bereich nicht aendern + } + // links ? + if ( nCol+1 == aFormatArea.aStart.Col() ) + { + bFound = TRUE; + aNewRange.aStart.SetCol( nCol ); + } + // rechts ? + if ( nCol == aFormatArea.aEnd.Col()+1 ) + { + bFound = TRUE; + aNewRange.aEnd.SetCol( nCol ); + } + } + if ( nCol >= aFormatArea.aStart.Col() && nCol <= aFormatArea.aEnd.Col() ) + { + // oben ? + if ( nRow+1 == aFormatArea.aStart.Row() ) + { + bFound = TRUE; + aNewRange.aStart.SetRow( nRow ); + } + // unten ? + if ( nRow == aFormatArea.aEnd.Row()+1 ) + { + bFound = TRUE; + aNewRange.aEnd.SetRow( nRow ); + } + } + } + + if (bFound) + aFormatArea = aNewRange; // erweitern + else + { + bFormatValid = FALSE; // ausserhalb -> abbrechen + if ( bAttrChanged ) // Wert mit Zahlformat eingegeben? + StartFormatArea(); // dann ggf. neu starten + } + + return bFound; +} + +void ScViewFunc::DoAutoAttributes( USHORT nCol, USHORT nRow, USHORT nTab, + BOOL bAttrChanged, BOOL bAddUndo ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + + const ScPatternAttr* pSource = pDoc->GetPattern( + aFormatSource.Col(), aFormatSource.Row(), nTab ); + if ( !((const ScMergeAttr&)pSource->GetItem(ATTR_MERGE)).IsMerged() ) + { + const ScPatternAttr* pDocOld = pDoc->GetPattern( nCol, nRow, nTab ); + // pDocOld ist nur bis zum Apply... gueltig! + + ScPatternAttr* pOldPattern = NULL; + if ( bAddUndo ) + pOldPattern = new ScPatternAttr( *pDocOld ); + + const ScStyleSheet* pSrcStyle = pSource->GetStyleSheet(); + if ( pSrcStyle && pSrcStyle != pDocOld->GetStyleSheet() ) + pDoc->ApplyStyle( nCol, nRow, nTab, *pSrcStyle ); + pDoc->ApplyPattern( nCol, nRow, nTab, *pSource ); + AdjustRowHeight( nRow, nRow, TRUE ); //! nicht doppelt ? + + if ( bAddUndo ) + { + const ScPatternAttr* pNewPattern = pDoc->GetPattern( nCol, nRow, nTab ); + + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoCursorAttr( pDocSh, nCol, nRow, nTab, + pOldPattern, pNewPattern, pSource, + TRUE ) ); + + delete pOldPattern; // wird im Undo kopiert (Pool) + } + } + + if ( bAttrChanged ) // Wert mit Zahlformat eingegeben? + aFormatSource.Set( nCol, nRow, nTab ); // dann als neue Quelle +} + +//------------------------------------------------------------------------------------ + +// Hilfsroutinen + +USHORT ScViewFunc::GetOptimalColWidth( USHORT nCol, USHORT nTab, BOOL bFormula ) +{ + ScDocument* pDoc = GetViewData()->GetDocument(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + VirtualDevice aVirtDev; + aVirtDev.SetMapMode(MAP_PIXEL); + USHORT nTwips = pDoc->GetOptimalColWidth( nCol, nTab, &aVirtDev, + GetViewData()->GetPPTX(), + GetViewData()->GetPPTY(), + GetViewData()->GetZoomX(), + GetViewData()->GetZoomY(), + bFormula, &rMark ); + return nTwips; +} + +BOOL ScViewFunc::SelectionEditable( BOOL* pOnlyNotBecauseOfMatrix /* = NULL */ ) +{ + BOOL bRet; + ScDocument* pDoc = GetViewData()->GetDocument(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + if (rMark.IsMarked() || rMark.IsMultiMarked()) + bRet = pDoc->IsSelectionEditable( rMark, pOnlyNotBecauseOfMatrix ); + else + { + USHORT nCol = GetViewData()->GetCurX(); + USHORT nRow = GetViewData()->GetCurY(); + USHORT nTab = GetViewData()->GetTabNo(); + bRet = pDoc->IsBlockEditable( nTab, nCol, nRow, nCol, nRow, + pOnlyNotBecauseOfMatrix ); + } + return bRet; +} + +#ifndef LRU_MAX +#define LRU_MAX 10 +#endif + +BOOL lcl_FunctionKnown( USHORT nOpCode ) +{ + const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList(); + if ( pFuncList ) + { + ULONG nCount = pFuncList->GetCount(); + for (ULONG i=0; i<nCount; i++) + if ( pFuncList->GetFunction(i)->nFIndex == nOpCode ) + return TRUE; + } + return FALSE; +} + +BOOL lcl_AddFunction( ScAppOptions& rAppOpt, USHORT nOpCode ) +{ + USHORT nOldCount = rAppOpt.GetLRUFuncListCount(); + USHORT* pOldList = rAppOpt.GetLRUFuncList(); + USHORT nPos; + for (nPos=0; nPos<nOldCount; nPos++) + if (pOldList[nPos] == nOpCode) // is the function already in the list? + { + if ( nPos == 0 ) + return FALSE; // already at the top -> no change + + // count doesn't change, so the original array is modified + + for (USHORT nCopy=nPos; nCopy>0; nCopy--) + pOldList[nCopy] = pOldList[nCopy-1]; + pOldList[0] = nOpCode; + + return TRUE; // list has changed + } + + if ( !lcl_FunctionKnown( nOpCode ) ) + return FALSE; // not in function list -> no change + + USHORT nNewCount = Min( (USHORT)(nOldCount + 1), (USHORT)LRU_MAX ); + USHORT nNewList[LRU_MAX]; + nNewList[0] = nOpCode; + for (nPos=1; nPos<nNewCount; nPos++) + nNewList[nPos] = pOldList[nPos-1]; + rAppOpt.SetLRUFuncList( nNewList, nNewCount ); + + return TRUE; // list has changed +} + +// eigentliche Funktionen + +// Eingabe - Undo OK + +void ScViewFunc::EnterData( USHORT nCol, USHORT nRow, USHORT nTab, const String& rString, + BOOL bRecord ) +{ + ScDocument* pDoc = GetViewData()->GetDocument(); + SvNumberFormatter& rFormatter = *pDoc->GetFormatTable(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + USHORT nTabCount = pDoc->GetTableCount(); + USHORT nSelCount = rMark.GetSelectCount(); + USHORT i; + + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocShellModificator aModificator( *pDocSh ); + + if (pDoc->IsSelectedBlockEditable( nCol,nRow, nCol,nRow, rMark )) + { + BOOL bEditDeleted = FALSE; + + ScBaseCell** ppOldCells = NULL; + BOOL* pHasFormat = NULL; + ULONG* pOldFormats = NULL; + USHORT* pTabs = NULL; + USHORT nUndoPos = 0; + if ( bRecord ) + { + ppOldCells = new ScBaseCell*[nSelCount]; + pHasFormat = new BOOL[nSelCount]; + pOldFormats = new ULONG[nSelCount]; + pTabs = new USHORT[nSelCount]; + nUndoPos = 0; + + for (i=0; i<nTabCount; i++) + if (rMark.GetTableSelect(i)) + { + pTabs[nUndoPos] = i; + ScBaseCell* pDocCell; + pDoc->GetCell( nCol, nRow, i, pDocCell ); + if ( pDocCell ) + { + ppOldCells[nUndoPos] = pDocCell->Clone(pDoc); + if ( pDocCell->GetCellType() == CELLTYPE_EDIT ) + bEditDeleted = TRUE; + } + else + { + ppOldCells[nUndoPos] = NULL; + } + + const SfxPoolItem* pItem; + const ScPatternAttr* pPattern = pDoc->GetPattern(nCol, nRow, i); + if ( SFX_ITEM_SET == pPattern->GetItemSet().GetItemState( + ATTR_VALUE_FORMAT,FALSE,&pItem) ) + { + pHasFormat[nUndoPos] = TRUE; + pOldFormats[nUndoPos] = ((const SfxUInt32Item*)pItem)->GetValue(); + } + else + pHasFormat[nUndoPos] = FALSE; + + ++nUndoPos; + } + + DBG_ASSERT( nUndoPos==nSelCount, "nUndoPos!=nSelCount" ); + } + + BOOL bNumFmtChanged = FALSE; + // einzelnes '=' ist String (wird fuer Spezialfilter so gebraucht) + if ( rString.GetChar(0) == '=' && rString.Len() > 1 ) + { // Formel, compile mit AutoCorrection + for (i=0; i<nTabCount; i++) + if (rMark.GetTableSelect(i)) + break; + ScAddress aPos( nCol, nRow, i ); + ScCompiler aComp( pDoc, aPos ); +//2do: AutoCorrection via CalcOptions abschaltbar machen + aComp.SetAutoCorrection( TRUE ); + String aFormula( rString ); + ScTokenArray* pArr; + BOOL bAgain; + do + { + bAgain = FALSE; + BOOL bAddEqual = FALSE; + ScTokenArray* pArrFirst = pArr = aComp.CompileString( aFormula ); + BOOL bCorrected = aComp.IsCorrected(); + if ( bCorrected ) + { // probieren, mit erster Parser-Korrektur neu zu parsen + pArr = aComp.CompileString( aComp.GetCorrectedFormula() ); + } + if ( !pArr->GetError() ) + { + bAddEqual = TRUE; + aComp.CompileTokenArray(); + bCorrected |= aComp.IsCorrected(); + } + if ( bCorrected ) + { + String aCorrectedFormula; + if ( bAddEqual ) + { + aCorrectedFormula = '='; + aCorrectedFormula += aComp.GetCorrectedFormula(); + } + else + aCorrectedFormula = aComp.GetCorrectedFormula(); + short nResult; + if ( aCorrectedFormula.Len() == 1 ) + nResult = RET_NO; // leere Formel, nur '=' + else + { + String aMessage( ScResId( SCSTR_FORMULA_AUTOCORRECTION ) ); + aMessage += aCorrectedFormula; + nResult = QueryBox( GetViewData()->GetDialogParent(), + WinBits(WB_YES_NO | WB_DEF_YES), + aMessage ).Execute(); + } + if ( nResult == RET_YES ) + { + aFormula = aCorrectedFormula; + if ( pArr != pArrFirst ) + delete pArrFirst; + bAgain = TRUE; + } + else + { + if ( pArr != pArrFirst ) + { + delete pArr; + pArr = pArrFirst; + } + } + } + } while ( bAgain ); + // um in mehreren Tabellen eingesetzt zu werden, muss die Formel + // via ScFormulaCell copy-ctor evtl. wegen RangeNames neu kompiliert + // werden, gleiches Code-Array fuer alle Zellen geht nicht. + // Wenn das Array einen Fehler enthaelt, muss in den neu erzeugten + // Zellen RPN geloescht und der Fehler explizit gesetzt werden, da + // via FormulaCell copy-ctor und Interpreter das, wenn moeglich, + // wieder glattgebuegelt wird, zu intelligent.. z.B.: =1)) + USHORT nError = pArr->GetError(); + if ( !nError ) + { + // #68693# update list of recent functions with all functions that + // are not within parentheses + + ScModule* pScMod = SC_MOD(); + ScAppOptions aAppOpt = pScMod->GetAppOptions(); + BOOL bOptChanged = FALSE; + + ScToken** ppToken = pArr->GetArray(); + USHORT nTokens = pArr->GetLen(); + USHORT nLevel = 0; + for (USHORT nTP=0; nTP<nTokens; nTP++) + { + ScToken* pTok = ppToken[nTP]; + OpCode eOp = pTok->GetOpCode(); + if ( eOp == ocOpen ) + ++nLevel; + else if ( eOp == ocClose && nLevel ) + --nLevel; + if ( nLevel == 0 && pTok->IsFunction() && lcl_AddFunction( aAppOpt, eOp ) ) + bOptChanged = TRUE; + } + + if ( bOptChanged ) + { + pScMod->SetAppOptions(aAppOpt); + pScMod->RecentFunctionsChanged(); + } + } + + ScFormulaCell aCell( pDoc, aPos, pArr, 0 ); + delete pArr; + BOOL bAutoCalc = pDoc->GetAutoCalc(); + SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + for ( ; i<nTabCount; i++) + { + if (rMark.GetTableSelect(i)) + { + aPos.SetTab( i ); + ULONG nIndex = (ULONG) ((SfxUInt32Item*) pDoc->GetAttr( + nCol, nRow, i, ATTR_VALUE_FORMAT ))->GetValue(); + if ( pFormatter->GetType(nIndex) == NUMBERFORMAT_TEXT ) + { + ScStringCell* pCell = new ScStringCell( aFormula ); + pDoc->PutCell( aPos, pCell ); + } + else + { + ScFormulaCell* pCell = new ScFormulaCell( pDoc, aPos, aCell ); + if ( nError ) + { + pCell->GetCode()->DelRPN(); + pCell->SetErrCode( nError ); + } + pDoc->PutCell( aPos, pCell ); + if ( !bAutoCalc ) + { // einmal nur die Zelle berechnen und wieder dirty setzen + pCell->Interpret(); + pCell->SetDirtyVar(); + pDoc->PutInFormulaTree( pCell ); + } + } + + } + } + } + else + { + for (i=0; i<nTabCount; i++) + if (rMark.GetTableSelect(i)) + if (pDoc->SetString( nCol, nRow, i, rString )) + bNumFmtChanged = TRUE; + } + + HideAllCursors(); + + if (bEditDeleted || pDoc->HasAttrib( nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_NEEDHEIGHT )) + AdjustRowHeight(nRow,nRow); + + BOOL bAutoFormat = TestFormatArea(nCol, nRow, nTab, bNumFmtChanged); + if (bAutoFormat) + DoAutoAttributes(nCol, nRow, nTab, bNumFmtChanged, bRecord); + + if ( bRecord ) + { // wg. ChangeTrack erst jetzt + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoEnterData( pDocSh, nCol, nRow, nTab, nUndoPos, pTabs, + ppOldCells, pHasFormat, pOldFormats, + rString, NULL ) ); + } + + for (i=0; i<nTabCount; i++) + if (rMark.GetTableSelect(i)) + pDocSh->PostPaintCell( nCol, nRow, i ); + + ShowAllCursors(); + + pDocSh->UpdateOle(GetViewData()); + aModificator.SetDocumentModified(); + } + else + { + ErrorMessage(STR_PROTECTIONERR); + PaintArea( nCol, nRow, nCol, nRow ); // da steht evtl. noch die Edit-Engine + } +} + +// Wert in einzele Zelle eintragen (nur auf nTab) +//! umbenennen in EnterValue !!!! + +void ScViewFunc::EnterData( USHORT nCol, USHORT nRow, USHORT nTab, const double& rValue ) +{ + ScDocument* pDoc = GetViewData()->GetDocument(); + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + + if ( pDoc && pDocSh ) + { + ScDocShellModificator aModificator( *pDocSh ); + + if (pDoc->IsBlockEditable( nTab, nCol,nRow, nCol,nRow )) + { + ScBaseCell* pOldCell; + pDoc->GetCell( nCol, nRow, nTab, pOldCell ); + BOOL bNeedHeight = ( pOldCell && pOldCell->GetCellType() == CELLTYPE_EDIT ) + || pDoc->HasAttrib( + nCol,nRow,nTab, nCol,nRow,nTab, HASATTR_NEEDHEIGHT ); + + // Undo + ScBaseCell* pUndoCell = pOldCell ? pOldCell->Clone(pDoc) : NULL; + + pDoc->SetValue( nCol, nRow, nTab, rValue ); + + // wg. ChangeTrack nach Aenderung im Dokument + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoEnterValue( pDocSh, ScAddress(nCol,nRow,nTab), + pUndoCell, rValue, bNeedHeight ) ); + +/*! Zeilenhoehe anpassen? Dann auch bei Undo... + if (bNeedHeight) + AdjustRowHeight(nRow,nRow); +*/ + + pDocSh->PostPaintCell( nCol, nRow, nTab ); + pDocSh->UpdateOle(GetViewData()); + aModificator.SetDocumentModified(); + } + else + ErrorMessage(STR_PROTECTIONERR); + } +} + +void ScViewFunc::EnterData( USHORT nCol, USHORT nRow, USHORT nTab, const EditTextObject* pData, + BOOL bRecord, BOOL bTestSimple ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + ScDocument* pDoc = pDocSh->GetDocument(); + + ScDocShellModificator aModificator( *pDocSh ); + + if (pDoc->IsBlockEditable( nTab, nCol,nRow, nCol,nRow )) + { + // + // Test auf Attribute + // + BOOL bSimple = FALSE; + BOOL bCommon = FALSE; + ScPatternAttr* pCellAttrs = NULL; + EditTextObject* pNewData = NULL; + String aString; + if (bTestSimple) // Testen, ob einfacher String ohne Attribute + { + const ScPatternAttr* pOldPattern = pDoc->GetPattern( nCol, nRow, nTab ); + ScTabEditEngine aEngine( *pOldPattern, pDoc->GetEnginePool() ); + aEngine.SetText(*pData); + + ScEditAttrTester aTester( &aEngine ); + bSimple = !aTester.NeedsObject(); + bCommon = aTester.NeedsCellAttr(); + + if (bCommon) // Attribute fuer Tabelle + { + pCellAttrs = new ScPatternAttr( *pOldPattern ); + pCellAttrs->GetFromEditItemSet( &aTester.GetAttribs() ); + //! remove common attributes from EditEngine? + } + + if (bSimple) + aString = aEngine.GetText(); + } + + // + // Undo + // + + USHORT nTabCount = pDoc->GetTableCount(); + USHORT nSelCount = rMark.GetSelectCount(); + USHORT i; + ScBaseCell** ppOldCells = NULL; + USHORT* pTabs = NULL; + USHORT nPos = 0; + EditTextObject* pUndoData = NULL; + if (bRecord && !bSimple) + { + ppOldCells = new ScBaseCell*[nSelCount]; + pTabs = new USHORT[nSelCount]; + nPos = 0; + + for (i=0; i<nTabCount; i++) + if (rMark.GetTableSelect(i)) + { + pTabs[nPos] = i; + ScBaseCell* pDocCell; + pDoc->GetCell( nCol, nRow, i, pDocCell ); + if ( pDocCell ) + ppOldCells[nPos] = pDocCell->Clone( pDoc ); + else + ppOldCells[nPos] = NULL; + ++nPos; + } + + DBG_ASSERT( nPos==nSelCount, "nPos!=nSelCount" ); + + pUndoData = pData->Clone(); + } + + // + // Daten eintragen + // + + if (bCommon) + pDoc->ApplyPattern(nCol,nRow,nTab,*pCellAttrs); //! Undo + + if (bSimple) + { + if (bCommon) + AdjustRowHeight(nRow,nRow); + + EnterData(nCol,nRow,nTab,aString,bRecord); + } + else + { + for (i=0; i<nTabCount; i++) + if (rMark.GetTableSelect(i)) + pDoc->PutCell( nCol, nRow, i, new ScEditCell( pData, pDoc, NULL ) ); + + if ( bRecord ) + { // wg. ChangeTrack erst jetzt + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoEnterData( pDocSh, nCol, nRow, nTab, nPos, pTabs, + ppOldCells, NULL, NULL, String(), + pUndoData ) ); + } + + HideAllCursors(); + + AdjustRowHeight(nRow,nRow); + + for (i=0; i<nTabCount; i++) + if (rMark.GetTableSelect(i)) + pDocSh->PostPaintCell( nCol, nRow, i ); + + ShowAllCursors(); + + pDocSh->UpdateOle(GetViewData()); + aModificator.SetDocumentModified(); + } + + delete pCellAttrs; + delete pNewData; + } + else + { + ErrorMessage(STR_PROTECTIONERR); + PaintArea( nCol, nRow, nCol, nRow ); // da steht evtl. noch die Edit-Engine + } +} + +void ScViewFunc::EnterDataAtCursor( const String& rString ) +{ + USHORT nPosX = GetViewData()->GetCurX(); + USHORT nPosY = GetViewData()->GetCurY(); + USHORT nTab = GetViewData()->GetTabNo(); + + EnterData( nPosX, nPosY, nTab, rString ); +} + +void ScViewFunc::EnterMatrix( const String& rString ) +{ + ScViewData* pData = GetViewData(); + const ScMarkData& rMark = pData->GetMarkData(); + if ( !rMark.IsMarked() && !rMark.IsMultiMarked() ) + { + // nichts markiert -> automatisch Block mit Groesse des Ergebnisses + // Formel temporaer berechnen, um an die Groesse heranzukommen + + ScDocument* pDoc = pData->GetDocument(); + USHORT nCol = pData->GetCurX(); + USHORT nRow = pData->GetCurY(); + USHORT nTab = pData->GetTabNo(); + ScFormulaCell aFormCell( pDoc, ScAddress(nCol,nRow,nTab), rString, MM_FORMULA ); + + USHORT nSizeX, nSizeY; + aFormCell.GetResultDimensions( nSizeX, nSizeY ); + if ( nSizeX && nSizeY && nCol+nSizeX-1 <= MAXCOL && nRow+nSizeY-1 <= MAXROW ) + { + ScRange aResult( nCol, nRow, nTab, nCol+nSizeX-1, nRow+nSizeY-1, nTab ); + MarkRange( aResult, FALSE ); + } + } + + ScRange aRange; + if (pData->GetSimpleArea(aRange)) + { + ScDocShell* pDocSh = pData->GetDocShell(); + BOOL bSuccess = pDocSh->GetDocFunc().EnterMatrix( aRange, &rMark, rString, FALSE ); + if (bSuccess) + pDocSh->UpdateOle(GetViewData()); + } + else + ErrorMessage(STR_NOMULTISELECT); +} + +const ScPatternAttr* ScViewFunc::GetSelectionPattern() +{ + const ScMarkData& rMark = GetViewData()->GetMarkData(); + ScDocument* pDoc = GetViewData()->GetDocument(); + if ( rMark.IsMarked() || rMark.IsMultiMarked() ) + { + // MarkToMulti ist fuer pDoc->GetSelectionPattern nicht mehr noetig + const ScPatternAttr* pAttr = pDoc->GetSelectionPattern( rMark ); + return pAttr; + } + else + { + USHORT nCol = GetViewData()->GetCurX(); + USHORT nRow = GetViewData()->GetCurY(); + USHORT nTab = GetViewData()->GetTabNo(); + + ScMarkData aTempMark( rMark ); // Tabellen kopieren + aTempMark.SetMarkArea( ScRange( nCol, nRow, nTab ) ); + const ScPatternAttr* pAttr = pDoc->GetSelectionPattern( aTempMark ); + return pAttr; + } +} + +void ScViewFunc::GetSelectionFrame( SvxBoxItem& rLineOuter, + SvxBoxInfoItem& rLineInner ) +{ + ScDocument* pDoc = GetViewData()->GetDocument(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + + if ( rMark.IsMarked() || rMark.IsMultiMarked() ) + { + pDoc->GetSelectionFrame( rMark, rLineOuter, rLineInner ); + } + else + { + const ScPatternAttr* pAttrs = + pDoc->GetPattern( GetViewData()->GetCurX(), + GetViewData()->GetCurY(), + GetViewData()->GetTabNo() ); + + rLineOuter = (const SvxBoxItem&) (pAttrs->GetItem( ATTR_BORDER )); + rLineInner = (const SvxBoxInfoItem&)(pAttrs->GetItem( ATTR_BORDER_INNER )); + rLineInner.SetTable(FALSE); + rLineInner.SetDist((BOOL)FALSE); + rLineInner.SetMinDist(FALSE); + } +} + +// +// Attribute anwenden - Undo OK +// +// kompletter Set ( ATTR_STARTINDEX, ATTR_ENDINDEX ) +// + +void ScViewFunc::ApplyAttributes( const SfxItemSet* pDialogSet, + const SfxItemSet* pOldSet, + BOOL bRecord ) +{ + // nur wegen Matrix nicht editierbar? Attribute trotzdem ok + BOOL bOnlyNotBecauseOfMatrix; + if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix ) + { + ErrorMessage(STR_PROTECTIONERR); + return; + } + + ScPatternAttr aOldAttrs( new SfxItemSet(*pOldSet) ); + ScPatternAttr aNewAttrs( new SfxItemSet(*pDialogSet) ); + aNewAttrs.DeleteUnchanged( &aOldAttrs ); + + ULONG nOldFormat = + ((const SfxUInt32Item&)pOldSet->Get( ATTR_VALUE_FORMAT )).GetValue(); + ULONG nNewFormat = + ((const SfxUInt32Item&)pDialogSet->Get( ATTR_VALUE_FORMAT )).GetValue(); + if ( nNewFormat != nOldFormat ) + { + SvNumberFormatter* pFormatter = + GetViewData()->GetDocument()->GetFormatTable(); + const SvNumberformat* pOldEntry = pFormatter->GetEntry( nOldFormat ); + LanguageType eOldLang = + pOldEntry ? pOldEntry->GetLanguage() : LANGUAGE_DONTKNOW; + const SvNumberformat* pNewEntry = pFormatter->GetEntry( nNewFormat ); + LanguageType eNewLang = + pNewEntry ? pNewEntry->GetLanguage() : LANGUAGE_DONTKNOW; + if ( eNewLang != eOldLang ) + { + aNewAttrs.GetItemSet().Put( + SvxLanguageItem( eNewLang, ATTR_LANGUAGE_FORMAT ) ); + + // #40606# nur die Sprache geaendert -> Zahlformat-Attribut nicht anfassen + ULONG nNewMod = nNewFormat % SV_COUNTRY_LANGUAGE_OFFSET; + if ( nNewMod == ( nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET ) && + nNewMod <= SV_MAX_ANZ_STANDARD_FORMATE ) + aNewAttrs.GetItemSet().ClearItem( ATTR_VALUE_FORMAT ); + } + } + + const SvxBoxItem* pOldOuter = (const SvxBoxItem*) &pOldSet->Get( ATTR_BORDER ); + const SvxBoxItem* pNewOuter = (const SvxBoxItem*) &pDialogSet->Get( ATTR_BORDER ); + const SvxBoxInfoItem* pOldInner = (const SvxBoxInfoItem*) &pOldSet->Get( ATTR_BORDER_INNER ); + const SvxBoxInfoItem* pNewInner = (const SvxBoxInfoItem*) &pDialogSet->Get( ATTR_BORDER_INNER ); + SfxItemSet& rNewSet = aNewAttrs.GetItemSet(); + SfxItemPool* pNewPool = rNewSet.GetPool(); + + pNewPool->Put( *pNewOuter ); // noch nicht loeschen + pNewPool->Put( *pNewInner ); + rNewSet.ClearItem( ATTR_BORDER ); + rNewSet.ClearItem( ATTR_BORDER_INNER ); + + /* + * Feststellen, ob Rahmenattribute zu setzen sind: + * 1. Neu != Alt + * 2. Ist eine der Linien nicht-DontCare (seit 238.f: IsxxValid()) + * + */ + + BOOL bFrame = (pDialogSet->GetItemState( ATTR_BORDER ) != SFX_ITEM_DEFAULT) + || (pDialogSet->GetItemState( ATTR_BORDER_INNER ) != SFX_ITEM_DEFAULT); + + if ( pNewOuter==pOldOuter && pNewInner==pOldInner ) + bFrame = FALSE; + + // das sollte doch der Pool abfangen: ?!??!?? + + if ( bFrame && pNewOuter && pNewInner ) + if ( *pNewOuter == *pOldOuter && *pNewInner == *pOldInner ) + bFrame = FALSE; + + if ( pNewInner ) + { + bFrame = bFrame + && ( pNewInner->IsValid(VALID_LEFT) + || pNewInner->IsValid(VALID_RIGHT) + || pNewInner->IsValid(VALID_TOP) + || pNewInner->IsValid(VALID_BOTTOM) + || pNewInner->IsValid(VALID_HORI) + || pNewInner->IsValid(VALID_VERT) ); + } + else + bFrame = FALSE; + + if (!bFrame) + ApplySelectionPattern( aNewAttrs, bRecord ); // nur normale + else + { + // wenn neue Items Default-Items sind, so muessen die + // alten Items geputtet werden: + + BOOL bDefNewOuter = ( SFX_ITEMS_STATICDEFAULT == pNewOuter->GetRef() ); + BOOL bDefNewInner = ( SFX_ITEMS_STATICDEFAULT == pNewInner->GetRef() ); + + ApplyPatternLines( aNewAttrs, + bDefNewOuter ? pOldOuter : pNewOuter, + bDefNewInner ? pOldInner : pNewInner, + bRecord ); + } + + pNewPool->Remove( *pNewOuter ); // freigeben + pNewPool->Remove( *pNewInner ); + + // Hoehen anpassen + AdjustBlockHeight(); + + // CellContentChanged wird von ApplySelectionPattern / ApplyPatternLines gerufen +} + +void ScViewFunc::ApplyAttr( const SfxPoolItem& rAttrItem ) +{ + // nur wegen Matrix nicht editierbar? Attribute trotzdem ok + BOOL bOnlyNotBecauseOfMatrix; + if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix ) + { + ErrorMessage(STR_PROTECTIONERR); + return; + } + + ScPatternAttr aNewAttrs( new SfxItemSet( *GetViewData()->GetDocument()->GetPool(), + ATTR_PATTERN_START, ATTR_PATTERN_END ) ); + + aNewAttrs.GetItemSet().Put( rAttrItem ); + // Wenn Ausrichtung eingestellt wird (ueber Buttons), immer Einzug 0 + if ( rAttrItem.Which() == ATTR_HOR_JUSTIFY ) + aNewAttrs.GetItemSet().Put( SfxUInt16Item( ATTR_INDENT, 0 ) ); + ApplySelectionPattern( aNewAttrs ); + + AdjustBlockHeight(); + + // CellContentChanged wird von ApplySelectionPattern gerufen +} + + +// Pattern und Rahmen + +void ScViewFunc::ApplyPatternLines( const ScPatternAttr& rAttr, const SvxBoxItem* pNewOuter, + const SvxBoxInfoItem* pNewInner, BOOL bRecord ) +{ + ScDocument* pDoc = GetViewData()->GetDocument(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + + USHORT nStartCol; + USHORT nStartRow; + USHORT nStartTab; + USHORT nEndCol; + USHORT nEndRow; + USHORT nEndTab; + + if (GetViewData()->GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab,TRUE)) + { + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + + ScDocShellModificator aModificator( *pDocSh ); + + if (!rMark.IsMarked()) + { + DoneBlockMode(); + InitOwnBlockMode(); + rMark.SetMarkArea( ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab ) ); + } + + if (bRecord) + { + USHORT nTabCount = pDoc->GetTableCount(); + ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + pUndoDoc->InitUndo( pDoc, nStartTab, nStartTab ); + for (USHORT i=0; i<nTabCount; i++) + if (i != nStartTab && rMark.GetTableSelect(i)) + pUndoDoc->AddUndoTab( i, i ); + pDoc->CopyToDocument( nStartCol, nStartRow, 0, nEndCol, nEndRow, nTabCount-1, + IDF_ATTRIB, FALSE, pUndoDoc ); + + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoSelectionAttr( pDocSh, rMark, + nStartCol, nStartRow, nStartTab, + nEndCol, nEndRow, nEndTab, + pUndoDoc, FALSE, &rAttr, pNewOuter, pNewInner ) ); + } + + BOOL bOldLines = pDoc->HasAttrib( nStartCol, nStartRow, nStartTab, + nEndCol, nEndRow, nEndTab, + HASATTR_PAINTEXT ); + + pDoc->ApplySelectionFrame( rMark, pNewOuter, pNewInner ); + + BOOL bNewLines = pDoc->HasAttrib( nStartCol, nStartRow, nStartTab, + nEndCol, nEndRow, nEndTab, + HASATTR_PAINTEXT ); + + rMark.MarkToMulti(); + pDoc->ApplySelectionPattern( rAttr, rMark ); + + USHORT nExt = SC_PF_TESTMERGE; + if (bOldLines || bNewLines) nExt |= SC_PF_LINES; + pDocSh->PostPaint( nStartCol, nStartRow, nStartTab, + nEndCol, nEndRow, nEndTab, + PAINT_GRID, nExt ); + pDocSh->UpdateOle(GetViewData()); + aModificator.SetDocumentModified(); + CellContentChanged(); + rMark.MarkToSimple(); + } + else + { // "Rahmen nicht auf Mehrfachselektion" + ErrorMessage(STR_MSSG_APPLYPATTLINES_0); + } + + StartFormatArea(); +} + +// nur Pattern + +void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr, + BOOL bRecord, BOOL bCursorOnly ) +{ + ScViewData* pViewData = GetViewData(); + ScDocShell* pDocSh = pViewData->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + ScMarkData& rMark = pViewData->GetMarkData(); + + ScDocShellModificator aModificator( *pDocSh ); + + USHORT nStartCol; + USHORT nStartRow; + USHORT nStartTab; + USHORT nEndCol; + USHORT nEndRow; + USHORT nEndTab; + + BOOL bMulti = rMark.IsMultiMarked(); + rMark.MarkToMulti(); + BOOL bOnlyTab = (!rMark.IsMultiMarked() && !bCursorOnly && rMark.GetSelectCount() > 1); + if (bOnlyTab) + { + USHORT nCol = pViewData->GetCurX(); + USHORT nRow = pViewData->GetCurY(); + USHORT nTab = pViewData->GetTabNo(); + ScAddress aCursor(nCol,nRow,nTab); + rMark.SetMarkArea(ScRange(aCursor,aCursor)); + rMark.MarkToMulti(); + } + + if (rMark.IsMultiMarked() && !bCursorOnly) + { + if (bRecord) + { + ScRange aMarkRange; + rMark.GetMultiMarkArea( aMarkRange ); + nStartCol = aMarkRange.aStart.Col(); + nStartRow = aMarkRange.aStart.Row(); + nStartTab = aMarkRange.aStart.Tab(); + nEndCol = aMarkRange.aEnd.Col(); + nEndRow = aMarkRange.aEnd.Row(); + nEndTab = aMarkRange.aEnd.Tab(); + + ScRange aCopyRange = aMarkRange; + USHORT nTabCount = pDoc->GetTableCount(); + aCopyRange.aStart.SetTab(0); + aCopyRange.aEnd.SetTab(nTabCount-1); + + ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + pUndoDoc->InitUndo( pDoc, nStartTab, nStartTab ); + for (USHORT i=0; i<nTabCount; i++) + if (i != nStartTab && rMark.GetTableSelect(i)) + pUndoDoc->AddUndoTab( i, i ); + pDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, bMulti, pUndoDoc, &rMark ); + + rMark.MarkToMulti(); + + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoSelectionAttr( + pDocSh, rMark, + nStartCol, nStartRow, nStartTab, + nEndCol, nEndRow, nEndTab, + pUndoDoc, bMulti, &rAttr ) ); + } + + pDoc->ApplySelectionPattern( rAttr, rMark ); + + if (bOnlyTab) + rMark.ResetMark(); + else + rMark.MarkToSimple(); + + pDocSh->PostPaint( nStartCol, nStartRow, nStartTab, + nEndCol, nEndRow, nEndTab, + PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE ); + pDocSh->UpdateOle(GetViewData()); + aModificator.SetDocumentModified(); + CellContentChanged(); + } + else // einzelne Zelle - Undo einfacher + { + USHORT nCol = pViewData->GetCurX(); + USHORT nRow = pViewData->GetCurY(); + USHORT nTab = pViewData->GetTabNo(); + ScPatternAttr* pOldPat = new ScPatternAttr(*pDoc->GetPattern( nCol, nRow, nTab )); + + const SfxItemSet& rOldSet = pOldPat->GetItemSet(); + BOOL bOldLines = rOldSet.GetItemState( ATTR_BORDER, TRUE ) == SFX_ITEM_SET || + rOldSet.GetItemState( ATTR_SHADOW, TRUE ) == SFX_ITEM_SET; + const SfxItemSet& rNewSet = rAttr.GetItemSet(); + BOOL bNewLines = rNewSet.GetItemState( ATTR_BORDER, TRUE ) == SFX_ITEM_SET || + rNewSet.GetItemState( ATTR_SHADOW, TRUE ) == SFX_ITEM_SET; + + pDoc->ApplyPattern( nCol, nRow, nTab, rAttr ); + + const ScPatternAttr* pNewPat = pDoc->GetPattern( nCol, nRow, nTab ); + + if (bRecord) + { + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoCursorAttr( pDocSh, + nCol, nRow, nTab, + pOldPat, pNewPat, &rAttr, + FALSE ) ); // FALSE = nicht automatisch + } + delete pOldPat; // wird im Undo kopiert (Pool) + + USHORT nFlags = 0; + if ( bOldLines || bNewLines ) + nFlags |= SC_PF_LINES; + + pDocSh->PostPaint( nCol,nRow,nTab, nCol,nRow,nTab, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE ); + pDocSh->UpdateOle(GetViewData()); + aModificator.SetDocumentModified(); + CellContentChanged(); + } + + StartFormatArea(); +} + +const SfxStyleSheet* ScViewFunc::GetStyleSheetFromMarked() +{ + const ScStyleSheet* pSheet = NULL; + ScViewData* pViewData = GetViewData(); + ScDocument* pDoc = pViewData->GetDocument(); + ScMarkData& rMark = pViewData->GetMarkData(); + + if ( rMark.IsMarked() || rMark.IsMultiMarked() ) + pSheet = pDoc->GetSelectionStyle( rMark ); // MarkToMulti nicht noetig !! + else + pSheet = pDoc->GetStyle( pViewData->GetCurX(), + pViewData->GetCurY(), + pViewData->GetTabNo() ); + + return pSheet; +} + +void ScViewFunc::SetStyleSheetToMarked( SfxStyleSheet* pStyleSheet, BOOL bRecord ) +{ + // nur wegen Matrix nicht editierbar? Attribute trotzdem ok + BOOL bOnlyNotBecauseOfMatrix; + if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix ) + { + ErrorMessage(STR_PROTECTIONERR); + return; + } + + if ( !pStyleSheet) return; + // ------------------------------------------------------------------- + + ScViewData* pViewData = GetViewData(); + ScDocShell* pDocSh = pViewData->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + ScMarkData& rMark = pViewData->GetMarkData(); + USHORT nTabCount = pDoc->GetTableCount(); + + ScDocShellModificator aModificator( *pDocSh ); + + if ( rMark.IsMarked() || rMark.IsMultiMarked() ) + { + ScRange aMarkRange; + rMark.MarkToMulti(); + rMark.GetMultiMarkArea( aMarkRange ); + + if ( bRecord ) + { + USHORT nTab = pViewData->GetTabNo(); + ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + pUndoDoc->InitUndo( pDoc, nTab, nTab ); + for (USHORT i=0; i<nTabCount; i++) + if (i != nTab && rMark.GetTableSelect(i)) + pUndoDoc->AddUndoTab( i, i ); + + ScRange aCopyRange = aMarkRange; + aCopyRange.aStart.SetTab(0); + aCopyRange.aEnd.SetTab(nTabCount-1); + pDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, TRUE, pUndoDoc, &rMark ); + rMark.MarkToMulti(); + + String aName = pStyleSheet->GetName(); + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoSelectionStyle( pDocSh, rMark, aMarkRange, aName, pUndoDoc ) ); + } + + pDoc->ApplySelectionStyle( (ScStyleSheet&)*pStyleSheet, rMark ); + + if (!AdjustBlockHeight()) + pViewData->GetDocShell()->PostPaint( aMarkRange, PAINT_GRID ); + + rMark.MarkToSimple(); + } + else + { + USHORT nCol = pViewData->GetCurX(); + USHORT nRow = pViewData->GetCurY(); + USHORT nTab = pViewData->GetTabNo(); + + if ( bRecord ) + { + ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + pUndoDoc->InitUndo( pDoc, nTab, nTab ); + for (USHORT i=0; i<nTabCount; i++) + if (i != nTab && rMark.GetTableSelect(i)) + pUndoDoc->AddUndoTab( i, i ); + + ScRange aCopyRange( nCol, nRow, 0, nCol, nRow, nTabCount-1 ); + pDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, FALSE, pUndoDoc ); + + ScRange aMarkRange ( nCol, nRow, nTab ); + ScMarkData aUndoMark = rMark; + aUndoMark.SetMultiMarkArea( aMarkRange ); + + String aName = pStyleSheet->GetName(); + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoSelectionStyle( pDocSh, aUndoMark, aMarkRange, aName, pUndoDoc ) ); + } + + for (USHORT i=0; i<nTabCount; i++) + if (rMark.GetTableSelect(i)) + pDoc->ApplyStyle( nCol, nRow, i, (ScStyleSheet&)*pStyleSheet ); + + if (!AdjustBlockHeight()) + pViewData->GetDocShell()->PostPaintCell( nCol, nRow, nTab ); + + } + + aModificator.SetDocumentModified(); + + StartFormatArea(); +} + + +void ScViewFunc::RemoveStyleSheetInUse( SfxStyleSheet* pStyleSheet ) +{ + if ( !pStyleSheet) return; + // ------------------------------------------------------------------- + + ScViewData* pViewData = GetViewData(); + ScDocument* pDoc = pViewData->GetDocument(); + ScDocShell* pDocSh = pViewData->GetDocShell(); + + ScDocShellModificator aModificator( *pDocSh ); + + VirtualDevice aVirtDev; + aVirtDev.SetMapMode(MAP_PIXEL); + pDoc->StyleSheetChanged( pStyleSheet, TRUE, &aVirtDev, + pViewData->GetPPTX(), + pViewData->GetPPTY(), + pViewData->GetZoomX(), + pViewData->GetZoomY() ); + + pDocSh->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT ); + aModificator.SetDocumentModified(); + + ScInputHandler* pHdl = SC_MOD()->GetInputHdl(); + if (pHdl) + pHdl->ForgetLastPattern(); +} + +void ScViewFunc::UpdateStyleSheetInUse( SfxStyleSheet* pStyleSheet ) +{ + if ( !pStyleSheet) return; + // ------------------------------------------------------------------- + + ScViewData* pViewData = GetViewData(); + ScDocument* pDoc = pViewData->GetDocument(); + ScDocShell* pDocSh = pViewData->GetDocShell(); + + ScDocShellModificator aModificator( *pDocSh ); + + VirtualDevice aVirtDev; + aVirtDev.SetMapMode(MAP_PIXEL); + pDoc->StyleSheetChanged( pStyleSheet, FALSE, &aVirtDev, + pViewData->GetPPTX(), + pViewData->GetPPTY(), + pViewData->GetZoomX(), + pViewData->GetZoomY() ); + + pDocSh->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT ); + aModificator.SetDocumentModified(); + + ScInputHandler* pHdl = SC_MOD()->GetInputHdl(); + if (pHdl) + pHdl->ForgetLastPattern(); +} + +// Zellen einfuegen - Undo OK + +BOOL ScViewFunc::InsertCells( InsCellCmd eCmd, BOOL bRecord ) +{ + ScRange aRange; + if (GetViewData()->GetSimpleArea(aRange)) + { + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + BOOL bSuccess = pDocSh->GetDocFunc().InsertCells( aRange, eCmd, bRecord, FALSE ); + if (bSuccess) + { + pDocSh->UpdateOle(GetViewData()); + CellContentChanged(); + } + return bSuccess; + } + else + { + ErrorMessage(STR_NOMULTISELECT); + return FALSE; + } +} + +// Zellen loeschen - Undo OK + +void ScViewFunc::DeleteCells( DelCellCmd eCmd, BOOL bRecord ) +{ + ScRange aRange; + if (GetViewData()->GetSimpleArea(aRange)) + { + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + pDocSh->GetDocFunc().DeleteCells( aRange, eCmd, bRecord, FALSE ); + + pDocSh->UpdateOle(GetViewData()); + CellContentChanged(); + + // #58106# Cursor direkt hinter den geloeschten Bereich setzen + USHORT nCurX = GetViewData()->GetCurX(); + USHORT nCurY = GetViewData()->GetCurY(); + if ( eCmd==DEL_CELLSLEFT || eCmd==DEL_DELCOLS ) + nCurX = aRange.aStart.Col(); + else + nCurY = aRange.aStart.Row(); + SetCursor( nCurX, nCurY ); + } + else + { + if (eCmd == DEL_DELCOLS) + DeleteMulti( FALSE, bRecord ); + else if (eCmd == DEL_DELROWS) + DeleteMulti( TRUE, bRecord ); + else + ErrorMessage(STR_NOMULTISELECT); + } + + Unmark(); +} + +void ScViewFunc::DeleteMulti( BOOL bRows, BOOL bRecord ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocShellModificator aModificator( *pDocSh ); + USHORT nTab = GetViewData()->GetTabNo(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + ScDocument* pDoc = pDocSh->GetDocument(); + USHORT* pRanges = new USHORT[MAXROW+1]; + USHORT nRangeCnt = bRows ? rMark.GetMarkRowRanges( pRanges ) : + rMark.GetMarkColumnRanges( pRanges ); + if (!nRangeCnt) + { + pRanges[0] = pRanges[1] = bRows ? GetViewData()->GetCurY() : GetViewData()->GetCurX(); + nRangeCnt = 1; + } + + // Test ob erlaubt + + USHORT* pOneRange = pRanges; + BOOL bAllowed = TRUE; + USHORT nRangeNo; + for (nRangeNo=0; nRangeNo<nRangeCnt && bAllowed; nRangeNo++) + { + USHORT nStart = *(pOneRange++); + USHORT nEnd = *(pOneRange++); + + //! ... + } + + // ausfuehren + + WaitObject aWait( GetFrameWin() ); // wichtig wegen TrackFormulas bei UpdateReference + + ScDocument* pUndoDoc = NULL; + ScRefUndoData* pUndoData = NULL; + if (bRecord) + { + pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + pUndoDoc->InitUndo( pDoc, nTab, nTab, !bRows, bRows ); // Zeilenhoehen + + pOneRange = pRanges; + for (nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++) + { + USHORT nStart = *(pOneRange++); + USHORT nEnd = *(pOneRange++); + if (bRows) + pDoc->CopyToDocument( 0,nStart,nTab, MAXCOL,nEnd,nTab, IDF_ALL,FALSE,pUndoDoc ); + else + pDoc->CopyToDocument( nStart,0,nTab, nEnd,MAXROW,nTab, IDF_ALL,FALSE,pUndoDoc ); + } + + // alle Formeln wegen Referenzen + USHORT nTabCount = pDoc->GetTableCount(); + pUndoDoc->AddUndoTab( 0, nTabCount-1, FALSE, FALSE ); + pDoc->CopyToDocument( 0,0,0, MAXCOL,MAXROW,MAXTAB, IDF_FORMULA,FALSE,pUndoDoc ); + + pUndoData = new ScRefUndoData( pDoc ); + + pDoc->BeginDrawUndo(); + } + + pOneRange = &pRanges[2*nRangeCnt]; // rueckwaerts + for (nRangeNo=0; nRangeNo<nRangeCnt && bAllowed; nRangeNo++) + { + USHORT nEnd = *(--pOneRange); + USHORT nStart = *(--pOneRange); + + if (bRows) + pDoc->DeleteRow( 0,nTab, MAXCOL,nTab, nStart, nEnd-nStart+1 ); + else + pDoc->DeleteCol( 0,nTab, MAXROW,nTab, nStart, nEnd-nStart+1 ); + } + + if (bRecord) + { + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoDeleteMulti( pDocSh, bRows, nTab, pRanges, nRangeCnt, + pUndoDoc, pUndoData ) ); + } + + if (!AdjustRowHeight(0, MAXROW)) + if (bRows) + pDocSh->PostPaint( 0,pRanges[0],nTab, MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_LEFT ); + else + pDocSh->PostPaint( pRanges[0],0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_TOP ); + aModificator.SetDocumentModified(); + + CellContentChanged(); + + // #58106# Cursor direkt hinter den ersten geloeschten Bereich setzen + USHORT nCurX = GetViewData()->GetCurX(); + USHORT nCurY = GetViewData()->GetCurY(); + if ( bRows ) + nCurY = pRanges[0]; + else + nCurX = pRanges[0]; + SetCursor( nCurX, nCurY ); + + delete[] pRanges; +} + +// Inhalte loeschen + +void ScViewFunc::DeleteContents( USHORT nFlags, BOOL bRecord ) +{ + // nur wegen Matrix nicht editierbar? Attribute trotzdem ok + BOOL bOnlyNotBecauseOfMatrix; + BOOL bEditable = SelectionEditable( &bOnlyNotBecauseOfMatrix ); + if ( !bEditable ) + { + if ( !(bOnlyNotBecauseOfMatrix && + ((nFlags & (IDF_ATTRIB | IDF_EDITATTR)) == nFlags)) ) + { + ErrorMessage(STR_PROTECTIONERR); + return; + } + } + + ScRange aMarkRange; + BOOL bSimple = FALSE; + + ScDocument* pDoc = GetViewData()->GetDocument(); + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + + ScDocShellModificator aModificator( *pDocSh ); + + if ( !rMark.IsMarked() && !rMark.IsMultiMarked() ) + { + aMarkRange.aStart.SetCol(GetViewData()->GetCurX()); + aMarkRange.aStart.SetRow(GetViewData()->GetCurY()); + aMarkRange.aStart.SetTab(GetViewData()->GetTabNo()); + aMarkRange.aEnd = aMarkRange.aStart; + if ( pDoc->HasAttrib( aMarkRange, HASATTR_MERGED ) ) + { + InitOwnBlockMode(); + rMark.SetMarkArea( aMarkRange ); + } + else + bSimple = TRUE; + } + + rMark.SetMarking(FALSE); // fuer MarkToMulti + + DBG_ASSERT( rMark.IsMarked() || rMark.IsMultiMarked() || bSimple, "was denn loeschen ???" ) + + ScDocument* pUndoDoc = NULL; + BOOL bMulti = !bSimple && rMark.IsMultiMarked(); + if (!bSimple) + { + rMark.MarkToMulti(); + rMark.GetMultiMarkArea( aMarkRange ); + } + ScRange aExtendedRange(aMarkRange); + if (!bSimple) + { + if ( pDoc->ExtendMerge( aExtendedRange, TRUE ) ) + bMulti = FALSE; + } + + // keine Objekte auf geschuetzten Tabellen + BOOL bObjects = FALSE; + if ( nFlags & IDF_OBJECTS ) + { + bObjects = TRUE; + USHORT nTabCount = pDoc->GetTableCount(); + for (USHORT nTab=0; nTab<nTabCount; nTab++) + if (rMark.GetTableSelect(nTab) && pDoc->IsTabProtected(nTab)) + bObjects = FALSE; + } + + USHORT nExtFlags = 0; // Linien interessieren nur, wenn Attribute + if ( nFlags & IDF_ATTRIB ) // geloescht werden + if (pDoc->HasAttrib( aMarkRange, HASATTR_PAINTEXT )) + nExtFlags |= SC_PF_LINES; + + // Reihenfolge: + // 1) BeginDrawUndo + // 2) Objekte loeschen (DrawUndo wird gefuellt) + // 3) Inhalte fuer Undo kopieren + // 4) Inhalte loeschen + // 5) Undo-Aktion anlegen + + if (bObjects) + { + if (bRecord) + pDoc->BeginDrawUndo(); + + if (bMulti) + pDoc->DeleteObjectsInSelection( rMark ); + else + pDoc->DeleteObjectsInArea( aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), +/*!*/ aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(), + rMark ); + } + + if ( bRecord ) + { + pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + USHORT nTab = aMarkRange.aStart.Tab(); + pUndoDoc->InitUndo( pDoc, nTab, nTab ); + USHORT nTabCount = pDoc->GetTableCount(); + for (USHORT i=0; i<nTabCount; i++) + if (i != nTab && rMark.GetTableSelect(i)) + pUndoDoc->AddUndoTab( i, i ); + ScRange aCopyRange = aExtendedRange; + aCopyRange.aStart.SetTab(0); + aCopyRange.aEnd.SetTab(nTabCount-1); + + // bei "Format/Standard" alle Attribute kopieren, weil CopyToDocument + // nur mit IDF_HARDATTR zu langsam ist: + USHORT nUndoDocFlags = nFlags; + if (nFlags & IDF_ATTRIB) + nUndoDocFlags |= IDF_ATTRIB; + if (nFlags & IDF_EDITATTR) // Edit-Engine-Attribute + nUndoDocFlags |= IDF_STRING; // -> Zellen werden geaendert + if (nFlags & IDF_NOTE) + nUndoDocFlags |= IDF_CONTENTS; // #68795# copy all cells with their notes + pDoc->CopyToDocument( aCopyRange, nUndoDocFlags, bMulti, pUndoDoc, &rMark ); + } + + HideAllCursors(); // falls Zusammenfassung aufgehoben wird + if (bSimple) + pDoc->DeleteArea( aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), + aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(), + rMark, nFlags ); + else + { + pDoc->DeleteSelection( nFlags, rMark ); + rMark.MarkToSimple(); + } + + if ( bRecord ) + { + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoDeleteContents( pDocSh, rMark, aExtendedRange, + pUndoDoc, bMulti, nFlags, bObjects ) ); + } + + if (!AdjustRowHeight( aExtendedRange.aStart.Row(), aExtendedRange.aEnd.Row() )) + pDocSh->PostPaint( aExtendedRange, PAINT_GRID, nExtFlags ); + + pDocSh->UpdateOle(GetViewData()); + aModificator.SetDocumentModified(); + CellContentChanged(); + ShowAllCursors(); + + if ( nFlags & IDF_ATTRIB ) + { + if ( nFlags & IDF_CONTENTS ) + ForgetFormatArea(); + else + StartFormatArea(); // Attribute loeschen ist auch Attributierung + } +} + +// Spaltenbreiten/Zeilenhoehen (ueber Header) - Undo OK + +void ScViewFunc::SetWidthOrHeight( BOOL bWidth, USHORT nRangeCnt, USHORT* pRanges, + ScSizeMode eMode, USHORT nSizeTwips, BOOL bRecord, BOOL bPaint ) +{ + if (!nRangeCnt) + return; + + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + USHORT nTab = GetViewData()->GetTabNo(); + + ScDocShellModificator aModificator( *pDocSh ); + + BOOL bAllowed = TRUE; + for ( USHORT i=0; i<nRangeCnt && bAllowed; i++ ) + { + BOOL bOnlyMatrix; + if (bWidth) + bAllowed = pDoc->IsBlockEditable( nTab, + pRanges[2*i],0, pRanges[2*i+1],MAXROW, &bOnlyMatrix ) || bOnlyMatrix; + else + bAllowed = pDoc->IsBlockEditable( nTab, + 0,pRanges[2*i], MAXCOL,pRanges[2*i+1], &bOnlyMatrix ) || bOnlyMatrix; + } + if ( !bAllowed ) + { + ErrorMessage(STR_PROTECTIONERR); + return; + } + + ScMarkData& rMark = GetViewData()->GetMarkData(); + + USHORT nStart = pRanges[0]; + USHORT nEnd = pRanges[2*nRangeCnt-1]; + + BOOL bFormula = FALSE; + if ( eMode == SC_SIZE_OPTIMAL ) + { + const ScViewOptions& rOpts = GetViewData()->GetOptions(); + bFormula = rOpts.GetOption( VOPT_FORMULAS ); + } + + ScDocument* pUndoDoc = NULL; + ScOutlineTable* pUndoTab = NULL; + USHORT* pUndoRanges = NULL; + + if ( bRecord ) + { + pDoc->BeginDrawUndo(); // Drawing Updates + + pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + if (bWidth) + { + pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, FALSE ); + pDoc->CopyToDocument( nStart, 0, nTab, nEnd, MAXROW, nTab, IDF_NONE, FALSE, pUndoDoc ); + } + else + { + pUndoDoc->InitUndo( pDoc, nTab, nTab, FALSE, TRUE ); + pDoc->CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, FALSE, pUndoDoc ); + } + + pUndoRanges = new USHORT[ 2*nRangeCnt ]; + memmove( pUndoRanges, pRanges, 2*nRangeCnt*sizeof(USHORT) ); + + ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab ); + if (pTable) + pUndoTab = new ScOutlineTable( *pTable ); + } + + if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT ) + rMark.MarkToMulti(); + + BOOL bShow = nSizeTwips > 0 || eMode != SC_SIZE_DIRECT; + BOOL bOutline = FALSE; + + pDoc->IncSizeRecalcLevel( nTab ); // nicht fuer jede Spalte einzeln + for (USHORT nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++) + { + USHORT nStartNo = *(pRanges++); + USHORT nEndNo = *(pRanges++); + + if ( !bWidth ) // Hoehen immer blockweise + { + if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT ) + { + BOOL bAll = ( eMode==SC_SIZE_OPTIMAL ); + if (!bAll) + { + // fuer alle eingeblendeten CR_MANUALSIZE loeschen, + // dann SetOptimalHeight mit bShrink = FALSE + for (USHORT nRow=nStartNo; nRow<=nEndNo; nRow++) + { + BYTE nOld = pDoc->GetRowFlags(nRow,nTab); + if ( (nOld & CR_HIDDEN) == 0 && ( nOld & CR_MANUALSIZE ) ) + pDoc->SetRowFlags( nRow, nTab, nOld & ~CR_MANUALSIZE ); + } + } + VirtualDevice aVirtDev; + pDoc->SetOptimalHeight( nStartNo, nEndNo, nTab, nSizeTwips, &aVirtDev, + GetViewData()->GetPPTX(), + GetViewData()->GetPPTY(), + GetViewData()->GetZoomX(), + GetViewData()->GetZoomY(), bAll ); + if (bAll) + pDoc->ShowRows( nStartNo, nEndNo, nTab, TRUE ); + + // Manual-Flag wird bei bAll=TRUE schon in SetOptimalHeight gesetzt + // (an bei Extra-Height, sonst aus). + } + else if ( eMode==SC_SIZE_DIRECT ) + { + if (nSizeTwips) + pDoc->SetRowHeightRange( nStartNo, nEndNo, nTab, nSizeTwips ); + pDoc->ShowRows( nStartNo, nEndNo, nTab, nSizeTwips != 0 ); + pDoc->SetManualHeight( nStartNo, nEndNo, nTab, TRUE ); // Manual-Flag + } + else if ( eMode==SC_SIZE_SHOW ) + { + pDoc->ShowRows( nStartNo, nEndNo, nTab, TRUE ); + } + } + else // Spaltenbreiten + { + for (USHORT nCol=nStartNo; nCol<=nEndNo; nCol++) + { + if ( eMode != SC_SIZE_VISOPT || + (pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN) == 0 ) + { + USHORT nThisSize = nSizeTwips; + + if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT ) + nThisSize = nSizeTwips + GetOptimalColWidth( nCol, nTab, bFormula ); + if ( nThisSize ) + pDoc->SetColWidth( nCol, nTab, nThisSize ); + + pDoc->ShowCol( nCol, nTab, bShow ); + } + } + } + + // Outline anpassen + + if (bWidth) + bOutline = bOutline || pDoc->UpdateOutlineCol( nStartNo, nEndNo, nTab, bShow ); + else + bOutline = bOutline || pDoc->UpdateOutlineRow( nStartNo, nEndNo, nTab, bShow ); + } + pDoc->DecSizeRecalcLevel( nTab ); // nicht fuer jede Spalte einzeln + + if (!bOutline) + DELETEZ(pUndoTab); + + if (bRecord) + { + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoWidthOrHeight( pDocSh, rMark, + nStart, nTab, nEnd, nTab, + pUndoDoc, nRangeCnt, pUndoRanges, + pUndoTab, eMode, nSizeTwips, bWidth ) ); + } + + pDoc->UpdatePageBreaks( nTab ); + GetViewData()->GetView()->UpdateScrollBars(); + + if (bPaint) + { + HideCursor(); + + if (bWidth) + { + if (pDoc->HasAttrib( nStart,0,nTab, nEnd,MAXROW,nTab, HASATTR_MERGED | HASATTR_OVERLAPPED )) + nStart = 0; + if (nStart) // weiter oben anfangen wegen Linien und Cursor + --nStart; + pDocSh->PostPaint( nStart, 0, nTab, MAXCOL, MAXROW, nTab, PAINT_GRID | PAINT_TOP ); + } + else + { + if (pDoc->HasAttrib( 0,nStart,nTab, MAXCOL,nEnd,nTab, HASATTR_MERGED | HASATTR_OVERLAPPED )) + nStart = 0; + if (nStart) + --nStart; + pDocSh->PostPaint( 0, nStart, nTab, MAXCOL, MAXROW, nTab, PAINT_GRID | PAINT_LEFT ); + } + pDocSh->UpdateOle(GetViewData()); + aModificator.SetDocumentModified(); + + ShowCursor(); + } +} + +// Spaltenbreiten/Zeilenhoehen (ueber Blockmarken) + +void ScViewFunc::SetMarkedWidthOrHeight( BOOL bWidth, ScSizeMode eMode, USHORT nSizeTwips, + BOOL bRecord, BOOL bPaint ) +{ + ScDocument* pDoc = GetViewData()->GetDocument(); + ScMarkData& rMark = GetViewData()->GetMarkData(); + + rMark.MarkToMulti(); + if (!rMark.IsMultiMarked()) + { + USHORT nCol = GetViewData()->GetCurX(); + USHORT nRow = GetViewData()->GetCurY(); + USHORT nTab = GetViewData()->GetTabNo(); + DoneBlockMode(); + InitOwnBlockMode(); + rMark.SetMultiMarkArea( ScRange( nCol,nRow,nTab ), TRUE ); + } + + USHORT* pRanges = new USHORT[MAXROW+1]; + USHORT nRangeCnt = 0; + + if ( bWidth ) + nRangeCnt = rMark.GetMarkColumnRanges( pRanges ); + else + nRangeCnt = rMark.GetMarkRowRanges( pRanges ); + + SetWidthOrHeight( bWidth, nRangeCnt, pRanges, eMode, nSizeTwips, bRecord, bPaint ); + + delete[] pRanges; + rMark.MarkToSimple(); +} + +void ScViewFunc::ModifyCellSize( ScDirection eDir, BOOL bOptimal ) +{ + //! Schrittweiten einstellbar + // Schrittweite ist auch Minimum + USHORT nStepX = STD_COL_WIDTH / 5; + USHORT nStepY = ScGlobal::nStdRowHeight; + + ScModule* pScMod = SC_MOD(); + BOOL bAnyEdit = pScMod->IsInputMode(); + USHORT nCol = GetViewData()->GetCurX(); + USHORT nRow = GetViewData()->GetCurY(); + USHORT nTab = GetViewData()->GetTabNo(); + ScDocument* pDoc = GetViewData()->GetDocument(); + + BOOL bAllowed, bOnlyMatrix; + if ( eDir == DIR_LEFT || eDir == DIR_RIGHT ) + bAllowed = pDoc->IsBlockEditable( nTab, nCol,0, nCol,MAXROW, &bOnlyMatrix ); + else + bAllowed = pDoc->IsBlockEditable( nTab, 0,nRow, MAXCOL,nRow, &bOnlyMatrix ); + if ( !bAllowed && !bOnlyMatrix ) + { + ErrorMessage(STR_PROTECTIONERR); + return; + } + + HideAllCursors(); + + USHORT nWidth = pDoc->GetColWidth( nCol, nTab ); + USHORT nHeight = pDoc->GetRowHeight( nRow, nTab ); + USHORT nRange[2]; + if ( eDir == DIR_LEFT || eDir == DIR_RIGHT ) + { + if (bOptimal) // Breite dieser einen Zelle + { + if ( bAnyEdit ) + { + // beim Editieren die aktuelle Breite der Eingabe + ScInputHandler* pHdl = pScMod->GetInputHdl( GetViewData()->GetViewShell() ); + if (pHdl) + { + long nEdit = pHdl->GetTextSize().Width(); // in 1/100mm + + const ScPatternAttr* pPattern = pDoc->GetPattern( nCol, nRow, nTab ); + const SvxMarginItem& rMItem = + (const SvxMarginItem&)pPattern->GetItem(ATTR_MARGIN); + USHORT nMargin = rMItem.GetLeftMargin() + rMItem.GetRightMargin(); + if ( ((const SvxHorJustifyItem&) pPattern-> + GetItem( ATTR_HOR_JUSTIFY )).GetValue() == SVX_HOR_JUSTIFY_LEFT ) + nMargin += ((const SfxUInt16Item&)pPattern->GetItem(ATTR_INDENT)).GetValue(); + + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + nWidth = (USHORT)(nEdit * pDocSh->GetOutputFactor() / HMM_PER_TWIPS) + + nMargin + STD_EXTRA_WIDTH; + } + } + else + { + VirtualDevice aVirtDev; + aVirtDev.SetMapMode(MAP_PIXEL); + long nPixel = pDoc->GetNeededSize( nCol, nRow, nTab, &aVirtDev, + GetViewData()->GetPPTX(), GetViewData()->GetPPTY(), + GetViewData()->GetZoomX(), GetViewData()->GetZoomY(), + TRUE ); + USHORT nTwips = (USHORT)( nPixel / GetViewData()->GetPPTX() ); + if (nTwips != 0) + nWidth = nTwips + STD_EXTRA_WIDTH; + else + nWidth = STD_COL_WIDTH; + } + } + else // vergroessern / verkleinern + { + if ( eDir == DIR_RIGHT ) + nWidth += nStepX; + else if ( nWidth > nStepX ) + nWidth -= nStepX; + if ( nWidth < nStepX ) nWidth = nStepX; + if ( nWidth > MAX_COL_WIDTH ) nWidth = MAX_COL_WIDTH; + } + nRange[0] = nRange[1] = nCol; + SetWidthOrHeight( TRUE, 1, nRange, SC_SIZE_DIRECT, nWidth ); + + // hier bei Breite auch Hoehe anpassen (nur die eine Zeile) + + if (!bAnyEdit) + { + const ScPatternAttr* pPattern = pDoc->GetPattern( nCol, nRow, nTab ); + BOOL bNeedHeight = + ((const SfxBoolItem&)pPattern->GetItem( ATTR_LINEBREAK )).GetValue() || + ((const SvxHorJustifyItem&)pPattern-> + GetItem( ATTR_HOR_JUSTIFY )).GetValue() == SVX_HOR_JUSTIFY_BLOCK; + if (bNeedHeight) + AdjustRowHeight( nRow, nRow ); + } + } + else + { + ScSizeMode eMode; + if (bOptimal) + { + eMode = SC_SIZE_OPTIMAL; + nHeight = 0; + } + else + { + eMode = SC_SIZE_DIRECT; + if ( eDir == DIR_BOTTOM ) + nHeight += nStepY; + else if ( nHeight > nStepY ) + nHeight -= nStepY; + if ( nHeight < nStepY ) nHeight = nStepY; + if ( nHeight > MAX_COL_HEIGHT ) nHeight = MAX_COL_HEIGHT; + //! MAX_COL_HEIGHT umbenennen in MAX_ROW_HEIGHT in global.hxx !!!!!! + } + nRange[0] = nRange[1] = nRow; + SetWidthOrHeight( FALSE, 1, nRange, eMode, nHeight ); + } + + if ( bAnyEdit ) + { + UpdateEditView(); + if ( pDoc->HasAttrib( nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_NEEDHEIGHT ) ) + { + ScInputHandler* pHdl = pScMod->GetInputHdl( GetViewData()->GetViewShell() ); + if (pHdl) + pHdl->SetModified(); // damit bei Enter die Hoehe angepasst wird + } + } + + ShowAllCursors(); +} + +void ScViewFunc::Protect( USHORT nTab, const String& rPassword ) +{ + ScMarkData& rMark = GetViewData()->GetMarkData(); + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocFunc aFunc(*pDocSh); + + if ( nTab == TABLEID_DOC || rMark.GetSelectCount() <= 1 ) + aFunc.Protect( nTab, rPassword, FALSE ); + else + { + // modifying several tables is handled here + + String aUndo = ScGlobal::GetRscString( STR_UNDO_PROTECT_TAB ); + pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo ); + + USHORT nCount = pDocSh->GetDocument()->GetTableCount(); + for ( USHORT i=0; i<nCount; i++ ) + if ( rMark.GetTableSelect(i) ) + aFunc.Protect( i, rPassword, FALSE ); + + pDocSh->GetUndoManager()->LeaveListAction(); + } + + UpdateLayerLocks(); //! broadcast to all views +} + +BOOL ScViewFunc::Unprotect( USHORT nTab, const String& rPassword ) +{ + ScMarkData& rMark = GetViewData()->GetMarkData(); + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocFunc aFunc(*pDocSh); + BOOL bChanged = FALSE; + + if ( nTab == TABLEID_DOC || rMark.GetSelectCount() <= 1 ) + bChanged = aFunc.Unprotect( nTab, rPassword, FALSE ); + else + { + // modifying several tables is handled here + + String aUndo = ScGlobal::GetRscString( STR_UNDO_UNPROTECT_TAB ); + pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo ); + + USHORT nCount = pDocSh->GetDocument()->GetTableCount(); + for ( USHORT i=0; i<nCount; i++ ) + if ( rMark.GetTableSelect(i) ) + if ( aFunc.Unprotect( i, rPassword, FALSE ) ) + bChanged = TRUE; + + pDocSh->GetUndoManager()->LeaveListAction(); + } + + if (bChanged) + UpdateLayerLocks(); //! broadcast to all views + + return bChanged; +} + +void ScViewFunc::SetNote( USHORT nCol, USHORT nRow, USHORT nTab, const ScPostIt& rNote ) +{ + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + pDocSh->GetDocFunc().SetNote( ScAddress(nCol,nRow,nTab), rNote, FALSE ); +} + +void ScViewFunc::SetNumberFormat( short nFormatType, ULONG nAdd ) +{ + // nur wegen Matrix nicht editierbar? Attribute trotzdem ok + BOOL bOnlyNotBecauseOfMatrix; + if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix ) + { + ErrorMessage(STR_PROTECTIONERR); + return; + } + + ULONG nNumberFormat = 0; + ScViewData* pViewData = GetViewData(); + ScDocument* pDoc = pViewData->GetDocument(); + SvNumberFormatter* pNumberFormatter = pDoc->GetFormatTable(); + LanguageType eLanguage = ScGlobal::eLnge; + ScPatternAttr aNewAttrs( pDoc->GetPool() ); + + // #67936# always take language from cursor position, even if there is a selection + + ULONG nCurrentNumberFormat; + pDoc->GetNumberFormat( pViewData->GetCurX(), + pViewData->GetCurY(), + pViewData->GetTabNo(), + nCurrentNumberFormat ); + const SvNumberformat* pEntry = pNumberFormatter->GetEntry( nCurrentNumberFormat ); + if (pEntry) + eLanguage = pEntry->GetLanguage(); // sonst ScGlobal::eLnge behalten + + nNumberFormat = pNumberFormatter->GetStandardFormat( nFormatType, eLanguage ) + nAdd; + + SfxItemSet& rSet = aNewAttrs.GetItemSet(); + rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNumberFormat ) ); + // ATTR_LANGUAGE_FORMAT nicht + ApplySelectionPattern( aNewAttrs, TRUE ); +} + +void ScViewFunc::SetNumFmtByStr( const String& rCode ) +{ + // nur wegen Matrix nicht editierbar? Attribute trotzdem ok + BOOL bOnlyNotBecauseOfMatrix; + if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix ) + { + ErrorMessage(STR_PROTECTIONERR); + return; + } + + ScViewData* pViewData = GetViewData(); + ScDocument* pDoc = pViewData->GetDocument(); + SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + + // Sprache immer von Cursorposition + + ULONG nCurrentNumberFormat; + pDoc->GetNumberFormat( pViewData->GetCurX(), pViewData->GetCurY(), + pViewData->GetTabNo(), nCurrentNumberFormat ); + const SvNumberformat* pEntry = pFormatter->GetEntry( nCurrentNumberFormat ); + LanguageType eLanguage = pEntry ? pEntry->GetLanguage() : ScGlobal::eLnge; + + // Index fuer String bestimmen + + BOOL bOk = TRUE; + ULONG nNumberFormat = pFormatter->GetEntryKey( rCode, eLanguage ); + if ( nNumberFormat == NUMBERFORMAT_ENTRY_NOT_FOUND ) + { + // neu eintragen + + String aFormat = rCode; // wird veraendert + xub_StrLen nErrPos = 0; + short nType = 0; //! ??? + bOk = pFormatter->PutEntry( aFormat, nErrPos, nType, nNumberFormat, eLanguage ); + } + + if ( bOk ) // gueltiges Format? + { + ScPatternAttr aNewAttrs( pDoc->GetPool() ); + SfxItemSet& rSet = aNewAttrs.GetItemSet(); + rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNumberFormat ) ); + rSet.Put( SvxLanguageItem( eLanguage, ATTR_LANGUAGE_FORMAT ) ); + ApplySelectionPattern( aNewAttrs, TRUE ); + } + + //! sonst Fehler zuerueckgeben / Meldung ausgeben ??? +} + +void ScViewFunc::ChangeNumFmtDecimals( BOOL bIncrement ) +{ + // nur wegen Matrix nicht editierbar? Attribute trotzdem ok + BOOL bOnlyNotBecauseOfMatrix; + if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix ) + { + ErrorMessage(STR_PROTECTIONERR); + return; + } + + ScDocument* pDoc = GetViewData()->GetDocument(); + SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + + USHORT nCol = GetViewData()->GetCurX(); + USHORT nRow = GetViewData()->GetCurY(); + USHORT nTab = GetViewData()->GetTabNo(); + + ULONG nOldFormat; + pDoc->GetNumberFormat( nCol, nRow, nTab, nOldFormat ); + const SvNumberformat* pOldEntry = pFormatter->GetEntry( nOldFormat ); + if (!pOldEntry) + { + DBG_ERROR("Zahlformat nicht gefunden !!!"); + return; + } + + // was haben wir denn da? + + ULONG nNewFormat = nOldFormat; + BOOL bError = FALSE; + + LanguageType eLanguage = pOldEntry->GetLanguage(); + BOOL bThousand, bNegRed; + USHORT nPrecision, nLeading; + // GetFormatSpecialInfo ist nicht-const + ((SvNumberformat*)pOldEntry)->GetFormatSpecialInfo( + bThousand, bNegRed, nPrecision, nLeading ); + + short nOldType = pOldEntry->GetType(); + if ( 0 == ( nOldType & ( + NUMBERFORMAT_NUMBER | NUMBERFORMAT_CURRENCY | NUMBERFORMAT_PERCENT ) ) ) + { + // Datum, Zeit, Bruch, logisch, Text kann nicht angepasst werden + //! bei Wisssenschaftlich kann es der Numberformatter auch nicht + bError = TRUE; + } + + //! Das SvNumberformat hat einen Member bStandard, verraet ihn aber nicht + BOOL bWasStandard = ( nOldFormat == pFormatter->GetStandardIndex( eLanguage ) ); + if (bWasStandard) + { + // bei "Standard" die Nachkommastellen abhaengig vom Zellinhalt + // 0 bei leer oder Text -> keine Nachkommastellen + double nVal = pDoc->GetValue( ScAddress( nCol, nRow, nTab ) ); + + // Die Wege des Numberformatters sind unergruendlich, darum ausprobieren: + String aOut; + Color* pCol; + ((SvNumberformat*)pOldEntry)->GetOutputString( nVal, aOut, &pCol ); + + nPrecision = 0; + // 'E' fuer Exponential ist fest im Numberformatter + if ( aOut.Search('E') != STRING_NOTFOUND ) + bError = TRUE; // Exponential nicht veraendern + else + { + sal_Unicode cDecSep; + if ( eLanguage == ScGlobal::pScInternational->GetLanguage() ) + cDecSep = ScGlobal::pScInternational->GetNumDecimalSep(); + else + cDecSep = International(eLanguage).GetNumDecimalSep(); + xub_StrLen nPos = aOut.Search( cDecSep ); + if ( nPos != STRING_NOTFOUND ) + nPrecision = aOut.Len() - nPos - 1; + // sonst 0 behalten + } + } + + if (!bError) + { + if (bIncrement) + { + if (nPrecision<20) + ++nPrecision; // erhoehen + else + bError = TRUE; // 20 ist Maximum + } + else + { + if (nPrecision) + --nPrecision; // vermindern + else + bError = TRUE; // weniger als 0 geht nicht + } + } + + if (!bError) + { + String aNewPicture; + pFormatter->GenerateFormat( aNewPicture, nOldFormat, eLanguage, + bThousand, bNegRed, nPrecision, nLeading ); + + nNewFormat = pFormatter->GetEntryKey( aNewPicture, eLanguage ); + if ( nNewFormat == NUMBERFORMAT_ENTRY_NOT_FOUND ) + { + xub_StrLen nErrPos = 0; + short nNewType = 0; + BOOL bOk = pFormatter->PutEntry( aNewPicture, nErrPos, + nNewType, nNewFormat, eLanguage ); + DBG_ASSERT( bOk, "falsches Zahlformat generiert" ); + if (!bOk) + bError = TRUE; + } + } + + if (!bError) + { + ScPatternAttr aNewAttrs( pDoc->GetPool() ); + SfxItemSet& rSet = aNewAttrs.GetItemSet(); + rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) ); + // ATTR_LANGUAGE_FORMAT nicht + ApplySelectionPattern( aNewAttrs, TRUE ); + } + else + Sound::Beep(); // war nix +} + +void ScViewFunc::ChangeIndent( BOOL bIncrement ) +{ + ScViewData* pViewData = GetViewData(); + ScDocShell* pDocSh = pViewData->GetDocShell(); + ScMarkData& rMark = pViewData->GetMarkData(); + + ScMarkData aWorkMark = rMark; + aWorkMark.MarkToMulti(); + if (!aWorkMark.IsMultiMarked()) + { + USHORT nCol = pViewData->GetCurX(); + USHORT nRow = pViewData->GetCurY(); + USHORT nTab = pViewData->GetTabNo(); + aWorkMark.SetMultiMarkArea( ScRange(nCol,nRow,nTab) ); + } + + BOOL bSuccess = pDocSh->GetDocFunc().ChangeIndent( aWorkMark, bIncrement, FALSE ); + if (bSuccess) + { + pDocSh->UpdateOle(pViewData); + StartFormatArea(); + } +} + +BOOL ScViewFunc::InsertName( const String& rName, const String& rSymbol, + const String& rType ) +{ + // Type = P,R,C,F (und Kombinationen) + //! Undo... + + BOOL bOk = FALSE; + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + ScDocument* pDoc = pDocSh->GetDocument(); + USHORT nTab = GetViewData()->GetTabNo(); + ScRangeName* pList = pDoc->GetRangeName(); + + RangeType nType = RT_NAME; + ScRangeData* pNewEntry = new ScRangeData( pDoc, rName, rSymbol, + GetViewData()->GetCurX(), GetViewData()->GetCurY(), nTab, + nType ); + String aUpType = rType; + aUpType.ToUpperAscii(); + if ( aUpType.Search( 'P' ) != STRING_NOTFOUND ) + nType |= RT_PRINTAREA; + if ( aUpType.Search( 'R' ) != STRING_NOTFOUND ) + nType |= RT_ROWHEADER; + if ( aUpType.Search( 'C' ) != STRING_NOTFOUND ) + nType |= RT_COLHEADER; + if ( aUpType.Search( 'F' ) != STRING_NOTFOUND ) + nType |= RT_CRITERIA; + pNewEntry->AddType(nType); + + if ( !pNewEntry->GetErrCode() ) // Text gueltig? + { + ScDocShellModificator aModificator( *pDocSh ); + + pDoc->CompileNameFormula( TRUE ); // CreateFormulaString + + // Eintrag bereits vorhanden? Dann vorher entfernen (=Aendern) + USHORT nFoundAt; + if ( pList->SearchName( rName, nFoundAt ) ) + { // alten Index uebernehmen + pNewEntry->SetIndex( ((ScRangeData*)pList->At(nFoundAt))->GetIndex() ); + pList->AtFree( nFoundAt ); + } + + if ( pList->Insert( pNewEntry ) ) + { + pNewEntry = NULL; // nicht loeschen + bOk = TRUE; + } + + pDoc->CompileNameFormula( FALSE ); // CompileFormulaString + aModificator.SetDocumentModified(); + SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) ); + } + + delete pNewEntry; // wenn er nicht eingefuegt wurde + return bOk; +} + +void ScViewFunc::CreateNames( USHORT nFlags ) +{ + BOOL bDone = FALSE; + ScRange aRange; + if ( GetViewData()->GetSimpleArea(aRange) ) + bDone = GetViewData()->GetDocShell()->GetDocFunc().CreateNames( aRange, nFlags, FALSE ); + + if (!bDone) + ErrorMessage(STR_CREATENAME_MARKERR); +} + +USHORT ScViewFunc::GetCreateNameFlags() +{ + USHORT nFlags = 0; + + USHORT nStartCol,nStartRow,nEndCol,nEndRow; + USHORT nDummy; + if (GetViewData()->GetSimpleArea(nStartCol,nStartRow,nDummy,nEndCol,nEndRow,nDummy)) + { + ScDocument* pDoc = GetViewData()->GetDocument(); + USHORT nTab = GetViewData()->GetTabNo(); + USHORT i; + BOOL bOk; + + bOk = TRUE; + USHORT nFirstCol = nStartCol; + USHORT nLastCol = nEndCol; + if (nStartCol+1 < nEndCol) { ++nFirstCol; --nLastCol; } + for (i=nFirstCol; i<=nLastCol && bOk; i++) + if (!pDoc->HasStringData( i,nStartRow,nTab )) + bOk = FALSE; + if (bOk) + nFlags |= NAME_TOP; + else // Bottom nur wenn nicht Top + { + bOk = TRUE; + for (i=nFirstCol; i<=nLastCol && bOk; i++) + if (!pDoc->HasStringData( i,nEndRow,nTab )) + bOk = FALSE; + if (bOk) + nFlags |= NAME_BOTTOM; + } + + bOk = TRUE; + USHORT nFirstRow = nStartRow; + USHORT nLastRow = nEndRow; + if (nStartRow+1 < nEndRow) { ++nFirstRow; --nLastRow; } + for (i=nFirstRow; i<=nLastRow && bOk; i++) + if (!pDoc->HasStringData( nStartCol,i,nTab )) + bOk = FALSE; + if (bOk) + nFlags |= NAME_LEFT; + else // Right nur wenn nicht Left + { + bOk = TRUE; + for (i=nFirstRow; i<=nLastRow && bOk; i++) + if (!pDoc->HasStringData( nEndCol,i,nTab )) + bOk = FALSE; + if (bOk) + nFlags |= NAME_RIGHT; + } + } + + if (nStartCol == nEndCol) + nFlags &= ~( NAME_LEFT | NAME_RIGHT ); + if (nStartRow == nEndRow) + nFlags &= ~( NAME_TOP | NAME_BOTTOM ); + + return nFlags; +} + +void ScViewFunc::InsertNameList() +{ + ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ); + ScDocShell* pDocSh = GetViewData()->GetDocShell(); + if ( pDocSh->GetDocFunc().InsertNameList( aPos, FALSE ) ) + pDocSh->UpdateOle(GetViewData()); +} + + + + diff --git a/sc/source/ui/view/viewutil.cxx b/sc/source/ui/view/viewutil.cxx new file mode 100644 index 000000000000..caede9a444b5 --- /dev/null +++ b/sc/source/ui/view/viewutil.cxx @@ -0,0 +1,427 @@ +/************************************************************************* + * + * $RCSfile: viewutil.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +// INCLUDE --------------------------------------------------------------- +#include <tools/list.hxx> +#include "scitems.hxx" +#include <svx/charmap.hxx> +#include <svx/fontitem.hxx> +#include <vcl/svapp.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/wrkwin.hxx> + +#include "viewutil.hxx" +#include "global.hxx" +#include "chgtrack.hxx" +#include "chgviset.hxx" + +// STATIC DATA ----------------------------------------------------------- + +//================================================================== + +// static +BOOL ScViewUtil::IsActionShown( const ScChangeAction& rAction, + const ScChangeViewSettings& rSettings, + ScDocument& rDocument ) +{ + // abgelehnte werden durch eine invertierende akzeptierte Action dargestellt, + // die Reihenfolge von ShowRejected/ShowAccepted ist deswegen wichtig + + if ( !rSettings.IsShowRejected() && rAction.IsRejecting() ) + return FALSE; + + if ( !rSettings.IsShowAccepted() && rAction.IsAccepted() && !rAction.IsRejecting() ) + return FALSE; + + if ( rSettings.HasAuthor() ) + { + if ( rSettings.IsEveryoneButMe() ) + { + // GetUser() am ChangeTrack ist der aktuelle Benutzer + ScChangeTrack* pTrack = rDocument.GetChangeTrack(); + if ( !pTrack || rAction.GetUser() == pTrack->GetUser() ) + return FALSE; + } + else if ( rAction.GetUser() != rSettings.GetTheAuthorToShow() ) + return FALSE; + } + + if ( rSettings.HasComment() ) + { + String aComStr=rAction.GetComment(); + aComStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" )); + rAction.GetDescription( aComStr, &rDocument ); + aComStr+=')'; + + if(!rSettings.IsValidComment(&aComStr)) + return FALSE; + } + + if ( rSettings.HasRange() ) + if ( !rSettings.GetTheRangeList().Intersects( rAction.GetBigRange().MakeRange() ) ) + return FALSE; + + if ( rSettings.HasDate() && rSettings.GetTheDateMode() != SCDM_NO_DATEMODE ) + { + DateTime aDateTime = rAction.GetDateTime(); + const DateTime& rFirst = rSettings.GetTheFirstDateTime(); + const DateTime& rLast = rSettings.GetTheLastDateTime(); + switch ( rSettings.GetTheDateMode() ) + { // korrespondiert mit ScHighlightChgDlg::OKBtnHdl + case SCDM_DATE_BEFORE: + if ( aDateTime > rFirst ) + return FALSE; + break; + + case SCDM_DATE_SINCE: + if ( aDateTime < rFirst ) + return FALSE; + break; + + case SCDM_DATE_EQUAL: + case SCDM_DATE_BETWEEN: + if ( aDateTime < rFirst || aDateTime > rLast ) + return FALSE; + break; + + case SCDM_DATE_NOTEQUAL: + if ( aDateTime >= rFirst && aDateTime <= rLast ) + return FALSE; + break; + + case SCDM_DATE_SAVE: + { + ScChangeTrack* pTrack = rDocument.GetChangeTrack(); + if ( !pTrack || pTrack->GetLastSavedActionNumber() >= + rAction.GetActionNumber() ) + return FALSE; + } + break; + } + } + + return TRUE; +} + +//================================================================== + +BOOL ScViewUtil::ExecuteCharMap( const SvxFontItem& rOldFont, + SvxFontItem& rNewFont, + String& rString ) +{ + BOOL bRet = FALSE; + + Font aFont; + aFont.SetName ( rOldFont.GetFamilyName() ); + aFont.SetStyleName( rOldFont.GetStyleName() ); + aFont.SetFamily ( rOldFont.GetFamily() ); + aFont.SetCharSet ( rOldFont.GetCharSet() ); + aFont.SetPitch ( rOldFont.GetPitch() ); + + SvxCharacterMap* pDlg = new SvxCharacterMap( NULL, FALSE ); + pDlg->SetCharFont( aFont ); + + if ( pDlg->Execute() == RET_OK ) + { + rString = pDlg->GetCharacters(); + aFont = pDlg->GetCharFont(); + rNewFont = SvxFontItem( aFont.GetFamily(), aFont.GetName(), + aFont.GetStyleName(), aFont.GetPitch(), + aFont.GetCharSet() ); // nId egal + + bRet = TRUE; + } + delete pDlg; + + return bRet; +} + +//------------------------------------------------------------------ + +ScUpdateRect::ScUpdateRect( USHORT nX1, USHORT nY1, USHORT nX2, USHORT nY2 ) +{ + PutInOrder( nX1, nX2 ); + PutInOrder( nY1, nY2 ); + + nOldStartX = nX1; + nOldStartY = nY1; + nOldEndX = nX2; + nOldEndY = nY2; +} + +void ScUpdateRect::SetNew( USHORT nX1, USHORT nY1, USHORT nX2, USHORT nY2 ) +{ + PutInOrder( nX1, nX2 ); + PutInOrder( nY1, nY2 ); + + nNewStartX = nX1; + nNewStartY = nY1; + nNewEndX = nX2; + nNewEndY = nY2; +} + +BOOL ScUpdateRect::GetDiff( USHORT& rX1, USHORT& rY1, USHORT& rX2, USHORT& rY2 ) +{ + if ( nNewStartX == nOldStartX && nNewEndX == nOldEndX && + nNewStartY == nOldStartY && nNewEndY == nOldEndY ) + { + rX1 = nNewStartX; + rY1 = nNewStartY; + rX2 = nNewStartX; + rY2 = nNewStartY; + return FALSE; + } + + rX1 = Min(nNewStartX,nOldStartX); + rY1 = Min(nNewStartY,nOldStartY); + rX2 = Max(nNewEndX,nOldEndX); + rY2 = Max(nNewEndY,nOldEndY); + + if ( nNewStartX == nOldStartX && nNewEndX == nOldEndX ) + { + if ( nNewStartY == nOldStartY ) + { + rY1 = Min( nNewEndY, nOldEndY ); + rY2 = Max( nNewEndY, nOldEndY ); + } + else if ( nNewEndY == nOldEndY ) + { + rY1 = Min( nNewStartY, nOldStartY ); + rY2 = Max( nNewStartY, nOldStartY ); + } + } + else if ( nNewStartY == nOldStartY && nNewEndY == nOldEndY ) + { + if ( nNewStartX == nOldStartX ) + { + rX1 = Min( nNewEndX, nOldEndX ); + rX2 = Max( nNewEndX, nOldEndX ); + } + else if ( nNewEndX == nOldEndX ) + { + rX1 = Min( nNewStartX, nOldStartX ); + rX2 = Max( nNewStartX, nOldStartX ); + } + } + + return TRUE; +} + +BOOL ScUpdateRect::GetXorDiff( USHORT& rX1, USHORT& rY1, USHORT& rX2, USHORT& rY2, BOOL& rCont ) +{ + rCont = FALSE; + + if ( nNewStartX == nOldStartX && nNewEndX == nOldEndX && + nNewStartY == nOldStartY && nNewEndY == nOldEndY ) + { + rX1 = nNewStartX; + rY1 = nNewStartY; + rX2 = nNewStartX; + rY2 = nNewStartY; + return FALSE; + } + + rX1 = Min(nNewStartX,nOldStartX); + rY1 = Min(nNewStartY,nOldStartY); + rX2 = Max(nNewEndX,nOldEndX); + rY2 = Max(nNewEndY,nOldEndY); + + if ( nNewStartX == nOldStartX && nNewEndX == nOldEndX ) // nur vertikal + { + if ( nNewStartY == nOldStartY ) + { + rY1 = Min( nNewEndY, nOldEndY ) + 1; + rY2 = Max( nNewEndY, nOldEndY ); + } + else if ( nNewEndY == nOldEndY ) + { + rY1 = Min( nNewStartY, nOldStartY ); + rY2 = Max( nNewStartY, nOldStartY ) - 1; + } + else + { + rY1 = Min( nNewStartY, nOldStartY ); + rY2 = Max( nNewStartY, nOldStartY ) - 1; + rCont = TRUE; + nContY1 = Min( nNewEndY, nOldEndY ) + 1; + nContY2 = Max( nNewEndY, nOldEndY ); + nContX1 = rX1; + nContX2 = rX2; + } + } + else if ( nNewStartY == nOldStartY && nNewEndY == nOldEndY ) // nur horizontal + { + if ( nNewStartX == nOldStartX ) + { + rX1 = Min( nNewEndX, nOldEndX ) + 1; + rX2 = Max( nNewEndX, nOldEndX ); + } + else if ( nNewEndX == nOldEndX ) + { + rX1 = Min( nNewStartX, nOldStartX ); + rX2 = Max( nNewStartX, nOldStartX ) - 1; + } + else + { + rX1 = Min( nNewStartX, nOldStartX ); + rX2 = Max( nNewStartX, nOldStartX ) - 1; + rCont = TRUE; + nContX1 = Min( nNewEndX, nOldEndX ) + 1; + nContX2 = Max( nNewEndX, nOldEndX ); + nContY1 = rY1; + nContY2 = rY2; + } + } + else if ( nNewEndX == nOldEndX && nNewEndY == nOldEndY ) // links oben + { + if ( (nNewStartX<nOldStartX) == (nNewStartY<nOldStartY) ) + rX1 = Min( nNewStartX, nOldStartX ); + else + rX1 = Max( nNewStartX, nOldStartX ); // Ecke weglassen + rX2 = nOldEndX; + rY1 = Min( nNewStartY, nOldStartY ); // oben + rY2 = Max( nNewStartY, nOldStartY ) - 1; + rCont = TRUE; + nContY1 = rY2+1; + nContY2 = nOldEndY; + nContX1 = Min( nNewStartX, nOldStartX ); // links + nContX2 = Max( nNewStartX, nOldStartX ) - 1; + } + else if ( nNewStartX == nOldStartX && nNewEndY == nOldEndY ) // rechts oben + { + if ( (nNewEndX<nOldEndX) != (nNewStartY<nOldStartY) ) + rX2 = Max( nNewEndX, nOldEndX ); + else + rX2 = Min( nNewEndX, nOldEndX ); // Ecke weglassen + rX1 = nOldStartX; + rY1 = Min( nNewStartY, nOldStartY ); // oben + rY2 = Max( nNewStartY, nOldStartY ) - 1; + rCont = TRUE; + nContY1 = rY2+1; + nContY2 = nOldEndY; + nContX1 = Min( nNewEndX, nOldEndX ) + 1; // rechts + nContX2 = Max( nNewEndX, nOldEndX ); + } + else if ( nNewEndX == nOldEndX && nNewStartY == nOldStartY ) // links unten + { + if ( (nNewStartX<nOldStartX) != (nNewEndY<nOldEndY) ) + rX1 = Min( nNewStartX, nOldStartX ); + else + rX1 = Max( nNewStartX, nOldStartX ); // Ecke weglassen + rX2 = nOldEndX; + rY1 = Min( nNewEndY, nOldEndY ) + 1; // unten + rY2 = Max( nNewEndY, nOldEndY ); + rCont = TRUE; + nContY1 = nOldStartY; + nContY2 = rY1-1; + nContX1 = Min( nNewStartX, nOldStartX ); // links + nContX2 = Max( nNewStartX, nOldStartX ) - 1; + } + else if ( nNewStartX == nOldStartX && nNewStartY == nOldStartY ) // rechts unten + { + if ( (nNewEndX<nOldEndX) == (nNewEndY<nOldEndY) ) + rX2 = Max( nNewEndX, nOldEndX ); + else + rX2 = Min( nNewEndX, nOldEndX ); // Ecke weglassen + rX1 = nOldStartX; + rY1 = Min( nNewEndY, nOldEndY ) + 1; // unten + rY2 = Max( nNewEndY, nOldEndY ); + rCont = TRUE; + nContY1 = nOldStartY; + nContY2 = rY1-1; + nContX1 = Min( nNewEndX, nOldEndX ) + 1; // rechts + nContX2 = Max( nNewEndX, nOldEndX ); + } + else // Ueberschlag + { + rX1 = nOldStartX; + rY1 = nOldStartY; + rX2 = nOldEndX; + rY2 = nOldEndY; + rCont = TRUE; + nContX1 = nNewStartX; + nContY1 = nNewStartY; + nContX2 = nNewEndX; + nContY2 = nNewEndY; + } + + return TRUE; +} + +void ScUpdateRect::GetContDiff( USHORT& rX1, USHORT& rY1, USHORT& rX2, USHORT& rY2 ) +{ + rX1 = nContX1; + rY1 = nContY1; + rX2 = nContX2; + rY2 = nContY2; +} + + + + + + diff --git a/sc/source/ui/view/waitoff.cxx b/sc/source/ui/view/waitoff.cxx new file mode 100644 index 000000000000..34390e05217e --- /dev/null +++ b/sc/source/ui/view/waitoff.cxx @@ -0,0 +1,105 @@ +/************************************************************************* + * + * $RCSfile: waitoff.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:10 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef PCH +#include "ui_pch.hxx" +#endif + +#pragma hdrstop + +//------------------------------------------------------------------------ + +#include <vcl/window.hxx> + +#include "waitoff.hxx" + +//------------------------------------------------------------------------ + +ScWaitCursorOff::ScWaitCursorOff( Window* pWinP ) + : + pWin( pWinP ), + nWaiters(0) +{ + if ( pWin ) + { + while ( pWin->IsWait() ) + { + nWaiters++; + pWin->LeaveWait(); + } + } +} + +ScWaitCursorOff::~ScWaitCursorOff() +{ + if ( pWin ) + { + while ( nWaiters ) + { + nWaiters--; + pWin->EnterWait(); + } + } +} + + + + |