/************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: foptmgr.cxx,v $ * $Revision: 1.7 $ * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 3 * only, as published by the Free Software Foundation. * * OpenOffice.org is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License version 3 for more details * (a copy is included in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU Lesser General Public License * version 3 along with OpenOffice.org. If not, see * * for a copy of the LGPLv3 License. * ************************************************************************/ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" // System - Includes --------------------------------------------------------- // INCLUDE ------------------------------------------------------------------- #include #include #include "anyrefdg.hxx" #include "rangeutl.hxx" #include "dbcolect.hxx" #include "viewdata.hxx" #include "document.hxx" #define _FOPTMGR_CXX #include "foptmgr.hxx" #undef _FOPTMGR_CXX //---------------------------------------------------------------------------- ScFilterOptionsMgr::ScFilterOptionsMgr( Dialog* ptrDlg, ScViewData* ptrViewData, const ScQueryParam& refQueryData, MoreButton& refBtnMore, CheckBox& refBtnCase, CheckBox& refBtnRegExp, CheckBox& refBtnHeader, CheckBox& refBtnUnique, CheckBox& refBtnCopyResult, CheckBox& refBtnDestPers, ListBox& refLbCopyArea, Edit& refEdCopyArea, ScRefButton& refRbCopyArea, FixedText& refFtDbAreaLabel, FixedInfo& refFtDbArea, FixedLine& refFlOptions, const String& refStrNoName, const String& refStrUndefined ) : pDlg ( ptrDlg ), pViewData ( ptrViewData ), pDoc ( ptrViewData ? ptrViewData->GetDocument() : NULL ), rBtnMore ( refBtnMore ), rBtnCase ( refBtnCase ), rBtnRegExp ( refBtnRegExp ), rBtnHeader ( refBtnHeader ), rBtnUnique ( refBtnUnique ), rBtnCopyResult ( refBtnCopyResult ), rBtnDestPers ( refBtnDestPers ), rLbCopyPos ( refLbCopyArea ), rEdCopyPos ( refEdCopyArea ), rRbCopyPos ( refRbCopyArea ), rFtDbAreaLabel ( refFtDbAreaLabel ), rFtDbArea ( refFtDbArea ), rFlOptions ( refFlOptions ), rStrNoName ( refStrNoName ), rStrUndefined ( refStrUndefined ), rQueryData ( refQueryData ) { Init(); } //---------------------------------------------------------------------------- ScFilterOptionsMgr::~ScFilterOptionsMgr() { USHORT nEntries = rLbCopyPos.GetEntryCount(); USHORT i; for ( i=2; iGetTabNo() ), ScAddress( rQueryData.nCol2, rQueryData.nRow2, pViewData->GetTabNo() ) ); ScDBCollection* pDBColl = pDoc->GetDBCollection(); String theDbArea; String theDbName = rStrNoName; theCurArea.Format( theAreaStr, SCR_ABS_3D, pDoc ); // Zielbereichsliste fuellen rLbCopyPos.Clear(); rLbCopyPos.InsertEntry( rStrUndefined, 0 ); ScAreaNameIterator aIter( pDoc ); String aName; ScRange aRange; String aRefStr; while ( aIter.Next( aName, aRange ) ) { USHORT nInsert = rLbCopyPos.InsertEntry( aName ); aRange.aStart.Format( aRefStr, SCA_ABS_3D, pDoc ); rLbCopyPos.SetEntryData( nInsert, new String( aRefStr ) ); } rBtnDestPers.Check( TRUE ); // beim Aufruf immer an rLbCopyPos.SelectEntryPos( 0 ); rEdCopyPos.SetText( EMPTY_STRING ); /* * Ueberpruefen, ob es sich bei dem uebergebenen * Bereich um einen Datenbankbereich handelt: */ theDbArea = theAreaStr; if ( pDBColl ) { ScAddress& rStart = theCurArea.aStart; ScAddress& rEnd = theCurArea.aEnd; ScDBData* pDBData = pDBColl->GetDBAtArea( rStart.Tab(), rStart.Col(), rStart.Row(), rEnd.Col(), rEnd.Row() ); if ( pDBData ) { rBtnHeader.Check( pDBData->HasHeader() ); pDBData->GetName( theDbName ); if ( theDbName != rStrNoName ) { rBtnHeader.Disable(); } } } theDbArea.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" (")); theDbArea += theDbName; theDbArea += ')'; rFtDbArea.SetText( theDbArea ); //------------------------------------------------------ // Kopierposition: if ( !rQueryData.bInplace ) { String aString; ScAddress( rQueryData.nDestCol, rQueryData.nDestRow, rQueryData.nDestTab ).Format( aString, SCA_ABS_3D, pDoc ); rBtnCopyResult.Check( TRUE ); rEdCopyPos.SetText( aString ); EdPosModifyHdl( &rEdCopyPos ); rLbCopyPos.Enable(); rEdCopyPos.Enable(); rRbCopyPos.Enable(); rBtnDestPers.Enable(); } else { rBtnCopyResult.Check( FALSE ); rEdCopyPos.SetText( EMPTY_STRING ); rLbCopyPos.Disable(); rEdCopyPos.Disable(); rRbCopyPos.Disable(); rBtnDestPers.Disable(); } } else rEdCopyPos.SetText( EMPTY_STRING ); } //---------------------------------------------------------------------------- BOOL ScFilterOptionsMgr::VerifyPosStr( const String& rPosStr ) const { String aPosStr( rPosStr ); xub_StrLen nColonPos = aPosStr.Search( ':' ); if ( STRING_NOTFOUND != nColonPos ) aPosStr.Erase( nColonPos ); USHORT nResult = ScAddress().Parse( aPosStr, pDoc ); return ( SCA_VALID == (nResult & SCA_VALID) ); } //---------------------------------------------------------------------------- // Handler: //---------------------------------------------------------------------------- IMPL_LINK( ScFilterOptionsMgr, LbPosSelHdl, ListBox*, pLb ) { if ( pLb == &rLbCopyPos ) { String aString; USHORT nSelPos = rLbCopyPos.GetSelectEntryPos(); if ( nSelPos > 0 ) aString = *(String*)rLbCopyPos.GetEntryData( nSelPos ); rEdCopyPos.SetText( aString ); } return 0; } //---------------------------------------------------------------------------- IMPL_LINK( ScFilterOptionsMgr, EdPosModifyHdl, Edit*, pEd ) { if ( pEd == &rEdCopyPos ) { String theCurPosStr = pEd->GetText(); USHORT nResult = ScAddress().Parse( theCurPosStr, pDoc ); if ( SCA_VALID == (nResult & SCA_VALID) ) { String* pStr = NULL; BOOL bFound = FALSE; USHORT i = 0; USHORT nCount = rLbCopyPos.GetEntryCount(); for ( i=2; iIsChecked() ) { rBtnDestPers.Enable(); rLbCopyPos.Enable(); rEdCopyPos.Enable(); rRbCopyPos.Enable(); rEdCopyPos.GrabFocus(); } else { rBtnDestPers.Disable(); rLbCopyPos.Disable(); rEdCopyPos.Disable(); rRbCopyPos.Disable(); } } return 0; }