summaryrefslogtreecommitdiff
path: root/sc/source/ui/dbgui
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui/dbgui')
-rw-r--r--sc/source/ui/dbgui/asciiopt.cxx480
-rw-r--r--sc/source/ui/dbgui/asciiopt.hrc71
-rw-r--r--sc/source/ui/dbgui/asciiopt.src322
-rw-r--r--sc/source/ui/dbgui/consdlg.cxx655
-rw-r--r--sc/source/ui/dbgui/consdlg.hrc61
-rw-r--r--sc/source/ui/dbgui/consdlg.src231
-rw-r--r--sc/source/ui/dbgui/csvcontrol.cxx337
-rw-r--r--sc/source/ui/dbgui/csvgrid.cxx1355
-rw-r--r--sc/source/ui/dbgui/csvruler.cxx682
-rw-r--r--sc/source/ui/dbgui/csvsplits.cxx120
-rw-r--r--sc/source/ui/dbgui/csvtablebox.cxx464
-rw-r--r--sc/source/ui/dbgui/dapidata.cxx229
-rw-r--r--sc/source/ui/dbgui/dapitype.cxx142
-rw-r--r--sc/source/ui/dbgui/dapitype.hrc53
-rw-r--r--sc/source/ui/dbgui/dapitype.src319
-rw-r--r--sc/source/ui/dbgui/dbnamdlg.cxx721
-rw-r--r--sc/source/ui/dbgui/dpgroupdlg.cxx360
-rw-r--r--sc/source/ui/dbgui/dpgroupdlg.hrc64
-rw-r--r--sc/source/ui/dbgui/dpgroupdlg.src286
-rw-r--r--sc/source/ui/dbgui/expftext.cxx95
-rw-r--r--sc/source/ui/dbgui/fieldwnd.cxx776
-rw-r--r--sc/source/ui/dbgui/filtdlg.cxx1186
-rw-r--r--sc/source/ui/dbgui/foptmgr.cxx337
-rw-r--r--sc/source/ui/dbgui/imoptdlg.cxx90
-rw-r--r--sc/source/ui/dbgui/imoptdlg.hrc44
-rw-r--r--sc/source/ui/dbgui/imoptdlg.src147
-rw-r--r--sc/source/ui/dbgui/makefile.mk122
-rw-r--r--sc/source/ui/dbgui/outline.src51
-rw-r--r--sc/source/ui/dbgui/pfiltdlg.cxx620
-rw-r--r--sc/source/ui/dbgui/pivot.hrc81
-rw-r--r--sc/source/ui/dbgui/pivot.src342
-rw-r--r--sc/source/ui/dbgui/pvfundlg.cxx790
-rw-r--r--sc/source/ui/dbgui/pvfundlg.hrc83
-rw-r--r--sc/source/ui/dbgui/pvfundlg.src538
-rw-r--r--sc/source/ui/dbgui/pvglob.hxx42
-rw-r--r--sc/source/ui/dbgui/pvlaydlg.cxx1823
-rw-r--r--sc/source/ui/dbgui/scendlg.cxx243
-rw-r--r--sc/source/ui/dbgui/scendlg.hrc57
-rw-r--r--sc/source/ui/dbgui/scendlg.src206
-rw-r--r--sc/source/ui/dbgui/scuiasciiopt.cxx718
-rw-r--r--sc/source/ui/dbgui/scuiimoptdlg.cxx316
-rw-r--r--sc/source/ui/dbgui/sfiltdlg.cxx530
-rw-r--r--sc/source/ui/dbgui/sortdlg.cxx107
-rw-r--r--sc/source/ui/dbgui/subtdlg.cxx69
-rw-r--r--sc/source/ui/dbgui/textimportoptions.cxx121
-rw-r--r--sc/source/ui/dbgui/textimportoptions.src115
-rw-r--r--sc/source/ui/dbgui/tpsort.cxx1080
-rw-r--r--sc/source/ui/dbgui/tpsubt.cxx686
-rw-r--r--sc/source/ui/dbgui/validate.cxx1021
-rw-r--r--sc/source/ui/dbgui/validate.src427
50 files changed, 19815 insertions, 0 deletions
diff --git a/sc/source/ui/dbgui/asciiopt.cxx b/sc/source/ui/dbgui/asciiopt.cxx
new file mode 100644
index 000000000000..a22953ade25b
--- /dev/null
+++ b/sc/source/ui/dbgui/asciiopt.cxx
@@ -0,0 +1,480 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "global.hxx"
+#include "scresid.hxx"
+#include "impex.hxx"
+#include "asciiopt.hxx"
+#include "asciiopt.hrc"
+#include <tools/debug.hxx>
+#include <rtl/tencinfo.h>
+#include <unotools/transliterationwrapper.hxx>
+// ause
+#include "editutil.hxx"
+
+// ============================================================================
+
+static const sal_Char __FAR_DATA pStrFix[] = "FIX";
+static const sal_Char __FAR_DATA pStrMrg[] = "MRG";
+
+
+// ============================================================================
+
+ScAsciiOptions::ScAsciiOptions() :
+ bFixedLen ( FALSE ),
+ aFieldSeps ( ';' ),
+ bMergeFieldSeps ( FALSE ),
+ bQuotedFieldAsText(false),
+ bDetectSpecialNumber(false),
+ cTextSep ( cDefaultTextSep ),
+ eCharSet ( gsl_getSystemTextEncoding() ),
+ eLang ( LANGUAGE_SYSTEM ),
+ bCharSetSystem ( FALSE ),
+ nStartRow ( 1 ),
+ nInfoCount ( 0 ),
+ pColStart ( NULL ),
+ pColFormat ( NULL )
+{
+}
+
+
+ScAsciiOptions::ScAsciiOptions(const ScAsciiOptions& rOpt) :
+ bFixedLen ( rOpt.bFixedLen ),
+ aFieldSeps ( rOpt.aFieldSeps ),
+ bMergeFieldSeps ( rOpt.bMergeFieldSeps ),
+ bQuotedFieldAsText(rOpt.bQuotedFieldAsText),
+ bDetectSpecialNumber(rOpt.bDetectSpecialNumber),
+ cTextSep ( rOpt.cTextSep ),
+ eCharSet ( rOpt.eCharSet ),
+ eLang ( rOpt.eLang ),
+ bCharSetSystem ( rOpt.bCharSetSystem ),
+ nStartRow ( rOpt.nStartRow ),
+ nInfoCount ( rOpt.nInfoCount )
+{
+ if (nInfoCount)
+ {
+ pColStart = new xub_StrLen[nInfoCount];
+ pColFormat = new BYTE[nInfoCount];
+ for (USHORT i=0; i<nInfoCount; i++)
+ {
+ pColStart[i] = rOpt.pColStart[i];
+ pColFormat[i] = rOpt.pColFormat[i];
+ }
+ }
+ else
+ {
+ pColStart = NULL;
+ pColFormat = NULL;
+ }
+}
+
+
+ScAsciiOptions::~ScAsciiOptions()
+{
+ delete[] pColStart;
+ delete[] pColFormat;
+}
+
+
+void ScAsciiOptions::SetColInfo( USHORT nCount, const xub_StrLen* pStart, const BYTE* pFormat )
+{
+ delete[] pColStart;
+ delete[] pColFormat;
+
+ nInfoCount = nCount;
+
+ if (nInfoCount)
+ {
+ pColStart = new xub_StrLen[nInfoCount];
+ pColFormat = new BYTE[nInfoCount];
+ for (USHORT i=0; i<nInfoCount; i++)
+ {
+ pColStart[i] = pStart[i];
+ pColFormat[i] = pFormat[i];
+ }
+ }
+ else
+ {
+ pColStart = NULL;
+ pColFormat = NULL;
+ }
+}
+
+
+void ScAsciiOptions::SetColumnInfo( const ScCsvExpDataVec& rDataVec )
+{
+ delete[] pColStart;
+ pColStart = NULL;
+ delete[] pColFormat;
+ pColFormat = NULL;
+
+ nInfoCount = static_cast< sal_uInt16 >( rDataVec.size() );
+ if( nInfoCount )
+ {
+ pColStart = new xub_StrLen[ nInfoCount ];
+ pColFormat = new sal_uInt8[ nInfoCount ];
+ for( sal_uInt16 nIx = 0; nIx < nInfoCount; ++nIx )
+ {
+ pColStart[ nIx ] = rDataVec[ nIx ].mnIndex;
+ pColFormat[ nIx ] = rDataVec[ nIx ].mnType;
+ }
+ }
+}
+
+
+ScAsciiOptions& ScAsciiOptions::operator=( const ScAsciiOptions& rCpy )
+{
+ SetColInfo( rCpy.nInfoCount, rCpy.pColStart, rCpy.pColFormat );
+
+ bFixedLen = rCpy.bFixedLen;
+ aFieldSeps = rCpy.aFieldSeps;
+ bMergeFieldSeps = rCpy.bMergeFieldSeps;
+ bQuotedFieldAsText = rCpy.bQuotedFieldAsText;
+ cTextSep = rCpy.cTextSep;
+ eCharSet = rCpy.eCharSet;
+ bCharSetSystem = rCpy.bCharSetSystem;
+ nStartRow = rCpy.nStartRow;
+
+ return *this;
+}
+
+
+BOOL ScAsciiOptions::operator==( const ScAsciiOptions& rCmp ) const
+{
+ if ( bFixedLen == rCmp.bFixedLen &&
+ aFieldSeps == rCmp.aFieldSeps &&
+ bMergeFieldSeps == rCmp.bMergeFieldSeps &&
+ bQuotedFieldAsText == rCmp.bQuotedFieldAsText &&
+ cTextSep == rCmp.cTextSep &&
+ eCharSet == rCmp.eCharSet &&
+ bCharSetSystem == rCmp.bCharSetSystem &&
+ nStartRow == rCmp.nStartRow &&
+ nInfoCount == rCmp.nInfoCount )
+ {
+ DBG_ASSERT( !nInfoCount || (pColStart && pColFormat && rCmp.pColStart && rCmp.pColFormat),
+ "0-Zeiger in ScAsciiOptions" );
+ for (USHORT i=0; i<nInfoCount; i++)
+ if ( pColStart[i] != rCmp.pColStart[i] ||
+ pColFormat[i] != rCmp.pColFormat[i] )
+ return FALSE;
+
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//
+// Der Options-String darf kein Semikolon mehr enthalten (wegen Pickliste)
+// darum ab Version 336 Komma stattdessen
+//
+
+
+void ScAsciiOptions::ReadFromString( const String& rString )
+{
+ xub_StrLen nCount = rString.GetTokenCount(',');
+ String aToken;
+ xub_StrLen nSub;
+ xub_StrLen i;
+
+ //
+ // Feld-Trenner
+ //
+
+ if ( nCount >= 1 )
+ {
+ bFixedLen = bMergeFieldSeps = FALSE;
+ aFieldSeps.Erase();
+
+ aToken = rString.GetToken(0,',');
+ if ( aToken.EqualsAscii(pStrFix) )
+ bFixedLen = TRUE;
+ nSub = aToken.GetTokenCount('/');
+ for ( i=0; i<nSub; i++ )
+ {
+ String aCode = aToken.GetToken( i, '/' );
+ if ( aCode.EqualsAscii(pStrMrg) )
+ bMergeFieldSeps = TRUE;
+ else
+ {
+ sal_Int32 nVal = aCode.ToInt32();
+ if ( nVal )
+ aFieldSeps += (sal_Unicode) nVal;
+ }
+ }
+ }
+
+ //
+ // Text-Trenner
+ //
+
+ if ( nCount >= 2 )
+ {
+ aToken = rString.GetToken(1,',');
+ sal_Int32 nVal = aToken.ToInt32();
+ cTextSep = (sal_Unicode) nVal;
+ }
+
+ //
+ // Zeichensatz
+ //
+
+ if ( nCount >= 3 )
+ {
+ aToken = rString.GetToken(2,',');
+ eCharSet = ScGlobal::GetCharsetValue( aToken );
+ }
+
+ //
+ // Startzeile
+ //
+
+ if ( nCount >= 4 )
+ {
+ aToken = rString.GetToken(3,',');
+ nStartRow = aToken.ToInt32();
+ }
+
+ //
+ // Spalten-Infos
+ //
+
+ if ( nCount >= 5 )
+ {
+ delete[] pColStart;
+ delete[] pColFormat;
+
+ aToken = rString.GetToken(4,',');
+ nSub = aToken.GetTokenCount('/');
+ nInfoCount = nSub / 2;
+ if (nInfoCount)
+ {
+ pColStart = new xub_StrLen[nInfoCount];
+ pColFormat = new BYTE[nInfoCount];
+ for (USHORT nInfo=0; nInfo<nInfoCount; nInfo++)
+ {
+ pColStart[nInfo] = (xub_StrLen) aToken.GetToken( 2*nInfo, '/' ).ToInt32();
+ pColFormat[nInfo] = (BYTE) aToken.GetToken( 2*nInfo+1, '/' ).ToInt32();
+ }
+ }
+ else
+ {
+ pColStart = NULL;
+ pColFormat = NULL;
+ }
+ }
+
+ // Language
+ if (nCount >= 6)
+ {
+ aToken = rString.GetToken(5, ',');
+ eLang = static_cast<LanguageType>(aToken.ToInt32());
+ }
+
+ // Import quoted field as text.
+ if (nCount >= 7)
+ {
+ aToken = rString.GetToken(6, ',');
+ bQuotedFieldAsText = aToken.EqualsAscii("true") ? true : false;
+ }
+
+ // Detect special nubmers.
+ if (nCount >= 8)
+ {
+ aToken = rString.GetToken(7, ',');
+ bDetectSpecialNumber = aToken.EqualsAscii("true") ? true : false;
+ }
+}
+
+
+String ScAsciiOptions::WriteToString() const
+{
+ String aOutStr;
+
+ //
+ // Feld-Trenner
+ //
+
+ if ( bFixedLen )
+ aOutStr.AppendAscii(pStrFix);
+ else if ( !aFieldSeps.Len() )
+ aOutStr += '0';
+ else
+ {
+ xub_StrLen nLen = aFieldSeps.Len();
+ for (xub_StrLen i=0; i<nLen; i++)
+ {
+ if (i)
+ aOutStr += '/';
+ aOutStr += String::CreateFromInt32(aFieldSeps.GetChar(i));
+ }
+ if ( bMergeFieldSeps )
+ {
+ aOutStr += '/';
+ aOutStr.AppendAscii(pStrMrg);
+ }
+ }
+
+ aOutStr += ','; // Token-Ende
+
+ //
+ // Text-Trenner
+ //
+
+ aOutStr += String::CreateFromInt32(cTextSep);
+ aOutStr += ','; // Token-Ende
+
+ //
+ // Zeichensatz
+ //
+
+ if ( bCharSetSystem ) // force "SYSTEM"
+ aOutStr += ScGlobal::GetCharsetString( RTL_TEXTENCODING_DONTKNOW );
+ else
+ aOutStr += ScGlobal::GetCharsetString( eCharSet );
+ aOutStr += ','; // Token-Ende
+
+ //
+ // Startzeile
+ //
+
+ aOutStr += String::CreateFromInt32(nStartRow);
+ aOutStr += ','; // Token-Ende
+
+ //
+ // Spalten-Infos
+ //
+
+ DBG_ASSERT( !nInfoCount || (pColStart && pColFormat), "0-Zeiger in ScAsciiOptions" );
+ for (USHORT nInfo=0; nInfo<nInfoCount; nInfo++)
+ {
+ if (nInfo)
+ aOutStr += '/';
+ aOutStr += String::CreateFromInt32(pColStart[nInfo]);
+ aOutStr += '/';
+ aOutStr += String::CreateFromInt32(pColFormat[nInfo]);
+ }
+
+ // #i112025# the options string is used in macros and linked sheets,
+ // so new options must be added at the end, to remain compatible
+
+ aOutStr += ',';
+
+ // Language
+ aOutStr += String::CreateFromInt32(eLang);
+ aOutStr += ',';
+
+ // Import quoted field as text.
+ aOutStr += String::CreateFromAscii(bQuotedFieldAsText ? "true" : "false");
+ aOutStr += ',';
+
+ // Detect special nubmers.
+ aOutStr += String::CreateFromAscii(bDetectSpecialNumber ? "true" : "false");
+
+ return aOutStr;
+}
+
+#if 0
+// Code, um die Spalten-Liste aus einem Excel-kompatiblen String zu erzeugen:
+// (im Moment nicht benutzt)
+
+void ScAsciiOptions::InterpretColumnList( const String& rString )
+{
+ // Eingabe ist 1-basiert, pColStart fuer FixedLen ist 0-basiert
+
+ // Kommas durch Semikolon ersetzen
+
+ String aSemiStr = rString;
+ USHORT nPos = 0;
+ do
+ nPos = aSemiStr.SearchAndReplace( ',', ';', nPos );
+ while ( nPos != STRING_NOTFOUND );
+
+ // Eintraege sortieren
+
+ USHORT nCount = aSemiStr.GetTokenCount();
+ USHORT* pTemp = new USHORT[nCount+1];
+ pTemp[0] = 1; // erste Spalte faengt immer bei 1 an
+ USHORT nFound = 1;
+ USHORT i,j;
+ for (i=0; i<nCount; i++)
+ {
+ USHORT nVal = (USHORT) aSemiStr.GetToken(i);
+ if (nVal)
+ {
+ BOOL bThere = FALSE;
+ nPos = 0;
+ for (j=0; j<nFound; j++)
+ {
+ if ( pTemp[j] == nVal )
+ bThere = TRUE;
+ else if ( pTemp[j] < nVal )
+ nPos = j+1;
+ }
+ if ( !bThere )
+ {
+ if ( nPos < nFound )
+ memmove( &pTemp[nPos+1], &pTemp[nPos], (nFound-nPos)*sizeof(USHORT) );
+ pTemp[nPos] = nVal;
+ ++nFound;
+ }
+ }
+ }
+
+ // Eintraege uebernehmen
+
+ delete[] pColStart;
+ delete[] pColFormat;
+ nInfoCount = nFound;
+ if (nInfoCount)
+ {
+ pColStart = new USHORT[nInfoCount];
+ pColFormat = new BYTE[nInfoCount];
+ for (i=0; i<nInfoCount; i++)
+ {
+ pColStart[i] = pTemp[i] - 1;
+ pColFormat[i] = SC_COL_STANDARD;
+ }
+ }
+ else
+ {
+ pColStart = NULL;
+ pColFormat = NULL;
+ }
+
+ bFixedLen = TRUE; // sonst macht's keinen Sinn
+
+ // aufraeumen
+
+ delete[] pTemp;
+}
+#endif
+
diff --git a/sc/source/ui/dbgui/asciiopt.hrc b/sc/source/ui/dbgui/asciiopt.hrc
new file mode 100644
index 000000000000..7bf6d42d6e2f
--- /dev/null
+++ b/sc/source/ui/dbgui/asciiopt.hrc
@@ -0,0 +1,71 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "sc.hrc"
+//#define RID_SCDLG_ASCII 256
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+
+#define FL_FIELDOPT 4
+#define FT_CHARSET 5
+#define LB_CHARSET 6
+#define FT_CUSTOMLANG 7
+#define LB_CUSTOMLANG 8
+#define FT_AT_ROW 9
+#define NF_AT_ROW 10
+
+#define FL_SEPOPT 11
+#define RB_FIXED 12
+#define RB_SEPARATED 13
+#define CKB_TAB 14
+#define CKB_COMMA 15
+#define CKB_OTHER 16
+#define ED_OTHER 17
+#define CKB_SEMICOLON 18
+#define CKB_SPACE 19
+#define CB_ASONCE 20
+#define CB_TEXTSEP 21
+#define FT_TEXTSEP 22
+
+#define FL_OTHER_OPTIONS 23
+#define CB_QUOTED_AS_TEXT 24
+#define CB_DETECT_SPECIAL_NUMBER 25
+
+#define FL_WIDTH 26
+#define FT_TYPE 27
+#define LB_TYPE1 28
+#define CTR_TABLEBOX 29
+#define STR_TEXTTOCOLUMNS 30
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/dbgui/asciiopt.src b/sc/source/ui/dbgui/asciiopt.src
new file mode 100644
index 000000000000..5ddaba95d4df
--- /dev/null
+++ b/sc/source/ui/dbgui/asciiopt.src
@@ -0,0 +1,322 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "asciiopt.hrc"
+
+ModalDialog RID_SCDLG_ASCII
+{
+ HelpID = "sc:ModalDialog:RID_SCDLG_ASCII";
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 320 , 305 ) ;
+ Text [ en-US ] = "Text Import" ;
+ Moveable = TRUE ;
+
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 264 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 264 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 264 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+
+ FixedLine FL_FIELDOPT
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 252 , 8 ) ;
+ Text [ en-US ] = "Import" ;
+ };
+
+ FixedText FT_CHARSET
+ {
+ Pos = MAP_APPFONT ( 12 , 16 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Ch~aracter set" ;
+ };
+
+ ListBox LB_CHARSET
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_ASCII:LB_CHARSET";
+ Pos = MAP_APPFONT ( 76 , 14 ) ;
+ Size = MAP_APPFONT ( 130 , 61 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ Sort = TRUE;
+ };
+
+ FixedText FT_CUSTOMLANG
+ {
+ Pos = MAP_APPFONT ( 12 , 32 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Language" ;
+ };
+
+ ListBox LB_CUSTOMLANG
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_ASCII:LB_CUSTOMLANG";
+ Pos = MAP_APPFONT ( 76 , 30 ) ;
+ Size = MAP_APPFONT ( 130 , 61 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ Sort = TRUE;
+ };
+
+ FixedText FT_AT_ROW
+ {
+ Pos = MAP_APPFONT ( 12 , 48 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "From ro~w" ;
+ };
+
+ NumericField NF_AT_ROW
+ {
+ HelpID = "sc:NumericField:RID_SCDLG_ASCII:NF_AT_ROW";
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 76 , 46 ) ;
+ Size = MAP_APPFONT ( 30 , 12 ) ;
+ TabStop = TRUE ;
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ Minimum = 1 ;
+ };
+
+ FixedLine FL_SEPOPT
+ {
+ Pos = MAP_APPFONT ( 6 , 63 ) ;
+ Size = MAP_APPFONT ( 252 , 8 ) ;
+ Text [ en-US ] = "Separator options" ;
+ };
+ RadioButton RB_FIXED
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_ASCII:RB_FIXED";
+ Pos = MAP_APPFONT ( 12 , 75 ) ;
+ Size = MAP_APPFONT ( 243 , 10 ) ;
+ Text [ en-US ] = "~Fixed width" ;
+ TabStop = TRUE ;
+ };
+ RadioButton RB_SEPARATED
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_ASCII:RB_SEPARATED";
+ Pos = MAP_APPFONT ( 12 , 89 ) ;
+ Size = MAP_APPFONT ( 243 , 10 ) ;
+ Text [ en-US ] = "~Separated by" ;
+ TabStop = TRUE ;
+ Check = TRUE ;
+ };
+
+ CheckBox CKB_TAB
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_ASCII:CKB_TAB";
+ Pos = MAP_APPFONT ( 20 , 102 ) ;
+ Size = MAP_APPFONT ( 68 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Tab" ;
+ };
+ CheckBox CKB_COMMA
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_ASCII:CKB_COMMA";
+ Pos = MAP_APPFONT ( 92 , 102 ) ;
+ Size = MAP_APPFONT ( 68 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Comma" ;
+ };
+ CheckBox CKB_OTHER
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_ASCII:CKB_OTHER";
+ Pos = MAP_APPFONT ( 164 , 102 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Other" ;
+ };
+ Edit ED_OTHER
+ {
+ HelpID = "sc:Edit:RID_SCDLG_ASCII:ED_OTHER";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 218 , 100 ) ;
+ Size = MAP_APPFONT ( 37 , 12 ) ;
+ TabStop = TRUE ;
+ MaxTextLength = 10 ;
+ };
+
+ CheckBox CKB_SEMICOLON
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_ASCII:CKB_SEMICOLON";
+ Pos = MAP_APPFONT ( 20 , 115 ) ;
+ Size = MAP_APPFONT ( 68 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "S~emicolon" ;
+ };
+ CheckBox CKB_SPACE
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_ASCII:CKB_SPACE";
+ Pos = MAP_APPFONT ( 92 , 115 ) ;
+ Size = MAP_APPFONT ( 68 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "S~pace" ;
+ };
+
+ CheckBox CB_ASONCE
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_ASCII:CB_ASONCE";
+ Pos = MAP_APPFONT ( 20 , 130 ) ;
+ Size = MAP_APPFONT ( 130 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Merge ~delimiters" ;
+ };
+
+ ComboBox CB_TEXTSEP
+ {
+ HelpID = "sc:ComboBox:RID_SCDLG_ASCII:CB_TEXTSEP";
+ Pos = MAP_APPFONT ( 218 , 128 ) ;
+ Size = MAP_APPFONT ( 37 , 94 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ FixedText FT_TEXTSEP
+ {
+ Pos = MAP_APPFONT ( 156 , 130 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Te~xt delimiter" ;
+ };
+
+ FixedLine FL_OTHER_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 6 , 146 ) ;
+ Size = MAP_APPFONT ( 252 , 8 ) ;
+ Text [ en-US ] = "Other options" ;
+ };
+
+ CheckBox CB_QUOTED_AS_TEXT
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_ASCII:CB_QUOTED_AS_TEXT";
+ Pos = MAP_APPFONT ( 12 , 158 ) ;
+ Size = MAP_APPFONT ( 130 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Quoted field as text" ;
+ };
+
+ CheckBox CB_DETECT_SPECIAL_NUMBER
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_ASCII:CB_DETECT_SPECIAL_NUMBER";
+ Pos = MAP_APPFONT ( 12 , 171 ) ;
+ Size = MAP_APPFONT ( 130 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Detect special numbers" ;
+ };
+
+ FixedLine FL_WIDTH
+ {
+ Pos = MAP_APPFONT ( 6 , 187 ) ;
+ Size = MAP_APPFONT ( 252 , 8 ) ;
+ Text [ en-US ] = "Fields" ;
+ };
+ FixedText FT_TYPE
+ {
+ Pos = MAP_APPFONT ( 12 , 200 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Column t~ype";
+ };
+ ListBox LB_TYPE1
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_ASCII:LB_TYPE1";
+ Pos = MAP_APPFONT ( 76 , 198 ) ;
+ Size = MAP_APPFONT ( 60 , 68 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ Control CTR_TABLEBOX
+ {
+ HelpId = HID_SC_ASCII_TABCTR ;
+ Border = TRUE ;
+ DialogControl = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 216 ) ;
+ Size = MAP_APPFONT ( 243 , 82 ) ;
+ };
+
+ String STR_TEXTTOCOLUMNS
+ {
+ Text [ en-US ] = "Text to Columns" ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/dbgui/consdlg.cxx b/sc/source/ui/dbgui/consdlg.cxx
new file mode 100644
index 000000000000..e094149ab99b
--- /dev/null
+++ b/sc/source/ui/dbgui/consdlg.cxx
@@ -0,0 +1,655 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+#include <sfx2/dispatch.hxx>
+
+// INCLUDE -------------------------------------------------------------------
+
+#include "tabvwsh.hxx"
+#include "uiitems.hxx"
+#include "dbcolect.hxx"
+#include "rangenam.hxx"
+#include "rangeutl.hxx"
+#include "reffact.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+
+#include "globstr.hrc"
+#include "consdlg.hrc"
+
+#define _CONSDLG_CXX
+#include "consdlg.hxx"
+#undef _CONSDLG_CXX
+#include <vcl/msgbox.hxx>
+
+#define INFOBOX(id) InfoBox(this, ScGlobal::GetRscString(id)).Execute()
+
+//============================================================================
+// class ScAreaData
+
+class ScAreaData
+{
+public:
+ ScAreaData() {}
+ ~ScAreaData() {}
+
+ void Set( const String& rName, const String& rArea, BOOL bDb )
+ {
+ aStrName = rName;
+ aStrArea = rArea;
+ bIsDbArea = bDb;
+ }
+
+ String aStrName;
+ String aStrArea;
+ BOOL bIsDbArea;
+};
+
+
+//============================================================================
+// class ScConsolidateDialog
+
+
+ScConsolidateDlg::ScConsolidateDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ const SfxItemSet& rArgSet )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_CONSOLIDATE ),
+ //
+ aFtFunc ( this, ScResId( FT_FUNC ) ),
+ aLbFunc ( this, ScResId( LB_FUNC ) ),
+
+ aFtConsAreas ( this, ScResId( FT_CONSAREAS ) ),
+ aLbConsAreas ( this, ScResId( LB_CONSAREAS ) ),
+
+ aLbDataArea ( this, ScResId( LB_DATA_AREA ) ),
+ aFtDataArea ( this, ScResId( FT_DATA_AREA ) ),
+ aEdDataArea ( this, this, ScResId( ED_DATA_AREA ) ),
+ aRbDataArea ( this, ScResId( RB_DATA_AREA ), &aEdDataArea, this ),
+
+ aLbDestArea ( this, ScResId( LB_DEST_AREA ) ),
+ aFtDestArea ( this, ScResId( FT_DEST_AREA ) ),
+ aEdDestArea ( this, this, ScResId( ED_DEST_AREA ) ),
+ aRbDestArea ( this, ScResId( RB_DEST_AREA ), &aEdDestArea, this),
+
+ aFlConsBy ( this, ScResId( FL_CONSBY ) ),
+ aBtnByRow ( this, ScResId( BTN_BYROW ) ),
+ aBtnByCol ( this, ScResId( BTN_BYCOL) ),
+
+ aFlSep ( this, ScResId( FL_SEP ) ),
+ aFlOptions ( this, ScResId( FL_OPTIONS ) ),
+ aBtnRefs ( this, ScResId( BTN_REFS ) ),
+
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnAdd ( this, ScResId( BTN_ADD ) ),
+ aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
+ aBtnMore ( this, ScResId( BTN_MORE ) ),
+
+ aStrUndefined ( ScResId( SCSTR_UNDEFINED ) ),
+ //
+ theConsData ( ((const ScConsolidateItem&)
+ rArgSet.Get( rArgSet.GetPool()->
+ GetWhich( SID_CONSOLIDATE ) )
+ ).GetData() ),
+ pViewData ( ((ScTabViewShell*)SfxViewShell::Current())->
+ GetViewData() ),
+ pDoc ( ((ScTabViewShell*)SfxViewShell::Current())->
+ GetViewData()->GetDocument() ),
+ pRangeUtil ( new ScRangeUtil ),
+ pAreaData ( NULL ),
+ nAreaDataCount ( 0 ),
+ nWhichCons ( rArgSet.GetPool()->GetWhich( SID_CONSOLIDATE ) ),
+
+ pRefInputEdit ( &aEdDataArea )
+{
+ Init();
+ FreeResource();
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScConsolidateDlg::~ScConsolidateDlg()
+{
+ delete [] pAreaData;
+ delete pRangeUtil;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScConsolidateDlg::Init()
+{
+ DBG_ASSERT( pViewData && pDoc && pRangeUtil, "Error in Ctor" );
+
+ String aStr;
+ USHORT i=0;
+
+ aEdDataArea .SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
+ aEdDestArea .SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
+ aLbDataArea .SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
+ aLbDestArea .SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
+ aEdDataArea .SetModifyHdl ( LINK( this, ScConsolidateDlg, ModifyHdl ) );
+ aEdDestArea .SetModifyHdl ( LINK( this, ScConsolidateDlg, ModifyHdl ) );
+ aLbConsAreas.SetSelectHdl ( LINK( this, ScConsolidateDlg, SelectHdl ) );
+ aLbDataArea .SetSelectHdl ( LINK( this, ScConsolidateDlg, SelectHdl ) );
+ aLbDestArea .SetSelectHdl ( LINK( this, ScConsolidateDlg, SelectHdl ) );
+ aBtnOk .SetClickHdl ( LINK( this, ScConsolidateDlg, OkHdl ) );
+ aBtnCancel .SetClickHdl ( LINK( this, ScConsolidateDlg, ClickHdl ) );
+ aBtnAdd .SetClickHdl ( LINK( this, ScConsolidateDlg, ClickHdl ) );
+ aBtnRemove .SetClickHdl ( LINK( this, ScConsolidateDlg, ClickHdl ) );
+
+ aBtnMore.AddWindow( &aFlConsBy );
+ aBtnMore.AddWindow( &aBtnByRow );
+ aBtnMore.AddWindow( &aBtnByCol );
+ aBtnMore.AddWindow( &aFlSep );
+ aBtnMore.AddWindow( &aFlOptions );
+ aBtnMore.AddWindow( &aBtnRefs );
+
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+
+ aBtnByRow.Check( theConsData.bByRow );
+ aBtnByCol.Check( theConsData.bByCol );
+ aBtnRefs .Check( theConsData.bReferenceData );
+
+ aLbFunc.SelectEntryPos( FuncToLbPos( theConsData.eFunction ) );
+
+ // Einlesen der Konsolidierungsbereiche
+ aLbConsAreas.Clear();
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ for ( i=0; i<theConsData.nDataAreaCount; i++ )
+ {
+ const ScArea& rArea = *(theConsData.ppDataAreas[i] );
+ if ( rArea.nTab < pDoc->GetTableCount() )
+ {
+ ScRange( rArea.nColStart, rArea.nRowStart, rArea.nTab,
+ rArea.nColEnd, rArea.nRowEnd, rArea.nTab ).Format( aStr,
+ SCR_ABS_3D, pDoc, eConv );
+ aLbConsAreas.InsertEntry( aStr );
+ }
+ }
+
+ if ( theConsData.nTab < pDoc->GetTableCount() )
+ {
+ ScAddress( theConsData.nCol, theConsData.nRow, theConsData.nTab
+ ).Format( aStr, SCA_ABS_3D, pDoc, eConv );
+ aEdDestArea.SetText( aStr );
+ }
+ else
+ aEdDestArea.SetText( EMPTY_STRING );
+
+ //----------------------------------------------------------
+
+ /*
+ * Aus den RangeNames und Datenbankbereichen werden sich
+ * in der Hilfsklasse ScAreaData die Bereichsnamen gemerkt,
+ * die in den ListBoxen erscheinen.
+ */
+
+ ScRangeName* pRangeNames = pDoc->GetRangeName();
+ ScDBCollection* pDbNames = pDoc->GetDBCollection();
+ const USHORT nRangeCount = pRangeNames ? pRangeNames->GetCount() : 0;
+ const USHORT nDbCount = pDbNames ? pDbNames ->GetCount() : 0;
+
+ nAreaDataCount = nRangeCount+nDbCount;
+ pAreaData = NULL;
+
+ if ( nAreaDataCount > 0 )
+ {
+ pAreaData = new ScAreaData[nAreaDataCount];
+
+ String aStrName;
+ String aStrArea;
+ USHORT nAt = 0;
+ ScRange aRange;
+ ScAreaNameIterator aIter( pDoc );
+ while ( aIter.Next( aStrName, aRange ) )
+ {
+ aRange.Format( aStrArea, SCA_ABS_3D, pDoc, eConv );
+ pAreaData[nAt++].Set( aStrName, aStrArea, aIter.WasDBName() );
+ }
+ }
+
+ FillAreaLists();
+ ModifyHdl( &aEdDestArea );
+ aLbDataArea.SelectEntryPos( 0 );
+ aEdDataArea.SetText( EMPTY_STRING );
+ aEdDataArea.GrabFocus();
+
+ aFlSep.SetStyle( aFlSep.GetStyle() | WB_VERT );
+
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable();
+}
+
+
+//----------------------------------------------------------------------------
+void ScConsolidateDlg::FillAreaLists()
+{
+ aLbDataArea.Clear();
+ aLbDestArea.Clear();
+ aLbDataArea.InsertEntry( aStrUndefined );
+ aLbDestArea.InsertEntry( aStrUndefined );
+
+ if ( pRangeUtil && pAreaData && (nAreaDataCount > 0) )
+ {
+ String aString;
+
+ for ( USHORT i=0;
+ (i<nAreaDataCount) && (pAreaData[i].aStrName.Len()>0);
+ i++ )
+ {
+ aLbDataArea.InsertEntry( pAreaData[i].aStrName, i+1 );
+
+// if ( !pAreaData[i].bIsDbArea )
+ aLbDestArea.InsertEntry( pAreaData[i].aStrName, i+1 );
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------
+// Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
+// neue Selektion im Referenz-Fenster angezeigt wird.
+
+
+void ScConsolidateDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( pRefInputEdit )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart( pRefInputEdit );
+
+ String aStr;
+ USHORT nFmt = SCR_ABS_3D; //!!! nCurTab fehlt noch
+ const formula::FormulaGrammar::AddressConvention eConv = pDocP->GetAddressConvention();
+
+ if ( rRef.aStart.Tab() != rRef.aEnd.Tab() )
+ nFmt |= SCA_TAB2_3D;
+
+ if ( pRefInputEdit == &aEdDataArea)
+ rRef.Format( aStr, nFmt, pDocP, eConv );
+ else if ( pRefInputEdit == &aEdDestArea )
+ rRef.aStart.Format( aStr, nFmt, pDocP, eConv );
+
+ pRefInputEdit->SetRefString( aStr );
+ }
+
+ ModifyHdl( pRefInputEdit );
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScConsolidateDlg::Close()
+{
+ return DoClose( ScConsolidateDlgWrapper::GetChildWindowId() );
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScConsolidateDlg::SetActive()
+{
+ if ( bDlgLostFocus )
+ {
+ bDlgLostFocus = FALSE;
+
+ if ( pRefInputEdit )
+ {
+ pRefInputEdit->GrabFocus();
+ ModifyHdl( pRefInputEdit );
+ }
+ }
+ else
+ GrabFocus();
+
+ RefInputDone();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScConsolidateDlg::Deactivate()
+{
+ bDlgLostFocus = TRUE;
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScConsolidateDlg::VerifyEdit( formula::RefEdit* pEd )
+{
+ if ( !pRangeUtil || !pDoc || !pViewData ||
+ ((pEd != &aEdDataArea) && (pEd != &aEdDestArea)) )
+ return FALSE;
+
+ SCTAB nTab = pViewData->GetTabNo();
+ BOOL bEditOk = FALSE;
+ String theCompleteStr;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+
+ if ( pEd == &aEdDataArea )
+ {
+ bEditOk = pRangeUtil->IsAbsArea( pEd->GetText(), pDoc,
+ nTab, &theCompleteStr, NULL, NULL, eConv );
+ }
+ else if ( pEd == &aEdDestArea )
+ {
+ String aPosStr;
+
+ pRangeUtil->CutPosString( pEd->GetText(), aPosStr );
+ bEditOk = pRangeUtil->IsAbsPos( aPosStr, pDoc,
+ nTab, &theCompleteStr, NULL, eConv );
+ }
+
+ if ( bEditOk )
+ pEd->SetText( theCompleteStr );
+
+ return bEditOk;
+}
+
+
+//----------------------------------------------------------------------------
+// Handler:
+// ========
+
+IMPL_LINK( ScConsolidateDlg, GetFocusHdl, Control*, pCtr )
+{
+ if ( pCtr ==(Control*)&aEdDataArea ||
+ pCtr ==(Control*)&aEdDestArea)
+ {
+ pRefInputEdit = (formula::RefEdit*)pCtr;
+ }
+ else if(pCtr ==(Control*)&aLbDataArea )
+ {
+ pRefInputEdit = &aEdDataArea;
+ }
+ else if(pCtr ==(Control*)&aLbDestArea )
+ {
+ pRefInputEdit = &aEdDestArea;
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScConsolidateDlg, OkHdl, void*, EMPTYARG )
+{
+ USHORT nDataAreaCount = aLbConsAreas.GetEntryCount();
+
+ if ( nDataAreaCount > 0 )
+ {
+ ScRefAddress aDestAddress;
+ SCTAB nTab = pViewData->GetTabNo();
+ String aDestPosStr( aEdDestArea.GetText() );
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+
+ if ( pRangeUtil->IsAbsPos( aDestPosStr, pDoc, nTab, NULL, &aDestAddress, eConv ) )
+ {
+ ScConsolidateParam theOutParam( theConsData );
+ ScArea** ppDataAreas = new ScArea*[nDataAreaCount];
+ ScArea* pArea;
+ USHORT i=0;
+
+ for ( i=0; i<nDataAreaCount; i++ )
+ {
+ pArea = new ScArea;
+ pRangeUtil->MakeArea( aLbConsAreas.GetEntry( i ),
+ *pArea, pDoc, nTab, eConv );
+ ppDataAreas[i] = pArea;
+ }
+
+ theOutParam.nCol = aDestAddress.Col();
+ theOutParam.nRow = aDestAddress.Row();
+ theOutParam.nTab = aDestAddress.Tab();
+ theOutParam.eFunction = LbPosToFunc( aLbFunc.GetSelectEntryPos() );
+ theOutParam.bByCol = aBtnByCol.IsChecked();
+ theOutParam.bByRow = aBtnByRow.IsChecked();
+ theOutParam.bReferenceData = aBtnRefs.IsChecked();
+ theOutParam.SetAreas( ppDataAreas, nDataAreaCount );
+
+ for ( i=0; i<nDataAreaCount; i++ )
+ delete ppDataAreas[i];
+ delete [] ppDataAreas;
+
+ ScConsolidateItem aOutItem( nWhichCons, &theOutParam );
+
+ SetDispatcherLock( FALSE );
+ SwitchToDocument();
+ GetBindings().GetDispatcher()->Execute( SID_CONSOLIDATE,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ &aOutItem, 0L, 0L );
+ Close();
+ }
+ else
+ {
+ INFOBOX( STR_INVALID_TABREF );
+ aEdDestArea.GrabFocus();
+ }
+ }
+ else
+ Close(); // keine Datenbereiche definiert -> Cancel
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScConsolidateDlg, ClickHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &aBtnCancel )
+ Close();
+ else if ( pBtn == &aBtnAdd )
+ {
+ if ( aEdDataArea.GetText().Len() > 0 )
+ {
+ String aNewEntry( aEdDataArea.GetText() );
+ ScArea** ppAreas = NULL;
+ USHORT nAreaCount = 0;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+
+ if ( pRangeUtil->IsAbsTabArea( aNewEntry, pDoc, &ppAreas, &nAreaCount, TRUE, eConv ) )
+ {
+ // IsAbsTabArea() legt ein Array von ScArea-Zeigern an,
+ // welche ebenfalls dynamisch erzeugt wurden.
+ // Diese Objekte muessen hier abgeraeumt werden.
+
+ for ( USHORT i=0; i<nAreaCount; i++ )
+ {
+ String aNewArea;
+
+ if ( ppAreas[i] )
+ {
+ const ScArea& rArea = *(ppAreas[i]);
+ ScRange( rArea.nColStart, rArea.nRowStart, rArea.nTab,
+ rArea.nColEnd, rArea.nRowEnd, rArea.nTab
+ ).Format( aNewArea, SCR_ABS_3D, pDoc, eConv );
+
+ if ( aLbConsAreas.GetEntryPos( aNewArea )
+ == LISTBOX_ENTRY_NOTFOUND )
+ {
+ aLbConsAreas.InsertEntry( aNewArea );
+ }
+ delete ppAreas[i];
+ }
+ }
+ delete [] ppAreas;
+ }
+ else if ( VerifyEdit( &aEdDataArea ) )
+ {
+ String aNewArea( aEdDataArea.GetText() );
+
+ if ( aLbConsAreas.GetEntryPos( aNewArea ) == LISTBOX_ENTRY_NOTFOUND )
+ aLbConsAreas.InsertEntry( aNewArea );
+ else
+ INFOBOX( STR_AREA_ALREADY_INSERTED );
+ }
+ else
+ {
+ INFOBOX( STR_INVALID_TABREF );
+ aEdDataArea.GrabFocus();
+ }
+ }
+ }
+ else if ( pBtn == &aBtnRemove )
+ {
+ while ( aLbConsAreas.GetSelectEntryCount() )
+ aLbConsAreas.RemoveEntry( aLbConsAreas.GetSelectEntryPos() );
+ aBtnRemove.Disable();
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScConsolidateDlg, SelectHdl, ListBox*, pLb )
+{
+ if ( pLb == &aLbConsAreas )
+ {
+ if ( aLbConsAreas.GetSelectEntryCount() > 0 )
+ aBtnRemove.Enable();
+ else
+ aBtnRemove.Disable();
+ }
+ else if ( (pLb == &aLbDataArea) || (pLb == &aLbDestArea) )
+ {
+ Edit* pEd = (pLb == &aLbDataArea) ? &aEdDataArea : &aEdDestArea;
+ USHORT nSelPos = pLb->GetSelectEntryPos();
+
+ if ( pRangeUtil
+ && (nSelPos > 0)
+ && (nAreaDataCount > 0)
+ && (pAreaData != NULL) )
+ {
+ if ( nSelPos <= nAreaDataCount )
+ {
+ String aString( pAreaData[nSelPos-1].aStrArea );
+
+ if ( pLb == &aLbDestArea )
+ pRangeUtil->CutPosString( aString, aString );
+
+ pEd->SetText( aString );
+
+ if ( pEd == &aEdDataArea )
+ aBtnAdd.Enable();
+ }
+ }
+ else
+ {
+ pEd->SetText( EMPTY_STRING );
+ if ( pEd == &aEdDataArea )
+ aBtnAdd.Enable();
+ }
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScConsolidateDlg, ModifyHdl, formula::RefEdit*, pEd )
+{
+ if ( pEd == &aEdDataArea )
+ {
+ String aAreaStr( pEd->GetText() );
+ if ( aAreaStr.Len() > 0 )
+ {
+ aBtnAdd.Enable();
+ }
+ else
+ aBtnAdd.Disable();
+ }
+ else if ( pEd == &aEdDestArea )
+ {
+ aLbDestArea.SelectEntryPos(0);
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+// Verallgemeinern!!! :
+// Resource der ListBox und diese beiden Umrechnungsmethoden gibt es
+// auch noch in tpsubt bzw. ueberall, wo StarCalc-Funktionen
+// auswaehlbar sind.
+
+ScSubTotalFunc ScConsolidateDlg::LbPosToFunc( USHORT nPos )
+{
+ switch ( nPos )
+ {
+ case 2: return SUBTOTAL_FUNC_AVE;
+ case 6: return SUBTOTAL_FUNC_CNT;
+ case 1: return SUBTOTAL_FUNC_CNT2;
+ case 3: return SUBTOTAL_FUNC_MAX;
+ case 4: return SUBTOTAL_FUNC_MIN;
+ case 5: return SUBTOTAL_FUNC_PROD;
+ case 7: return SUBTOTAL_FUNC_STD;
+ case 8: return SUBTOTAL_FUNC_STDP;
+ case 9: return SUBTOTAL_FUNC_VAR;
+ case 10: return SUBTOTAL_FUNC_VARP;
+ case 0:
+ default:
+ return SUBTOTAL_FUNC_SUM;
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+USHORT ScConsolidateDlg::FuncToLbPos( ScSubTotalFunc eFunc )
+{
+ switch ( eFunc )
+ {
+ case SUBTOTAL_FUNC_AVE: return 2;
+ case SUBTOTAL_FUNC_CNT: return 6;
+ case SUBTOTAL_FUNC_CNT2: return 1;
+ case SUBTOTAL_FUNC_MAX: return 3;
+ case SUBTOTAL_FUNC_MIN: return 4;
+ case SUBTOTAL_FUNC_PROD: return 5;
+ case SUBTOTAL_FUNC_STD: return 7;
+ case SUBTOTAL_FUNC_STDP: return 8;
+ case SUBTOTAL_FUNC_VAR: return 9;
+ case SUBTOTAL_FUNC_VARP: return 10;
+ case SUBTOTAL_FUNC_NONE:
+ case SUBTOTAL_FUNC_SUM:
+ default:
+ return 0;
+ }
+}
+
diff --git a/sc/source/ui/dbgui/consdlg.hrc b/sc/source/ui/dbgui/consdlg.hrc
new file mode 100644
index 000000000000..6f9f6708c388
--- /dev/null
+++ b/sc/source/ui/dbgui/consdlg.hrc
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc"
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+#define BTN_MORE 4
+
+#define BTN_ADD 5
+#define BTN_REMOVE 6
+
+#define FT_FUNC 11
+#define LB_FUNC 12
+
+#define FT_CONSAREAS 21
+#define LB_CONSAREAS 22
+
+#define FT_DATA_AREA 31
+#define LB_DATA_AREA 32
+#define ED_DATA_AREA 33
+#define RB_DATA_AREA 34
+
+#define FT_DEST_AREA 41
+#define LB_DEST_AREA 42
+#define ED_DEST_AREA 43
+#define RB_DEST_AREA 44
+
+#define FL_CONSBY 50
+#define BTN_BYROW 51
+#define BTN_BYCOL 52
+#define FL_SEP 59
+
+#define FL_OPTIONS 60
+#define BTN_REFS 61
+
diff --git a/sc/source/ui/dbgui/consdlg.src b/sc/source/ui/dbgui/consdlg.src
new file mode 100644
index 000000000000..4dad5dcb3cee
--- /dev/null
+++ b/sc/source/ui/dbgui/consdlg.src
@@ -0,0 +1,231 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "consdlg.hrc"
+ModelessDialog RID_SCDLG_CONSOLIDATE
+{
+ OutputSize = TRUE ;
+ HelpId = CMD_SID_OPENDLG_CONSOLIDATE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 280 , 154 ) ;
+ Text [ en-US ] = "Consolidate" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ ListBox LB_FUNC
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_CONSOLIDATE:LB_FUNC";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 17 ) ;
+ Size = MAP_APPFONT ( 212 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "Sum" ; Default ; > ;
+ < "Count" ; Default ; > ;
+ < "Average" ; Default ; > ;
+ < "Max" ; Default ; > ;
+ < "Min" ; Default ; > ;
+ < "Product" ; Default ; > ;
+ < "Count (numbers only)" ; Default ; > ;
+ < "StDev (sample)" ; Default ; > ;
+ < "StDevP (population)" ; Default ; > ;
+ < "Var (sample)" ; Default ; > ;
+ < "VarP (population)" ; Default ; > ;
+ };
+ };
+ Edit ED_DATA_AREA
+ {
+ HelpID = "sc:Edit:RID_SCDLG_CONSOLIDATE:ED_DATA_AREA";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 100 , 106 ) ;
+ Size = MAP_APPFONT ( 104 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ Edit ED_DEST_AREA
+ {
+ HelpID = "sc:Edit:RID_SCDLG_CONSOLIDATE:ED_DEST_AREA";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 100 , 135 ) ;
+ Size = MAP_APPFONT ( 104 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_DATA_AREA
+ {
+ HelpID = "sc:ImageButton:RID_SCDLG_CONSOLIDATE:RB_DATA_AREA";
+ Pos = MAP_APPFONT ( 206 , 105 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ ImageButton RB_DEST_AREA
+ {
+ HelpID = "sc:ImageButton:RID_SCDLG_CONSOLIDATE:RB_DEST_AREA";
+ Pos = MAP_APPFONT ( 206 , 134 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ ListBox LB_DATA_AREA
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_CONSOLIDATE:LB_DATA_AREA";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 106 ) ;
+ Size = MAP_APPFONT ( 90 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_DEST_AREA
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_CONSOLIDATE:LB_DEST_AREA";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 135 ) ;
+ Size = MAP_APPFONT ( 90 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ MultiListBox LB_CONSAREAS
+ {
+ HelpID = "sc:MultiListBox:RID_SCDLG_CONSOLIDATE:LB_CONSAREAS";
+ SimpleMode = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 46 ) ;
+ Size = MAP_APPFONT ( 212 , 43 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_FUNC
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 212 , 8 ) ;
+ Text [ en-US ] = "~Function" ;
+ };
+ FixedText FT_CONSAREAS
+ {
+ Pos = MAP_APPFONT ( 6 , 35 ) ;
+ Size = MAP_APPFONT ( 212 , 8 ) ;
+ Text [ en-US ] = "~Consolidation ranges" ;
+ };
+ FixedText FT_DATA_AREA
+ {
+ Pos = MAP_APPFONT ( 6 , 95 ) ;
+ Size = MAP_APPFONT ( 212 , 8 ) ;
+ Text [ en-US ] = "~Source data range" ;
+ };
+ FixedText FT_DEST_AREA
+ {
+ Pos = MAP_APPFONT ( 6 , 124 ) ;
+ Size = MAP_APPFONT ( 212 , 8 ) ;
+ Text [ en-US ] = "Copy results ~to" ;
+ };
+ CheckBox BTN_BYROW
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_CONSOLIDATE:BTN_BYROW";
+ Pos = MAP_APPFONT ( 12 , 165 ) ;
+ Size = MAP_APPFONT ( 94 , 10 ) ;
+ Text [ en-US ] = "~Row labels" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_BYCOL
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_CONSOLIDATE:BTN_BYCOL";
+ Pos = MAP_APPFONT ( 12 , 179 ) ;
+ Size = MAP_APPFONT ( 94 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "C~olumn labels" ;
+ };
+ FixedLine FL_CONSBY
+ {
+ Pos = MAP_APPFONT ( 6 , 154 ) ;
+ Size = MAP_APPFONT ( 103 , 8 ) ;
+ Text [ en-US ] = "Consolidate by" ;
+ };
+ FixedLine FL_SEP
+ {
+ Pos = MAP_APPFONT ( 112 , 165 ) ;
+ Size = MAP_APPFONT ( 1 , 24 ) ;
+ };
+ FixedLine FL_OPTIONS
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 115 , 154 ) ;
+ Size = MAP_APPFONT ( 103 , 8 ) ;
+ Text [ en-US ] = "Options" ;
+ };
+ CheckBox BTN_REFS
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_CONSOLIDATE:BTN_REFS";
+ Pos = MAP_APPFONT ( 121 , 165 ) ;
+ Size = MAP_APPFONT ( 94 , 10 ) ;
+ Text [ en-US ] = "~Link to source data" ;
+ TabStop = TRUE ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 224 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 224 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 224 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ MoreButton BTN_MORE
+ {
+ HelpID = "sc:MoreButton:RID_SCDLG_CONSOLIDATE:BTN_MORE";
+ Pos = MAP_APPFONT ( 224 , 134 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ MapUnit = MAP_APPFONT ;
+ Delta = 41 ;
+ };
+ PushButton BTN_REMOVE
+ {
+ HelpID = "sc:PushButton:RID_SCDLG_CONSOLIDATE:BTN_REMOVE";
+ Pos = MAP_APPFONT ( 224 , 114 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Delete" ;
+ TabStop = TRUE ;
+ };
+ PushButton BTN_ADD
+ {
+ HelpID = "sc:PushButton:RID_SCDLG_CONSOLIDATE:BTN_ADD";
+ Pos = MAP_APPFONT ( 224 , 96 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Add" ;
+ TabStop = TRUE ;
+ };
+};
+
diff --git a/sc/source/ui/dbgui/csvcontrol.cxx b/sc/source/ui/dbgui/csvcontrol.cxx
new file mode 100644
index 000000000000..0dbc4e7dab39
--- /dev/null
+++ b/sc/source/ui/dbgui/csvcontrol.cxx
@@ -0,0 +1,337 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+// ============================================================================
+#include "csvcontrol.hxx"
+#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+#include "AccessibleCsvControl.hxx"
+
+
+// ============================================================================
+
+ScCsvLayoutData::ScCsvLayoutData() :
+ mnPosCount( 1 ),
+ mnPosOffset( 0 ),
+ mnWinWidth( 1 ),
+ mnHdrWidth( 0 ),
+ mnCharWidth( 1 ),
+ mnLineCount( 1 ),
+ mnLineOffset( 0 ),
+ mnWinHeight( 1 ),
+ mnHdrHeight( 0 ),
+ mnLineHeight( 1 ),
+ mnPosCursor( CSV_POS_INVALID ),
+ mnColCursor( 0 ),
+ mnNoRepaint( 0 ),
+ mbAppRTL( !!Application::GetSettings().GetLayoutRTL() )
+{
+}
+
+ScCsvDiff ScCsvLayoutData::GetDiff( const ScCsvLayoutData& rData ) const
+{
+ ScCsvDiff nRet = CSV_DIFF_EQUAL;
+ if( mnPosCount != rData.mnPosCount ) nRet |= CSV_DIFF_POSCOUNT;
+ if( mnPosOffset != rData.mnPosOffset ) nRet |= CSV_DIFF_POSOFFSET;
+ if( mnHdrWidth != rData.mnHdrWidth ) nRet |= CSV_DIFF_HDRWIDTH;
+ if( mnCharWidth != rData.mnCharWidth ) nRet |= CSV_DIFF_CHARWIDTH;
+ if( mnLineCount != rData.mnLineCount ) nRet |= CSV_DIFF_LINECOUNT;
+ if( mnLineOffset != rData.mnLineOffset ) nRet |= CSV_DIFF_LINEOFFSET;
+ if( mnHdrHeight != rData.mnHdrHeight ) nRet |= CSV_DIFF_HDRHEIGHT;
+ if( mnLineHeight != rData.mnLineHeight ) nRet |= CSV_DIFF_LINEHEIGHT;
+ if( mnPosCursor != rData.mnPosCursor ) nRet |= CSV_DIFF_RULERCURSOR;
+ if( mnColCursor != rData.mnColCursor ) nRet |= CSV_DIFF_GRIDCURSOR;
+ return nRet;
+}
+
+
+// ============================================================================
+
+ScCsvControl::ScCsvControl( ScCsvControl& rParent ) :
+ Control( &rParent, WB_TABSTOP | WB_NODIALOGCONTROL ),
+ mrData( rParent.GetLayoutData() ),
+ mpAccessible( NULL ),
+ mbValidGfx( false )
+{
+}
+
+ScCsvControl::ScCsvControl( Window* pParent, const ScCsvLayoutData& rData, WinBits nStyle ) :
+ Control( pParent, nStyle ),
+ mrData( rData ),
+ mpAccessible( NULL ),
+ mbValidGfx( false )
+{
+}
+
+ScCsvControl::ScCsvControl( Window* pParent, const ScCsvLayoutData& rData, const ResId& rResId ) :
+ Control( pParent, rResId ),
+ mrData( rData ),
+ mpAccessible( NULL ),
+ mbValidGfx( false )
+{
+}
+
+ScCsvControl::~ScCsvControl()
+{
+ if( mpAccessible )
+ mpAccessible->dispose();
+}
+
+
+// event handling -------------------------------------------------------------
+
+void ScCsvControl::GetFocus()
+{
+ Control::GetFocus();
+ AccSendFocusEvent( true );
+}
+
+void ScCsvControl::LoseFocus()
+{
+ Control::LoseFocus();
+ AccSendFocusEvent( false );
+}
+
+void ScCsvControl::AccSendFocusEvent( bool bFocused )
+{
+ if( mpAccessible )
+ mpAccessible->SendFocusEvent( bFocused );
+}
+
+void ScCsvControl::AccSendCaretEvent()
+{
+ if( mpAccessible )
+ mpAccessible->SendCaretEvent();
+}
+
+void ScCsvControl::AccSendVisibleEvent()
+{
+ if( mpAccessible )
+ mpAccessible->SendVisibleEvent();
+}
+
+void ScCsvControl::AccSendSelectionEvent()
+{
+ if( mpAccessible )
+ mpAccessible->SendSelectionEvent();
+}
+
+void ScCsvControl::AccSendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows )
+{
+ if( mpAccessible )
+ mpAccessible->SendTableUpdateEvent( nFirstColumn, nLastColumn, bAllRows );
+}
+
+void ScCsvControl::AccSendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn )
+{
+ if( mpAccessible )
+ mpAccessible->SendInsertColumnEvent( nFirstColumn, nLastColumn );
+}
+
+void ScCsvControl::AccSendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn )
+{
+ if( mpAccessible )
+ mpAccessible->SendRemoveColumnEvent( nFirstColumn, nLastColumn );
+}
+
+
+// repaint helpers ------------------------------------------------------------
+
+void ScCsvControl::Repaint( bool bInvalidate )
+{
+ if( bInvalidate )
+ InvalidateGfx();
+ if( !IsNoRepaint() )
+ Execute( CSVCMD_REPAINT );
+}
+
+void ScCsvControl::DisableRepaint()
+{
+ ++mrData.mnNoRepaint;
+}
+
+void ScCsvControl::EnableRepaint( bool bInvalidate )
+{
+ DBG_ASSERT( IsNoRepaint(), "ScCsvControl::EnableRepaint - invalid call" );
+ --mrData.mnNoRepaint;
+ Repaint( bInvalidate );
+}
+
+
+// command handling -----------------------------------------------------------
+
+void ScCsvControl::Execute( ScCsvCmdType eType, sal_Int32 nParam1, sal_Int32 nParam2 )
+{
+ maCmd.Set( eType, nParam1, nParam2 );
+ maCmdHdl.Call( this );
+}
+
+
+// layout helpers -------------------------------------------------------------
+
+sal_Int32 ScCsvControl::GetVisPosCount() const
+{
+ return (mrData.mnWinWidth - GetHdrWidth()) / GetCharWidth();
+}
+
+sal_Int32 ScCsvControl::GetMaxPosOffset() const
+{
+ return Max( GetPosCount() - GetVisPosCount() + 2L, 0L );
+}
+
+bool ScCsvControl::IsValidSplitPos( sal_Int32 nPos ) const
+{
+ return (0 < nPos) && (nPos < GetPosCount() );
+}
+
+bool ScCsvControl::IsVisibleSplitPos( sal_Int32 nPos ) const
+{
+ return IsValidSplitPos( nPos ) && (GetFirstVisPos() <= nPos) && (nPos <= GetLastVisPos());
+}
+
+sal_Int32 ScCsvControl::GetHdrX() const
+{
+ return IsRTL() ? (mrData.mnWinWidth - GetHdrWidth()) : 0;
+}
+
+sal_Int32 ScCsvControl::GetFirstX() const
+{
+ return IsRTL() ? 0 : GetHdrWidth();
+}
+
+sal_Int32 ScCsvControl::GetLastX() const
+{
+ return mrData.mnWinWidth - (IsRTL() ? GetHdrWidth() : 0) - 1;
+}
+
+sal_Int32 ScCsvControl::GetX( sal_Int32 nPos ) const
+{
+ return GetFirstX() + (nPos - GetFirstVisPos()) * GetCharWidth();
+}
+
+sal_Int32 ScCsvControl::GetPosFromX( sal_Int32 nX ) const
+{
+ return (nX - GetFirstX() + GetCharWidth() / 2) / GetCharWidth() + GetFirstVisPos();
+}
+
+sal_Int32 ScCsvControl::GetVisLineCount() const
+{
+ return (mrData.mnWinHeight - GetHdrHeight() - 2) / GetLineHeight() + 1;
+}
+
+sal_Int32 ScCsvControl::GetLastVisLine() const
+{
+ return Min( GetFirstVisLine() + GetVisLineCount(), GetLineCount() ) - 1;
+}
+
+sal_Int32 ScCsvControl::GetMaxLineOffset() const
+{
+ return Max( GetLineCount() - GetVisLineCount() + 1L, 0L );
+}
+
+bool ScCsvControl::IsValidLine( sal_Int32 nLine ) const
+{
+ return (0 <= nLine) && (nLine < GetLineCount());
+}
+
+bool ScCsvControl::IsVisibleLine( sal_Int32 nLine ) const
+{
+ return IsValidLine( nLine ) && (GetFirstVisLine() <= nLine) && (nLine <= GetLastVisLine());
+}
+
+sal_Int32 ScCsvControl::GetY( sal_Int32 nLine ) const
+{
+ return GetHdrHeight() + (nLine - GetFirstVisLine()) * GetLineHeight();
+}
+
+sal_Int32 ScCsvControl::GetLineFromY( sal_Int32 nY ) const
+{
+ return (nY - GetHdrHeight()) / GetLineHeight() + GetFirstVisLine();
+}
+
+
+// static helpers -------------------------------------------------------------
+
+void ScCsvControl::ImplInvertRect( OutputDevice& rOutDev, const Rectangle& rRect )
+{
+ rOutDev.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR | PUSH_RASTEROP );
+ rOutDev.SetLineColor( Color( COL_BLACK ) );
+ rOutDev.SetFillColor( Color( COL_BLACK ) );
+ rOutDev.SetRasterOp( ROP_INVERT );
+ rOutDev.DrawRect( rRect );
+ rOutDev.Pop();
+}
+
+ScMoveMode ScCsvControl::GetHorzDirection( sal_uInt16 nCode, bool bHomeEnd )
+{
+ switch( nCode )
+ {
+ case KEY_LEFT: return MOVE_PREV;
+ case KEY_RIGHT: return MOVE_NEXT;
+ }
+ if( bHomeEnd ) switch( nCode )
+ {
+ case KEY_HOME: return MOVE_FIRST;
+ case KEY_END: return MOVE_LAST;
+ }
+ return MOVE_NONE;
+}
+
+ScMoveMode ScCsvControl::GetVertDirection( sal_uInt16 nCode, bool bHomeEnd )
+{
+ switch( nCode )
+ {
+ case KEY_UP: return MOVE_PREV;
+ case KEY_DOWN: return MOVE_NEXT;
+ case KEY_PAGEUP: return MOVE_PREVPAGE;
+ case KEY_PAGEDOWN: return MOVE_NEXTPAGE;
+ }
+ if( bHomeEnd ) switch( nCode )
+ {
+ case KEY_HOME: return MOVE_FIRST;
+ case KEY_END: return MOVE_LAST;
+ }
+ return MOVE_NONE;
+}
+
+
+// accessibility --------------------------------------------------------------
+
+ScCsvControl::XAccessibleRef ScCsvControl::CreateAccessible()
+{
+ mpAccessible = ImplCreateAccessible();
+ mxAccessible = mpAccessible;
+ return mxAccessible;
+}
+
+
+// ============================================================================
+
diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx
new file mode 100644
index 000000000000..d271022a987c
--- /dev/null
+++ b/sc/source/ui/dbgui/csvgrid.cxx
@@ -0,0 +1,1355 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+// ============================================================================
+#include "csvgrid.hxx"
+
+#include <algorithm>
+#include <svtools/colorcfg.hxx>
+#include <svl/smplhint.hxx>
+#include <tools/poly.hxx>
+#include "scmod.hxx"
+#include "asciiopt.hxx"
+#include "impex.hxx"
+#include "AccessibleCsvControl.hxx"
+
+// *** edit engine ***
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+
+#include <editeng/colritem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/fontitem.hxx>
+#include <svl/itemset.hxx>
+#include "editutil.hxx"
+// *** edit engine ***
+
+
+// ============================================================================
+
+struct Func_SetType
+{
+ sal_Int32 mnType;
+ inline Func_SetType( sal_Int32 nType ) : mnType( nType ) {}
+ inline void operator()( ScCsvColState& rState ) { rState.mnType = mnType; }
+};
+
+struct Func_Select
+{
+ bool mbSelect;
+ inline Func_Select( bool bSelect ) : mbSelect( bSelect ) {}
+ inline void operator()( ScCsvColState& rState ) { rState.Select( mbSelect ); }
+};
+
+
+// ============================================================================
+
+ScCsvGrid::ScCsvGrid( ScCsvControl& rParent ) :
+ ScCsvControl( rParent ),
+ mrColorConfig( SC_MOD()->GetColorConfig() ),
+ mpEditEngine( new ScEditEngineDefaulter( EditEngine::CreatePool(), TRUE ) ),
+ maHeaderFont( GetFont() ),
+ maColStates( 1 ),
+ maTypeNames( 1 ),
+ mnFirstImpLine( 0 ),
+ mnRecentSelCol( CSV_COLUMN_INVALID )
+{
+ mpEditEngine->SetRefDevice( &maBackgrDev );
+ mpEditEngine->SetRefMapMode( MapMode( MAP_PIXEL ) );
+ maEdEngSize = mpEditEngine->GetPaperSize();
+
+ maPopup.SetMenuFlags( maPopup.GetMenuFlags() | MENU_FLAG_NOAUTOMNEMONICS );
+
+ EnableRTL( false ); // #107812# RTL
+ InitColors();
+ InitFonts();
+ ImplClearSplits();
+ mrColorConfig.AddListener(this);
+}
+
+ScCsvGrid::~ScCsvGrid()
+{
+ mrColorConfig.RemoveListener(this);
+}
+
+
+// common grid handling -------------------------------------------------------
+
+void ScCsvGrid::UpdateLayoutData()
+{
+ DisableRepaint();
+ SetFont( maMonoFont );
+ Execute( CSVCMD_SETCHARWIDTH, GetTextWidth( String( 'X' ) ) );
+ Execute( CSVCMD_SETLINEHEIGHT, GetTextHeight() + 1 );
+ SetFont( maHeaderFont );
+ Execute( CSVCMD_SETHDRHEIGHT, GetTextHeight() + 1 );
+ UpdateOffsetX();
+ EnableRepaint();
+}
+
+void ScCsvGrid::UpdateOffsetX()
+{
+ sal_Int32 nLastLine = GetLastVisLine() + 1;
+ sal_Int32 nDigits = 2;
+ while( nLastLine /= 10 ) ++nDigits;
+ nDigits = Max( nDigits, sal_Int32( 3 ) );
+ Execute( CSVCMD_SETHDRWIDTH, GetTextWidth( String( '0' ) ) * nDigits );
+}
+
+void ScCsvGrid::ApplyLayout( const ScCsvLayoutData& rOldData )
+{
+ ScCsvDiff nDiff = GetLayoutData().GetDiff( rOldData );
+ if( nDiff == CSV_DIFF_EQUAL ) return;
+
+ DisableRepaint();
+
+ if( nDiff & CSV_DIFF_RULERCURSOR )
+ {
+ ImplInvertCursor( rOldData.mnPosCursor );
+ ImplInvertCursor( GetRulerCursorPos() );
+ }
+
+ if( nDiff & CSV_DIFF_POSCOUNT )
+ {
+ if( GetPosCount() < rOldData.mnPosCount )
+ {
+ SelectAll( false );
+ maSplits.RemoveRange( GetPosCount(), rOldData.mnPosCount );
+ }
+ else
+ maSplits.Remove( rOldData.mnPosCount );
+ maSplits.Insert( GetPosCount() );
+ maColStates.resize( maSplits.Count() - 1 );
+ }
+
+ if( nDiff & CSV_DIFF_LINEOFFSET )
+ {
+ Execute( CSVCMD_UPDATECELLTEXTS );
+ UpdateOffsetX();
+ }
+
+ ScCsvDiff nHVDiff = nDiff & (CSV_DIFF_HORIZONTAL | CSV_DIFF_VERTICAL);
+ if( nHVDiff == CSV_DIFF_POSOFFSET )
+ ImplDrawHorzScrolled( rOldData.mnPosOffset );
+ else if( nHVDiff != CSV_DIFF_EQUAL )
+ InvalidateGfx();
+
+ EnableRepaint();
+
+ if( nDiff & (CSV_DIFF_POSOFFSET | CSV_DIFF_LINEOFFSET) )
+ AccSendVisibleEvent();
+}
+
+void ScCsvGrid::SetFirstImportedLine( sal_Int32 nLine )
+{
+ ImplDrawFirstLineSep( false );
+ mnFirstImpLine = nLine;
+ ImplDrawFirstLineSep( true );
+ ImplDrawGridDev();
+ Repaint();
+}
+
+sal_Int32 ScCsvGrid::GetNoScrollCol( sal_Int32 nPos ) const
+{
+ sal_Int32 nNewPos = nPos;
+ if( nNewPos != CSV_POS_INVALID )
+ {
+ if( nNewPos < GetFirstVisPos() + CSV_SCROLL_DIST )
+ {
+ sal_Int32 nScroll = (GetFirstVisPos() > 0) ? CSV_SCROLL_DIST : 0;
+ nNewPos = GetFirstVisPos() + nScroll;
+ }
+ else if( nNewPos > GetLastVisPos() - CSV_SCROLL_DIST - 1L )
+ {
+ sal_Int32 nScroll = (GetFirstVisPos() < GetMaxPosOffset()) ? CSV_SCROLL_DIST : 0;
+ nNewPos = GetLastVisPos() - nScroll - 1;
+ }
+ }
+ return nNewPos;
+}
+
+void ScCsvGrid::InitColors()
+{
+ maBackColor.SetColor( static_cast< sal_uInt32 >( mrColorConfig.GetColorValue( ::svtools::DOCCOLOR ).nColor ) );
+ maGridColor.SetColor( static_cast< sal_uInt32 >( mrColorConfig.GetColorValue( ::svtools::CALCGRID ).nColor ) );
+ maGridPBColor.SetColor( static_cast< sal_uInt32 >( mrColorConfig.GetColorValue( ::svtools::CALCPAGEBREAK ).nColor ) );
+ maAppBackColor.SetColor( static_cast< sal_uInt32 >( mrColorConfig.GetColorValue( ::svtools::APPBACKGROUND ).nColor ) );
+ maTextColor.SetColor( static_cast< sal_uInt32 >( mrColorConfig.GetColorValue( ::svtools::FONTCOLOR ).nColor ) );
+
+ const StyleSettings& rSett = GetSettings().GetStyleSettings();
+ maHeaderBackColor = rSett.GetFaceColor();
+ maHeaderGridColor = rSett.GetDarkShadowColor();
+ maHeaderTextColor = rSett.GetButtonTextColor();
+ maSelectColor = rSett.GetActiveColor();
+
+ InvalidateGfx();
+}
+
+void ScCsvGrid::InitFonts()
+{
+ maMonoFont = OutputDevice::GetDefaultFont( DEFAULTFONT_FIXED, LANGUAGE_ENGLISH_US, 0 );
+ maMonoFont.SetSize( Size( maMonoFont.GetSize().Width(), maHeaderFont.GetSize().Height() ) );
+
+ /* *** Set edit engine defaults ***
+ maMonoFont for Latin script, smaller default font for Asian and Complex script. */
+
+ // get default fonts
+ SvxFontItem aLatinItem( EE_CHAR_FONTINFO );
+ SvxFontItem aAsianItem( EE_CHAR_FONTINFO_CJK );
+ SvxFontItem aComplexItem( EE_CHAR_FONTINFO_CTL );
+ ::GetDefaultFonts( aLatinItem, aAsianItem, aComplexItem );
+
+ // create item set for defaults
+ SfxItemSet aDefSet( mpEditEngine->GetEmptyItemSet() );
+ EditEngine::SetFontInfoInItemSet( aDefSet, maMonoFont );
+ aDefSet.Put( aAsianItem );
+ aDefSet.Put( aComplexItem );
+
+ // set Asian/Complex font size to height of character in Latin font
+ ULONG nFontHt = static_cast< ULONG >( maMonoFont.GetSize().Height() );
+ aDefSet.Put( SvxFontHeightItem( nFontHt, 100, EE_CHAR_FONTHEIGHT_CJK ) );
+ aDefSet.Put( SvxFontHeightItem( nFontHt, 100, EE_CHAR_FONTHEIGHT_CTL ) );
+
+ // copy other items from default font
+ const SfxPoolItem& rWeightItem = aDefSet.Get( EE_CHAR_WEIGHT );
+ aDefSet.Put( rWeightItem, EE_CHAR_WEIGHT_CJK );
+ aDefSet.Put( rWeightItem, EE_CHAR_WEIGHT_CTL );
+ const SfxPoolItem& rItalicItem = aDefSet.Get( EE_CHAR_ITALIC );
+ aDefSet.Put( rItalicItem, EE_CHAR_ITALIC_CJK );
+ aDefSet.Put( rItalicItem, EE_CHAR_ITALIC_CTL );
+ const SfxPoolItem& rLangItem = aDefSet.Get( EE_CHAR_LANGUAGE );
+ aDefSet.Put( rLangItem, EE_CHAR_LANGUAGE_CJK );
+ aDefSet.Put( rLangItem, EE_CHAR_LANGUAGE_CTL );
+
+ mpEditEngine->SetDefaults( aDefSet );
+ InvalidateGfx();
+}
+
+void ScCsvGrid::InitSizeData()
+{
+ maWinSize = GetSizePixel();
+ maBackgrDev.SetOutputSizePixel( maWinSize );
+ maGridDev.SetOutputSizePixel( maWinSize );
+ InvalidateGfx();
+}
+
+
+// split handling -------------------------------------------------------------
+
+void ScCsvGrid::InsertSplit( sal_Int32 nPos )
+{
+ if( ImplInsertSplit( nPos ) )
+ {
+ DisableRepaint();
+ Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ Execute( CSVCMD_UPDATECELLTEXTS );
+ sal_uInt32 nColIx = GetColumnFromPos( nPos );
+ ImplDrawColumn( nColIx - 1 );
+ ImplDrawColumn( nColIx );
+ ValidateGfx(); // performance: do not redraw all columns
+ EnableRepaint();
+ }
+}
+
+void ScCsvGrid::RemoveSplit( sal_Int32 nPos )
+{
+ if( ImplRemoveSplit( nPos ) )
+ {
+ DisableRepaint();
+ Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ Execute( CSVCMD_UPDATECELLTEXTS );
+ ImplDrawColumn( GetColumnFromPos( nPos ) );
+ ValidateGfx(); // performance: do not redraw all columns
+ EnableRepaint();
+ }
+}
+
+void ScCsvGrid::MoveSplit( sal_Int32 nPos, sal_Int32 nNewPos )
+{
+ sal_uInt32 nColIx = GetColumnFromPos( nPos );
+ if( nColIx != CSV_COLUMN_INVALID )
+ {
+ DisableRepaint();
+ if( (GetColumnPos( nColIx - 1 ) < nNewPos) && (nNewPos < GetColumnPos( nColIx + 1 )) )
+ {
+ // move a split in the range between 2 others -> keep selection state of both columns
+ maSplits.Remove( nPos );
+ maSplits.Insert( nNewPos );
+ Execute( CSVCMD_UPDATECELLTEXTS );
+ ImplDrawColumn( nColIx - 1 );
+ ImplDrawColumn( nColIx );
+ ValidateGfx(); // performance: do not redraw all columns
+ AccSendTableUpdateEvent( nColIx - 1, nColIx );
+ }
+ else
+ {
+ ImplRemoveSplit( nPos );
+ ImplInsertSplit( nNewPos );
+ Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ Execute( CSVCMD_UPDATECELLTEXTS );
+ }
+ EnableRepaint();
+ }
+}
+
+void ScCsvGrid::RemoveAllSplits()
+{
+ DisableRepaint();
+ ImplClearSplits();
+ Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ Execute( CSVCMD_UPDATECELLTEXTS );
+ EnableRepaint();
+}
+
+void ScCsvGrid::SetSplits( const ScCsvSplits& rSplits )
+{
+ DisableRepaint();
+ ImplClearSplits();
+ sal_uInt32 nCount = rSplits.Count();
+ for( sal_uInt32 nIx = 0; nIx < nCount; ++nIx )
+ maSplits.Insert( rSplits[ nIx ] );
+ maColStates.clear();
+ maColStates.resize( maSplits.Count() - 1 );
+ Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ Execute( CSVCMD_UPDATECELLTEXTS );
+ EnableRepaint();
+}
+
+bool ScCsvGrid::ImplInsertSplit( sal_Int32 nPos )
+{
+ sal_uInt32 nColIx = GetColumnFromPos( nPos );
+ bool bRet = (nColIx < GetColumnCount()) && maSplits.Insert( nPos );
+ if( bRet )
+ {
+ ScCsvColState aState( GetColumnType( nColIx ) );
+ aState.Select( IsSelected( nColIx ) && IsSelected( nColIx + 1 ) );
+ maColStates.insert( maColStates.begin() + nColIx + 1, aState );
+ AccSendInsertColumnEvent( nColIx + 1, nColIx + 1 );
+ AccSendTableUpdateEvent( nColIx, nColIx );
+ }
+ return bRet;
+}
+
+bool ScCsvGrid::ImplRemoveSplit( sal_Int32 nPos )
+{
+ bool bRet = maSplits.Remove( nPos );
+ if( bRet )
+ {
+ sal_uInt32 nColIx = GetColumnFromPos( nPos );
+ bool bSel = IsSelected( nColIx ) || IsSelected( nColIx + 1 );
+ maColStates.erase( maColStates.begin() + nColIx + 1 );
+ maColStates[ nColIx ].Select( bSel );
+ AccSendRemoveColumnEvent( nColIx + 1, nColIx + 1 );
+ AccSendTableUpdateEvent( nColIx, nColIx );
+ }
+ return bRet;
+}
+
+void ScCsvGrid::ImplClearSplits()
+{
+ sal_uInt32 nColumns = GetColumnCount();
+ maSplits.Clear();
+ maSplits.Insert( 0 );
+ maSplits.Insert( GetPosCount() );
+ maColStates.resize( 1 );
+ InvalidateGfx();
+ AccSendRemoveColumnEvent( 1, nColumns - 1 );
+}
+
+// columns/column types -------------------------------------------------------
+
+sal_uInt32 ScCsvGrid::GetFirstVisColumn() const
+{
+ return GetColumnFromPos( GetFirstVisPos() );
+}
+
+sal_uInt32 ScCsvGrid::GetLastVisColumn() const
+{
+ return GetColumnFromPos( Min( GetLastVisPos(), GetPosCount() ) - 1 );
+}
+
+bool ScCsvGrid::IsValidColumn( sal_uInt32 nColIndex ) const
+{
+ return nColIndex < GetColumnCount();
+}
+
+bool ScCsvGrid::IsVisibleColumn( sal_uInt32 nColIndex ) const
+{
+ return IsValidColumn( nColIndex ) &&
+ (GetColumnPos( nColIndex ) < GetLastVisPos()) &&
+ (GetFirstVisPos() < GetColumnPos( nColIndex + 1 ));
+}
+
+sal_Int32 ScCsvGrid::GetColumnX( sal_uInt32 nColIndex ) const
+{
+ return GetX( GetColumnPos( nColIndex ) );
+}
+
+sal_uInt32 ScCsvGrid::GetColumnFromX( sal_Int32 nX ) const
+{
+ sal_Int32 nPos = (nX - GetFirstX()) / GetCharWidth() + GetFirstVisPos();
+ return ((GetFirstVisPos() <= nPos) && (nPos <= GetLastVisPos())) ?
+ GetColumnFromPos( nPos ) : CSV_COLUMN_INVALID;
+}
+
+sal_uInt32 ScCsvGrid::GetColumnFromPos( sal_Int32 nPos ) const
+{
+ return maSplits.UpperBound( nPos );
+}
+
+sal_Int32 ScCsvGrid::GetColumnWidth( sal_uInt32 nColIndex ) const
+{
+ return IsValidColumn( nColIndex ) ? (GetColumnPos( nColIndex + 1 ) - GetColumnPos( nColIndex )) : 0;
+}
+
+void ScCsvGrid::SetColumnStates( const ScCsvColStateVec& rStates )
+{
+ maColStates = rStates;
+ maColStates.resize( maSplits.Count() - 1 );
+ Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ AccSendTableUpdateEvent( 0, GetColumnCount(), false );
+ AccSendSelectionEvent();
+}
+
+sal_Int32 ScCsvGrid::GetColumnType( sal_uInt32 nColIndex ) const
+{
+ return IsValidColumn( nColIndex ) ? maColStates[ nColIndex ].mnType : CSV_TYPE_NOSELECTION;
+}
+
+void ScCsvGrid::SetColumnType( sal_uInt32 nColIndex, sal_Int32 nColType )
+{
+ if( IsValidColumn( nColIndex ) )
+ {
+ maColStates[ nColIndex ].mnType = nColType;
+ AccSendTableUpdateEvent( nColIndex, nColIndex, false );
+ }
+}
+
+sal_Int32 ScCsvGrid::GetSelColumnType() const
+{
+ sal_uInt32 nColIx = GetFirstSelected();
+ if( nColIx == CSV_COLUMN_INVALID )
+ return CSV_TYPE_NOSELECTION;
+
+ sal_Int32 nType = GetColumnType( nColIx );
+ while( (nColIx != CSV_COLUMN_INVALID) && (nType != CSV_TYPE_MULTI) )
+ {
+ if( nType != GetColumnType( nColIx ) )
+ nType = CSV_TYPE_MULTI;
+ nColIx = GetNextSelected( nColIx );
+ }
+ return nType;
+}
+
+void ScCsvGrid::SetSelColumnType( sal_Int32 nType )
+{
+ if( (nType != CSV_TYPE_MULTI) && (nType != CSV_TYPE_NOSELECTION) )
+ {
+ for( sal_uInt32 nColIx = GetFirstSelected(); nColIx != CSV_COLUMN_INVALID; nColIx = GetNextSelected( nColIx ) )
+ SetColumnType( nColIx, nType );
+ Repaint( true );
+ Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ }
+}
+
+void ScCsvGrid::SetTypeNames( const StringVec& rTypeNames )
+{
+ DBG_ASSERT( !rTypeNames.empty(), "ScCsvGrid::SetTypeNames - vector is empty" );
+ maTypeNames = rTypeNames;
+ Repaint( true );
+
+ maPopup.Clear();
+ sal_uInt32 nCount = maTypeNames.size();
+ sal_uInt32 nIx;
+ sal_uInt16 nItemId;
+ for( nIx = 0, nItemId = 1; nIx < nCount; ++nIx, ++nItemId )
+ maPopup.InsertItem( nItemId, maTypeNames[ nIx ] );
+
+ ::std::for_each( maColStates.begin(), maColStates.end(), Func_SetType( CSV_TYPE_DEFAULT ) );
+}
+
+const String& ScCsvGrid::GetColumnTypeName( sal_uInt32 nColIndex ) const
+{
+ sal_uInt32 nTypeIx = static_cast< sal_uInt32 >( GetColumnType( nColIndex ) );
+ return (nTypeIx < maTypeNames.size()) ? maTypeNames[ nTypeIx ] : EMPTY_STRING;
+}
+
+sal_uInt8 lcl_GetExtColumnType( sal_Int32 nIntType )
+{
+ static sal_uInt8 pExtTypes[] =
+ { SC_COL_STANDARD, SC_COL_TEXT, SC_COL_DMY, SC_COL_MDY, SC_COL_YMD, SC_COL_ENGLISH, SC_COL_SKIP };
+ static sal_Int32 nExtTypeCount = sizeof( pExtTypes ) / sizeof( *pExtTypes );
+ return pExtTypes[ ((0 <= nIntType) && (nIntType < nExtTypeCount)) ? nIntType : 0 ];
+}
+
+void ScCsvGrid::FillColumnDataSep( ScAsciiOptions& rOptions ) const
+{
+ sal_uInt32 nCount = GetColumnCount();
+ ScCsvExpDataVec aDataVec;
+
+ for( sal_uInt32 nColIx = 0; nColIx < nCount; ++nColIx )
+ {
+ if( GetColumnType( nColIx ) != CSV_TYPE_DEFAULT )
+ // 1-based column index
+ aDataVec.push_back( ScCsvExpData(
+ static_cast< xub_StrLen >( nColIx + 1 ),
+ lcl_GetExtColumnType( GetColumnType( nColIx ) ) ) );
+ }
+ rOptions.SetColumnInfo( aDataVec );
+}
+
+void ScCsvGrid::FillColumnDataFix( ScAsciiOptions& rOptions ) const
+{
+ sal_uInt32 nCount = Min( GetColumnCount(), static_cast<sal_uInt32>(MAXCOLCOUNT) );
+ ScCsvExpDataVec aDataVec( nCount + 1 );
+
+ for( sal_uInt32 nColIx = 0; nColIx < nCount; ++nColIx )
+ {
+ ScCsvExpData& rData = aDataVec[ nColIx ];
+ rData.mnIndex = static_cast< xub_StrLen >(
+ Min( static_cast< sal_Int32 >( STRING_MAXLEN ), GetColumnPos( nColIx ) ) );
+ rData.mnType = lcl_GetExtColumnType( GetColumnType( nColIx ) );
+ }
+ aDataVec[ nCount ].mnIndex = STRING_MAXLEN;
+ aDataVec[ nCount ].mnType = SC_COL_SKIP;
+ rOptions.SetColumnInfo( aDataVec );
+}
+
+void ScCsvGrid::ScrollVertRel( ScMoveMode eDir )
+{
+ sal_Int32 nLine = GetFirstVisLine();
+ switch( eDir )
+ {
+ case MOVE_PREV: --nLine; break;
+ case MOVE_NEXT: ++nLine; break;
+ case MOVE_FIRST: nLine = 0; break;
+ case MOVE_LAST: nLine = GetMaxLineOffset(); break;
+ case MOVE_PREVPAGE: nLine -= GetVisLineCount() - 2; break;
+ case MOVE_NEXTPAGE: nLine += GetVisLineCount() - 2; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ Execute( CSVCMD_SETLINEOFFSET, nLine );
+}
+
+void ScCsvGrid::ExecutePopup( const Point& rPos )
+{
+ sal_uInt16 nItemId = maPopup.Execute( this, rPos );
+ if( nItemId ) // 0 = cancelled
+ Execute( CSVCMD_SETCOLUMNTYPE, maPopup.GetItemPos( nItemId ) );
+}
+
+
+// selection handling ---------------------------------------------------------
+
+bool ScCsvGrid::IsSelected( sal_uInt32 nColIndex ) const
+{
+ return IsValidColumn( nColIndex ) && maColStates[ nColIndex ].IsSelected();
+}
+
+sal_uInt32 ScCsvGrid::GetFirstSelected() const
+{
+ return IsSelected( 0 ) ? 0 : GetNextSelected( 0 );
+}
+
+sal_uInt32 ScCsvGrid::GetNextSelected( sal_uInt32 nFromIndex ) const
+{
+ sal_uInt32 nColCount = GetColumnCount();
+ for( sal_uInt32 nColIx = nFromIndex + 1; nColIx < nColCount; ++nColIx )
+ if( IsSelected( nColIx ) )
+ return nColIx;
+ return CSV_COLUMN_INVALID;
+}
+
+void ScCsvGrid::Select( sal_uInt32 nColIndex, bool bSelect )
+{
+ if( IsValidColumn( nColIndex ) )
+ {
+ maColStates[ nColIndex ].Select( bSelect );
+ ImplDrawColumnSelection( nColIndex );
+ Repaint();
+ Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ if( bSelect )
+ mnRecentSelCol = nColIndex;
+ AccSendSelectionEvent();
+ }
+}
+
+void ScCsvGrid::ToggleSelect( sal_uInt32 nColIndex )
+{
+ Select( nColIndex, !IsSelected( nColIndex ) );
+}
+
+void ScCsvGrid::SelectRange( sal_uInt32 nColIndex1, sal_uInt32 nColIndex2, bool bSelect )
+{
+ if( nColIndex1 == CSV_COLUMN_INVALID )
+ Select( nColIndex2 );
+ else if( nColIndex2 == CSV_COLUMN_INVALID )
+ Select( nColIndex1 );
+ else if( nColIndex1 > nColIndex2 )
+ {
+ SelectRange( nColIndex2, nColIndex1, bSelect );
+ if( bSelect )
+ mnRecentSelCol = nColIndex1;
+ }
+ else if( IsValidColumn( nColIndex1 ) && IsValidColumn( nColIndex2 ) )
+ {
+ for( sal_uInt32 nColIx = nColIndex1; nColIx <= nColIndex2; ++nColIx )
+ {
+ maColStates[ nColIx ].Select( bSelect );
+ ImplDrawColumnSelection( nColIx );
+ }
+ Repaint();
+ Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ if( bSelect )
+ mnRecentSelCol = nColIndex1;
+ AccSendSelectionEvent();
+ }
+}
+
+void ScCsvGrid::SelectAll( bool bSelect )
+{
+ SelectRange( 0, GetColumnCount() - 1, bSelect );
+}
+
+void ScCsvGrid::MoveCursor( sal_uInt32 nColIndex )
+{
+ DisableRepaint();
+ if( IsValidColumn( nColIndex ) )
+ {
+ sal_Int32 nPosBeg = GetColumnPos( nColIndex );
+ sal_Int32 nPosEnd = GetColumnPos( nColIndex + 1 );
+ sal_Int32 nMinPos = Max( nPosBeg - CSV_SCROLL_DIST, sal_Int32( 0 ) );
+ sal_Int32 nMaxPos = Min( nPosEnd - GetVisPosCount() + CSV_SCROLL_DIST + sal_Int32( 1 ), nMinPos );
+ if( nPosBeg - CSV_SCROLL_DIST + 1 <= GetFirstVisPos() )
+ Execute( CSVCMD_SETPOSOFFSET, nMinPos );
+ else if( nPosEnd + CSV_SCROLL_DIST >= GetLastVisPos() )
+ Execute( CSVCMD_SETPOSOFFSET, nMaxPos );
+ }
+ Execute( CSVCMD_MOVEGRIDCURSOR, GetColumnPos( nColIndex ) );
+ EnableRepaint();
+}
+
+void ScCsvGrid::MoveCursorRel( ScMoveMode eDir )
+{
+ if( GetFocusColumn() != CSV_COLUMN_INVALID )
+ {
+ switch( eDir )
+ {
+ case MOVE_FIRST:
+ MoveCursor( 0 );
+ break;
+ case MOVE_LAST:
+ MoveCursor( GetColumnCount() - 1 );
+ break;
+ case MOVE_PREV:
+ if( GetFocusColumn() > 0 )
+ MoveCursor( GetFocusColumn() - 1 );
+ break;
+ case MOVE_NEXT:
+ if( GetFocusColumn() < GetColumnCount() - 1 )
+ MoveCursor( GetFocusColumn() + 1 );
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+}
+
+void ScCsvGrid::ImplClearSelection()
+{
+ ::std::for_each( maColStates.begin(), maColStates.end(), Func_Select( false ) );
+ ImplDrawGridDev();
+}
+
+void ScCsvGrid::DoSelectAction( sal_uInt32 nColIndex, sal_uInt16 nModifier )
+{
+ if( !(nModifier & KEY_MOD1) )
+ ImplClearSelection();
+ if( nModifier & KEY_SHIFT ) // SHIFT always expands
+ SelectRange( mnRecentSelCol, nColIndex );
+ else if( !(nModifier & KEY_MOD1) ) // no SHIFT/CTRL always selects 1 column
+ Select( nColIndex );
+ else if( IsTracking() ) // CTRL in tracking does not toggle
+ Select( nColIndex, mbMTSelecting );
+ else // CTRL only toggles
+ ToggleSelect( nColIndex );
+ Execute( CSVCMD_MOVEGRIDCURSOR, GetColumnPos( nColIndex ) );
+}
+
+
+// cell contents --------------------------------------------------------------
+
+void ScCsvGrid::ImplSetTextLineSep(
+ sal_Int32 nLine, const String& rTextLine,
+ const String& rSepChars, sal_Unicode cTextSep, bool bMergeSep )
+{
+ if( nLine < GetFirstVisLine() ) return;
+
+ sal_uInt32 nLineIx = nLine - GetFirstVisLine();
+ while( maTexts.size() <= nLineIx )
+ maTexts.push_back( StringVec() );
+ StringVec& rStrVec = maTexts[ nLineIx ];
+ rStrVec.clear();
+
+ // scan for separators
+ String aCellText;
+ const sal_Unicode* pSepChars = rSepChars.GetBuffer();
+ const sal_Unicode* pChar = rTextLine.GetBuffer();
+ sal_uInt32 nColIx = 0;
+
+ while( *pChar && (nColIx < sal::static_int_cast<sal_uInt32>(CSV_MAXCOLCOUNT)) )
+ {
+ // scan for next cell text
+ bool bIsQuoted = false;
+ pChar = ScImportExport::ScanNextFieldFromString( pChar, aCellText, cTextSep, pSepChars, bMergeSep, bIsQuoted );
+
+ // update column width
+ sal_Int32 nWidth = Max( CSV_MINCOLWIDTH, aCellText.Len() + sal_Int32( 1 ) );
+ if( IsValidColumn( nColIx ) )
+ {
+ // expand existing column
+ sal_Int32 nDiff = nWidth - GetColumnWidth( nColIx );
+ if( nDiff > 0 )
+ {
+ Execute( CSVCMD_SETPOSCOUNT, GetPosCount() + nDiff );
+ for( sal_uInt32 nSplitIx = GetColumnCount() - 1; nSplitIx > nColIx; --nSplitIx )
+ {
+ sal_Int32 nPos = maSplits[ nSplitIx ];
+ maSplits.Remove( nPos );
+ maSplits.Insert( nPos + nDiff );
+ }
+ }
+ }
+ else
+ {
+ // append new column
+ sal_Int32 nLastPos = GetPosCount();
+ Execute( CSVCMD_SETPOSCOUNT, nLastPos + nWidth );
+ ImplInsertSplit( nLastPos );
+ }
+
+ if( aCellText.Len() <= CSV_MAXSTRLEN )
+ rStrVec.push_back( aCellText );
+ else
+ rStrVec.push_back( aCellText.Copy( 0, CSV_MAXSTRLEN ) );
+ ++nColIx;
+ }
+ InvalidateGfx();
+}
+
+void ScCsvGrid::ImplSetTextLineFix( sal_Int32 nLine, const String& rTextLine )
+{
+ if( nLine < GetFirstVisLine() ) return;
+
+ sal_Int32 nChars = rTextLine.Len();
+ if( nChars > GetPosCount() )
+ Execute( CSVCMD_SETPOSCOUNT, nChars );
+
+ sal_uInt32 nLineIx = nLine - GetFirstVisLine();
+ while( maTexts.size() <= nLineIx )
+ maTexts.push_back( StringVec() );
+
+ StringVec& rStrVec = maTexts[ nLineIx ];
+ rStrVec.clear();
+ sal_uInt32 nColCount = GetColumnCount();
+ xub_StrLen nStrLen = rTextLine.Len();
+ xub_StrLen nStrIx = 0;
+ for( sal_uInt32 nColIx = 0; (nColIx < nColCount) && (nStrIx < nStrLen); ++nColIx )
+ {
+ xub_StrLen nColWidth = static_cast< xub_StrLen >( GetColumnWidth( nColIx ) );
+ rStrVec.push_back( rTextLine.Copy( nStrIx, Max( nColWidth, CSV_MAXSTRLEN ) ) );
+ nStrIx = sal::static_int_cast<xub_StrLen>( nStrIx + nColWidth );
+ }
+ InvalidateGfx();
+}
+
+const String& ScCsvGrid::GetCellText( sal_uInt32 nColIndex, sal_Int32 nLine ) const
+{
+ if( nLine < GetFirstVisLine() ) return EMPTY_STRING;
+
+ sal_uInt32 nLineIx = nLine - GetFirstVisLine();
+ if( nLineIx >= maTexts.size() ) return EMPTY_STRING;
+
+ const StringVec& rStrVec = maTexts[ nLineIx ];
+ if( nColIndex >= rStrVec.size() ) return EMPTY_STRING;
+
+ return rStrVec[ nColIndex ];
+}
+
+
+// event handling -------------------------------------------------------------
+
+void ScCsvGrid::Resize()
+{
+ ScCsvControl::Resize();
+ InitSizeData();
+ Execute( CSVCMD_UPDATECELLTEXTS );
+}
+
+void ScCsvGrid::GetFocus()
+{
+ ScCsvControl::GetFocus();
+ Execute( CSVCMD_MOVEGRIDCURSOR, GetNoScrollCol( GetGridCursorPos() ) );
+ Repaint();
+}
+
+void ScCsvGrid::LoseFocus()
+{
+ ScCsvControl::LoseFocus();
+ Repaint();
+}
+
+void ScCsvGrid::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ DisableRepaint();
+ if( !HasFocus() )
+ GrabFocus();
+
+ Point aPos( rMEvt.GetPosPixel() );
+ sal_uInt32 nColIx = GetColumnFromX( aPos.X() );
+
+ if( rMEvt.IsLeft() )
+ {
+ if( (GetFirstX() > aPos.X()) || (aPos.X() > GetLastX()) ) // in header column
+ {
+ if( aPos.Y() <= GetHdrHeight() )
+ SelectAll();
+ }
+ else if( IsValidColumn( nColIx ) )
+ {
+ DoSelectAction( nColIx, rMEvt.GetModifier() );
+ mnMTCurrCol = nColIx;
+ mbMTSelecting = IsSelected( nColIx );
+ StartTracking( STARTTRACK_BUTTONREPEAT );
+ }
+ }
+ EnableRepaint();
+}
+
+void ScCsvGrid::Tracking( const TrackingEvent& rTEvt )
+{
+ if( rTEvt.IsTrackingEnded() || rTEvt.IsTrackingRepeat() )
+ {
+ DisableRepaint();
+ const MouseEvent& rMEvt = rTEvt.GetMouseEvent();
+
+ sal_Int32 nPos = (rMEvt.GetPosPixel().X() - GetFirstX()) / GetCharWidth() + GetFirstVisPos();
+ // on mouse tracking: keep position valid
+ nPos = Max( Min( nPos, GetPosCount() - sal_Int32( 1 ) ), sal_Int32( 0 ) );
+ Execute( CSVCMD_MAKEPOSVISIBLE, nPos );
+
+ sal_uInt32 nColIx = GetColumnFromPos( nPos );
+ if( mnMTCurrCol != nColIx )
+ {
+ DoSelectAction( nColIx, rMEvt.GetModifier() );
+ mnMTCurrCol = nColIx;
+ }
+ EnableRepaint();
+ }
+}
+
+void ScCsvGrid::KeyInput( const KeyEvent& rKEvt )
+{
+ const KeyCode& rKCode = rKEvt.GetKeyCode();
+ sal_uInt16 nCode = rKCode.GetCode();
+ bool bShift = rKCode.IsShift() == TRUE;
+ bool bMod1 = rKCode.IsMod1() == TRUE;
+
+ if( !rKCode.IsMod2() )
+ {
+ ScMoveMode eHDir = GetHorzDirection( nCode, !bMod1 );
+ ScMoveMode eVDir = GetVertDirection( nCode, bMod1 );
+
+ if( eHDir != MOVE_NONE )
+ {
+ DisableRepaint();
+ MoveCursorRel( eHDir );
+ if( !bMod1 )
+ ImplClearSelection();
+ if( bShift )
+ SelectRange( mnRecentSelCol, GetFocusColumn() );
+ else if( !bMod1 )
+ Select( GetFocusColumn() );
+ EnableRepaint();
+ }
+ else if( eVDir != MOVE_NONE )
+ ScrollVertRel( eVDir );
+ else if( nCode == KEY_SPACE )
+ {
+ if( !bMod1 )
+ ImplClearSelection();
+ if( bShift )
+ SelectRange( mnRecentSelCol, GetFocusColumn() );
+ else if( bMod1 )
+ ToggleSelect( GetFocusColumn() );
+ else
+ Select( GetFocusColumn() );
+ }
+ else if( !bShift && bMod1 )
+ {
+ if( nCode == KEY_A )
+ SelectAll();
+ else if( (KEY_1 <= nCode) && (nCode <= KEY_9) )
+ {
+ sal_uInt32 nType = nCode - KEY_1;
+ if( nType < maTypeNames.size() )
+ Execute( CSVCMD_SETCOLUMNTYPE, nType );
+ }
+ }
+ }
+
+ if( rKCode.GetGroup() != KEYGROUP_CURSOR )
+ ScCsvControl::KeyInput( rKEvt );
+}
+
+void ScCsvGrid::Command( const CommandEvent& rCEvt )
+{
+ switch( rCEvt.GetCommand() )
+ {
+ case COMMAND_CONTEXTMENU:
+ {
+ if( rCEvt.IsMouseEvent() )
+ {
+ Point aPos( rCEvt.GetMousePosPixel() );
+ sal_uInt32 nColIx = GetColumnFromX( aPos.X() );
+ if( IsValidColumn( nColIx ) && (GetFirstX() <= aPos.X()) && (aPos.X() <= GetLastX()) )
+ {
+ if( !IsSelected( nColIx ) )
+ DoSelectAction( nColIx, 0 ); // focus & select
+ ExecutePopup( aPos );
+ }
+ }
+ else
+ {
+ sal_uInt32 nColIx = GetFocusColumn();
+ if( !IsSelected( nColIx ) )
+ Select( nColIx );
+ sal_Int32 nX1 = Max( GetColumnX( nColIx ), GetFirstX() );
+ sal_Int32 nX2 = Min( GetColumnX( nColIx + 1 ), GetWidth() );
+ ExecutePopup( Point( (nX1 + nX2) / 2, GetHeight() / 2 ) );
+ }
+ }
+ break;
+ case COMMAND_WHEEL:
+ {
+ Point aPoint;
+ Rectangle aRect( aPoint, maWinSize );
+ if( aRect.IsInside( rCEvt.GetMousePosPixel() ) )
+ {
+ const CommandWheelData* pData = rCEvt.GetWheelData();
+ if( pData && (pData->GetMode() == COMMAND_WHEEL_SCROLL) && !pData->IsHorz() )
+ Execute( CSVCMD_SETLINEOFFSET, GetFirstVisLine() - pData->GetNotchDelta() );
+ }
+ }
+ break;
+ default:
+ ScCsvControl::Command( rCEvt );
+ }
+}
+
+void ScCsvGrid::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ InitColors();
+ InitFonts();
+ UpdateLayoutData();
+ Execute( CSVCMD_UPDATECELLTEXTS );
+ }
+ ScCsvControl::DataChanged( rDCEvt );
+}
+
+void ScCsvGrid::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
+{
+ InitColors();
+ Repaint();
+}
+
+
+// painting -------------------------------------------------------------------
+
+void ScCsvGrid::Paint( const Rectangle& )
+{
+ Repaint();
+}
+
+void ScCsvGrid::ImplRedraw()
+{
+ if( IsVisible() )
+ {
+ if( !IsValidGfx() )
+ {
+ ValidateGfx();
+ ImplDrawBackgrDev();
+ ImplDrawGridDev();
+ }
+ DrawOutDev( Point(), maWinSize, Point(), maWinSize, maGridDev );
+ ImplDrawTrackingRect( GetFocusColumn() );
+ }
+}
+
+EditEngine* ScCsvGrid::GetEditEngine()
+{
+ return mpEditEngine.get();
+}
+
+void ScCsvGrid::ImplSetColumnClipRegion( OutputDevice& rOutDev, sal_uInt32 nColIndex )
+{
+ rOutDev.SetClipRegion( Region( Rectangle(
+ Max( GetColumnX( nColIndex ), GetFirstX() ) + 1, 0,
+ Min( GetColumnX( nColIndex + 1 ), GetLastX() ), GetHeight() - 1 ) ) );
+}
+
+void ScCsvGrid::ImplDrawColumnHeader( OutputDevice& rOutDev, sal_uInt32 nColIndex, Color aFillColor )
+{
+ sal_Int32 nX1 = GetColumnX( nColIndex ) + 1;
+ sal_Int32 nX2 = GetColumnX( nColIndex + 1 );
+ sal_Int32 nHdrHt = GetHdrHeight();
+
+ rOutDev.SetLineColor();
+ rOutDev.SetFillColor( aFillColor );
+ rOutDev.DrawRect( Rectangle( nX1, 0, nX2, nHdrHt ) );
+
+ rOutDev.SetFont( maHeaderFont );
+ rOutDev.SetTextColor( maHeaderTextColor );
+ rOutDev.SetTextFillColor();
+ rOutDev.DrawText( Point( nX1 + 1, 0 ), GetColumnTypeName( nColIndex ) );
+
+ rOutDev.SetLineColor( maHeaderGridColor );
+ rOutDev.DrawLine( Point( nX1, nHdrHt ), Point( nX2, nHdrHt ) );
+ rOutDev.DrawLine( Point( nX2, 0 ), Point( nX2, nHdrHt ) );
+}
+
+void ScCsvGrid::ImplDrawCellText( const Point& rPos, const String& rText )
+{
+ String aPlainText( rText );
+ aPlainText.SearchAndReplaceAll( '\t', ' ' );
+ aPlainText.SearchAndReplaceAll( '\n', ' ' );
+ mpEditEngine->SetPaperSize( maEdEngSize );
+
+ /* #i60296# If string contains mixed script types, the space character
+ U+0020 may be drawn with a wrong width (from non-fixed-width Asian or
+ Complex font). Now we draw every non-space portion separately. */
+ xub_StrLen nTokenCount = aPlainText.GetTokenCount( ' ' );
+ xub_StrLen nCharIx = 0;
+ for( xub_StrLen nToken = 0; nToken < nTokenCount; ++nToken )
+ {
+ xub_StrLen nBeginIx = nCharIx;
+ String aToken = aPlainText.GetToken( 0, ' ', nCharIx );
+ if( aToken.Len() > 0 )
+ {
+ sal_Int32 nX = rPos.X() + GetCharWidth() * nBeginIx;
+ mpEditEngine->SetText( aToken );
+ mpEditEngine->Draw( &maBackgrDev, Point( nX, rPos.Y() ) );
+ }
+ }
+
+ nCharIx = 0;
+ while( (nCharIx = rText.Search( '\t', nCharIx )) != STRING_NOTFOUND )
+ {
+ sal_Int32 nX1 = rPos.X() + GetCharWidth() * nCharIx;
+ sal_Int32 nX2 = nX1 + GetCharWidth() - 2;
+ sal_Int32 nY = rPos.Y() + GetLineHeight() / 2;
+ Color aColor( maTextColor );
+ maBackgrDev.SetLineColor( aColor );
+ maBackgrDev.DrawLine( Point( nX1, nY ), Point( nX2, nY ) );
+ maBackgrDev.DrawLine( Point( nX2 - 2, nY - 2 ), Point( nX2, nY ) );
+ maBackgrDev.DrawLine( Point( nX2 - 2, nY + 2 ), Point( nX2, nY ) );
+ ++nCharIx;
+ }
+ nCharIx = 0;
+ while( (nCharIx = rText.Search( '\n', nCharIx )) != STRING_NOTFOUND )
+ {
+ sal_Int32 nX1 = rPos.X() + GetCharWidth() * nCharIx;
+ sal_Int32 nX2 = nX1 + GetCharWidth() - 2;
+ sal_Int32 nY = rPos.Y() + GetLineHeight() / 2;
+ Color aColor( maTextColor );
+ maBackgrDev.SetLineColor( aColor );
+ maBackgrDev.DrawLine( Point( nX1, nY ), Point( nX2, nY ) );
+ maBackgrDev.DrawLine( Point( nX1 + 2, nY - 2 ), Point( nX1, nY ) );
+ maBackgrDev.DrawLine( Point( nX1 + 2, nY + 2 ), Point( nX1, nY ) );
+ maBackgrDev.DrawLine( Point( nX2, nY - 2 ), Point( nX2, nY ) );
+ ++nCharIx;
+ }
+}
+
+void ScCsvGrid::ImplDrawFirstLineSep( bool bSet )
+{
+ if( IsVisibleLine( mnFirstImpLine ) && (mnFirstImpLine != GetFirstVisLine() ) )
+ {
+ sal_Int32 nY = GetY( mnFirstImpLine );
+ sal_Int32 nX = Min( GetColumnX( GetLastVisColumn() + 1 ), GetLastX() );
+ maBackgrDev.SetLineColor( bSet ? maGridPBColor : maGridColor );
+ maBackgrDev.DrawLine( Point( GetFirstX() + 1, nY ), Point( nX, nY ) );
+ }
+}
+
+void ScCsvGrid::ImplDrawColumnBackgr( sal_uInt32 nColIndex )
+{
+ if( !IsVisibleColumn( nColIndex ) )
+ return;
+
+ ImplSetColumnClipRegion( maBackgrDev, nColIndex );
+
+ // grid
+ maBackgrDev.SetLineColor();
+ maBackgrDev.SetFillColor( maBackColor );
+ sal_Int32 nX1 = GetColumnX( nColIndex ) + 1;
+ sal_Int32 nX2 = GetColumnX( nColIndex + 1 );
+ sal_Int32 nY2 = GetY( GetLastVisLine() + 1 );
+ sal_Int32 nHdrHt = GetHdrHeight();
+ Rectangle aRect( nX1, nHdrHt, nX2, nY2 );
+ maBackgrDev.DrawRect( aRect );
+ maBackgrDev.SetLineColor( maGridColor );
+ maBackgrDev.DrawGrid( aRect, Size( 1, GetLineHeight() ), GRID_HORZLINES );
+ maBackgrDev.DrawLine( Point( nX2, nHdrHt ), Point( nX2, nY2 ) );
+ ImplDrawFirstLineSep( true );
+
+ // cell texts
+ mpEditEngine->SetDefaultItem( SvxColorItem( maTextColor, EE_CHAR_COLOR ) );
+ size_t nLineCount = ::std::min( static_cast< size_t >( GetLastVisLine() - GetFirstVisLine() + 1 ), maTexts.size() );
+ // #i67432# cut string to avoid edit engine performance problems with very large strings
+ sal_Int32 nFirstVisPos = ::std::max( GetColumnPos( nColIndex ), GetFirstVisPos() );
+ sal_Int32 nLastVisPos = ::std::min( GetColumnPos( nColIndex + 1 ), GetLastVisPos() );
+ xub_StrLen nStrPos = static_cast< xub_StrLen >( nFirstVisPos - GetColumnPos( nColIndex ) );
+ xub_StrLen nStrLen = static_cast< xub_StrLen >( nLastVisPos - nFirstVisPos + 1 );
+ sal_Int32 nStrX = GetX( nFirstVisPos );
+ for( size_t nLine = 0; nLine < nLineCount; ++nLine )
+ {
+ StringVec& rStrVec = maTexts[ nLine ];
+ if( (nColIndex < rStrVec.size()) && (rStrVec[ nColIndex ].Len() > nStrPos) )
+ {
+ String aText( rStrVec[ nColIndex ], nStrPos, nStrLen );
+ ImplDrawCellText( Point( nStrX, GetY( GetFirstVisLine() + nLine ) ), aText );
+ }
+ }
+
+ // header
+ ImplDrawColumnHeader( maBackgrDev, nColIndex, maHeaderBackColor );
+
+ maBackgrDev.SetClipRegion();
+}
+
+void ScCsvGrid::ImplDrawRowHeaders()
+{
+ maBackgrDev.SetLineColor();
+ maBackgrDev.SetFillColor( maAppBackColor );
+ Point aPoint( GetHdrX(), 0 );
+ Rectangle aRect( aPoint, Size( GetHdrWidth() + 1, GetHeight() ) );
+ maBackgrDev.DrawRect( aRect );
+
+ maBackgrDev.SetFillColor( maHeaderBackColor );
+ aRect.Bottom() = GetY( GetLastVisLine() + 1 );
+ maBackgrDev.DrawRect( aRect );
+
+ // line numbers
+ maBackgrDev.SetFont( maHeaderFont );
+ maBackgrDev.SetTextColor( maHeaderTextColor );
+ maBackgrDev.SetTextFillColor();
+ sal_Int32 nLastLine = GetLastVisLine();
+ for( sal_Int32 nLine = GetFirstVisLine(); nLine <= nLastLine; ++nLine )
+ {
+ String aText( String::CreateFromInt32( nLine + 1 ) );
+ sal_Int32 nX = GetHdrX() + (GetHdrWidth() - maBackgrDev.GetTextWidth( aText )) / 2;
+ maBackgrDev.DrawText( Point( nX, GetY( nLine ) ), aText );
+ }
+
+ // grid
+ maBackgrDev.SetLineColor( maHeaderGridColor );
+ if( IsRTL() )
+ {
+ maBackgrDev.DrawLine( Point( 0, 0 ), Point( 0, GetHeight() - 1 ) );
+ maBackgrDev.DrawLine( aRect.TopLeft(), aRect.BottomLeft() );
+ }
+ else
+ maBackgrDev.DrawLine( aRect.TopRight(), aRect.BottomRight() );
+ aRect.Top() = GetHdrHeight();
+ maBackgrDev.DrawGrid( aRect, Size( 1, GetLineHeight() ), GRID_HORZLINES );
+}
+
+void ScCsvGrid::ImplDrawBackgrDev()
+{
+ maBackgrDev.SetLineColor();
+ maBackgrDev.SetFillColor( maAppBackColor );
+ maBackgrDev.DrawRect( Rectangle(
+ Point( GetFirstX() + 1, 0 ), Size( GetWidth() - GetHdrWidth(), GetHeight() ) ) );
+
+ sal_uInt32 nLastCol = GetLastVisColumn();
+ for( sal_uInt32 nColIx = GetFirstVisColumn(); nColIx <= nLastCol; ++nColIx )
+ ImplDrawColumnBackgr( nColIx );
+
+ ImplDrawRowHeaders();
+}
+
+void ScCsvGrid::ImplDrawColumnSelection( sal_uInt32 nColIndex )
+{
+ ImplInvertCursor( GetRulerCursorPos() );
+ ImplSetColumnClipRegion( maGridDev, nColIndex );
+ maGridDev.DrawOutDev( Point(), maWinSize, Point(), maWinSize, maBackgrDev );
+
+ if( IsSelected( nColIndex ) )
+ {
+ sal_Int32 nX1 = GetColumnX( nColIndex ) + 1;
+ sal_Int32 nX2 = GetColumnX( nColIndex + 1 );
+
+ // header
+ Rectangle aRect( nX1, 0, nX2, GetHdrHeight() );
+ maGridDev.SetLineColor();
+ if( maHeaderBackColor.IsDark() )
+ // redraw with light gray background in dark mode
+ ImplDrawColumnHeader( maGridDev, nColIndex, COL_LIGHTGRAY );
+ else
+ {
+ // use transparent active color
+ maGridDev.SetFillColor( maSelectColor );
+ maGridDev.DrawTransparent( PolyPolygon( Polygon( aRect ) ), CSV_HDR_TRANSPARENCY );
+ }
+
+ // column selection
+ aRect = Rectangle( nX1, GetHdrHeight() + 1, nX2, GetY( GetLastVisLine() + 1 ) - 1 );
+ ImplInvertRect( maGridDev, aRect );
+ }
+
+ maGridDev.SetClipRegion();
+ ImplInvertCursor( GetRulerCursorPos() );
+}
+
+void ScCsvGrid::ImplDrawGridDev()
+{
+ maGridDev.DrawOutDev( Point(), maWinSize, Point(), maWinSize, maBackgrDev );
+ sal_uInt32 nLastCol = GetLastVisColumn();
+ for( sal_uInt32 nColIx = GetFirstVisColumn(); nColIx <= nLastCol; ++nColIx )
+ ImplDrawColumnSelection( nColIx );
+}
+
+void ScCsvGrid::ImplDrawColumn( sal_uInt32 nColIndex )
+{
+ ImplDrawColumnBackgr( nColIndex );
+ ImplDrawColumnSelection( nColIndex );
+}
+
+void ScCsvGrid::ImplDrawHorzScrolled( sal_Int32 nOldPos )
+{
+ sal_Int32 nPos = GetFirstVisPos();
+ if( !IsValidGfx() || (nPos == nOldPos) )
+ return;
+ if( Abs( nPos - nOldPos ) > GetVisPosCount() / 2 )
+ {
+ ImplDrawBackgrDev();
+ ImplDrawGridDev();
+ return;
+ }
+
+ Point aSrc, aDest;
+ sal_uInt32 nFirstColIx, nLastColIx;
+ if( nPos < nOldPos )
+ {
+ aSrc = Point( GetFirstX() + 1, 0 );
+ aDest = Point( GetFirstX() + GetCharWidth() * (nOldPos - nPos) + 1, 0 );
+ nFirstColIx = GetColumnFromPos( nPos );
+ nLastColIx = GetColumnFromPos( nOldPos );
+ }
+ else
+ {
+ aSrc = Point( GetFirstX() + GetCharWidth() * (nPos - nOldPos) + 1, 0 );
+ aDest = Point( GetFirstX() + 1, 0 );
+ nFirstColIx = GetColumnFromPos( Min( nOldPos + GetVisPosCount(), GetPosCount() ) - 1 );
+ nLastColIx = GetColumnFromPos( Min( nPos + GetVisPosCount(), GetPosCount() ) - 1 );
+ }
+
+ ImplInvertCursor( GetRulerCursorPos() + (nPos - nOldPos) );
+ Rectangle aRectangle( GetFirstX(), 0, GetLastX(), GetHeight() - 1 );
+ Region aClipReg( aRectangle );
+ maBackgrDev.SetClipRegion( aClipReg );
+ maBackgrDev.CopyArea( aDest, aSrc, maWinSize );
+ maBackgrDev.SetClipRegion();
+ maGridDev.SetClipRegion( aClipReg );
+ maGridDev.CopyArea( aDest, aSrc, maWinSize );
+ maGridDev.SetClipRegion();
+ ImplInvertCursor( GetRulerCursorPos() );
+
+ for( sal_uInt32 nColIx = nFirstColIx; nColIx <= nLastColIx; ++nColIx )
+ ImplDrawColumn( nColIx );
+
+ sal_Int32 nLastX = GetX( GetPosCount() ) + 1;
+ if( nLastX <= GetLastX() )
+ {
+ Rectangle aRect( nLastX, 0, GetLastX(), GetHeight() - 1 );
+ maBackgrDev.SetLineColor();
+ maBackgrDev.SetFillColor( maAppBackColor );
+ maBackgrDev.DrawRect( aRect );
+ maGridDev.SetLineColor();
+ maGridDev.SetFillColor( maAppBackColor );
+ maGridDev.DrawRect( aRect );
+ }
+}
+
+void ScCsvGrid::ImplInvertCursor( sal_Int32 nPos )
+{
+ if( IsVisibleSplitPos( nPos ) )
+ {
+ sal_Int32 nX = GetX( nPos ) - 1;
+ Rectangle aRect( Point( nX, 0 ), Size( 3, GetHdrHeight() ) );
+ ImplInvertRect( maGridDev, aRect );
+ aRect.Top() = GetHdrHeight() + 1;
+ aRect.Bottom() = GetY( GetLastVisLine() + 1 );
+ ImplInvertRect( maGridDev, aRect );
+ }
+}
+
+void ScCsvGrid::ImplDrawTrackingRect( sal_uInt32 nColIndex )
+{
+ if( HasFocus() && IsVisibleColumn( nColIndex ) )
+ {
+ sal_Int32 nX1 = Max( GetColumnX( nColIndex ), GetFirstX() ) + 1;
+ sal_Int32 nX2 = Min( GetColumnX( nColIndex + 1 ) - sal_Int32( 1 ), GetLastX() );
+ sal_Int32 nY2 = Min( GetY( GetLastVisLine() + 1 ), GetHeight() ) - 1;
+ InvertTracking( Rectangle( nX1, 0, nX2, nY2 ), SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
+ }
+}
+
+
+// accessibility ==============================================================
+
+ScAccessibleCsvControl* ScCsvGrid::ImplCreateAccessible()
+{
+ return new ScAccessibleCsvGrid( *this );
+}
+
+
+// ============================================================================
+
diff --git a/sc/source/ui/dbgui/csvruler.cxx b/sc/source/ui/dbgui/csvruler.cxx
new file mode 100644
index 000000000000..56aa2a50a835
--- /dev/null
+++ b/sc/source/ui/dbgui/csvruler.cxx
@@ -0,0 +1,682 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+// ============================================================================
+#include "csvruler.hxx"
+#include "AccessibleCsvControl.hxx"
+
+
+#include <optutil.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include "miscuno.hxx"
+
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+
+
+// ============================================================================
+#define SEP_PATH "Office.Calc/Dialogs/CSVImport"
+#define FIXED_WIDTH_LIST "FixedWidthList"
+
+
+// ============================================================================
+
+static void load_FixedWidthList(ScCsvSplits &aSplits)
+{
+ String sSplits;
+ OUString sFixedWidthLists;
+
+ Sequence<Any>aValues;
+ const Any *pProperties;
+ Sequence<OUString> aNames(1);
+ OUString* pNames = aNames.getArray();
+ ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
+
+ pNames[0] = OUString::createFromAscii( FIXED_WIDTH_LIST );
+ aValues = aItem.GetProperties( aNames );
+ pProperties = aValues.getConstArray();
+
+ if( pProperties[0].hasValue() )
+ {
+ aSplits.Clear();
+ pProperties[0] >>= sFixedWidthLists;
+
+ sSplits = String( sFixedWidthLists );
+
+ // String ends with a semi-colon so there is no 'int' after the last one.
+ xub_StrLen n = sSplits.GetTokenCount() - 1;
+ for (xub_StrLen i = 0; i < n; ++i)
+ aSplits.Insert( sSplits.GetToken(i).ToInt32() );
+ }
+}
+static void save_FixedWidthList(ScCsvSplits aSplits)
+{
+ String sSplits;
+ // Create a semi-colon separated string to save the splits
+ sal_uInt32 n = aSplits.Count();
+ for (sal_uInt32 i = 0; i < n; ++i)
+ {
+ sSplits.Append( String::CreateFromInt32( aSplits[i] ) );
+ sSplits.Append((char)';');
+ }
+
+ OUString sFixedWidthLists = OUString( sSplits );
+ Sequence<Any> aValues;
+ Any *pProperties;
+ Sequence<OUString> aNames(1);
+ OUString* pNames = aNames.getArray();
+ ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
+
+ pNames[0] = OUString::createFromAscii( FIXED_WIDTH_LIST );
+ aValues = aItem.GetProperties( aNames );
+ pProperties = aValues.getArray();
+ pProperties[0] <<= sFixedWidthLists;
+
+ aItem.PutProperties(aNames, aValues);
+}
+
+ScCsvRuler::ScCsvRuler( ScCsvControl& rParent ) :
+ ScCsvControl( rParent ),
+ mnPosCursorLast( 1 )
+{
+ EnableRTL( false ); // #107812# RTL
+ InitColors();
+ InitSizeData();
+ maBackgrDev.SetFont( GetFont() );
+ maRulerDev.SetFont( GetFont() );
+
+ load_FixedWidthList( maSplits );
+}
+
+ScCsvRuler::~ScCsvRuler()
+{
+ save_FixedWidthList( maSplits );
+}
+
+
+// common ruler handling ------------------------------------------------------
+
+void ScCsvRuler::SetPosSizePixel(
+ long nX, long nY, long nWidth, long nHeight, USHORT nFlags )
+{
+ if( nFlags & WINDOW_POSSIZE_HEIGHT )
+ nHeight = GetTextHeight() + mnSplitSize + 2;
+ ScCsvControl::SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
+}
+
+void ScCsvRuler::ApplyLayout( const ScCsvLayoutData& rOldData )
+{
+ ScCsvDiff nDiff = GetLayoutData().GetDiff( rOldData ) & (CSV_DIFF_HORIZONTAL | CSV_DIFF_RULERCURSOR);
+ if( nDiff == CSV_DIFF_EQUAL ) return;
+
+ DisableRepaint();
+ if( nDiff & CSV_DIFF_HORIZONTAL )
+ {
+ InitSizeData();
+ if( GetRulerCursorPos() >= GetPosCount() )
+ MoveCursor( GetPosCount() - 1 );
+ }
+ if( nDiff & CSV_DIFF_RULERCURSOR )
+ {
+ ImplInvertCursor( rOldData.mnPosCursor );
+ ImplInvertCursor( GetRulerCursorPos() );
+ }
+ EnableRepaint();
+
+ if( nDiff & CSV_DIFF_POSOFFSET )
+ AccSendVisibleEvent();
+}
+
+void ScCsvRuler::InitColors()
+{
+ const StyleSettings& rSett = GetSettings().GetStyleSettings();
+ maBackColor = rSett.GetFaceColor();
+ maActiveColor = rSett.GetWindowColor();
+ maTextColor = rSett.GetLabelTextColor();
+ maSplitColor = maBackColor.IsDark() ? maTextColor : Color( COL_LIGHTRED );
+ InvalidateGfx();
+}
+
+void ScCsvRuler::InitSizeData()
+{
+ maWinSize = GetSizePixel();
+
+ mnSplitSize = (GetCharWidth() * 3 / 5) | 1; // make an odd number
+
+ sal_Int32 nActiveWidth = Min( GetWidth() - GetHdrWidth(), GetPosCount() * GetCharWidth() );
+ sal_Int32 nActiveHeight = GetTextHeight();
+
+ maActiveRect.SetPos( Point( GetFirstX(), (GetHeight() - nActiveHeight - 1) / 2 ) );
+ maActiveRect.SetSize( Size( nActiveWidth, nActiveHeight ) );
+
+ maBackgrDev.SetOutputSizePixel( maWinSize );
+ maRulerDev.SetOutputSizePixel( maWinSize );
+
+ InvalidateGfx();
+}
+
+void ScCsvRuler::MoveCursor( sal_Int32 nPos, bool bScroll )
+{
+ DisableRepaint();
+ if( bScroll )
+ Execute( CSVCMD_MAKEPOSVISIBLE, nPos );
+ Execute( CSVCMD_MOVERULERCURSOR, IsVisibleSplitPos( nPos ) ? nPos : CSV_POS_INVALID );
+ EnableRepaint();
+ AccSendCaretEvent();
+}
+
+void ScCsvRuler::MoveCursorRel( ScMoveMode eDir )
+{
+ if( GetRulerCursorPos() != CSV_POS_INVALID )
+ {
+ switch( eDir )
+ {
+ case MOVE_FIRST:
+ MoveCursor( 1 );
+ break;
+ case MOVE_LAST:
+ MoveCursor( GetPosCount() - 1 );
+ break;
+ case MOVE_PREV:
+ if( GetRulerCursorPos() > 1 )
+ MoveCursor( GetRulerCursorPos() - 1 );
+ break;
+ case MOVE_NEXT:
+ if( GetRulerCursorPos() < GetPosCount() - 1 )
+ MoveCursor( GetRulerCursorPos() + 1 );
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+}
+
+void ScCsvRuler::MoveCursorToSplit( ScMoveMode eDir )
+{
+ if( GetRulerCursorPos() != CSV_POS_INVALID )
+ {
+ sal_uInt32 nIndex = CSV_VEC_NOTFOUND;
+ switch( eDir )
+ {
+ case MOVE_FIRST: nIndex = maSplits.LowerBound( 0 ); break;
+ case MOVE_LAST: nIndex = maSplits.UpperBound( GetPosCount() ); break;
+ case MOVE_PREV: nIndex = maSplits.UpperBound( GetRulerCursorPos() - 1 ); break;
+ case MOVE_NEXT: nIndex = maSplits.LowerBound( GetRulerCursorPos() + 1 ); break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ sal_Int32 nPos = maSplits[ nIndex ];
+ if( nPos != CSV_POS_INVALID )
+ MoveCursor( nPos );
+ }
+}
+
+void ScCsvRuler::ScrollVertRel( ScMoveMode eDir )
+{
+ sal_Int32 nLine = GetFirstVisLine();
+ switch( eDir )
+ {
+ case MOVE_PREV: --nLine; break;
+ case MOVE_NEXT: ++nLine; break;
+ case MOVE_PREVPAGE: nLine -= GetVisLineCount() - 1; break;
+ case MOVE_NEXTPAGE: nLine += GetVisLineCount() - 1; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ Execute( CSVCMD_SETLINEOFFSET, nLine );
+}
+
+
+// split handling -------------------------------------------------------------
+
+sal_Int32 ScCsvRuler::GetNoScrollPos( sal_Int32 nPos ) const
+{
+ sal_Int32 nNewPos = nPos;
+ if( nNewPos != CSV_POS_INVALID )
+ {
+ if( nNewPos < GetFirstVisPos() + CSV_SCROLL_DIST )
+ {
+ sal_Int32 nScroll = (GetFirstVisPos() > 0) ? CSV_SCROLL_DIST : 0;
+ nNewPos = Max( nPos, GetFirstVisPos() + nScroll );
+ }
+ else if( nNewPos > GetLastVisPos() - CSV_SCROLL_DIST - 1L )
+ {
+ sal_Int32 nScroll = (GetFirstVisPos() < GetMaxPosOffset()) ? CSV_SCROLL_DIST : 0;
+ nNewPos = Min( nNewPos, GetLastVisPos() - nScroll - sal_Int32( 1 ) );
+ }
+ }
+ return nNewPos;
+}
+
+void ScCsvRuler::InsertSplit( sal_Int32 nPos )
+{
+ if( maSplits.Insert( nPos ) )
+ {
+ ImplDrawSplit( nPos );
+ Repaint();
+ }
+}
+
+void ScCsvRuler::RemoveSplit( sal_Int32 nPos )
+{
+ if( maSplits.Remove( nPos ) )
+ {
+ ImplEraseSplit( nPos );
+ Repaint();
+ }
+}
+
+void ScCsvRuler::MoveSplit( sal_Int32 nPos, sal_Int32 nNewPos )
+{
+ bool bRemove = maSplits.Remove( nPos );
+ bool bInsert = maSplits.Insert( nNewPos );
+ if( bRemove || bInsert )
+ {
+ ImplEraseSplit( nPos );
+ ImplDrawSplit( nNewPos );
+ Repaint();
+ }
+}
+
+void ScCsvRuler::RemoveAllSplits()
+{
+ maSplits.Clear();
+ Repaint( true );
+}
+
+sal_Int32 ScCsvRuler::FindEmptyPos( sal_Int32 nPos, ScMoveMode eDir ) const
+{
+ sal_Int32 nNewPos = nPos;
+ if( nNewPos != CSV_POS_INVALID )
+ {
+ switch( eDir )
+ {
+ case MOVE_FIRST:
+ nNewPos = Min( nPos, FindEmptyPos( 0, MOVE_NEXT ) );
+ break;
+ case MOVE_LAST:
+ nNewPos = Max( nPos, FindEmptyPos( GetPosCount(), MOVE_PREV ) );
+ break;
+ case MOVE_PREV:
+ while( HasSplit( --nNewPos ) ) ;
+ break;
+ case MOVE_NEXT:
+ while( HasSplit( ++nNewPos ) ) ;
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+ return IsValidSplitPos( nNewPos ) ? nNewPos : CSV_POS_INVALID;
+}
+
+void ScCsvRuler::MoveCurrSplit( sal_Int32 nNewPos )
+{
+ DisableRepaint();
+ Execute( CSVCMD_MOVESPLIT, GetRulerCursorPos(), nNewPos );
+ MoveCursor( nNewPos );
+ EnableRepaint();
+}
+
+void ScCsvRuler::MoveCurrSplitRel( ScMoveMode eDir )
+{
+ if( HasSplit( GetRulerCursorPos() ) )
+ {
+ sal_Int32 nNewPos = FindEmptyPos( GetRulerCursorPos(), eDir );
+ if( nNewPos != CSV_POS_INVALID )
+ MoveCurrSplit( nNewPos );
+ }
+}
+
+
+// event handling -------------------------------------------------------------
+
+void ScCsvRuler::Resize()
+{
+ ScCsvControl::Resize();
+ InitSizeData();
+ Repaint();
+}
+
+void ScCsvRuler::GetFocus()
+{
+ ScCsvControl::GetFocus();
+ DisableRepaint();
+ if( GetRulerCursorPos() == CSV_POS_INVALID )
+ MoveCursor( GetNoScrollPos( mnPosCursorLast ) );
+ EnableRepaint();
+}
+
+void ScCsvRuler::LoseFocus()
+{
+ ScCsvControl::LoseFocus();
+ mnPosCursorLast = GetRulerCursorPos();
+ MoveCursor( CSV_POS_INVALID );
+}
+
+void ScCsvRuler::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ InitColors();
+ Repaint();
+ }
+ ScCsvControl::DataChanged( rDCEvt );
+}
+
+void ScCsvRuler::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ DisableRepaint();
+ if( !HasFocus() )
+ GrabFocus();
+ if( rMEvt.IsLeft() )
+ {
+ sal_Int32 nPos = GetPosFromX( rMEvt.GetPosPixel().X() );
+ if( IsVisibleSplitPos( nPos ) )
+ StartMouseTracking( nPos );
+ ImplSetMousePointer( nPos );
+ }
+ EnableRepaint();
+}
+
+void ScCsvRuler::MouseMove( const MouseEvent& rMEvt )
+{
+ if( !rMEvt.IsModifierChanged() )
+ {
+ sal_Int32 nPos = GetPosFromX( rMEvt.GetPosPixel().X() );
+ if( IsTracking() )
+ {
+ // on mouse tracking: keep position valid
+ nPos = Max( Min( nPos, GetPosCount() - sal_Int32( 1 ) ), sal_Int32( 1 ) );
+ MoveMouseTracking( nPos );
+ }
+ else
+ {
+ Point aPoint;
+ Rectangle aRect( aPoint, maWinSize );
+ if( !IsVisibleSplitPos( nPos ) || !aRect.IsInside( rMEvt.GetPosPixel() ) )
+ // if focused, keep old cursor position for key input
+ nPos = HasFocus() ? GetRulerCursorPos() : CSV_POS_INVALID;
+ MoveCursor( nPos, false );
+ }
+ ImplSetMousePointer( nPos );
+ }
+}
+
+void ScCsvRuler::Tracking( const TrackingEvent& rTEvt )
+{
+ if( rTEvt.IsTrackingEnded() || rTEvt.IsTrackingRepeat() )
+ MouseMove( rTEvt.GetMouseEvent() );
+ if( rTEvt.IsTrackingEnded() )
+ EndMouseTracking( !rTEvt.IsTrackingCanceled() );
+}
+
+void ScCsvRuler::KeyInput( const KeyEvent& rKEvt )
+{
+ const KeyCode& rKCode = rKEvt.GetKeyCode();
+ sal_uInt16 nCode = rKCode.GetCode();
+ bool bNoMod = !rKCode.GetModifier();
+ bool bShift = (rKCode.GetModifier() == KEY_SHIFT);
+ bool bJump = (rKCode.GetModifier() == KEY_MOD1);
+ bool bMove = (rKCode.GetModifier() == (KEY_MOD1 | KEY_SHIFT));
+
+ ScMoveMode eHDir = GetHorzDirection( nCode, true );
+ ScMoveMode eVDir = GetVertDirection( nCode, false );
+
+ if( bNoMod )
+ {
+ if( eHDir != MOVE_NONE )
+ MoveCursorRel( eHDir );
+ else if( eVDir != MOVE_NONE )
+ ScrollVertRel( eVDir );
+ else switch( nCode )
+ {
+ case KEY_SPACE: Execute( CSVCMD_TOGGLESPLIT, GetRulerCursorPos() ); break;
+ case KEY_INSERT: Execute( CSVCMD_INSERTSPLIT, GetRulerCursorPos() ); break;
+ case KEY_DELETE: Execute( CSVCMD_REMOVESPLIT, GetRulerCursorPos() ); break;
+ }
+ }
+ else if( bJump && (eHDir != MOVE_NONE) )
+ MoveCursorToSplit( eHDir );
+ else if( bMove && (eHDir != MOVE_NONE) )
+ MoveCurrSplitRel( eHDir );
+ else if( bShift && (nCode == KEY_DELETE) )
+ Execute( CSVCMD_REMOVEALLSPLITS );
+
+ if( rKCode.GetGroup() != KEYGROUP_CURSOR )
+ ScCsvControl::KeyInput( rKEvt );
+}
+
+void ScCsvRuler::StartMouseTracking( sal_Int32 nPos )
+{
+ mnPosMTStart = mnPosMTCurr = nPos;
+ mbPosMTMoved = false;
+ maOldSplits = maSplits;
+ Execute( CSVCMD_INSERTSPLIT, nPos );
+ if( HasSplit( nPos ) )
+ StartTracking( STARTTRACK_BUTTONREPEAT );
+}
+
+void ScCsvRuler::MoveMouseTracking( sal_Int32 nPos )
+{
+ if( mnPosMTCurr != nPos )
+ {
+ DisableRepaint();
+ MoveCursor( nPos );
+ if( (mnPosMTCurr != mnPosMTStart) && maOldSplits.HasSplit( mnPosMTCurr ) )
+ Execute( CSVCMD_INSERTSPLIT, nPos );
+ else
+ Execute( CSVCMD_MOVESPLIT, mnPosMTCurr, nPos );
+ mnPosMTCurr = nPos;
+ mbPosMTMoved = true;
+ EnableRepaint();
+ }
+}
+
+void ScCsvRuler::EndMouseTracking( bool bApply )
+{
+ if( bApply ) // tracking finished successfully
+ {
+ // remove on simple click on an existing split
+ if( (mnPosMTCurr == mnPosMTStart) && maOldSplits.HasSplit( mnPosMTCurr ) && !mbPosMTMoved )
+ Execute( CSVCMD_REMOVESPLIT, mnPosMTCurr );
+ }
+ else // tracking cancelled
+ {
+ MoveCursor( mnPosMTStart );
+ // move split to origin
+ if( maOldSplits.HasSplit( mnPosMTStart ) )
+ MoveMouseTracking( mnPosMTStart );
+ // remove temporarily inserted split
+ else if( !maOldSplits.HasSplit( mnPosMTCurr ) )
+ Execute( CSVCMD_REMOVESPLIT, mnPosMTCurr );
+ }
+ mnPosMTStart = CSV_POS_INVALID;
+}
+
+
+// painting -------------------------------------------------------------------
+
+void ScCsvRuler::Paint( const Rectangle& )
+{
+ Repaint();
+}
+
+void ScCsvRuler::ImplRedraw()
+{
+ if( IsVisible() )
+ {
+ if( !IsValidGfx() )
+ {
+ ValidateGfx();
+ ImplDrawBackgrDev();
+ ImplDrawRulerDev();
+ }
+ DrawOutDev( Point(), maWinSize, Point(), maWinSize, maRulerDev );
+ ImplDrawTrackingRect();
+ }
+}
+
+void ScCsvRuler::ImplDrawArea( sal_Int32 nPosX, sal_Int32 nWidth )
+{
+ maBackgrDev.SetLineColor();
+ Rectangle aRect( Point( nPosX, 0 ), Size( nWidth, GetHeight() ) );
+ maBackgrDev.SetFillColor( maBackColor );
+ maBackgrDev.DrawRect( aRect );
+
+ aRect = maActiveRect;
+ aRect.Left() = Max( GetFirstX(), nPosX );
+ aRect.Right() = Min( Min( GetX( GetPosCount() ), GetLastX() ), nPosX + nWidth - sal_Int32( 1 ) );
+ if( aRect.Left() <= aRect.Right() )
+ {
+ maBackgrDev.SetFillColor( maActiveColor );
+ maBackgrDev.DrawRect( aRect );
+ }
+
+ maBackgrDev.SetLineColor( maTextColor );
+ sal_Int32 nY = GetHeight() - 1;
+ maBackgrDev.DrawLine( Point( nPosX, nY ), Point( nPosX + nWidth - 1, nY ) );
+}
+
+void ScCsvRuler::ImplDrawBackgrDev()
+{
+ ImplDrawArea( 0, GetWidth() );
+
+ // scale
+ maBackgrDev.SetLineColor( maTextColor );
+ maBackgrDev.SetFillColor();
+ sal_Int32 nPos;
+
+ sal_Int32 nFirstPos = Max( GetPosFromX( 0 ) - (sal_Int32)(1L), (sal_Int32)(0L) );
+ sal_Int32 nLastPos = GetPosFromX( GetWidth() );
+ sal_Int32 nY = (maActiveRect.Top() + maActiveRect.Bottom()) / 2;
+ for( nPos = nFirstPos; nPos <= nLastPos; ++nPos )
+ {
+ sal_Int32 nX = GetX( nPos );
+ if( nPos % 5 )
+ maBackgrDev.DrawPixel( Point( nX, nY ) );
+ else
+ maBackgrDev.DrawLine( Point( nX, nY - 1 ), Point( nX, nY + 1 ) );
+ }
+
+ // texts
+ maBackgrDev.SetTextColor( maTextColor );
+ maBackgrDev.SetTextFillColor();
+ for( nPos = ((nFirstPos + 9) / 10) * 10; nPos <= nLastPos; nPos += 10 )
+ {
+ String aText( String::CreateFromInt32( nPos ) );
+ sal_Int32 nTextWidth = maBackgrDev.GetTextWidth( aText );
+ sal_Int32 nTextX = GetX( nPos ) - nTextWidth / 2;
+ ImplDrawArea( nTextX - 1, nTextWidth + 2 );
+ maBackgrDev.DrawText( Point( nTextX, maActiveRect.Top() ), aText );
+ }
+}
+
+void ScCsvRuler::ImplDrawSplit( sal_Int32 nPos )
+{
+ if( IsVisibleSplitPos( nPos ) )
+ {
+ Point aPos( GetX( nPos ) - mnSplitSize / 2, GetHeight() - mnSplitSize - 2 );
+ Size aSize( mnSplitSize, mnSplitSize );
+ maRulerDev.SetLineColor( maTextColor );
+ maRulerDev.SetFillColor( maSplitColor );
+ maRulerDev.DrawEllipse( Rectangle( aPos, aSize ) );
+ maRulerDev.DrawPixel( Point( GetX( nPos ), GetHeight() - 2 ) );
+ }
+}
+
+void ScCsvRuler::ImplEraseSplit( sal_Int32 nPos )
+{
+ if( IsVisibleSplitPos( nPos ) )
+ {
+ ImplInvertCursor( GetRulerCursorPos() );
+ Point aPos( GetX( nPos ) - mnSplitSize / 2, 0 );
+ Size aSize( mnSplitSize, GetHeight() );
+ maRulerDev.DrawOutDev( aPos, aSize, aPos, aSize, maBackgrDev );
+ ImplInvertCursor( GetRulerCursorPos() );
+ }
+}
+
+void ScCsvRuler::ImplDrawRulerDev()
+{
+ maRulerDev.DrawOutDev( Point(), maWinSize, Point(), maWinSize, maBackgrDev );
+ ImplInvertCursor( GetRulerCursorPos() );
+
+ sal_uInt32 nFirst = maSplits.LowerBound( GetFirstVisPos() );
+ sal_uInt32 nLast = maSplits.UpperBound( GetLastVisPos() );
+ if( (nFirst != CSV_VEC_NOTFOUND) && (nLast != CSV_VEC_NOTFOUND) )
+ for( sal_uInt32 nIndex = nFirst; nIndex <= nLast; ++nIndex )
+ ImplDrawSplit( GetSplitPos( nIndex ) );
+}
+
+void ScCsvRuler::ImplInvertCursor( sal_Int32 nPos )
+{
+ if( IsVisibleSplitPos( nPos ) )
+ {
+ ImplInvertRect( maRulerDev, Rectangle( Point( GetX( nPos ) - 1, 0 ), Size( 3, GetHeight() - 1 ) ) );
+ if( HasSplit( nPos ) )
+ ImplDrawSplit( nPos );
+ }
+}
+
+void ScCsvRuler::ImplDrawTrackingRect()
+{
+ if( HasFocus() )
+ InvertTracking( Rectangle( 0, 0, GetWidth() - 1, GetHeight() - 2 ),
+ SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
+}
+
+void ScCsvRuler::ImplSetMousePointer( sal_Int32 nPos )
+{
+ SetPointer( Pointer( HasSplit( nPos ) ? POINTER_HSPLIT : POINTER_ARROW ) );
+}
+
+
+// accessibility ==============================================================
+
+ScAccessibleCsvControl* ScCsvRuler::ImplCreateAccessible()
+{
+ return new ScAccessibleCsvRuler( *this );
+}
+
+
+// ============================================================================
+
diff --git a/sc/source/ui/dbgui/csvsplits.cxx b/sc/source/ui/dbgui/csvsplits.cxx
new file mode 100644
index 000000000000..b93bb09b5151
--- /dev/null
+++ b/sc/source/ui/dbgui/csvsplits.cxx
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+// ============================================================================
+#include "csvsplits.hxx"
+#include <tools/debug.hxx>
+
+#include <algorithm>
+
+
+// ============================================================================
+
+bool ScCsvSplits::Insert( sal_Int32 nPos )
+{
+ bool bValid = (nPos >= 0);
+ if( bValid )
+ {
+ iterator aIter = ::std::lower_bound( maVec.begin(), maVec.end(), nPos );
+ bValid = (aIter == maVec.end()) || (*aIter != nPos);
+ if( bValid )
+ aIter = maVec.insert( aIter, nPos );
+ }
+ return bValid;
+}
+
+bool ScCsvSplits::Remove( sal_Int32 nPos )
+{
+ sal_uInt32 nIndex = GetIndex( nPos );
+ bool bValid = (nIndex != CSV_VEC_NOTFOUND);
+ if( bValid )
+ maVec.erase( maVec.begin() + nIndex );
+ return bValid;
+}
+
+void ScCsvSplits::RemoveRange( sal_Int32 nPosStart, sal_Int32 nPosEnd )
+{
+ sal_uInt32 nStartIx = LowerBound( nPosStart );
+ sal_uInt32 nEndIx = UpperBound( nPosEnd );
+ if( (nStartIx != CSV_VEC_NOTFOUND) && (nEndIx != CSV_VEC_NOTFOUND) && (nStartIx <= nEndIx) )
+ maVec.erase( maVec.begin() + nStartIx, maVec.begin() + nEndIx + 1 );
+}
+
+void ScCsvSplits::Clear()
+{
+ maVec.clear();
+}
+
+bool ScCsvSplits::HasSplit( sal_Int32 nPos ) const
+{
+ return GetIndex( nPos ) != CSV_VEC_NOTFOUND;
+}
+
+
+// ----------------------------------------------------------------------------
+
+sal_uInt32 ScCsvSplits::GetIndex( sal_Int32 nPos ) const
+{
+ const_iterator aIter = ::std::lower_bound( maVec.begin(), maVec.end(), nPos );
+ return GetIterIndex( ((aIter != maVec.end()) && (*aIter == nPos)) ? aIter : maVec.end() );
+}
+
+sal_uInt32 ScCsvSplits::LowerBound( sal_Int32 nPos ) const
+{
+ return GetIterIndex( ::std::lower_bound( maVec.begin(), maVec.end(), nPos ) );
+}
+
+sal_uInt32 ScCsvSplits::UpperBound( sal_Int32 nPos ) const
+{
+ sal_uInt32 nIndex = LowerBound( nPos );
+ if( nIndex == CSV_VEC_NOTFOUND )
+ return Count() ? (Count() - 1) : CSV_VEC_NOTFOUND;
+ if( GetPos( nIndex ) == nPos )
+ return nIndex;
+ return nIndex ? (nIndex - 1) : CSV_VEC_NOTFOUND;
+}
+
+sal_Int32 ScCsvSplits::GetPos( sal_uInt32 nIndex ) const
+{
+ return (nIndex < Count()) ? maVec[ nIndex ] : CSV_POS_INVALID;
+}
+
+
+// ----------------------------------------------------------------------------
+
+sal_uInt32 ScCsvSplits::GetIterIndex( const_iterator aIter ) const
+{
+ return (aIter == maVec.end()) ? CSV_VEC_NOTFOUND : (aIter - maVec.begin());
+}
+
+
+// ============================================================================
+
diff --git a/sc/source/ui/dbgui/csvtablebox.cxx b/sc/source/ui/dbgui/csvtablebox.cxx
new file mode 100644
index 000000000000..842f1cc81dea
--- /dev/null
+++ b/sc/source/ui/dbgui/csvtablebox.cxx
@@ -0,0 +1,464 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+// ============================================================================
+#include "csvtablebox.hxx"
+#include <tools/debug.hxx>
+#include <vcl/lstbox.hxx>
+
+// ause
+#include "editutil.hxx"
+
+// ============================================================================
+
+//UNUSED2009-05 ScCsvTableBox::ScCsvTableBox( Window* pParent ) :
+//UNUSED2009-05 ScCsvControl( pParent, maData, WB_BORDER | WB_TABSTOP | WB_DIALOGCONTROL ),
+//UNUSED2009-05 maRuler( *this ),
+//UNUSED2009-05 maGrid( *this ),
+//UNUSED2009-05 maHScroll( this, WB_HORZ | WB_DRAG ),
+//UNUSED2009-05 maVScroll( this, WB_VERT | WB_DRAG ),
+//UNUSED2009-05 maScrollBox( this )
+//UNUSED2009-05 {
+//UNUSED2009-05 Init();
+//UNUSED2009-05 }
+
+ScCsvTableBox::ScCsvTableBox( Window* pParent, const ResId& rResId ) :
+ ScCsvControl( pParent, maData, rResId ),
+ maRuler( *this ),
+ maGrid( *this ),
+ maHScroll( this, WB_HORZ | WB_DRAG ),
+ maVScroll( this, WB_VERT | WB_DRAG ),
+ maScrollBox( this )
+{
+ Init();
+}
+
+
+// common table box handling --------------------------------------------------
+
+void ScCsvTableBox::SetSeparatorsMode()
+{
+ if( mbFixedMode )
+ {
+ // rescue data for fixed width mode
+ mnFixedWidth = GetPosCount();
+ maFixColStates = maGrid.GetColumnStates();
+ // switch to separators mode
+ mbFixedMode = false;
+ // reset and reinitialize controls
+ DisableRepaint();
+ Execute( CSVCMD_SETLINEOFFSET, 0 );
+ Execute( CSVCMD_SETPOSCOUNT, 1 );
+ Execute( CSVCMD_NEWCELLTEXTS );
+ maGrid.SetColumnStates( maSepColStates );
+ InitControls();
+ EnableRepaint();
+ }
+}
+
+void ScCsvTableBox::SetFixedWidthMode()
+{
+ if( !mbFixedMode )
+ {
+ // rescue data for separators mode
+ maSepColStates = maGrid.GetColumnStates();
+ // switch to fixed width mode
+ mbFixedMode = true;
+ // reset and reinitialize controls
+ DisableRepaint();
+ Execute( CSVCMD_SETLINEOFFSET, 0 );
+ Execute( CSVCMD_SETPOSCOUNT, mnFixedWidth );
+ maGrid.SetSplits( maRuler.GetSplits() );
+ maGrid.SetColumnStates( maFixColStates );
+ InitControls();
+ EnableRepaint();
+ }
+}
+
+void ScCsvTableBox::Init()
+{
+ mbFixedMode = false;
+ mnFixedWidth = 1;
+
+ maHScroll.EnableRTL( false ); // #107812# RTL
+ maHScroll.SetLineSize( 1 );
+ maVScroll.SetLineSize( 1 );
+
+ Link aLink = LINK( this, ScCsvTableBox, CsvCmdHdl );
+ SetCmdHdl( aLink );
+ maRuler.SetCmdHdl( aLink );
+ maGrid.SetCmdHdl( aLink );
+
+ aLink = LINK( this, ScCsvTableBox, ScrollHdl );
+ maHScroll.SetScrollHdl( aLink );
+ maVScroll.SetScrollHdl( aLink );
+
+ aLink = LINK( this, ScCsvTableBox, ScrollEndHdl );
+ maHScroll.SetEndScrollHdl( aLink );
+ maVScroll.SetEndScrollHdl( aLink );
+
+ InitControls();
+}
+
+void ScCsvTableBox::InitControls()
+{
+ maGrid.UpdateLayoutData();
+
+ long nScrollBarSize = GetSettings().GetStyleSettings().GetScrollBarSize();
+ Size aWinSize = CalcOutputSize( GetSizePixel() );
+ long nDataWidth = aWinSize.Width() - nScrollBarSize;
+ long nDataHeight = aWinSize.Height() - nScrollBarSize;
+
+ maData.mnWinWidth = nDataWidth;
+ maData.mnWinHeight = nDataHeight;
+
+ if( mbFixedMode )
+ {
+ // ruler sets height internally
+ maRuler.SetPosSizePixel( 0, 0, nDataWidth, 0 );
+ sal_Int32 nY = maRuler.GetSizePixel().Height();
+ maData.mnWinHeight -= nY;
+ maGrid.SetPosSizePixel( 0, nY, nDataWidth, maData.mnWinHeight );
+ }
+ else
+ maGrid.SetPosSizePixel( 0, 0, nDataWidth, nDataHeight );
+ maGrid.Show();
+ maRuler.Show( mbFixedMode );
+
+ // scrollbars always visible
+ maHScroll.SetPosSizePixel( 0, nDataHeight, nDataWidth, nScrollBarSize );
+ InitHScrollBar();
+ maHScroll.Show();
+
+ // scrollbars always visible
+ maVScroll.SetPosSizePixel( nDataWidth, 0, nScrollBarSize, nDataHeight );
+ InitVScrollBar();
+ maVScroll.Show();
+
+ bool bScrBox = maHScroll.IsVisible() && maVScroll.IsVisible();
+ if( bScrBox )
+ maScrollBox.SetPosSizePixel( nDataWidth, nDataHeight, nScrollBarSize, nScrollBarSize );
+ maScrollBox.Show( bScrBox );
+
+ // let the controls self-adjust to visible area
+ Execute( CSVCMD_SETPOSOFFSET, GetFirstVisPos() );
+ Execute( CSVCMD_SETLINEOFFSET, GetFirstVisLine() );
+}
+
+void ScCsvTableBox::InitHScrollBar()
+{
+ maHScroll.SetRange( Range( 0, GetPosCount() + 2 ) );
+ maHScroll.SetVisibleSize( GetVisPosCount() );
+ maHScroll.SetPageSize( GetVisPosCount() * 3 / 4 );
+ maHScroll.SetThumbPos( GetFirstVisPos() );
+}
+
+void ScCsvTableBox::InitVScrollBar()
+{
+ maVScroll.SetRange( Range( 0, GetLineCount() + 1 ) );
+ maVScroll.SetVisibleSize( GetVisLineCount() );
+ maVScroll.SetPageSize( GetVisLineCount() - 2 );
+ maVScroll.SetThumbPos( GetFirstVisLine() );
+}
+
+void ScCsvTableBox::MakePosVisible( sal_Int32 nPos )
+{
+ if( (0 <= nPos) && (nPos < GetPosCount()) )
+ {
+ if( nPos - CSV_SCROLL_DIST + 1 <= GetFirstVisPos() )
+ Execute( CSVCMD_SETPOSOFFSET, nPos - CSV_SCROLL_DIST );
+ else if( nPos + CSV_SCROLL_DIST >= GetLastVisPos() )
+ Execute( CSVCMD_SETPOSOFFSET, nPos - GetVisPosCount() + CSV_SCROLL_DIST );
+ }
+}
+
+
+// cell contents --------------------------------------------------------------
+
+void ScCsvTableBox::SetUniStrings(
+ const String* pTextLines, const String& rSepChars,
+ sal_Unicode cTextSep, bool bMergeSep )
+{
+ // assuming that pTextLines is a string array with size CSV_PREVIEW_LINES
+ // -> will be dynamic sometime
+ DisableRepaint();
+ sal_Int32 nEndLine = GetFirstVisLine() + CSV_PREVIEW_LINES;
+ const String* pString = pTextLines;
+ for( sal_Int32 nLine = GetFirstVisLine(); nLine < nEndLine; ++nLine, ++pString )
+ {
+ if( mbFixedMode )
+ maGrid.ImplSetTextLineFix( nLine, *pString );
+ else
+ maGrid.ImplSetTextLineSep( nLine, *pString, rSepChars, cTextSep, bMergeSep );
+ }
+ EnableRepaint();
+}
+
+//UNUSED2009-05 void ScCsvTableBox::SetByteStrings(
+//UNUSED2009-05 const ByteString* pTextLines, CharSet eCharSet,
+//UNUSED2009-05 const String& rSepChars, sal_Unicode cTextSep, bool bMergeSep )
+//UNUSED2009-05 {
+//UNUSED2009-05 // assuming that pTextLines is a string array with size CSV_PREVIEW_LINES
+//UNUSED2009-05 // -> will be dynamic sometime
+//UNUSED2009-05 DisableRepaint();
+//UNUSED2009-05 sal_Int32 nEndLine = GetFirstVisLine() + CSV_PREVIEW_LINES;
+//UNUSED2009-05 const ByteString* pString = pTextLines;
+//UNUSED2009-05 for( sal_Int32 nLine = GetFirstVisLine(); nLine < nEndLine; ++nLine, ++pString )
+//UNUSED2009-05 {
+//UNUSED2009-05 if( mbFixedMode )
+//UNUSED2009-05 maGrid.ImplSetTextLineFix( nLine, String( *pString, eCharSet ) );
+//UNUSED2009-05 else
+//UNUSED2009-05 maGrid.ImplSetTextLineSep( nLine, String( *pString, eCharSet ), rSepChars, cTextSep, bMergeSep );
+//UNUSED2009-05 }
+//UNUSED2009-05 EnableRepaint();
+//UNUSED2009-05 }
+
+
+// column settings ------------------------------------------------------------
+
+void ScCsvTableBox::InitTypes( const ListBox& rListBox )
+{
+ sal_uInt16 nTypeCount = rListBox.GetEntryCount();
+ StringVec aTypeNames( nTypeCount );
+ for( sal_uInt16 nIndex = 0; nIndex < nTypeCount; ++nIndex )
+ aTypeNames[ nIndex ] = rListBox.GetEntry( nIndex );
+ maGrid.SetTypeNames( aTypeNames );
+}
+
+void ScCsvTableBox::FillColumnData( ScAsciiOptions& rOptions ) const
+{
+ if( mbFixedMode )
+ maGrid.FillColumnDataFix( rOptions );
+ else
+ maGrid.FillColumnDataSep( rOptions );
+}
+
+
+// event handling -------------------------------------------------------------
+
+void ScCsvTableBox::Resize()
+{
+ ScCsvControl::Resize();
+ InitControls();
+}
+
+void ScCsvTableBox::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ InitControls();
+ ScCsvControl::DataChanged( rDCEvt );
+}
+
+IMPL_LINK( ScCsvTableBox, CsvCmdHdl, ScCsvControl*, pCtrl )
+{
+ DBG_ASSERT( pCtrl, "ScCsvTableBox::CsvCmdHdl - missing sender" );
+
+ const ScCsvCmd& rCmd = pCtrl->GetCmd();
+ ScCsvCmdType eType = rCmd.GetType();
+ sal_Int32 nParam1 = rCmd.GetParam1();
+ sal_Int32 nParam2 = rCmd.GetParam2();
+
+ bool bFound = true;
+ switch( eType )
+ {
+ case CSVCMD_REPAINT:
+ if( !IsNoRepaint() )
+ {
+ maGrid.ImplRedraw();
+ maRuler.ImplRedraw();
+ InitHScrollBar();
+ InitVScrollBar();
+ }
+ break;
+ case CSVCMD_MAKEPOSVISIBLE:
+ MakePosVisible( nParam1 );
+ break;
+
+ case CSVCMD_NEWCELLTEXTS:
+ if( mbFixedMode )
+ Execute( CSVCMD_UPDATECELLTEXTS );
+ else
+ {
+ DisableRepaint();
+ ScCsvColStateVec aStates( maGrid.GetColumnStates() );
+ sal_Int32 nPos = GetFirstVisPos();
+ Execute( CSVCMD_SETPOSCOUNT, 1 );
+ Execute( CSVCMD_UPDATECELLTEXTS );
+ Execute( CSVCMD_SETPOSOFFSET, nPos );
+ maGrid.SetColumnStates( aStates );
+ EnableRepaint();
+ }
+ break;
+ case CSVCMD_UPDATECELLTEXTS:
+ maUpdateTextHdl.Call( this );
+ break;
+ case CSVCMD_SETCOLUMNTYPE:
+ maGrid.SetSelColumnType( nParam1 );
+ break;
+ case CSVCMD_EXPORTCOLUMNTYPE:
+ maColTypeHdl.Call( this );
+ break;
+ case CSVCMD_SETFIRSTIMPORTLINE:
+ maGrid.SetFirstImportedLine( nParam1 );
+ break;
+
+ case CSVCMD_INSERTSPLIT:
+ DBG_ASSERT( mbFixedMode, "ScCsvTableBox::CsvCmdHdl::InsertSplit - invalid call" );
+ if( maRuler.GetSplitCount() + 1 < sal::static_int_cast<sal_uInt32>(CSV_MAXCOLCOUNT) )
+ {
+ maRuler.InsertSplit( nParam1 );
+ maGrid.InsertSplit( nParam1 );
+ }
+ break;
+ case CSVCMD_REMOVESPLIT:
+ DBG_ASSERT( mbFixedMode, "ScCsvTableBox::CsvCmdHdl::RemoveSplit - invalid call" );
+ maRuler.RemoveSplit( nParam1 );
+ maGrid.RemoveSplit( nParam1 );
+ break;
+ case CSVCMD_TOGGLESPLIT:
+ Execute( maRuler.HasSplit( nParam1 ) ? CSVCMD_REMOVESPLIT : CSVCMD_INSERTSPLIT, nParam1 );
+ break;
+ case CSVCMD_MOVESPLIT:
+ DBG_ASSERT( mbFixedMode, "ScCsvTableBox::CsvCmdHdl::MoveSplit - invalid call" );
+ maRuler.MoveSplit( nParam1, nParam2 );
+ maGrid.MoveSplit( nParam1, nParam2 );
+ break;
+ case CSVCMD_REMOVEALLSPLITS:
+ DBG_ASSERT( mbFixedMode, "ScCsvTableBox::CsvCmdHdl::RemoveAllSplits - invalid call" );
+ maRuler.RemoveAllSplits();
+ maGrid.RemoveAllSplits();
+ break;
+ default:
+ bFound = false;
+ }
+ if( bFound )
+ return 0;
+
+ const ScCsvLayoutData aOldData( maData );
+ switch( eType )
+ {
+ case CSVCMD_SETPOSCOUNT:
+ maData.mnPosCount = Max( nParam1, sal_Int32( 1 ) );
+ ImplSetPosOffset( GetFirstVisPos() );
+ break;
+ case CSVCMD_SETPOSOFFSET:
+ ImplSetPosOffset( nParam1 );
+ break;
+ case CSVCMD_SETHDRWIDTH:
+ maData.mnHdrWidth = Max( nParam1, sal_Int32( 0 ) );
+ ImplSetPosOffset( GetFirstVisPos() );
+ break;
+ case CSVCMD_SETCHARWIDTH:
+ maData.mnCharWidth = Max( nParam1, sal_Int32( 1 ) );
+ ImplSetPosOffset( GetFirstVisPos() );
+ break;
+ case CSVCMD_SETLINECOUNT:
+ maData.mnLineCount = Max( nParam1, sal_Int32( 1 ) );
+ ImplSetLineOffset( GetFirstVisLine() );
+ break;
+ case CSVCMD_SETLINEOFFSET:
+ ImplSetLineOffset( nParam1 );
+ break;
+ case CSVCMD_SETHDRHEIGHT:
+ maData.mnHdrHeight = Max( nParam1, sal_Int32( 0 ) );
+ ImplSetLineOffset( GetFirstVisLine() );
+ break;
+ case CSVCMD_SETLINEHEIGHT:
+ maData.mnLineHeight = Max( nParam1, sal_Int32( 1 ) );
+ ImplSetLineOffset( GetFirstVisLine() );
+ break;
+ case CSVCMD_MOVERULERCURSOR:
+ maData.mnPosCursor = IsVisibleSplitPos( nParam1 ) ? nParam1 : CSV_POS_INVALID;
+ break;
+ case CSVCMD_MOVEGRIDCURSOR:
+ maData.mnColCursor = ((0 <= nParam1) && (nParam1 < GetPosCount())) ? nParam1 : CSV_POS_INVALID;
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ if( maData != aOldData )
+ {
+ DisableRepaint();
+ maRuler.ApplyLayout( aOldData );
+ maGrid.ApplyLayout( aOldData );
+ EnableRepaint();
+ }
+
+ return 0;
+}
+
+IMPL_LINK( ScCsvTableBox, ScrollHdl, ScrollBar*, pScrollBar )
+{
+ DBG_ASSERT( pScrollBar, "ScCsvTableBox::ScrollHdl - missing sender" );
+
+ if( pScrollBar == &maHScroll )
+ Execute( CSVCMD_SETPOSOFFSET, pScrollBar->GetThumbPos() );
+ else if( pScrollBar == &maVScroll )
+ Execute( CSVCMD_SETLINEOFFSET, pScrollBar->GetThumbPos() );
+
+ return 0;
+}
+
+IMPL_LINK( ScCsvTableBox, ScrollEndHdl, ScrollBar*, pScrollBar )
+{
+ DBG_ASSERT( pScrollBar, "ScCsvTableBox::ScrollEndHdl - missing sender" );
+
+ if( pScrollBar == &maHScroll )
+ {
+ if( GetRulerCursorPos() != CSV_POS_INVALID )
+ Execute( CSVCMD_MOVERULERCURSOR, maRuler.GetNoScrollPos( GetRulerCursorPos() ) );
+ if( GetGridCursorPos() != CSV_POS_INVALID )
+ Execute( CSVCMD_MOVEGRIDCURSOR, maGrid.GetNoScrollCol( GetGridCursorPos() ) );
+ }
+
+ return 0;
+}
+
+
+// accessibility --------------------------------------------------------------
+
+ScCsvTableBox::XAccessibleRef ScCsvTableBox::CreateAccessible()
+{
+ // do not use the ScCsvControl mechanism, return default accessible object
+ return Control::CreateAccessible();
+}
+
+ScAccessibleCsvControl* ScCsvTableBox::ImplCreateAccessible()
+{
+ return NULL; // not used, see CreateAccessible()
+}
+
+
+// ============================================================================
+
diff --git a/sc/source/ui/dbgui/dapidata.cxx b/sc/source/ui/dbgui/dapidata.cxx
new file mode 100644
index 000000000000..976e0ae23039
--- /dev/null
+++ b/sc/source/ui/dbgui/dapidata.cxx
@@ -0,0 +1,229 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include <tools/debug.hxx>
+#include <vcl/waitobj.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <com/sun/star/sheet/DataImportMode.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+
+using namespace com::sun::star;
+
+#include "dapidata.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "dapitype.hrc"
+#include "miscuno.hxx"
+#include "dpsdbtab.hxx" // ScImportSourceDesc
+
+//-------------------------------------------------------------------------
+
+#define DP_SERVICE_DBCONTEXT "com.sun.star.sdb.DatabaseContext"
+#define SC_SERVICE_INTHANDLER "com.sun.star.task.InteractionHandler"
+
+// entries in the "type" ListBox
+#define DP_TYPELIST_TABLE 0
+#define DP_TYPELIST_QUERY 1
+#define DP_TYPELIST_SQL 2
+#define DP_TYPELIST_SQLNAT 3
+
+//-------------------------------------------------------------------------
+
+ScDataPilotDatabaseDlg::ScDataPilotDatabaseDlg( Window* pParent ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DAPIDATA ) ),
+ //
+ aFlFrame ( this, ScResId( FL_FRAME ) ),
+ aFtDatabase ( this, ScResId( FT_DATABASE ) ),
+ aLbDatabase ( this, ScResId( LB_DATABASE ) ),
+ aFtObject ( this, ScResId( FT_OBJECT ) ),
+ aCbObject ( this, ScResId( CB_OBJECT ) ),
+ aFtType ( this, ScResId( FT_OBJTYPE ) ),
+ aLbType ( this, ScResId( LB_OBJTYPE ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+ FreeResource();
+
+ WaitObject aWait( this ); // initializing the database service the first time takes a while
+
+ try
+ {
+ // get database names
+
+ uno::Reference<container::XNameAccess> xContext(
+ comphelper::getProcessServiceFactory()->createInstance(
+ rtl::OUString::createFromAscii( DP_SERVICE_DBCONTEXT ) ),
+ uno::UNO_QUERY);
+ if (xContext.is())
+ {
+ uno::Sequence<rtl::OUString> aNames = xContext->getElementNames();
+ long nCount = aNames.getLength();
+ const rtl::OUString* pArray = aNames.getConstArray();
+ for (long nPos = 0; nPos < nCount; nPos++)
+ {
+ String aName = pArray[nPos];
+ aLbDatabase.InsertEntry( aName );
+ }
+ }
+ }
+ catch(uno::Exception&)
+ {
+ DBG_ERROR("exception in database");
+ }
+
+ aLbDatabase.SelectEntryPos( 0 );
+ aLbType.SelectEntryPos( 0 );
+
+ FillObjects();
+
+ aLbDatabase.SetSelectHdl( LINK( this, ScDataPilotDatabaseDlg, SelectHdl ) );
+ aLbType.SetSelectHdl( LINK( this, ScDataPilotDatabaseDlg, SelectHdl ) );
+}
+
+ScDataPilotDatabaseDlg::~ScDataPilotDatabaseDlg()
+{
+}
+
+void ScDataPilotDatabaseDlg::GetValues( ScImportSourceDesc& rDesc )
+{
+ USHORT nSelect = aLbType.GetSelectEntryPos();
+
+ rDesc.aDBName = aLbDatabase.GetSelectEntry();
+ rDesc.aObject = aCbObject.GetText();
+
+ if ( !rDesc.aDBName.Len() || !rDesc.aObject.Len() )
+ rDesc.nType = sheet::DataImportMode_NONE;
+ else if ( nSelect == DP_TYPELIST_TABLE )
+ rDesc.nType = sheet::DataImportMode_TABLE;
+ else if ( nSelect == DP_TYPELIST_QUERY )
+ rDesc.nType = sheet::DataImportMode_QUERY;
+ else
+ rDesc.nType = sheet::DataImportMode_SQL;
+
+ rDesc.bNative = ( nSelect == DP_TYPELIST_SQLNAT );
+}
+
+IMPL_LINK( ScDataPilotDatabaseDlg, SelectHdl, ListBox*, EMPTYARG )
+{
+ FillObjects();
+ return 0;
+}
+
+void ScDataPilotDatabaseDlg::FillObjects()
+{
+ aCbObject.Clear();
+
+ String aDatabaseName = aLbDatabase.GetSelectEntry();
+ if (!aDatabaseName.Len())
+ return;
+
+ USHORT nSelect = aLbType.GetSelectEntryPos();
+ if ( nSelect > DP_TYPELIST_QUERY )
+ return; // only tables and queries
+
+ try
+ {
+ // open connection (for tables or queries)
+
+ uno::Reference<container::XNameAccess> xContext(
+ comphelper::getProcessServiceFactory()->createInstance(
+ rtl::OUString::createFromAscii( DP_SERVICE_DBCONTEXT ) ),
+ uno::UNO_QUERY);
+ if ( !xContext.is() ) return;
+
+ uno::Any aSourceAny = xContext->getByName( aDatabaseName );
+ uno::Reference<sdb::XCompletedConnection> xSource(
+ ScUnoHelpFunctions::AnyToInterface( aSourceAny ), uno::UNO_QUERY );
+ if ( !xSource.is() ) return;
+
+ uno::Reference<task::XInteractionHandler> xHandler(
+ comphelper::getProcessServiceFactory()->createInstance(
+ rtl::OUString::createFromAscii( SC_SERVICE_INTHANDLER ) ),
+ uno::UNO_QUERY);
+
+ uno::Reference<sdbc::XConnection> xConnection = xSource->connectWithCompletion( xHandler );
+
+ uno::Sequence<rtl::OUString> aNames;
+ if ( nSelect == DP_TYPELIST_TABLE )
+ {
+ // get all tables
+
+ uno::Reference<sdbcx::XTablesSupplier> xTablesSupp( xConnection, uno::UNO_QUERY );
+ if ( !xTablesSupp.is() ) return;
+
+ uno::Reference<container::XNameAccess> xTables = xTablesSupp->getTables();
+ if ( !xTables.is() ) return;
+
+ aNames = xTables->getElementNames();
+ }
+ else
+ {
+ // get all queries
+
+ uno::Reference<sdb::XQueriesSupplier> xQueriesSupp( xConnection, uno::UNO_QUERY );
+ if ( !xQueriesSupp.is() ) return;
+
+ uno::Reference<container::XNameAccess> xQueries = xQueriesSupp->getQueries();
+ if ( !xQueries.is() ) return;
+
+ aNames = xQueries->getElementNames();
+ }
+
+ // fill list
+
+ long nCount = aNames.getLength();
+ const rtl::OUString* pArray = aNames.getConstArray();
+ for( long nPos=0; nPos<nCount; nPos++ )
+ {
+ String aName = pArray[nPos];
+ aCbObject.InsertEntry( aName );
+ }
+ }
+ catch(uno::Exception&)
+ {
+ // #71604# this may happen if an invalid database is selected -> no DBG_ERROR
+ DBG_WARNING("exception in database");
+ }
+}
+
+
+
+
diff --git a/sc/source/ui/dbgui/dapitype.cxx b/sc/source/ui/dbgui/dapitype.cxx
new file mode 100644
index 000000000000..31aafbcb13da
--- /dev/null
+++ b/sc/source/ui/dbgui/dapitype.cxx
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "dapitype.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "dapitype.hrc"
+
+using namespace com::sun::star;
+
+//-------------------------------------------------------------------------
+
+ScDataPilotSourceTypeDlg::ScDataPilotSourceTypeDlg( Window* pParent, BOOL bEnableExternal ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DAPITYPE ) ),
+ //
+ aFlFrame ( this, ScResId( FL_FRAME ) ),
+ aBtnSelection ( this, ScResId( BTN_SELECTION ) ),
+ aBtnDatabase ( this, ScResId( BTN_DATABASE ) ),
+ aBtnExternal ( this, ScResId( BTN_EXTERNAL ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+ if (!bEnableExternal)
+ aBtnExternal.Disable();
+
+ aBtnSelection.Check();
+
+ FreeResource();
+}
+
+ScDataPilotSourceTypeDlg::~ScDataPilotSourceTypeDlg()
+{
+}
+
+BOOL ScDataPilotSourceTypeDlg::IsDatabase() const
+{
+ return aBtnDatabase.IsChecked();
+}
+
+BOOL ScDataPilotSourceTypeDlg::IsExternal() const
+{
+ return aBtnExternal.IsChecked();
+}
+
+//-------------------------------------------------------------------------
+
+ScDataPilotServiceDlg::ScDataPilotServiceDlg( Window* pParent,
+ const uno::Sequence<rtl::OUString>& rServices ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DAPISERVICE ) ),
+ //
+ aFlFrame ( this, ScResId( FL_FRAME ) ),
+ aFtService ( this, ScResId( FT_SERVICE ) ),
+ aLbService ( this, ScResId( LB_SERVICE ) ),
+ aFtSource ( this, ScResId( FT_SOURCE ) ),
+ aEdSource ( this, ScResId( ED_SOURCE ) ),
+ aFtName ( this, ScResId( FT_NAME ) ),
+ aEdName ( this, ScResId( ED_NAME ) ),
+ aFtUser ( this, ScResId( FT_USER ) ),
+ aEdUser ( this, ScResId( ED_USER ) ),
+ aFtPasswd ( this, ScResId( FT_PASSWD ) ),
+ aEdPasswd ( this, ScResId( ED_PASSWD ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+ long nCount = rServices.getLength();
+ const rtl::OUString* pArray = rServices.getConstArray();
+ for (long i=0; i<nCount; i++)
+ {
+ String aName = pArray[i];
+ aLbService.InsertEntry( aName );
+ }
+ aLbService.SelectEntryPos( 0 );
+
+ FreeResource();
+}
+
+ScDataPilotServiceDlg::~ScDataPilotServiceDlg()
+{
+}
+
+String ScDataPilotServiceDlg::GetServiceName() const
+{
+ return aLbService.GetSelectEntry();
+}
+
+String ScDataPilotServiceDlg::GetParSource() const
+{
+ return aEdSource.GetText();
+}
+
+String ScDataPilotServiceDlg::GetParName() const
+{
+ return aEdName.GetText();
+}
+
+String ScDataPilotServiceDlg::GetParUser() const
+{
+ return aEdUser.GetText();
+}
+
+String ScDataPilotServiceDlg::GetParPass() const
+{
+ return aEdPasswd.GetText();
+}
+
+
+
diff --git a/sc/source/ui/dbgui/dapitype.hrc b/sc/source/ui/dbgui/dapitype.hrc
new file mode 100644
index 000000000000..efbabe64fa04
--- /dev/null
+++ b/sc/source/ui/dbgui/dapitype.hrc
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+#define BTN_SELECTION 4
+#define BTN_DATABASE 5
+#define BTN_EXTERNAL 6
+#define FL_FRAME 7
+
+#define FT_SERVICE 8
+#define LB_SERVICE 9
+#define FT_SOURCE 10
+#define ED_SOURCE 11
+#define FT_NAME 12
+#define ED_NAME 13
+#define FT_USER 14
+#define ED_USER 15
+#define FT_PASSWD 16
+#define ED_PASSWD 17
+
+#define FT_DATABASE 18
+#define LB_DATABASE 19
+#define FT_OBJECT 20
+#define CB_OBJECT 21
+#define FT_OBJTYPE 22
+#define LB_OBJTYPE 23
+
diff --git a/sc/source/ui/dbgui/dapitype.src b/sc/source/ui/dbgui/dapitype.src
new file mode 100644
index 000000000000..84b1c1c6068f
--- /dev/null
+++ b/sc/source/ui/dbgui/dapitype.src
@@ -0,0 +1,319 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc"
+#include "dapitype.hrc"
+
+
+ModalDialog RID_SCDLG_DAPITYPE
+{
+ OutputSize = TRUE ;
+ HelpId = HID_DATAPILOT_TYPE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 241 , 63 ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 185 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 185 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 185 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_SELECTION
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_DAPITYPE:BTN_SELECTION";
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 164 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Current selection";
+ };
+ RadioButton BTN_DATABASE
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_DAPITYPE:BTN_DATABASE";
+ Pos = MAP_APPFONT ( 12 , 28 ) ;
+ Size = MAP_APPFONT ( 164 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Data source registered in %PRODUCTNAME";
+ };
+ RadioButton BTN_EXTERNAL
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_DAPITYPE:BTN_EXTERNAL";
+ Pos = MAP_APPFONT ( 12 , 42 ) ;
+ Size = MAP_APPFONT ( 164 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~External source/interface";
+ };
+ FixedLine FL_FRAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 173 , 8 ) ;
+ Text [ en-US ] = "Selection";
+ };
+ Text [ en-US ] = "Select Source";
+};
+
+
+//------------------------------------------------------------------------
+
+
+ModalDialog RID_SCDLG_DAPISERVICE
+{
+ OutputSize = TRUE ;
+ HelpId = HID_DATAPILOT_SERVICE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 241 , 94 ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 185 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 185 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 185 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_SERVICE
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 40 , 8 ) ;
+ Text [ en-US ] = "~Service";
+ };
+ ListBox LB_SERVICE
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_DAPISERVICE:LB_SERVICE";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 56 , 12 ) ;
+ Size = MAP_APPFONT ( 120 , 80 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ FixedText FT_SOURCE
+ {
+ Pos = MAP_APPFONT ( 12 , 30 ) ;
+ Size = MAP_APPFONT ( 40 , 8 ) ;
+ Text [ en-US ] = "So~urce";
+ };
+ Edit ED_SOURCE
+ {
+ HelpID = "sc:Edit:RID_SCDLG_DAPISERVICE:ED_SOURCE";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 56 , 28 ) ;
+ Size = MAP_APPFONT ( 120 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_NAME
+ {
+ Pos = MAP_APPFONT ( 12 , 46 ) ;
+ Size = MAP_APPFONT ( 40 , 8 ) ;
+ Text [ en-US ] = "~Name";
+ };
+ Edit ED_NAME
+ {
+ HelpID = "sc:Edit:RID_SCDLG_DAPISERVICE:ED_NAME";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 56 , 44 ) ;
+ Size = MAP_APPFONT ( 120 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_USER
+ {
+ Pos = MAP_APPFONT ( 12 , 62 ) ;
+ Size = MAP_APPFONT ( 40 , 8 ) ;
+ Text [ en-US ] = "Us~er";
+ };
+ Edit ED_USER
+ {
+ HelpID = "sc:Edit:RID_SCDLG_DAPISERVICE:ED_USER";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 56 , 60 ) ;
+ Size = MAP_APPFONT ( 120 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_PASSWD
+ {
+ Pos = MAP_APPFONT ( 12 , 78 ) ;
+ Size = MAP_APPFONT ( 40 , 8 ) ;
+ Text [ en-US ] = "~Password";
+ };
+ Edit ED_PASSWD
+ {
+ HelpID = "sc:Edit:RID_SCDLG_DAPISERVICE:ED_PASSWD";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 56 , 76 ) ;
+ Size = MAP_APPFONT ( 120 , 12 ) ;
+ TabStop = TRUE ;
+ PassWord = TRUE ;
+ };
+ FixedLine FL_FRAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 173 , 8 ) ;
+ Text [ en-US ] = "Selection";
+ };
+ Text [ en-US ] = "External Source";
+};
+
+
+//------------------------------------------------------------------------
+
+
+ModalDialog RID_SCDLG_DAPIDATA
+{
+ OutputSize = TRUE ;
+ HelpId = HID_DATAPILOT_DATABASE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 241 , 63 ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 185 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 185 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 185 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+
+ FixedText FT_DATABASE
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 52 , 8 ) ;
+ Text [ en-US ] = "~Database";
+ };
+ ListBox LB_DATABASE
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_DAPIDATA:LB_DATABASE";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 66 , 12 ) ;
+ Size = MAP_APPFONT ( 110 , 80 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+
+ FixedText FT_OBJECT
+ {
+ Pos = MAP_APPFONT ( 12 , 30 ) ;
+ Size = MAP_APPFONT ( 52 , 8 ) ;
+ Text [ en-US ] = "Data so~urce";
+ };
+ ComboBox CB_OBJECT
+ {
+ HelpID = "sc:ComboBox:RID_SCDLG_DAPIDATA:CB_OBJECT";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 66 , 28 ) ;
+ Size = MAP_APPFONT ( 110 , 80 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+
+ FixedText FT_OBJTYPE
+ {
+ Pos = MAP_APPFONT ( 12 , 46 ) ;
+ Size = MAP_APPFONT ( 52 , 8 ) ;
+ Text [ en-US ] = "~Type";
+ };
+ ListBox LB_OBJTYPE
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_DAPIDATA:LB_OBJTYPE";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 66 , 44 ) ;
+ Size = MAP_APPFONT ( 110 , 80 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "Sheet" ; Default ; > ;
+ < "Query" ; Default ; > ;
+ < "Sql" ; Default ; > ;
+ < "Sql [Native]" ; Default ; > ;
+ };
+ };
+
+ FixedLine FL_FRAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 173 , 8 ) ;
+ Text [ en-US ] = "Selection";
+ };
+ Text [ en-US ] = "Select Data Source";
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx
new file mode 100644
index 000000000000..a2f4d61af537
--- /dev/null
+++ b/sc/source/ui/dbgui/dbnamdlg.cxx
@@ -0,0 +1,721 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+// INCLUDE -------------------------------------------------------------------
+
+#include <vcl/msgbox.hxx>
+
+#include "reffact.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "globstr.hrc"
+#include "dbnamdlg.hrc"
+#include "rangenam.hxx" // IsNameValid
+
+#define _DBNAMDLG_CXX
+#include "dbnamdlg.hxx"
+#undef _DBNAMDLG_CXX
+
+
+//============================================================================
+
+#define ABS_SREF SCA_VALID \
+ | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
+#define ABS_DREF ABS_SREF \
+ | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
+#define ABS_SREF3D ABS_SREF | SCA_TAB_3D
+#define ABS_DREF3D ABS_DREF | SCA_TAB_3D
+
+//----------------------------------------------------------------------------
+
+class DBSaveData;
+
+static DBSaveData* pSaveObj = NULL;
+
+#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute()
+#define QUERYBOX(m) QueryBox(this,WinBits(WB_YES_NO|WB_DEF_YES),m).Execute()
+
+//============================================================================
+// class DBSaveData
+
+class DBSaveData
+{
+public:
+ DBSaveData( Edit& rEd, CheckBox& rHdr, CheckBox& rSize, CheckBox& rFmt,
+ CheckBox& rStrip, ScRange& rArea )
+ : rEdAssign(rEd),
+ rBtnHeader(rHdr), rBtnSize(rSize), rBtnFormat(rFmt), rBtnStrip(rStrip),
+ rCurArea(rArea),
+ bHeader(FALSE), bSize(FALSE), bFormat(FALSE), bDirty(FALSE) {}
+ void Save();
+ void Restore();
+
+private:
+ Edit& rEdAssign;
+ CheckBox& rBtnHeader;
+ CheckBox& rBtnSize;
+ CheckBox& rBtnFormat;
+ CheckBox& rBtnStrip;
+ ScRange& rCurArea;
+ String aStr;
+ ScRange aArea;
+ BOOL bHeader:1;
+ BOOL bSize:1;
+ BOOL bFormat:1;
+ BOOL bStrip:1;
+ BOOL bDirty:1;
+};
+
+
+
+//----------------------------------------------------------------------------
+
+void DBSaveData::Save()
+{
+ aArea = rCurArea;
+ aStr = rEdAssign.GetText();
+ bHeader = rBtnHeader.IsChecked();
+ bSize = rBtnSize.IsChecked();
+ bFormat = rBtnFormat.IsChecked();
+ bStrip = rBtnStrip.IsChecked();
+ bDirty = TRUE;
+}
+
+
+//----------------------------------------------------------------------------
+
+void DBSaveData::Restore()
+{
+ if ( bDirty )
+ {
+ rCurArea = aArea;
+ rEdAssign.SetText( aStr );
+ rBtnHeader.Check ( bHeader );
+ rBtnSize.Check ( bSize );
+ rBtnFormat.Check ( bFormat );
+ rBtnStrip.Check ( bStrip );
+ bDirty = FALSE;
+ }
+}
+
+
+//============================================================================
+// class ScDbNameDlg
+
+//----------------------------------------------------------------------------
+
+ScDbNameDlg::ScDbNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScViewData* ptrViewData )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_DBNAMES ),
+ //
+ aFlName ( this, ScResId( FL_NAME ) ),
+ aEdName ( this, ScResId( ED_NAME ) ),
+
+ aFlAssign ( this, ScResId( FL_ASSIGN ) ),
+ aEdAssign ( this, this, ScResId( ED_DBAREA ) ),
+ aRbAssign ( this, ScResId( RB_DBAREA ), &aEdAssign, this ),
+
+ aFlOptions ( this, ScResId( FL_OPTIONS ) ),
+ aBtnHeader ( this, ScResId( BTN_HEADER ) ),
+ aBtnDoSize ( this, ScResId( BTN_SIZE ) ),
+ aBtnKeepFmt ( this, ScResId( BTN_FORMAT ) ),
+ aBtnStripData ( this, ScResId( BTN_STRIPDATA ) ),
+ aFTSource ( this, ScResId( FT_SOURCE ) ),
+ aFTOperations ( this, ScResId( FT_OPERATIONS ) ),
+
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnAdd ( this, ScResId( BTN_ADD ) ),
+ aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
+ aBtnMore ( this, ScResId( BTN_MORE ) ),
+
+ aStrAdd ( ScResId( STR_ADD ) ),
+ aStrModify ( ScResId( STR_MODIFY ) ),
+ aStrNoName ( ScGlobal::GetRscString(STR_DB_NONAME) ),
+ aStrInvalid ( ScResId( STR_DB_INVALID ) ),
+ //
+ pViewData ( ptrViewData ),
+ pDoc ( ptrViewData->GetDocument() ),
+ bRefInputMode ( FALSE ),
+ aAddrDetails ( pDoc->GetAddressConvention(), 0, 0 ),
+ aLocalDbCol ( *(pDoc->GetDBCollection()) )
+{
+ // WB_NOLABEL can't be set in resource...
+ aFTSource.SetStyle( aFTSource.GetStyle() | WB_NOLABEL );
+ aFTOperations.SetStyle( aFTOperations.GetStyle() | WB_NOLABEL );
+
+ // damit die Strings in der Resource bei den FixedTexten bleiben koennen:
+ aStrSource = aFTSource.GetText();
+ aStrOperations = aFTOperations.GetText();
+
+ pSaveObj = new DBSaveData( aEdAssign, aBtnHeader,
+ aBtnDoSize, aBtnKeepFmt, aBtnStripData, theCurArea );
+ Init();
+ FreeResource();
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScDbNameDlg::~ScDbNameDlg()
+{
+ DELETEZ( pSaveObj );
+
+ ScRange* pEntry = (ScRange*)aRemoveList.First();
+ while ( pEntry )
+ {
+ aRemoveList.Remove( pEntry );
+ delete pEntry;
+ pEntry = (ScRange*)aRemoveList.Next();
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScDbNameDlg::Init()
+{
+ aBtnHeader.Check( TRUE ); // Default: mit Spaltenkoepfen
+
+ aBtnMore.AddWindow( &aFlOptions );
+ aBtnMore.AddWindow( &aBtnHeader );
+ aBtnMore.AddWindow( &aBtnDoSize );
+ aBtnMore.AddWindow( &aBtnKeepFmt );
+ aBtnMore.AddWindow( &aBtnStripData );
+ aBtnMore.AddWindow( &aFTSource );
+ aBtnMore.AddWindow( &aFTOperations );
+
+ String theAreaStr;
+ SCCOL nStartCol = 0;
+ SCROW nStartRow = 0;
+ SCTAB nStartTab = 0;
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = 0;
+ SCTAB nEndTab = 0;
+
+ aBtnOk.SetClickHdl ( LINK( this, ScDbNameDlg, OkBtnHdl ) );
+ aBtnCancel.SetClickHdl ( LINK( this, ScDbNameDlg, CancelBtnHdl ) );
+ aBtnAdd.SetClickHdl ( LINK( this, ScDbNameDlg, AddBtnHdl ) );
+ aBtnRemove.SetClickHdl ( LINK( this, ScDbNameDlg, RemoveBtnHdl ) );
+ aEdName.SetModifyHdl ( LINK( this, ScDbNameDlg, NameModifyHdl ) );
+ aEdAssign.SetModifyHdl ( LINK( this, ScDbNameDlg, AssModifyHdl ) );
+ UpdateNames();
+
+ if ( pViewData && pDoc )
+ {
+ ScDBCollection* pDBColl = pDoc->GetDBCollection();
+ ScDBData* pDBData = NULL;
+
+ pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab );
+
+ theCurArea = ScRange( ScAddress( nStartCol, nStartRow, nStartTab ),
+ ScAddress( nEndCol, nEndRow, nEndTab ) );
+
+ theCurArea.Format( theAreaStr, ABS_DREF3D, pDoc, aAddrDetails );
+
+ if ( pDBColl )
+ {
+ // Feststellen, ob definierter DB-Bereich markiert wurde:
+ pDBData = pDBColl->GetDBAtCursor( nStartCol, nStartRow, nStartTab, TRUE );
+ if ( pDBData )
+ {
+ String theDbName;
+ ScAddress& rStart = theCurArea.aStart;
+ ScAddress& rEnd = theCurArea.aEnd;
+ SCCOL nCol1;
+ SCCOL nCol2;
+ SCROW nRow1;
+ SCROW nRow2;
+ SCTAB nTab;
+
+ pDBData->GetArea( nTab, nCol1, nRow1, nCol2, nRow2 );
+
+ if ( (rStart.Tab() == nTab)
+ && (rStart.Col() == nCol1) && (rStart.Row() == nRow1)
+ && (rEnd.Col() == nCol2) && (rEnd.Row() == nRow2 ) )
+ {
+ pDBData->GetName( theDbName );
+ if ( theDbName != aStrNoName )
+ aEdName.SetText( theDbName );
+ else
+ aEdName.SetText( EMPTY_STRING );
+ aBtnHeader.Check( pDBData->HasHeader() );
+ aBtnDoSize.Check( pDBData->IsDoSize() );
+ aBtnKeepFmt.Check( pDBData->IsKeepFmt() );
+ aBtnStripData.Check( pDBData->IsStripData() );
+ SetInfoStrings( pDBData );
+ }
+ }
+ }
+ }
+
+ aEdAssign.SetText( theAreaStr );
+ aEdName.GrabFocus();
+ bSaved=TRUE;
+ pSaveObj->Save();
+ NameModifyHdl( 0 );
+}
+
+
+void ScDbNameDlg::SetInfoStrings( const ScDBData* pDBData )
+{
+ String aSource = aStrSource;
+ if (pDBData)
+ {
+ aSource += ' ';
+ aSource += pDBData->GetSourceString();
+ }
+ aFTSource.SetText( aSource );
+
+ String aOper = aStrOperations;
+ if (pDBData)
+ {
+ aOper += ' ';
+ aOper += pDBData->GetOperations();
+ }
+ aFTOperations.SetText( aOper );
+}
+
+//----------------------------------------------------------------------------
+// Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
+// neue Selektion im Referenz-Fenster angezeigt wird.
+
+void ScDbNameDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( aEdAssign.IsEnabled() )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart( &aEdAssign );
+
+ theCurArea = rRef;
+
+ String aRefStr;
+ theCurArea.Format( aRefStr, ABS_DREF3D, pDocP, aAddrDetails );
+ aEdAssign.SetRefString( aRefStr );
+ aBtnHeader.Enable();
+ aBtnDoSize.Enable();
+ aBtnKeepFmt.Enable();
+ aBtnStripData.Enable();
+ aFTSource.Enable();
+ aFTOperations.Enable();
+ aBtnAdd.Enable();
+ bSaved=TRUE;
+ pSaveObj->Save();
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScDbNameDlg::Close()
+{
+ return DoClose( ScDbNameDlgWrapper::GetChildWindowId() );
+}
+
+//------------------------------------------------------------------------
+
+void ScDbNameDlg::SetActive()
+{
+ aEdAssign.GrabFocus();
+
+ // kein NameModifyHdl, weil sonst Bereiche nicht geaendert werden koennen
+ // (nach dem Aufziehen der Referenz wuerde der alte Inhalt wieder angezeigt)
+ // (der ausgewaehlte DB-Name hat sich auch nicht veraendert)
+
+ RefInputDone();
+}
+
+//------------------------------------------------------------------------
+
+void ScDbNameDlg::UpdateNames()
+{
+ USHORT nNameCount = aLocalDbCol.GetCount();
+
+ aEdName.SetUpdateMode( FALSE );
+ //-----------------------------------------------------------
+ aEdName.Clear();
+ aEdAssign.SetText( EMPTY_STRING );
+
+ if ( nNameCount > 0 )
+ {
+ ScDBData* pDbData = NULL;
+ String aString;
+
+ for ( USHORT i=0; i<nNameCount; i++ )
+ {
+ pDbData = (ScDBData*)(aLocalDbCol.At( i ));
+ if ( pDbData )
+ {
+ pDbData->GetName( aString );
+ if ( aString != aStrNoName )
+ aEdName.InsertEntry( aString );
+ }
+ }
+ }
+ else
+ {
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ }
+ //-----------------------------------------------------------
+ aEdName.SetUpdateMode( TRUE );
+ aEdName.Invalidate();
+}
+
+//------------------------------------------------------------------------
+
+void ScDbNameDlg::UpdateDBData( const String& rStrName )
+{
+ String theArea;
+ USHORT nAt;
+ ScDBData* pData;
+
+ aLocalDbCol.SearchName( rStrName, nAt );
+ pData = (ScDBData*)(aLocalDbCol.At( nAt ));
+
+ if ( pData )
+ {
+ SCCOL nColStart = 0;
+ SCROW nRowStart = 0;
+ SCCOL nColEnd = 0;
+ SCROW nRowEnd = 0;
+ SCTAB nTab = 0;
+
+ pData->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd );
+ theCurArea = ScRange( ScAddress( nColStart, nRowStart, nTab ),
+ ScAddress( nColEnd, nRowEnd, nTab ) );
+ theCurArea.Format( theArea, ABS_DREF3D, pDoc, aAddrDetails );
+ aEdAssign.SetText( theArea );
+ aBtnAdd.SetText( aStrModify );
+ aBtnHeader.Check( pData->HasHeader() );
+ aBtnDoSize.Check( pData->IsDoSize() );
+ aBtnKeepFmt.Check( pData->IsKeepFmt() );
+ aBtnStripData.Check( pData->IsStripData() );
+ SetInfoStrings( pData );
+ }
+
+ aBtnAdd.SetText( aStrModify );
+ aBtnAdd.Enable();
+ aBtnRemove.Enable();
+ aBtnHeader.Enable();
+ aBtnDoSize.Enable();
+ aBtnKeepFmt.Enable();
+ aBtnStripData.Enable();
+ aFTSource.Enable();
+ aFTOperations.Enable();
+}
+
+//------------------------------------------------------------------------
+
+
+BOOL ScDbNameDlg::IsRefInputMode() const
+{
+ return bRefInputMode;
+}
+
+//------------------------------------------------------------------------
+// Handler:
+// ========
+
+IMPL_LINK( ScDbNameDlg, OkBtnHdl, void *, EMPTYARG )
+{
+ AddBtnHdl( 0 );
+
+ // Der View die Aenderungen und die Remove-Liste uebergeben:
+ // beide werden nur als Referenz uebergeben, so dass an dieser
+ // Stelle keine Speicherleichen entstehen koennen:
+ if ( pViewData )
+ pViewData->GetView()->
+ NotifyCloseDbNameDlg( aLocalDbCol, aRemoveList );
+
+ Close();
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScDbNameDlg, CancelBtnHdl, void *, EMPTYARG )
+{
+ Close();
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScDbNameDlg, CancelBtnHdl, void *, EMPTYARG )
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScDbNameDlg, AddBtnHdl, void *, EMPTYARG )
+{
+ String aNewName = aEdName.GetText();
+ String aNewArea = aEdAssign.GetText();
+
+ aNewName.EraseLeadingChars( ' ' );
+ aNewName.EraseTrailingChars( ' ' );
+
+ if ( aNewName.Len() > 0 && aNewArea.Len() > 0 )
+ {
+ if ( ScRangeData::IsNameValid( aNewName, pDoc ) )
+ {
+ // weil jetzt editiert werden kann, muss erst geparst werden
+ ScRange aTmpRange;
+ String aText = aEdAssign.GetText();
+ if ( aTmpRange.ParseAny( aText, pDoc, aAddrDetails ) & SCA_VALID )
+ {
+ theCurArea = aTmpRange;
+ ScAddress aStart = theCurArea.aStart;
+ ScAddress aEnd = theCurArea.aEnd;
+
+ ScDBData* pOldEntry = NULL;
+ USHORT nFoundAt = 0;
+ if ( aLocalDbCol.SearchName( aNewName, nFoundAt ) )
+ pOldEntry = aLocalDbCol[nFoundAt];
+ if (pOldEntry)
+ {
+ // Bereich veraendern
+
+ pOldEntry->MoveTo( aStart.Tab(), aStart.Col(), aStart.Row(),
+ aEnd.Col(), aEnd.Row() );
+ pOldEntry->SetByRow( TRUE );
+ pOldEntry->SetHeader( aBtnHeader.IsChecked() );
+ pOldEntry->SetDoSize( aBtnDoSize.IsChecked() );
+ pOldEntry->SetKeepFmt( aBtnKeepFmt.IsChecked() );
+ pOldEntry->SetStripData( aBtnStripData.IsChecked() );
+ }
+ else
+ {
+ // neuen Bereich einfuegen
+
+ ScDBData* pNewEntry = new ScDBData( aNewName, aStart.Tab(),
+ aStart.Col(), aStart.Row(),
+ aEnd.Col(), aEnd.Row(),
+ TRUE, aBtnHeader.IsChecked() );
+ pNewEntry->SetDoSize( aBtnDoSize.IsChecked() );
+ pNewEntry->SetKeepFmt( aBtnKeepFmt.IsChecked() );
+ pNewEntry->SetStripData( aBtnStripData.IsChecked() );
+
+ if ( !aLocalDbCol.Insert( pNewEntry ) )
+ delete pNewEntry;
+ }
+
+ UpdateNames();
+
+ aEdName.SetText( EMPTY_STRING );
+ aEdName.GrabFocus();
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ aEdAssign.SetText( EMPTY_STRING );
+ aBtnHeader.Check( TRUE ); // Default: mit Spaltenkoepfen
+ aBtnDoSize.Check( FALSE );
+ aBtnKeepFmt.Check( FALSE );
+ aBtnStripData.Check( FALSE );
+ SetInfoStrings( NULL ); // leer
+ theCurArea = ScRange();
+ bSaved=TRUE;
+ pSaveObj->Save();
+ NameModifyHdl( 0 );
+ }
+ else
+ {
+ ERRORBOX( aStrInvalid );
+ aEdAssign.SetSelection( Selection( 0, SELECTION_MAX ) );
+ aEdAssign.GrabFocus();
+ }
+ }
+ else
+ {
+ ERRORBOX( ScGlobal::GetRscString(STR_INVALIDNAME) );
+ aEdName.SetSelection( Selection( 0, SELECTION_MAX ) );
+ aEdName.GrabFocus();
+ }
+ }
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScDbNameDlg, RemoveBtnHdl, void *, EMPTYARG )
+{
+ USHORT nRemoveAt = 0;
+ const String aStrEntry = aEdName.GetText();
+
+ if ( aLocalDbCol.SearchName( aStrEntry, nRemoveAt ) )
+ {
+ String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY );
+ String aMsg = aStrDelMsg.GetToken( 0, '#' );
+
+ aMsg += aStrEntry;
+ aMsg += aStrDelMsg.GetToken( 1, '#' );
+
+ if ( RET_YES == QUERYBOX(aMsg) )
+ {
+ ScDBData* pEntry = (ScDBData*)aLocalDbCol.At(nRemoveAt);
+
+ if ( pEntry )
+ {
+ SCTAB nTab;
+ SCCOL nColStart, nColEnd;
+ SCROW nRowStart, nRowEnd;
+ pEntry->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd );
+ aRemoveList.Insert(
+ new ScRange( ScAddress( nColStart, nRowStart, nTab ),
+ ScAddress( nColEnd, nRowEnd, nTab ) ) );
+ }
+ aLocalDbCol.AtFree( nRemoveAt );
+
+ UpdateNames();
+
+ aEdName.SetText( EMPTY_STRING );
+ aEdName.GrabFocus();
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ aEdAssign.SetText( EMPTY_STRING );
+ theCurArea = ScRange();
+ aBtnHeader.Check( TRUE ); // Default: mit Spaltenkoepfen
+ aBtnDoSize.Check( FALSE );
+ aBtnKeepFmt.Check( FALSE );
+ aBtnStripData.Check( FALSE );
+ SetInfoStrings( NULL ); // leer
+ bSaved=FALSE;
+ pSaveObj->Restore();
+ NameModifyHdl( 0 );
+ }
+ }
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScDbNameDlg, NameModifyHdl, void *, EMPTYARG )
+{
+ String theName = aEdName.GetText();
+ BOOL bNameFound = (COMBOBOX_ENTRY_NOTFOUND
+ != aEdName.GetEntryPos( theName ));
+
+ if ( theName.Len() == 0 )
+ {
+ if ( aBtnAdd.GetText() != aStrAdd )
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd .Disable();
+ aBtnRemove .Disable();
+ aFlAssign .Disable();
+ aBtnHeader .Disable();
+ aBtnDoSize .Disable();
+ aBtnKeepFmt .Disable();
+ aBtnStripData.Disable();
+ aFTSource .Disable();
+ aFTOperations.Disable();
+ aEdAssign .Disable();
+ aRbAssign .Disable();
+ //bSaved=FALSE;
+ //pSaveObj->Restore();
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+ bRefInputMode = FALSE;
+ }
+ else
+ {
+ if ( bNameFound )
+ {
+ if ( aBtnAdd.GetText() != aStrModify )
+ aBtnAdd.SetText( aStrModify );
+
+ if(!bSaved)
+ {
+ bSaved=TRUE;
+ pSaveObj->Save();
+ }
+ UpdateDBData( theName );
+ }
+ else
+ {
+ if ( aBtnAdd.GetText() != aStrAdd )
+ aBtnAdd.SetText( aStrAdd );
+
+ bSaved=FALSE;
+ pSaveObj->Restore();
+
+ if ( aEdAssign.GetText().Len() > 0 )
+ {
+ aBtnAdd.Enable();
+ aBtnHeader.Enable();
+ aBtnDoSize.Enable();
+ aBtnKeepFmt.Enable();
+ aBtnStripData.Enable();
+ aFTSource.Enable();
+ aFTOperations.Enable();
+ }
+ else
+ {
+ aBtnAdd.Disable();
+ aBtnHeader.Disable();
+ aBtnDoSize.Disable();
+ aBtnKeepFmt.Disable();
+ aBtnStripData.Disable();
+ aFTSource.Disable();
+ aFTOperations.Disable();
+ }
+ aBtnRemove.Disable();
+ }
+
+ aFlAssign.Enable();
+ aEdAssign.Enable();
+ aRbAssign.Enable();
+
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable();
+ bRefInputMode = TRUE;
+ }
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScDbNameDlg, AssModifyHdl, void *, EMPTYARG )
+{
+ // hier parsen fuer Save() etc.
+
+ ScRange aTmpRange;
+ String aText = aEdAssign.GetText();
+ if ( aTmpRange.ParseAny( aText, pDoc, aAddrDetails ) & SCA_VALID )
+ theCurArea = aTmpRange;
+
+ return 0;
+}
+
+
diff --git a/sc/source/ui/dbgui/dpgroupdlg.cxx b/sc/source/ui/dbgui/dpgroupdlg.cxx
new file mode 100644
index 000000000000..4ac3fb8d68ad
--- /dev/null
+++ b/sc/source/ui/dbgui/dpgroupdlg.cxx
@@ -0,0 +1,360 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#ifdef SC_DLLIMPLEMENTATION
+#undef SC_DLLIMPLEMENTATION
+#endif
+
+
+#include "dpgroupdlg.hxx"
+#ifndef SC_DPGROUPDLG_HRC
+#include "dpgroupdlg.hrc"
+#endif
+#include <tools/resary.hxx>
+#include "scresid.hxx"
+#ifndef SC_SC_HRC
+#include "sc.hrc"
+#endif
+#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
+
+// ============================================================================
+
+namespace {
+
+/** Date part flags in order of the list box entries. */
+static const sal_Int32 spnDateParts[] =
+{
+ com::sun::star::sheet::DataPilotFieldGroupBy::SECONDS,
+ com::sun::star::sheet::DataPilotFieldGroupBy::MINUTES,
+ com::sun::star::sheet::DataPilotFieldGroupBy::HOURS,
+ com::sun::star::sheet::DataPilotFieldGroupBy::DAYS,
+ com::sun::star::sheet::DataPilotFieldGroupBy::MONTHS,
+ com::sun::star::sheet::DataPilotFieldGroupBy::QUARTERS,
+ com::sun::star::sheet::DataPilotFieldGroupBy::YEARS
+};
+
+} // namespace
+
+// ============================================================================
+
+ScDPGroupEditHelper::ScDPGroupEditHelper( RadioButton& rRbAuto, RadioButton& rRbMan, Edit& rEdValue ) :
+ mrRbAuto( rRbAuto ),
+ mrRbMan( rRbMan ),
+ mrEdValue( rEdValue )
+{
+ mrRbAuto.SetClickHdl( LINK( this, ScDPGroupEditHelper, ClickHdl ) );
+ mrRbMan.SetClickHdl( LINK( this, ScDPGroupEditHelper, ClickHdl ) );
+}
+
+bool ScDPGroupEditHelper::IsAuto() const
+{
+ return mrRbAuto.IsChecked();
+}
+
+double ScDPGroupEditHelper::GetValue() const
+{
+ double fValue;
+ if( !ImplGetValue( fValue ) )
+ fValue = 0.0;
+ return fValue;
+}
+
+void ScDPGroupEditHelper::SetValue( bool bAuto, double fValue )
+{
+ if( bAuto )
+ {
+ mrRbAuto.Check();
+ ClickHdl( &mrRbAuto );
+ }
+ else
+ {
+ mrRbMan.Check();
+ ClickHdl( &mrRbMan );
+ }
+ ImplSetValue( fValue );
+}
+
+IMPL_LINK( ScDPGroupEditHelper, ClickHdl, RadioButton*, pButton )
+{
+ if( pButton == &mrRbAuto )
+ {
+ // disable edit field on clicking "automatic" radio button
+ mrEdValue.Disable();
+ }
+ else if( pButton == &mrRbMan )
+ {
+ // enable and set focus to edit field on clicking "manual" radio button
+ mrEdValue.Enable();
+ mrEdValue.GrabFocus();
+ }
+ return 0;
+}
+
+// ----------------------------------------------------------------------------
+
+ScDPNumGroupEditHelper::ScDPNumGroupEditHelper(
+ RadioButton& rRbAuto, RadioButton& rRbMan, ScDoubleField& rEdValue ) :
+ ScDPGroupEditHelper( rRbAuto, rRbMan, rEdValue ),
+ mrEdValue( rEdValue )
+{
+}
+
+bool ScDPNumGroupEditHelper::ImplGetValue( double& rfValue ) const
+{
+ return mrEdValue.GetValue( rfValue );
+}
+
+void ScDPNumGroupEditHelper::ImplSetValue( double fValue )
+{
+ mrEdValue.SetValue( fValue );
+}
+
+// ----------------------------------------------------------------------------
+
+ScDPDateGroupEditHelper::ScDPDateGroupEditHelper(
+ RadioButton& rRbAuto, RadioButton& rRbMan, DateField& rEdValue, const Date& rNullDate ) :
+ ScDPGroupEditHelper( rRbAuto, rRbMan, rEdValue ),
+ mrEdValue( rEdValue ),
+ maNullDate( rNullDate )
+{
+}
+
+bool ScDPDateGroupEditHelper::ImplGetValue( double& rfValue ) const
+{
+ rfValue = mrEdValue.GetDate() - maNullDate;
+ return true;
+}
+
+void ScDPDateGroupEditHelper::ImplSetValue( double fValue )
+{
+ Date aDate( maNullDate );
+ aDate += static_cast< sal_Int32 >( fValue );
+ mrEdValue.SetDate( aDate );
+}
+
+// ============================================================================
+// ============================================================================
+
+ScDPNumGroupDlg::ScDPNumGroupDlg( Window* pParent, const ScDPNumGroupInfo& rInfo ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DPNUMGROUP ) ),
+ maFlStart ( this, ScResId( FL_START ) ),
+ maRbAutoStart ( this, ScResId( RB_AUTOSTART ) ),
+ maRbManStart ( this, ScResId( RB_MANSTART ) ),
+ maEdStart ( this, ScResId( ED_START ) ),
+ maFlEnd ( this, ScResId( FL_END ) ),
+ maRbAutoEnd ( this, ScResId( RB_AUTOEND ) ),
+ maRbManEnd ( this, ScResId( RB_MANEND ) ),
+ maEdEnd ( this, ScResId( ED_END ) ),
+ maFlBy ( this, ScResId( FL_BY ) ),
+ maEdBy ( this, ScResId( ED_BY ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+ maStartHelper ( maRbAutoStart, maRbManStart, maEdStart ),
+ maEndHelper ( maRbAutoEnd, maRbManEnd, maEdEnd )
+{
+ FreeResource();
+
+ maStartHelper.SetValue( rInfo.AutoStart, rInfo.Start );
+ maEndHelper.SetValue( rInfo.AutoEnd, rInfo.End );
+ maEdBy.SetValue( (rInfo.Step <= 0.0) ? 1.0 : rInfo.Step );
+
+ /* Set the initial focus, currently it is somewhere after calling all the radio
+ button click handlers. Now the first enabled editable control is focused. */
+ if( maEdStart.IsEnabled() )
+ maEdStart.GrabFocus();
+ else if( maEdEnd.IsEnabled() )
+ maEdEnd.GrabFocus();
+ else
+ maEdBy.GrabFocus();
+}
+
+ScDPNumGroupInfo ScDPNumGroupDlg::GetGroupInfo() const
+{
+ ScDPNumGroupInfo aInfo;
+ aInfo.Enable = sal_True;
+ aInfo.DateValues = sal_False;
+ aInfo.AutoStart = maStartHelper.IsAuto();
+ aInfo.AutoEnd = maEndHelper.IsAuto();
+
+ // get values and silently auto-correct them, if they are not valid
+ // TODO: error messages in OK event?
+ aInfo.Start = maStartHelper.GetValue();
+ aInfo.End = maEndHelper.GetValue();
+ if( !maEdBy.GetValue( aInfo.Step ) || (aInfo.Step <= 0.0) )
+ aInfo.Step = 1.0;
+ if( aInfo.End <= aInfo.Start )
+ aInfo.End = aInfo.Start + aInfo.Step;
+
+ return aInfo;
+}
+
+// ============================================================================
+
+ScDPDateGroupDlg::ScDPDateGroupDlg( Window* pParent,
+ const ScDPNumGroupInfo& rInfo, sal_Int32 nDatePart, const Date& rNullDate ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DPDATEGROUP ) ),
+ maFlStart ( this, ScResId( FL_START ) ),
+ maRbAutoStart ( this, ScResId( RB_AUTOSTART ) ),
+ maRbManStart ( this, ScResId( RB_MANSTART ) ),
+ maEdStart ( this, ScResId( ED_START ) ),
+ maFlEnd ( this, ScResId( FL_END ) ),
+ maRbAutoEnd ( this, ScResId( RB_AUTOEND ) ),
+ maRbManEnd ( this, ScResId( RB_MANEND ) ),
+ maEdEnd ( this, ScResId( ED_END ) ),
+ maFlBy ( this, ScResId( FL_BY ) ),
+ maRbNumDays ( this, ScResId( RB_NUMDAYS ) ),
+ maRbUnits ( this, ScResId( RB_UNITS ) ),
+ maEdNumDays ( this, ScResId( ED_NUMDAYS ) ),
+ maLbUnits ( this, ScResId( LB_UNITS ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+ maStartHelper ( maRbAutoStart, maRbManStart, maEdStart, rNullDate ),
+ maEndHelper ( maRbAutoEnd, maRbManEnd, maEdEnd, rNullDate )
+{
+ maLbUnits.SetHelpId( HID_SC_DPDATEGROUP_LB );
+ ResStringArray aArr( ScResId( STR_UNITS ) );
+ for( USHORT nIdx = 0, nCount = sal::static_int_cast<USHORT>(aArr.Count()); nIdx < nCount; ++nIdx )
+ maLbUnits.InsertEntry( aArr.GetString( nIdx ) );
+
+ FreeResource();
+
+ maEdStart.SetShowDateCentury( TRUE );
+ maEdEnd.SetShowDateCentury( TRUE );
+
+ maStartHelper.SetValue( rInfo.AutoStart, rInfo.Start );
+ maEndHelper.SetValue( rInfo.AutoEnd, rInfo.End );
+
+ if( nDatePart == 0 )
+ nDatePart = com::sun::star::sheet::DataPilotFieldGroupBy::MONTHS;
+ for( ULONG nIdx = 0, nCount = maLbUnits.GetEntryCount(); nIdx < nCount; ++nIdx )
+ maLbUnits.CheckEntryPos( static_cast< USHORT >( nIdx ), (nDatePart & spnDateParts[ nIdx ]) != 0 );
+
+ if( rInfo.DateValues )
+ {
+ maRbNumDays.Check();
+ ClickHdl( &maRbNumDays );
+
+ double fNumDays = rInfo.Step;
+ if( fNumDays < 1.0 )
+ fNumDays = 1.0;
+ else if( fNumDays > 32767.0 )
+ fNumDays = 32767.0;
+ maEdNumDays.SetValue( static_cast< long >( fNumDays ) );
+ }
+ else
+ {
+ maRbUnits.Check();
+ ClickHdl( &maRbUnits );
+ }
+
+ /* Set the initial focus, currently it is somewhere after calling all the radio
+ button click handlers. Now the first enabled editable control is focused. */
+ if( maEdStart.IsEnabled() )
+ maEdStart.GrabFocus();
+ else if( maEdEnd.IsEnabled() )
+ maEdEnd.GrabFocus();
+ else if( maEdNumDays.IsEnabled() )
+ maEdNumDays.GrabFocus();
+ else if( maLbUnits.IsEnabled() )
+ maLbUnits.GrabFocus();
+
+ maRbNumDays.SetClickHdl( LINK( this, ScDPDateGroupDlg, ClickHdl ) );
+ maRbUnits.SetClickHdl( LINK( this, ScDPDateGroupDlg, ClickHdl ) );
+ maLbUnits.SetCheckButtonHdl( LINK( this, ScDPDateGroupDlg, CheckHdl ) );
+}
+
+ScDPNumGroupInfo ScDPDateGroupDlg::GetGroupInfo() const
+{
+ ScDPNumGroupInfo aInfo;
+ aInfo.Enable = sal_True;
+ aInfo.DateValues = maRbNumDays.IsChecked();
+ aInfo.AutoStart = maStartHelper.IsAuto();
+ aInfo.AutoEnd = maEndHelper.IsAuto();
+
+ // get values and silently auto-correct them, if they are not valid
+ // TODO: error messages in OK event?
+ aInfo.Start = maStartHelper.GetValue();
+ aInfo.End = maEndHelper.GetValue();
+ sal_Int64 nNumDays = maEdNumDays.GetValue();
+ aInfo.Step = static_cast<double>( aInfo.DateValues ? nNumDays : 0L );
+ if( aInfo.End <= aInfo.Start )
+ aInfo.End = aInfo.Start + nNumDays;
+
+ return aInfo;
+}
+
+sal_Int32 ScDPDateGroupDlg::GetDatePart() const
+{
+ // return DAYS for special "number of days" mode
+ if( maRbNumDays.IsChecked() )
+ return com::sun::star::sheet::DataPilotFieldGroupBy::DAYS;
+
+ // return listbox contents for "units" mode
+ sal_Int32 nDatePart = 0;
+ for( ULONG nIdx = 0, nCount = maLbUnits.GetEntryCount(); nIdx < nCount; ++nIdx )
+ if( maLbUnits.IsChecked( static_cast< USHORT >( nIdx ) ) )
+ nDatePart |= spnDateParts[ nIdx ];
+ return nDatePart;
+}
+
+IMPL_LINK( ScDPDateGroupDlg, ClickHdl, RadioButton*, pButton )
+{
+ if( pButton == &maRbNumDays )
+ {
+ maLbUnits.Disable();
+ // enable and set focus to edit field on clicking "num of days" radio button
+ maEdNumDays.Enable();
+ maEdNumDays.GrabFocus();
+ maBtnOk.Enable();
+ }
+ else if( pButton == &maRbUnits )
+ {
+ maEdNumDays.Disable();
+ // enable and set focus to listbox on clicking "units" radio button
+ maLbUnits.Enable();
+ maLbUnits.GrabFocus();
+ // disable OK button if no date part selected
+ CheckHdl( &maLbUnits );
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDPDateGroupDlg, CheckHdl, SvxCheckListBox*, pListBox )
+{
+ // enable/disable OK button on modifying check list box
+ if( pListBox == &maLbUnits )
+ maBtnOk.Enable( maLbUnits.GetCheckedEntryCount() > 0 );
+ return 0;
+}
+
+// ============================================================================
+
diff --git a/sc/source/ui/dbgui/dpgroupdlg.hrc b/sc/source/ui/dbgui/dpgroupdlg.hrc
new file mode 100644
index 000000000000..5a4797489ddf
--- /dev/null
+++ b/sc/source/ui/dbgui/dpgroupdlg.hrc
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_DPGROUPDLG_HRC
+#define SC_DPGROUPDLG_HRC
+
+#include "sc.hrc"
+
+// push buttons
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+
+// fixed lines
+#define FL_START 1
+#define FL_END 2
+#define FL_BY 3
+
+// radio buttons
+#define RB_AUTOSTART 1
+#define RB_MANSTART 2
+#define RB_AUTOEND 3
+#define RB_MANEND 4
+#define RB_NUMDAYS 5
+#define RB_UNITS 6
+
+// edit fields
+#define ED_START 1
+#define ED_END 2
+#define ED_BY 3
+#define ED_NUMDAYS 4
+
+// list boxes
+#define LB_UNITS 1
+
+// strings/string arrays
+#define STR_UNITS 1
+
+#endif
+
diff --git a/sc/source/ui/dbgui/dpgroupdlg.src b/sc/source/ui/dbgui/dpgroupdlg.src
new file mode 100644
index 000000000000..84a27faf867c
--- /dev/null
+++ b/sc/source/ui/dbgui/dpgroupdlg.src
@@ -0,0 +1,286 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "dpgroupdlg.hrc"
+
+// ----------------------------------------------------------------------------
+
+ModalDialog RID_SCDLG_DPNUMGROUP
+{
+ Size = MAP_APPFONT ( 220 , 110 ) ;
+ HelpId = HID_SC_DPNUMGROUP ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ Hide = TRUE ;
+ FixedLine FL_START
+ {
+ Pos = MAP_APPFONT ( 6, 3 ) ;
+ Size = MAP_APPFONT ( 152, 8 ) ;
+ Text [ en-US ] = "Start" ;
+ };
+ RadioButton RB_AUTOSTART
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_DPNUMGROUP:RB_AUTOSTART";
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Automatically" ;
+ };
+ RadioButton RB_MANSTART
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_DPNUMGROUP:RB_MANSTART";
+ Pos = MAP_APPFONT ( 12 , 28 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Manually at" ;
+ };
+ Edit ED_START
+ {
+ HelpID = "sc:Edit:RID_SCDLG_DPNUMGROUP:ED_START";
+ Pos = MAP_APPFONT ( 94 , 26 ) ;
+ Size = MAP_APPFONT ( 58 , 12 ) ;
+ TabStop = TRUE ;
+ Border = TRUE ;
+ };
+ FixedLine FL_END
+ {
+ Pos = MAP_APPFONT ( 6 , 42 ) ;
+ Size = MAP_APPFONT ( 152 , 8 ) ;
+ Text [ en-US ] = "End" ;
+ };
+ RadioButton RB_AUTOEND
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_DPNUMGROUP:RB_AUTOEND";
+ Pos = MAP_APPFONT ( 12 , 53 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "A~utomatically" ;
+ };
+ RadioButton RB_MANEND
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_DPNUMGROUP:RB_MANEND";
+ Pos = MAP_APPFONT ( 12 , 67 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Ma~nually at" ;
+ };
+ Edit ED_END
+ {
+ HelpID = "sc:Edit:RID_SCDLG_DPNUMGROUP:ED_END";
+ Pos = MAP_APPFONT ( 94 , 65 ) ;
+ Size = MAP_APPFONT ( 58 , 12 ) ;
+ TabStop = TRUE ;
+ Border = TRUE ;
+ };
+ FixedLine FL_BY
+ {
+ Pos = MAP_APPFONT ( 6 , 81 ) ;
+ Size = MAP_APPFONT ( 152 , 8 ) ;
+ Text [ en-US ] = "~Group by" ;
+ };
+ Edit ED_BY
+ {
+ HelpID = "sc:Edit:RID_SCDLG_DPNUMGROUP:ED_BY";
+ Pos = MAP_APPFONT ( 94 , 92 ) ;
+ Size = MAP_APPFONT ( 58 , 12 ) ;
+ TabStop = TRUE ;
+ Border = TRUE ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 164 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 164 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 164 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ Text [ en-US ] = "Grouping" ;
+} ;
+
+// ----------------------------------------------------------------------------
+
+ModalDialog RID_SCDLG_DPDATEGROUP
+{
+ Size = MAP_APPFONT ( 220 , 180 ) ;
+ HelpId = HID_SC_DPDATEGROUP ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ Hide = TRUE ;
+ FixedLine FL_START
+ {
+ Pos = MAP_APPFONT ( 6, 3 ) ;
+ Size = MAP_APPFONT ( 152, 8 ) ;
+ Text [ en-US ] = "Start" ;
+ };
+ RadioButton RB_AUTOSTART
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_DPDATEGROUP:RB_AUTOSTART";
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Automatically" ;
+ };
+ RadioButton RB_MANSTART
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_DPDATEGROUP:RB_MANSTART";
+ Pos = MAP_APPFONT ( 12 , 28 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Manually at" ;
+ };
+ DateField ED_START
+ {
+ HelpID = "sc:DateField:RID_SCDLG_DPDATEGROUP:ED_START";
+ Pos = MAP_APPFONT ( 94 , 26 ) ;
+ Size = MAP_APPFONT ( 58 , 12 ) ;
+ TabStop = TRUE ;
+ Border = TRUE ;
+ };
+ FixedLine FL_END
+ {
+ Pos = MAP_APPFONT ( 6 , 42 ) ;
+ Size = MAP_APPFONT ( 152 , 8 ) ;
+ Text [ en-US ] = "End" ;
+ };
+ RadioButton RB_AUTOEND
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_DPDATEGROUP:RB_AUTOEND";
+ Pos = MAP_APPFONT ( 12 , 53 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "A~utomatically" ;
+ };
+ RadioButton RB_MANEND
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_DPDATEGROUP:RB_MANEND";
+ Pos = MAP_APPFONT ( 12 , 67 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Ma~nually at" ;
+ };
+ DateField ED_END
+ {
+ HelpID = "sc:DateField:RID_SCDLG_DPDATEGROUP:ED_END";
+ Pos = MAP_APPFONT ( 94 , 65 ) ;
+ Size = MAP_APPFONT ( 58 , 12 ) ;
+ TabStop = TRUE ;
+ Border = TRUE ;
+ };
+ FixedLine FL_BY
+ {
+ Pos = MAP_APPFONT ( 6 , 81 ) ;
+ Size = MAP_APPFONT ( 152 , 8 ) ;
+ Text [ en-US ] = "Group by" ;
+ };
+ RadioButton RB_NUMDAYS
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_DPDATEGROUP:RB_NUMDAYS";
+ Pos = MAP_APPFONT ( 12 , 94 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Number of ~days" ;
+ };
+ RadioButton RB_UNITS
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_DPDATEGROUP:RB_UNITS";
+ Pos = MAP_APPFONT ( 12 , 110 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Intervals" ;
+ };
+ NumericField ED_NUMDAYS
+ {
+ HelpID = "sc:NumericField:RID_SCDLG_DPDATEGROUP:ED_NUMDAYS";
+ Pos = MAP_APPFONT ( 94, 92 ) ;
+ Size = MAP_APPFONT ( 35, 12 ) ;
+ TabStop = TRUE ;
+ Border = TRUE ;
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ Minimum = 1 ;
+ Maximum = 32767 ;
+ SpinSize = 1 ;
+ };
+ Control LB_UNITS
+ {
+ Pos = MAP_APPFONT( 94, 110 );
+ Size = MAP_APPFONT( 58, 64 );
+ TabStop = TRUE;
+ Border = TRUE;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 164 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 164 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 164 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ StringArray STR_UNITS
+ {
+ ItemList [ en-US ] =
+ {
+ < "Seconds" ; Default ; > ;
+ < "Minutes" ; Default ; > ;
+ < "Hours" ; Default ; > ;
+ < "Days" ; Default ; > ;
+ < "Months" ; Default ; > ;
+ < "Quarters" ; Default ; > ;
+ < "Years" ; Default ; > ;
+ } ;
+ } ;
+ Text [ en-US ] = "Grouping" ;
+} ;
+
+// ----------------------------------------------------------------------------
+
diff --git a/sc/source/ui/dbgui/expftext.cxx b/sc/source/ui/dbgui/expftext.cxx
new file mode 100644
index 000000000000..405a18fcc004
--- /dev/null
+++ b/sc/source/ui/dbgui/expftext.cxx
@@ -0,0 +1,95 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "expftext.hxx"
+#include <vcl/help.hxx>
+
+/*************************************************************************
+#* Member: ScExpandedFixedText Datum:18.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: MD_Test
+#*
+#* Funktion: Konstruktor der Klasse SvxCtrDial
+#*
+#* Input: Parent- Window, Resource ID
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+ScExpandedFixedText::ScExpandedFixedText( Window* pParent,
+ const ResId& rResId) :
+ FixedText( pParent, rResId )
+{
+
+}
+
+/*************************************************************************
+#* Member: RequestHelp Datum:18.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScExpandedFixedText
+#*
+#* Funktion: Die Methode wird gerufen, um Hilfe fuer das Fenster
+#* anzuzeigen. Zeigt das Fenster einen gekuerzten Text
+#* an, so wird selbiger in voller Laenge angezeigt.
+#*
+#* Input: HelpEvent
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScExpandedFixedText::RequestHelp(const HelpEvent& rEvt)
+{
+ String aTxtStr = GetText();
+ long nTxtWidth = GetTextWidth(aTxtStr);
+ if ( ( rEvt.GetMode() & HELPMODE_QUICK ) == HELPMODE_QUICK &&
+ nTxtWidth > GetSizePixel().Width())
+ {
+ Point aShowPoint = OutputToScreenPixel(Point(0,0));
+ long nTxtHeight = GetTextHeight();
+
+ Help::ShowQuickHelp( this,
+ Rectangle( aShowPoint, Size(nTxtWidth,nTxtHeight) ), aTxtStr,
+ QUICKHELP_TOP|QUICKHELP_LEFT );
+ }
+ else
+ {
+ FixedText::RequestHelp( rEvt );
+ }
+}
+
+
+
+
diff --git a/sc/source/ui/dbgui/fieldwnd.cxx b/sc/source/ui/dbgui/fieldwnd.cxx
new file mode 100644
index 000000000000..d4b477cd4b33
--- /dev/null
+++ b/sc/source/ui/dbgui/fieldwnd.cxx
@@ -0,0 +1,776 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include <vcl/virdev.hxx>
+#include <vcl/decoview.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/mnemonic.hxx>
+#include <vcl/help.hxx>
+#include <tools/debug.hxx>
+
+#include "fieldwnd.hxx"
+#include "pvlaydlg.hxx"
+#include "pvglob.hxx"
+#include "AccessibleDataPilotControl.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+
+const size_t INVALID_INDEX = static_cast< size_t >( -1 );
+
+//===================================================================
+
+ScDPFieldWindow::ScDPFieldWindow(
+ ScDPLayoutDlg* pDialog,
+ const ResId& rResId,
+ ScDPFieldType eFieldType,
+ FixedText* pFtFieldCaption ) :
+ Control( pDialog, rResId ),
+ pDlg( pDialog ),
+ pFtCaption( pFtFieldCaption ),
+ eType( eFieldType ),
+ nFieldSelected( 0 ),
+ pAccessible( NULL )
+{
+ Init();
+ if (eType != TYPE_SELECT && pFtCaption)
+ aName = MnemonicGenerator::EraseAllMnemonicChars( pFtCaption->GetText() );
+}
+
+ScDPFieldWindow::ScDPFieldWindow(
+ ScDPLayoutDlg* pDialog,
+ const ResId& rResId,
+ ScDPFieldType eFieldType,
+ const String& rName ) :
+ Control( pDialog, rResId ),
+ aName(rName),
+ pDlg( pDialog ),
+ pFtCaption( NULL ),
+ eType( eFieldType ),
+ nFieldSelected( 0 ),
+ pAccessible( NULL )
+{
+ Init();
+}
+
+void ScDPFieldWindow::Init()
+{
+ aWndRect = Rectangle( GetPosPixel(), GetSizePixel() );
+ nFieldSize = (eType == TYPE_SELECT) ? PAGE_SIZE : ((eType == TYPE_PAGE) ? MAX_PAGEFIELDS : MAX_FIELDS);
+
+ if( pFtCaption )
+ {
+ Size aWinSize( aWndRect.GetSize() );
+ Size aTextSize( GetTextWidth( pFtCaption->GetText() ), GetTextHeight() );
+ aTextPos.X() = (aWinSize.Width() - aTextSize.Width()) / 2;
+ aTextPos.Y() = (aWinSize.Height() - aTextSize.Height()) / 2;
+ }
+
+ GetStyleSettings();
+}
+
+__EXPORT ScDPFieldWindow::~ScDPFieldWindow()
+{
+ if (pAccessible)
+ {
+ com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
+ if (xTempAcc.is())
+ pAccessible->dispose();
+ }
+}
+
+//-------------------------------------------------------------------
+
+void ScDPFieldWindow::GetStyleSettings()
+{
+ const StyleSettings& rStyleSet = GetSettings().GetStyleSettings();
+ aFaceColor = rStyleSet.GetFaceColor();
+ aWinColor = rStyleSet.GetWindowColor();
+ aTextColor = rStyleSet.GetButtonTextColor();
+ aWinTextColor = rStyleSet.GetWindowTextColor();
+}
+
+//-------------------------------------------------------------------
+
+Point ScDPFieldWindow::GetFieldPosition( size_t nIndex ) const
+{
+ Point aPos;
+ switch( eType )
+ {
+ case TYPE_PAGE:
+ aPos.X() = OWIDTH * (nIndex % (MAX_PAGEFIELDS / 2));
+ aPos.Y() = OHEIGHT * (nIndex / (MAX_PAGEFIELDS / 2));
+ break;
+ case TYPE_COL:
+ aPos.X() = OWIDTH * (nIndex % (MAX_FIELDS / 2));
+ aPos.Y() = OHEIGHT * (nIndex / (MAX_FIELDS / 2));
+ break;
+ case TYPE_ROW:
+ case TYPE_DATA:
+ aPos.X() = 0;
+ aPos.Y() = OHEIGHT * nIndex;
+ break;
+ case TYPE_SELECT:
+ aPos.X() = (OWIDTH + SSPACE) * (nIndex / LINE_SIZE);
+ aPos.Y() = (OHEIGHT + SSPACE) * (nIndex % LINE_SIZE);
+ break;
+ }
+ return aPos;
+}
+
+Size ScDPFieldWindow::GetFieldSize() const
+{
+ return Size( (eType == TYPE_DATA) ? GetSizePixel().Width() : OWIDTH, OHEIGHT );
+}
+
+Point ScDPFieldWindow::GetLastPosition() const
+{
+ return OutputToScreenPixel( GetFieldPosition( nFieldSize - 1 ) );
+}
+
+bool ScDPFieldWindow::GetFieldIndex( const Point& rPos, size_t& rnIndex ) const
+{
+ rnIndex = INVALID_INDEX;
+ if( (rPos.X() >= 0) && (rPos.Y() >= 0) )
+ {
+ switch( eType )
+ {
+ case TYPE_ROW:
+ case TYPE_DATA:
+ rnIndex = rPos.Y() / OHEIGHT;
+ break;
+ case TYPE_PAGE:
+ {
+ size_t nRow = rPos.Y() / OHEIGHT;
+ size_t nCol = rPos.X() / OWIDTH;
+ rnIndex = nRow * MAX_PAGEFIELDS / 2 + nCol;
+ }
+ break;
+ case TYPE_COL:
+ {
+ size_t nRow = rPos.Y() / OHEIGHT;
+ size_t nCol = rPos.X() / OWIDTH;
+ rnIndex = nRow * MAX_FIELDS / 2 + nCol;
+ }
+ break;
+ case TYPE_SELECT:
+ {
+ size_t nRow = rPos.Y() / (OHEIGHT + SSPACE);
+ size_t nCol = rPos.X() / (OWIDTH + SSPACE);
+ // is not between controls?
+ if( (rPos.Y() % (OHEIGHT + SSPACE) < OHEIGHT) && (rPos.X() % (OWIDTH + SSPACE) < OWIDTH) )
+ rnIndex = nCol * LINE_SIZE + nRow;
+ }
+ break;
+ }
+ }
+ return IsValidIndex( rnIndex );
+}
+
+//-------------------------------------------------------------------
+
+void ScDPFieldWindow::DrawBackground( OutputDevice& rDev )
+{
+ Point aPos0;
+ Size aSize( GetSizePixel() );
+
+ if ( eType == TYPE_SELECT )
+ {
+ rDev.SetLineColor();
+ rDev.SetFillColor( aFaceColor );
+ rDev.DrawRect( Rectangle( aPos0, aSize ) );
+ }
+ else
+ {
+ rDev.SetLineColor( aWinTextColor );
+ rDev.SetFillColor( aWinColor );
+ rDev.DrawRect( Rectangle( aPos0, aSize ) );
+
+ rDev.SetTextColor( aWinTextColor );
+
+ /* Draw the caption text. This needs some special handling, because we
+ support hard line breaks here. This part will draw each line of the
+ text for itself. */
+
+ xub_StrLen nTokenCnt = GetText().GetTokenCount( '\n' );
+ long nY = (aSize.Height() - nTokenCnt * rDev.GetTextHeight()) / 2;
+ for( xub_StrLen nToken = 0, nStringIx = 0; nToken < nTokenCnt; ++nToken )
+ {
+ String aLine( GetText().GetToken( 0, '\n', nStringIx ) );
+ Point aLinePos( (aSize.Width() - rDev.GetCtrlTextWidth( aLine )) / 2, nY );
+ rDev.DrawCtrlText( aLinePos, aLine );
+ nY += rDev.GetTextHeight();
+ }
+ }
+}
+
+void ScDPFieldWindow::DrawField(
+ OutputDevice& rDev, const Rectangle& rRect, FieldString& rText, bool bFocus )
+{
+ VirtualDevice aVirDev( rDev );
+ // #i97623# VirtualDevice is always LTR while other windows derive direction from parent
+ aVirDev.EnableRTL( IsRTLEnabled() );
+
+ String aText = rText.first;
+ Size aDevSize( rRect.GetSize() );
+ long nWidth = aDevSize.Width();
+ long nHeight = aDevSize.Height();
+ long nLabelWidth = rDev.GetTextWidth( aText );
+ long nLabelHeight = rDev.GetTextHeight();
+
+ // #i31600# if text is too long, cut and add ellipsis
+ rText.second = nLabelWidth + 6 <= nWidth;
+ if( !rText.second )
+ {
+ xub_StrLen nMinLen = 0;
+ xub_StrLen nMaxLen = aText.Len();
+ bool bFits = false;
+ do
+ {
+ xub_StrLen nCurrLen = (nMinLen + nMaxLen) / 2;
+ aText = String( rText.first, 0, nCurrLen ).AppendAscii( "..." );
+ nLabelWidth = rDev.GetTextWidth( aText );
+ bFits = nLabelWidth + 6 <= nWidth;
+ (bFits ? nMinLen : nMaxLen) = nCurrLen;
+ }
+ while( !bFits || (nMinLen + 1 < nMaxLen) );
+ }
+ Point aLabelPos( (nWidth - nLabelWidth) / 2, ::std::max< long >( (nHeight - nLabelHeight) / 2, 3 ) );
+
+ aVirDev.SetOutputSizePixel( aDevSize );
+ aVirDev.SetFont( rDev.GetFont() );
+ DecorationView aDecoView( &aVirDev );
+ aDecoView.DrawButton( Rectangle( Point( 0, 0 ), aDevSize ), bFocus ? BUTTON_DRAW_DEFAULT : 0 );
+ aVirDev.SetTextColor( aTextColor );
+ aVirDev.DrawText( aLabelPos, aText );
+ rDev.DrawBitmap( rRect.TopLeft(), aVirDev.GetBitmap( Point( 0, 0 ), aDevSize ) );
+}
+
+void ScDPFieldWindow::Redraw()
+{
+ VirtualDevice aVirDev;
+ // #i97623# VirtualDevice is always LTR while other windows derive direction from parent
+ aVirDev.EnableRTL( IsRTLEnabled() );
+ aVirDev.SetMapMode( MAP_PIXEL );
+
+ Point aPos0;
+ Size aSize( GetSizePixel() );
+ Font aFont( GetFont() ); // Font vom Window
+ aFont.SetTransparent( TRUE );
+ aVirDev.SetFont( aFont );
+ aVirDev.SetOutputSizePixel( aSize );
+
+ DrawBackground( aVirDev );
+
+ if( !aFieldArr.empty() && (nFieldSelected >= aFieldArr.size()) )
+ nFieldSelected = aFieldArr.size() - 1;
+ Rectangle aFieldRect( aPos0, GetFieldSize() );
+ for( size_t nIx = 0; nIx < aFieldArr.size(); ++nIx )
+ {
+ aFieldRect.SetPos( GetFieldPosition( nIx ) );
+ bool bFocus = HasFocus() && (nIx == nFieldSelected);
+ DrawField( aVirDev, aFieldRect, aFieldArr[ nIx ], bFocus );
+ }
+ DrawBitmap( aPos0, aVirDev.GetBitmap( aPos0, aSize ) );
+
+ if( HasFocus() && (nFieldSelected < aFieldArr.size()) )
+ {
+ long nFieldWidth = aFieldRect.GetWidth();
+ long nSelectionWidth = Min( GetTextWidth( aFieldArr[ nFieldSelected ].first ) + 4, nFieldWidth - 6 );
+ Rectangle aSelection(
+ GetFieldPosition( nFieldSelected ) + Point( (nFieldWidth - nSelectionWidth) / 2, 3 ),
+ Size( nSelectionWidth, aFieldRect.GetHeight() - 6 ) );
+ InvertTracking( aSelection, SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
+ }
+
+ UpdateStyle();
+}
+
+void ScDPFieldWindow::UpdateStyle()
+{
+ WinBits nMask = ~(WB_TABSTOP | WB_NOTABSTOP);
+ SetStyle( (GetStyle() & nMask) | (IsEmpty() ? WB_NOTABSTOP : WB_TABSTOP) );
+}
+
+//-------------------------------------------------------------------
+
+bool ScDPFieldWindow::IsValidIndex( size_t nIndex ) const
+{
+ return nIndex < nFieldSize;
+}
+
+bool ScDPFieldWindow::IsExistingIndex( size_t nIndex ) const
+{
+ return nIndex < aFieldArr.size();
+}
+
+bool ScDPFieldWindow::IsShortenedText( size_t nIndex ) const
+{
+ return (nIndex < aFieldArr.size()) && !aFieldArr[ nIndex ].second;
+}
+
+size_t ScDPFieldWindow::CalcNewFieldIndex( SCsCOL nDX, SCsROW nDY ) const
+{
+ size_t nNewField = nFieldSelected;
+ switch( eType )
+ {
+ case TYPE_PAGE:
+ nNewField += static_cast<SCsCOLROW>(nDX) + nDY * MAX_PAGEFIELDS / 2;
+ break;
+ case TYPE_COL:
+ nNewField += static_cast<SCsCOLROW>(nDX) + nDY * MAX_FIELDS / 2;
+ break;
+ case TYPE_ROW:
+ case TYPE_DATA:
+ nNewField += nDY;
+ break;
+ case TYPE_SELECT:
+ nNewField += static_cast<SCsCOLROW>(nDX) * LINE_SIZE + nDY;
+ break;
+ }
+
+ return IsExistingIndex( nNewField ) ? nNewField : nFieldSelected;
+}
+
+void ScDPFieldWindow::SetSelection( size_t nIndex )
+{
+ if( !aFieldArr.empty() )
+ {
+ if( nFieldSelected >= aFieldArr.size() )
+ nFieldSelected = aFieldArr.size() - 1;
+ if( nFieldSelected != nIndex )
+ {
+ sal_Int32 nOldSelected(nFieldSelected);
+ nFieldSelected = nIndex;
+ Redraw();
+
+ if (pAccessible && HasFocus())
+ {
+ com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
+ if (xTempAcc.is())
+ pAccessible->FieldFocusChange(nOldSelected, nFieldSelected);
+ else
+ pAccessible = NULL;
+ }
+ }
+ }
+}
+
+void ScDPFieldWindow::SetSelectionHome()
+{
+ if( !aFieldArr.empty() )
+ {
+ if( eType == TYPE_SELECT )
+ pDlg->NotifyMoveSlider( KEY_HOME );
+ SetSelection( 0 );
+ }
+}
+
+void ScDPFieldWindow::SetSelectionEnd()
+{
+ if( !aFieldArr.empty() )
+ {
+ if( eType == TYPE_SELECT )
+ pDlg->NotifyMoveSlider( KEY_END );
+ SetSelection( aFieldArr.size() - 1 );
+ }
+}
+
+void ScDPFieldWindow::MoveSelection( USHORT nKeyCode, SCsCOL nDX, SCsROW nDY )
+{
+ size_t nNewIndex = CalcNewFieldIndex( nDX, nDY );
+ if( (eType == TYPE_SELECT) && (nNewIndex == nFieldSelected) )
+ {
+ if( pDlg->NotifyMoveSlider( nKeyCode ) )
+ {
+ switch( nKeyCode )
+ {
+ case KEY_UP: nNewIndex += (LINE_SIZE - 1); break;
+ case KEY_DOWN: nNewIndex -= (LINE_SIZE - 1); break;
+ }
+ }
+ }
+ SetSelection( nNewIndex );
+}
+
+void ScDPFieldWindow::ModifySelectionOffset( long nOffsetDiff )
+{
+ nFieldSelected -= nOffsetDiff;
+ Redraw();
+}
+
+void ScDPFieldWindow::SelectNext()
+{
+ if( eType == TYPE_SELECT )
+ MoveSelection( KEY_DOWN, 0, 1 );
+}
+
+void ScDPFieldWindow::GrabFocusWithSel( size_t nIndex )
+{
+ SetSelection( nIndex );
+ if( !HasFocus() )
+ GrabFocus();
+}
+
+void ScDPFieldWindow::MoveField( size_t nDestIndex )
+{
+ if( nDestIndex != nFieldSelected )
+ {
+ // "recycle" existing functionality
+ pDlg->NotifyMouseButtonDown( eType, nFieldSelected );
+ pDlg->NotifyMouseButtonUp( OutputToScreenPixel( GetFieldPosition( nDestIndex ) ) );
+ }
+}
+
+void ScDPFieldWindow::MoveFieldRel( SCsCOL nDX, SCsROW nDY )
+{
+ MoveField( CalcNewFieldIndex( nDX, nDY ) );
+}
+
+//-------------------------------------------------------------------
+
+void __EXPORT ScDPFieldWindow::Paint( const Rectangle& /* rRect */ )
+{
+ // #124828# hiding the caption is now done from StateChanged
+ Redraw();
+}
+
+void ScDPFieldWindow::UseMnemonic()
+{
+ // Now the FixedText has its mnemonic char. Grab the text and hide the
+ // FixedText to be able to handle tabstop and mnemonics separately.
+ if( pFtCaption )
+ {
+ SetText( pFtCaption->GetText() );
+ pFtCaption->Hide();
+ }
+
+ // after reading the mnemonics, tab stop style bits can be updated
+ UpdateStyle();
+}
+
+void __EXPORT ScDPFieldWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ GetStyleSettings();
+ Redraw();
+ }
+ Control::DataChanged( rDCEvt );
+}
+
+void __EXPORT ScDPFieldWindow::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if( rMEvt.IsLeft() )
+ {
+ size_t nIndex = 0;
+ if( GetFieldIndex( rMEvt.GetPosPixel(), nIndex ) && IsExistingIndex( nIndex ) )
+ {
+ GrabFocusWithSel( nIndex );
+
+ if( rMEvt.GetClicks() == 1 )
+ {
+ PointerStyle ePtr = pDlg->NotifyMouseButtonDown( eType, nIndex );
+ CaptureMouse();
+ SetPointer( Pointer( ePtr ) );
+ }
+ else
+ pDlg->NotifyDoubleClick( eType, nIndex );
+ }
+ }
+}
+
+void __EXPORT ScDPFieldWindow::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ if( rMEvt.IsLeft() )
+ {
+ if( rMEvt.GetClicks() == 1 )
+ {
+ pDlg->NotifyMouseButtonUp( OutputToScreenPixel( rMEvt.GetPosPixel() ) );
+ SetPointer( Pointer( POINTER_ARROW ) );
+ }
+
+ if( IsMouseCaptured() )
+ ReleaseMouse();
+ }
+}
+
+void __EXPORT ScDPFieldWindow::MouseMove( const MouseEvent& rMEvt )
+{
+ if( IsMouseCaptured() )
+ {
+ PointerStyle ePtr = pDlg->NotifyMouseMove( OutputToScreenPixel( rMEvt.GetPosPixel() ) );
+ SetPointer( Pointer( ePtr ) );
+ }
+ size_t nIndex = 0;
+ if( GetFieldIndex( rMEvt.GetPosPixel(), nIndex ) && IsShortenedText( nIndex ) )
+ {
+ Point aPos = OutputToScreenPixel( rMEvt.GetPosPixel() );
+ Rectangle aRect( aPos, GetSizePixel() );
+ String aHelpText = GetFieldText(nIndex);
+ Help::ShowQuickHelp( this, aRect, aHelpText );
+ }
+}
+
+void __EXPORT ScDPFieldWindow::KeyInput( const KeyEvent& rKEvt )
+{
+ const KeyCode& rKeyCode = rKEvt.GetKeyCode();
+ USHORT nCode = rKeyCode.GetCode();
+ BOOL bKeyEvaluated = FALSE;
+
+ if( rKeyCode.IsMod1() && (eType != TYPE_SELECT) )
+ {
+ bKeyEvaluated = TRUE;
+ switch( nCode )
+ {
+ case KEY_UP: MoveFieldRel( 0, -1 ); break;
+ case KEY_DOWN: MoveFieldRel( 0, 1 ); break;
+ case KEY_LEFT: MoveFieldRel( -1, 0 ); break;
+ case KEY_RIGHT: MoveFieldRel( 1, 0 ); break;
+ case KEY_HOME: MoveField( 0 ); break;
+ case KEY_END: MoveField( aFieldArr.size() - 1 ); break;
+ default: bKeyEvaluated = FALSE;
+ }
+ }
+ else
+ {
+ bKeyEvaluated = TRUE;
+ switch( nCode )
+ {
+ case KEY_UP: MoveSelection( nCode, 0, -1 ); break;
+ case KEY_DOWN: MoveSelection( nCode, 0, 1 ); break;
+ case KEY_LEFT: MoveSelection( nCode, -1, 0 ); break;
+ case KEY_RIGHT: MoveSelection( nCode, 1, 0 ); break;
+ case KEY_HOME: SetSelectionHome(); break;
+ case KEY_END: SetSelectionEnd(); break;
+ case KEY_DELETE:
+ pDlg->NotifyRemoveField( eType, nFieldSelected ); break;
+ default: bKeyEvaluated = FALSE;
+ }
+ }
+
+ if( !bKeyEvaluated )
+ Control::KeyInput( rKEvt );
+}
+
+void __EXPORT ScDPFieldWindow::GetFocus()
+{
+ Control::GetFocus();
+ Redraw();
+ if( GetGetFocusFlags() & GETFOCUS_MNEMONIC ) // move field on shortcut
+ pDlg->NotifyMoveField( eType );
+ else // else change focus
+ pDlg->NotifyFieldFocus( eType, TRUE );
+
+ if (pAccessible)
+ {
+ com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
+ if (xTempAcc.is())
+ pAccessible->GotFocus();
+ else
+ pAccessible = NULL;
+ }
+}
+
+void __EXPORT ScDPFieldWindow::LoseFocus()
+{
+ Control::LoseFocus();
+ Redraw();
+ pDlg->NotifyFieldFocus( eType, FALSE );
+
+ if (pAccessible)
+ {
+ com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
+ if (xTempAcc.is())
+ pAccessible->LostFocus();
+ else
+ pAccessible = NULL;
+ }
+}
+
+//-------------------------------------------------------------------
+
+void ScDPFieldWindow::AddField( const String& rText, size_t nNewIndex )
+{
+ DBG_ASSERT( nNewIndex == aFieldArr.size(), "ScDPFieldWindow::AddField - invalid index" );
+ if( IsValidIndex( nNewIndex ) )
+ {
+ aFieldArr.push_back( FieldString( rText, true ) );
+ if (pAccessible)
+ {
+ com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
+ if (xTempAcc.is())
+ pAccessible->AddField(nNewIndex);
+ else
+ pAccessible = NULL;
+ }
+ }
+}
+
+void ScDPFieldWindow::DelField( size_t nDelIndex )
+{
+ if( IsExistingIndex( nDelIndex ) )
+ {
+ if (pAccessible) // before decrement fieldcount
+ {
+ com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
+ if (xTempAcc.is())
+ pAccessible->RemoveField(nDelIndex);
+ else
+ pAccessible = NULL;
+ }
+ aFieldArr.erase( aFieldArr.begin() + nDelIndex );
+ Redraw();
+ }
+}
+
+void ScDPFieldWindow::ClearFields()
+{
+ if( eType == TYPE_SELECT || eType == TYPE_PAGE || eType == TYPE_COL || eType == TYPE_ROW || eType == TYPE_DATA)
+ {
+ com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
+ if (!xTempAcc.is() && pAccessible)
+ pAccessible = NULL;
+ if (pAccessible)
+ for( size_t nIdx = aFieldArr.size(); nIdx > 0; --nIdx )
+ pAccessible->RemoveField( nIdx - 1 );
+
+ aFieldArr.clear();
+ }
+}
+
+void ScDPFieldWindow::SetFieldText( const String& rText, size_t nIndex )
+{
+ if( IsExistingIndex( nIndex ) )
+ {
+ aFieldArr[ nIndex ] = FieldString( rText, true );
+ Redraw();
+
+ if (pAccessible)
+ {
+ com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
+ if (xTempAcc.is())
+ pAccessible->FieldNameChange(nIndex);
+ else
+ pAccessible = NULL;
+ }
+ }
+}
+
+const String& ScDPFieldWindow::GetFieldText( size_t nIndex ) const
+{
+ if( IsExistingIndex( nIndex ) )
+ return aFieldArr[ nIndex ].first;
+ return EMPTY_STRING;
+}
+
+//-------------------------------------------------------------------
+
+bool ScDPFieldWindow::AddField( const String& rText, const Point& rPos, size_t& rnIndex )
+{
+ if ( aFieldArr.size() == nFieldSize )
+ return FALSE;
+
+ size_t nNewIndex = 0;
+ if( GetFieldIndex( rPos, nNewIndex ) )
+ {
+ if( nNewIndex > aFieldArr.size() )
+ nNewIndex = aFieldArr.size();
+
+ aFieldArr.insert( aFieldArr.begin() + nNewIndex, FieldString( rText, true ) );
+ nFieldSelected = nNewIndex;
+ Redraw();
+ rnIndex = nNewIndex;
+
+ if (pAccessible)
+ {
+ com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
+ if (xTempAcc.is())
+ pAccessible->AddField(nNewIndex);
+ else
+ pAccessible = NULL;
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
+void ScDPFieldWindow::GetExistingIndex( const Point& rPos, size_t& rnIndex )
+{
+ if( !aFieldArr.empty() && (eType != TYPE_SELECT) && GetFieldIndex( rPos, rnIndex ) )
+ {
+ if( rnIndex >= aFieldArr.size() )
+ rnIndex = aFieldArr.size() - 1;
+ }
+ else
+ rnIndex = 0;
+}
+
+String ScDPFieldWindow::GetDescription() const
+{
+ String sDescription;
+ switch( eType )
+ {
+ case TYPE_COL:
+ sDescription = ScResId(STR_ACC_DATAPILOT_COL_DESCR);
+ break;
+ case TYPE_ROW:
+ sDescription = ScResId(STR_ACC_DATAPILOT_ROW_DESCR);
+ break;
+ case TYPE_DATA:
+ sDescription = ScResId(STR_ACC_DATAPILOT_DATA_DESCR);
+ break;
+ case TYPE_SELECT:
+ sDescription = ScResId(STR_ACC_DATAPILOT_SEL_DESCR);
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ return sDescription;
+}
+
+::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ScDPFieldWindow::CreateAccessible()
+{
+ pAccessible =
+ new ScAccessibleDataPilotControl(GetAccessibleParentWindow()->GetAccessible(), this);
+
+ com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessible > xReturn = pAccessible;
+
+ pAccessible->Init();
+ xAccessible = xReturn;
+
+ return xReturn;
+}
+
+//===================================================================
+
diff --git a/sc/source/ui/dbgui/filtdlg.cxx b/sc/source/ui/dbgui/filtdlg.cxx
new file mode 100644
index 000000000000..b5dd2f3242c2
--- /dev/null
+++ b/sc/source/ui/dbgui/filtdlg.cxx
@@ -0,0 +1,1186 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+// INCLUDE -------------------------------------------------------------------
+#include <rangelst.hxx>
+#include <sfx2/dispatch.hxx>
+#include <vcl/waitobj.hxx>
+
+#include "uiitems.hxx"
+#include "dbcolect.hxx"
+#include "reffact.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "scresid.hxx"
+
+#include "foptmgr.hxx"
+
+#include "globstr.hrc"
+#include "filter.hrc"
+
+#define _FILTDLG_CXX
+#include "filtdlg.hxx"
+#undef _FILTDLG_CXX
+#include <vcl/msgbox.hxx>
+
+// DEFINE --------------------------------------------------------------------
+
+#define ERRORBOX(rid) ErrorBox( this, WinBits( WB_OK|WB_DEF_OK), \
+ ScGlobal::GetRscString(rid) ).Execute()
+
+
+//============================================================================
+// class ScFilterDlg
+
+//----------------------------------------------------------------------------
+
+ScFilterDlg::ScFilterDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ const SfxItemSet& rArgSet )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_FILTER ),
+ //
+ aFlCriteria ( this, ScResId( FL_CRITERIA ) ),
+ aLbConnect1 ( this, ScResId( LB_OP1 ) ),
+ aLbField1 ( this, ScResId( LB_FIELD1 ) ),
+ aLbCond1 ( this, ScResId( LB_COND1 ) ),
+ aEdVal1 ( this, ScResId( ED_VAL1 ) ),
+ aLbConnect2 ( this, ScResId( LB_OP2 ) ),
+ aLbField2 ( this, ScResId( LB_FIELD2 ) ),
+ aLbCond2 ( this, ScResId( LB_COND2 ) ),
+ aEdVal2 ( this, ScResId( ED_VAL2 ) ),
+ aLbConnect3 ( this, ScResId( LB_OP3 ) ),
+ aLbField3 ( this, ScResId( LB_FIELD3 ) ),
+ aLbCond3 ( this, ScResId( LB_COND3 ) ),
+ aEdVal3 ( this, ScResId( ED_VAL3 ) ),
+ aLbConnect4 ( this, ScResId( LB_OP4 ) ),
+ aLbField4 ( this, ScResId( LB_FIELD4 ) ),
+ aLbCond4 ( this, ScResId( LB_COND4 ) ),
+ aEdVal4 ( this, ScResId( ED_VAL4 ) ),
+ aFtConnect ( this, ScResId( FT_OP ) ),
+ aFtField ( this, ScResId( FT_FIELD ) ),
+ aFtCond ( this, ScResId( FT_COND ) ),
+ aFtVal ( this, ScResId( FT_VAL ) ),
+ aFlSeparator ( this, ScResId( FL_SEPARATOR ) ),
+ aScrollBar ( this, ScResId( LB_SCROLL ) ),
+ aFlOptions ( this, ScResId( FL_OPTIONS ) ),
+ aBtnMore ( this, ScResId( BTN_MORE ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ _INIT_COMMON_FILTER_RSCOBJS
+ aStrEmpty ( ScResId( SCSTR_EMPTY ) ),
+ aStrNotEmpty ( ScResId( SCSTR_NOTEMPTY ) ),
+ aStrRow ( ScResId( SCSTR_ROW ) ),
+ aStrColumn ( ScResId( SCSTR_COLUMN ) ),
+ //
+ pOptionsMgr ( NULL ),
+ nWhichQuery ( rArgSet.GetPool()->GetWhich( SID_QUERY ) ),
+ theQueryData ( ((const ScQueryItem&)
+ rArgSet.Get( nWhichQuery )).GetQueryData() ),
+ pOutItem ( NULL ),
+ pViewData ( NULL ),
+ pDoc ( NULL ),
+ nSrcTab ( 0 ),
+ nFieldCount ( 0 ),
+ bRefInputMode ( FALSE ),
+ pTimer ( NULL )
+{
+ for (USHORT i=0; i<=MAXCOL; i++)
+ pEntryLists[i] = NULL;
+ for (SCSIZE i=0;i<MAXQUERY;i++)
+ {
+ bRefreshExceptQuery[i]=FALSE;
+ }
+ aBtnMore.SetMoreText( String(ScResId( SCSTR_MOREBTN_MOREOPTIONS )) );
+ aBtnMore.SetLessText( String(ScResId( SCSTR_MOREBTN_FEWEROPTIONS )) );
+ Init( rArgSet );
+ FreeResource();
+
+ // Hack: RefInput-Kontrolle
+ pTimer = new Timer;
+ pTimer->SetTimeout( 50 ); // 50ms warten
+ pTimer->SetTimeoutHdl( LINK( this, ScFilterDlg, TimeOutHdl ) );
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScFilterDlg::~ScFilterDlg()
+{
+ for (USHORT i=0; i<=MAXCOL; i++)
+ delete pEntryLists[i];
+
+ delete pOptionsMgr;
+ delete pOutItem;
+
+ // Hack: RefInput-Kontrolle
+ pTimer->Stop();
+ delete pTimer;
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScFilterDlg::Init( const SfxItemSet& rArgSet )
+{
+ const ScQueryItem& rQueryItem = (const ScQueryItem&)
+ rArgSet.Get( nWhichQuery );
+
+ aBtnOk.SetClickHdl ( LINK( this, ScFilterDlg, EndDlgHdl ) );
+ aBtnCancel.SetClickHdl ( LINK( this, ScFilterDlg, EndDlgHdl ) );
+ aBtnMore.SetClickHdl ( LINK( this, ScFilterDlg, MoreClickHdl ) );
+ aBtnHeader.SetClickHdl ( LINK( this, ScFilterDlg, CheckBoxHdl ) );
+ aBtnCase.SetClickHdl ( LINK( this, ScFilterDlg, CheckBoxHdl ) );
+ //
+ aLbField1.SetSelectHdl ( LINK( this, ScFilterDlg, LbSelectHdl ) );
+ aLbField2.SetSelectHdl ( LINK( this, ScFilterDlg, LbSelectHdl ) );
+ aLbField3.SetSelectHdl ( LINK( this, ScFilterDlg, LbSelectHdl ) );
+ aLbField4.SetSelectHdl ( LINK( this, ScFilterDlg, LbSelectHdl ) );
+ aLbConnect1.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
+ aLbConnect2.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
+ aLbConnect3.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
+ aLbConnect4.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
+
+ aLbCond1.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
+ aLbCond2.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
+ aLbCond3.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
+ aLbCond4.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
+
+ pViewData = rQueryItem.GetViewData();
+ pDoc = pViewData ? pViewData->GetDocument() : NULL;
+ nSrcTab = pViewData ? pViewData->GetTabNo() : static_cast<SCTAB>(0);
+
+ // fuer leichteren Zugriff:
+ aFieldLbArr [0] = &aLbField1;
+ aFieldLbArr [1] = &aLbField2;
+ aFieldLbArr [2] = &aLbField3;
+ aFieldLbArr [3] = &aLbField4;
+ aValueEdArr [0] = &aEdVal1;
+ aValueEdArr [1] = &aEdVal2;
+ aValueEdArr [2] = &aEdVal3;
+ aValueEdArr [3] = &aEdVal4;
+ aCondLbArr [0] = &aLbCond1;
+ aCondLbArr [1] = &aLbCond2;
+ aCondLbArr [2] = &aLbCond3;
+ aCondLbArr [3] = &aLbCond4;
+ aConnLbArr [0] = &aLbConnect1;
+ aConnLbArr [1] = &aLbConnect2;
+ aConnLbArr [2] = &aLbConnect3;
+ aConnLbArr [3] = &aLbConnect4;
+
+ // Optionen initialisieren lassen:
+
+ pOptionsMgr = new ScFilterOptionsMgr(
+ this,
+ pViewData,
+ theQueryData,
+ aBtnMore,
+ aBtnCase,
+ aBtnRegExp,
+ aBtnHeader,
+ aBtnUnique,
+ aBtnCopyResult,
+ aBtnDestPers,
+ aLbCopyArea,
+ aEdCopyArea,
+ aRbCopyArea,
+ aFtDbAreaLabel,
+ aFtDbArea,
+ aFlOptions,
+ aStrNoName,
+ aStrUndefined );
+
+ // Feldlisten einlesen und Eintraege selektieren:
+
+ FillFieldLists();
+
+ for ( SCSIZE i=0; i<4; i++ )
+ {
+ String aValStr;
+ USHORT nCondPos = 0;
+ USHORT nFieldSelPos = 0;
+
+ ScQueryEntry& rEntry = theQueryData.GetEntry(i);
+ if ( rEntry.bDoQuery )
+ {
+ nCondPos = (USHORT)rEntry.eOp;
+ nFieldSelPos = GetFieldSelPos( static_cast<SCCOL>(rEntry.nField) );
+ if ( rEntry.nVal == SC_EMPTYFIELDS && !rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING )
+ {
+ aValStr = aStrEmpty;
+ aCondLbArr[i]->Disable();
+ }
+ else if ( rEntry.nVal == SC_NONEMPTYFIELDS && !rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING )
+ {
+ aValStr = aStrNotEmpty;
+ aCondLbArr[i]->Disable();
+ }
+ else
+ aValStr = *rEntry.pStr;
+ }
+ else if ( i == 0 )
+ {
+ nFieldSelPos = GetFieldSelPos( pViewData->GetCurX() );
+ rEntry.nField = nFieldSelPos ? (theQueryData.nCol1 +
+ static_cast<SCCOL>(nFieldSelPos) - 1) : static_cast<SCCOL>(0);
+ rEntry.bDoQuery=TRUE;
+ bRefreshExceptQuery[i]=TRUE;
+
+ }
+ aFieldLbArr[i]->SelectEntryPos( nFieldSelPos );
+ aCondLbArr [i]->SelectEntryPos( nCondPos );
+ aValueEdArr[i]->SetText( aValStr );
+ aValueEdArr[i]->SetModifyHdl( LINK( this, ScFilterDlg, ValModifyHdl ) );
+ UpdateValueList( static_cast<USHORT>(i+1) );
+ }
+
+ aScrollBar.SetEndScrollHdl( LINK( this, ScFilterDlg, ScrollHdl ) );
+ aScrollBar.SetScrollHdl( LINK( this, ScFilterDlg, ScrollHdl ) );
+
+ aScrollBar.SetRange( Range( 0, 4 ) );
+ aScrollBar.SetLineSize( 1 );
+ aLbConnect1.Hide();
+ // Disable/Enable Logik:
+
+ (aLbField1.GetSelectEntryPos() != 0)
+ && (aLbField2.GetSelectEntryPos() != 0)
+ ? aLbConnect2.SelectEntryPos( (USHORT)theQueryData.GetEntry(1).eConnect )
+ : aLbConnect2.SetNoSelection();
+
+ (aLbField2.GetSelectEntryPos() != 0)
+ && (aLbField3.GetSelectEntryPos() != 0)
+ ? aLbConnect3.SelectEntryPos( (USHORT)theQueryData.GetEntry(2).eConnect )
+ : aLbConnect3.SetNoSelection();
+
+ (aLbField3.GetSelectEntryPos() != 0)
+ && (aLbField4.GetSelectEntryPos() != 0)
+ ? aLbConnect4.SelectEntryPos( (USHORT)theQueryData.GetEntry(3).eConnect )
+ : aLbConnect4.SetNoSelection();
+ if ( aLbField1.GetSelectEntryPos() == 0 )
+ {
+ aLbConnect2.Disable();
+ aLbField2.Disable();
+ aLbCond2.Disable();
+ aEdVal2.Disable();
+ }
+ else if ( aLbConnect2.GetSelectEntryCount() == 0 )
+ {
+ aLbField2.Disable();
+ aLbCond2.Disable();
+ aEdVal2.Disable();
+ }
+
+ if ( aLbField2.GetSelectEntryPos() == 0 )
+ {
+ aLbConnect3.Disable();
+ aLbField3.Disable();
+ aLbCond3.Disable();
+ aEdVal3.Disable();
+ }
+ else if ( aLbConnect3.GetSelectEntryCount() == 0 )
+ {
+ aLbField3.Disable();
+ aLbCond3.Disable();
+ aEdVal3.Disable();
+ }
+ if ( aLbField3.GetSelectEntryPos() == 0 )
+ {
+ aLbConnect4.Disable();
+ aLbField4.Disable();
+ aLbCond4.Disable();
+ aEdVal4.Disable();
+ }
+ else if ( aLbConnect4.GetSelectEntryCount() == 0 )
+ {
+ aLbField4.Disable();
+ aLbCond4.Disable();
+ aEdVal4.Disable();
+ }
+
+ if(pDoc!=NULL &&
+ pDoc->GetChangeTrack()!=NULL) aBtnCopyResult.Disable();
+ // Modal-Modus einschalten
+// SetDispatcherLock( TRUE );
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+// SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScFilterDlg::Close()
+{
+ if (pViewData)
+ pViewData->GetDocShell()->CancelAutoDBRange();
+
+ return DoClose( ScFilterDlgWrapper::GetChildWindowId() );
+}
+
+
+//----------------------------------------------------------------------------
+// Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
+// neue Selektion im Referenz-Edit angezeigt wird.
+
+void ScFilterDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( bRefInputMode ) // Nur moeglich, wenn im Referenz-Editmodus
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart( &aEdCopyArea );
+ String aRefStr;
+ rRef.aStart.Format( aRefStr, SCA_ABS_3D, pDocP, pDocP->GetAddressConvention() );
+ aEdCopyArea.SetRefString( aRefStr );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScFilterDlg::SetActive()
+{
+ if ( bRefInputMode )
+ {
+ aEdCopyArea.GrabFocus();
+ if ( aEdCopyArea.GetModifyHdl().IsSet() )
+ ((Link&)aEdCopyArea.GetModifyHdl()).Call( &aEdCopyArea );
+ }
+ else
+ GrabFocus();
+
+ RefInputDone();
+}
+
+//----------------------------------------------------------------------------
+
+void ScFilterDlg::FillFieldLists()
+{
+ aLbField1.Clear();
+ aLbField2.Clear();
+ aLbField3.Clear();
+ aLbField4.Clear();
+ aLbField1.InsertEntry( aStrNone, 0 );
+ aLbField2.InsertEntry( aStrNone, 0 );
+ aLbField3.InsertEntry( aStrNone, 0 );
+ aLbField4.InsertEntry( aStrNone, 0 );
+
+ if ( pDoc )
+ {
+ String aFieldName;
+ SCTAB nTab = nSrcTab;
+ SCCOL nFirstCol = theQueryData.nCol1;
+ SCROW nFirstRow = theQueryData.nRow1;
+ SCCOL nMaxCol = theQueryData.nCol2;
+ SCCOL col = 0;
+ USHORT i=1;
+
+ for ( col=nFirstCol; col<=nMaxCol; col++ )
+ {
+ pDoc->GetString( col, nFirstRow, nTab, aFieldName );
+ if ( !aBtnHeader.IsChecked() || (aFieldName.Len() == 0) )
+ {
+ aFieldName = aStrColumn;
+ aFieldName += ' ';
+ aFieldName += ScColToAlpha( col );
+ }
+ aLbField1.InsertEntry( aFieldName, i );
+ aLbField2.InsertEntry( aFieldName, i );
+ aLbField3.InsertEntry( aFieldName, i );
+ aLbField4.InsertEntry( aFieldName, i );
+ i++;
+ }
+ nFieldCount = i;
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScFilterDlg::UpdateValueList( USHORT nList )
+{
+ if ( pDoc && nList>0 && nList<=4 )
+ {
+ ComboBox* pValList = aValueEdArr[nList-1];
+ USHORT nFieldSelPos = aFieldLbArr[nList-1]->GetSelectEntryPos();
+ USHORT nListPos = 0;
+ String aCurValue = pValList->GetText();
+
+ pValList->Clear();
+ pValList->InsertEntry( aStrNotEmpty, 0 );
+ pValList->InsertEntry( aStrEmpty, 1 );
+ nListPos = 2;
+
+ if ( nFieldSelPos )
+ {
+ WaitObject aWaiter( this ); // auch wenn nur die ListBox gefuellt wird
+
+ SCCOL nColumn = theQueryData.nCol1 + static_cast<SCCOL>(nFieldSelPos) - 1;
+ if (!pEntryLists[nColumn])
+ {
+ USHORT nOffset = GetSliderPos();
+ SCTAB nTab = nSrcTab;
+ SCROW nFirstRow = theQueryData.nRow1;
+ SCROW nLastRow = theQueryData.nRow2;
+ mbHasDates[nOffset+nList-1] = false;
+
+ // erstmal ohne die erste Zeile
+
+ pEntryLists[nColumn] = new TypedScStrCollection( 128, 128 );
+ pEntryLists[nColumn]->SetCaseSensitive( aBtnCase.IsChecked() );
+ pDoc->GetFilterEntriesArea( nColumn, nFirstRow+1, nLastRow,
+ nTab, *pEntryLists[nColumn], mbHasDates[nOffset+nList-1] );
+
+ // Eintrag fuer die erste Zeile
+ //! Eintrag (pHdrEntry) ohne Collection erzeugen?
+
+ nHeaderPos[nColumn] = USHRT_MAX;
+ TypedScStrCollection aHdrColl( 1, 1 );
+ bool bDummy = false;
+ pDoc->GetFilterEntriesArea( nColumn, nFirstRow, nFirstRow,
+ nTab, aHdrColl, bDummy );
+ TypedStrData* pHdrEntry = aHdrColl[0];
+ if ( pHdrEntry )
+ {
+ TypedStrData* pNewEntry = new TypedStrData(*pHdrEntry);
+ if ( pEntryLists[nColumn]->Insert( pNewEntry ) )
+ {
+ nHeaderPos[nColumn] = pEntryLists[nColumn]->IndexOf( pNewEntry );
+ DBG_ASSERT( nHeaderPos[nColumn] != USHRT_MAX,
+ "Header-Eintrag nicht wiedergefunden" );
+ }
+ else
+ delete pNewEntry; // war schon drin
+ }
+ }
+
+ TypedScStrCollection* pColl = pEntryLists[nColumn];
+ USHORT nValueCount = pColl->GetCount();
+ if ( nValueCount > 0 )
+ {
+ for ( USHORT i=0; i<nValueCount; i++ )
+ {
+ pValList->InsertEntry( (*pColl)[i]->GetString(), nListPos );
+ nListPos++;
+ }
+ }
+ }
+ pValList->SetText( aCurValue );
+ }
+
+ UpdateHdrInValueList( nList );
+}
+
+void ScFilterDlg::UpdateHdrInValueList( USHORT nList )
+{
+ //! GetText / SetText ??
+
+ if ( pDoc && nList>0 && nList<=4 )
+ {
+ USHORT nFieldSelPos = aFieldLbArr[nList-1]->GetSelectEntryPos();
+ if ( nFieldSelPos )
+ {
+ SCCOL nColumn = theQueryData.nCol1 + static_cast<SCCOL>(nFieldSelPos) - 1;
+ if ( pEntryLists[nColumn] )
+ {
+ USHORT nPos = nHeaderPos[nColumn];
+ if ( nPos != USHRT_MAX )
+ {
+ ComboBox* pValList = aValueEdArr[nList-1];
+ USHORT nListPos = nPos + 2; // nach "leer" und "nicht leer"
+
+ TypedStrData* pHdrEntry = (*pEntryLists[nColumn])[nPos];
+ if ( pHdrEntry )
+ {
+ String aHdrStr = pHdrEntry->GetString();
+ BOOL bWasThere = ( pValList->GetEntry(nListPos) == aHdrStr );
+ BOOL bInclude = !aBtnHeader.IsChecked();
+
+ if (bInclude) // Eintrag aufnehmen
+ {
+ if (!bWasThere)
+ pValList->InsertEntry(aHdrStr, nListPos);
+ }
+ else // Eintrag weglassen
+ {
+ if (bWasThere)
+ pValList->RemoveEntry(nListPos);
+ }
+ }
+ else
+ {
+ DBG_ERROR("Eintag in Liste nicht gefunden");
+ }
+ }
+ }
+ else
+ {
+ DBG_ERROR("Spalte noch nicht initialisiert");
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScFilterDlg::ClearValueList( USHORT nList )
+{
+ if ( nList>0 && nList<=4 )
+ {
+ ComboBox* pValList = aValueEdArr[nList-1];
+ pValList->Clear();
+ pValList->InsertEntry( aStrNotEmpty, 0 );
+ pValList->InsertEntry( aStrEmpty, 1 );
+ pValList->SetText( EMPTY_STRING );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+USHORT ScFilterDlg::GetFieldSelPos( SCCOL nField )
+{
+ if ( nField >= theQueryData.nCol1 && nField <= theQueryData.nCol2 )
+ return static_cast<USHORT>(nField - theQueryData.nCol1 + 1);
+ else
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+ScQueryItem* ScFilterDlg::GetOutputItem()
+{
+ ScAddress theCopyPos;
+ ScQueryParam theParam( theQueryData );
+ BOOL bCopyPosOk = FALSE;
+
+ if ( aBtnCopyResult.IsChecked() )
+ {
+ String theCopyStr( aEdCopyArea.GetText() );
+ xub_StrLen nColonPos = theCopyStr.Search( ':' );
+
+ if ( STRING_NOTFOUND != nColonPos )
+ theCopyStr.Erase( nColonPos );
+
+ USHORT nResult = theCopyPos.Parse( theCopyStr, pDoc, pDoc->GetAddressConvention() );
+ bCopyPosOk = ( SCA_VALID == (nResult & SCA_VALID) );
+ }
+
+ if ( aBtnCopyResult.IsChecked() && bCopyPosOk )
+ {
+ theParam.bInplace = FALSE;
+ theParam.nDestTab = theCopyPos.Tab();
+ theParam.nDestCol = theCopyPos.Col();
+ theParam.nDestRow = theCopyPos.Row();
+ }
+ else
+ {
+ theParam.bInplace = TRUE;
+ theParam.nDestTab = 0;
+ theParam.nDestCol = 0;
+ theParam.nDestRow = 0;
+ }
+
+ theParam.bHasHeader = aBtnHeader.IsChecked();
+ theParam.bByRow = TRUE;
+ theParam.bDuplicate = !aBtnUnique.IsChecked();
+ theParam.bCaseSens = aBtnCase.IsChecked();
+ theParam.bRegExp = aBtnRegExp.IsChecked();
+ theParam.bDestPers = aBtnDestPers.IsChecked();
+
+ // nur die drei eingestellten - alles andere zuruecksetzen
+
+ DELETEZ( pOutItem );
+ pOutItem = new ScQueryItem( nWhichQuery, &theParam );
+
+ return pOutItem;
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScFilterDlg::IsRefInputMode() const
+{
+ return bRefInputMode;
+}
+
+
+//----------------------------------------------------------------------------
+// Handler:
+// ========
+
+IMPL_LINK( ScFilterDlg, EndDlgHdl, Button*, pBtn )
+{
+ if ( pBtn == &aBtnOk )
+ {
+ BOOL bAreaInputOk = TRUE;
+
+ if ( aBtnCopyResult.IsChecked() )
+ {
+ if ( !pOptionsMgr->VerifyPosStr( aEdCopyArea.GetText() ) )
+ {
+ if ( !aBtnMore.GetState() )
+ aBtnMore.SetState( TRUE );
+
+ ERRORBOX( STR_INVALID_TABREF );
+ aEdCopyArea.GrabFocus();
+ bAreaInputOk = FALSE;
+ }
+ }
+
+ if ( bAreaInputOk )
+ {
+ SetDispatcherLock( FALSE );
+ SwitchToDocument();
+ GetBindings().GetDispatcher()->Execute( FID_FILTER_OK,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ GetOutputItem(), 0L, 0L );
+ Close();
+ }
+ }
+ else if ( pBtn == &aBtnCancel )
+ {
+ Close();
+ }
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScFilterDlg, MoreClickHdl, MoreButton*, EMPTYARG )
+{
+ if ( aBtnMore.GetState() )
+ pTimer->Start();
+ else
+ {
+ pTimer->Stop();
+ bRefInputMode = FALSE;
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScFilterDlg, TimeOutHdl, Timer*, _pTimer )
+{
+ // alle 50ms nachschauen, ob RefInputMode noch stimmt
+
+ if( _pTimer == pTimer && IsActive() )
+ bRefInputMode = (aEdCopyArea.HasFocus() || aRbCopyArea.HasFocus());
+
+ if ( aBtnMore.GetState() )
+ pTimer->Start();
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScFilterDlg, LbSelectHdl, ListBox*, pLb )
+{
+ /*
+ * Behandlung der Enable/Disable-Logik,
+ * abhaengig davon, welche ListBox angefasst wurde:
+ */
+ USHORT nOffset = GetSliderPos();
+
+ if ( pLb == &aLbConnect1 )
+ {
+ aLbField1.Enable();
+ aLbCond1.Enable();
+ aEdVal1.Enable();
+
+ USHORT nConnect1 = aLbConnect1.GetSelectEntryPos();
+ USHORT nQE = nOffset;
+ theQueryData.GetEntry(nQE).eConnect =(ScQueryConnect)nConnect1;
+ bRefreshExceptQuery[nQE]=TRUE;
+ }
+
+ else if ( pLb == &aLbConnect2 )
+ {
+ aLbField2.Enable();
+ aLbCond2.Enable();
+ aEdVal2.Enable();
+
+ USHORT nConnect2 = aLbConnect2.GetSelectEntryPos();
+ USHORT nQE = 1+nOffset;
+ theQueryData.GetEntry(nQE).eConnect =(ScQueryConnect)nConnect2;
+ bRefreshExceptQuery[nQE]=TRUE;
+ }
+ else if ( pLb == &aLbConnect3 )
+ {
+ aLbField3.Enable();
+ aLbCond3.Enable();
+ aEdVal3.Enable();
+
+ USHORT nConnect3 = aLbConnect3.GetSelectEntryPos();
+ USHORT nQE = 2+nOffset;
+ theQueryData.GetEntry(nQE).eConnect = (ScQueryConnect)nConnect3;
+ bRefreshExceptQuery[nQE]=TRUE;
+
+ }
+ else if ( pLb == &aLbConnect4 )
+ {
+ aLbField4.Enable();
+ aLbCond4.Enable();
+ aEdVal4.Enable();
+
+ USHORT nConnect4 = aLbConnect4.GetSelectEntryPos();
+ USHORT nQE = 3+nOffset;
+ theQueryData.GetEntry(nQE).eConnect = (ScQueryConnect)nConnect4;
+ bRefreshExceptQuery[nQE]=TRUE;
+
+ }
+ else if ( pLb == &aLbField1 )
+ {
+ if ( aLbField1.GetSelectEntryPos() == 0 )
+ {
+ aLbConnect2.SetNoSelection();
+ aLbConnect3.SetNoSelection();
+ aLbConnect4.SetNoSelection();
+ aLbField2.SelectEntryPos( 0 );
+ aLbField3.SelectEntryPos( 0 );
+ aLbField4.SelectEntryPos( 0 );
+ aLbCond2.SelectEntryPos( 0 );
+ aLbCond3.SelectEntryPos( 0 );
+ aLbCond4.SelectEntryPos( 0 );
+ ClearValueList( 1 );
+ ClearValueList( 2 );
+ ClearValueList( 3 );
+ ClearValueList( 4 );
+
+ aLbConnect2.Disable();
+ aLbConnect3.Disable();
+ aLbConnect4.Disable();
+ aLbField2.Disable();
+ aLbField3.Disable();
+ aLbField4.Disable();
+ aLbCond2.Disable();
+ aLbCond3.Disable();
+ aLbCond4.Disable();
+ aEdVal2.Disable();
+ aEdVal3.Disable();
+ aEdVal4.Disable();
+ for (USHORT i= nOffset; i< MAXQUERY; i++)
+ {
+ theQueryData.GetEntry(i).bDoQuery = FALSE;
+ bRefreshExceptQuery[i]=FALSE;
+ theQueryData.GetEntry(i).nField = static_cast<SCCOL>(0);
+ }
+ bRefreshExceptQuery[nOffset] =TRUE;
+ }
+ else
+ {
+ UpdateValueList( 1 );
+ if ( !aLbConnect2.IsEnabled() )
+ {
+ aLbConnect2.Enable();
+ }
+ theQueryData.GetEntry(nOffset).bDoQuery = TRUE;
+ USHORT nField = pLb->GetSelectEntryPos();
+ theQueryData.GetEntry(nOffset).nField = theQueryData.nCol1 + static_cast<SCCOL>(nField) - 1 ;
+ }
+ }
+ else if ( pLb == &aLbField2 )
+ {
+ if ( aLbField2.GetSelectEntryPos() == 0 )
+ {
+ aLbConnect3.SetNoSelection();
+ aLbConnect4.SetNoSelection();
+ aLbField3.SelectEntryPos( 0 );
+ aLbField4.SelectEntryPos( 0 );
+ aLbCond3.SelectEntryPos( 0 );
+ aLbCond4.SelectEntryPos( 0 );
+ ClearValueList( 2 );
+ ClearValueList( 3 );
+ ClearValueList( 4 );
+
+ aLbConnect3.Disable();
+ aLbConnect4.Disable();
+ aLbField3.Disable();
+ aLbField4.Disable();
+ aLbCond3.Disable();
+ aLbCond4.Disable();
+ aEdVal3.Disable();
+ aEdVal4.Disable();
+
+ USHORT nTemp=nOffset+1;
+ for (USHORT i= nTemp; i< MAXQUERY; i++)
+ {
+ theQueryData.GetEntry(i).bDoQuery = FALSE;
+ bRefreshExceptQuery[i]=FALSE;
+ theQueryData.GetEntry(i).nField = static_cast<SCCOL>(0);
+ }
+ bRefreshExceptQuery[nTemp]=TRUE;
+ }
+ else
+ {
+ UpdateValueList( 2 );
+ if ( !aLbConnect3.IsEnabled() )
+ {
+ aLbConnect3.Enable();
+ }
+ USHORT nField = pLb->GetSelectEntryPos();
+ USHORT nQ=1+nOffset;
+ theQueryData.GetEntry(nQ).bDoQuery = TRUE;
+ theQueryData.GetEntry(nQ).nField = theQueryData.nCol1 + static_cast<SCCOL>(nField) - 1 ;
+ }
+ }
+ else if ( pLb == &aLbField3 )
+ {
+ if ( aLbField3.GetSelectEntryPos() == 0 )
+ {
+ aLbConnect4.SetNoSelection();
+ aLbField4.SelectEntryPos( 0 );
+ aLbCond4.SelectEntryPos( 0 );
+ ClearValueList( 3 );
+ ClearValueList( 4 );
+
+ aLbConnect4.Disable();
+ aLbField4.Disable();
+ aLbCond4.Disable();
+ aEdVal4.Disable();
+
+ USHORT nTemp=nOffset+2;
+ for (USHORT i= nTemp; i< MAXQUERY; i++)
+ {
+ theQueryData.GetEntry(i).bDoQuery = FALSE;
+ bRefreshExceptQuery[i]=FALSE;
+ theQueryData.GetEntry(i).nField = static_cast<SCCOL>(0);
+ }
+ bRefreshExceptQuery[nTemp]=TRUE;
+ }
+ else
+ {
+ UpdateValueList( 3 );
+ if ( !aLbConnect4.IsEnabled() )
+ {
+ aLbConnect4.Enable();
+ }
+
+ USHORT nField = pLb->GetSelectEntryPos();
+ USHORT nQ=2+nOffset;
+ theQueryData.GetEntry(nQ).bDoQuery = TRUE;
+ theQueryData.GetEntry(nQ).nField = theQueryData.nCol1 + static_cast<SCCOL>(nField) - 1 ;
+
+ }
+ }
+ else if ( pLb == &aLbField4 )
+ {
+ if ( aLbField4.GetSelectEntryPos() == 0 )
+ {
+ ClearValueList( 4 );
+ USHORT nTemp=nOffset+3;
+ for (USHORT i= nTemp; i< MAXQUERY; i++)
+ {
+ theQueryData.GetEntry(i).bDoQuery = FALSE;
+ bRefreshExceptQuery[i]=FALSE;
+ theQueryData.GetEntry(i).nField = static_cast<SCCOL>(0);
+ }
+ bRefreshExceptQuery[nTemp]=TRUE;
+ }
+ else
+ {
+ UpdateValueList( 4 );
+ USHORT nField = pLb->GetSelectEntryPos();
+ USHORT nQ=3+nOffset;
+ theQueryData.GetEntry(nQ).bDoQuery = TRUE;
+ theQueryData.GetEntry(nQ).nField = theQueryData.nCol1 + static_cast<SCCOL>(nField) - 1 ;
+ }
+
+ }
+ else if ( pLb == &aLbCond1)
+ {
+ theQueryData.GetEntry(nOffset).eOp=(ScQueryOp)pLb->GetSelectEntryPos();
+ }
+ else if ( pLb == &aLbCond2)
+ {
+ USHORT nQ=1+nOffset;
+ theQueryData.GetEntry(nQ).eOp=(ScQueryOp)pLb->GetSelectEntryPos();
+ }
+ else if ( pLb == &aLbCond3)
+ {
+ USHORT nQ=2+nOffset;
+ theQueryData.GetEntry(nQ).eOp=(ScQueryOp)pLb->GetSelectEntryPos();
+ }
+ else
+ {
+ USHORT nQ=3+nOffset;
+ theQueryData.GetEntry(nQ).eOp=(ScQueryOp)pLb->GetSelectEntryPos();
+ }
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScFilterDlg, CheckBoxHdl, CheckBox*, pBox )
+{
+ // Spaltenkoepfe:
+ // FeldListen: Spaltexx <-> Spaltenkopf-String
+ // WertListen: Spaltenkopf-Wert entfaellt.
+ // Gross-/Kleinschreibung:
+ // WertListen: komplett neu
+
+ if ( pBox == &aBtnHeader ) // Feldlisten und Wertlisten
+ {
+ USHORT nCurSel1 = aLbField1.GetSelectEntryPos();
+ USHORT nCurSel2 = aLbField2.GetSelectEntryPos();
+ USHORT nCurSel3 = aLbField3.GetSelectEntryPos();
+ USHORT nCurSel4 = aLbField4.GetSelectEntryPos();
+ FillFieldLists();
+ aLbField1.SelectEntryPos( nCurSel1 );
+ aLbField2.SelectEntryPos( nCurSel2 );
+ aLbField3.SelectEntryPos( nCurSel3 );
+ aLbField4.SelectEntryPos( nCurSel4 );
+
+ UpdateHdrInValueList( 1 );
+ UpdateHdrInValueList( 2 );
+ UpdateHdrInValueList( 3 );
+ UpdateHdrInValueList( 4 );
+ }
+
+ if ( pBox == &aBtnCase ) // Wertlisten komplett
+ {
+ for (USHORT i=0; i<=MAXCOL; i++)
+ DELETEZ( pEntryLists[i] );
+
+ UpdateValueList( 1 ); // aktueller Text wird gemerkt
+ UpdateValueList( 2 );
+ UpdateValueList( 3 );
+ UpdateValueList( 4 );
+ }
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScFilterDlg, ValModifyHdl, ComboBox*, pEd )
+{
+ USHORT nOffset = GetSliderPos();
+ USHORT i=0;
+ USHORT nQE =i + nOffset;
+ if ( pEd )
+ {
+ String aStrVal = pEd->GetText();
+ ListBox* pLbCond = &aLbCond1;
+ ListBox* pLbField = &aLbField1;
+ if ( pEd == &aEdVal2 )
+ {
+ pLbCond = &aLbCond2;
+ pLbField = &aLbField2;
+ i=1;
+ nQE=i+nOffset;
+ }
+ if ( pEd == &aEdVal3 )
+ {
+ pLbCond = &aLbCond3;
+ pLbField = &aLbField3;
+ i=2;
+ nQE=i+nOffset;
+ }
+ if ( pEd == &aEdVal4 )
+ {
+ pLbCond = &aLbCond4;
+ pLbField = &aLbField4;
+ i=3;
+ nQE=i+nOffset;
+ }
+
+ if ( aStrEmpty == aStrVal || aStrNotEmpty == aStrVal )
+ {
+ pLbCond->SelectEntry( '=' );
+ pLbCond->Disable();
+ }
+ else
+ pLbCond->Enable();
+
+ ScQueryEntry& rEntry = theQueryData.GetEntry( nQE );
+ BOOL bDoThis = (pLbField->GetSelectEntryPos() != 0);
+ rEntry.bDoQuery = bDoThis;
+
+ if ( rEntry.bDoQuery || bRefreshExceptQuery[nQE] )
+ {
+ if ( aStrVal == aStrEmpty )
+ {
+ rEntry.pStr->Erase();
+ rEntry.nVal = SC_EMPTYFIELDS;
+ rEntry.bQueryByString = FALSE;
+ }
+ else if ( aStrVal == aStrNotEmpty )
+ {
+ rEntry.pStr->Erase();
+ rEntry.nVal = SC_NONEMPTYFIELDS;
+ rEntry.bQueryByString = FALSE;
+ }
+ else
+ {
+ *rEntry.pStr = aStrVal;
+ rEntry.nVal = 0;
+ rEntry.bQueryByString = TRUE;
+ }
+
+ USHORT nField = pLbField->GetSelectEntryPos();
+ rEntry.nField = nField ? (theQueryData.nCol1 +
+ static_cast<SCCOL>(nField) - 1) : static_cast<SCCOL>(0);
+
+ ScQueryOp eOp = (ScQueryOp)pLbCond->GetSelectEntryPos();
+ rEntry.eOp = eOp;
+ rEntry.bQueryByDate = mbHasDates[nQE];
+
+ }
+ }
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+IMPL_LINK( ScFilterDlg, ScrollHdl, ScrollBar*, EMPTYARG )
+{
+ SliderMoved();
+ return 0;
+}
+
+void ScFilterDlg::SliderMoved()
+{
+ USHORT nOffset = GetSliderPos();
+ RefreshEditRow( nOffset);
+}
+USHORT ScFilterDlg::GetSliderPos()
+{
+ return (USHORT) aScrollBar.GetThumbPos();
+}
+void ScFilterDlg::RefreshEditRow( USHORT nOffset )
+{
+ if (nOffset==0)
+ aConnLbArr[0]->Hide();
+ else
+ aConnLbArr[0]->Show();
+
+ for ( USHORT i=0; i<4; i++ )
+ {
+ String aValStr;
+ USHORT nCondPos = 0;
+ USHORT nFieldSelPos = 0;
+ USHORT nQE = i+nOffset;
+
+ ScQueryEntry& rEntry = theQueryData.GetEntry( nQE);
+ if ( rEntry.bDoQuery || bRefreshExceptQuery[nQE] )
+ {
+ nCondPos = (USHORT)rEntry.eOp;
+ if(rEntry.bDoQuery)
+ nFieldSelPos = GetFieldSelPos( static_cast<SCCOL>(rEntry.nField) );
+
+ if ( rEntry.nVal == SC_EMPTYFIELDS && !rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING )
+ {
+ aValStr = aStrEmpty;
+ aCondLbArr[i]->Disable();
+ }
+ else if ( rEntry.nVal == SC_NONEMPTYFIELDS && !rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING )
+ {
+ aValStr = aStrNotEmpty;
+ aCondLbArr[i]->Disable();
+ }
+ else
+ {
+ aValStr = *rEntry.pStr;
+ aCondLbArr[i]->Enable();
+ }
+ aFieldLbArr[i]->Enable();
+ aValueEdArr[i]->Enable();
+
+ if (nOffset==0)
+ {
+ if (i<3)
+ {
+ if(rEntry.bDoQuery)
+ aConnLbArr[i+1]->Enable();
+ else
+ aConnLbArr[i+1]->Disable();
+ USHORT nQENext = nQE+1;
+ if(theQueryData.GetEntry(nQENext).bDoQuery || bRefreshExceptQuery[nQENext])
+ aConnLbArr[i+1]->SelectEntryPos( (USHORT) theQueryData.GetEntry(nQENext).eConnect );
+ else
+ aConnLbArr[i+1]->SetNoSelection();
+ }
+ }
+ else
+ {
+ if(theQueryData.GetEntry( nQE-1).bDoQuery)
+ aConnLbArr[i]->Enable();
+ else
+ aConnLbArr[i]->Disable();
+
+ if(rEntry.bDoQuery || bRefreshExceptQuery[nQE])
+ aConnLbArr[i]->SelectEntryPos( (USHORT) rEntry.eConnect );
+ else
+ aConnLbArr[i]->SetNoSelection();
+ }
+
+ }
+ else
+ {
+ if (nOffset==0)
+ {
+ if(i<3)
+ {
+ aConnLbArr[i+1]->SetNoSelection();
+ aConnLbArr[i+1]->Disable();
+ }
+ }
+ else
+ {
+ if(theQueryData.GetEntry( nQE-1).bDoQuery)
+ aConnLbArr[i]->Enable();
+ else
+ aConnLbArr[i]->Disable();
+ aConnLbArr[i]->SetNoSelection();
+ }
+ aFieldLbArr[i]->Disable();
+ aCondLbArr[i]->Disable();
+ aValueEdArr[i]->Disable();
+ }
+ aFieldLbArr[i]->SelectEntryPos( nFieldSelPos );
+ aCondLbArr [i]->SelectEntryPos( nCondPos );
+ aValueEdArr[i]->SetText( aValStr );
+ UpdateValueList( static_cast<USHORT>(i+1) );
+ }
+}
diff --git a/sc/source/ui/dbgui/foptmgr.cxx b/sc/source/ui/dbgui/foptmgr.cxx
new file mode 100644
index 000000000000..1e274690c31c
--- /dev/null
+++ b/sc/source/ui/dbgui/foptmgr.cxx
@@ -0,0 +1,337 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+// INCLUDE -------------------------------------------------------------------
+
+#include <vcl/morebtn.hxx>
+#include <svtools/stdctrl.hxx>
+
+#include "anyrefdg.hxx"
+#include "rangeutl.hxx"
+#include "dbcolect.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "queryparam.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,
+ formula::RefButton& 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; i<nEntries; i++ )
+ delete (String*)rLbCopyPos.GetEntryData( i );
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScFilterOptionsMgr::Init()
+{
+ DBG_ASSERT( pViewData && pDoc, "Init failed :-/" );
+
+ rLbCopyPos.SetSelectHdl ( LINK( this, ScFilterOptionsMgr, LbPosSelHdl ) );
+ rEdCopyPos.SetModifyHdl ( LINK( this, ScFilterOptionsMgr, EdPosModifyHdl ) );
+ rBtnCopyResult.SetClickHdl( LINK( this, ScFilterOptionsMgr, BtnCopyResultHdl ) );
+
+ rBtnMore.AddWindow( &rBtnCase );
+ rBtnMore.AddWindow( &rBtnRegExp );
+ rBtnMore.AddWindow( &rBtnHeader );
+ rBtnMore.AddWindow( &rBtnUnique );
+ rBtnMore.AddWindow( &rBtnCopyResult );
+ rBtnMore.AddWindow( &rBtnDestPers );
+ rBtnMore.AddWindow( &rLbCopyPos );
+ rBtnMore.AddWindow( &rEdCopyPos );
+ rBtnMore.AddWindow( &rRbCopyPos );
+ rBtnMore.AddWindow( &rFtDbAreaLabel );
+ rBtnMore.AddWindow( &rFtDbArea );
+ rBtnMore.AddWindow( &rFlOptions );
+
+ rBtnCase .Check( rQueryData.bCaseSens );
+ rBtnHeader .Check( rQueryData.bHasHeader );
+ rBtnRegExp .Check( rQueryData.bRegExp );
+ rBtnUnique .Check( !rQueryData.bDuplicate );
+
+ if ( pViewData && pDoc )
+ {
+ String theAreaStr;
+ ScRange theCurArea ( ScAddress( rQueryData.nCol1,
+ rQueryData.nRow1,
+ pViewData->GetTabNo() ),
+ ScAddress( rQueryData.nCol2,
+ rQueryData.nRow2,
+ pViewData->GetTabNo() ) );
+ ScDBCollection* pDBColl = pDoc->GetDBCollection();
+ String theDbArea;
+ String theDbName = rStrNoName;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+
+ theCurArea.Format( theAreaStr, SCR_ABS_3D, pDoc, eConv );
+
+ // 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, eConv );
+ 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, eConv );
+
+ 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, pDoc->GetAddressConvention() );
+
+ 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, pDoc->GetAddressConvention() );
+
+ if ( SCA_VALID == (nResult & SCA_VALID) )
+ {
+ String* pStr = NULL;
+ BOOL bFound = FALSE;
+ USHORT i = 0;
+ USHORT nCount = rLbCopyPos.GetEntryCount();
+
+ for ( i=2; i<nCount && !bFound; i++ )
+ {
+ pStr = (String*)rLbCopyPos.GetEntryData( i );
+ bFound = (theCurPosStr == *pStr);
+ }
+
+ if ( bFound )
+ rLbCopyPos.SelectEntryPos( --i );
+ else
+ rLbCopyPos.SelectEntryPos( 0 );
+ }
+ else
+ rLbCopyPos.SelectEntryPos( 0 );
+ }
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScFilterOptionsMgr, BtnCopyResultHdl, CheckBox*, pBox )
+{
+ if ( pBox == &rBtnCopyResult )
+ {
+ if ( pBox->IsChecked() )
+ {
+ rBtnDestPers.Enable();
+ rLbCopyPos.Enable();
+ rEdCopyPos.Enable();
+ rRbCopyPos.Enable();
+ rEdCopyPos.GrabFocus();
+ }
+ else
+ {
+ rBtnDestPers.Disable();
+ rLbCopyPos.Disable();
+ rEdCopyPos.Disable();
+ rRbCopyPos.Disable();
+ }
+ }
+
+ return 0;
+}
diff --git a/sc/source/ui/dbgui/imoptdlg.cxx b/sc/source/ui/dbgui/imoptdlg.cxx
new file mode 100644
index 000000000000..bd18008afd47
--- /dev/null
+++ b/sc/source/ui/dbgui/imoptdlg.cxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "imoptdlg.hxx"
+#include "scresid.hxx"
+#include "imoptdlg.hrc"
+#include <rtl/tencinfo.h>
+
+static const sal_Char pStrFix[] = "FIX";
+
+//------------------------------------------------------------------------
+// Der Options-String darf kein Semikolon mehr enthalten (wegen Pickliste)
+// darum ab Version 336 Komma stattdessen
+
+
+ScImportOptions::ScImportOptions( const String& rStr )
+{
+ bFixedWidth = FALSE;
+ nFieldSepCode = 0;
+ if ( rStr.GetTokenCount(',') >= 3 )
+ {
+ String aToken( rStr.GetToken( 0, ',' ) );
+ if( aToken.EqualsIgnoreCaseAscii( pStrFix ) )
+ bFixedWidth = TRUE;
+ else
+ nFieldSepCode = (sal_Unicode) aToken.ToInt32();
+ nTextSepCode = (sal_Unicode) rStr.GetToken(1,',').ToInt32();
+ aStrFont = rStr.GetToken(2,',');
+ eCharSet = ScGlobal::GetCharsetValue(aStrFont);
+ bSaveAsShown = (rStr.GetToken( 3, ',' ).ToInt32() ? TRUE : FALSE);
+ }
+}
+
+//------------------------------------------------------------------------
+
+String ScImportOptions::BuildString() const
+{
+ String aResult;
+
+ if( bFixedWidth )
+ aResult.AppendAscii( pStrFix );
+ else
+ aResult += String::CreateFromInt32(nFieldSepCode);
+ aResult += ',';
+ aResult += String::CreateFromInt32(nTextSepCode);
+ aResult += ',';
+ aResult += aStrFont;
+ aResult += ',';
+ aResult += String::CreateFromInt32( bSaveAsShown ? 1 : 0 );
+
+ return aResult;
+}
+
+//------------------------------------------------------------------------
+
+void ScImportOptions::SetTextEncoding( rtl_TextEncoding nEnc )
+{
+ eCharSet = (nEnc == RTL_TEXTENCODING_DONTKNOW ?
+ gsl_getSystemTextEncoding() : nEnc);
+ aStrFont = ScGlobal::GetCharsetString( nEnc );
+}
diff --git a/sc/source/ui/dbgui/imoptdlg.hrc b/sc/source/ui/dbgui/imoptdlg.hrc
new file mode 100644
index 000000000000..5fd9256e8009
--- /dev/null
+++ b/sc/source/ui/dbgui/imoptdlg.hrc
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "sc.hrc"
+
+//#define RID_SCDLG_IMPORTOPT 2256
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+#define FT_FIELDSEP 4
+#define ED_FIELDSEP 5
+#define FT_TEXTSEP 6
+#define ED_TEXTSEP 7
+#define FT_FONT 8
+#define DDLB_FONT 9
+#define LB_FONT 10
+#define FL_FIELDOPT 11
+#define CB_FIXEDWIDTH 12
+#define CB_SAVESHOWN 13
+
diff --git a/sc/source/ui/dbgui/imoptdlg.src b/sc/source/ui/dbgui/imoptdlg.src
new file mode 100644
index 000000000000..e83f3a9c9dac
--- /dev/null
+++ b/sc/source/ui/dbgui/imoptdlg.src
@@ -0,0 +1,147 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "imoptdlg.hrc"
+
+ModalDialog RID_SCDLG_IMPORTOPT
+{
+ HelpId = HID_SC_INPORTOPT ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 256 , 66 ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ Text [ en-US ] = "Import File" ;
+ FixedText FT_FIELDSEP
+ {
+ Pos = MAP_APPFONT ( 12 , 32 ) ;
+ Size = MAP_APPFONT ( 55 , 8 ) ;
+ Text [ en-US ] = "~Field delimiter" ;
+ };
+ ComboBox ED_FIELDSEP
+ {
+ HelpID = "sc:ComboBox:RID_SCDLG_IMPORTOPT:ED_FIELDSEP";
+ Pos = MAP_APPFONT ( 70 , 30 ) ;
+ Size = MAP_APPFONT ( 121 , 60 ) ;
+ DropDown = TRUE ;
+ };
+ FixedText FT_TEXTSEP
+ {
+ Pos = MAP_APPFONT ( 12 , 48 ) ;
+ Size = MAP_APPFONT ( 55 , 8 ) ;
+ Text [ en-US ] = "~Text delimiter" ;
+ };
+ ComboBox ED_TEXTSEP
+ {
+ HelpID = "sc:ComboBox:RID_SCDLG_IMPORTOPT:ED_TEXTSEP";
+ Pos = MAP_APPFONT ( 70 , 46 ) ;
+ Size = MAP_APPFONT ( 121 , 60 ) ;
+ DropDown = TRUE ;
+ };
+ FixedText FT_FONT
+ {
+ Pos = MAP_APPFONT ( 12 , 16 ) ;
+ Size = MAP_APPFONT ( 55 , 8 ) ;
+ Text [ en-US ] = "~Character set" ;
+ };
+ ListBox DDLB_FONT
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_IMPORTOPT:DDLB_FONT";
+ Border = TRUE;
+ Sort = TRUE;
+ DropDown = TRUE ;
+ Pos = MAP_APPFONT ( 70 , 14 ) ;
+ Size = MAP_APPFONT ( 121 , 52 ) ;
+ };
+ ListBox LB_FONT
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_IMPORTOPT:LB_FONT";
+ Border = TRUE;
+ Sort = TRUE;
+ DropDown = FALSE ;
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 179 , 50 ) ;
+ };
+ FixedLine FL_FIELDOPT
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 188 , 8 ) ;
+ Text [ en-US ] = "Field options" ;
+ };
+ CheckBox CB_FIXEDWIDTH
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_IMPORTOPT:CB_FIXEDWIDTH";
+ Pos = MAP_APPFONT( 12, 80 );
+ Size = MAP_APPFONT( 172, 10 );
+ Hide = TRUE;
+ Text [ en-US ] = "Fixed column ~width";
+ };
+ CheckBox CB_SAVESHOWN
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_IMPORTOPT:CB_SAVESHOWN";
+ Pos = MAP_APPFONT( 12, 66 );
+ Size = MAP_APPFONT( 172, 10 );
+ TabStop = TRUE;
+ Hide = TRUE;
+ Text [ en-US ] = "Save cell content as ~shown";
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 202 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 202 , 24 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 202 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/dbgui/makefile.mk b/sc/source/ui/dbgui/makefile.mk
new file mode 100644
index 000000000000..1e7000d0cb07
--- /dev/null
+++ b/sc/source/ui/dbgui/makefile.mk
@@ -0,0 +1,122 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=dbgui
+LIBTARGET=no
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : scpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sc.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/sortdlg.obj \
+ $(SLO)$/tpsort.obj \
+ $(SLO)$/filtdlg.obj \
+ $(SLO)$/sfiltdlg.obj \
+ $(SLO)$/foptmgr.obj \
+ $(SLO)$/pfiltdlg.obj \
+ $(SLO)$/dbnamdlg.obj \
+ $(SLO)$/expftext.obj \
+ $(SLO)$/textimportoptions.obj \
+ $(SLO)$/subtdlg.obj \
+ $(SLO)$/tpsubt.obj \
+ $(SLO)$/fieldwnd.obj \
+ $(SLO)$/pvlaydlg.obj \
+ $(SLO)$/pvfundlg.obj \
+ $(SLO)$/dpgroupdlg.obj \
+ $(SLO)$/dapitype.obj \
+ $(SLO)$/dapidata.obj \
+ $(SLO)$/consdlg.obj \
+ $(SLO)$/scendlg.obj \
+ $(SLO)$/imoptdlg.obj \
+ $(SLO)$/validate.obj \
+ $(SLO)$/csvsplits.obj \
+ $(SLO)$/csvcontrol.obj \
+ $(SLO)$/csvruler.obj \
+ $(SLO)$/csvgrid.obj \
+ $(SLO)$/csvtablebox.obj \
+ $(SLO)$/asciiopt.obj \
+ $(SLO)$/scuiasciiopt.obj \
+ $(SLO)$/scuiimoptdlg.obj
+
+EXCEPTIONSFILES= \
+ $(SLO)$/csvgrid.obj \
+ $(SLO)$/csvruler.obj \
+ $(SLO)$/csvsplits.obj \
+ $(SLO)$/csvtablebox.obj \
+ $(SLO)$/fieldwnd.obj \
+ $(SLO)$/pvfundlg.obj \
+ $(SLO)$/pvlaydlg.obj \
+ $(SLO)$/dapidata.obj \
+ $(SLO)$/validate.obj
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ textimportoptions.src \
+ pivot.src \
+ pvfundlg.src \
+ dpgroupdlg.src \
+ dapitype.src \
+ consdlg.src \
+ scendlg.src \
+ imoptdlg.src \
+ validate.src \
+ asciiopt.src \
+ outline.src
+
+LIB1TARGET = $(SLB)$/$(TARGET).lib
+
+LIB1OBJFILES = \
+ $(SLO)$/filtdlg.obj \
+ $(SLO)$/sfiltdlg.obj \
+ $(SLO)$/foptmgr.obj \
+ $(SLO)$/dbnamdlg.obj \
+ $(SLO)$/expftext.obj \
+ $(SLO)$/fieldwnd.obj \
+ $(SLO)$/pvlaydlg.obj \
+ $(SLO)$/consdlg.obj \
+ $(SLO)$/imoptdlg.obj \
+ $(SLO)$/csvsplits.obj \
+ $(SLO)$/csvcontrol.obj \
+ $(SLO)$/csvruler.obj \
+ $(SLO)$/csvgrid.obj \
+ $(SLO)$/csvtablebox.obj \
+ $(SLO)$/asciiopt.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/sc/source/ui/dbgui/outline.src b/sc/source/ui/dbgui/outline.src
new file mode 100644
index 000000000000..cd59bf3b099d
--- /dev/null
+++ b/sc/source/ui/dbgui/outline.src
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc"
+
+
+// Imageliste hier, damit sie nicht in ui.src beim Zusammenbauen der
+// "echten" Imagelisten stoert
+
+#define OUTLINE_ID_LIST \
+ IdList = { 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; }; \
+ IdCount = { 12; };
+
+ImageList RID_OUTLINEBITMAPS
+{
+ Prefix = "ou";
+ MaskColor = STD_MASKCOLOR;
+ OUTLINE_ID_LIST
+};
+
+ImageList RID_OUTLINEBITMAPS_H
+{
+ Prefix = "ouh";
+ MaskColor = SC_HC_MASKCOLOR;
+ OUTLINE_ID_LIST
+};
+
diff --git a/sc/source/ui/dbgui/pfiltdlg.cxx b/sc/source/ui/dbgui/pfiltdlg.cxx
new file mode 100644
index 000000000000..d590ffb83457
--- /dev/null
+++ b/sc/source/ui/dbgui/pfiltdlg.cxx
@@ -0,0 +1,620 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+#ifndef PCH
+#include <vcl/waitobj.hxx>
+#endif
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "uiitems.hxx"
+#include "global.hxx"
+#include "dbcolect.hxx"
+#include "scresid.hxx"
+
+#include "sc.hrc"
+#include "filter.hrc"
+#include "globstr.hrc"
+
+#define _PFILTDLG_CXX
+#include "pfiltdlg.hxx"
+#undef _PFILTDLG_CXX
+#include <svl/zforlist.hxx>
+
+//==================================================================
+
+ScPivotFilterDlg::ScPivotFilterDlg( Window* pParent,
+ const SfxItemSet& rArgSet,
+ SCTAB nSourceTab )
+
+ : ModalDialog ( pParent, ScResId( RID_SCDLG_PIVOTFILTER ) ),
+ //
+ aFlCriteria ( this, ScResId( FL_CRITERIA ) ),
+ aLbField1 ( this, ScResId( LB_FIELD1 ) ),
+ aLbCond1 ( this, ScResId( LB_COND1 ) ),
+ aEdVal1 ( this, ScResId( ED_VAL1 ) ),
+ aLbConnect1 ( this, ScResId( LB_OP1 ) ),
+ aLbField2 ( this, ScResId( LB_FIELD2 ) ),
+ aLbCond2 ( this, ScResId( LB_COND2 ) ),
+ aEdVal2 ( this, ScResId( ED_VAL2 ) ),
+ aLbConnect2 ( this, ScResId( LB_OP2 ) ),
+ aLbField3 ( this, ScResId( LB_FIELD3 ) ),
+ aLbCond3 ( this, ScResId( LB_COND3 ) ),
+ aEdVal3 ( this, ScResId( ED_VAL3 ) ),
+ aFtConnect ( this, ScResId( FT_OP ) ),
+ aFtField ( this, ScResId( FT_FIELD ) ),
+ aFtCond ( this, ScResId( FT_COND ) ),
+ aFtVal ( this, ScResId( FT_VAL ) ),
+ aFlOptions ( this, ScResId( FL_OPTIONS ) ),
+ aBtnCase ( this, ScResId( BTN_CASE ) ),
+ aBtnRegExp ( this, ScResId( BTN_REGEXP ) ),
+ aBtnUnique ( this, ScResId( BTN_UNIQUE ) ),
+ aFtDbAreaLabel ( this, ScResId( FT_DBAREA_LABEL ) ),
+ aFtDbArea ( this, ScResId( FT_DBAREA ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnMore ( this, ScResId( BTN_MORE ) ),
+ aStrUndefined ( ScResId( SCSTR_UNDEFINED ) ),
+ aStrNoName ( ScGlobal::GetRscString(STR_DB_NONAME) ),
+ aStrNone ( ScResId( SCSTR_NONE ) ),
+ aStrEmpty ( ScResId( SCSTR_EMPTY ) ),
+ aStrNotEmpty ( ScResId( SCSTR_NOTEMPTY ) ),
+ aStrRow ( ScResId( SCSTR_ROW ) ),
+ aStrColumn ( ScResId( SCSTR_COLUMN ) ),
+ //
+ nWhichQuery ( rArgSet.GetPool()->GetWhich( SID_QUERY ) ),
+ theQueryData ( ((const ScQueryItem&)
+ rArgSet.Get( nWhichQuery )).GetQueryData() ),
+ pOutItem ( NULL ),
+ pViewData ( NULL ),
+ pDoc ( NULL ),
+ nSrcTab ( nSourceTab ), // ist nicht im QueryParam
+ nFieldCount ( 0 )
+{
+ for (USHORT i=0; i<=MAXCOL; i++)
+ pEntryLists[i] = NULL;
+
+ Init( rArgSet );
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScPivotFilterDlg::~ScPivotFilterDlg()
+{
+ for (USHORT i=0; i<=MAXCOL; i++)
+ delete pEntryLists[i];
+
+ if ( pOutItem )
+ delete pOutItem;
+}
+
+//------------------------------------------------------------------------
+
+void __EXPORT ScPivotFilterDlg::Init( const SfxItemSet& rArgSet )
+{
+ const ScQueryItem& rQueryItem = (const ScQueryItem&)
+ rArgSet.Get( nWhichQuery );
+
+ aBtnCase.SetClickHdl ( LINK( this, ScPivotFilterDlg, CheckBoxHdl ) );
+
+ aLbField1.SetSelectHdl ( LINK( this, ScPivotFilterDlg, LbSelectHdl ) );
+ aLbField2.SetSelectHdl ( LINK( this, ScPivotFilterDlg, LbSelectHdl ) );
+ aLbField3.SetSelectHdl ( LINK( this, ScPivotFilterDlg, LbSelectHdl ) );
+ aLbConnect1.SetSelectHdl( LINK( this, ScPivotFilterDlg, LbSelectHdl ) );
+ aLbConnect2.SetSelectHdl( LINK( this, ScPivotFilterDlg, LbSelectHdl ) );
+
+ aBtnMore.AddWindow( &aBtnCase );
+ aBtnMore.AddWindow( &aBtnRegExp );
+ aBtnMore.AddWindow( &aBtnUnique );
+ aBtnMore.AddWindow( &aFtDbAreaLabel );
+ aBtnMore.AddWindow( &aFtDbArea );
+ aBtnMore.AddWindow( &aFlOptions );
+
+ aBtnCase .Check( theQueryData.bCaseSens );
+ aBtnRegExp .Check( theQueryData.bRegExp );
+ aBtnUnique .Check( !theQueryData.bDuplicate );
+
+ pViewData = rQueryItem.GetViewData();
+ pDoc = pViewData ? pViewData->GetDocument() : NULL;
+
+ // fuer leichteren Zugriff:
+ aFieldLbArr [0] = &aLbField1;
+ aFieldLbArr [1] = &aLbField2;
+ aFieldLbArr [2] = &aLbField3;
+ aValueEdArr [0] = &aEdVal1;
+ aValueEdArr [1] = &aEdVal2;
+ aValueEdArr [2] = &aEdVal3;
+ aCondLbArr [0] = &aLbCond1;
+ aCondLbArr [1] = &aLbCond2;
+ aCondLbArr [2] = &aLbCond3;
+
+ if ( pViewData && pDoc )
+ {
+ String theAreaStr;
+ ScRange theCurArea ( ScAddress( theQueryData.nCol1,
+ theQueryData.nRow1,
+ nSrcTab ),
+ ScAddress( theQueryData.nCol2,
+ theQueryData.nRow2,
+ nSrcTab ) );
+ ScDBCollection* pDBColl = pDoc->GetDBCollection();
+ String theDbArea;
+ String theDbName = aStrNoName;
+
+ /*
+ * Ueberpruefen, ob es sich bei dem uebergebenen
+ * Bereich um einen Datenbankbereich handelt:
+ */
+
+ theCurArea.Format( theAreaStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+
+ 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 )
+ pDBData->GetName( theDbName );
+ }
+
+ theDbArea.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" ("));
+ theDbArea += theDbName;
+ theDbArea += ')';
+ aFtDbArea.SetText( theDbArea );
+ }
+ else
+ {
+ aFtDbArea.SetText( EMPTY_STRING );
+ }
+
+ // Feldlisten einlesen und Eintraege selektieren:
+
+ FillFieldLists();
+
+ for ( SCSIZE i=0; i<3; i++ )
+ {
+ if ( theQueryData.GetEntry(i).bDoQuery )
+ {
+ ScQueryEntry& rEntry = theQueryData.GetEntry(i);
+
+ String aValStr = *rEntry.pStr;
+ if (!rEntry.bQueryByString && aValStr == EMPTY_STRING)
+ {
+ if (rEntry.nVal == SC_EMPTYFIELDS)
+ aValStr = aStrEmpty;
+ else if (rEntry.nVal == SC_NONEMPTYFIELDS)
+ aValStr = aStrNotEmpty;
+ }
+ USHORT nCondPos = (USHORT)rEntry.eOp;
+ USHORT nFieldSelPos = GetFieldSelPos( static_cast<SCCOL>(rEntry.nField) );
+
+ aFieldLbArr[i]->SelectEntryPos( nFieldSelPos );
+ aCondLbArr [i]->SelectEntryPos( nCondPos );
+ UpdateValueList( static_cast<USHORT>(i+1) );
+ aValueEdArr[i]->SetText( aValStr );
+ if (aValStr == aStrEmpty || aValStr == aStrNotEmpty)
+ aCondLbArr[i]->Disable();
+ }
+ else
+ {
+ aFieldLbArr[i]->SelectEntryPos( 0 ); // "keiner" selektieren
+ aCondLbArr [i]->SelectEntryPos( 0 ); // "=" selektieren
+ UpdateValueList( static_cast<USHORT>(i) );
+ aValueEdArr[i]->SetText( EMPTY_STRING );
+ }
+ aValueEdArr[i]->SetModifyHdl( LINK( this, ScPivotFilterDlg, ValModifyHdl ) );
+ }
+
+ // Disable/Enable Logik:
+
+ (aLbField1.GetSelectEntryPos() != 0)
+ && (aLbField2.GetSelectEntryPos() != 0)
+ ? aLbConnect1.SelectEntryPos( (USHORT)theQueryData.GetEntry(1).eConnect )
+ : aLbConnect1.SetNoSelection();
+
+ (aLbField2.GetSelectEntryPos() != 0)
+ && (aLbField3.GetSelectEntryPos() != 0)
+ ? aLbConnect2.SelectEntryPos( (USHORT)theQueryData.GetEntry(2).eConnect )
+ : aLbConnect2.SetNoSelection();
+
+ if ( aLbField1.GetSelectEntryPos() == 0 )
+ {
+ aLbConnect1.Disable();
+ aLbField2.Disable();
+ aLbCond2.Disable();
+ aEdVal2.Disable();
+ }
+ else if ( aLbConnect1.GetSelectEntryCount() == 0 )
+ {
+ aLbField2.Disable();
+ aLbCond2.Disable();
+ aEdVal2.Disable();
+ }
+
+ if ( aLbField2.GetSelectEntryPos() == 0 )
+ {
+ aLbConnect2.Disable();
+ aLbField3.Disable();
+ aLbCond3.Disable();
+ aEdVal3.Disable();
+ }
+ else if ( aLbConnect2.GetSelectEntryCount() == 0 )
+ {
+ aLbField3.Disable();
+ aLbCond3.Disable();
+ aEdVal3.Disable();
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScPivotFilterDlg::FillFieldLists()
+{
+ aLbField1.Clear();
+ aLbField2.Clear();
+ aLbField3.Clear();
+ aLbField1.InsertEntry( aStrNone, 0 );
+ aLbField2.InsertEntry( aStrNone, 0 );
+ aLbField3.InsertEntry( aStrNone, 0 );
+
+ if ( pDoc )
+ {
+ String aFieldName;
+ SCTAB nTab = nSrcTab;
+ SCCOL nFirstCol = theQueryData.nCol1;
+ SCROW nFirstRow = theQueryData.nRow1;
+ SCCOL nMaxCol = theQueryData.nCol2;
+ SCCOL col = 0;
+ USHORT i=1;
+
+ for ( col=nFirstCol; col<=nMaxCol; col++ )
+ {
+ pDoc->GetString( col, nFirstRow, nTab, aFieldName );
+ if ( aFieldName.Len() == 0 )
+ {
+ aFieldName = aStrColumn;
+ aFieldName += ' ';
+ aFieldName += ScColToAlpha( col );
+ }
+ aLbField1.InsertEntry( aFieldName, i );
+ aLbField2.InsertEntry( aFieldName, i );
+ aLbField3.InsertEntry( aFieldName, i );
+ i++;
+ }
+ nFieldCount = i;
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScPivotFilterDlg::UpdateValueList( USHORT nList )
+{
+ if ( pDoc && nList>0 && nList<=3 )
+ {
+ ComboBox* pValList = aValueEdArr[nList-1];
+ USHORT nFieldSelPos = aFieldLbArr[nList-1]->GetSelectEntryPos();
+ USHORT nListPos = 0;
+ String aCurValue = pValList->GetText();
+
+ pValList->Clear();
+ pValList->InsertEntry( aStrNotEmpty, 0 );
+ pValList->InsertEntry( aStrEmpty, 1 );
+ nListPos = 2;
+
+ if ( pDoc && nFieldSelPos )
+ {
+ SCCOL nColumn = theQueryData.nCol1 + static_cast<SCCOL>(nFieldSelPos) - 1;
+ if (!pEntryLists[nColumn])
+ {
+ WaitObject aWaiter( this );
+
+ SCTAB nTab = nSrcTab;
+ SCROW nFirstRow = theQueryData.nRow1;
+ SCROW nLastRow = theQueryData.nRow2;
+ nFirstRow++;
+ bool bHasDates = false;
+
+ pEntryLists[nColumn] = new TypedScStrCollection( 128, 128 );
+ pEntryLists[nColumn]->SetCaseSensitive( aBtnCase.IsChecked() );
+ pDoc->GetFilterEntriesArea( nColumn, nFirstRow, nLastRow,
+ nTab, *pEntryLists[nColumn], bHasDates );
+ }
+
+ TypedScStrCollection* pColl = pEntryLists[nColumn];
+ USHORT nValueCount = pColl->GetCount();
+ if ( nValueCount > 0 )
+ {
+ for ( USHORT i=0; i<nValueCount; i++ )
+ {
+ pValList->InsertEntry( (*pColl)[i]->GetString(), nListPos );
+ nListPos++;
+ }
+ }
+ }
+ pValList->SetText( aCurValue );
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScPivotFilterDlg::ClearValueList( USHORT nList )
+{
+ if ( nList>0 && nList<=3 )
+ {
+ ComboBox* pValList = aValueEdArr[nList-1];
+ pValList->Clear();
+ pValList->InsertEntry( aStrNotEmpty, 0 );
+ pValList->InsertEntry( aStrEmpty, 1 );
+ pValList->SetText( EMPTY_STRING );
+ }
+}
+
+//------------------------------------------------------------------------
+
+USHORT ScPivotFilterDlg::GetFieldSelPos( SCCOL nField )
+{
+ if ( nField >= theQueryData.nCol1 && nField <= theQueryData.nCol2 )
+ return static_cast<USHORT>(nField - theQueryData.nCol1 + 1);
+ else
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+const ScQueryItem& ScPivotFilterDlg::GetOutputItem()
+{
+ ScQueryParam theParam( theQueryData );
+ USHORT nConnect1 = aLbConnect1.GetSelectEntryPos();
+ USHORT nConnect2 = aLbConnect2.GetSelectEntryPos();
+
+ for ( SCSIZE i=0; i<3; i++ )
+ {
+ USHORT nField = aFieldLbArr[i]->GetSelectEntryPos();
+ ScQueryOp eOp = (ScQueryOp)aCondLbArr[i]->GetSelectEntryPos();
+
+ BOOL bDoThis = (aFieldLbArr[i]->GetSelectEntryPos() != 0);
+ theParam.GetEntry(i).bDoQuery = bDoThis;
+
+ if ( bDoThis )
+ {
+ ScQueryEntry& rEntry = theParam.GetEntry(i);
+
+ String aStrVal( aValueEdArr[i]->GetText() );
+
+ /*
+ * Dialog liefert die ausgezeichneten Feldwerte "leer"/"nicht leer"
+ * als Konstanten in nVal in Verbindung mit dem Schalter
+ * bQueryByString auf FALSE.
+ */
+ if ( aStrVal == aStrEmpty )
+ {
+ *rEntry.pStr = EMPTY_STRING;
+ rEntry.nVal = SC_EMPTYFIELDS;
+ rEntry.bQueryByString = FALSE;
+ }
+ else if ( aStrVal == aStrNotEmpty )
+ {
+ *rEntry.pStr = EMPTY_STRING;
+ rEntry.nVal = SC_NONEMPTYFIELDS;
+ rEntry.bQueryByString = FALSE;
+ }
+ else
+ {
+ *rEntry.pStr = aStrVal;
+ rEntry.nVal = 0;
+ rEntry.bQueryByString = TRUE;
+ }
+
+ rEntry.nField = nField ? (theQueryData.nCol1 +
+ static_cast<SCCOL>(nField) - 1) : static_cast<SCCOL>(0);
+ rEntry.eOp = eOp;
+ }
+ }
+
+ theParam.GetEntry(1).eConnect = (nConnect1 != LISTBOX_ENTRY_NOTFOUND)
+ ? (ScQueryConnect)nConnect1
+ : SC_AND;
+ theParam.GetEntry(2).eConnect = (nConnect2 != LISTBOX_ENTRY_NOTFOUND)
+ ? (ScQueryConnect)nConnect2
+ : SC_AND;
+
+ theParam.bInplace = FALSE;
+ theParam.nDestTab = 0; // Woher kommen diese Werte?
+ theParam.nDestCol = 0;
+ theParam.nDestRow = 0;
+
+ theParam.bDuplicate = !aBtnUnique.IsChecked();
+ theParam.bCaseSens = aBtnCase.IsChecked();
+ theParam.bRegExp = aBtnRegExp.IsChecked();
+
+ if ( pOutItem ) DELETEZ( pOutItem );
+ pOutItem = new ScQueryItem( nWhichQuery, &theParam );
+
+ return *pOutItem;
+}
+
+//------------------------------------------------------------------------
+// Handler:
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScPivotFilterDlg, LbSelectHdl, ListBox*, pLb )
+{
+ /*
+ * Behandlung der Enable/Disable-Logik,
+ * abhaengig davon, welche ListBox angefasst wurde:
+ */
+
+ if ( pLb == &aLbConnect1 )
+ {
+ if ( !aLbField2.IsEnabled() )
+ {
+ aLbField2.Enable();
+ aLbCond2.Enable();
+ aEdVal2.Enable();
+ }
+ }
+ else if ( pLb == &aLbConnect2 )
+ {
+ if ( !aLbField3.IsEnabled() )
+ {
+ aLbField3.Enable();
+ aLbCond3.Enable();
+ aEdVal3.Enable();
+ }
+ }
+ else if ( pLb == &aLbField1 )
+ {
+ if ( aLbField1.GetSelectEntryPos() == 0 )
+ {
+ aLbConnect1.SetNoSelection();
+ aLbConnect2.SetNoSelection();
+ aLbField2.SelectEntryPos( 0 );
+ aLbField3.SelectEntryPos( 0 );
+ aLbCond2.SelectEntryPos( 0 );
+ aLbCond3.SelectEntryPos( 0 );
+ ClearValueList( 1 );
+ ClearValueList( 2 );
+ ClearValueList( 3 );
+
+ aLbConnect1.Disable();
+ aLbConnect2.Disable();
+ aLbField2.Disable();
+ aLbField3.Disable();
+ aLbCond2.Disable();
+ aLbCond3.Disable();
+ aEdVal2.Disable();
+ aEdVal3.Disable();
+ }
+ else
+ {
+ UpdateValueList( 1 );
+ if ( !aLbConnect1.IsEnabled() )
+ {
+ aLbConnect1.Enable();
+ }
+ }
+ }
+ else if ( pLb == &aLbField2 )
+ {
+ if ( aLbField2.GetSelectEntryPos() == 0 )
+ {
+ aLbConnect2.SetNoSelection();
+ aLbField3.SelectEntryPos( 0 );
+ aLbCond3.SelectEntryPos( 0 );
+ ClearValueList( 2 );
+ ClearValueList( 3 );
+
+ aLbConnect2.Disable();
+ aLbField3.Disable();
+ aLbCond3.Disable();
+ aEdVal3.Disable();
+ }
+ else
+ {
+ UpdateValueList( 2 );
+ if ( !aLbConnect2.IsEnabled() )
+ {
+ aLbConnect2.Enable();
+ }
+ }
+ }
+ else if ( pLb == &aLbField3 )
+ {
+ ( aLbField3.GetSelectEntryPos() == 0 )
+ ? ClearValueList( 3 )
+ : UpdateValueList( 3 );
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScPivotFilterDlg, CheckBoxHdl, CheckBox*, pBox )
+{
+ // bei Gross-/Kleinschreibung die Werte-Listen aktualisieren
+
+ if ( pBox == &aBtnCase ) // Wertlisten
+ {
+ for (USHORT i=0; i<=MAXCOL; i++)
+ DELETEZ( pEntryLists[i] );
+
+ String aCurVal1 = aEdVal1.GetText();
+ String aCurVal2 = aEdVal2.GetText();
+ String aCurVal3 = aEdVal3.GetText();
+ UpdateValueList( 1 );
+ UpdateValueList( 2 );
+ UpdateValueList( 3 );
+ aEdVal1.SetText( aCurVal1 );
+ aEdVal2.SetText( aCurVal2 );
+ aEdVal3.SetText( aCurVal3 );
+ }
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScPivotFilterDlg, ValModifyHdl, ComboBox*, pEd )
+{
+ if ( pEd )
+ {
+ String aStrVal = pEd->GetText();
+ ListBox* pLb = &aLbCond1;
+
+ if ( pEd == &aEdVal2 ) pLb = &aLbCond2;
+ else if ( pEd == &aEdVal3 ) pLb = &aLbCond3;
+
+ // wenn einer der Sonderwerte leer/nicht-leer
+ // gewaehlt wird, so macht nur der =-Operator Sinn:
+
+ if ( aStrEmpty == aStrVal || aStrNotEmpty == aStrVal )
+ {
+ pLb->SelectEntry( '=' );
+ pLb->Disable();
+ }
+ else
+ pLb->Enable();
+ }
+
+ return 0;
+}
+
+
diff --git a/sc/source/ui/dbgui/pivot.hrc b/sc/source/ui/dbgui/pivot.hrc
new file mode 100644
index 000000000000..1a97d4c75b52
--- /dev/null
+++ b/sc/source/ui/dbgui/pivot.hrc
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "sc.hrc" // ->RID_SCDLG_PIVOT_LAYOUT
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+#define BTN_MORE 4
+#define BTN_REMOVE 5
+#define BTN_OPTIONS 6
+
+#define FL_LAYOUT 10
+#define WND_COL 11
+#define WND_ROW 12
+#define WND_DATA 13
+#define WND_SELECT 14
+#define WND_FIELD 15
+#define WND_FIELD_SPACE 16
+#define WND_HSCROLL 17
+#define WND_PAGE 18
+#define FT_COL 31
+#define FT_ROW 32
+#define FT_DATA 33
+#define STR_SELECT 34
+#define FT_PAGE 35
+
+#define PTR_FIELD 18
+#define FT_INFO 19
+
+#define FL_OUTPUT 20
+#define FT_OUTAREA 21
+#define LB_OUTAREA 22
+#define ED_OUTAREA 23
+#define RB_OUTAREA 24
+#define BTN_IGNEMPTYROWS 25
+#define BTN_DETECTCAT 26
+#define BTN_TOTALCOL 27
+#define BTN_TOTALROW 28
+#define BTN_FILTER 29
+#define BTN_DRILLDOWN 30
+
+#define FT_INAREA 40
+#define RB_INAREA 41
+#define ED_INAREA 42
+
+#define PIVOTSTR_SUM 1
+#define PIVOTSTR_COUNT 2
+#define PIVOTSTR_AVG 3
+#define PIVOTSTR_MAX 4
+#define PIVOTSTR_MIN 5
+#define PIVOTSTR_PROD 6
+#define PIVOTSTR_COUNT2 7
+#define PIVOTSTR_DEV 8
+#define PIVOTSTR_DEV2 9
+#define PIVOTSTR_VAR 10
+#define PIVOTSTR_VAR2 11
+
diff --git a/sc/source/ui/dbgui/pivot.src b/sc/source/ui/dbgui/pivot.src
new file mode 100644
index 000000000000..763f03fe82bf
--- /dev/null
+++ b/sc/source/ui/dbgui/pivot.src
@@ -0,0 +1,342 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "pivot.hrc"
+
+ModelessDialog RID_SCDLG_PIVOT_LAYOUT
+{
+ OutputSize = TRUE ;
+ HelpId = CMD_SID_OPENDLG_PIVOTTABLE ;
+ Size = MAP_APPFONT ( 336 , 190 ) ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ Text [ en-US ] = "DataPilot" ;
+
+ FixedText FT_PAGE
+ {
+ Pos = MAP_APPFONT ( 194 , 168 ) ;
+ Size = MAP_APPFONT ( 37 , 8 ) ;
+ Text[ en-US ] = "Page Fields" ;
+ };
+ Control WND_PAGE
+ {
+ Pos = MAP_APPFONT ( 6 , 14 ) ;
+ Size = MAP_APPFONT ( 182 , 24 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_COL
+ {
+ Pos = MAP_APPFONT ( 231 , 168 ) ;
+ Size = MAP_APPFONT ( 37 , 8 ) ;
+ Text [ en-US ] = "Column Fields" ;
+ };
+ Control WND_COL
+ {
+ Pos = MAP_APPFONT ( 44 , 40 ) ;
+ Size = MAP_APPFONT ( 144 , 24 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_ROW
+ {
+ Pos = MAP_APPFONT ( 194 , 176 ) ;
+ Size = MAP_APPFONT ( 37 , 8 ) ;
+ Text [ en-US ] = "Row\nFields" ;
+ };
+ Control WND_ROW
+ {
+ Pos = MAP_APPFONT ( 6 , 66 ) ;
+ Size = MAP_APPFONT ( 36 , 96 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_DATA
+ {
+ Pos = MAP_APPFONT ( 231, 176 ) ;
+ Size = MAP_APPFONT ( 37 , 8 ) ;
+ Text [ en-US ] = "Data Fields" ;
+ };
+ Control WND_DATA
+ {
+ Pos = MAP_APPFONT ( 44 , 66 ) ;
+ Size = MAP_APPFONT ( 144 , 96 ) ;
+ TabStop = TRUE ;
+ };
+ Control WND_SELECT
+ {
+ Pos = MAP_APPFONT ( 194 , 14 ) ;
+ Size = MAP_APPFONT ( 70 , 126 ) ;
+ TabStop = TRUE ;
+ };
+ String STR_SELECT
+ {
+ Text [ en-US ] = "Selection area";
+ };
+ ScrollBar WND_HSCROLL
+ {
+ Pos = MAP_APPFONT ( 194 , 144 ) ;
+ Size = MAP_APPFONT ( 70 , 8 ) ;
+ HScroll = TRUE ;
+ TabStop = FALSE ;
+ };
+ FixedText FT_INFO
+ {
+ Pos = MAP_APPFONT ( 6 , 168 ) ;
+ Size = MAP_APPFONT ( 182 , 16 ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "Drag the fields from the right into the desired position." ;
+ };
+ FixedLine FL_LAYOUT
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 268 , 8 ) ;
+ Text [ en-US ] = "Layout";
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 280 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 280 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 280 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton BTN_REMOVE
+ {
+ HelpID = "sc:PushButton:RID_SCDLG_PIVOT_LAYOUT:BTN_REMOVE";
+ Pos = MAP_APPFONT ( 280 , 63 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Remove";
+ };
+ PushButton BTN_OPTIONS
+ {
+ HelpID = "sc:PushButton:RID_SCDLG_PIVOT_LAYOUT:BTN_OPTIONS";
+ Pos = MAP_APPFONT ( 280 , 80 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Options...";
+ };
+ MoreButton BTN_MORE
+ {
+ HelpID = "sc:MoreButton:RID_SCDLG_PIVOT_LAYOUT:BTN_MORE";
+ Pos = MAP_APPFONT ( 280 , 170 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ MapUnit = MAP_APPFONT ;
+ Delta = 90 ;
+ };
+ Window WND_FIELD
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 36 , 12 ) ;
+ };
+ Window WND_FIELD_SPACE
+ {
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 2 , 2 ) ;
+ };
+ FixedLine FL_OUTPUT
+ {
+ Pos = MAP_APPFONT ( 6 , 190 ) ;
+ Size = MAP_APPFONT ( 268 , 8 ) ;
+ Text [ en-US ] = "Result" ;
+ Hide = TRUE ;
+ };
+
+ FixedText FT_INAREA
+ {
+ Pos = MAP_APPFONT ( 12 , 203 ) ;
+ Size = MAP_APPFONT ( 59 , 8 ) ;
+ Hide = TRUE ;
+ Text [ en-US ] = "Selection from" ;
+ };
+ Edit ED_INAREA
+ {
+ HelpID = "sc:Edit:RID_SCDLG_PIVOT_LAYOUT:ED_INAREA";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 73 , 201 ) ;
+ Size = MAP_APPFONT ( 100 , 12 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ };
+ ImageButton RB_INAREA
+ {
+ HelpID = "sc:ImageButton:RID_SCDLG_PIVOT_LAYOUT:RB_INAREA";
+ Pos = MAP_APPFONT ( 177 , 200 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+
+ FixedText FT_OUTAREA
+ {
+ Pos = MAP_APPFONT ( 12 , 221 ) ;
+ Size = MAP_APPFONT ( 59 , 8 ) ;
+ Hide = TRUE ;
+ Text [ en-US ] = "Results to" ;
+ };
+ ListBox LB_OUTAREA
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_PIVOT_LAYOUT:LB_OUTAREA";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 73 , 219 ) ;
+ Size = MAP_APPFONT ( 75 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ Hide = TRUE ;
+ };
+ Edit ED_OUTAREA
+ {
+ HelpID = "sc:Edit:RID_SCDLG_PIVOT_LAYOUT:ED_OUTAREA";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 152 , 219 ) ;
+ Size = MAP_APPFONT ( 100 , 12 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ };
+ ImageButton RB_OUTAREA
+ {
+ HelpID = "sc:ImageButton:RID_SCDLG_PIVOT_LAYOUT:RB_OUTAREA";
+ Pos = MAP_APPFONT ( 256 , 218 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ CheckBox BTN_IGNEMPTYROWS
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_PIVOT_LAYOUT:BTN_IGNEMPTYROWS";
+ Pos = MAP_APPFONT ( 12 , 237 ) ;
+ Size = MAP_APPFONT ( 124 , 10 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ Text [ en-US ] = "Ignore ~empty rows" ;
+ };
+ CheckBox BTN_DETECTCAT
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_PIVOT_LAYOUT:BTN_DETECTCAT";
+ Pos = MAP_APPFONT ( 142 , 237 ) ;
+ Size = MAP_APPFONT ( 124 , 10 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ Text [ en-US ] = "~Identify categories" ;
+ };
+ CheckBox BTN_TOTALCOL
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_PIVOT_LAYOUT:BTN_TOTALCOL";
+ Pos = MAP_APPFONT ( 12 , 251 ) ;
+ Size = MAP_APPFONT ( 124 , 10 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ Text [ en-US ] = "Total columns" ;
+ };
+ CheckBox BTN_TOTALROW
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_PIVOT_LAYOUT:BTN_TOTALROW";
+ Pos = MAP_APPFONT ( 142 , 251 ) ;
+ Size = MAP_APPFONT ( 124 , 10 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ Text [ en-US ] = "~Total rows" ;
+ };
+ CheckBox BTN_FILTER
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_PIVOT_LAYOUT:BTN_FILTER";
+ Pos = MAP_APPFONT ( 12 , 265 ) ;
+ Size = MAP_APPFONT ( 124 , 10 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ Text [ en-US ] = "~Add filter" ;
+ };
+ CheckBox BTN_DRILLDOWN
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_PIVOT_LAYOUT:BTN_DRILLDOWN";
+ Pos = MAP_APPFONT ( 142 , 265 ) ;
+ Size = MAP_APPFONT ( 124 , 10 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ Text [ en-US ] = "Ena~ble drill to details" ;
+ };
+ String PIVOTSTR_SUM
+ {
+ Text [ en-US ] = "Sum - " ;
+ };
+ String PIVOTSTR_COUNT
+ {
+ Text [ en-US ] = "Count - " ;
+ };
+ String PIVOTSTR_AVG
+ {
+ Text [ en-US ] = "Mean - " ;
+ };
+ String PIVOTSTR_MAX
+ {
+ Text [ en-US ] = "Max - " ;
+ };
+ String PIVOTSTR_MIN
+ {
+ Text [ en-US ] = "Min - " ;
+ };
+ String PIVOTSTR_PROD
+ {
+ Text [ en-US ] = "Product - " ;
+ };
+ String PIVOTSTR_COUNT2
+ {
+ Text [ en-US ] = "Count - " ;
+ };
+ String PIVOTSTR_DEV
+ {
+ Text [ en-US ] = "StDev - " ;
+ };
+ String PIVOTSTR_DEV2
+ {
+ Text [ en-US ] = "StDevP - " ;
+ };
+ String PIVOTSTR_VAR
+ {
+ Text [ en-US ] = "Var - " ;
+ };
+ String PIVOTSTR_VAR2
+ {
+ Text [ en-US ] = "VarP - " ;
+ };
+};
+
diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx
new file mode 100644
index 000000000000..b5a19ef0ec9b
--- /dev/null
+++ b/sc/source/ui/dbgui/pvfundlg.cxx
@@ -0,0 +1,790 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+#include "pvfundlg.hxx"
+
+#include <com/sun/star/sheet/DataPilotFieldReferenceType.hpp>
+#include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp>
+#include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp>
+#include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
+#include <com/sun/star/sheet/DataPilotFieldShowItemsMode.hpp>
+
+#include <tools/resary.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "scresid.hxx"
+#include "dpobject.hxx"
+#include "dpsave.hxx"
+#include "pvfundlg.hrc"
+#include "globstr.hrc"
+
+#include <vector>
+
+// ============================================================================
+
+using namespace ::com::sun::star::sheet;
+
+using ::rtl::OUString;
+using ::com::sun::star::uno::Sequence;
+using ::std::vector;
+
+// ============================================================================
+
+namespace {
+
+/** Appends all strings from the Sequence to the list box.
+
+ Empty strings are replaced by a localized "(empty)" entry and inserted at
+ the specified position.
+
+ @return true = The passed string list contains an empty string entry.
+ */
+template< typename ListBoxType >
+bool lclFillListBox( ListBoxType& rLBox, const Sequence< OUString >& rStrings, USHORT nEmptyPos = LISTBOX_APPEND )
+{
+ bool bEmpty = false;
+ if( const OUString* pStr = rStrings.getConstArray() )
+ {
+ for( const OUString* pEnd = pStr + rStrings.getLength(); pStr != pEnd; ++pStr )
+ {
+ if( pStr->getLength() )
+ rLBox.InsertEntry( *pStr );
+ else
+ {
+ rLBox.InsertEntry( ScGlobal::GetRscString( STR_EMPTYDATA ), nEmptyPos );
+ bEmpty = true;
+ }
+ }
+ }
+ return bEmpty;
+}
+
+template< typename ListBoxType >
+bool lclFillListBox( ListBoxType& rLBox, const vector<ScDPLabelData::Member>& rMembers, USHORT nEmptyPos = LISTBOX_APPEND )
+{
+ bool bEmpty = false;
+ vector<ScDPLabelData::Member>::const_iterator itr = rMembers.begin(), itrEnd = rMembers.end();
+ for (; itr != itrEnd; ++itr)
+ {
+ OUString aName = itr->getDisplayName();
+ if (aName.getLength())
+ rLBox.InsertEntry(aName);
+ else
+ {
+ rLBox.InsertEntry(ScGlobal::GetRscString(STR_EMPTYDATA), nEmptyPos);
+ bEmpty = true;
+ }
+ }
+ return bEmpty;
+}
+
+/** Searches for a listbox entry, starts search at specified position. */
+USHORT lclFindListBoxEntry( const ListBox& rLBox, const String& rEntry, USHORT nStartPos )
+{
+ USHORT nPos = nStartPos;
+ while( (nPos < rLBox.GetEntryCount()) && (rLBox.GetEntry( nPos ) != rEntry) )
+ ++nPos;
+ return (nPos < rLBox.GetEntryCount()) ? nPos : LISTBOX_ENTRY_NOTFOUND;
+}
+
+/** This table represents the order of the strings in the resource string array. */
+static const USHORT spnFunctions[] =
+{
+ PIVOT_FUNC_SUM,
+ PIVOT_FUNC_COUNT,
+ PIVOT_FUNC_AVERAGE,
+ PIVOT_FUNC_MAX,
+ PIVOT_FUNC_MIN,
+ PIVOT_FUNC_PRODUCT,
+ PIVOT_FUNC_COUNT_NUM,
+ PIVOT_FUNC_STD_DEV,
+ PIVOT_FUNC_STD_DEVP,
+ PIVOT_FUNC_STD_VAR,
+ PIVOT_FUNC_STD_VARP
+};
+
+const USHORT SC_BASEITEM_PREV_POS = 0;
+const USHORT SC_BASEITEM_NEXT_POS = 1;
+const USHORT SC_BASEITEM_USER_POS = 2;
+
+const USHORT SC_SORTNAME_POS = 0;
+const USHORT SC_SORTDATA_POS = 1;
+
+const long SC_SHOW_DEFAULT = 10;
+
+static const ScDPListBoxWrapper::MapEntryType spRefTypeMap[] =
+{
+ { 0, DataPilotFieldReferenceType::NONE },
+ { 1, DataPilotFieldReferenceType::ITEM_DIFFERENCE },
+ { 2, DataPilotFieldReferenceType::ITEM_PERCENTAGE },
+ { 3, DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE },
+ { 4, DataPilotFieldReferenceType::RUNNING_TOTAL },
+ { 5, DataPilotFieldReferenceType::ROW_PERCENTAGE },
+ { 6, DataPilotFieldReferenceType::COLUMN_PERCENTAGE },
+ { 7, DataPilotFieldReferenceType::TOTAL_PERCENTAGE },
+ { 8, DataPilotFieldReferenceType::INDEX },
+ { LISTBOX_ENTRY_NOTFOUND, DataPilotFieldReferenceType::NONE }
+};
+
+static const ScDPListBoxWrapper::MapEntryType spLayoutMap[] =
+{
+ { 0, DataPilotFieldLayoutMode::TABULAR_LAYOUT },
+ { 1, DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP },
+ { 2, DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM },
+ { LISTBOX_ENTRY_NOTFOUND, DataPilotFieldLayoutMode::TABULAR_LAYOUT }
+};
+
+static const ScDPListBoxWrapper::MapEntryType spShowFromMap[] =
+{
+ { 0, DataPilotFieldShowItemsMode::FROM_TOP },
+ { 1, DataPilotFieldShowItemsMode::FROM_BOTTOM },
+ { LISTBOX_ENTRY_NOTFOUND, DataPilotFieldShowItemsMode::FROM_TOP }
+};
+
+} // namespace
+
+// ============================================================================
+
+ScDPFunctionListBox::ScDPFunctionListBox( Window* pParent, const ResId& rResId ) :
+ MultiListBox( pParent, rResId )
+{
+ FillFunctionNames();
+}
+
+void ScDPFunctionListBox::SetSelection( USHORT nFuncMask )
+{
+ if( (nFuncMask == PIVOT_FUNC_NONE) || (nFuncMask == PIVOT_FUNC_AUTO) )
+ SetNoSelection();
+ else
+ for( USHORT nEntry = 0, nCount = GetEntryCount(); nEntry < nCount; ++nEntry )
+ SelectEntryPos( nEntry, (nFuncMask & spnFunctions[ nEntry ]) != 0 );
+}
+
+USHORT ScDPFunctionListBox::GetSelection() const
+{
+ USHORT nFuncMask = PIVOT_FUNC_NONE;
+ for( USHORT nSel = 0, nCount = GetSelectEntryCount(); nSel < nCount; ++nSel )
+ nFuncMask |= spnFunctions[ GetSelectEntryPos( nSel ) ];
+ return nFuncMask;
+}
+
+void ScDPFunctionListBox::FillFunctionNames()
+{
+ DBG_ASSERT( !GetEntryCount(), "ScDPFunctionListBox::FillFunctionNames - do not add texts to resource" );
+ Clear();
+ ResStringArray aArr( ScResId( SCSTR_DPFUNCLISTBOX ) );
+ for( USHORT nIndex = 0, nCount = sal::static_int_cast<USHORT>(aArr.Count()); nIndex < nCount; ++nIndex )
+ InsertEntry( aArr.GetString( nIndex ) );
+}
+
+// ============================================================================
+
+ScDPFunctionDlg::ScDPFunctionDlg(
+ Window* pParent, const ScDPLabelDataVec& rLabelVec,
+ const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DPDATAFIELD ) ),
+ maFlFunc ( this, ScResId( FL_FUNC ) ),
+ maLbFunc ( this, ScResId( LB_FUNC ) ),
+ maFtNameLabel ( this, ScResId( FT_NAMELABEL ) ),
+ maFtName ( this, ScResId( FT_NAME ) ),
+ maFlDisplay ( this, ScResId( FL_DISPLAY ) ),
+ maFtType ( this, ScResId( FT_TYPE ) ),
+ maLbType ( this, ScResId( LB_TYPE ) ),
+ maFtBaseField ( this, ScResId( FT_BASEFIELD ) ),
+ maLbBaseField ( this, ScResId( LB_BASEFIELD ) ),
+ maFtBaseItem ( this, ScResId( FT_BASEITEM ) ),
+ maLbBaseItem ( this, ScResId( LB_BASEITEM ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+ maBtnMore ( this, ScResId( BTN_MORE ) ),
+ maLbTypeWrp ( maLbType, spRefTypeMap ),
+ mrLabelVec ( rLabelVec ),
+ mbEmptyItem ( false )
+{
+ FreeResource();
+ Init( rLabelData, rFuncData );
+}
+
+USHORT ScDPFunctionDlg::GetFuncMask() const
+{
+ return maLbFunc.GetSelection();
+}
+
+DataPilotFieldReference ScDPFunctionDlg::GetFieldRef() const
+{
+ DataPilotFieldReference aRef;
+
+ aRef.ReferenceType = maLbTypeWrp.GetControlValue();
+ aRef.ReferenceField = maLbBaseField.GetSelectEntry();
+
+ USHORT nBaseItemPos = maLbBaseItem.GetSelectEntryPos();
+ switch( nBaseItemPos )
+ {
+ case SC_BASEITEM_PREV_POS:
+ aRef.ReferenceItemType = DataPilotFieldReferenceItemType::PREVIOUS;
+ break;
+ case SC_BASEITEM_NEXT_POS:
+ aRef.ReferenceItemType = DataPilotFieldReferenceItemType::NEXT;
+ break;
+ default:
+ {
+ aRef.ReferenceItemType = DataPilotFieldReferenceItemType::NAMED;
+ if( !mbEmptyItem || (nBaseItemPos > SC_BASEITEM_USER_POS) )
+ aRef.ReferenceItemName = maLbBaseItem.GetSelectEntry();
+ }
+ }
+
+ return aRef;
+}
+
+void ScDPFunctionDlg::Init( const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData )
+{
+ // list box
+ USHORT nFuncMask = (rFuncData.mnFuncMask == PIVOT_FUNC_NONE) ? PIVOT_FUNC_SUM : rFuncData.mnFuncMask;
+ maLbFunc.SetSelection( nFuncMask );
+
+ // field name
+ maFtName.SetText(rLabelData.getDisplayName());
+
+ // "More button" controls
+ maBtnMore.AddWindow( &maFlDisplay );
+ maBtnMore.AddWindow( &maFtType );
+ maBtnMore.AddWindow( &maLbType );
+ maBtnMore.AddWindow( &maFtBaseField );
+ maBtnMore.AddWindow( &maLbBaseField );
+ maBtnMore.AddWindow( &maFtBaseItem );
+ maBtnMore.AddWindow( &maLbBaseItem );
+
+ // handlers
+ maLbFunc.SetDoubleClickHdl( LINK( this, ScDPFunctionDlg, DblClickHdl ) );
+ maLbType.SetSelectHdl( LINK( this, ScDPFunctionDlg, SelectHdl ) );
+ maLbBaseField.SetSelectHdl( LINK( this, ScDPFunctionDlg, SelectHdl ) );
+
+ // base field list box
+ for( ScDPLabelDataVec::const_iterator aIt = mrLabelVec.begin(), aEnd = mrLabelVec.end(); aIt != aEnd; ++aIt )
+ maLbBaseField.InsertEntry(aIt->getDisplayName());
+
+ // base item list box
+ maLbBaseItem.SetSeparatorPos( SC_BASEITEM_USER_POS - 1 );
+
+ // select field reference type
+ maLbTypeWrp.SetControlValue( rFuncData.maFieldRef.ReferenceType );
+ SelectHdl( &maLbType ); // enables base field/item list boxes
+
+ // select base field
+ maLbBaseField.SelectEntry( rFuncData.maFieldRef.ReferenceField );
+ if( maLbBaseField.GetSelectEntryPos() >= maLbBaseField.GetEntryCount() )
+ maLbBaseField.SelectEntryPos( 0 );
+ SelectHdl( &maLbBaseField ); // fills base item list, selects base item
+
+ // select base item
+ switch( rFuncData.maFieldRef.ReferenceItemType )
+ {
+ case DataPilotFieldReferenceItemType::PREVIOUS:
+ maLbBaseItem.SelectEntryPos( SC_BASEITEM_PREV_POS );
+ break;
+ case DataPilotFieldReferenceItemType::NEXT:
+ maLbBaseItem.SelectEntryPos( SC_BASEITEM_NEXT_POS );
+ break;
+ default:
+ {
+ if( mbEmptyItem && !rFuncData.maFieldRef.ReferenceItemName.getLength() )
+ {
+ // select special "(empty)" entry added before other items
+ maLbBaseItem.SelectEntryPos( SC_BASEITEM_USER_POS );
+ }
+ else
+ {
+ USHORT nStartPos = mbEmptyItem ? (SC_BASEITEM_USER_POS + 1) : SC_BASEITEM_USER_POS;
+ USHORT nPos = lclFindListBoxEntry( maLbBaseItem, rFuncData.maFieldRef.ReferenceItemName, nStartPos );
+ if( nPos >= maLbBaseItem.GetEntryCount() )
+ nPos = (maLbBaseItem.GetEntryCount() > SC_BASEITEM_USER_POS) ? SC_BASEITEM_USER_POS : SC_BASEITEM_PREV_POS;
+ maLbBaseItem.SelectEntryPos( nPos );
+ }
+ }
+ }
+}
+
+IMPL_LINK( ScDPFunctionDlg, SelectHdl, ListBox*, pLBox )
+{
+ if( pLBox == &maLbType )
+ {
+ bool bEnableField, bEnableItem;
+ switch( maLbTypeWrp.GetControlValue() )
+ {
+ case DataPilotFieldReferenceType::ITEM_DIFFERENCE:
+ case DataPilotFieldReferenceType::ITEM_PERCENTAGE:
+ case DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE:
+ bEnableField = bEnableItem = true;
+ break;
+
+ case DataPilotFieldReferenceType::RUNNING_TOTAL:
+ bEnableField = true;
+ bEnableItem = false;
+ break;
+
+ default:
+ bEnableField = bEnableItem = false;
+ }
+
+ bEnableField &= maLbBaseField.GetEntryCount() > 0;
+ maFtBaseField.Enable( bEnableField );
+ maLbBaseField.Enable( bEnableField );
+
+ bEnableItem &= bEnableField;
+ maFtBaseItem.Enable( bEnableItem );
+ maLbBaseItem.Enable( bEnableItem );
+ }
+ else if( pLBox == &maLbBaseField )
+ {
+ // keep "previous" and "next" entries
+ while( maLbBaseItem.GetEntryCount() > SC_BASEITEM_USER_POS )
+ maLbBaseItem.RemoveEntry( SC_BASEITEM_USER_POS );
+
+ // update item list for current base field
+ mbEmptyItem = false;
+ size_t nBasePos = maLbBaseField.GetSelectEntryPos();
+ if( nBasePos < mrLabelVec.size() )
+ mbEmptyItem = lclFillListBox( maLbBaseItem, mrLabelVec[ nBasePos ].maMembers, SC_BASEITEM_USER_POS );
+
+ // select base item
+ USHORT nItemPos = (maLbBaseItem.GetEntryCount() > SC_BASEITEM_USER_POS) ? SC_BASEITEM_USER_POS : SC_BASEITEM_PREV_POS;
+ maLbBaseItem.SelectEntryPos( nItemPos );
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDPFunctionDlg, DblClickHdl, MultiListBox*, EMPTYARG )
+{
+ maBtnOk.Click();
+ return 0;
+}
+
+// ============================================================================
+
+ScDPSubtotalDlg::ScDPSubtotalDlg( Window* pParent, ScDPObject& rDPObj,
+ const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData,
+ const ScDPNameVec& rDataFields, bool bEnableLayout ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_PIVOTSUBT ) ),
+ maFlSubt ( this, ScResId( FL_FUNC ) ),
+ maRbNone ( this, ScResId( RB_NONE ) ),
+ maRbAuto ( this, ScResId( RB_AUTO ) ),
+ maRbUser ( this, ScResId( RB_USER ) ),
+ maLbFunc ( this, ScResId( LB_FUNC ) ),
+ maFtNameLabel ( this, ScResId( FT_NAMELABEL ) ),
+ maFtName ( this, ScResId( FT_NAME ) ),
+ maCbShowAll ( this, ScResId( CB_SHOWALL ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+ maBtnOptions ( this, ScResId( BTN_OPTIONS ) ),
+ mrDPObj ( rDPObj ),
+ mrDataFields ( rDataFields ),
+ maLabelData ( rLabelData ),
+ mbEnableLayout ( bEnableLayout )
+{
+ FreeResource();
+ Init( rLabelData, rFuncData );
+}
+
+USHORT ScDPSubtotalDlg::GetFuncMask() const
+{
+ USHORT nFuncMask = PIVOT_FUNC_NONE;
+
+ if( maRbAuto.IsChecked() )
+ nFuncMask = PIVOT_FUNC_AUTO;
+ else if( maRbUser.IsChecked() )
+ nFuncMask = maLbFunc.GetSelection();
+
+ return nFuncMask;
+}
+
+void ScDPSubtotalDlg::FillLabelData( ScDPLabelData& rLabelData ) const
+{
+ rLabelData.mnFuncMask = GetFuncMask();
+ rLabelData.mnUsedHier = maLabelData.mnUsedHier;
+ rLabelData.mbShowAll = maCbShowAll.IsChecked();
+ rLabelData.maMembers = maLabelData.maMembers;
+ rLabelData.maSortInfo = maLabelData.maSortInfo;
+ rLabelData.maLayoutInfo = maLabelData.maLayoutInfo;
+ rLabelData.maShowInfo = maLabelData.maShowInfo;
+}
+
+void ScDPSubtotalDlg::Init( const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData )
+{
+ // field name
+ maFtName.SetText(rLabelData.getDisplayName());
+
+ // radio buttons
+ maRbNone.SetClickHdl( LINK( this, ScDPSubtotalDlg, RadioClickHdl ) );
+ maRbAuto.SetClickHdl( LINK( this, ScDPSubtotalDlg, RadioClickHdl ) );
+ maRbUser.SetClickHdl( LINK( this, ScDPSubtotalDlg, RadioClickHdl ) );
+
+ RadioButton* pRBtn = 0;
+ switch( rFuncData.mnFuncMask )
+ {
+ case PIVOT_FUNC_NONE: pRBtn = &maRbNone; break;
+ case PIVOT_FUNC_AUTO: pRBtn = &maRbAuto; break;
+ default: pRBtn = &maRbUser;
+ }
+ pRBtn->Check();
+ RadioClickHdl( pRBtn );
+
+ // list box
+ maLbFunc.SetSelection( rFuncData.mnFuncMask );
+ maLbFunc.SetDoubleClickHdl( LINK( this, ScDPSubtotalDlg, DblClickHdl ) );
+
+ // show all
+ maCbShowAll.Check( rLabelData.mbShowAll );
+
+ // options
+ maBtnOptions.SetClickHdl( LINK( this, ScDPSubtotalDlg, ClickHdl ) );
+}
+
+// ----------------------------------------------------------------------------
+
+IMPL_LINK( ScDPSubtotalDlg, RadioClickHdl, RadioButton*, pBtn )
+{
+ maLbFunc.Enable( pBtn == &maRbUser );
+ return 0;
+}
+
+IMPL_LINK( ScDPSubtotalDlg, DblClickHdl, MultiListBox*, EMPTYARG )
+{
+ maBtnOk.Click();
+ return 0;
+}
+
+IMPL_LINK( ScDPSubtotalDlg, ClickHdl, PushButton*, pBtn )
+{
+ if( pBtn == &maBtnOptions )
+ {
+ ScDPSubtotalOptDlg* pDlg = new ScDPSubtotalOptDlg( this, mrDPObj, maLabelData, mrDataFields, mbEnableLayout );
+ if( pDlg->Execute() == RET_OK )
+ pDlg->FillLabelData( maLabelData );
+ delete pDlg;
+ }
+ return 0;
+}
+
+// ============================================================================
+
+ScDPSubtotalOptDlg::ScDPSubtotalOptDlg( Window* pParent, ScDPObject& rDPObj,
+ const ScDPLabelData& rLabelData, const ScDPNameVec& rDataFields,
+ bool bEnableLayout ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DPSUBTOTAL_OPT ) ),
+ maFlSortBy ( this, ScResId( FL_SORT_BY ) ),
+ maLbSortBy ( this, ScResId( LB_SORT_BY ) ),
+ maRbSortAsc ( this, ScResId( RB_SORT_ASC ) ),
+ maRbSortDesc ( this, ScResId( RB_SORT_DESC ) ),
+ maRbSortMan ( this, ScResId( RB_SORT_MAN ) ),
+ maFlLayout ( this, ScResId( FL_LAYOUT ) ),
+ maFtLayout ( this, ScResId( FT_LAYOUT ) ),
+ maLbLayout ( this, ScResId( LB_LAYOUT ) ),
+ maCbLayoutEmpty ( this, ScResId( CB_LAYOUT_EMPTY ) ),
+ maFlAutoShow ( this, ScResId( FL_AUTOSHOW ) ),
+ maCbShow ( this, ScResId( CB_SHOW ) ),
+ maNfShow ( this, ScResId( NF_SHOW ) ),
+ maFtShow ( this, ScResId( FT_SHOW ) ),
+ maFtShowFrom ( this, ScResId( FT_SHOW_FROM ) ),
+ maLbShowFrom ( this, ScResId( LB_SHOW_FROM ) ),
+ maFtShowUsing ( this, ScResId( FT_SHOW_USING ) ),
+ maLbShowUsing ( this, ScResId( LB_SHOW_USING ) ),
+ maFlHide ( this, ScResId( FL_HIDE ) ),
+ maLbHide ( this, ScResId( CT_HIDE ) ),
+ maFtHierarchy ( this, ScResId( FT_HIERARCHY ) ),
+ maLbHierarchy ( this, ScResId( LB_HIERARCHY ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+ maLbLayoutWrp ( maLbLayout, spLayoutMap ),
+ maLbShowFromWrp ( maLbShowFrom, spShowFromMap ),
+ mrDPObj ( rDPObj ),
+ maLabelData ( rLabelData )
+{
+ FreeResource();
+ Init( rDataFields, bEnableLayout );
+}
+
+void ScDPSubtotalOptDlg::FillLabelData( ScDPLabelData& rLabelData ) const
+{
+ // *** SORTING ***
+
+ if( maRbSortMan.IsChecked() )
+ rLabelData.maSortInfo.Mode = DataPilotFieldSortMode::MANUAL;
+ else if( maLbSortBy.GetSelectEntryPos() == SC_SORTNAME_POS )
+ rLabelData.maSortInfo.Mode = DataPilotFieldSortMode::NAME;
+ else
+ rLabelData.maSortInfo.Mode = DataPilotFieldSortMode::DATA;
+
+ rLabelData.maSortInfo.Field = maLbSortBy.GetSelectEntry();
+ rLabelData.maSortInfo.IsAscending = maRbSortAsc.IsChecked();
+
+ // *** LAYOUT MODE ***
+
+ rLabelData.maLayoutInfo.LayoutMode = maLbLayoutWrp.GetControlValue();
+ rLabelData.maLayoutInfo.AddEmptyLines = maCbLayoutEmpty.IsChecked();
+
+ // *** AUTO SHOW ***
+
+ rLabelData.maShowInfo.IsEnabled = maCbShow.IsChecked();
+ rLabelData.maShowInfo.ShowItemsMode = maLbShowFromWrp.GetControlValue();
+ rLabelData.maShowInfo.ItemCount = sal::static_int_cast<sal_Int32>( maNfShow.GetValue() );
+ rLabelData.maShowInfo.DataField = maLbShowUsing.GetSelectEntry();
+
+ // *** HIDDEN ITEMS ***
+
+ rLabelData.maMembers = maLabelData.maMembers;
+ ULONG nVisCount = maLbHide.GetEntryCount();
+ for( USHORT nPos = 0; nPos < nVisCount; ++nPos )
+ rLabelData.maMembers[nPos].mbVisible = !maLbHide.IsChecked(nPos);
+
+ // *** HIERARCHY ***
+
+ rLabelData.mnUsedHier = maLbHierarchy.GetSelectEntryCount() ? maLbHierarchy.GetSelectEntryPos() : 0;
+}
+
+void ScDPSubtotalOptDlg::Init( const ScDPNameVec& rDataFields, bool bEnableLayout )
+{
+ // *** SORTING ***
+
+ sal_Int32 nSortMode = maLabelData.maSortInfo.Mode;
+
+ // sort fields list box
+ maLbSortBy.InsertEntry(maLabelData.getDisplayName());
+
+ for( ScDPNameVec::const_iterator aIt = rDataFields.begin(), aEnd = rDataFields.end(); aIt != aEnd; ++aIt )
+ {
+ maLbSortBy.InsertEntry( *aIt );
+ maLbShowUsing.InsertEntry( *aIt ); // for AutoShow
+ }
+ if( maLbSortBy.GetEntryCount() > SC_SORTDATA_POS )
+ maLbSortBy.SetSeparatorPos( SC_SORTDATA_POS - 1 );
+
+ USHORT nSortPos = SC_SORTNAME_POS;
+ if( nSortMode == DataPilotFieldSortMode::DATA )
+ {
+ nSortPos = lclFindListBoxEntry( maLbSortBy, maLabelData.maSortInfo.Field, SC_SORTDATA_POS );
+ if( nSortPos >= maLbSortBy.GetEntryCount() )
+ {
+ nSortPos = SC_SORTNAME_POS;
+ nSortMode = DataPilotFieldSortMode::MANUAL;
+ }
+ }
+ maLbSortBy.SelectEntryPos( nSortPos );
+
+ // sorting mode
+ maRbSortAsc.SetClickHdl( LINK( this, ScDPSubtotalOptDlg, RadioClickHdl ) );
+ maRbSortDesc.SetClickHdl( LINK( this, ScDPSubtotalOptDlg, RadioClickHdl ) );
+ maRbSortMan.SetClickHdl( LINK( this, ScDPSubtotalOptDlg, RadioClickHdl ) );
+
+ RadioButton* pRBtn = 0;
+ switch( nSortMode )
+ {
+ case DataPilotFieldSortMode::NONE:
+ case DataPilotFieldSortMode::MANUAL:
+ pRBtn = &maRbSortMan;
+ break;
+ default:
+ pRBtn = maLabelData.maSortInfo.IsAscending ? &maRbSortAsc : &maRbSortDesc;
+ }
+ pRBtn->Check();
+ RadioClickHdl( pRBtn );
+
+ // *** LAYOUT MODE ***
+
+ maFlLayout.Enable( bEnableLayout );
+ maFtLayout.Enable( bEnableLayout );
+ maLbLayout.Enable( bEnableLayout );
+ maCbLayoutEmpty.Enable( bEnableLayout );
+
+ maLbLayoutWrp.SetControlValue( maLabelData.maLayoutInfo.LayoutMode );
+ maCbLayoutEmpty.Check( maLabelData.maLayoutInfo.AddEmptyLines );
+
+ // *** AUTO SHOW ***
+
+ maCbShow.Check( maLabelData.maShowInfo.IsEnabled );
+ maCbShow.SetClickHdl( LINK( this, ScDPSubtotalOptDlg, CheckHdl ) );
+
+ maLbShowFromWrp.SetControlValue( maLabelData.maShowInfo.ShowItemsMode );
+ long nCount = static_cast< long >( maLabelData.maShowInfo.ItemCount );
+ if( nCount < 1 )
+ nCount = SC_SHOW_DEFAULT;
+ maNfShow.SetValue( nCount );
+
+ // maLbShowUsing already filled above
+ maLbShowUsing.SelectEntry( maLabelData.maShowInfo.DataField );
+ if( maLbShowUsing.GetSelectEntryPos() >= maLbShowUsing.GetEntryCount() )
+ maLbShowUsing.SelectEntryPos( 0 );
+
+ CheckHdl( &maCbShow ); // enable/disable dependent controls
+
+ // *** HIDDEN ITEMS ***
+
+ maLbHide.SetHelpId( HID_SC_DPSUBT_HIDE );
+ InitHideListBox();
+
+ // *** HIERARCHY ***
+
+ if( maLabelData.maHiers.getLength() > 1 )
+ {
+ lclFillListBox( maLbHierarchy, maLabelData.maHiers );
+ sal_Int32 nHier = maLabelData.mnUsedHier;
+ if( (nHier < 0) || (nHier >= maLabelData.maHiers.getLength()) ) nHier = 0;
+ maLbHierarchy.SelectEntryPos( static_cast< USHORT >( nHier ) );
+ maLbHierarchy.SetSelectHdl( LINK( this, ScDPSubtotalOptDlg, SelectHdl ) );
+ }
+ else
+ {
+ maFtHierarchy.Disable();
+ maLbHierarchy.Disable();
+ }
+}
+
+void ScDPSubtotalOptDlg::InitHideListBox()
+{
+ maLbHide.Clear();
+ lclFillListBox( maLbHide, maLabelData.maMembers );
+ size_t n = maLabelData.maMembers.size();
+ for (size_t i = 0; i < n; ++i)
+ maLbHide.CheckEntryPos(static_cast<USHORT>(i), !maLabelData.maMembers[i].mbVisible);
+ bool bEnable = maLbHide.GetEntryCount() > 0;
+ maFlHide.Enable( bEnable );
+ maLbHide.Enable( bEnable );
+}
+
+IMPL_LINK( ScDPSubtotalOptDlg, RadioClickHdl, RadioButton*, pBtn )
+{
+ maLbSortBy.Enable( pBtn != &maRbSortMan );
+ return 0;
+}
+
+IMPL_LINK( ScDPSubtotalOptDlg, CheckHdl, CheckBox*, pCBox )
+{
+ if( pCBox == &maCbShow )
+ {
+ bool bEnable = maCbShow.IsChecked();
+ maNfShow.Enable( bEnable );
+ maFtShow.Enable( bEnable );
+ maFtShowFrom.Enable( bEnable );
+ maLbShowFrom.Enable( bEnable );
+
+ bool bEnableUsing = bEnable && (maLbShowUsing.GetEntryCount() > 0);
+ maFtShowUsing.Enable( bEnableUsing );
+ maLbShowUsing.Enable( bEnableUsing );
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDPSubtotalOptDlg, SelectHdl, ListBox*, pLBox )
+{
+ if( pLBox == &maLbHierarchy )
+ {
+ mrDPObj.GetMembers(maLabelData.mnCol, maLbHierarchy.GetSelectEntryPos(), maLabelData.maMembers);
+ InitHideListBox();
+ }
+ return 0;
+}
+
+// ============================================================================
+
+ScDPShowDetailDlg::ScDPShowDetailDlg( Window* pParent, ScDPObject& rDPObj, USHORT nOrient ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DPSHOWDETAIL ) ),
+ maFtDims ( this, ScResId( FT_DIMS ) ),
+ maLbDims ( this, ScResId( LB_DIMS ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+
+ mrDPObj(rDPObj)
+{
+ FreeResource();
+
+ ScDPSaveData* pSaveData = rDPObj.GetSaveData();
+ long nDimCount = rDPObj.GetDimCount();
+ for (long nDim=0; nDim<nDimCount; nDim++)
+ {
+ BOOL bIsDataLayout;
+ sal_Int32 nDimFlags = 0;
+ String aName = rDPObj.GetDimName( nDim, bIsDataLayout, &nDimFlags );
+ if ( !bIsDataLayout && !rDPObj.IsDuplicated( nDim ) && ScDPObject::IsOrientationAllowed( nOrient, nDimFlags ) )
+ {
+ const ScDPSaveDimension* pDimension = pSaveData ? pSaveData->GetExistingDimensionByName(aName) : 0;
+ if ( !pDimension || (pDimension->GetOrientation() != nOrient) )
+ {
+ if (pDimension)
+ {
+ const OUString* pLayoutName = pDimension->GetLayoutName();
+ if (pLayoutName)
+ aName = *pLayoutName;
+ }
+ maLbDims.InsertEntry( aName );
+ maNameIndexMap.insert(DimNameIndexMap::value_type(aName, nDim));
+ }
+ }
+ }
+ if( maLbDims.GetEntryCount() )
+ maLbDims.SelectEntryPos( 0 );
+
+ maLbDims.SetDoubleClickHdl( LINK( this, ScDPShowDetailDlg, DblClickHdl ) );
+}
+
+short ScDPShowDetailDlg::Execute()
+{
+ return maLbDims.GetEntryCount() ? ModalDialog::Execute() : RET_CANCEL;
+}
+
+String ScDPShowDetailDlg::GetDimensionName() const
+{
+ // Look up the internal dimension name which may be different from the
+ // displayed field name.
+ String aSelectedName = maLbDims.GetSelectEntry();
+ DimNameIndexMap::const_iterator itr = maNameIndexMap.find(aSelectedName);
+ if (itr == maNameIndexMap.end())
+ // This should never happen!
+ return aSelectedName;
+
+ long nDim = itr->second;
+ BOOL bIsDataLayout = false;
+ return mrDPObj.GetDimName(nDim, bIsDataLayout);
+}
+
+IMPL_LINK( ScDPShowDetailDlg, DblClickHdl, ListBox*, pLBox )
+{
+ if( pLBox == &maLbDims )
+ maBtnOk.Click();
+ return 0;
+}
+
+// ============================================================================
+
diff --git a/sc/source/ui/dbgui/pvfundlg.hrc b/sc/source/ui/dbgui/pvfundlg.hrc
new file mode 100644
index 000000000000..c9b6f562a9e1
--- /dev/null
+++ b/sc/source/ui/dbgui/pvfundlg.hrc
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc"
+
+// RID_SCDLG_DPDATAFIELD - DataPilot Data Field Function
+// RID_SCDLG_PIVOTSUBT - DataPilot Page/Row/Column Field Subtotals
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+#define BTN_MORE 4
+#define BTN_OPTIONS 5
+
+#define RB_NONE 1
+#define RB_AUTO 2
+#define RB_USER 3
+#define RB_SORT_ASC 4
+#define RB_SORT_DESC 5
+#define RB_SORT_MAN 6
+
+#define FL_FUNC 1
+#define FL_DISPLAY 2
+#define FL_SORT_BY 3
+#define FL_LAYOUT 4
+#define FL_AUTOSHOW 5
+#define FL_HIDE 6
+
+#define LB_FUNC 1
+#define LB_TYPE 2
+#define LB_BASEFIELD 3
+#define LB_BASEITEM 4
+#define LB_SORT_BY 5
+#define LB_LAYOUT 6
+#define LB_SHOW_FROM 7
+#define LB_SHOW_USING 8
+#define LB_HIERARCHY 9
+#define LB_DIMS 10
+
+#define FT_NAMELABEL 1
+#define FT_NAME 2
+#define FT_TYPE 3
+#define FT_BASEFIELD 4
+#define FT_BASEITEM 5
+#define FT_LAYOUT 6
+#define FT_SHOW 7
+#define FT_SHOW_FROM 8
+#define FT_SHOW_USING 9
+#define FT_HIERARCHY 10
+#define FT_DIMS 11
+
+#define CB_SHOWALL 1
+#define CB_LAYOUT_EMPTY 2
+#define CB_SHOW 3
+
+#define NF_SHOW 1
+
+#define CT_HIDE 1
+
diff --git a/sc/source/ui/dbgui/pvfundlg.src b/sc/source/ui/dbgui/pvfundlg.src
new file mode 100644
index 000000000000..d5203f2a89ac
--- /dev/null
+++ b/sc/source/ui/dbgui/pvfundlg.src
@@ -0,0 +1,538 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "pvfundlg.hrc"
+
+StringArray SCSTR_DPFUNCLISTBOX
+{
+ ItemList [ en-US ] =
+ {
+ < "Sum" ; Default ; > ;
+ < "Count" ; Default ; > ;
+ < "Average" ; Default ; > ;
+ < "Max" ; Default ; > ;
+ < "Min" ; Default ; > ;
+ < "Product" ; Default ; > ;
+ < "Count (Numbers only)" ; Default ; > ;
+ < "StDev (Sample)" ; Default ; > ;
+ < "StDevP (Population)" ; Default ; > ;
+ < "Var (Sample)" ; Default ; > ;
+ < "VarP (Population)" ; Default ; > ;
+ };
+};
+
+// ----------------------------------------------------------------------------
+
+ModalDialog RID_SCDLG_DPDATAFIELD
+{
+ OutputSize = TRUE ;
+ HelpId = HID_SC_DPDATAFIELD ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 220 , 99 ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ Hide = TRUE ;
+ FixedLine FL_FUNC
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 152 , 8 ) ;
+ Text [ en-US ] = "~Function" ;
+ };
+ MultiListBox LB_FUNC
+ {
+ HelpID = "sc:MultiListBox:RID_SCDLG_DPDATAFIELD:LB_FUNC";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 140 , 65 ) ;
+ TabStop = TRUE ;
+ AutoHScroll = TRUE ;
+ SimpleMode = TRUE ;
+ };
+ FixedText FT_NAMELABEL
+ {
+ Pos = MAP_APPFONT ( 6 , 85 ) ;
+ Size = MAP_APPFONT ( 25 , 8 ) ;
+ Text [ en-US ] = "Name:" ;
+ };
+ FixedText FT_NAME
+ {
+ Pos = MAP_APPFONT ( 32 , 85 ) ;
+ Size = MAP_APPFONT ( 126 , 8 ) ;
+ };
+ FixedLine FL_DISPLAY
+ {
+ Pos = MAP_APPFONT( 6, 99 );
+ Size = MAP_APPFONT( 152, 8 );
+ Text [ en-US ] = "Displayed value";
+ };
+ FixedText FT_TYPE
+ {
+ Pos = MAP_APPFONT( 12, 112 );
+ Size = MAP_APPFONT( 60, 8 );
+ Text [ en-US ] = "~Type";
+ };
+ ListBox LB_TYPE
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_DPDATAFIELD:LB_TYPE";
+ Pos = MAP_APPFONT( 75, 110 );
+ Size = MAP_APPFONT( 77, 120 );
+ TabStop = TRUE;
+ Border = TRUE;
+ DropDown = TRUE;
+ StringList [ en-US ] =
+ {
+ < "Normal"; Default; >;
+ < "Difference from"; Default; >;
+ < "% of"; Default; >;
+ < "% difference from"; Default; >;
+ < "Running total in"; Default; >;
+ < "% of row"; Default; >;
+ < "% of column"; Default; >;
+ < "% of total"; Default; >;
+ < "Index"; Default; >;
+ };
+ };
+ FixedText FT_BASEFIELD
+ {
+ Pos = MAP_APPFONT( 12, 128 );
+ Size = MAP_APPFONT( 60, 8 );
+ Text [ en-US ] = "~Base field";
+ };
+ ListBox LB_BASEFIELD
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_DPDATAFIELD:LB_BASEFIELD";
+ Pos = MAP_APPFONT( 75, 126 );
+ Size = MAP_APPFONT( 77, 120 );
+ TabStop = TRUE;
+ Border = TRUE;
+ DropDown = TRUE;
+ };
+ FixedText FT_BASEITEM
+ {
+ Pos = MAP_APPFONT( 12, 144 );
+ Size = MAP_APPFONT( 60, 8 );
+ Text [ en-US ] = "Ba~se item";
+ };
+ ListBox LB_BASEITEM
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_DPDATAFIELD:LB_BASEITEM";
+ Pos = MAP_APPFONT( 75, 142 );
+ Size = MAP_APPFONT( 77, 120 );
+ TabStop = TRUE;
+ Border = TRUE;
+ DropDown = TRUE;
+ StringList [ en-US ] =
+ {
+ < "- previous item -"; Default; >;
+ < "- next item -"; Default; >;
+ };
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 164 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 164 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 164 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ MoreButton BTN_MORE
+ {
+ HelpID = "sc:MoreButton:RID_SCDLG_DPDATAFIELD:BTN_MORE";
+ Pos = MAP_APPFONT ( 164 , 79 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ MapUnit = MAP_APPFONT ;
+ Delta = 61 ;
+ };
+ Text [ en-US ] = "Data Field" ;
+};
+
+// ----------------------------------------------------------------------------
+
+ModalDialog RID_SCDLG_PIVOTSUBT
+{
+ OutputSize = TRUE ;
+ HelpId = HID_SC_PIVOTSUBT ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 220 , 155 ) ;
+ Text [ en-US ] = "Data Field" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ Hide = TRUE ;
+ RadioButton RB_NONE
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_PIVOTSUBT:RB_NONE";
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 140 , 10 ) ;
+ Text [ en-US ] = "~None" ;
+ TabStop = TRUE ;
+ };
+ RadioButton RB_AUTO
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_PIVOTSUBT:RB_AUTO";
+ Pos = MAP_APPFONT ( 12 , 28 ) ;
+ Size = MAP_APPFONT ( 140 , 10 ) ;
+ Text [ en-US ] = "~Automatic" ;
+ TabStop = TRUE ;
+ };
+ RadioButton RB_USER
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_PIVOTSUBT:RB_USER";
+ Pos = MAP_APPFONT ( 12 , 42 ) ;
+ Size = MAP_APPFONT ( 140 , 10 ) ;
+ Text [ en-US ] = "~User-defined" ;
+ TabStop = TRUE ;
+ };
+ MultiListBox LB_FUNC
+ {
+ HelpID = "sc:MultiListBox:RID_SCDLG_PIVOTSUBT:LB_FUNC";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 56 ) ;
+ Size = MAP_APPFONT ( 140 , 65 ) ;
+ TabStop = TRUE ;
+ AutoHScroll = TRUE ;
+ SimpleMode = TRUE ;
+ };
+ FixedLine FL_FUNC
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 152 , 8 ) ;
+ Text [ en-US ] = "Subtotals" ;
+ };
+ CheckBox CB_SHOWALL
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_PIVOTSUBT:CB_SHOWALL";
+ Pos = MAP_APPFONT ( 6 , 127 ) ;
+ Size = MAP_APPFONT ( 152 , 10 ) ;
+ Text [ en-US ] = "Show it~ems without data";
+ TabStop = TRUE ;
+ };
+ FixedText FT_NAMELABEL
+ {
+ Pos = MAP_APPFONT ( 6 , 141 ) ;
+ Size = MAP_APPFONT ( 25 , 8 ) ;
+ Text [ en-US ] = "Name:" ;
+ };
+ FixedText FT_NAME
+ {
+ Pos = MAP_APPFONT ( 32 , 141 ) ;
+ Size = MAP_APPFONT ( 126 , 8 ) ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 164 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 164 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 164 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton BTN_OPTIONS
+ {
+ HelpID = "sc:PushButton:RID_SCDLG_PIVOTSUBT:BTN_OPTIONS";
+ Pos = MAP_APPFONT ( 164 , 135 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Options...";
+ };
+};
+
+// ----------------------------------------------------------------------------
+
+ModalDialog RID_SCDLG_DPSUBTOTAL_OPT
+{
+ OutputSize = TRUE;
+ HelpId = HID_SC_DPSUBT_OPT;
+ SVLook = TRUE;
+ Size = MAP_APPFONT( 266, 240 );
+ Moveable = TRUE;
+ Closeable = FALSE;
+ Hide = TRUE;
+ FixedLine FL_SORT_BY
+ {
+ Pos = MAP_APPFONT( 6, 3 );
+ Size = MAP_APPFONT( 198, 8 );
+ Text [ en-US ] = "Sort ~by";
+ };
+ ListBox LB_SORT_BY
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_DPSUBTOTAL_OPT:LB_SORT_BY";
+ Pos = MAP_APPFONT( 12, 26 );
+ Size = MAP_APPFONT( 96, 120 );
+ TabStop = TRUE;
+ Border = TRUE;
+ DropDown = TRUE;
+ };
+ RadioButton RB_SORT_ASC
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_DPSUBTOTAL_OPT:RB_SORT_ASC";
+ Pos = MAP_APPFONT( 114, 14 );
+ Size = MAP_APPFONT( 84, 10 );
+ TabStop = TRUE;
+ Text [ en-US ] = "~Ascending";
+ };
+ RadioButton RB_SORT_DESC
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_DPSUBTOTAL_OPT:RB_SORT_DESC";
+ Pos = MAP_APPFONT( 114, 28 );
+ Size = MAP_APPFONT( 84, 10 );
+ TabStop = TRUE;
+ Text [ en-US ] = "~Descending";
+ };
+ RadioButton RB_SORT_MAN
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_DPSUBTOTAL_OPT:RB_SORT_MAN";
+ Pos = MAP_APPFONT( 114, 42 );
+ Size = MAP_APPFONT( 84, 10 );
+ TabStop = TRUE;
+ Text [ en-US ] = "~Manual";
+ };
+ FixedLine FL_LAYOUT
+ {
+ Pos = MAP_APPFONT( 6, 56 );
+ Size = MAP_APPFONT( 198, 8 );
+ Text [ en-US ] = "Display options";
+ };
+ FixedText FT_LAYOUT
+ {
+ Pos = MAP_APPFONT( 12, 69 );
+ Size = MAP_APPFONT( 70, 8 );
+ Text [ en-US ] = "~Layout";
+ };
+ ListBox LB_LAYOUT
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_DPSUBTOTAL_OPT:LB_LAYOUT";
+ Pos = MAP_APPFONT( 84, 67 );
+ Size = MAP_APPFONT( 114, 120 );
+ TabStop = TRUE;
+ Border = TRUE;
+ DropDown = TRUE;
+ StringList [ en-US ] =
+ {
+ < "Tabular layout"; Default; >;
+ < "Outline layout with subtotals at the top"; Default; >;
+ < "Outline layout with subtotals at the bottom"; Default; >;
+ };
+ };
+ CheckBox CB_LAYOUT_EMPTY
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_DPSUBTOTAL_OPT:CB_LAYOUT_EMPTY";
+ Pos = MAP_APPFONT( 12, 85 );
+ Size = MAP_APPFONT( 186, 10 );
+ TabStop = TRUE;
+ Text [ en-US ] = "~Empty line after each item";
+ };
+ FixedLine FL_AUTOSHOW
+ {
+ Pos = MAP_APPFONT( 6, 99 );
+ Size = MAP_APPFONT( 198, 8 );
+ Text [ en-US ] = "Show automatically";
+ };
+ CheckBox CB_SHOW
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_DPSUBTOTAL_OPT:CB_SHOW";
+ Pos = MAP_APPFONT( 12, 112 );
+ Size = MAP_APPFONT( 70, 10 );
+ TabStop = TRUE;
+ Text[ en-US ] = "~Show";
+ };
+ NumericField NF_SHOW
+ {
+ HelpID = "sc:NumericField:RID_SCDLG_DPSUBTOTAL_OPT:NF_SHOW";
+ Pos = MAP_APPFONT( 84, 110 );
+ Size = MAP_APPFONT( 30, 12 );
+ TabStop = TRUE;
+ Border = TRUE;
+ Repeat = TRUE;
+ Spin = TRUE;
+ Minimum = 1;
+ Maximum = 999;
+ SpinSize = 1;
+ StrictFormat = TRUE;
+ };
+ FixedText FT_SHOW
+ {
+ Pos = MAP_APPFONT( 118, 112 );
+ Size = MAP_APPFONT( 80, 8 );
+ Text [ en-US ] = "items";
+ };
+ FixedText FT_SHOW_FROM
+ {
+ Pos = MAP_APPFONT( 22, 128 );
+ Size = MAP_APPFONT( 60, 8 );
+ Text [ en-US ] = "~From";
+ };
+ ListBox LB_SHOW_FROM
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_DPSUBTOTAL_OPT:LB_SHOW_FROM";
+ Pos = MAP_APPFONT( 84, 126 );
+ Size = MAP_APPFONT( 114, 50 );
+ TabStop = TRUE;
+ Border = TRUE;
+ DropDown = TRUE;
+ StringList [ en-US ] =
+ {
+ < "Top"; Default; >;
+ < "Bottom"; Default; >;
+ };
+ };
+ FixedText FT_SHOW_USING
+ {
+ Pos = MAP_APPFONT( 22, 144 );
+ Size = MAP_APPFONT( 60, 8 );
+ Text [ en-US ] = "~Using field";
+ };
+ ListBox LB_SHOW_USING
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_DPSUBTOTAL_OPT:LB_SHOW_USING";
+ Pos = MAP_APPFONT( 84, 142 );
+ Size = MAP_APPFONT( 114, 120 );
+ TabStop = TRUE;
+ Border = TRUE;
+ DropDown = TRUE;
+ };
+ FixedLine FL_HIDE
+ {
+ Pos = MAP_APPFONT( 6, 160 );
+ Size = MAP_APPFONT( 198, 8 );
+ Text [ en-US ] = "Hide i~tems";
+ };
+ Control CT_HIDE
+ {
+ Pos = MAP_APPFONT( 12, 171 );
+ Size = MAP_APPFONT( 186, 45 );
+ TabStop = TRUE;
+ Border = TRUE;
+ };
+ FixedText FT_HIERARCHY
+ {
+ Pos = MAP_APPFONT( 6, 224 );
+ Size = MAP_APPFONT( 76, 8 );
+ Text [ en-US ] = "Hierarch~y";
+ };
+ ListBox LB_HIERARCHY
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_DPSUBTOTAL_OPT:LB_HIERARCHY";
+ Pos = MAP_APPFONT( 84, 222 );
+ Size = MAP_APPFONT( 114, 120 );
+ TabStop = TRUE;
+ Border = TRUE;
+ DropDown = TRUE;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT( 210, 6 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ DefButton = TRUE;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT( 210, 23 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT( 210, 43 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ };
+ Text [ en-US ] = "Data Field Options";
+};
+
+// ----------------------------------------------------------------------------
+
+ModalDialog RID_SCDLG_DPSHOWDETAIL
+{
+ OutputSize = TRUE;
+ HelpId = HID_SC_DPSHOWDETAIL;
+ SVLook = TRUE;
+ Size = MAP_APPFONT( 200, 116 );
+ Moveable = TRUE;
+ Closeable = FALSE;
+ FixedText FT_DIMS
+ {
+ Pos = MAP_APPFONT( 6, 3 );
+ Size = MAP_APPFONT( 132, 24 );
+ WordBreak = TRUE;
+ Text [ en-US ] = "~Choose the field containing the detail you want to show";
+ };
+ ListBox LB_DIMS
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_DPSHOWDETAIL:LB_DIMS";
+ Pos = MAP_APPFONT( 6, 30 );
+ Size = MAP_APPFONT( 132, 80 );
+ TabStop = TRUE;
+ Border = TRUE;
+ DropDown = FALSE;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT( 144, 6 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ DefButton = TRUE;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT( 144, 23 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT( 144, 43 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ };
+ Text [ en-US ] = "Show Detail";
+};
+
+// ----------------------------------------------------------------------------
+
diff --git a/sc/source/ui/dbgui/pvglob.hxx b/sc/source/ui/dbgui/pvglob.hxx
new file mode 100644
index 000000000000..6b6526266035
--- /dev/null
+++ b/sc/source/ui/dbgui/pvglob.hxx
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_PVGLOB_HXX
+#define SC_PVGLOB_HXX
+
+//-------------------------------------------------------------------
+
+class PivotGlobal
+{
+public:
+ static long nObjHeight;
+ static long nObjWidth;
+ static long nSelSpace;
+};
+
+
+#endif // SC_PVGLOB_HXX
diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx
new file mode 100644
index 000000000000..56d7e3550cda
--- /dev/null
+++ b/sc/source/ui/dbgui/pvlaydlg.cxx
@@ -0,0 +1,1823 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//----------------------------------------------------------------------------
+
+#include "pvlaydlg.hxx"
+#include "dbdocfun.hxx"
+
+#include <sfx2/dispatch.hxx>
+#include <vcl/msgbox.hxx>
+
+#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
+#include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
+
+#include "uiitems.hxx"
+#include "rangeutl.hxx"
+#include "document.hxx"
+#include "viewdata.hxx"
+#include "tabvwsh.hxx"
+#include "reffact.hxx"
+#include "scresid.hxx"
+#include "pvglob.hxx"
+//CHINA001 #include "pvfundlg.hxx"
+#include "globstr.hrc"
+#include "pivot.hrc"
+#include "dpobject.hxx"
+#include "dpsave.hxx"
+#include "dpshttab.hxx"
+#include "scmod.hxx"
+
+#include "sc.hrc" //CHINA001
+#include "scabstdlg.hxx" //CHINA001
+using namespace com::sun::star;
+using ::rtl::OUString;
+using ::std::vector;
+
+//----------------------------------------------------------------------------
+
+#define FSTR(index) aFuncNameArr[index-1]
+#define STD_FORMAT SCA_VALID | SCA_TAB_3D \
+ | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
+
+long PivotGlobal::nObjHeight = 0; // initialized with resource data
+long PivotGlobal::nObjWidth = 0;
+long PivotGlobal::nSelSpace = 0;
+
+
+//============================================================================
+
+namespace {
+
+void lcl_FillToPivotField( PivotField& rPivotField, const ScDPFuncData& rFuncData )
+{
+ rPivotField.nCol = rFuncData.mnCol;
+ rPivotField.nFuncMask = rFuncData.mnFuncMask;
+ rPivotField.maFieldRef = rFuncData.maFieldRef;
+}
+
+PointerStyle lclGetPointerForField( ScDPFieldType eType )
+{
+ switch( eType )
+ {
+ case TYPE_PAGE: return POINTER_PIVOT_FIELD;
+ case TYPE_COL: return POINTER_PIVOT_COL;
+ case TYPE_ROW: return POINTER_PIVOT_ROW;
+ case TYPE_DATA: return POINTER_PIVOT_FIELD;
+ case TYPE_SELECT: return POINTER_PIVOT_FIELD;
+ }
+ return POINTER_ARROW;
+}
+
+} // namespace
+
+//============================================================================
+
+//----------------------------------------------------------------------------
+
+ScDPLayoutDlg::ScDPLayoutDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ const ScDPObject& rDPObject )
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_PIVOT_LAYOUT ),
+ aFlLayout ( this, ScResId( FL_LAYOUT ) ),
+ aFtPage ( this, ScResId( FT_PAGE ) ),
+ aWndPage ( this, ScResId( WND_PAGE ), TYPE_PAGE, &aFtPage ),
+ aFtCol ( this, ScResId( FT_COL ) ),
+ aWndCol ( this, ScResId( WND_COL ), TYPE_COL, &aFtCol ),
+ aFtRow ( this, ScResId( FT_ROW ) ),
+ aWndRow ( this, ScResId( WND_ROW ), TYPE_ROW, &aFtRow ),
+ aFtData ( this, ScResId( FT_DATA ) ),
+ aWndData ( this, ScResId( WND_DATA ), TYPE_DATA, &aFtData ),
+ aWndSelect ( this, ScResId( WND_SELECT ), TYPE_SELECT, String(ScResId(STR_SELECT)) ),
+ aSlider ( this, ScResId( WND_HSCROLL ) ),
+ aFtInfo ( this, ScResId( FT_INFO ) ),
+
+ aFlAreas ( this, ScResId( FL_OUTPUT ) ),
+
+ aFtInArea ( this, ScResId( FT_INAREA) ),
+ aEdInPos ( this, ScResId( ED_INAREA) ),
+ aRbInPos ( this, ScResId( RB_INAREA ), &aEdInPos, this ),
+
+ aLbOutPos ( this, ScResId( LB_OUTAREA ) ),
+ aFtOutArea ( this, ScResId( FT_OUTAREA ) ),
+ aEdOutPos ( this, this, ScResId( ED_OUTAREA ) ),
+ aRbOutPos ( this, ScResId( RB_OUTAREA ), &aEdOutPos, this ),
+ aBtnIgnEmptyRows( this, ScResId( BTN_IGNEMPTYROWS ) ),
+ aBtnDetectCat ( this, ScResId( BTN_DETECTCAT ) ),
+ aBtnTotalCol ( this, ScResId( BTN_TOTALCOL ) ),
+ aBtnTotalRow ( this, ScResId( BTN_TOTALROW ) ),
+ aBtnFilter ( this, ScResId( BTN_FILTER ) ),
+ aBtnDrillDown ( this, ScResId( BTN_DRILLDOWN ) ),
+
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
+ aBtnOptions ( this, ScResId( BTN_OPTIONS ) ),
+ aBtnMore ( this, ScResId( BTN_MORE ) ),
+
+ aStrUndefined ( ScResId( SCSTR_UNDEFINED ) ),
+ aStrNewTable ( ScResId( SCSTR_NEWTABLE ) ),
+
+ bIsDrag ( FALSE ),
+
+ pEditActive ( NULL ),
+
+ eLastActiveType ( TYPE_SELECT ),
+ nOffset ( 0 ),
+ //
+ xDlgDPObject ( new ScDPObject( rDPObject ) ),
+ pViewData ( ((ScTabViewShell*)SfxViewShell::Current())->
+ GetViewData() ),
+ pDoc ( ((ScTabViewShell*)SfxViewShell::Current())->
+ GetViewData()->GetDocument() ),
+ bRefInputMode ( FALSE )
+{
+ xDlgDPObject->SetAlive( TRUE ); // needed to get structure information
+ xDlgDPObject->FillOldParam( thePivotData, FALSE );
+ xDlgDPObject->FillLabelData( thePivotData );
+
+ Init();
+ FreeResource();
+}
+
+
+//----------------------------------------------------------------------------
+
+ScDPLayoutDlg::~ScDPLayoutDlg()
+{
+ USHORT nEntries = aLbOutPos.GetEntryCount();
+ USHORT i;
+
+ for ( i=2; i<nEntries; i++ )
+ delete (String*)aLbOutPos.GetEntryData( i );
+}
+
+
+//----------------------------------------------------------------------------
+
+ScDPFieldWindow& ScDPLayoutDlg::GetFieldWindow( ScDPFieldType eType )
+{
+ switch( eType )
+ {
+ case TYPE_PAGE: return aWndPage;
+ case TYPE_ROW: return aWndRow;
+ case TYPE_COL: return aWndCol;
+ case TYPE_DATA: return aWndData;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ return aWndSelect;
+}
+
+void __EXPORT ScDPLayoutDlg::Init()
+{
+ DBG_ASSERT( pViewData && pDoc,
+ "Ctor-Initialisierung fehlgeschlagen!" );
+
+ aBtnRemove.SetClickHdl( LINK( this, ScDPLayoutDlg, ClickHdl ) );
+ aBtnOptions.SetClickHdl( LINK( this, ScDPLayoutDlg, ClickHdl ) );
+
+ aFuncNameArr.reserve( FUNC_COUNT );
+ for ( USHORT i = 0; i < FUNC_COUNT; ++i )
+ aFuncNameArr.push_back( String( ScResId( i + 1 ) ) );
+
+ aBtnMore.AddWindow( &aFlAreas );
+ aBtnMore.AddWindow( &aFtInArea );
+ aBtnMore.AddWindow( &aEdInPos );
+ aBtnMore.AddWindow( &aRbInPos );
+ aBtnMore.AddWindow( &aFtOutArea );
+ aBtnMore.AddWindow( &aLbOutPos );
+ aBtnMore.AddWindow( &aEdOutPos );
+ aBtnMore.AddWindow( &aRbOutPos );
+ aBtnMore.AddWindow( &aBtnIgnEmptyRows );
+ aBtnMore.AddWindow( &aBtnDetectCat );
+ aBtnMore.AddWindow( &aBtnTotalCol );
+ aBtnMore.AddWindow( &aBtnTotalRow );
+ aBtnMore.AddWindow( &aBtnFilter );
+ aBtnMore.AddWindow( &aBtnDrillDown );
+ aBtnMore.SetClickHdl( LINK( this, ScDPLayoutDlg, MoreClickHdl ) );
+
+ {
+ Size aFieldSize( Window( this, ScResId( WND_FIELD ) ).GetSizePixel() );
+ OHEIGHT = aFieldSize.Height();
+ OWIDTH = aFieldSize.Width();
+ }
+ SSPACE = Window( this, ScResId( WND_FIELD_SPACE ) ).GetSizePixel().Width();
+
+ CalcWndSizes();
+
+ aSelectArr.resize( MAX_LABELS );
+ aPageArr.resize( MAX_PAGEFIELDS );
+ aColArr.resize( MAX_FIELDS );
+ aRowArr.resize( MAX_FIELDS );
+ aDataArr.resize( MAX_FIELDS );
+
+ ScRange inRange;
+ String inString;
+ if (xDlgDPObject->GetSheetDesc())
+ {
+ aEdInPos.Enable();
+ aRbInPos.Enable();
+ aOldRange = xDlgDPObject->GetSheetDesc()->aSourceRange;
+ aOldRange.Format( inString, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+ aEdInPos.SetText(inString);
+ }
+ else
+ {
+ /* Data is not reachable, so could be a remote database */
+ aEdInPos.Disable();
+ aRbInPos.Disable();
+ }
+
+ InitFields();
+
+ aLbOutPos .SetSelectHdl( LINK( this, ScDPLayoutDlg, SelAreaHdl ) );
+ aEdOutPos .SetModifyHdl( LINK( this, ScDPLayoutDlg, EdModifyHdl ) );
+ aEdInPos .SetModifyHdl( LINK( this, ScDPLayoutDlg, EdInModifyHdl ) );
+ aBtnOk .SetClickHdl ( LINK( this, ScDPLayoutDlg, OkHdl ) );
+ aBtnCancel.SetClickHdl ( LINK( this, ScDPLayoutDlg, CancelHdl ) );
+ Link aLink = LINK( this, ScDPLayoutDlg, GetFocusHdl );
+ if ( aEdInPos.IsEnabled() )
+ // Once disabled it will never get enabled, so no need to handle focus.
+ aEdInPos.SetGetFocusHdl( aLink );
+ aEdOutPos.SetGetFocusHdl( aLink );
+
+ if ( pViewData && pDoc )
+ {
+ /*
+ * Aus den RangeNames des Dokumentes werden nun die
+ * in einem Zeiger-Array gemerkt, bei denen es sich
+ * um sinnvolle Bereiche handelt
+ */
+
+ aLbOutPos.Clear();
+ aLbOutPos.InsertEntry( aStrUndefined, 0 );
+ aLbOutPos.InsertEntry( aStrNewTable, 1 );
+
+ ScAreaNameIterator aIter( pDoc );
+ String aName;
+ ScRange aRange;
+ String aRefStr;
+ while ( aIter.Next( aName, aRange ) )
+ {
+ if ( !aIter.WasDBName() ) // hier keine DB-Bereiche !
+ {
+ USHORT nInsert = aLbOutPos.InsertEntry( aName );
+
+ aRange.aStart.Format( aRefStr, SCA_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+ aLbOutPos.SetEntryData( nInsert, new String( aRefStr ) );
+ }
+ }
+ }
+
+ if ( thePivotData.nTab != MAXTAB+1 )
+ {
+ String aStr;
+ ScAddress( thePivotData.nCol,
+ thePivotData.nRow,
+ thePivotData.nTab ).Format( aStr, STD_FORMAT, pDoc, pDoc->GetAddressConvention() );
+ aEdOutPos.SetText( aStr );
+ EdModifyHdl(0);
+ }
+ else
+ {
+ aLbOutPos.SelectEntryPos( aLbOutPos.GetEntryCount()-1 );
+ SelAreaHdl(NULL);
+ }
+
+ aBtnIgnEmptyRows.Check( thePivotData.bIgnoreEmptyRows );
+ aBtnDetectCat .Check( thePivotData.bDetectCategories );
+ aBtnTotalCol .Check( thePivotData.bMakeTotalCol );
+ aBtnTotalRow .Check( thePivotData.bMakeTotalRow );
+
+ if( const ScDPSaveData* pSaveData = xDlgDPObject->GetSaveData() )
+ {
+ aBtnFilter.Check( pSaveData->GetFilterButton() );
+ aBtnDrillDown.Check( pSaveData->GetDrillDown() );
+ }
+ else
+ {
+ aBtnFilter.Check();
+ aBtnDrillDown.Check();
+ }
+
+ aWndPage.SetHelpId( HID_SC_DPLAY_PAGE );
+ aWndCol.SetHelpId( HID_SC_DPLAY_COLUMN );
+ aWndRow.SetHelpId( HID_SC_DPLAY_ROW );
+ aWndData.SetHelpId( HID_SC_DPLAY_DATA );
+ aWndSelect.SetHelpId( HID_SC_DPLAY_SELECT );
+
+ InitFocus();
+
+// SetDispatcherLock( TRUE ); // Modal-Modus einschalten
+
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScDPLayoutDlg::Close()
+{
+ return DoClose( ScPivotLayoutWrapper::GetChildWindowId() );
+}
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::StateChanged( StateChangedType nStateChange )
+{
+ ScAnyRefDlg::StateChanged( nStateChange );
+
+ if ( nStateChange == STATE_CHANGE_INITSHOW )
+ {
+ // #124828# Hiding the FixedTexts and clearing the tab stop style bits
+ // has to be done after assigning the mnemonics, but Paint is too late,
+ // because the test tool may send key events to the dialog when it isn't visible.
+ // Mnemonics are assigned in the Dialog::StateChanged for STATE_CHANGE_INITSHOW,
+ // so this can be done immediately afterwards.
+
+ aWndPage.UseMnemonic();
+ aWndCol.UseMnemonic();
+ aWndRow.UseMnemonic();
+ aWndData.UseMnemonic();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::InitWndSelect( const vector<ScDPLabelDataRef>& rLabels )
+{
+ size_t nLabelCount = rLabels.size();
+ if (nLabelCount > MAX_LABELS)
+ nLabelCount = MAX_LABELS;
+ size_t nLast = (nLabelCount > PAGE_SIZE) ? (PAGE_SIZE - 1) : (nLabelCount - 1);
+
+ aLabelDataArr.clear();
+ aLabelDataArr.reserve( nLabelCount );
+ for ( size_t i=0; i < nLabelCount; i++ )
+ {
+ aLabelDataArr.push_back(*rLabels[i]);
+
+ if ( i <= nLast )
+ {
+ aWndSelect.AddField(aLabelDataArr[i].getDisplayName(), i);
+ aSelectArr[i].reset( new ScDPFuncData( aLabelDataArr[i].mnCol, aLabelDataArr[i].mnFuncMask ) );
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::InitWnd( PivotField* pArr, long nCount, ScDPFieldType eType )
+{
+ if ( pArr && (eType != TYPE_SELECT) )
+ {
+ ScDPFuncDataVec* pInitArr = NULL;
+ ScDPFieldWindow* pInitWnd = NULL;
+ BOOL bDataArr = FALSE;
+
+ switch ( eType )
+ {
+ case TYPE_PAGE:
+ pInitArr = &aPageArr;
+ pInitWnd = &aWndPage;
+ break;
+
+ case TYPE_COL:
+ pInitArr = &aColArr;
+ pInitWnd = &aWndCol;
+ break;
+
+ case TYPE_ROW:
+ pInitArr = &aRowArr;
+ pInitWnd = &aWndRow;
+ break;
+
+ case TYPE_DATA:
+ pInitArr = &aDataArr;
+ pInitWnd = &aWndData;
+ bDataArr = TRUE;
+ break;
+ default:
+ break;
+ }
+
+ if ( pInitArr && pInitWnd )
+ {
+ long j=0;
+ for ( long i=0; (i<nCount); i++ )
+ {
+ SCCOL nCol = pArr[i].nCol;
+ USHORT nMask = pArr[i].nFuncMask;
+
+ if ( nCol != PIVOT_DATA_FIELD )
+ {
+ (*pInitArr)[j].reset( new ScDPFuncData( nCol, nMask, pArr[i].maFieldRef ) );
+
+ if ( !bDataArr )
+ {
+ pInitWnd->AddField( GetLabelString( nCol ), j );
+ }
+ else
+ {
+ ScDPLabelData* pData = GetLabelData( nCol );
+ DBG_ASSERT( pData, "ScDPLabelData not found" );
+ if (pData)
+ {
+ String aStr( GetFuncString( (*pInitArr)[j]->mnFuncMask,
+ pData->mbIsValue ) );
+
+ aStr += GetLabelString( nCol );
+ pInitWnd->AddField( aStr, j );
+
+ pData->mnFuncMask = nMask;
+ }
+ }
+ ++j;
+ }
+ }
+// Do not redraw here -> first the FixedText has to get its mnemonic char
+// pInitWnd->Redraw();
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::InitFocus()
+{
+ if( aWndSelect.IsEmpty() )
+ {
+ aBtnOk.GrabFocus();
+ NotifyFieldFocus( TYPE_SELECT, FALSE );
+ }
+ else
+ aWndSelect.GrabFocus();
+}
+
+void ScDPLayoutDlg::InitFields()
+{
+ InitWndSelect(thePivotData.maLabelArray);
+ InitWnd( thePivotData.aPageArr, static_cast<long>(thePivotData.nPageCount), TYPE_PAGE );
+ InitWnd( thePivotData.aColArr, static_cast<long>(thePivotData.nColCount), TYPE_COL );
+ InitWnd( thePivotData.aRowArr, static_cast<long>(thePivotData.nRowCount), TYPE_ROW );
+ InitWnd( thePivotData.aDataArr, static_cast<long>(thePivotData.nDataCount), TYPE_DATA );
+
+ size_t nLabels = thePivotData.maLabelArray.size();
+ aSlider.SetPageSize( PAGE_SIZE );
+ aSlider.SetVisibleSize( PAGE_SIZE );
+ aSlider.SetLineSize( LINE_SIZE );
+ aSlider.SetRange( Range( 0, static_cast<long>(((nLabels+LINE_SIZE-1)/LINE_SIZE)*LINE_SIZE) ) );
+
+ if ( nLabels > PAGE_SIZE )
+ {
+ aSlider.SetEndScrollHdl( LINK( this, ScDPLayoutDlg, ScrollHdl ) );
+ aSlider.Show();
+ }
+ else
+ aSlider.Hide();
+}
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::AddField( size_t nFromIndex, ScDPFieldType eToType, const Point& rAtPos )
+{
+ ScDPFuncData fData( *(aSelectArr[nFromIndex]) );
+ size_t nAt = 0;
+ ScDPFieldWindow* toWnd = NULL;
+ ScDPFieldWindow* rmWnd1 = NULL;
+ ScDPFieldWindow* rmWnd2 = NULL;
+ ScDPFuncDataVec* toArr = NULL;
+ ScDPFuncDataVec* rmArr1 = NULL;
+ ScDPFuncDataVec* rmArr2 = NULL;
+ BOOL bDataArr = FALSE;
+
+ switch ( eToType )
+ {
+ case TYPE_PAGE:
+ toWnd = &aWndPage;
+ rmWnd1 = &aWndRow;
+ rmWnd2 = &aWndCol;
+ toArr = &aPageArr;
+ rmArr1 = &aRowArr;
+ rmArr2 = &aColArr;
+ break;
+
+ case TYPE_COL:
+ toWnd = &aWndCol;
+ rmWnd1 = &aWndPage;
+ rmWnd2 = &aWndRow;
+ toArr = &aColArr;
+ rmArr1 = &aPageArr;
+ rmArr2 = &aRowArr;
+ break;
+
+ case TYPE_ROW:
+ toWnd = &aWndRow;
+ rmWnd1 = &aWndPage;
+ rmWnd2 = &aWndCol;
+ toArr = &aRowArr;
+ rmArr1 = &aPageArr;
+ rmArr2 = &aColArr;
+ break;
+
+ case TYPE_DATA:
+ toWnd = &aWndData;
+ toArr = &aDataArr;
+ bDataArr = TRUE;
+ break;
+
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ bool bAllowed = IsOrientationAllowed( fData.mnCol, eToType );
+ if ( bAllowed
+ && (toArr->back().get() == NULL)
+ && (!Contains( toArr, fData.mnCol, nAt )) )
+ {
+ // ggF. in anderem Fenster entfernen
+ if ( rmArr1 )
+ {
+ if ( Contains( rmArr1, fData.mnCol, nAt ) )
+ {
+ rmWnd1->DelField( nAt );
+ Remove( rmArr1, nAt );
+ }
+ }
+ if ( rmArr2 )
+ {
+ if ( Contains( rmArr2, fData.mnCol, nAt ) )
+ {
+ rmWnd2->DelField( nAt );
+ Remove( rmArr2, nAt );
+ }
+ }
+
+ ScDPLabelData& rData = aLabelDataArr[nFromIndex+nOffset];
+ size_t nAddedAt = 0;
+
+ if ( !bDataArr )
+ {
+ if ( toWnd->AddField( rData.getDisplayName(),
+ DlgPos2WndPos( rAtPos, *toWnd ),
+ nAddedAt ) )
+ {
+ Insert( toArr, fData, nAddedAt );
+ toWnd->GrabFocus();
+ }
+ }
+ else
+ {
+ USHORT nMask = fData.mnFuncMask;
+ OUString aStr = GetFuncString( nMask, rData.mbIsValue );
+
+ aStr += rData.getDisplayName();
+
+ if ( toWnd->AddField( aStr,
+ DlgPos2WndPos( rAtPos, *toWnd ),
+ nAddedAt ) )
+ {
+ fData.mnFuncMask = nMask;
+ Insert( toArr, fData, nAddedAt );
+ toWnd->GrabFocus();
+ }
+ }
+
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::MoveField( ScDPFieldType eFromType, size_t nFromIndex, ScDPFieldType eToType, const Point& rAtPos )
+{
+ if ( eFromType == TYPE_SELECT )
+ AddField( nFromIndex, eToType, rAtPos );
+ else if ( eFromType != eToType )
+ {
+ ScDPFieldWindow* fromWnd = NULL;
+ ScDPFieldWindow* toWnd = NULL;
+ ScDPFieldWindow* rmWnd1 = NULL;
+ ScDPFieldWindow* rmWnd2 = NULL;
+ ScDPFuncDataVec* fromArr = NULL;
+ ScDPFuncDataVec* toArr = NULL;
+ ScDPFuncDataVec* rmArr1 = NULL;
+ ScDPFuncDataVec* rmArr2 = NULL;
+ size_t nAt = 0;
+ BOOL bDataArr = FALSE;
+
+ switch ( eFromType )
+ {
+ case TYPE_PAGE:
+ fromWnd = &aWndPage;
+ fromArr = &aPageArr;
+ break;
+
+ case TYPE_COL:
+ fromWnd = &aWndCol;
+ fromArr = &aColArr;
+ break;
+
+ case TYPE_ROW:
+ fromWnd = &aWndRow;
+ fromArr = &aRowArr;
+ break;
+
+ case TYPE_DATA:
+ fromWnd = &aWndData;
+ fromArr = &aDataArr;
+ break;
+
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ switch ( eToType )
+ {
+ case TYPE_PAGE:
+ toWnd = &aWndPage;
+ toArr = &aPageArr;
+ rmWnd1 = &aWndCol;
+ rmWnd2 = &aWndRow;
+ rmArr1 = &aColArr;
+ rmArr2 = &aRowArr;
+ break;
+
+ case TYPE_COL:
+ toWnd = &aWndCol;
+ toArr = &aColArr;
+ rmWnd1 = &aWndPage;
+ rmWnd2 = &aWndRow;
+ rmArr1 = &aPageArr;
+ rmArr2 = &aRowArr;
+ break;
+
+ case TYPE_ROW:
+ toWnd = &aWndRow;
+ toArr = &aRowArr;
+ rmWnd1 = &aWndPage;
+ rmWnd2 = &aWndCol;
+ rmArr1 = &aPageArr;
+ rmArr2 = &aColArr;
+ break;
+
+ case TYPE_DATA:
+ toWnd = &aWndData;
+ toArr = &aDataArr;
+ bDataArr = TRUE;
+ break;
+
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ if ( fromArr && toArr && fromWnd && toWnd )
+ {
+ ScDPFuncData fData( *((*fromArr)[nFromIndex]) );
+
+ bool bAllowed = IsOrientationAllowed( fData.mnCol, eToType );
+ if ( bAllowed && Contains( fromArr, fData.mnCol, nAt ) )
+ {
+ fromWnd->DelField( nAt );
+ Remove( fromArr, nAt );
+
+ if ( (toArr->back().get() == NULL)
+ && (!Contains( toArr, fData.mnCol, nAt )) )
+ {
+ size_t nAddedAt = 0;
+ if ( !bDataArr )
+ {
+ // ggF. in anderem Fenster entfernen
+ if ( rmArr1 )
+ {
+ if ( Contains( rmArr1, fData.mnCol, nAt ) )
+ {
+ rmWnd1->DelField( nAt );
+ Remove( rmArr1, nAt );
+ }
+ }
+ if ( rmArr2 )
+ {
+ if ( Contains( rmArr2, fData.mnCol, nAt ) )
+ {
+ rmWnd2->DelField( nAt );
+ Remove( rmArr2, nAt );
+ }
+ }
+
+ if ( toWnd->AddField( GetLabelString( fData.mnCol ),
+ DlgPos2WndPos( rAtPos, *toWnd ),
+ nAddedAt ) )
+ {
+ Insert( toArr, fData, nAddedAt );
+ toWnd->GrabFocus();
+ }
+ }
+ else
+ {
+ String aStr;
+ USHORT nMask = fData.mnFuncMask;
+ aStr = GetFuncString( nMask );
+ aStr += GetLabelString( fData.mnCol );
+
+ if ( toWnd->AddField( aStr,
+ DlgPos2WndPos( rAtPos, *toWnd ),
+ nAddedAt ) )
+ {
+ fData.mnFuncMask = nMask;
+ Insert( toArr, fData, nAddedAt );
+ toWnd->GrabFocus();
+ }
+ }
+ }
+ }
+ }
+ }
+ else // -> eFromType == eToType
+ {
+ ScDPFieldWindow* theWnd = NULL;
+ ScDPFuncDataVec* theArr = NULL;
+ size_t nAt = 0;
+ size_t nToIndex = 0;
+ Point aToPos;
+ BOOL bDataArr = FALSE;
+
+ switch ( eFromType )
+ {
+ case TYPE_PAGE:
+ theWnd = &aWndPage;
+ theArr = &aPageArr;
+ break;
+
+ case TYPE_COL:
+ theWnd = &aWndCol;
+ theArr = &aColArr;
+ break;
+
+ case TYPE_ROW:
+ theWnd = &aWndRow;
+ theArr = &aRowArr;
+ break;
+
+ case TYPE_DATA:
+ theWnd = &aWndData;
+ theArr = &aDataArr;
+ bDataArr = TRUE;
+ break;
+
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ ScDPFuncData fData( *((*theArr)[nFromIndex]) );
+
+ if ( Contains( theArr, fData.mnCol, nAt ) )
+ {
+ aToPos = DlgPos2WndPos( rAtPos, *theWnd );
+ theWnd->GetExistingIndex( aToPos, nToIndex );
+
+ if ( nToIndex != nAt )
+ {
+ size_t nAddedAt = 0;
+
+ theWnd->DelField( nAt );
+ Remove( theArr, nAt );
+
+ if ( !bDataArr )
+ {
+ if ( theWnd->AddField( GetLabelString( fData.mnCol ),
+ aToPos,
+ nAddedAt ) )
+ {
+ Insert( theArr, fData, nAddedAt );
+ }
+ }
+ else
+ {
+ String aStr;
+ USHORT nMask = fData.mnFuncMask;
+ aStr = GetFuncString( nMask );
+ aStr += GetLabelString( fData.mnCol );
+
+ if ( theWnd->AddField( aStr,
+ DlgPos2WndPos( rAtPos, *theWnd ),
+ nAddedAt ) )
+ {
+ fData.mnFuncMask = nMask;
+ Insert( theArr, fData, nAddedAt );
+ }
+ }
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::RemoveField( ScDPFieldType eFromType, size_t nIndex )
+{
+ ScDPFuncDataVec* pArr = NULL;
+ switch( eFromType )
+ {
+ case TYPE_PAGE: pArr = &aPageArr; break;
+ case TYPE_COL: pArr = &aColArr; break;
+ case TYPE_ROW: pArr = &aRowArr; break;
+ case TYPE_DATA: pArr = &aDataArr; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ if( pArr )
+ {
+ ScDPFieldWindow& rWnd = GetFieldWindow( eFromType );
+ rWnd.DelField( nIndex );
+ Remove( pArr, nIndex );
+ if( rWnd.IsEmpty() ) InitFocus();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::NotifyMouseButtonUp( const Point& rAt )
+{
+ if ( bIsDrag )
+ {
+ bIsDrag = FALSE;
+
+ ScDPFieldType eDnDToType = TYPE_SELECT;
+ Point aPos = ScreenToOutputPixel( rAt );
+ BOOL bDel = FALSE;
+
+ if ( aRectPage.IsInside( aPos ) )
+ {
+ eDnDToType = TYPE_PAGE;
+ bDel = FALSE;
+ }
+ else if ( aRectCol.IsInside( aPos ) )
+ {
+ eDnDToType = TYPE_COL;
+ bDel = FALSE;
+ }
+ else if ( aRectRow.IsInside( aPos ) )
+ {
+ eDnDToType = TYPE_ROW;
+ bDel = FALSE;
+ }
+ else if ( aRectData.IsInside( aPos ) )
+ {
+ eDnDToType = TYPE_DATA;
+ bDel = FALSE;
+ }
+ else if ( aRectSelect.IsInside( aPos ) )
+ {
+ eDnDToType = TYPE_SELECT;
+ bDel = TRUE;
+ }
+ else
+ bDel = TRUE;
+
+ if ( bDel )
+ RemoveField( eDnDFromType, nDnDFromIndex );
+ else
+ MoveField( eDnDFromType, nDnDFromIndex, eDnDToType, aPos );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+PointerStyle ScDPLayoutDlg::NotifyMouseMove( const Point& rAt )
+{
+ PointerStyle ePtr = POINTER_ARROW;
+
+ if ( bIsDrag )
+ {
+ Point aPos = ScreenToOutputPixel( rAt );
+ ScDPFieldType eCheckTarget = TYPE_SELECT;
+
+ if ( aRectPage.IsInside( aPos ) )
+ eCheckTarget = TYPE_PAGE;
+ else if ( aRectCol.IsInside( aPos ) )
+ eCheckTarget = TYPE_COL;
+ else if ( aRectRow.IsInside( aPos ) )
+ eCheckTarget = TYPE_ROW;
+ else if ( aRectData.IsInside( aPos ) )
+ eCheckTarget = TYPE_DATA;
+ else if ( eDnDFromType != TYPE_SELECT )
+ ePtr = POINTER_PIVOT_DELETE;
+ else if ( aRectSelect.IsInside( aPos ) )
+ ePtr = lclGetPointerForField( TYPE_SELECT );
+ else
+ ePtr = POINTER_NOTALLOWED;
+
+ if ( eCheckTarget != TYPE_SELECT )
+ {
+ // check if the target orientation is allowed for this field
+ ScDPFuncDataVec* fromArr = NULL;
+ switch ( eDnDFromType )
+ {
+ case TYPE_PAGE: fromArr = &aPageArr; break;
+ case TYPE_COL: fromArr = &aColArr; break;
+ case TYPE_ROW: fromArr = &aRowArr; break;
+ case TYPE_DATA: fromArr = &aDataArr; break;
+ case TYPE_SELECT: fromArr = &aSelectArr; break;
+ }
+ ScDPFuncData fData( *((*fromArr)[nDnDFromIndex]) );
+ if (IsOrientationAllowed( fData.mnCol, eCheckTarget ))
+ ePtr = lclGetPointerForField( eCheckTarget );
+ else
+ ePtr = POINTER_NOTALLOWED;
+ }
+ }
+
+ return ePtr;
+}
+
+
+//----------------------------------------------------------------------------
+
+PointerStyle ScDPLayoutDlg::NotifyMouseButtonDown( ScDPFieldType eType, size_t nFieldIndex )
+{
+ bIsDrag = TRUE;
+ eDnDFromType = eType;
+ nDnDFromIndex = nFieldIndex;
+ return lclGetPointerForField( eType );
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::NotifyDoubleClick( ScDPFieldType eType, size_t nFieldIndex )
+{
+ ScDPFuncDataVec* pArr = NULL;
+ switch ( eType )
+ {
+ case TYPE_PAGE: pArr = &aPageArr; break;
+ case TYPE_COL: pArr = &aColArr; break;
+ case TYPE_ROW: pArr = &aRowArr; break;
+ case TYPE_DATA: pArr = &aDataArr; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ if ( pArr )
+ {
+ if ( nFieldIndex >= pArr->size() )
+ {
+ DBG_ERROR("invalid selection");
+ return;
+ }
+
+ size_t nArrPos = 0;
+ if( ScDPLabelData* pData = GetLabelData( (*pArr)[nFieldIndex]->mnCol, &nArrPos ) )
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
+
+ switch ( eType )
+ {
+ case TYPE_PAGE:
+ case TYPE_COL:
+ case TYPE_ROW:
+ {
+ // list of names of all data fields
+ std::vector< String > aDataFieldNames;
+ for( ScDPFuncDataVec::const_iterator aIt = aDataArr.begin(), aEnd = aDataArr.end();
+ (aIt != aEnd) && aIt->get(); ++aIt )
+ {
+ String aName( GetLabelString( (*aIt)->mnCol ) );
+ if( aName.Len() )
+ aDataFieldNames.push_back( aName );
+ }
+
+ bool bLayout = (eType == TYPE_ROW) &&
+ ((aDataFieldNames.size() > 1) || ((nFieldIndex + 1 < pArr->size()) && (*pArr)[nFieldIndex+1].get()));
+
+ AbstractScDPSubtotalDlg* pDlg = pFact->CreateScDPSubtotalDlg(
+ this, RID_SCDLG_PIVOTSUBT,
+ *xDlgDPObject, *pData, *(*pArr)[nFieldIndex], aDataFieldNames, bLayout );
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ pDlg->FillLabelData( *pData );
+ (*pArr)[nFieldIndex]->mnFuncMask = pData->mnFuncMask;
+ }
+ delete pDlg;
+ }
+ break;
+
+ case TYPE_DATA:
+ {
+ AbstractScDPFunctionDlg* pDlg = pFact->CreateScDPFunctionDlg(
+ this, RID_SCDLG_DPDATAFIELD,
+ aLabelDataArr, *pData, *(*pArr)[nFieldIndex] );
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ (*pArr)[nFieldIndex]->mnFuncMask = pData->mnFuncMask = pDlg->GetFuncMask();
+ (*pArr)[nFieldIndex]->maFieldRef = pDlg->GetFieldRef();
+
+ String aStr( GetFuncString ( aDataArr[nFieldIndex]->mnFuncMask ) );
+ aStr += GetLabelString( aDataArr[nFieldIndex]->mnCol );
+ aWndData.SetFieldText( aStr, nFieldIndex );
+ }
+ delete pDlg;
+ }
+ break;
+
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::NotifyFieldFocus( ScDPFieldType eType, BOOL bGotFocus )
+{
+ /* Enable Remove/Options buttons on GetFocus in field window.
+ #107616# Enable them also, if dialog is deactivated (click into document).
+ The !IsActive() condition handles the case that a LoseFocus event of a
+ field window would follow the Deactivate event of this dialog. */
+ BOOL bEnable = (bGotFocus || !IsActive()) && (eType != TYPE_SELECT);
+
+ // #128113# The TestTool may set the focus into an empty field.
+ // Then the Remove/Options buttons must be disabled.
+ if ( bEnable && bGotFocus && GetFieldWindow( eType ).IsEmpty() )
+ bEnable = FALSE;
+
+ aBtnRemove.Enable( bEnable );
+ aBtnOptions.Enable( bEnable );
+ if( bGotFocus )
+ eLastActiveType = eType;
+}
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::NotifyMoveField( ScDPFieldType eToType )
+{
+ ScDPFieldWindow& rWnd = GetFieldWindow( eLastActiveType );
+ if( (eToType != TYPE_SELECT) && !rWnd.IsEmpty() )
+ {
+ MoveField( eLastActiveType, rWnd.GetSelectedField(), eToType, GetFieldWindow( eToType ).GetLastPosition() );
+ if( rWnd.IsEmpty() )
+ NotifyFieldFocus( eToType, TRUE );
+ else
+ rWnd.GrabFocus();
+ if( eLastActiveType == TYPE_SELECT )
+ aWndSelect.SelectNext();
+ }
+ else
+ InitFocus();
+}
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::NotifyRemoveField( ScDPFieldType eType, size_t nFieldIndex )
+{
+ if( eType != TYPE_SELECT )
+ RemoveField( eType, nFieldIndex );
+}
+
+//----------------------------------------------------------------------------
+
+BOOL ScDPLayoutDlg::NotifyMoveSlider( USHORT nKeyCode )
+{
+ long nOldPos = aSlider.GetThumbPos();
+ switch( nKeyCode )
+ {
+ case KEY_HOME: aSlider.DoScroll( 0 ); break;
+ case KEY_END: aSlider.DoScroll( aSlider.GetRangeMax() ); break;
+ case KEY_UP:
+ case KEY_LEFT: aSlider.DoScrollAction( SCROLL_LINEUP ); break;
+ case KEY_DOWN:
+ case KEY_RIGHT: aSlider.DoScrollAction( SCROLL_LINEDOWN ); break;
+ }
+ return nOldPos != aSlider.GetThumbPos();
+}
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::Deactivate()
+{
+ /* #107616# If the dialog has been deactivated (click into document), the LoseFocus
+ event from field window disables Remove/Options buttons. Re-enable them here by
+ simulating a GetFocus event. Event order of LoseFocus and Deactivate is not important.
+ The last event will enable the buttons in both cases (see NotifyFieldFocus). */
+ NotifyFieldFocus( eLastActiveType, TRUE );
+}
+
+//----------------------------------------------------------------------------
+
+BOOL ScDPLayoutDlg::Contains( ScDPFuncDataVec* pArr, SCsCOL nCol, size_t& nAt )
+{
+ if ( !pArr )
+ return FALSE;
+
+ BOOL bFound = FALSE;
+ size_t i = 0;
+
+ while ( (i<pArr->size()) && ((*pArr)[i].get() != NULL) && !bFound )
+ {
+ bFound = ((*pArr)[i]->mnCol == nCol);
+ if ( bFound )
+ nAt = i;
+ i++;
+ }
+
+ return bFound;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::Remove( ScDPFuncDataVec* pArr, size_t nAt )
+{
+ if ( !pArr || (nAt>=pArr->size()) )
+ return;
+
+ pArr->erase( pArr->begin() + nAt );
+ pArr->push_back( ScDPFuncDataRef() );
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::Insert( ScDPFuncDataVec* pArr, const ScDPFuncData& rFData, size_t nAt )
+{
+ if ( !pArr || (nAt>=pArr->size()) )
+ return;
+
+ if ( (*pArr)[nAt].get() == NULL )
+ {
+ (*pArr)[nAt].reset( new ScDPFuncData( rFData ) );
+ }
+ else
+ {
+ if ( pArr->back().get() == NULL ) // mind. ein Slot frei?
+ {
+ pArr->insert( pArr->begin() + nAt, ScDPFuncDataRef( new ScDPFuncData( rFData ) ) );
+ pArr->erase( pArr->end() - 1 );
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+ScDPLabelData* ScDPLayoutDlg::GetLabelData( SCsCOL nCol, size_t* pnPos )
+{
+ ScDPLabelData* pData = 0;
+ for( ScDPLabelDataVec::iterator aIt = aLabelDataArr.begin(), aEnd = aLabelDataArr.end(); !pData && (aIt != aEnd); ++aIt )
+ {
+ if( aIt->mnCol == nCol )
+ {
+ pData = &*aIt;
+ if( pnPos ) *pnPos = aIt - aLabelDataArr.begin();
+ }
+ }
+ return pData;
+}
+
+
+//----------------------------------------------------------------------------
+
+String ScDPLayoutDlg::GetLabelString( SCsCOL nCol )
+{
+ ScDPLabelData* pData = GetLabelData( nCol );
+ DBG_ASSERT( pData, "LabelData not found" );
+ if (pData)
+ return pData->getDisplayName();
+ return String();
+}
+
+//----------------------------------------------------------------------------
+
+bool ScDPLayoutDlg::IsOrientationAllowed( SCsCOL nCol, ScDPFieldType eType )
+{
+ bool bAllowed = true;
+ ScDPLabelData* pData = GetLabelData( nCol );
+ DBG_ASSERT( pData, "LabelData not found" );
+ if (pData)
+ {
+ sheet::DataPilotFieldOrientation eOrient = sheet::DataPilotFieldOrientation_HIDDEN;
+ switch (eType)
+ {
+ case TYPE_PAGE: eOrient = sheet::DataPilotFieldOrientation_PAGE; break;
+ case TYPE_COL: eOrient = sheet::DataPilotFieldOrientation_COLUMN; break;
+ case TYPE_ROW: eOrient = sheet::DataPilotFieldOrientation_ROW; break;
+ case TYPE_DATA: eOrient = sheet::DataPilotFieldOrientation_DATA; break;
+ case TYPE_SELECT: eOrient = sheet::DataPilotFieldOrientation_HIDDEN; break;
+ }
+ bAllowed = ScDPObject::IsOrientationAllowed( (USHORT)eOrient, pData->mnFlags );
+ }
+ return bAllowed;
+}
+
+//----------------------------------------------------------------------------
+
+String ScDPLayoutDlg::GetFuncString( USHORT& rFuncMask, BOOL bIsValue )
+{
+ String aStr;
+
+ if ( rFuncMask == PIVOT_FUNC_NONE
+ || rFuncMask == PIVOT_FUNC_AUTO )
+ {
+ if ( bIsValue )
+ {
+ aStr = FSTR(PIVOTSTR_SUM);
+ rFuncMask = PIVOT_FUNC_SUM;
+ }
+ else
+ {
+ aStr = FSTR(PIVOTSTR_COUNT);
+ rFuncMask = PIVOT_FUNC_COUNT;
+ }
+ }
+ else if ( rFuncMask == PIVOT_FUNC_SUM ) aStr = FSTR(PIVOTSTR_SUM);
+ else if ( rFuncMask == PIVOT_FUNC_COUNT ) aStr = FSTR(PIVOTSTR_COUNT);
+ else if ( rFuncMask == PIVOT_FUNC_AVERAGE ) aStr = FSTR(PIVOTSTR_AVG);
+ else if ( rFuncMask == PIVOT_FUNC_MAX ) aStr = FSTR(PIVOTSTR_MAX);
+ else if ( rFuncMask == PIVOT_FUNC_MIN ) aStr = FSTR(PIVOTSTR_MIN);
+ else if ( rFuncMask == PIVOT_FUNC_PRODUCT ) aStr = FSTR(PIVOTSTR_PROD);
+ else if ( rFuncMask == PIVOT_FUNC_COUNT_NUM ) aStr = FSTR(PIVOTSTR_COUNT2);
+ else if ( rFuncMask == PIVOT_FUNC_STD_DEV ) aStr = FSTR(PIVOTSTR_DEV);
+ else if ( rFuncMask == PIVOT_FUNC_STD_DEVP ) aStr = FSTR(PIVOTSTR_DEV2);
+ else if ( rFuncMask == PIVOT_FUNC_STD_VAR ) aStr = FSTR(PIVOTSTR_VAR);
+ else if ( rFuncMask == PIVOT_FUNC_STD_VARP ) aStr = FSTR(PIVOTSTR_VAR2);
+ else
+ {
+ aStr = ScGlobal::GetRscString( STR_TABLE_ERGEBNIS );
+ aStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " - " ));
+ }
+
+ return aStr;
+}
+
+
+//----------------------------------------------------------------------------
+
+Point ScDPLayoutDlg::DlgPos2WndPos( const Point& rPt, Window& rWnd )
+{
+ Point aWndPt( rPt );
+ aWndPt.X() = rPt.X()-rWnd.GetPosPixel().X();
+ aWndPt.Y() = rPt.Y()-rWnd.GetPosPixel().Y();
+
+ return aWndPt;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::CalcWndSizes()
+{
+ // row/column/data area sizes
+ aWndPage.SetSizePixel( Size( MAX_PAGEFIELDS * OWIDTH / 2, 2 * OHEIGHT ) );
+ aWndRow.SetSizePixel( Size( OWIDTH, MAX_FIELDS * OHEIGHT ) );
+ aWndCol.SetSizePixel( Size( MAX_FIELDS * OWIDTH / 2, 2 * OHEIGHT ) );
+ aWndData.SetSizePixel( Size( MAX_FIELDS * OWIDTH / 2, MAX_FIELDS * OHEIGHT ) );
+
+ // #i29203# align right border of page window with data window
+ long nDataPosX = aWndData.GetPosPixel().X() + aWndData.GetSizePixel().Width();
+ aWndPage.SetPosPixel( Point( nDataPosX - aWndPage.GetSizePixel().Width(), aWndPage.GetPosPixel().Y() ) );
+
+ // selection area
+ aWndSelect.SetSizePixel( Size(
+ 2 * OWIDTH + SSPACE, LINE_SIZE * OHEIGHT + (LINE_SIZE - 1) * SSPACE ) );
+
+ // scroll bar
+ Point aSliderPos( aWndSelect.GetPosPixel() );
+ Size aSliderSize( aWndSelect.GetSizePixel() );
+ aSliderPos.Y() += aSliderSize.Height() + SSPACE;
+ aSliderSize.Height() = GetSettings().GetStyleSettings().GetScrollBarSize();
+ aSlider.SetPosSizePixel( aSliderPos, aSliderSize );
+
+ aRectPage = Rectangle( aWndPage.GetPosPixel(), aWndPage.GetSizePixel() );
+ aRectRow = Rectangle( aWndRow.GetPosPixel(), aWndRow.GetSizePixel() );
+ aRectCol = Rectangle( aWndCol.GetPosPixel(), aWndCol.GetSizePixel() );
+ aRectData = Rectangle( aWndData.GetPosPixel(), aWndData.GetSizePixel() );
+ aRectSelect = Rectangle( aWndSelect.GetPosPixel(), aWndSelect.GetSizePixel() );
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScDPLayoutDlg::GetPivotArrays( PivotField* pPageArr,
+ PivotField* pColArr,
+ PivotField* pRowArr,
+ PivotField* pDataArr,
+ USHORT& rPageCount,
+ USHORT& rColCount,
+ USHORT& rRowCount,
+ USHORT& rDataCount )
+{
+ BOOL bFit = TRUE;
+ USHORT i=0;
+
+ for ( i=0; (i<aDataArr.size()) && (aDataArr[i].get() != NULL ); i++ )
+ lcl_FillToPivotField( pDataArr[i], *aDataArr[i] );
+ rDataCount = i;
+
+ for ( i=0; (i<aPageArr.size()) && (aPageArr[i].get() != NULL ); i++ )
+ lcl_FillToPivotField( pPageArr[i], *aPageArr[i] );
+ rPageCount = i;
+
+ for ( i=0; (i<aColArr.size()) && (aColArr[i].get() != NULL ); i++ )
+ lcl_FillToPivotField( pColArr[i], *aColArr[i] );
+ rColCount = i;
+
+ for ( i=0; (i<aRowArr.size()) && (aRowArr[i].get() != NULL ); i++ )
+ lcl_FillToPivotField( pRowArr[i], *aRowArr[i] );
+ rRowCount = i;
+
+ if ( rRowCount < aRowArr.size() )
+ pRowArr[rRowCount++].nCol = PIVOT_DATA_FIELD;
+ else if ( rColCount < aColArr.size() )
+ pColArr[rColCount++].nCol = PIVOT_DATA_FIELD;
+ else
+ bFit = FALSE; // kein Platz fuer Datenfeld
+
+ return bFit;
+}
+
+void ScDPLayoutDlg::UpdateSrcRange()
+{
+ String theCurPosStr = aEdInPos.GetText();
+ USHORT nResult = ScRange().Parse(theCurPosStr, pDoc, pDoc->GetAddressConvention());
+
+ if ( SCA_VALID != (nResult & SCA_VALID) )
+ // invalid source range.
+ return;
+
+ ScRefAddress start, end;
+ ConvertDoubleRef(pDoc, theCurPosStr, 1, start, end, pDoc->GetAddressConvention());
+ ScRange aNewRange(start.GetAddress(), end.GetAddress());
+ ScSheetSourceDesc inSheet = *xDlgDPObject->GetSheetDesc();
+
+ if (inSheet.aSourceRange == aNewRange)
+ // new range is identical to the current range. Nothing to do.
+ return;
+
+ ScTabViewShell * pTabViewShell = pViewData->GetViewShell();
+ inSheet.aSourceRange = aNewRange;
+ xDlgDPObject->SetSheetDesc(inSheet);
+ xDlgDPObject->FillOldParam( thePivotData, FALSE );
+ xDlgDPObject->FillLabelData(thePivotData);
+
+ pTabViewShell->SetDialogDPObject(xDlgDPObject.get());
+ aLabelDataArr.clear();
+ aWndSelect.ClearFields();
+ aWndData.ClearFields();
+ aWndRow.ClearFields();
+ aWndCol.ClearFields();
+ aWndPage.ClearFields();
+
+ for (size_t i = 0; i < MAX_LABELS; ++i)
+ aSelectArr[i].reset();
+
+ for (size_t i = 0; i < MAX_FIELDS; ++i)
+ {
+ aRowArr[i].reset();
+ aColArr[i].reset();
+ aDataArr[i].reset();
+ }
+
+ for (size_t i = 0; i < MAX_PAGEFIELDS; ++i)
+ aPageArr[i].reset();
+
+ InitFields();
+}
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( !bRefInputMode || !pEditActive )
+ return;
+
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart( pEditActive );
+
+ if ( pEditActive == &aEdInPos )
+ {
+ String aRefStr;
+ rRef.Format( aRefStr, SCR_ABS_3D, pDocP, pDocP->GetAddressConvention() );
+ pEditActive->SetRefString( aRefStr );
+ }
+ else if ( pEditActive == &aEdOutPos )
+ {
+ String aRefStr;
+ rRef.aStart.Format( aRefStr, STD_FORMAT, pDocP, pDocP->GetAddressConvention() );
+ pEditActive->SetRefString( aRefStr );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::SetActive()
+{
+ if ( bRefInputMode )
+ {
+ if ( pEditActive )
+ pEditActive->GrabFocus();
+
+ if ( pEditActive == &aEdInPos )
+ EdInModifyHdl( NULL );
+ else if ( pEditActive == &aEdOutPos )
+ EdModifyHdl( NULL );
+ }
+ else
+ {
+ GrabFocus();
+ }
+
+ RefInputDone();
+}
+
+//----------------------------------------------------------------------------
+// Handler:
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScDPLayoutDlg, ClickHdl, PushButton *, pBtn )
+{
+ if( pBtn == &aBtnRemove )
+ {
+ ScDPFieldWindow& rWnd = GetFieldWindow( eLastActiveType );
+ RemoveField( eLastActiveType, rWnd.GetSelectedField() );
+ if( !rWnd.IsEmpty() ) rWnd.GrabFocus();
+ }
+ else if( pBtn == &aBtnOptions )
+ {
+ ScDPFieldWindow& rWnd = GetFieldWindow( eLastActiveType );
+ NotifyDoubleClick( eLastActiveType, rWnd.GetSelectedField() );
+ rWnd.GrabFocus();
+ }
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScDPLayoutDlg, OkHdl, OKButton *, EMPTYARG )
+{
+ String aOutPosStr( aEdOutPos.GetText() );
+ ScAddress aAdrDest;
+ BOOL bToNewTable = (aLbOutPos.GetSelectEntryPos() == 1);
+ USHORT nResult = !bToNewTable ? aAdrDest.Parse( aOutPosStr, pDoc, pDoc->GetAddressConvention() ) : 0;
+
+ if ( bToNewTable
+ || ( (aOutPosStr.Len() > 0) && (SCA_VALID == (nResult & SCA_VALID)) ) )
+ {
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable();
+
+ ScPivotParam theOutParam;
+ PivotPageFieldArr aPageFieldArr;
+ PivotFieldArr aColFieldArr;
+ PivotFieldArr aRowFieldArr;
+ PivotFieldArr aDataFieldArr;
+ USHORT nPageCount;
+ USHORT nColCount;
+ USHORT nRowCount;
+ USHORT nDataCount;
+
+ BOOL bFit = GetPivotArrays( aPageFieldArr, aColFieldArr, aRowFieldArr, aDataFieldArr,
+ nPageCount, nColCount, nRowCount, nDataCount );
+ if ( bFit )
+ {
+ ScDPSaveData* pOldSaveData = xDlgDPObject->GetSaveData();
+
+ ScRange aOutRange( aAdrDest ); // bToNewTable is passed separately
+
+ ScDPSaveData aSaveData;
+ aSaveData.SetIgnoreEmptyRows( aBtnIgnEmptyRows.IsChecked() );
+ aSaveData.SetRepeatIfEmpty( aBtnDetectCat.IsChecked() );
+ aSaveData.SetColumnGrand( aBtnTotalCol.IsChecked() );
+ aSaveData.SetRowGrand( aBtnTotalRow.IsChecked() );
+ aSaveData.SetFilterButton( aBtnFilter.IsChecked() );
+ aSaveData.SetDrillDown( aBtnDrillDown.IsChecked() );
+
+ uno::Reference<sheet::XDimensionsSupplier> xSource = xDlgDPObject->GetSource();
+
+ ScDPObject::ConvertOrientation( aSaveData, aPageFieldArr, nPageCount,
+ sheet::DataPilotFieldOrientation_PAGE, NULL, 0, 0, xSource, FALSE );
+ ScDPObject::ConvertOrientation( aSaveData, aColFieldArr, nColCount,
+ sheet::DataPilotFieldOrientation_COLUMN, NULL, 0, 0, xSource, FALSE );
+ ScDPObject::ConvertOrientation( aSaveData, aRowFieldArr, nRowCount,
+ sheet::DataPilotFieldOrientation_ROW, NULL, 0, 0, xSource, FALSE );
+ ScDPObject::ConvertOrientation( aSaveData, aDataFieldArr, nDataCount,
+ sheet::DataPilotFieldOrientation_DATA, NULL, 0, 0, xSource, FALSE,
+ aColFieldArr, nColCount, aRowFieldArr, nRowCount, aPageFieldArr, nPageCount );
+
+ for( ScDPLabelDataVec::const_iterator aIt = aLabelDataArr.begin(), aEnd = aLabelDataArr.end(); aIt != aEnd; ++aIt )
+ {
+ if( ScDPSaveDimension* pDim = aSaveData.GetExistingDimensionByName( aIt->maName ) )
+ {
+ pDim->SetUsedHierarchy( aIt->mnUsedHier );
+ pDim->SetShowEmpty( aIt->mbShowAll );
+ pDim->SetSortInfo( &aIt->maSortInfo );
+ pDim->SetLayoutInfo( &aIt->maLayoutInfo );
+ pDim->SetAutoShowInfo( &aIt->maShowInfo );
+ ScDPSaveDimension* pOldDim = NULL;
+ if (pOldSaveData)
+ {
+ // Transfer the existing layout names to new dimension instance.
+ pOldDim = pOldSaveData->GetExistingDimensionByName(aIt->maName);
+ if (pOldDim)
+ {
+ const OUString* pLayoutName = pOldDim->GetLayoutName();
+ if (pLayoutName)
+ pDim->SetLayoutName(*pLayoutName);
+
+ const OUString* pSubtotalName = pOldDim->GetSubtotalName();
+ if (pSubtotalName)
+ pDim->SetSubtotalName(*pSubtotalName);
+ }
+ }
+
+ bool bManualSort = ( aIt->maSortInfo.Mode == sheet::DataPilotFieldSortMode::MANUAL );
+
+ // visibility of members
+ for (vector<ScDPLabelData::Member>::const_iterator itr = aIt->maMembers.begin(), itrEnd = aIt->maMembers.end();
+ itr != itrEnd; ++itr)
+ {
+ ScDPSaveMember* pMember = pDim->GetMemberByName(itr->maName);
+
+ // #i40054# create/access members only if flags are not default
+ // (or in manual sorting mode - to keep the order)
+ if (bManualSort || !itr->mbVisible || !itr->mbShowDetails)
+ {
+ pMember->SetIsVisible(itr->mbVisible);
+ pMember->SetShowDetails(itr->mbShowDetails);
+ }
+ if (pOldDim)
+ {
+ // Transfer the existing layout name.
+ ScDPSaveMember* pOldMember = pOldDim->GetMemberByName(itr->maName);
+ if (pOldMember)
+ {
+ const OUString* pLayoutName = pOldMember->GetLayoutName();
+ if (pLayoutName)
+ pMember->SetLayoutName(*pLayoutName);
+ }
+ }
+ }
+ }
+ }
+ ScDPSaveDimension* pDim = aSaveData.GetDataLayoutDimension();
+ if (pDim && pOldSaveData)
+ {
+ ScDPSaveDimension* pOldDim = pOldSaveData->GetDataLayoutDimension();
+ if (pOldDim)
+ {
+ const OUString* pLayoutName = pOldDim->GetLayoutName();
+ if (pLayoutName)
+ pDim->SetLayoutName(*pLayoutName);
+ }
+ }
+
+ USHORT nWhichPivot = SC_MOD()->GetPool().GetWhich( SID_PIVOT_TABLE );
+ ScPivotItem aOutItem( nWhichPivot, &aSaveData, &aOutRange, bToNewTable );
+
+ bRefInputMode = FALSE; // to allow deselecting when switching sheets
+
+ SetDispatcherLock( FALSE );
+ SwitchToDocument();
+
+ // #95513# don't hide the dialog before executing the slot, instead it is used as
+ // parent for message boxes in ScTabViewShell::GetDialogParent
+
+ const SfxPoolItem* pRet = GetBindings().GetDispatcher()->Execute(
+ SID_PIVOT_TABLE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, &aOutItem, 0L, 0L );
+
+ bool bSuccess = true;
+ if (pRet)
+ {
+ const SfxBoolItem* pItem = dynamic_cast<const SfxBoolItem*>(pRet);
+ if (pItem)
+ bSuccess = pItem->GetValue();
+ }
+ if (bSuccess)
+ // Table successfully inserted.
+ Close();
+ else
+ {
+ // Table insertion failed. Keep the dialog open.
+ bRefInputMode = true;
+ SetDispatcherLock(true);
+ }
+ }
+ else
+ {
+ ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ),
+ ScGlobal::GetRscString( STR_PIVOT_ERROR )
+ ).Execute();
+ }
+ }
+ else
+ {
+ if ( !aBtnMore.GetState() )
+ aBtnMore.SetState( TRUE );
+
+ ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ),
+ ScGlobal::GetRscString( STR_INVALID_TABREF )
+ ).Execute();
+ aEdOutPos.GrabFocus();
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScDPLayoutDlg, CancelHdl, CancelButton *, EMPTYARG )
+{
+ Close();
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScDPLayoutDlg, MoreClickHdl, MoreButton *, EMPTYARG )
+{
+ if ( aBtnMore.GetState() )
+ {
+ bRefInputMode = TRUE;
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable();
+ if ( aEdInPos.IsEnabled() )
+ {
+ aEdInPos.Enable();
+ aEdInPos.GrabFocus();
+ aEdInPos.Enable();
+ }
+ else
+ {
+ aEdOutPos.Enable();
+ aEdOutPos.GrabFocus();
+ aEdOutPos.Enable();
+ }
+ }
+ else
+ {
+ bRefInputMode = FALSE;
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScDPLayoutDlg, EdModifyHdl, Edit *, EMPTYARG )
+{
+ String theCurPosStr = aEdOutPos.GetText();
+ USHORT nResult = ScAddress().Parse( theCurPosStr, pDoc, pDoc->GetAddressConvention() );
+
+ if ( SCA_VALID == (nResult & SCA_VALID) )
+ {
+ String* pStr = NULL;
+ BOOL bFound = FALSE;
+ USHORT i = 0;
+ USHORT nCount = aLbOutPos.GetEntryCount();
+
+ for ( i=2; i<nCount && !bFound; i++ )
+ {
+ pStr = (String*)aLbOutPos.GetEntryData( i );
+ bFound = (theCurPosStr == *pStr);
+ }
+
+ if ( bFound )
+ aLbOutPos.SelectEntryPos( --i );
+ else
+ aLbOutPos.SelectEntryPos( 0 );
+ }
+ return 0;
+}
+
+
+IMPL_LINK( ScDPLayoutDlg, EdInModifyHdl, Edit *, EMPTYARG )
+{
+ UpdateSrcRange();
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScDPLayoutDlg, SelAreaHdl, ListBox *, EMPTYARG )
+{
+ String aString;
+ USHORT nSelPos = aLbOutPos.GetSelectEntryPos();
+
+ if ( nSelPos > 1 )
+ {
+ aString = *(String*)aLbOutPos.GetEntryData( nSelPos );
+ }
+ else if ( nSelPos == aLbOutPos.GetEntryCount()-1 ) // auf neue Tabelle?
+ {
+ aEdOutPos.Disable();
+ aRbOutPos.Disable();
+ }
+ else
+ {
+ aEdOutPos.Enable();
+ aRbOutPos.Enable();
+ }
+
+ aEdOutPos.SetText( aString );
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScDPLayoutDlg, ScrollHdl, ScrollBar *, EMPTYARG )
+{
+ long nNewOffset = aSlider.GetThumbPos();
+ long nOffsetDiff = nNewOffset - nOffset;
+ nOffset = nNewOffset;
+
+ size_t nFields = std::min< size_t >( aLabelDataArr.size() - nOffset, PAGE_SIZE );
+
+ aWndSelect.ClearFields();
+
+ size_t i=0;
+ for ( i=0; i<nFields; i++ )
+ {
+ const ScDPLabelData& rData = aLabelDataArr[nOffset+i];
+ aWndSelect.AddField(rData.getDisplayName(), i);
+ aSelectArr[i].reset( new ScDPFuncData( rData.mnCol, rData.mnFuncMask ) );
+ }
+ for ( ; i<aSelectArr.size(); i++ )
+ aSelectArr[i].reset();
+
+ aWndSelect.ModifySelectionOffset( nOffsetDiff ); // adjusts selection & redraws
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScDPLayoutDlg, GetFocusHdl, Control*, pCtrl )
+{
+ pEditActive = NULL;
+ if ( pCtrl == &aEdInPos )
+ pEditActive = &aEdInPos;
+ else if ( pCtrl == &aEdOutPos )
+ pEditActive = &aEdOutPos;
+
+ return 0;
+}
+
diff --git a/sc/source/ui/dbgui/scendlg.cxx b/sc/source/ui/dbgui/scendlg.cxx
new file mode 100644
index 000000000000..96c9f120f5b1
--- /dev/null
+++ b/sc/source/ui/dbgui/scendlg.cxx
@@ -0,0 +1,243 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+#include "scitems.hxx"
+#include <svx/drawitem.hxx>
+#include <svx/xtable.hxx>
+#include <sfx2/objsh.hxx>
+#include <unotools/useroptions.hxx>
+#include <vcl/msgbox.hxx>
+#include <unotools/localedatawrapper.hxx>
+
+#include "global.hxx"
+#include "globstr.hrc"
+#include "tabvwsh.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "scendlg.hrc"
+#include "scendlg.hxx"
+
+//========================================================================
+
+ScNewScenarioDlg::ScNewScenarioDlg( Window* pParent, const String& rName, BOOL bEdit, BOOL bSheetProtected)
+
+ : ModalDialog ( pParent, ScResId( RID_SCDLG_NEWSCENARIO ) ),
+ aFlName ( this, ScResId( FL_NAME )),
+ aEdName ( this, ScResId( ED_NAME ) ),
+ aFlComment ( this, ScResId( FL_COMMENT ) ),
+ aEdComment ( this, ScResId( ED_COMMENT ) ),
+ aFlOptions ( this, ScResId( FL_OPTIONS ) ),
+ aCbShowFrame ( this, ScResId( CB_SHOWFRAME ) ),
+ aLbColor ( this, ScResId( LB_COLOR ) ),
+ //aCbPrintFrame ( this, ScResId( CB_PRINTFRAME ) ),
+ aCbTwoWay ( this, ScResId( CB_TWOWAY ) ),
+ //aCbAttrib ( this, ScResId( CB_ATTRIB ) ),
+ //aCbValue ( this, ScResId( CB_VALUE ) ),
+ aCbCopyAll ( this, ScResId( CB_COPYALL ) ),
+ aCbProtect ( this, ScResId( CB_PROTECT ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aDefScenarioName( rName ),
+ bIsEdit ( bEdit )
+{
+ if (bIsEdit)
+ SetText(String(ScResId(STR_EDIT)));
+
+ SfxObjectShell* pDocSh = SfxObjectShell::Current();
+ if ( pDocSh )
+ {
+ const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE );
+ if ( pItem )
+ {
+ XColorTable* pColorTable = ((SvxColorTableItem*)pItem)->GetColorTable();
+ if (pColorTable)
+ {
+ aLbColor.SetUpdateMode( FALSE );
+ long nCount = pColorTable->Count();
+ for ( long n=0; n<nCount; n++ )
+ {
+ XColorEntry* pEntry = pColorTable->GetColor(n);
+ aLbColor.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
+ }
+ aLbColor.SetUpdateMode( TRUE );
+ }
+ }
+ }
+
+ SvtUserOptions aUserOpt;
+
+ String aComment( ScResId( STR_CREATEDBY ) );
+
+ aComment += ' ';
+ aComment += (String)aUserOpt.GetFirstName();
+ aComment += ' ';
+ aComment += (String)aUserOpt.GetLastName();
+ aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ", " ));
+ aComment += String( ScResId( STR_ON ) );
+ aComment += ' ';
+ aComment += ScGlobal::GetpLocaleData()->getDate( Date() );//CHINA001 aComment += ScGlobal::pLocaleData->getDate( Date() );
+ aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ", " ));
+ aComment += ScGlobal::GetpLocaleData()->getTime( Time() );//CHINA001 aComment += ScGlobal::pLocaleData->getTime( Time() );
+
+ aEdComment .SetText( aComment );
+ aEdName .SetText( rName );
+ aBtnOk .SetClickHdl( LINK( this, ScNewScenarioDlg, OkHdl ) );
+ aCbShowFrame.SetClickHdl( LINK( this, ScNewScenarioDlg, EnableHdl ) );
+
+ FreeResource();
+
+ aLbColor.SelectEntry( Color( COL_LIGHTGRAY ) );
+ aCbShowFrame.Check(TRUE);
+ //aCbPrintFrame.Check(TRUE);
+ aCbTwoWay.Check(TRUE);
+ //aCbAttrib.Check(FALSE);
+ //aCbValue.Check(FALSE);
+ aCbCopyAll.Check(FALSE);
+ aCbProtect.Check(TRUE);
+
+ if (bIsEdit)
+ aCbCopyAll.Enable(FALSE);
+ // If the Sheet is protected then we disable the Scenario Protect input
+ // and default it to true above. Note we are in 'Add' mode here as: if
+ // Sheet && scenario protection are true, then we cannot edit this dialog.
+ if (bSheetProtected)
+ aCbProtect.Enable(FALSE);
+
+ //! die drei funktionieren noch nicht...
+ /*
+ aCbPrintFrame.Enable(FALSE);
+ aCbAttrib.Enable(FALSE);
+ aCbValue.Enable(FALSE);
+ */
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScNewScenarioDlg::~ScNewScenarioDlg()
+{
+}
+
+//------------------------------------------------------------------------
+
+void ScNewScenarioDlg::GetScenarioData( String& rName, String& rComment,
+ Color& rColor, USHORT& rFlags ) const
+{
+ rComment = aEdComment.GetText();
+ rName = aEdName.GetText();
+
+ if ( rName.Len() == 0 )
+ rName = aDefScenarioName;
+
+ rColor = aLbColor.GetSelectEntryColor();
+ USHORT nBits = 0;
+ if (aCbShowFrame.IsChecked())
+ nBits |= SC_SCENARIO_SHOWFRAME;
+ /*
+ if (aCbPrintFrame.IsChecked())
+ nBits |= SC_SCENARIO_PRINTFRAME;
+ */
+ if (aCbTwoWay.IsChecked())
+ nBits |= SC_SCENARIO_TWOWAY;
+ /*
+ if (aCbAttrib.IsChecked())
+ nBits |= SC_SCENARIO_ATTRIB;
+ if (aCbValue.IsChecked())
+ nBits |= SC_SCENARIO_VALUE;
+ */
+ if (aCbCopyAll.IsChecked())
+ nBits |= SC_SCENARIO_COPYALL;
+ if (aCbProtect.IsChecked())
+ nBits |= SC_SCENARIO_PROTECT;
+ rFlags = nBits;
+}
+
+void ScNewScenarioDlg::SetScenarioData( const String& rName, const String& rComment,
+ const Color& rColor, USHORT nFlags )
+{
+ aEdComment.SetText(rComment);
+ aEdName.SetText(rName);
+ aLbColor.SelectEntry(rColor);
+
+ aCbShowFrame.Check ( (nFlags & SC_SCENARIO_SHOWFRAME) != 0 );
+ EnableHdl( &aCbShowFrame );
+ //aCbPrintFrame.Check( (nFlags & SC_SCENARIO_PRINTFRAME) != 0 );
+ aCbTwoWay.Check ( (nFlags & SC_SCENARIO_TWOWAY) != 0 );
+ //aCbAttrib.Check ( (nFlags & SC_SCENARIO_ATTRIB) != 0 );
+ //aCbValue.Check ( (nFlags & SC_SCENARIO_VALUE) != 0 );
+ // CopyAll nicht
+ aCbProtect.Check ( (nFlags & SC_SCENARIO_PROTECT) != 0 );
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScNewScenarioDlg, OkHdl, OKButton *, EMPTYARG )
+{
+ String aName ( aEdName.GetText() );
+ ScDocument* pDoc = ((ScTabViewShell*)SfxViewShell::Current())->
+ GetViewData()->GetDocument();
+
+ aName.EraseLeadingChars( ' ' );
+ aName.EraseTrailingChars( ' ' );
+ aEdName.SetText( aName );
+
+ if ( !pDoc->ValidTabName( aName ) )
+ {
+ InfoBox( this, ScGlobal::GetRscString( STR_INVALIDTABNAME ) ).
+ Execute();
+ aEdName.GrabFocus();
+ }
+ else if ( !bIsEdit && !pDoc->ValidNewTabName( aName ) )
+ {
+ InfoBox( this, ScGlobal::GetRscString( STR_NEWTABNAMENOTUNIQUE ) ).
+ Execute();
+ aEdName.GrabFocus();
+ }
+ else
+ EndDialog( RET_OK );
+ return 0;
+
+ //! beim Editieren testen, ob eine andere Tabelle den Namen hat!
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScNewScenarioDlg, EnableHdl, CheckBox *, pBox )
+{
+ if( pBox == &aCbShowFrame )
+ aLbColor.Enable( aCbShowFrame.IsChecked() );
+ return 0;
+}
+
diff --git a/sc/source/ui/dbgui/scendlg.hrc b/sc/source/ui/dbgui/scendlg.hrc
new file mode 100644
index 000000000000..83818773bf5a
--- /dev/null
+++ b/sc/source/ui/dbgui/scendlg.hrc
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "sc.hrc"
+//#define RID_SCDLG_NEWSCENARIO 256
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+
+#define FL_NAME 10
+#define ED_NAME 11
+#define FL_COMMENT 12
+#define ED_COMMENT 13
+
+#define FL_OPTIONS 20
+#define CB_SHOWFRAME 21
+#define LB_COLOR 22
+#define CB_PRINTFRAME 23
+#define CB_TWOWAY 24
+#define CB_ATTRIB 25
+#define CB_VALUE 26
+#define CB_COPYALL 27
+#define CB_PROTECT 28
+
+#ifdef STR_ON
+#undef STR_ON
+#endif
+#ifdef STR_EDIT
+#undef STR_EDIT
+#endif
+
+#define STR_CREATEDBY 31
+#define STR_ON 32
+#define STR_EDIT 33
diff --git a/sc/source/ui/dbgui/scendlg.src b/sc/source/ui/dbgui/scendlg.src
new file mode 100644
index 000000000000..f7c3d29b8365
--- /dev/null
+++ b/sc/source/ui/dbgui/scendlg.src
@@ -0,0 +1,206 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "scendlg.hrc"
+ModalDialog RID_SCDLG_NEWSCENARIO
+{
+ HelpID = "sc:ModalDialog:RID_SCDLG_NEWSCENARIO";
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 260 , 165 ) ;
+ Text [ en-US ] = "Create Scenario" ;
+ Moveable = TRUE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 204 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 204 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 204 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ MultiLineEdit ED_COMMENT
+ {
+ HelpID = "sc:MultiLineEdit:RID_SCDLG_NEWSCENARIO:ED_COMMENT";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 43 ) ;
+ Size = MAP_APPFONT ( 183 , 46 ) ;
+ TabStop = TRUE ;
+ MaxTextLength = 512 ;
+ VScroll = TRUE ;
+ IgnoreTab = TRUE ;
+ };
+ Edit ED_NAME
+ {
+ HelpID = "sc:Edit:RID_SCDLG_NEWSCENARIO:ED_NAME";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 183 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ CheckBox CB_SHOWFRAME
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_NEWSCENARIO:CB_SHOWFRAME";
+ Pos = MAP_APPFONT ( 12 , 107 ) ;
+ Size = MAP_APPFONT ( 109 , 10 ) ;
+ Text [ en-US ] = "~Display border";
+ };
+ ListBox LB_COLOR
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_NEWSCENARIO:LB_COLOR";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 125 , 105 ) ;
+ Size = MAP_APPFONT ( 70 , 86 ) ;
+ DropDown = TRUE ;
+ DDExtraWidth = TRUE ;
+ };
+ CheckBox CB_PRINTFRAME
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_NEWSCENARIO:CB_PRINTFRAME";
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 121 , 243 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "Print border" ;
+ };
+ CheckBox CB_TWOWAY
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_NEWSCENARIO:CB_TWOWAY";
+ Pos = MAP_APPFONT ( 12 , 121 ) ;
+ Size = MAP_APPFONT ( 183 , 10 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? Zurückkopieren : Zur³ckkopieren */
+ Text [ en-US ] = "Copy ~back" ;
+ };
+ CheckBox CB_ATTRIB
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_NEWSCENARIO:CB_ATTRIB";
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 20 , 243 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "Attributes" ;
+ };
+ CheckBox CB_VALUE
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_NEWSCENARIO:CB_VALUE";
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 230 , 243 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "Copy values only" ;
+ };
+ CheckBox CB_COPYALL
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_NEWSCENARIO:CB_COPYALL";
+ Pos = MAP_APPFONT ( 12 , 135 ) ;
+ Size = MAP_APPFONT ( 183 , 10 ) ;
+ Text [ en-US ] = "Copy ~entire sheet" ;
+ };
+ CheckBox CB_PROTECT
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_NEWSCENARIO:CB_PROTECT";
+ Pos = MAP_APPFONT ( 12 , 149 ) ;
+ Size = MAP_APPFONT ( 183 , 10 ) ;
+ Text [ en-US ] = "~Prevent changes" ;
+ };
+ String STR_EDIT
+ {
+ Text [ en-US ] = "Edit Scenario" ;
+ };
+ String STR_CREATEDBY
+ {
+ Text [ en-US ] = "Created by" ;
+ };
+ String STR_ON
+ {
+ Text [ en-US ] = "on" ;
+ };
+ FixedLine FL_NAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 192 , 8 ) ;
+ Text [ en-US ] = "~Name of scenario";
+ };
+ FixedLine FL_COMMENT
+ {
+ Pos = MAP_APPFONT ( 6 , 32 ) ;
+ Size = MAP_APPFONT ( 192 , 8 ) ;
+ Text [ en-US ] = "~Comment";
+ };
+ FixedLine FL_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 6 , 95 ) ;
+ Size = MAP_APPFONT ( 192 , 8 ) ;
+ Text [ en-US ] = "Settings";
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx
new file mode 100644
index 000000000000..42f2a2d86933
--- /dev/null
+++ b/sc/source/ui/dbgui/scuiasciiopt.cxx
@@ -0,0 +1,718 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+#include "global.hxx"
+#include "scresid.hxx"
+#include "impex.hxx"
+#include "scuiasciiopt.hxx"
+#include "asciiopt.hrc"
+#include <tools/debug.hxx>
+#include <rtl/tencinfo.h>
+#include <unotools/transliterationwrapper.hxx>
+// ause
+#include "editutil.hxx"
+
+#include <optutil.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include "miscuno.hxx"
+
+//! TODO make dynamic
+const SCSIZE ASCIIDLG_MAXROWS = MAXROWCOUNT;
+
+
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+// Defines - CSV Import Preserve Options
+#define FIXED_WIDTH "FixedWidth"
+#define FROM_ROW "FromRow"
+#define CHAR_SET "CharSet"
+#define SEPARATORS "Separators"
+#define TEXT_SEPARATORS "TextSeparators"
+#define MERGE_DELIMITERS "MergeDelimiters"
+#define QUOTED_AS_TEXT "QuotedFieldAsText"
+#define DETECT_SPECIAL_NUM "DetectSpecialNumbers"
+#define LANGUAGE "Language"
+#define SEP_PATH "Office.Calc/Dialogs/CSVImport"
+
+// ============================================================================
+
+void lcl_FillCombo( ComboBox& rCombo, const String& rList, sal_Unicode cSelect )
+{
+ xub_StrLen i;
+ xub_StrLen nCount = rList.GetTokenCount('\t');
+ for ( i=0; i<nCount; i+=2 )
+ rCombo.InsertEntry( rList.GetToken(i,'\t') );
+
+ if ( cSelect )
+ {
+ String aStr;
+ for ( i=0; i<nCount; i+=2 )
+ if ( (sal_Unicode)rList.GetToken(i+1,'\t').ToInt32() == cSelect )
+ aStr = rList.GetToken(i,'\t');
+ if (!aStr.Len())
+ aStr = cSelect; // Ascii
+
+ rCombo.SetText(aStr);
+ }
+}
+
+sal_Unicode lcl_CharFromCombo( ComboBox& rCombo, const String& rList )
+{
+ sal_Unicode c = 0;
+ String aStr = rCombo.GetText();
+ if ( aStr.Len() )
+ {
+ xub_StrLen nCount = rList.GetTokenCount('\t');
+ for ( xub_StrLen i=0; i<nCount; i+=2 )
+ {
+ if ( ScGlobal::GetpTransliteration()->isEqual( aStr, rList.GetToken(i,'\t') ) )//CHINA001 if ( ScGlobal::GetpTransliteration()->isEqual( aStr, rList.GetToken(i,'\t') ) )
+ c = (sal_Unicode)rList.GetToken(i+1,'\t').ToInt32();
+ }
+ if (!c && aStr.Len())
+ {
+ sal_Unicode cFirst = aStr.GetChar( 0 );
+ // #i24235# first try the first character of the string directly
+ if( (aStr.Len() == 1) || (cFirst < '0') || (cFirst > '9') )
+ c = cFirst;
+ else // keep old behaviour for compatibility (i.e. "39" -> "'")
+ c = (sal_Unicode) aStr.ToInt32(); // Ascii
+ }
+ }
+ return c;
+}
+
+static void load_Separators( OUString &sFieldSeparators, OUString &sTextSeparators,
+ bool &bMergeDelimiters, bool& bQuotedAsText, bool& bDetectSpecialNum,
+ bool &bFixedWidth, sal_Int32 &nFromRow, sal_Int32 &nCharSet,
+ sal_Int32& nLanguage )
+{
+ Sequence<Any>aValues;
+ const Any *pProperties;
+ Sequence<OUString> aNames(9);
+ OUString* pNames = aNames.getArray();
+ ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
+
+ pNames[0] = OUString::createFromAscii( MERGE_DELIMITERS );
+ pNames[1] = OUString::createFromAscii( SEPARATORS );
+ pNames[2] = OUString::createFromAscii( TEXT_SEPARATORS );
+ pNames[3] = OUString::createFromAscii( FIXED_WIDTH );
+ pNames[4] = OUString::createFromAscii( FROM_ROW );
+ pNames[5] = OUString::createFromAscii( CHAR_SET );
+ pNames[6] = OUString::createFromAscii( QUOTED_AS_TEXT );
+ pNames[7] = OUString::createFromAscii( DETECT_SPECIAL_NUM );
+ pNames[8] = OUString::createFromAscii( LANGUAGE );
+ aValues = aItem.GetProperties( aNames );
+ pProperties = aValues.getConstArray();
+ if( pProperties[1].hasValue() )
+ pProperties[1] >>= sFieldSeparators;
+
+ if( pProperties[2].hasValue() )
+ pProperties[2] >>= sTextSeparators;
+
+ if( pProperties[0].hasValue() )
+ bMergeDelimiters = ScUnoHelpFunctions::GetBoolFromAny( pProperties[0] );
+
+ if( pProperties[3].hasValue() )
+ bFixedWidth = ScUnoHelpFunctions::GetBoolFromAny( pProperties[3] );
+
+ if( pProperties[4].hasValue() )
+ pProperties[4] >>= nFromRow;
+
+ if( pProperties[5].hasValue() )
+ pProperties[5] >>= nCharSet;
+
+ if ( pProperties[6].hasValue() )
+ pProperties[6] >>= bQuotedAsText;
+
+ if ( pProperties[7].hasValue() )
+ pProperties[7] >>= bDetectSpecialNum;
+
+ if ( pProperties[8].hasValue() )
+ pProperties[8] >>= nLanguage;
+}
+
+static void save_Separators(
+ String maSeparators, String maTxtSep, bool bMergeDelimiters, bool bQuotedAsText,
+ bool bDetectSpecialNum, bool bFixedWidth, sal_Int32 nFromRow, sal_Int32 nCharSet, sal_Int32 nLanguage )
+{
+ OUString sFieldSeparators = OUString( maSeparators );
+ OUString sTextSeparators = OUString( maTxtSep );
+ Sequence<Any> aValues;
+ Any *pProperties;
+ Sequence<OUString> aNames(9);
+ OUString* pNames = aNames.getArray();
+ ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
+
+ pNames[0] = OUString::createFromAscii( MERGE_DELIMITERS );
+ pNames[1] = OUString::createFromAscii( SEPARATORS );
+ pNames[2] = OUString::createFromAscii( TEXT_SEPARATORS );
+ pNames[3] = OUString::createFromAscii( FIXED_WIDTH );
+ pNames[4] = OUString::createFromAscii( FROM_ROW );
+ pNames[5] = OUString::createFromAscii( CHAR_SET );
+ pNames[6] = OUString::createFromAscii( QUOTED_AS_TEXT );
+ pNames[7] = OUString::createFromAscii( DETECT_SPECIAL_NUM );
+ pNames[8] = OUString::createFromAscii( LANGUAGE );
+ aValues = aItem.GetProperties( aNames );
+ pProperties = aValues.getArray();
+ pProperties[1] <<= sFieldSeparators;
+ pProperties[2] <<= sTextSeparators;
+ ScUnoHelpFunctions::SetBoolInAny( pProperties[0], bMergeDelimiters );
+ ScUnoHelpFunctions::SetBoolInAny( pProperties[3], bFixedWidth );
+ pProperties[4] <<= nFromRow;
+ pProperties[5] <<= nCharSet;
+ pProperties[6] <<= static_cast<sal_Bool>(bQuotedAsText);
+ pProperties[7] <<= static_cast<sal_Bool>(bDetectSpecialNum);
+ pProperties[8] <<= nLanguage;
+
+ aItem.PutProperties(aNames, aValues);
+}
+
+// ----------------------------------------------------------------------------
+
+ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
+ SvStream* pInStream, sal_Unicode /*cSep*/ ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_ASCII ) ),
+ mpDatStream ( pInStream ),
+ mnStreamPos( pInStream ? pInStream->Tell() : 0 ),
+
+ mpRowPosArray( NULL ),
+ mnRowPosCount(0),
+
+ aFlFieldOpt ( this, ScResId( FL_FIELDOPT ) ),
+ aFtCharSet ( this, ScResId( FT_CHARSET ) ),
+ aLbCharSet ( this, ScResId( LB_CHARSET ) ),
+ aFtCustomLang( this, ScResId( FT_CUSTOMLANG ) ),
+ aLbCustomLang( this, ScResId( LB_CUSTOMLANG ) ),
+
+ aFtRow ( this, ScResId( FT_AT_ROW ) ),
+ aNfRow ( this, ScResId( NF_AT_ROW ) ),
+
+ aFlSepOpt ( this, ScResId( FL_SEPOPT ) ),
+ aRbFixed ( this, ScResId( RB_FIXED ) ),
+ aRbSeparated( this, ScResId( RB_SEPARATED ) ),
+
+ aCkbTab ( this, ScResId( CKB_TAB ) ),
+ aCkbSemicolon(this, ScResId( CKB_SEMICOLON ) ),
+ aCkbComma ( this, ScResId( CKB_COMMA ) ),
+ aCkbSpace ( this, ScResId( CKB_SPACE ) ),
+ aCkbOther ( this, ScResId( CKB_OTHER ) ),
+ aEdOther ( this, ScResId( ED_OTHER ) ),
+ aCkbAsOnce ( this, ScResId( CB_ASONCE) ),
+ aFlOtherOpt ( this, ScResId( FL_OTHER_OPTIONS ) ),
+
+ aFtTextSep ( this, ScResId( FT_TEXTSEP ) ),
+ aCbTextSep ( this, ScResId( CB_TEXTSEP ) ),
+
+ aCkbQuotedAsText( this, ScResId(CB_QUOTED_AS_TEXT) ),
+ aCkbDetectNumber( this, ScResId(CB_DETECT_SPECIAL_NUMBER) ),
+
+ aFlWidth ( this, ScResId( FL_WIDTH ) ),
+ aFtType ( this, ScResId( FT_TYPE ) ),
+ aLbType ( this, ScResId( LB_TYPE1 ) ),
+
+ maTableBox ( this, ScResId( CTR_TABLEBOX ) ),
+
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+
+ aCharSetUser( ScResId( SCSTR_CHARSET_USER ) ),
+ aColumnUser ( ScResId( SCSTR_COLUMN_USER ) ),
+ aFldSepList ( ScResId( SCSTR_FIELDSEP ) ),
+ aTextSepList( ScResId( SCSTR_TEXTSEP ) ),
+ mcTextSep ( ScAsciiOptions::cDefaultTextSep ),
+ maStrTextToColumns( ScResId( STR_TEXTTOCOLUMNS ) ),
+ mbFileImport(true)
+{
+ FreeResource();
+ mbFileImport = aDatName.Len() > 0;
+
+ String aName = GetText();
+ // aDatName is empty if invoked during paste from clipboard.
+ if (mbFileImport)
+ {
+ aName.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" - ["));
+ aName += aDatName;
+ aName += ']';
+ }
+ SetText( aName );
+
+
+ OUString sFieldSeparators;
+ OUString sTextSeparators;
+ bool bMergeDelimiters = false;
+ bool bFixedWidth = false;
+ bool bQuotedFieldAsText = true;
+ bool bDetectSpecialNum = false;
+ sal_Int32 nFromRow = 1;
+ sal_Int32 nCharSet = -1;
+ sal_Int32 nLanguage = 0;
+ if (mbFileImport)
+ // load separators only when importing csv files.
+ load_Separators (sFieldSeparators, sTextSeparators, bMergeDelimiters,
+ bQuotedFieldAsText, bDetectSpecialNum, bFixedWidth, nFromRow, nCharSet, nLanguage);
+ maFieldSeparators = String(sFieldSeparators);
+
+ if( bMergeDelimiters )
+ aCkbAsOnce.Check();
+ if (bQuotedFieldAsText)
+ aCkbQuotedAsText.Check();
+ if (bDetectSpecialNum)
+ aCkbDetectNumber.Check();
+ if( bFixedWidth )
+ aRbFixed.Check();
+ if( nFromRow != 1 )
+ aNfRow.SetValue( nFromRow );
+
+ ByteString bString(maFieldSeparators,RTL_TEXTENCODING_MS_1252);
+ const sal_Char *aSep = bString.GetBuffer();
+ int len = maFieldSeparators.Len();
+ for (int i = 0; i < len; ++i)
+ {
+ switch( aSep[i] )
+ {
+ case '\t': aCkbTab.Check(); break;
+ case ';': aCkbSemicolon.Check(); break;
+ case ',': aCkbComma.Check(); break;
+ case ' ': aCkbSpace.Check(); break;
+ default:
+ aCkbOther.Check();
+ aEdOther.SetText( aEdOther.GetText() + OUString( aSep[i] ) );
+ }
+ }
+
+ // Get Separators from the dialog
+ maFieldSeparators = GetSeparators();
+
+ // Clipboard is always Unicode, else detect.
+ bool bPreselectUnicode = !mbFileImport;
+ // Sniff for Unicode / not
+ if( !bPreselectUnicode && mpDatStream )
+ {
+ Seek( 0 );
+ mpDatStream->StartReadingUnicodeText();
+ ULONG nUniPos = mpDatStream->Tell();
+ if ( nUniPos > 0 )
+ bPreselectUnicode = TRUE; // read 0xfeff/0xfffe
+ else
+ {
+ UINT16 n;
+ *mpDatStream >> n;
+ // Assume that normal ASCII/ANSI/ISO/etc. text doesn't start with
+ // control characters except CR,LF,TAB
+ if ( (n & 0xff00) < 0x2000 )
+ {
+ switch ( n & 0xff00 )
+ {
+ case 0x0900 :
+ case 0x0a00 :
+ case 0x0d00 :
+ break;
+ default:
+ bPreselectUnicode = TRUE;
+ }
+ }
+ mpDatStream->Seek(0);
+ }
+ mnStreamPos = mpDatStream->Tell();
+ }
+
+ aNfRow.SetModifyHdl( LINK( this, ScImportAsciiDlg, FirstRowHdl ) );
+
+ // *** Separator characters ***
+ lcl_FillCombo( aCbTextSep, aTextSepList, mcTextSep );
+ aCbTextSep.SetText( sTextSeparators );
+
+ Link aSeparatorHdl =LINK( this, ScImportAsciiDlg, SeparatorHdl );
+ aCbTextSep.SetSelectHdl( aSeparatorHdl );
+ aCbTextSep.SetModifyHdl( aSeparatorHdl );
+ aCkbTab.SetClickHdl( aSeparatorHdl );
+ aCkbSemicolon.SetClickHdl( aSeparatorHdl );
+ aCkbComma.SetClickHdl( aSeparatorHdl );
+ aCkbAsOnce.SetClickHdl( aSeparatorHdl );
+ aCkbQuotedAsText.SetClickHdl( aSeparatorHdl );
+ aCkbDetectNumber.SetClickHdl( aSeparatorHdl );
+ aCkbSpace.SetClickHdl( aSeparatorHdl );
+ aCkbOther.SetClickHdl( aSeparatorHdl );
+ aEdOther.SetModifyHdl( aSeparatorHdl );
+
+ // *** text encoding ListBox ***
+ // all encodings allowed, including Unicode, but subsets are excluded
+ aLbCharSet.FillFromTextEncodingTable( TRUE );
+ // Insert one "SYSTEM" entry for compatibility in AsciiOptions and system
+ // independent document linkage.
+ aLbCharSet.InsertTextEncoding( RTL_TEXTENCODING_DONTKNOW, aCharSetUser );
+ aLbCharSet.SelectTextEncoding( bPreselectUnicode ?
+ RTL_TEXTENCODING_UNICODE : gsl_getSystemTextEncoding() );
+
+ if( nCharSet >= 0 )
+ aLbCharSet.SelectEntryPos( static_cast<USHORT>(nCharSet) );
+
+ SetSelectedCharSet();
+ aLbCharSet.SetSelectHdl( LINK( this, ScImportAsciiDlg, CharSetHdl ) );
+
+ aLbCustomLang.SetLanguageList(
+ LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, false, false);
+ aLbCustomLang.InsertLanguage(LANGUAGE_SYSTEM);
+ aLbCustomLang.SelectLanguage(static_cast<LanguageType>(nLanguage), true);
+
+ // *** column type ListBox ***
+ xub_StrLen nCount = aColumnUser.GetTokenCount();
+ for (xub_StrLen i=0; i<nCount; i++)
+ aLbType.InsertEntry( aColumnUser.GetToken( i ) );
+
+ aLbType.SetSelectHdl( LINK( this, ScImportAsciiDlg, LbColTypeHdl ) );
+ aFtType.Disable();
+ aLbType.Disable();
+
+ // *** table box preview ***
+ maTableBox.SetUpdateTextHdl( LINK( this, ScImportAsciiDlg, UpdateTextHdl ) );
+ maTableBox.InitTypes( aLbType );
+ maTableBox.SetColTypeHdl( LINK( this, ScImportAsciiDlg, ColTypeHdl ) );
+
+ aRbSeparated.SetClickHdl( LINK( this, ScImportAsciiDlg, RbSepFixHdl ) );
+ aRbFixed.SetClickHdl( LINK( this, ScImportAsciiDlg, RbSepFixHdl ) );
+
+ SetupSeparatorCtrls();
+ RbSepFixHdl( &aRbFixed );
+
+ UpdateVertical();
+
+ maTableBox.Execute( CSVCMD_NEWCELLTEXTS );
+}
+
+
+ScImportAsciiDlg::~ScImportAsciiDlg()
+{
+ delete[] mpRowPosArray;
+}
+
+
+// ----------------------------------------------------------------------------
+
+bool ScImportAsciiDlg::GetLine( ULONG nLine, String &rText )
+{
+ if (nLine >= ASCIIDLG_MAXROWS || !mpDatStream)
+ return false;
+
+ bool bRet = true;
+ bool bFixed = aRbFixed.IsChecked();
+
+ if (!mpRowPosArray)
+ mpRowPosArray = new ULONG[ASCIIDLG_MAXROWS + 2];
+
+ if (!mnRowPosCount) // complete re-fresh
+ {
+ memset( mpRowPosArray, 0, sizeof(mpRowPosArray[0]) * (ASCIIDLG_MAXROWS+2));
+
+ Seek(0);
+ if ( mpDatStream->GetStreamCharSet() == RTL_TEXTENCODING_UNICODE )
+ mpDatStream->StartReadingUnicodeText();
+
+ mnStreamPos = mpDatStream->Tell();
+ mpRowPosArray[mnRowPosCount] = mnStreamPos;
+ }
+
+ if (nLine >= mnRowPosCount)
+ {
+ // need to work out some more line information
+ do
+ {
+ if (!Seek( mpRowPosArray[mnRowPosCount]) ||
+ mpDatStream->GetError() != ERRCODE_NONE ||
+ mpDatStream->IsEof())
+ {
+ bRet = false;
+ break;
+ }
+ mpDatStream->ReadCsvLine( rText, !bFixed, maFieldSeparators,
+ mcTextSep);
+ mnStreamPos = mpDatStream->Tell();
+ mpRowPosArray[++mnRowPosCount] = mnStreamPos;
+ } while (nLine >= mnRowPosCount &&
+ mpDatStream->GetError() == ERRCODE_NONE &&
+ !mpDatStream->IsEof());
+ if (mpDatStream->IsEof() &&
+ mnStreamPos == mpRowPosArray[mnRowPosCount-1])
+ {
+ // the very end, not even an empty line read
+ bRet = false;
+ --mnRowPosCount;
+ }
+ }
+ else
+ {
+ Seek( mpRowPosArray[nLine]);
+ mpDatStream->ReadCsvLine( rText, !bFixed, maFieldSeparators, mcTextSep);
+ mnStreamPos = mpDatStream->Tell();
+ }
+
+ // #107455# If the file content isn't unicode, ReadUniStringLine
+ // may try to seek beyond the file's end and cause a CANTSEEK error
+ // (depending on the stream type). The error code has to be cleared,
+ // or further read operations (including non-unicode) will fail.
+ if ( mpDatStream->GetError() == ERRCODE_IO_CANTSEEK )
+ mpDatStream->ResetError();
+
+ return bRet;
+}
+
+
+void ScImportAsciiDlg::GetOptions( ScAsciiOptions& rOpt )
+{
+ rOpt.SetCharSet( meCharSet );
+ rOpt.SetCharSetSystem( mbCharSetSystem );
+ rOpt.SetLanguage(aLbCustomLang.GetSelectLanguage());
+ rOpt.SetFixedLen( aRbFixed.IsChecked() );
+ rOpt.SetStartRow( (long)aNfRow.GetValue() );
+ maTableBox.FillColumnData( rOpt );
+ if( aRbSeparated.IsChecked() )
+ {
+ rOpt.SetFieldSeps( GetSeparators() );
+ rOpt.SetMergeSeps( aCkbAsOnce.IsChecked() );
+ rOpt.SetTextSep( lcl_CharFromCombo( aCbTextSep, aTextSepList ) );
+ }
+
+ rOpt.SetQuotedAsText(aCkbQuotedAsText.IsChecked());
+ rOpt.SetDetectSpecialNumber(aCkbDetectNumber.IsChecked());
+}
+
+void ScImportAsciiDlg::SetTextToColumnsMode()
+{
+ SetText( maStrTextToColumns );
+ aFtCharSet.Disable();
+ aLbCharSet.Disable();
+ aFtCustomLang.Disable();
+ aLbCustomLang.SelectLanguage(LANGUAGE_SYSTEM);
+ aLbCustomLang.Disable();
+ aFtRow.Disable();
+ aNfRow.Disable();
+
+ // Quoted field as text option is not used for text-to-columns mode.
+ aCkbQuotedAsText.Check(false);
+ aCkbQuotedAsText.Disable();
+
+ // Always detect special numbers for text-to-columns mode.
+ aCkbDetectNumber.Check();
+ aCkbDetectNumber.Disable();
+}
+
+void ScImportAsciiDlg::SaveParameters()
+{
+ if (!mbFileImport)
+ // We save parameters only for file import.
+ return;
+
+ save_Separators( maFieldSeparators, aCbTextSep.GetText(), aCkbAsOnce.IsChecked(),
+ aCkbQuotedAsText.IsChecked(), aCkbDetectNumber.IsChecked(),
+ aRbFixed.IsChecked(),
+ static_cast<sal_Int32>(aNfRow.GetValue()),
+ static_cast<sal_Int32>(aLbCharSet.GetSelectEntryPos()),
+ static_cast<sal_Int32>(aLbCustomLang.GetSelectLanguage()) );
+}
+
+void ScImportAsciiDlg::SetSelectedCharSet()
+{
+ meCharSet = aLbCharSet.GetSelectTextEncoding();
+ mbCharSetSystem = (meCharSet == RTL_TEXTENCODING_DONTKNOW);
+ if( mbCharSetSystem )
+ meCharSet = gsl_getSystemTextEncoding();
+}
+
+String ScImportAsciiDlg::GetSeparators() const
+{
+ String aSepChars;
+ if( aCkbTab.IsChecked() )
+ aSepChars += '\t';
+ if( aCkbSemicolon.IsChecked() )
+ aSepChars += ';';
+ if( aCkbComma.IsChecked() )
+ aSepChars += ',';
+ if( aCkbSpace.IsChecked() )
+ aSepChars += ' ';
+ if( aCkbOther.IsChecked() )
+ aSepChars += aEdOther.GetText();
+ return aSepChars;
+}
+
+void ScImportAsciiDlg::SetupSeparatorCtrls()
+{
+ BOOL bEnable = aRbSeparated.IsChecked();
+ aCkbTab.Enable( bEnable );
+ aCkbSemicolon.Enable( bEnable );
+ aCkbComma.Enable( bEnable );
+ aCkbSpace.Enable( bEnable );
+ aCkbOther.Enable( bEnable );
+ aEdOther.Enable( bEnable );
+ aCkbAsOnce.Enable( bEnable );
+ aFtTextSep.Enable( bEnable );
+ aCbTextSep.Enable( bEnable );
+}
+
+void ScImportAsciiDlg::UpdateVertical()
+{
+ mnRowPosCount = 0;
+ if (mpDatStream)
+ mpDatStream->SetStreamCharSet(meCharSet);
+}
+
+
+// ----------------------------------------------------------------------------
+
+IMPL_LINK( ScImportAsciiDlg, RbSepFixHdl, RadioButton*, pButton )
+{
+ DBG_ASSERT( pButton, "ScImportAsciiDlg::RbSepFixHdl - missing sender" );
+
+ if( (pButton == &aRbFixed) || (pButton == &aRbSeparated) )
+ {
+ SetPointer( Pointer( POINTER_WAIT ) );
+ if( aRbFixed.IsChecked() )
+ maTableBox.SetFixedWidthMode();
+ else
+ maTableBox.SetSeparatorsMode();
+ SetPointer( Pointer( POINTER_ARROW ) );
+
+ SetupSeparatorCtrls();
+ }
+ return 0;
+}
+
+IMPL_LINK( ScImportAsciiDlg, SeparatorHdl, Control*, pCtrl )
+{
+ DBG_ASSERT( pCtrl, "ScImportAsciiDlg::SeparatorHdl - missing sender" );
+ DBG_ASSERT( !aRbFixed.IsChecked(), "ScImportAsciiDlg::SeparatorHdl - not allowed in fixed width" );
+
+ /* #i41550# First update state of the controls. The GetSeparators()
+ function needs final state of the check boxes. */
+ if( (pCtrl == &aCkbOther) && aCkbOther.IsChecked() )
+ aEdOther.GrabFocus();
+ else if( pCtrl == &aEdOther )
+ aCkbOther.Check( aEdOther.GetText().Len() > 0 );
+
+ String aOldFldSeps( maFieldSeparators);
+ maFieldSeparators = GetSeparators();
+ sal_Unicode cOldSep = mcTextSep;
+ mcTextSep = lcl_CharFromCombo( aCbTextSep, aTextSepList );
+ // Any separator changed may result in completely different lines due to
+ // embedded line breaks.
+ if (cOldSep != mcTextSep || aOldFldSeps != maFieldSeparators)
+ UpdateVertical();
+
+ maTableBox.Execute( CSVCMD_NEWCELLTEXTS );
+ return 0;
+}
+
+IMPL_LINK( ScImportAsciiDlg, CharSetHdl, SvxTextEncodingBox*, pCharSetBox )
+{
+ DBG_ASSERT( pCharSetBox, "ScImportAsciiDlg::CharSetHdl - missing sender" );
+
+ if( (pCharSetBox == &aLbCharSet) && (pCharSetBox->GetSelectEntryCount() == 1) )
+ {
+ SetPointer( Pointer( POINTER_WAIT ) );
+ CharSet eOldCharSet = meCharSet;
+ SetSelectedCharSet();
+ // switching char-set invalidates 8bit -> String conversions
+ if (eOldCharSet != meCharSet)
+ UpdateVertical();
+
+ maTableBox.Execute( CSVCMD_NEWCELLTEXTS );
+ SetPointer( Pointer( POINTER_ARROW ) );
+ }
+ return 0;
+}
+
+IMPL_LINK( ScImportAsciiDlg, FirstRowHdl, NumericField*, pNumField )
+{
+ DBG_ASSERT( pNumField, "ScImportAsciiDlg::FirstRowHdl - missing sender" );
+ maTableBox.Execute( CSVCMD_SETFIRSTIMPORTLINE, sal::static_int_cast<sal_Int32>( pNumField->GetValue() - 1 ) );
+ return 0;
+}
+
+IMPL_LINK( ScImportAsciiDlg, LbColTypeHdl, ListBox*, pListBox )
+{
+ DBG_ASSERT( pListBox, "ScImportAsciiDlg::LbColTypeHdl - missing sender" );
+ if( pListBox == &aLbType )
+ maTableBox.Execute( CSVCMD_SETCOLUMNTYPE, pListBox->GetSelectEntryPos() );
+ return 0;
+}
+
+IMPL_LINK( ScImportAsciiDlg, UpdateTextHdl, ScCsvTableBox*, EMPTYARG )
+{
+ sal_Int32 nBaseLine = maTableBox.GetFirstVisLine();
+ sal_Int32 nRead = maTableBox.GetVisLineCount();
+ // If mnRowPosCount==0, this is an initializing call, read ahead for row
+ // count and resulting scroll bar size and position to be able to scroll at
+ // all. When adding lines, read only the amount of next lines to be
+ // displayed.
+ if (!mnRowPosCount || nRead > CSV_PREVIEW_LINES)
+ nRead = CSV_PREVIEW_LINES;
+
+ sal_Int32 i;
+ for (i = 0; i < nRead; i++)
+ {
+ if (!GetLine( nBaseLine + i, maPreviewLine[i]))
+ break;
+ }
+ for (; i < CSV_PREVIEW_LINES; i++)
+ maPreviewLine[i].Erase();
+
+ maTableBox.Execute( CSVCMD_SETLINECOUNT, mnRowPosCount);
+ bool bMergeSep = (aCkbAsOnce.IsChecked() == TRUE);
+ maTableBox.SetUniStrings( maPreviewLine, maFieldSeparators, mcTextSep, bMergeSep);
+
+ return 0;
+}
+
+IMPL_LINK( ScImportAsciiDlg, ColTypeHdl, ScCsvTableBox*, pTableBox )
+{
+ DBG_ASSERT( pTableBox, "ScImportAsciiDlg::ColTypeHdl - missing sender" );
+
+ sal_Int32 nType = pTableBox->GetSelColumnType();
+ sal_Int32 nTypeCount = aLbType.GetEntryCount();
+ bool bEmpty = (nType == CSV_TYPE_MULTI);
+ bool bEnable = ((0 <= nType) && (nType < nTypeCount)) || bEmpty;
+
+ aFtType.Enable( bEnable );
+ aLbType.Enable( bEnable );
+
+ Link aSelHdl = aLbType.GetSelectHdl();
+ aLbType.SetSelectHdl( Link() );
+ if( bEmpty )
+ aLbType.SetNoSelection();
+ else if( bEnable )
+ aLbType.SelectEntryPos( static_cast< sal_uInt16 >( nType ) );
+ aLbType.SetSelectHdl( aSelHdl );
+
+ return 0;
+}
diff --git a/sc/source/ui/dbgui/scuiimoptdlg.cxx b/sc/source/ui/dbgui/scuiimoptdlg.cxx
new file mode 100644
index 000000000000..5440f515c86a
--- /dev/null
+++ b/sc/source/ui/dbgui/scuiimoptdlg.cxx
@@ -0,0 +1,316 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+#include "scuiimoptdlg.hxx"
+#include "scresid.hxx"
+#include "imoptdlg.hrc"
+#include <rtl/tencinfo.h>
+//========================================================================
+// ScDelimiterTable
+//========================================================================
+
+class ScDelimiterTable
+{
+public:
+ ScDelimiterTable( const String& rDelTab )
+ : theDelTab ( rDelTab ),
+ cSep ( '\t' ),
+ nCount ( rDelTab.GetTokenCount('\t') ),
+ nIter ( 0 )
+ {}
+
+ USHORT GetCode( const String& rDelimiter ) const;
+ String GetDelimiter( sal_Unicode nCode ) const;
+
+ String FirstDel() { nIter = 0; return theDelTab.GetToken( nIter, cSep ); }
+ String NextDel() { nIter +=2; return theDelTab.GetToken( nIter, cSep ); }
+
+private:
+ const String theDelTab;
+ const sal_Unicode cSep;
+ const xub_StrLen nCount;
+ xub_StrLen nIter;
+};
+
+//------------------------------------------------------------------------
+
+USHORT ScDelimiterTable::GetCode( const String& rDel ) const
+{
+ sal_Unicode nCode = 0;
+ xub_StrLen i = 0;
+
+ if ( nCount >= 2 )
+ {
+ while ( i<nCount )
+ {
+ if ( rDel == theDelTab.GetToken( i, cSep ) )
+ {
+ nCode = (sal_Unicode) theDelTab.GetToken( i+1, cSep ).ToInt32();
+ i = nCount;
+ }
+ else
+ i += 2;
+ }
+ }
+
+ return nCode;
+}
+
+//------------------------------------------------------------------------
+
+String ScDelimiterTable::GetDelimiter( sal_Unicode nCode ) const
+{
+ String aStrDel;
+ xub_StrLen i = 0;
+
+ if ( nCount >= 2 )
+ {
+ while ( i<nCount )
+ {
+ if ( nCode == (sal_Unicode) theDelTab.GetToken( i+1, cSep ).ToInt32() )
+ {
+ aStrDel = theDelTab.GetToken( i, cSep );
+ i = nCount;
+ }
+ else
+ i += 2;
+ }
+ }
+
+ return aStrDel;
+}
+
+//========================================================================
+// ScImportOptionsDlg
+//========================================================================
+
+ScImportOptionsDlg::ScImportOptionsDlg(
+ Window* pParent,
+ BOOL bAscii,
+ const ScImportOptions* pOptions,
+ const String* pStrTitle,
+ BOOL bMultiByte,
+ BOOL bOnlyDbtoolsEncodings,
+ BOOL bImport )
+
+ : ModalDialog ( pParent, ScResId( RID_SCDLG_IMPORTOPT ) ),
+ aFlFieldOpt ( this, ScResId( FL_FIELDOPT ) ),
+ aFtFont ( this, ScResId( FT_FONT ) ),
+ aLbFont ( this, ScResId( bAscii ? DDLB_FONT : LB_FONT ) ),
+ aFtFieldSep ( this, ScResId( FT_FIELDSEP ) ),
+ aEdFieldSep ( this, ScResId( ED_FIELDSEP ) ),
+ aFtTextSep ( this, ScResId( FT_TEXTSEP ) ),
+ aEdTextSep ( this, ScResId( ED_TEXTSEP ) ),
+ aCbFixed ( this, ScResId( CB_FIXEDWIDTH ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aCbShown ( this, ScResId( CB_SAVESHOWN ) )
+{
+ // im Ctor-Initializer nicht moeglich (MSC kann das nicht):
+ pFieldSepTab = new ScDelimiterTable( String(ScResId(SCSTR_FIELDSEP)) );
+ pTextSepTab = new ScDelimiterTable( String(ScResId(SCSTR_TEXTSEP)) );
+
+ String aStr = pFieldSepTab->FirstDel();
+ sal_Unicode nCode;
+
+ while ( aStr.Len() > 0 )
+ {
+ aEdFieldSep.InsertEntry( aStr );
+ aStr = pFieldSepTab->NextDel();
+ }
+
+ aStr = pTextSepTab->FirstDel();
+
+ while ( aStr.Len() > 0 )
+ {
+ aEdTextSep.InsertEntry( aStr );
+ aStr = pTextSepTab->NextDel();
+ }
+
+ aEdFieldSep.SetText( aEdFieldSep.GetEntry(0) );
+ aEdTextSep.SetText( aEdTextSep.GetEntry(0) );
+
+ if ( bOnlyDbtoolsEncodings )
+ {
+ // Even dBase export allows multibyte now
+ if ( bMultiByte )
+ aLbFont.FillFromDbTextEncodingMap( bImport );
+ else
+ aLbFont.FillFromDbTextEncodingMap( bImport, RTL_TEXTENCODING_INFO_MULTIBYTE );
+ }
+ else if ( !bAscii )
+ { //!TODO: Unicode would need work in each filter
+ if ( bMultiByte )
+ aLbFont.FillFromTextEncodingTable( bImport, RTL_TEXTENCODING_INFO_UNICODE );
+ else
+ aLbFont.FillFromTextEncodingTable( bImport, RTL_TEXTENCODING_INFO_UNICODE |
+ RTL_TEXTENCODING_INFO_MULTIBYTE );
+ }
+ else
+ {
+ if ( pOptions )
+ {
+ nCode = pOptions->nFieldSepCode;
+ aStr = pFieldSepTab->GetDelimiter( nCode );
+
+ if ( !aStr.Len() )
+ aEdFieldSep.SetText( String((sal_Unicode)nCode) );
+ else
+ aEdFieldSep.SetText( aStr );
+
+ nCode = pOptions->nTextSepCode;
+ aStr = pTextSepTab->GetDelimiter( nCode );
+
+ if ( !aStr.Len() )
+ aEdTextSep.SetText( String((sal_Unicode)nCode) );
+ else
+ aEdTextSep.SetText( aStr );
+ }
+ // all encodings allowed, even Unicode
+ aLbFont.FillFromTextEncodingTable( bImport );
+ }
+
+ if( bAscii )
+ {
+ Size aWinSize( GetSizePixel() );
+ aWinSize.Height() = aCbFixed.GetPosPixel().Y() + aCbFixed.GetSizePixel().Height();
+ Size aDiffSize( LogicToPixel( Size( 0, 6 ), MapMode( MAP_APPFONT ) ) );
+ aWinSize.Height() += aDiffSize.Height();
+ SetSizePixel( aWinSize );
+ aCbFixed.Show();
+ aCbFixed.SetClickHdl( LINK( this, ScImportOptionsDlg, FixedWidthHdl ) );
+ aCbFixed.Check( FALSE );
+ aCbShown.Show();
+ aCbShown.Check( TRUE );
+ }
+ else
+ {
+ aFlFieldOpt.SetText( aFtFont.GetText() );
+ aFtFieldSep.Hide();
+ aFtTextSep.Hide();
+ aFtFont.Hide();
+ aEdFieldSep.Hide();
+ aEdTextSep.Hide();
+ aCbFixed.Hide();
+ aCbShown.Hide();
+ aLbFont.GrabFocus();
+ aLbFont.SetDoubleClickHdl( LINK( this, ScImportOptionsDlg, DoubleClickHdl ) );
+ }
+
+ aLbFont.SelectTextEncoding( pOptions ? pOptions->eCharSet :
+ gsl_getSystemTextEncoding() );
+
+ // optionaler Titel:
+ if ( pStrTitle )
+ SetText( *pStrTitle );
+
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScImportOptionsDlg::~ScImportOptionsDlg()
+{
+ delete pFieldSepTab;
+ delete pTextSepTab;
+}
+
+//------------------------------------------------------------------------
+
+void ScImportOptionsDlg::GetImportOptions( ScImportOptions& rOptions ) const
+{
+ rOptions.SetTextEncoding( aLbFont.GetSelectTextEncoding() );
+
+ if ( aCbFixed.IsVisible() )
+ {
+ rOptions.nFieldSepCode = GetCodeFromCombo( aEdFieldSep );
+ rOptions.nTextSepCode = GetCodeFromCombo( aEdTextSep );
+ rOptions.bFixedWidth = aCbFixed.IsChecked();
+ rOptions.bSaveAsShown = aCbShown.IsChecked();
+ }
+}
+
+//------------------------------------------------------------------------
+
+USHORT ScImportOptionsDlg::GetCodeFromCombo( const ComboBox& rEd ) const
+{
+ ScDelimiterTable* pTab;
+ String aStr( rEd.GetText() );
+ USHORT nCode;
+
+ if ( &rEd == &aEdTextSep )
+ pTab = pTextSepTab;
+ else
+ pTab = pFieldSepTab;
+
+ if ( !aStr.Len() )
+ {
+ nCode = 0; // kein Trennzeichen
+ }
+ else
+ {
+ nCode = pTab->GetCode( aStr );
+
+ if ( nCode == 0 )
+ nCode = (USHORT)aStr.GetChar(0);
+ }
+
+ return nCode;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScImportOptionsDlg, FixedWidthHdl, CheckBox*, pCheckBox )
+{
+ if( pCheckBox == &aCbFixed )
+ {
+ BOOL bEnable = !aCbFixed.IsChecked();
+ aFtFieldSep.Enable( bEnable );
+ aEdFieldSep.Enable( bEnable );
+ aFtTextSep.Enable( bEnable );
+ aEdTextSep.Enable( bEnable );
+ aCbShown.Enable( bEnable );
+ }
+ return 0;
+}
+
+ IMPL_LINK( ScImportOptionsDlg, DoubleClickHdl, ListBox*, pLb )
+{
+ if ( pLb == &aLbFont )
+ {
+ aBtnOk.Click();
+ }
+ return 0;
+}
diff --git a/sc/source/ui/dbgui/sfiltdlg.cxx b/sc/source/ui/dbgui/sfiltdlg.cxx
new file mode 100644
index 000000000000..f70fbb094c92
--- /dev/null
+++ b/sc/source/ui/dbgui/sfiltdlg.cxx
@@ -0,0 +1,530 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+// INCLUDE -------------------------------------------------------------------
+#include <sfx2/dispatch.hxx>
+
+#include "uiitems.hxx"
+#include "rangenam.hxx"
+#include "dbcolect.hxx"
+#include "reffact.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "scresid.hxx"
+
+#include "foptmgr.hxx"
+
+#include "globstr.hrc"
+#include "filter.hrc"
+
+#define _SFILTDLG_CXX
+#include "filtdlg.hxx"
+#undef _SFILTDLG_CXX
+#include <vcl/msgbox.hxx>
+
+// DEFINE --------------------------------------------------------------------
+
+#define ERRORBOX(rid) ErrorBox( this, WinBits( WB_OK|WB_DEF_OK),\
+ ScGlobal::GetRscString(rid) ).Execute()
+
+
+//============================================================================
+// class ScSpecialFilterDialog
+
+//----------------------------------------------------------------------------
+
+ScSpecialFilterDlg::ScSpecialFilterDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ const SfxItemSet& rArgSet )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_SPEC_FILTER ),
+ //
+ aLbFilterArea ( this, ScResId( LB_CRITERIA_AREA ) ),
+ aFtFilterArea ( this, ScResId( FT_CRITERIA_AREA ) ),
+ aEdFilterArea ( this, this, ScResId( ED_CRITERIA_AREA ) ),
+ aRbFilterArea ( this, ScResId( RB_CRITERIA_AREA ), &aEdFilterArea, this ),
+ //
+ aFlOptions ( this, ScResId( FL_OPTIONS ) ),
+ _INIT_COMMON_FILTER_RSCOBJS
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnMore ( this, ScResId( BTN_MORE ) ),
+ //
+ pOptionsMgr ( NULL ),
+ nWhichQuery ( rArgSet.GetPool()->GetWhich( SID_QUERY ) ),
+ theQueryData ( ((const ScQueryItem&)
+ rArgSet.Get( nWhichQuery )).GetQueryData() ),
+ pOutItem ( NULL ),
+ pViewData ( NULL ),
+ pDoc ( NULL ),
+ pRefInputEdit ( NULL ),
+ bRefInputMode ( FALSE ),
+ pTimer ( NULL )
+{
+ Init( rArgSet );
+ aEdFilterArea.GrabFocus();
+
+ FreeResource();
+
+ // Hack: RefInput-Kontrolle
+ pTimer = new Timer;
+ pTimer->SetTimeout( 50 ); // 50ms warten
+ pTimer->SetTimeoutHdl( LINK( this, ScSpecialFilterDlg, TimeOutHdl ) );
+ pTimer->Start();
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScSpecialFilterDlg::~ScSpecialFilterDlg()
+{
+ USHORT nEntries = aLbFilterArea.GetEntryCount();
+ USHORT i;
+
+ for ( i=1; i<nEntries; i++ )
+ delete (String*)aLbFilterArea.GetEntryData( i );
+
+ delete pOptionsMgr;
+
+ if ( pOutItem )
+ delete pOutItem;
+
+ // Hack: RefInput-Kontrolle
+ pTimer->Stop();
+ delete pTimer;
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScSpecialFilterDlg::Init( const SfxItemSet& rArgSet )
+{
+ const ScQueryItem& rQueryItem = (const ScQueryItem&)
+ rArgSet.Get( nWhichQuery );
+
+ aBtnOk.SetClickHdl ( LINK( this, ScSpecialFilterDlg, EndDlgHdl ) );
+ aBtnCancel.SetClickHdl ( LINK( this, ScSpecialFilterDlg, EndDlgHdl ) );
+ aLbFilterArea.SetSelectHdl ( LINK( this, ScSpecialFilterDlg, FilterAreaSelHdl ) );
+ aEdFilterArea.SetModifyHdl ( LINK( this, ScSpecialFilterDlg, FilterAreaModHdl ) );
+
+ pViewData = rQueryItem.GetViewData();
+ pDoc = pViewData ? pViewData->GetDocument() : NULL;
+
+ aEdFilterArea.SetText( EMPTY_STRING ); // may be overwritten below
+
+ if ( pViewData && pDoc )
+ {
+ if(pDoc->GetChangeTrack()!=NULL) aBtnCopyResult.Disable();
+
+ ScRangeName* pRangeNames = pDoc->GetRangeName();
+ const USHORT nCount = pRangeNames ? pRangeNames->GetCount() : 0;
+
+ /*
+ * Aus den RangeNames des Dokumentes werden nun die
+ * gemerkt, bei denen es sich um Filter-Bereiche handelt
+ */
+
+ aLbFilterArea.Clear();
+ aLbFilterArea.InsertEntry( aStrUndefined, 0 );
+
+ if ( nCount > 0 )
+ {
+ String aString;
+ ScRangeData* pData = NULL;
+ USHORT nInsert = 0;
+
+ for ( USHORT i=0; i<nCount; i++ )
+ {
+ pData = (ScRangeData*)(pRangeNames->At( i ));
+ if ( pData )
+ {
+ if ( pData->HasType( RT_CRITERIA ) )
+ {
+ pData->GetName( aString );
+ nInsert = aLbFilterArea.InsertEntry( aString );
+ pData->GetSymbol( aString );
+ aLbFilterArea.SetEntryData( nInsert,
+ new String( aString ) );
+ }
+ }
+ }
+ }
+
+ // is there a stored source range?
+
+ ScRange aAdvSource;
+ if (rQueryItem.GetAdvancedQuerySource(aAdvSource))
+ {
+ String aRefStr;
+ aAdvSource.Format( aRefStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+ aEdFilterArea.SetRefString( aRefStr );
+ }
+ }
+
+ aLbFilterArea.SelectEntryPos( 0 );
+
+ // Optionen initialisieren lassen:
+
+ pOptionsMgr = new ScFilterOptionsMgr(
+ this,
+ pViewData,
+ theQueryData,
+ aBtnMore,
+ aBtnCase,
+ aBtnRegExp,
+ aBtnHeader,
+ aBtnUnique,
+ aBtnCopyResult,
+ aBtnDestPers,
+ aLbCopyArea,
+ aEdCopyArea,
+ aRbCopyArea,
+ aFtDbAreaLabel,
+ aFtDbArea,
+ aFlOptions,
+ aStrNoName,
+ aStrUndefined );
+
+ // #35206# Spezialfilter braucht immer Spaltenkoepfe
+ aBtnHeader.Check(TRUE);
+ aBtnHeader.Disable();
+
+ // Modal-Modus einschalten
+// SetDispatcherLock( TRUE );
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScSpecialFilterDlg::Close()
+{
+ if (pViewData)
+ pViewData->GetDocShell()->CancelAutoDBRange();
+
+ return DoClose( ScSpecialFilterDlgWrapper::GetChildWindowId() );
+}
+
+
+//----------------------------------------------------------------------------
+// Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
+// neue Selektion im Referenz-Edit angezeigt wird.
+
+void ScSpecialFilterDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( bRefInputMode && pRefInputEdit ) // Nur moeglich, wenn im Referenz-Editmodus
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart( pRefInputEdit );
+
+ String aRefStr;
+ const formula::FormulaGrammar::AddressConvention eConv = pDocP->GetAddressConvention();
+
+ if ( pRefInputEdit == &aEdCopyArea)
+ rRef.aStart.Format( aRefStr, SCA_ABS_3D, pDocP, eConv );
+ else if ( pRefInputEdit == &aEdFilterArea)
+ rRef.Format( aRefStr, SCR_ABS_3D, pDocP, eConv );
+
+ pRefInputEdit->SetRefString( aRefStr );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScSpecialFilterDlg::SetActive()
+{
+ if ( bRefInputMode )
+ {
+ if ( pRefInputEdit == &aEdCopyArea )
+ {
+ aEdCopyArea.GrabFocus();
+ if ( aEdCopyArea.GetModifyHdl().IsSet() )
+ ((Link&)aEdCopyArea.GetModifyHdl()).Call( &aEdCopyArea );
+ }
+ else if ( pRefInputEdit == &aEdFilterArea )
+ {
+ aEdFilterArea.GrabFocus();
+ FilterAreaModHdl( &aEdFilterArea );
+ }
+ }
+ else
+ GrabFocus();
+
+ RefInputDone();
+}
+
+
+//----------------------------------------------------------------------------
+
+ScQueryItem* ScSpecialFilterDlg::GetOutputItem( const ScQueryParam& rParam,
+ const ScRange& rSource )
+{
+ if ( pOutItem ) DELETEZ( pOutItem );
+ pOutItem = new ScQueryItem( nWhichQuery, &rParam );
+ pOutItem->SetAdvancedQuerySource( &rSource );
+
+ return pOutItem;
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScSpecialFilterDlg::IsRefInputMode() const
+{
+ return bRefInputMode;
+}
+
+
+//----------------------------------------------------------------------------
+// Handler:
+// ========
+
+IMPL_LINK( ScSpecialFilterDlg, EndDlgHdl, Button*, pBtn )
+{
+ DBG_ASSERT( pDoc && pViewData, "Document or ViewData not found. :-/" );
+
+ if ( (pBtn == &aBtnOk) && pDoc && pViewData )
+ {
+ String theCopyStr( aEdCopyArea.GetText() );
+ String theAreaStr( aEdFilterArea.GetText() );
+ ScQueryParam theOutParam( theQueryData );
+ ScAddress theAdrCopy;
+ BOOL bEditInputOk = TRUE;
+ BOOL bQueryOk = FALSE;
+ ScRange theFilterArea;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+
+ if ( aBtnCopyResult.IsChecked() )
+ {
+ xub_StrLen nColonPos = theCopyStr.Search( ':' );
+
+ if ( STRING_NOTFOUND != nColonPos )
+ theCopyStr.Erase( nColonPos );
+
+ USHORT nResult = theAdrCopy.Parse( theCopyStr, pDoc, eConv );
+
+ if ( SCA_VALID != (nResult & SCA_VALID) )
+ {
+ if ( !aBtnMore.GetState() )
+ aBtnMore.SetState( TRUE );
+
+ ERRORBOX( STR_INVALID_TABREF );
+ aEdCopyArea.GrabFocus();
+ bEditInputOk = FALSE;
+ }
+ }
+
+ if ( bEditInputOk )
+ {
+ USHORT nResult = ScRange().Parse( theAreaStr, pDoc, eConv );
+
+ if ( SCA_VALID != (nResult & SCA_VALID) )
+ {
+ ERRORBOX( STR_INVALID_TABREF );
+ aEdFilterArea.GrabFocus();
+ bEditInputOk = FALSE;
+ }
+ }
+
+ if ( bEditInputOk )
+ {
+ /*
+ * Alle Edit-Felder enthalten gueltige Bereiche.
+ * Nun wird versucht aus dem Filterbereich
+ * ein ScQueryParam zu erzeugen:
+ */
+
+ USHORT nResult = theFilterArea.Parse( theAreaStr, pDoc, eConv );
+
+ if ( SCA_VALID == (nResult & SCA_VALID) )
+ {
+ ScAddress& rStart = theFilterArea.aStart;
+ ScAddress& rEnd = theFilterArea.aEnd;
+
+ if ( aBtnCopyResult.IsChecked() )
+ {
+ theOutParam.bInplace = FALSE;
+ theOutParam.nDestTab = theAdrCopy.Tab();
+ theOutParam.nDestCol = theAdrCopy.Col();
+ theOutParam.nDestRow = theAdrCopy.Row();
+ }
+ else
+ {
+ theOutParam.bInplace = TRUE;
+ theOutParam.nDestTab = 0;
+ theOutParam.nDestCol = 0;
+ theOutParam.nDestRow = 0;
+ }
+
+ theOutParam.bHasHeader = aBtnHeader.IsChecked();
+ theOutParam.bByRow = TRUE;
+ theOutParam.bCaseSens = aBtnCase.IsChecked();
+ theOutParam.bRegExp = aBtnRegExp.IsChecked();
+ theOutParam.bDuplicate = !aBtnUnique.IsChecked();
+ theOutParam.bDestPers = aBtnDestPers.IsChecked();
+
+ bQueryOk =
+ pDoc->CreateQueryParam( rStart.Col(),
+ rStart.Row(),
+ rEnd.Col(),
+ rEnd.Row(),
+ rStart.Tab(),
+ theOutParam );
+
+ // an der DB-Collection koennen nur MAXQUERY Filter-Eintraege
+ // gespeichert werden
+
+ if ( bQueryOk && theOutParam.GetEntryCount() > MAXQUERY &&
+ theOutParam.GetEntry(MAXQUERY).bDoQuery )
+ {
+ bQueryOk = FALSE; // zu viele
+ //! andere Fehlermeldung ??
+ }
+ }
+ }
+
+ if ( bQueryOk )
+ {
+ SetDispatcherLock( FALSE );
+ SwitchToDocument();
+ GetBindings().GetDispatcher()->Execute( FID_FILTER_OK,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ GetOutputItem( theOutParam, theFilterArea ), 0L, 0L );
+ Close();
+ }
+ else
+ {
+ ERRORBOX( STR_INVALID_QUERYAREA );
+ aEdFilterArea.GrabFocus();
+ }
+ }
+ else if ( pBtn == &aBtnCancel )
+ {
+ Close();
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScSpecialFilterDlg, TimeOutHdl, Timer*, _pTimer )
+{
+ // alle 50ms nachschauen, ob RefInputMode noch stimmt
+
+ if( (_pTimer == pTimer) && IsActive() )
+ {
+ if( aEdCopyArea.HasFocus() || aRbCopyArea.HasFocus() )
+ {
+ pRefInputEdit = &aEdCopyArea;
+ bRefInputMode = TRUE;
+ }
+ else if( aEdFilterArea.HasFocus() || aRbFilterArea.HasFocus() )
+ {
+ pRefInputEdit = &aEdFilterArea;
+ bRefInputMode = TRUE;
+ }
+ else if( bRefInputMode )
+ {
+ pRefInputEdit = NULL;
+ bRefInputMode = FALSE;
+ }
+ }
+
+ pTimer->Start();
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScSpecialFilterDlg, FilterAreaSelHdl, ListBox*, pLb )
+{
+ if ( pLb == &aLbFilterArea )
+ {
+ String aString;
+ USHORT nSelPos = aLbFilterArea.GetSelectEntryPos();
+
+ if ( nSelPos > 0 )
+ aString = *(String*)aLbFilterArea.GetEntryData( nSelPos );
+
+ aEdFilterArea.SetText( aString );
+ }
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScSpecialFilterDlg, FilterAreaModHdl, formula::RefEdit*, pEd )
+{
+ if ( pEd == &aEdFilterArea )
+ {
+ if ( pDoc && pViewData )
+ {
+ String theCurAreaStr = pEd->GetText();
+ USHORT nResult = ScRange().Parse( theCurAreaStr, pDoc );
+
+ if ( SCA_VALID == (nResult & SCA_VALID) )
+ {
+ String* pStr = NULL;
+ BOOL bFound = FALSE;
+ USHORT i = 0;
+ USHORT nCount = aLbFilterArea.GetEntryCount();
+
+ for ( i=1; i<nCount && !bFound; i++ )
+ {
+ pStr = (String*)aLbFilterArea.GetEntryData( i );
+ bFound = (theCurAreaStr == *pStr);
+ }
+
+ if ( bFound )
+ aLbFilterArea.SelectEntryPos( --i );
+ else
+ aLbFilterArea.SelectEntryPos( 0 );
+ }
+ }
+ else
+ aLbFilterArea.SelectEntryPos( 0 );
+ }
+
+ return 0;
+}
+
+
diff --git a/sc/source/ui/dbgui/sortdlg.cxx b/sc/source/ui/dbgui/sortdlg.cxx
new file mode 100644
index 000000000000..f2a733af3aa8
--- /dev/null
+++ b/sc/source/ui/dbgui/sortdlg.cxx
@@ -0,0 +1,107 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+#include <vcl/msgbox.hxx>
+#include "tpsort.hxx"
+#include "sortdlg.hxx"
+#include "scresid.hxx"
+#include "sortdlg.hrc"
+
+#if !LAYOUT_SFX_TABDIALOG_BROKEN
+#include <layout/layout-pre.hxx>
+#endif
+
+ScSortDlg::ScSortDlg( Window* pParent,
+ const SfxItemSet* pArgSet ) :
+ SfxTabDialog( pParent,
+ ScResId( RID_SCDLG_SORT ),
+ pArgSet ),
+ bIsHeaders ( FALSE ),
+ bIsByRows ( FALSE )
+
+{
+#if LAYOUT_SFX_TABDIALOG_BROKEN
+ AddTabPage( TP_FIELDS, ScTabPageSortFields::Create, 0 );
+ AddTabPage( TP_OPTIONS, ScTabPageSortOptions::Create, 0 );
+#else
+ String fields = rtl::OUString::createFromAscii ("fields");
+ AddTabPage( TP_FIELDS, fields, ScTabPageSortFields::Create, 0, FALSE, TAB_APPEND);
+ String options = rtl::OUString::createFromAscii ("options");
+ AddTabPage( TP_OPTIONS, options, ScTabPageSortOptions::Create, 0, FALSE, TAB_APPEND);
+#endif
+ FreeResource();
+}
+
+__EXPORT ScSortDlg::~ScSortDlg()
+{
+}
+
+//==================================================================
+ScSortWarningDlg::ScSortWarningDlg( Window* pParent,
+ const String& rExtendText,
+ const String& rCurrentText ):
+ ModalDialog ( pParent, ScResId( RID_SCDLG_SORT_WARNING ) ),
+ aFtText ( this, ScResId( FT_TEXT ) ),
+ aFtTip ( this, ScResId( FT_TIP ) ),
+ aBtnExtSort ( this, ScResId( BTN_EXTSORT ) ),
+ aBtnCurSort ( this, ScResId( BTN_CURSORT ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) )
+{
+ String sTextName = aFtText.GetText();
+ sTextName.SearchAndReplaceAscii("%1", rExtendText);
+ sTextName.SearchAndReplaceAscii("%2", rCurrentText);
+ aFtText.SetText( sTextName );
+
+ aBtnExtSort .SetClickHdl( LINK( this, ScSortWarningDlg, BtnHdl ) );
+ aBtnCurSort .SetClickHdl( LINK( this, ScSortWarningDlg, BtnHdl ) );
+
+ FreeResource();
+}
+
+ScSortWarningDlg::~ScSortWarningDlg()
+{
+}
+
+IMPL_LINK( ScSortWarningDlg, BtnHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &aBtnExtSort )
+ {
+ EndDialog( BTN_EXTEND_RANGE );
+ }
+ else if( pBtn == &aBtnCurSort )
+ {
+ EndDialog( BTN_CURRENT_SELECTION );
+ }
+ return 0;
+}
+//========================================================================//
diff --git a/sc/source/ui/dbgui/subtdlg.cxx b/sc/source/ui/dbgui/subtdlg.cxx
new file mode 100644
index 000000000000..2c9cba31cd13
--- /dev/null
+++ b/sc/source/ui/dbgui/subtdlg.cxx
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+#include "tpsubt.hxx"
+#include "scresid.hxx"
+#include "subtdlg.hxx"
+#include "subtdlg.hrc"
+
+
+//==================================================================
+
+ScSubTotalDlg::ScSubTotalDlg( Window* pParent,
+ const SfxItemSet* pArgSet ) :
+ SfxTabDialog( pParent,
+ ScResId( RID_SCDLG_SUBTOTALS ),
+ pArgSet ),
+ aBtnRemove ( this, ScResId( BTN_REMOVE ) )
+{
+ AddTabPage( PAGE_GROUP1, ScTpSubTotalGroup1::Create, 0 );
+ AddTabPage( PAGE_GROUP2, ScTpSubTotalGroup2::Create, 0 );
+ AddTabPage( PAGE_GROUP3, ScTpSubTotalGroup3::Create, 0 );
+ AddTabPage( PAGE_OPTIONS, ScTpSubTotalOptions::Create, 0 );
+ aBtnRemove.SetClickHdl( LINK( this, ScSubTotalDlg, RemoveHdl ) );
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScSubTotalDlg, RemoveHdl, PushButton *, pBtn )
+{
+ if ( pBtn == &aBtnRemove )
+ {
+ EndDialog( SCRET_REMOVE );
+ }
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScSubTotalDlg, RemoveHdl, PushButton *, pBtn )
+
diff --git a/sc/source/ui/dbgui/textimportoptions.cxx b/sc/source/ui/dbgui/textimportoptions.cxx
new file mode 100644
index 000000000000..be918d2a0fbd
--- /dev/null
+++ b/sc/source/ui/dbgui/textimportoptions.cxx
@@ -0,0 +1,121 @@
+/*************************************************************************
+ *
+ * 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: langbox.hxx,v $
+ * $Revision: 1.4.242.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+//------------------------------------------------------------------------
+
+#include "textimportoptions.hxx"
+#include "textimportoptions.hrc"
+
+#include "scresid.hxx"
+#include "vcl/window.hxx"
+#include "vcl/msgbox.hxx"
+#include "vcl/svapp.hxx"
+
+ScTextImportOptionsDlg::ScTextImportOptionsDlg(Window* pParent) :
+ ModalDialog(pParent, ScResId(RID_SCDLG_TEXT_IMPORT_OPTIONS)),
+
+ maBtnOk(this, ScResId(BTN_OK)),
+ maBtnCancel(this, ScResId(BTN_CANCEL)),
+ maBtnHelp(this, ScResId(BTN_HELP)),
+ maFlChooseLang(this, ScResId(FL_CHOOSE_LANG)),
+ maRbAutomatic(this, ScResId(RB_AUTOMATIC)),
+ maRbCustom(this, ScResId(RB_CUSTOM)),
+ maLbCustomLang(this, ScResId(LB_CUSTOM_LANG)),
+ maFlOption(this, ScResId(FL_OPTION)),
+ maBtnConvertDate(this, ScResId(BTN_CONVERT_DATE))
+{
+ FreeResource();
+ init();
+}
+
+ScTextImportOptionsDlg::~ScTextImportOptionsDlg()
+{
+}
+
+short ScTextImportOptionsDlg::Execute()
+{
+ return ModalDialog::Execute();
+}
+
+LanguageType ScTextImportOptionsDlg::getLanguageType() const
+{
+ if (maRbAutomatic.IsChecked())
+ return LANGUAGE_SYSTEM;
+
+ return maLbCustomLang.GetSelectLanguage();
+}
+
+bool ScTextImportOptionsDlg::isDateConversionSet() const
+{
+ return maBtnConvertDate.IsChecked();
+}
+
+void ScTextImportOptionsDlg::init()
+{
+ Link aLink = LINK( this, ScTextImportOptionsDlg, OKHdl );
+ maBtnOk.SetClickHdl(aLink);
+ aLink = LINK( this, ScTextImportOptionsDlg, RadioHdl );
+ maRbAutomatic.SetClickHdl(aLink);
+ maRbCustom.SetClickHdl(aLink);
+
+ maRbAutomatic.Check(true);
+
+ maLbCustomLang.SetLanguageList(
+ LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, false, false);
+
+ LanguageType eLang = Application::GetSettings().GetLanguage();
+ maLbCustomLang.SelectLanguage(eLang);
+ maLbCustomLang.Disable();
+}
+
+IMPL_LINK( ScTextImportOptionsDlg, OKHdl, OKButton*, EMPTYARG )
+{
+ EndDialog(RET_OK);
+ return 0;
+}
+
+IMPL_LINK( ScTextImportOptionsDlg, RadioHdl, RadioButton*, pBtn )
+{
+ if (pBtn == &maRbAutomatic)
+ {
+ maLbCustomLang.Disable();
+ }
+ else if (pBtn == &maRbCustom)
+ {
+ maLbCustomLang.Enable();
+ }
+ return 0;
+}
+
diff --git a/sc/source/ui/dbgui/textimportoptions.src b/sc/source/ui/dbgui/textimportoptions.src
new file mode 100644
index 000000000000..7305986b3bec
--- /dev/null
+++ b/sc/source/ui/dbgui/textimportoptions.src
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * 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: retypepassdlg.src,v $
+ * $Revision: 1.1.2.3 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "textimportoptions.hrc"
+
+ModalDialog RID_SCDLG_TEXT_IMPORT_OPTIONS
+{
+ HelpID = "sc:ModalDialog:RID_SCDLG_TEXT_IMPORT_OPTIONS";
+ Text [ en-US ] = "Import Options" ;
+ Size = MAP_APPFONT ( 230 , 101 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ OutputSize = TRUE ;
+
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 175, 6 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ DefButton = TRUE ;
+ };
+
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 175, 23 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ };
+
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 175, 43 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ };
+
+ FixedLine FL_CHOOSE_LANG
+ {
+ Pos = MAP_APPFONT( 6, 3 ) ;
+ Size = MAP_APPFONT( 165, 14 ) ;
+
+ Text [ en-US ] = "Select the language to use for import" ;
+ };
+
+ RadioButton RB_AUTOMATIC
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_TEXT_IMPORT_OPTIONS:RB_AUTOMATIC";
+ Pos = MAP_APPFONT( 12, 20 ) ;
+ Size = MAP_APPFONT( 159, 10 ) ;
+ TabStop = TRUE ;
+
+ Text [ en-US ] = "Automatic" ;
+ };
+
+ RadioButton RB_CUSTOM
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_TEXT_IMPORT_OPTIONS:RB_CUSTOM";
+ Pos = MAP_APPFONT( 12, 34 ) ;
+ Size = MAP_APPFONT( 159, 10 ) ;
+ TabStop = TRUE ;
+
+ Text [ en-US ] = "Custom" ;
+ };
+
+ ListBox LB_CUSTOM_LANG
+ {
+ HelpID = "sc:ListBox:RID_SCDLG_TEXT_IMPORT_OPTIONS:LB_CUSTOM_LANG";
+ Pos = MAP_APPFONT( 20, 50 ) ;
+ Size = MAP_APPFONT( 140, 120 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ Sort = TRUE ;
+ };
+
+ FixedLine FL_OPTION
+ {
+ Pos = MAP_APPFONT( 6, 70 );
+ Size = MAP_APPFONT( 165, 14 );
+ Text [ en-US ] = "Options" ;
+ };
+
+ CheckBox BTN_CONVERT_DATE
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_TEXT_IMPORT_OPTIONS:BTN_CONVERT_DATE";
+ Pos = MAP_APPFONT( 12, 86 );
+ Size = MAP_APPFONT( 159, 10 );
+ TabStop = TRUE ;
+ Text [ en-US ] = "Detect special numbers (such as dates)." ;
+ };
+};
+
diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx
new file mode 100644
index 000000000000..18c1eb25664a
--- /dev/null
+++ b/sc/source/ui/dbgui/tpsort.cxx
@@ -0,0 +1,1080 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+#include <vcl/msgbox.hxx>
+#include <i18npool/mslangid.hxx>
+#include <svtools/collatorres.hxx>
+#include <unotools/collatorwrapper.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include "scitems.hxx"
+#include "uiitems.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "global.hxx"
+#include "dbcolect.hxx"
+#include "userlist.hxx"
+#include "rangeutl.hxx"
+#include "scresid.hxx"
+#include "sc.hrc" // -> Slot IDs
+#include "globstr.hrc"
+
+#include "sortdlg.hxx"
+#include "sortdlg.hrc"
+
+#define _TPSORT_CXX
+#include "tpsort.hxx"
+#undef _TPSORT_CXX
+
+using namespace com::sun::star;
+
+// STATIC DATA -----------------------------------------------------------
+
+static USHORT pSortRanges[] =
+{
+ SID_SORT,
+ SID_SORT,
+ 0
+};
+
+// -----------------------------------------------------------------------
+
+/*
+ * Da sich Einstellungen auf der zweiten TabPage (Optionen) auf
+ * die erste TabPage auswirken, muss es die Moeglichkeit geben,
+ * dies der jeweils anderen Seite mitzuteilen.
+ *
+ * Im Moment wird dieses Problem ueber zwei Datenmember des TabDialoges
+ * geloest. Wird eine Seite Aktiviert/Deaktiviert, so gleicht sie diese
+ * Datenmember mit dem eigenen Zustand ab (->Activate()/Deactivate()).
+ *
+ * 31.01.95:
+ * Die Klasse SfxTabPage bietet mittlerweile ein Verfahren an:
+ *
+ * virtual BOOL HasExchangeSupport() const; -> return TRUE;
+ * virtual void ActivatePage(const SfxItemSet &);
+ * virtual int DeactivatePage(SfxItemSet * = 0);
+ *
+ * muss noch geaendert werden!
+ */
+
+//========================================================================
+//========================================================================
+// Sortierkriterien-Tabpage:
+
+ScTabPageSortFields::ScTabPageSortFields( Window* pParent,
+ const SfxItemSet& rArgSet )
+
+ : SfxTabPage ( pParent,
+ ScResId( RID_SCPAGE_SORT_FIELDS ),
+ rArgSet ),
+ //
+ aFlSort1 ( this, ScResId( FL_SORT1 ) ),
+ aLbSort1 ( this, ScResId( LB_SORT1 ) ),
+ aBtnUp1 ( this, ScResId( BTN_UP1 ) ),
+ aBtnDown1 ( this, ScResId( BTN_DOWN1 ) ),
+ //
+ aFlSort2 ( this, ScResId( FL_SORT2 ) ),
+ aLbSort2 ( this, ScResId( LB_SORT2 ) ),
+ aBtnUp2 ( this, ScResId( BTN_UP2 ) ),
+ aBtnDown2 ( this, ScResId( BTN_DOWN2 ) ),
+ //
+ aFlSort3 ( this, ScResId( FL_SORT3 ) ),
+ aLbSort3 ( this, ScResId( LB_SORT3 ) ),
+ aBtnUp3 ( this, ScResId( BTN_UP3 ) ),
+ aBtnDown3 ( this, ScResId( BTN_DOWN3 ) ),
+
+ aStrUndefined ( ScResId( SCSTR_UNDEFINED ) ),
+ aStrColumn ( ScResId( SCSTR_COLUMN ) ),
+ aStrRow ( ScResId( SCSTR_ROW ) ),
+ //
+ nWhichSort ( rArgSet.GetPool()->GetWhich( SID_SORT ) ),
+ pDlg ( (ScSortDlg*)(GetParent()->GetParent()) ),
+ pViewData ( NULL ),
+ rSortData ( ((const ScSortItem&)
+ rArgSet.Get( nWhichSort )).
+ GetSortData() ),
+ nFieldCount ( 0 ),
+ bHasHeader ( FALSE ),
+ bSortByRows ( FALSE )
+{
+ Init();
+ FreeResource();
+ SetExchangeSupport();
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT ScTabPageSortFields::~ScTabPageSortFields()
+{
+}
+
+// -----------------------------------------------------------------------
+
+void ScTabPageSortFields::Init()
+{
+ const ScSortItem& rSortItem = (const ScSortItem&)
+ GetItemSet().Get( nWhichSort );
+
+ pViewData = rSortItem.GetViewData();
+
+ DBG_ASSERT( pViewData, "ViewData not found!" );
+
+ nFieldArr[0] = 0;
+ nFirstCol = 0;
+ nFirstRow = 0;
+
+ aLbSort1.SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) );
+ aLbSort2.SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) );
+ aLbSort3.SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) );
+ aLbSort1.Clear();
+ aLbSort2.Clear();
+ aLbSort3.Clear();
+
+ aSortLbArr[0] = &aLbSort1;
+ aSortLbArr[1] = &aLbSort2;
+ aSortLbArr[2] = &aLbSort3;
+ aDirBtnArr[0][0] = &aBtnUp1;
+ aDirBtnArr[0][1] = &aBtnDown1;
+ aDirBtnArr[1][0] = &aBtnUp2;
+ aDirBtnArr[1][1] = &aBtnDown2;
+ aDirBtnArr[2][0] = &aBtnUp3;
+ aDirBtnArr[2][1] = &aBtnDown3;
+ aFlArr[0] = &aFlSort1;
+ aFlArr[1] = &aFlSort2;
+ aFlArr[2] = &aFlSort3;
+}
+
+//------------------------------------------------------------------------
+
+USHORT* __EXPORT ScTabPageSortFields::GetRanges()
+{
+ return pSortRanges;
+}
+
+// -----------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScTabPageSortFields::Create( Window* pParent,
+ const SfxItemSet& rArgSet )
+{
+ return ( new ScTabPageSortFields( pParent, rArgSet ) );
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScTabPageSortFields::Reset( const SfxItemSet& /* rArgSet */ )
+{
+ bSortByRows = rSortData.bByRow;
+ bHasHeader = rSortData.bHasHeader;
+
+ if ( aLbSort1.GetEntryCount() == 0 )
+ FillFieldLists();
+
+ // Selektieren der ListBoxen:
+
+ if ( rSortData.bDoSort[0] )
+ {
+ for ( USHORT i=0; i<3; i++ )
+ {
+ if ( rSortData.bDoSort[i] )
+ {
+ aSortLbArr[i]->SelectEntryPos(
+ GetFieldSelPos( rSortData.nField[i] ) );
+
+ (rSortData.bAscending[i])
+ ? aDirBtnArr[i][0]->Check() // Up
+ : aDirBtnArr[i][1]->Check(); // Down
+ }
+ else
+ {
+ aSortLbArr[i]->SelectEntryPos( 0 ); // "keiner" selektieren
+ aDirBtnArr[i][0]->Check(); // Up
+ }
+ }
+
+ EnableField( 1 );
+ EnableField( 2 );
+ EnableField( 3 );
+ if ( aLbSort1.GetSelectEntryPos() == 0 )
+ DisableField( 2 );
+ if ( aLbSort2.GetSelectEntryPos() == 0 )
+ DisableField( 3 );
+ }
+ else
+ {
+ SCCOL nCol = pViewData->GetCurX();
+
+ if( nCol < rSortData.nCol1 )
+ nCol = rSortData.nCol1;
+ else if( nCol > rSortData.nCol2 )
+ nCol = rSortData.nCol2;
+
+ USHORT nSort1Pos = nCol - rSortData.nCol1+1;
+ aLbSort1.SelectEntryPos( nSort1Pos );
+ aLbSort2.SelectEntryPos( 0 );
+ aLbSort3.SelectEntryPos( 0 );
+ aBtnUp1.Check();
+ aBtnUp2.Check();
+ aBtnUp3.Check();
+ EnableField ( 1 );
+ EnableField ( 2 );
+ DisableField( 3 );
+ }
+
+ if ( pDlg )
+ {
+ pDlg->SetByRows ( bSortByRows );
+ pDlg->SetHeaders( bHasHeader );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+BOOL __EXPORT ScTabPageSortFields::FillItemSet( SfxItemSet& rArgSet )
+{
+ ScSortParam theSortData = rSortData;
+ if (pDlg)
+ {
+ const SfxItemSet* pExample = pDlg->GetExampleSet();
+ const SfxPoolItem* pItem;
+ if ( pExample && pExample->GetItemState( nWhichSort, TRUE, &pItem ) == SFX_ITEM_SET )
+ theSortData = ((const ScSortItem*)pItem)->GetSortData();
+ }
+
+ USHORT nSort1Pos = aLbSort1.GetSelectEntryPos();
+ USHORT nSort2Pos = aLbSort2.GetSelectEntryPos();
+ USHORT nSort3Pos = aLbSort3.GetSelectEntryPos();
+
+ DBG_ASSERT( (nSort1Pos <= SC_MAXFIELDS)
+ && (nSort2Pos <= SC_MAXFIELDS)
+ && (nSort3Pos <= SC_MAXFIELDS),
+ "Array-Range Fehler!" );
+
+ if ( nSort1Pos == LISTBOX_ENTRY_NOTFOUND ) nSort1Pos = 0;
+ if ( nSort2Pos == LISTBOX_ENTRY_NOTFOUND ) nSort2Pos = 0;
+ if ( nSort3Pos == LISTBOX_ENTRY_NOTFOUND ) nSort3Pos = 0;
+
+ if ( nSort1Pos > 0 )
+ {
+ theSortData.bDoSort[0] = (nSort1Pos > 0);
+ theSortData.bDoSort[1] = (nSort2Pos > 0);
+ theSortData.bDoSort[2] = (nSort3Pos > 0);
+
+ // wenn auf Optionen-Seite "OK" gewaehlt wurde und
+ // dabei die Sortierrichtung umgestellt wurde, so
+ // wird das erste Feld der jeweiligen Richtung als
+ // Sortierkriterium gewaehlt (steht in nFieldArr[0]):
+ if ( bSortByRows != pDlg->GetByRows() )
+ {
+ theSortData.nField[0] =
+ theSortData.nField[1] =
+ theSortData.nField[2] = ( bSortByRows ?
+ static_cast<SCCOLROW>(nFirstRow) :
+ static_cast<SCCOLROW>(nFirstCol) );
+ }
+ else
+ {
+ theSortData.nField[0] = nFieldArr[nSort1Pos];
+ theSortData.nField[1] = nFieldArr[nSort2Pos];
+ theSortData.nField[2] = nFieldArr[nSort3Pos];
+ }
+
+ theSortData.bAscending[0] = aBtnUp1.IsChecked();
+ theSortData.bAscending[1] = aBtnUp2.IsChecked();
+ theSortData.bAscending[2] = aBtnUp3.IsChecked();
+ // bHasHeader ist in ScTabPageSortOptions::FillItemSet, wo es hingehoert
+ }
+ else
+ {
+ theSortData.bDoSort[0] =
+ theSortData.bDoSort[1] =
+ theSortData.bDoSort[2] = FALSE;
+ }
+
+ rArgSet.Put( ScSortItem( SCITEM_SORTDATA, NULL, &theSortData ) );
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+// fuer Datenaustausch ohne Dialog-Umweg: (! noch zu tun !)
+// void ScTabPageSortFields::ActivatePage( const SfxItemSet& rSet )
+
+void __EXPORT ScTabPageSortFields::ActivatePage()
+{
+ if ( pDlg )
+ {
+ if ( bHasHeader != pDlg->GetHeaders()
+ || bSortByRows != pDlg->GetByRows() )
+ {
+ USHORT nCurSel1 = aLbSort1.GetSelectEntryPos();
+ USHORT nCurSel2 = aLbSort2.GetSelectEntryPos();
+ USHORT nCurSel3 = aLbSort3.GetSelectEntryPos();
+
+ bHasHeader = pDlg->GetHeaders();
+ bSortByRows = pDlg->GetByRows();
+ FillFieldLists();
+ aLbSort1.SelectEntryPos( nCurSel1 );
+ aLbSort2.SelectEntryPos( nCurSel2 );
+ aLbSort3.SelectEntryPos( nCurSel3 );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+int __EXPORT ScTabPageSortFields::DeactivatePage( SfxItemSet* pSetP )
+{
+ if ( pDlg )
+ {
+ if ( bHasHeader != pDlg->GetHeaders() )
+ pDlg->SetHeaders( bHasHeader );
+
+ if ( bSortByRows != pDlg->GetByRows() )
+ pDlg->SetByRows( bSortByRows );
+ }
+
+ if ( pSetP )
+ FillItemSet( *pSetP );
+
+ return SfxTabPage::LEAVE_PAGE;
+}
+
+// -----------------------------------------------------------------------
+
+void ScTabPageSortFields::DisableField( USHORT nField )
+{
+ nField--;
+
+ if ( nField<=2 )
+ {
+ aSortLbArr[nField] ->Disable();
+ aDirBtnArr[nField][0]->Disable();
+ aDirBtnArr[nField][1]->Disable();
+ aFlArr[nField] ->Disable();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void ScTabPageSortFields::EnableField( USHORT nField )
+{
+ nField--;
+
+ if ( nField<=2 )
+ {
+ aSortLbArr[nField] ->Enable();
+ aDirBtnArr[nField][0]->Enable();
+ aDirBtnArr[nField][1]->Enable();
+ aFlArr[nField] ->Enable();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void ScTabPageSortFields::FillFieldLists()
+{
+ if ( pViewData )
+ {
+ ScDocument* pDoc = pViewData->GetDocument();
+
+ if ( pDoc )
+ {
+ aLbSort1.Clear();
+ aLbSort2.Clear();
+ aLbSort3.Clear();
+ aLbSort1.InsertEntry( aStrUndefined, 0 );
+ aLbSort2.InsertEntry( aStrUndefined, 0 );
+ aLbSort3.InsertEntry( aStrUndefined, 0 );
+
+ SCCOL nFirstSortCol = rSortData.nCol1;
+ SCROW nFirstSortRow = rSortData.nRow1;
+ SCTAB nTab = pViewData->GetTabNo();
+ USHORT i = 1;
+
+ if ( bSortByRows )
+ {
+ String aFieldName;
+ SCCOL nMaxCol = rSortData.nCol2;
+ SCCOL col;
+
+ for ( col=nFirstSortCol; col<=nMaxCol && i<SC_MAXFIELDS; col++ )
+ {
+ pDoc->GetString( col, nFirstSortRow, nTab, aFieldName );
+ if ( !bHasHeader || (aFieldName.Len() == 0) )
+ {
+ aFieldName = aStrColumn;
+ aFieldName += ' ';
+ aFieldName += ScColToAlpha( col );
+ }
+ nFieldArr[i] = col;
+ aLbSort1.InsertEntry( aFieldName, i );
+ aLbSort2.InsertEntry( aFieldName, i );
+ aLbSort3.InsertEntry( aFieldName, i );
+ i++;
+ }
+ }
+ else
+ {
+ String aFieldName;
+ SCROW nMaxRow = rSortData.nRow2;
+ SCROW row;
+
+ for ( row=nFirstSortRow; row<=nMaxRow && i<SC_MAXFIELDS; row++ )
+ {
+ pDoc->GetString( nFirstSortCol, row, nTab, aFieldName );
+ if ( !bHasHeader || (aFieldName.Len() == 0) )
+ {
+ aFieldName = aStrRow;
+ aFieldName += ' ';
+ aFieldName += String::CreateFromInt32( row+1 );
+ }
+ nFieldArr[i] = row;
+ aLbSort1.InsertEntry( aFieldName, i );
+ aLbSort2.InsertEntry( aFieldName, i );
+ aLbSort3.InsertEntry( aFieldName, i );
+ i++;
+ }
+ }
+ nFieldCount = i;
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+USHORT ScTabPageSortFields::GetFieldSelPos( SCCOLROW nField )
+{
+ USHORT nFieldPos = 0;
+ BOOL bFound = FALSE;
+
+ for ( USHORT n=1; n<nFieldCount && !bFound; n++ )
+ {
+ if ( nFieldArr[n] == nField )
+ {
+ nFieldPos = n;
+ bFound = TRUE;
+ }
+ }
+
+ return nFieldPos;
+}
+
+// -----------------------------------------------------------------------
+// Handler:
+//---------
+
+IMPL_LINK( ScTabPageSortFields, SelectHdl, ListBox *, pLb )
+{
+ String aSelEntry = pLb->GetSelectEntry();
+
+ if ( pLb == &aLbSort1 )
+ {
+ if ( aSelEntry == aStrUndefined )
+ {
+ aLbSort2.SelectEntryPos( 0 );
+ aLbSort3.SelectEntryPos( 0 );
+
+ if ( aFlSort2.IsEnabled() )
+ DisableField( 2 );
+
+ if ( aFlSort3.IsEnabled() )
+ DisableField( 3 );
+ }
+ else
+ {
+ if ( !aFlSort2.IsEnabled() )
+ EnableField( 2 );
+ }
+ }
+ else if ( pLb == &aLbSort2 )
+ {
+ if ( aSelEntry == aStrUndefined )
+ {
+ aLbSort3.SelectEntryPos( 0 );
+ if ( aFlSort3.IsEnabled() )
+ DisableField( 3 );
+ }
+ else
+ {
+ if ( !aFlSort3.IsEnabled() )
+ EnableField( 3 );
+ }
+ }
+ return 0;
+}
+
+//========================================================================
+// Sortieroptionen-Tabpage:
+//========================================================================
+
+#if ENABLE_LAYOUT_EXPERIMENTAL
+#include <layout/layout-pre.hxx>
+
+#if ENABLE_LAYOUT
+#undef ScResId
+#define ScResId(x) #x
+#undef SfxTabPage
+#define SfxTabPage( parent, id, args ) SfxTabPage( parent, "sort-options.xml", id, &args )
+#endif /* ENABLE_LAYOUT */
+
+#endif /* ENABLE_LAYOUT_EXPERIMENTAL */
+
+ScTabPageSortOptions::ScTabPageSortOptions( Window* pParent,
+ const SfxItemSet& rArgSet )
+
+ : SfxTabPage ( pParent,
+ ScResId( RID_SCPAGE_SORT_OPTIONS ),
+ rArgSet ),
+ //
+ aBtnCase ( this, ScResId( BTN_CASESENSITIVE ) ),
+ aBtnHeader ( this, ScResId( BTN_LABEL ) ),
+ aBtnFormats ( this, ScResId( BTN_FORMATS ) ),
+ aBtnCopyResult ( this, ScResId( BTN_COPYRESULT ) ),
+ aLbOutPos ( this, ScResId( LB_OUTAREA ) ),
+ aEdOutPos ( this, ScResId( ED_OUTAREA ) ),
+ aBtnSortUser ( this, ScResId( BTN_SORT_USER ) ),
+ aLbSortUser ( this, ScResId( LB_SORT_USER ) ),
+ aFtLanguage ( this, ScResId( FT_LANGUAGE ) ),
+ aLbLanguage ( this, ScResId( LB_LANGUAGE ) ),
+ aFtAlgorithm ( this, ScResId( FT_ALGORITHM ) ),
+ aLbAlgorithm ( this, ScResId( LB_ALGORITHM ) ),
+ aLineDirection ( this, ScResId( FL_DIRECTION ) ),
+ aBtnTopDown ( this, ScResId( BTN_TOP_DOWN ) ),
+ aBtnLeftRight ( this, ScResId( BTN_LEFT_RIGHT ) ),
+ aFtAreaLabel ( this, ScResId( FT_AREA_LABEL ) ),
+// aFtArea ( this, ScResId( FT_AREA ) ),
+ //
+#if ENABLE_LAYOUT_EXPERIMENTAL
+#undef this
+#undef ScResId
+#define ScResId(x) this, #x
+#endif /* ENABLE_LAYOUT_EXPERIMENTAL */
+ aStrRowLabel ( ScResId( STR_ROW_LABEL ) ),
+ aStrColLabel ( ScResId( STR_COL_LABEL ) ),
+ aStrUndefined ( ScResId( SCSTR_UNDEFINED ) ),
+ aStrNoName ( ScGlobal::GetRscString(STR_DB_NONAME) ),
+ //
+ nWhichSort ( rArgSet.GetPool()->GetWhich( SID_SORT ) ),
+ rSortData ( ((const ScSortItem&)
+ rArgSet.Get( nWhichSort )).GetSortData() ),
+ pViewData ( NULL ),
+ pDoc ( NULL ),
+ pDlg ( (ScSortDlg*)(GetParent() ? GetParent()->GetParent() : 0 ) ),
+ pColRes ( NULL ),
+ pColWrap ( NULL )
+{
+ Init();
+ FreeResource();
+ SetExchangeSupport();
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT ScTabPageSortOptions::~ScTabPageSortOptions()
+{
+ USHORT nEntries = aLbOutPos.GetEntryCount();
+
+ for ( USHORT i=1; i<nEntries; i++ )
+ delete (String*)aLbOutPos.GetEntryData( i );
+
+ delete pColRes;
+ delete pColWrap; //! not if from document
+}
+
+// -----------------------------------------------------------------------
+
+void ScTabPageSortOptions::Init()
+{
+ aStrAreaLabel = aFtAreaLabel.GetText();
+ aStrAreaLabel.Append( (sal_Unicode) ' ' );
+
+ // CollatorRessource has user-visible names for sort algorithms
+ pColRes = new CollatorRessource();
+
+ //! use CollatorWrapper from document?
+ pColWrap = new CollatorWrapper( comphelper::getProcessServiceFactory() );
+
+ const ScSortItem& rSortItem = (const ScSortItem&)
+ GetItemSet().Get( nWhichSort );
+
+ aLbOutPos.SetSelectHdl ( LINK( this, ScTabPageSortOptions, SelOutPosHdl ) );
+ aBtnCopyResult.SetClickHdl( LINK( this, ScTabPageSortOptions, EnableHdl ) );
+ aBtnSortUser.SetClickHdl ( LINK( this, ScTabPageSortOptions, EnableHdl ) );
+ aBtnTopDown.SetClickHdl ( LINK( this, ScTabPageSortOptions, SortDirHdl ) );
+ aBtnLeftRight.SetClickHdl ( LINK( this, ScTabPageSortOptions, SortDirHdl ) );
+ aLbLanguage.SetSelectHdl ( LINK( this, ScTabPageSortOptions, FillAlgorHdl ) );
+
+ pViewData = rSortItem.GetViewData();
+ pDoc = pViewData ? pViewData->GetDocument() : NULL;
+
+ DBG_ASSERT( pViewData, "ViewData not found! :-/" );
+
+ if ( pViewData && pDoc )
+ {
+ String theArea;
+ ScDBCollection* pDBColl = pDoc->GetDBCollection();
+ String theDbArea;
+ String theDbName = aStrNoName;
+ const SCTAB nCurTab = pViewData->GetTabNo();
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+
+ aLbOutPos.Clear();
+ aLbOutPos.InsertEntry( aStrUndefined, 0 );
+ aLbOutPos.Disable();
+
+ ScAreaNameIterator aIter( pDoc );
+ String aName;
+ ScRange aRange;
+ String aRefStr;
+ while ( aIter.Next( aName, aRange ) )
+ {
+ USHORT nInsert = aLbOutPos.InsertEntry( aName );
+
+ aRange.aStart.Format( aRefStr, SCA_ABS_3D, pDoc, eConv );
+ aLbOutPos.SetEntryData( nInsert, new String( aRefStr ) );
+ }
+
+ aLbOutPos.SelectEntryPos( 0 );
+ aEdOutPos.SetText( EMPTY_STRING );
+
+ /*
+ * Ueberpruefen, ob es sich bei dem uebergebenen
+ * Bereich um einen Datenbankbereich handelt:
+ */
+
+ ScAddress aScAddress( rSortData.nCol1, rSortData.nRow1, nCurTab );
+ ScRange( aScAddress,
+ ScAddress( rSortData.nCol2, rSortData.nRow2, nCurTab )
+ ).Format( theArea, SCR_ABS, pDoc, eConv );
+
+ if ( pDBColl )
+ {
+ ScDBData* pDBData
+ = pDBColl->GetDBAtArea( nCurTab,
+ rSortData.nCol1, rSortData.nRow1,
+ rSortData.nCol2, rSortData.nRow2 );
+ if ( pDBData )
+ {
+ pDBData->GetName( theDbName );
+ aBtnHeader.Check( pDBData->HasHeader() );
+ }
+ }
+
+ theArea.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" ("));
+ theArea += theDbName;
+ theArea += ')';
+
+ //aFtArea.SetText( theArea );
+ theArea.Insert( aStrAreaLabel, 0 );
+ aFtAreaLabel.SetText( theArea );
+
+ aBtnHeader.SetText( aStrColLabel );
+ }
+
+ FillUserSortListBox();
+
+ // get available languages
+
+ aLbLanguage.SetLanguageList( LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, FALSE );
+ aLbLanguage.InsertLanguage( LANGUAGE_SYSTEM );
+}
+
+//------------------------------------------------------------------------
+
+USHORT* __EXPORT ScTabPageSortOptions::GetRanges()
+{
+ return pSortRanges;
+}
+
+// -----------------------------------------------------------------------
+
+#if ENABLE_LAYOUT_EXPERIMENTAL
+#undef SfxTabPage
+#endif /* ENABLE_LAYOUT_EXPERIMENTAL */
+SfxTabPage* __EXPORT ScTabPageSortOptions::Create(
+ Window* pParent,
+ const SfxItemSet& rArgSet )
+{
+ return ( new ScTabPageSortOptions( pParent, rArgSet ) );
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScTabPageSortOptions::Reset( const SfxItemSet& /* rArgSet */ )
+{
+ if ( rSortData.bUserDef )
+ {
+ aBtnSortUser.Check( TRUE );
+ aLbSortUser.Enable();
+ aLbSortUser.SelectEntryPos( rSortData.nUserIndex );
+ }
+ else
+ {
+ aBtnSortUser.Check( FALSE );
+ aLbSortUser.Disable();
+ aLbSortUser.SelectEntryPos( 0 );
+ }
+
+ aBtnCase.Check ( rSortData.bCaseSens );
+ aBtnFormats.Check ( rSortData.bIncludePattern );
+ aBtnHeader.Check ( rSortData.bHasHeader );
+
+ if ( rSortData.bByRow )
+ {
+ aBtnTopDown.Check();
+ aBtnHeader.SetText( aStrColLabel );
+ }
+ else
+ {
+ aBtnLeftRight.Check();
+ aBtnHeader.SetText( aStrRowLabel );
+ }
+
+ LanguageType eLang = MsLangId::convertLocaleToLanguage( rSortData.aCollatorLocale );
+ if ( eLang == LANGUAGE_DONTKNOW )
+ eLang = LANGUAGE_SYSTEM;
+ aLbLanguage.SelectLanguage( eLang );
+ FillAlgorHdl( &aLbLanguage ); // get algorithms, select default
+ if ( rSortData.aCollatorAlgorithm.Len() )
+ aLbAlgorithm.SelectEntry( pColRes->GetTranslation( rSortData.aCollatorAlgorithm ) );
+
+ if ( pDoc && !rSortData.bInplace )
+ {
+ String aStr;
+ USHORT nFormat = (rSortData.nDestTab != pViewData->GetTabNo())
+ ? SCR_ABS_3D
+ : SCR_ABS;
+
+ theOutPos.Set( rSortData.nDestCol,
+ rSortData.nDestRow,
+ rSortData.nDestTab );
+
+ theOutPos.Format( aStr, nFormat, pDoc, pDoc->GetAddressConvention() );
+ aBtnCopyResult.Check();
+ aLbOutPos.Enable();
+ aEdOutPos.Enable();
+ aEdOutPos.SetText( aStr );
+ EdOutPosModHdl( &aEdOutPos );
+ aEdOutPos.GrabFocus();
+ aEdOutPos.SetSelection( Selection( 0, SELECTION_MAX ) );
+ }
+ else
+ {
+ aBtnCopyResult.Check( FALSE );
+ aLbOutPos.Disable();
+ aEdOutPos.Disable();
+ aEdOutPos.SetText( EMPTY_STRING );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+BOOL __EXPORT ScTabPageSortOptions::FillItemSet( SfxItemSet& rArgSet )
+{
+ ScSortParam theSortData = rSortData;
+ if (pDlg)
+ {
+ const SfxItemSet* pExample = pDlg->GetExampleSet();
+ const SfxPoolItem* pItem;
+ if ( pExample && pExample->GetItemState( nWhichSort, TRUE, &pItem ) == SFX_ITEM_SET )
+ theSortData = ((const ScSortItem*)pItem)->GetSortData();
+ }
+
+ theSortData.bByRow = aBtnTopDown.IsChecked();
+ theSortData.bHasHeader = aBtnHeader.IsChecked();
+ theSortData.bCaseSens = aBtnCase.IsChecked();
+ theSortData.bIncludePattern = aBtnFormats.IsChecked();
+ theSortData.bInplace = !aBtnCopyResult.IsChecked();
+ theSortData.nDestCol = theOutPos.Col();
+ theSortData.nDestRow = theOutPos.Row();
+ theSortData.nDestTab = theOutPos.Tab();
+ theSortData.bUserDef = aBtnSortUser.IsChecked();
+ theSortData.nUserIndex = (aBtnSortUser.IsChecked())
+ ? aLbSortUser.GetSelectEntryPos()
+ : 0;
+
+ // get locale
+ LanguageType eLang = aLbLanguage.GetSelectLanguage();
+ theSortData.aCollatorLocale = MsLangId::convertLanguageToLocale( eLang, false );
+
+ // get algorithm
+ String sAlg;
+ if ( eLang != LANGUAGE_SYSTEM )
+ {
+ uno::Sequence<rtl::OUString> aAlgos = pColWrap->listCollatorAlgorithms(
+ theSortData.aCollatorLocale );
+ USHORT nSel = aLbAlgorithm.GetSelectEntryPos();
+ if ( nSel < aAlgos.getLength() )
+ sAlg = aAlgos[nSel];
+ }
+ theSortData.aCollatorAlgorithm = sAlg;
+
+ rArgSet.Put( ScSortItem( SCITEM_SORTDATA, &theSortData ) );
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+// fuer Datenaustausch ohne Dialog-Umweg: (! noch zu tun !)
+// void ScTabPageSortOptions::ActivatePage( const SfxItemSet& rSet )
+void __EXPORT ScTabPageSortOptions::ActivatePage()
+{
+ if ( pDlg )
+ {
+ if ( aBtnHeader.IsChecked() != pDlg->GetHeaders() )
+ {
+ aBtnHeader.Check( pDlg->GetHeaders() );
+ }
+
+ if ( aBtnTopDown.IsChecked() != pDlg->GetByRows() )
+ {
+ aBtnTopDown.Check( pDlg->GetByRows() );
+ aBtnLeftRight.Check( !pDlg->GetByRows() );
+ }
+
+ aBtnHeader.SetText( (pDlg->GetByRows())
+ ? aStrColLabel
+ : aStrRowLabel );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+int __EXPORT ScTabPageSortOptions::DeactivatePage( SfxItemSet* pSetP )
+{
+ BOOL bPosInputOk = TRUE;
+
+ if ( aBtnCopyResult.IsChecked() )
+ {
+ String thePosStr = aEdOutPos.GetText();
+ ScAddress thePos;
+ xub_StrLen nColonPos = thePosStr.Search( ':' );
+
+ if ( STRING_NOTFOUND != nColonPos )
+ thePosStr.Erase( nColonPos );
+
+ if ( pViewData )
+ {
+ // visible table is default for input without table
+ // must be changed to GetRefTabNo when sorting has RefInput!
+ thePos.SetTab( pViewData->GetTabNo() );
+ }
+
+ USHORT nResult = thePos.Parse( thePosStr, pDoc, pDoc->GetAddressConvention() );
+
+ bPosInputOk = ( SCA_VALID == (nResult & SCA_VALID) );
+
+ if ( !bPosInputOk )
+ {
+#if !ENABLE_LAYOUT_EXPERIMENTAL
+ ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ),
+ ScGlobal::GetRscString( STR_INVALID_TABREF )
+ ).Execute();
+#endif /* ENABLE_LAYOUT_EXPERIMENTAL */
+ aEdOutPos.GrabFocus();
+ aEdOutPos.SetSelection( Selection( 0, SELECTION_MAX ) );
+ theOutPos.Set(0,0,0);
+ }
+ else
+ {
+ aEdOutPos.SetText( thePosStr );
+ theOutPos = thePos;
+ }
+ }
+
+ if ( pDlg && bPosInputOk )
+ {
+ pDlg->SetHeaders( aBtnHeader.IsChecked() );
+ pDlg->SetByRows ( aBtnTopDown.IsChecked() );
+ }
+
+ if ( pSetP && bPosInputOk )
+ FillItemSet( *pSetP );
+
+ return bPosInputOk ? SfxTabPage::LEAVE_PAGE : SfxTabPage::KEEP_PAGE;
+}
+
+// -----------------------------------------------------------------------
+
+void ScTabPageSortOptions::FillUserSortListBox()
+{
+ ScUserList* pUserLists = ScGlobal::GetUserList();
+
+ aLbSortUser.Clear();
+ if ( pUserLists )
+ {
+ USHORT nCount = pUserLists->GetCount();
+ if ( nCount > 0 )
+ for ( USHORT i=0; i<nCount; i++ )
+ aLbSortUser.InsertEntry( (*pUserLists)[i]->GetString() );
+ }
+}
+
+// -----------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScTabPageSortOptions, EnableHdl, CheckBox *, pBox )
+{
+ if ( pBox == &aBtnCopyResult )
+ {
+ if ( pBox->IsChecked() )
+ {
+ aLbOutPos.Enable();
+ aEdOutPos.Enable();
+ aEdOutPos.GrabFocus();
+ }
+ else
+ {
+ aLbOutPos.Disable();
+ aEdOutPos.Disable();
+ }
+ }
+ else if ( pBox == &aBtnSortUser )
+ {
+ if ( pBox->IsChecked() )
+ {
+ aLbSortUser.Enable();
+ aLbSortUser.GrabFocus();
+ }
+ else
+ aLbSortUser.Disable();
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( ScTabPageSortOptions, SelOutPosHdl, ListBox *, pLb )
+{
+ if ( pLb == &aLbOutPos )
+ {
+ String aString;
+ USHORT nSelPos = aLbOutPos.GetSelectEntryPos();
+
+ if ( nSelPos > 0 )
+ aString = *(String*)aLbOutPos.GetEntryData( nSelPos );
+
+ aEdOutPos.SetText( aString );
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( ScTabPageSortOptions, SortDirHdl, RadioButton *, pBtn )
+{
+ if ( pBtn == &aBtnTopDown )
+ {
+ aBtnHeader.SetText( aStrColLabel );
+ }
+ else if ( pBtn == &aBtnLeftRight )
+ {
+ aBtnHeader.SetText( aStrRowLabel );
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScTabPageSortOptions::EdOutPosModHdl( Edit* pEd )
+{
+ if ( pEd == &aEdOutPos )
+ {
+ String theCurPosStr = aEdOutPos.GetText();
+ USHORT nResult = ScAddress().Parse( theCurPosStr, pDoc, pDoc->GetAddressConvention() );
+
+ if ( SCA_VALID == (nResult & SCA_VALID) )
+ {
+ String* pStr = NULL;
+ BOOL bFound = FALSE;
+ USHORT i = 0;
+ USHORT nCount = aLbOutPos.GetEntryCount();
+
+ for ( i=2; i<nCount && !bFound; i++ )
+ {
+ pStr = (String*)aLbOutPos.GetEntryData( i );
+ bFound = (theCurPosStr == *pStr);
+ }
+
+ if ( bFound )
+ aLbOutPos.SelectEntryPos( --i );
+ else
+ aLbOutPos.SelectEntryPos( 0 );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( ScTabPageSortOptions, FillAlgorHdl, void *, EMPTYARG )
+{
+ aLbAlgorithm.SetUpdateMode( FALSE );
+ aLbAlgorithm.Clear();
+
+ LanguageType eLang = aLbLanguage.GetSelectLanguage();
+ if ( eLang == LANGUAGE_SYSTEM )
+ {
+ // for LANGUAGE_SYSTEM no algorithm can be selected because
+ // it wouldn't necessarily exist for other languages
+ // -> leave list box empty if LANGUAGE_SYSTEM is selected
+ aFtAlgorithm.Enable( FALSE ); // nothing to select
+ aLbAlgorithm.Enable( FALSE ); // nothing to select
+ }
+ else
+ {
+ lang::Locale aLocale( MsLangId::convertLanguageToLocale( eLang ));
+ uno::Sequence<rtl::OUString> aAlgos = pColWrap->listCollatorAlgorithms( aLocale );
+
+ long nCount = aAlgos.getLength();
+ const rtl::OUString* pArray = aAlgos.getConstArray();
+ for (long i=0; i<nCount; i++)
+ {
+ String sAlg = pArray[i];
+ String sUser = pColRes->GetTranslation( sAlg );
+ aLbAlgorithm.InsertEntry( sUser, LISTBOX_APPEND );
+ }
+ aLbAlgorithm.SelectEntryPos( 0 ); // first entry is default
+ aFtAlgorithm.Enable( nCount > 1 ); // enable only if there is a choice
+ aLbAlgorithm.Enable( nCount > 1 ); // enable only if there is a choice
+ }
+
+ aLbAlgorithm.SetUpdateMode( TRUE );
+ return 0;
+}
+
+
diff --git a/sc/source/ui/dbgui/tpsubt.cxx b/sc/source/ui/dbgui/tpsubt.cxx
new file mode 100644
index 000000000000..fbada165b55d
--- /dev/null
+++ b/sc/source/ui/dbgui/tpsubt.cxx
@@ -0,0 +1,686 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+#include "scitems.hxx"
+#include "uiitems.hxx"
+#include "global.hxx"
+#include "userlist.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "sc.hrc" // -> Slot IDs
+
+#include "subtdlg.hxx"
+#include "subtdlg.hrc"
+#include "tpsubt.hxx"
+
+// STATIC DATA -----------------------------------------------------------
+
+static USHORT pSubTotalsRanges[] =
+{
+ SID_SUBTOTALS,
+ SID_SUBTOTALS,
+ 0
+};
+
+//========================================================================
+// Zwischenergebnisgruppen-Tabpage:
+
+ScTpSubTotalGroup::ScTpSubTotalGroup( Window* pParent, USHORT nResId,
+ const SfxItemSet& rArgSet )
+ : SfxTabPage ( pParent,
+ ScResId( nResId ),
+ rArgSet ),
+ //
+ aFtGroup ( this, ScResId( FT_GROUP ) ),
+ aLbGroup ( this, ScResId( LB_GROUP ) ),
+ aFtColumns ( this, ScResId( FT_COLUMNS ) ),
+ aLbColumns ( this, ScResId( WND_COLUMNS ) ),
+ aFtFunctions ( this, ScResId( FT_FUNCTIONS ) ),
+ aLbFunctions ( this, ScResId( LB_FUNCTIONS ) ),
+ aStrNone ( ScResId( SCSTR_NONE ) ),
+ aStrColumn ( ScResId( SCSTR_COLUMN ) ),
+ //
+ pViewData ( NULL ),
+ pDoc ( NULL ),
+ nWhichSubTotals ( rArgSet.GetPool()->GetWhich( SID_SUBTOTALS ) ),
+ rSubTotalData ( ((const ScSubTotalItem&)
+ rArgSet.Get( nWhichSubTotals )).
+ GetSubTotalData() ),
+ nFieldCount ( 0 )
+{
+ // Font is correctly initialized by SvTreeListBox ctor
+ aLbColumns.SetSelectionMode( SINGLE_SELECTION );
+ aLbColumns.SetDragDropMode( SV_DRAGDROP_NONE );
+ aLbColumns.SetSpaceBetweenEntries( 0 );
+ aLbColumns.Show();
+
+ Init ();
+ FreeResource();
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT ScTpSubTotalGroup::~ScTpSubTotalGroup()
+{
+ USHORT nCount = (USHORT)aLbColumns.GetEntryCount();
+
+ if ( nCount > 0 )
+ {
+ USHORT* pData = NULL;
+
+ for ( USHORT i=0; i<nCount; i++ )
+ {
+ pData = (USHORT*)(aLbColumns.GetEntryData( i ));
+ DBG_ASSERT( pData, "EntryData not found" );
+
+ delete pData;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void ScTpSubTotalGroup::Init()
+{
+ const ScSubTotalItem& rSubTotalItem = (const ScSubTotalItem&)
+ GetItemSet().Get( nWhichSubTotals );
+
+ pViewData = rSubTotalItem.GetViewData();
+ pDoc = ( pViewData ) ? pViewData->GetDocument() : NULL;
+
+ DBG_ASSERT( pViewData && pDoc, "ViewData or Document not found :-(" );
+
+ aLbGroup.SetSelectHdl ( LINK( this, ScTpSubTotalGroup, SelectHdl ) );
+ aLbColumns.SetSelectHdl ( LINK( this, ScTpSubTotalGroup, SelectHdl ) );
+ aLbColumns.SetCheckButtonHdl ( LINK( this, ScTpSubTotalGroup, CheckHdl ) );
+ aLbFunctions.SetSelectHdl ( LINK( this, ScTpSubTotalGroup, SelectHdl ) );
+
+ nFieldArr[0] = 0;
+ FillListBoxes();
+}
+
+//------------------------------------------------------------------------
+
+USHORT* __EXPORT ScTpSubTotalGroup::GetRanges()
+{
+ return pSubTotalsRanges;
+}
+
+// -----------------------------------------------------------------------
+
+BOOL ScTpSubTotalGroup::DoReset( USHORT nGroupNo,
+ const SfxItemSet& rArgSet )
+{
+ USHORT nGroupIdx = 0;
+
+ DBG_ASSERT( (nGroupNo<=3) && (nGroupNo>0), "Invalid group" );
+
+ if ( (nGroupNo > 3) || (nGroupNo == 0) )
+ return FALSE;
+ else
+ nGroupIdx = nGroupNo-1;
+
+ //----------------------------------------------------------
+
+ // #79058# first we have to clear the listboxes...
+ for ( USHORT nLbEntry = 0; nLbEntry < aLbColumns.GetEntryCount(); ++nLbEntry )
+ {
+ aLbColumns.CheckEntryPos( nLbEntry, FALSE );
+ *((USHORT*)aLbColumns.GetEntryData( nLbEntry )) = 0;
+ }
+ aLbFunctions.SelectEntryPos( 0 );
+
+ ScSubTotalParam theSubTotalData( ((const ScSubTotalItem&)
+ rArgSet.Get( nWhichSubTotals )).
+ GetSubTotalData() );
+
+ if ( theSubTotalData.bGroupActive[nGroupIdx] )
+ {
+ SCCOL nField = theSubTotalData.nField[nGroupIdx];
+ SCCOL nSubTotals = theSubTotalData.nSubTotals[nGroupIdx];
+ SCCOL* pSubTotals = theSubTotalData.pSubTotals[nGroupIdx];
+ ScSubTotalFunc* pFunctions = theSubTotalData.pFunctions[nGroupIdx];
+
+ aLbGroup.SelectEntryPos( GetFieldSelPos( nField )+1 );
+
+ for ( USHORT i=0; i<nSubTotals; i++ )
+ {
+ USHORT nCheckPos = GetFieldSelPos( pSubTotals[i] );
+ USHORT* pFunction = (USHORT*)aLbColumns.GetEntryData( nCheckPos );
+
+ aLbColumns.CheckEntryPos( nCheckPos );
+ *pFunction = FuncToLbPos( pFunctions[i] );
+ }
+ aLbColumns.SelectEntryPos( 0 );
+ }
+ else
+ {
+ aLbGroup.SelectEntryPos( (nGroupNo == 1) ? 1 : 0 );
+ aLbColumns.SelectEntryPos( 0 );
+ aLbFunctions.SelectEntryPos( 0 );
+ }
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+BOOL ScTpSubTotalGroup::DoFillItemSet( USHORT nGroupNo,
+ SfxItemSet& rArgSet )
+{
+ USHORT nGroupIdx = 0;
+
+ DBG_ASSERT( (nGroupNo<=3) && (nGroupNo>0), "Invalid group" );
+ DBG_ASSERT( (aLbGroup.GetEntryCount() > 0)
+ && (aLbColumns.GetEntryCount() > 0)
+ && (aLbFunctions.GetEntryCount() > 0),
+ "Non-initialized Lists" );
+
+
+ if ( (nGroupNo > 3) || (nGroupNo == 0)
+ || (aLbGroup.GetEntryCount() == 0)
+ || (aLbColumns.GetEntryCount() == 0)
+ || (aLbFunctions.GetEntryCount() == 0)
+ )
+ return FALSE;
+ else
+ nGroupIdx = nGroupNo-1;
+
+ //----------------------------------------------------------
+
+ ScSubTotalParam theSubTotalData; // auslesen, wenn schon teilweise gefuellt
+ SfxTabDialog* pDlg = GetTabDialog();
+ if ( pDlg )
+ {
+ const SfxItemSet* pExample = pDlg->GetExampleSet();
+ const SfxPoolItem* pItem;
+ if ( pExample && pExample->GetItemState( nWhichSubTotals, TRUE, &pItem ) == SFX_ITEM_SET )
+ theSubTotalData = ((const ScSubTotalItem*)pItem)->GetSubTotalData();
+ }
+
+ ScSubTotalFunc* pFunctions = NULL;
+ SCCOL* pSubTotals = NULL;
+ USHORT nGroup = aLbGroup.GetSelectEntryPos();
+ USHORT nEntryCount = (USHORT)aLbColumns.GetEntryCount();
+ USHORT nCheckCount = aLbColumns.GetCheckedEntryCount();
+
+ theSubTotalData.nCol1 = rSubTotalData.nCol1;
+ theSubTotalData.nRow1 = rSubTotalData.nRow1;
+ theSubTotalData.nCol2 = rSubTotalData.nCol2;
+ theSubTotalData.nRow2 = rSubTotalData.nRow2;
+ theSubTotalData.bGroupActive[nGroupIdx] = (nGroup != 0);
+ theSubTotalData.nField[nGroupIdx] = (nGroup != 0)
+ ? nFieldArr[nGroup-1]
+ : static_cast<SCCOL>(0);
+
+ if ( nEntryCount>0 && nCheckCount>0 && nGroup!=0 )
+ {
+ USHORT nFunction = 0;
+
+ pSubTotals = new SCCOL [nCheckCount];
+ pFunctions = new ScSubTotalFunc [nCheckCount];
+
+ for ( USHORT i=0, nCheck=0; i<nEntryCount; i++ )
+ {
+ if ( aLbColumns.IsChecked( i ) )
+ {
+ DBG_ASSERT( nCheck <= nCheckCount,
+ "Range error :-(" );
+ nFunction = *((USHORT*)aLbColumns.GetEntryData( i ));
+ pSubTotals[nCheck] = nFieldArr[i];
+ pFunctions[nCheck] = LbPosToFunc( nFunction );
+ nCheck++;
+ }
+ }
+ theSubTotalData.SetSubTotals( nGroupNo, // Gruppen-Nr.
+ pSubTotals,
+ pFunctions,
+ nCheckCount ); // Anzahl der Array-Elemente
+
+ }
+
+ rArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA, &theSubTotalData ) );
+
+ if ( pSubTotals ) delete [] pSubTotals;
+ if ( pFunctions ) delete [] pFunctions;
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+void ScTpSubTotalGroup::FillListBoxes()
+{
+ DBG_ASSERT( pViewData && pDoc, "ViewData or Document not found :-/" );
+
+ if ( pViewData && pDoc )
+ {
+ SCCOL nFirstCol = rSubTotalData.nCol1;
+ SCROW nFirstRow = rSubTotalData.nRow1;
+ SCTAB nTab = pViewData->GetTabNo();
+ SCCOL nMaxCol = rSubTotalData.nCol2;
+ SCCOL col;
+ USHORT i=0;
+ String aFieldName;
+
+ aLbGroup.Clear();
+ aLbColumns.Clear();
+ aLbGroup.InsertEntry( aStrNone, 0 );
+
+ i=0;
+ for ( col=nFirstCol; col<=nMaxCol && i<SC_MAXFIELDS; col++ )
+ {
+ pDoc->GetString( col, nFirstRow, nTab, aFieldName );
+ if ( aFieldName.Len() == 0 )
+ {
+ aFieldName = aStrColumn;
+ aFieldName += ' ';
+ aFieldName += ::ScColToAlpha( col ); // from global.hxx
+ }
+ nFieldArr[i] = col;
+ aLbGroup.InsertEntry( aFieldName, i+1 );
+ aLbColumns.InsertEntry( aFieldName, i );
+ aLbColumns.SetEntryData( i, new USHORT(0) );
+ i++;
+ }
+ // Nachtraegliche "Konstanteninitialisierung":
+ (USHORT&)nFieldCount = i;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+USHORT ScTpSubTotalGroup::GetFieldSelPos( SCCOL nField )
+{
+ USHORT nFieldPos = 0;
+ BOOL bFound = FALSE;
+
+ for ( USHORT n=0; n<nFieldCount && !bFound; n++ )
+ {
+ if ( nFieldArr[n] == nField )
+ {
+ nFieldPos = n;
+ bFound = TRUE;
+ }
+ }
+
+ return nFieldPos;
+}
+
+// -----------------------------------------------------------------------
+
+ScSubTotalFunc ScTpSubTotalGroup::LbPosToFunc( USHORT nPos )
+{
+ switch ( nPos )
+ {
+// case 0: return SUBTOTAL_FUNC_NONE;
+ case 2: return SUBTOTAL_FUNC_AVE;
+ case 6: return SUBTOTAL_FUNC_CNT;
+ case 1: return SUBTOTAL_FUNC_CNT2;
+ case 3: return SUBTOTAL_FUNC_MAX;
+ case 4: return SUBTOTAL_FUNC_MIN;
+ case 5: return SUBTOTAL_FUNC_PROD;
+ case 7: return SUBTOTAL_FUNC_STD;
+ case 8: return SUBTOTAL_FUNC_STDP;
+ case 0: return SUBTOTAL_FUNC_SUM;
+ case 9: return SUBTOTAL_FUNC_VAR;
+ case 10: return SUBTOTAL_FUNC_VARP;
+ default:
+ DBG_ERROR( "ScTpSubTotalGroup::LbPosToFunc" );
+ return SUBTOTAL_FUNC_NONE;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+USHORT ScTpSubTotalGroup::FuncToLbPos( ScSubTotalFunc eFunc )
+{
+ switch ( eFunc )
+ {
+// case SUBTOTAL_FUNC_NONE: return 0;
+ case SUBTOTAL_FUNC_AVE: return 2;
+ case SUBTOTAL_FUNC_CNT: return 6;
+ case SUBTOTAL_FUNC_CNT2: return 1;
+ case SUBTOTAL_FUNC_MAX: return 3;
+ case SUBTOTAL_FUNC_MIN: return 4;
+ case SUBTOTAL_FUNC_PROD: return 5;
+ case SUBTOTAL_FUNC_STD: return 7;
+ case SUBTOTAL_FUNC_STDP: return 8;
+ case SUBTOTAL_FUNC_SUM: return 0;
+ case SUBTOTAL_FUNC_VAR: return 9;
+ case SUBTOTAL_FUNC_VARP: return 10;
+ default:
+ DBG_ERROR( "ScTpSubTotalGroup::FuncToLbPos" );
+ return 0;
+ }
+}
+
+// -----------------------------------------------------------------------
+// Handler:
+//---------
+
+IMPL_LINK( ScTpSubTotalGroup, SelectHdl, ListBox *, pLb )
+{
+ if ( (aLbColumns.GetEntryCount() > 0)
+ && (aLbColumns.GetSelectionCount() > 0) )
+ {
+ USHORT nFunction = aLbFunctions.GetSelectEntryPos();
+ USHORT nColumn = aLbColumns.GetSelectEntryPos();
+ USHORT* pFunction = (USHORT*)aLbColumns.GetEntryData( nColumn );
+
+ DBG_ASSERT( pFunction, "EntryData nicht gefunden!" );
+ if ( !pFunction )
+ return 0;
+
+ if ( ((SvxCheckListBox*)pLb) == &aLbColumns )
+ {
+ aLbFunctions.SelectEntryPos( *pFunction );
+ }
+ else if ( pLb == &aLbFunctions )
+ {
+ *pFunction = nFunction;
+// aLbColumns.CheckEntryPos( nColumn, (nFunction != 0) );//XXX
+ aLbColumns.CheckEntryPos( nColumn, TRUE );
+ }
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( ScTpSubTotalGroup, CheckHdl, ListBox *, pLb )
+{
+ if ( ((SvxCheckListBox*)pLb) == &aLbColumns )
+ {
+ SvLBoxEntry* pEntry = aLbColumns.GetHdlEntry();
+
+ if ( pEntry )
+ {
+ aLbColumns.SelectEntryPos( (USHORT)aLbColumns.GetModel()->GetAbsPos( pEntry ) );
+ SelectHdl( pLb );
+ }
+ }
+ return 0;
+}
+
+//========================================================================
+// Abgeleitete Gruppen-TabPages:
+
+SfxTabPage* __EXPORT ScTpSubTotalGroup1::Create( Window* pParent,
+ const SfxItemSet& rArgSet )
+ { return ( new ScTpSubTotalGroup1( pParent, rArgSet ) ); }
+
+// -----------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScTpSubTotalGroup2::Create( Window* pParent,
+ const SfxItemSet& rArgSet )
+ { return ( new ScTpSubTotalGroup2( pParent, rArgSet ) ); }
+
+// -----------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScTpSubTotalGroup3::Create( Window* pParent,
+ const SfxItemSet& rArgSet )
+ { return ( new ScTpSubTotalGroup3( pParent, rArgSet ) ); }
+
+// -----------------------------------------------------------------------
+
+ScTpSubTotalGroup1::ScTpSubTotalGroup1( Window* pParent, const SfxItemSet& rArgSet ) :
+ ScTpSubTotalGroup( pParent, RID_SCPAGE_SUBT_GROUP1, rArgSet )
+{}
+
+ScTpSubTotalGroup2::ScTpSubTotalGroup2( Window* pParent, const SfxItemSet& rArgSet ) :
+ ScTpSubTotalGroup( pParent, RID_SCPAGE_SUBT_GROUP2, rArgSet )
+{}
+
+ScTpSubTotalGroup3::ScTpSubTotalGroup3( Window* pParent, const SfxItemSet& rArgSet ) :
+ ScTpSubTotalGroup( pParent, RID_SCPAGE_SUBT_GROUP3, rArgSet )
+{}
+
+// -----------------------------------------------------------------------
+
+
+#define RESET(i) (ScTpSubTotalGroup::DoReset( (i), rArgSet ))
+
+void __EXPORT ScTpSubTotalGroup1::Reset( const SfxItemSet& rArgSet ) { RESET(1); }
+
+void __EXPORT ScTpSubTotalGroup2::Reset( const SfxItemSet& rArgSet ) { RESET(2); }
+
+void __EXPORT ScTpSubTotalGroup3::Reset( const SfxItemSet& rArgSet ) { RESET(3); }
+
+#undef RESET
+
+// -----------------------------------------------------------------------
+
+#define FILLSET(i) (ScTpSubTotalGroup::DoFillItemSet( (i), rArgSet ))
+
+BOOL __EXPORT ScTpSubTotalGroup1::FillItemSet( SfxItemSet& rArgSet ) { return FILLSET(1); }
+
+BOOL __EXPORT ScTpSubTotalGroup2::FillItemSet( SfxItemSet& rArgSet ) { return FILLSET(2); }
+
+BOOL __EXPORT ScTpSubTotalGroup3::FillItemSet( SfxItemSet& rArgSet ) { return FILLSET(3); }
+
+#undef FILL
+
+//========================================================================
+// Optionen-Tabpage:
+
+ScTpSubTotalOptions::ScTpSubTotalOptions( Window* pParent,
+ const SfxItemSet& rArgSet )
+
+ : SfxTabPage ( pParent,
+ ScResId( RID_SCPAGE_SUBT_OPTIONS ),
+ rArgSet ),
+ //
+ aFlGroup ( this, ScResId( FL_GROUP ) ),
+ aBtnPagebreak ( this, ScResId( BTN_PAGEBREAK ) ),
+ aBtnCase ( this, ScResId( BTN_CASE ) ),
+ aBtnSort ( this, ScResId( BTN_SORT ) ),
+ aFlSort ( this, ScResId( FL_SORT ) ),
+ aBtnAscending ( this, ScResId( BTN_ASCENDING ) ),
+ aBtnDescending ( this, ScResId( BTN_DESCENDING ) ),
+ aBtnFormats ( this, ScResId( BTN_FORMATS ) ),
+ aBtnUserDef ( this, ScResId( BTN_USERDEF ) ),
+ aLbUserDef ( this, ScResId( LB_USERDEF ) ),
+ //
+ pViewData ( NULL ),
+ pDoc ( NULL ),
+ nWhichSubTotals ( rArgSet.GetPool()->GetWhich( SID_SUBTOTALS ) ),
+ rSubTotalData ( ((const ScSubTotalItem&)
+ rArgSet.Get( nWhichSubTotals )).
+ GetSubTotalData() )
+{
+ Init();
+ FreeResource();
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT ScTpSubTotalOptions::~ScTpSubTotalOptions()
+{
+}
+
+// -----------------------------------------------------------------------
+
+void ScTpSubTotalOptions::Init()
+{
+ const ScSubTotalItem& rSubTotalItem = (const ScSubTotalItem&)
+ GetItemSet().Get( nWhichSubTotals );
+
+ pViewData = rSubTotalItem.GetViewData();
+ pDoc = ( pViewData ) ? pViewData->GetDocument() : NULL;
+
+ DBG_ASSERT( pViewData && pDoc, "ViewData oder Document nicht gefunden!" );
+
+ aBtnSort.SetClickHdl ( LINK( this, ScTpSubTotalOptions, CheckHdl ) );
+ aBtnUserDef.SetClickHdl ( LINK( this, ScTpSubTotalOptions, CheckHdl ) );
+
+ FillUserSortListBox();
+}
+
+// -----------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScTpSubTotalOptions::Create( Window* pParent,
+ const SfxItemSet& rArgSet )
+{
+ return ( new ScTpSubTotalOptions( pParent, rArgSet ) );
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScTpSubTotalOptions::Reset( const SfxItemSet& /* rArgSet */ )
+{
+ aBtnPagebreak.Check ( rSubTotalData.bPagebreak );
+ aBtnCase.Check ( rSubTotalData.bCaseSens );
+ aBtnFormats.Check ( rSubTotalData.bIncludePattern );
+ aBtnSort.Check ( rSubTotalData.bDoSort );
+ aBtnAscending.Check ( rSubTotalData.bAscending );
+ aBtnDescending.Check( !rSubTotalData.bAscending );
+
+ if ( rSubTotalData.bUserDef )
+ {
+ aBtnUserDef.Check( TRUE );
+ aLbUserDef.Enable();
+ aLbUserDef.SelectEntryPos( rSubTotalData.nUserIndex );
+ }
+ else
+ {
+ aBtnUserDef.Check( FALSE );
+ aLbUserDef.Disable();
+ aLbUserDef.SelectEntryPos( 0 );
+ }
+
+ CheckHdl( &aBtnSort );
+}
+
+// -----------------------------------------------------------------------
+
+BOOL __EXPORT ScTpSubTotalOptions::FillItemSet( SfxItemSet& rArgSet )
+{
+ ScSubTotalParam theSubTotalData; // auslesen, wenn schon teilweise gefuellt
+ SfxTabDialog* pDlg = GetTabDialog();
+ if ( pDlg )
+ {
+ const SfxItemSet* pExample = pDlg->GetExampleSet();
+ const SfxPoolItem* pItem;
+ if ( pExample && pExample->GetItemState( nWhichSubTotals, TRUE, &pItem ) == SFX_ITEM_SET )
+ theSubTotalData = ((const ScSubTotalItem*)pItem)->GetSubTotalData();
+ }
+
+ theSubTotalData.bPagebreak = aBtnPagebreak.IsChecked();
+ theSubTotalData.bReplace = TRUE;
+ theSubTotalData.bCaseSens = aBtnCase.IsChecked();
+ theSubTotalData.bIncludePattern = aBtnFormats.IsChecked();
+ theSubTotalData.bDoSort = aBtnSort.IsChecked();
+ theSubTotalData.bAscending = aBtnAscending.IsChecked();
+ theSubTotalData.bUserDef = aBtnUserDef.IsChecked();
+ theSubTotalData.nUserIndex = (aBtnUserDef.IsChecked())
+ ? aLbUserDef.GetSelectEntryPos()
+ : 0;
+
+ rArgSet.Put( ScSubTotalItem( nWhichSubTotals, &theSubTotalData ) );
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+void ScTpSubTotalOptions::FillUserSortListBox()
+{
+ ScUserList* pUserLists = ScGlobal::GetUserList();
+
+ aLbUserDef.Clear();
+ if ( pUserLists )
+ {
+ USHORT nCount = pUserLists->GetCount();
+ if ( nCount > 0 )
+ for ( USHORT i=0; i<nCount; i++ )
+ aLbUserDef.InsertEntry( (*pUserLists)[i]->GetString() );
+ }
+}
+
+// -----------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScTpSubTotalOptions, CheckHdl, CheckBox *, pBox )
+{
+ if ( pBox == &aBtnSort )
+ {
+ if ( aBtnSort.IsChecked() )
+ {
+ aFlSort .Enable();
+ aBtnFormats .Enable();
+ aBtnUserDef .Enable();
+ aBtnAscending .Enable();
+ aBtnDescending .Enable();
+
+ if ( aBtnUserDef.IsChecked() )
+ aLbUserDef.Enable();
+ }
+ else
+ {
+ aFlSort .Disable();
+ aBtnFormats .Disable();
+ aBtnUserDef .Disable();
+ aBtnAscending .Disable();
+ aBtnDescending .Disable();
+ aLbUserDef .Disable();
+ }
+ }
+ else if ( pBox == &aBtnUserDef )
+ {
+ if ( aBtnUserDef.IsChecked() )
+ {
+ aLbUserDef.Enable();
+ aLbUserDef.GrabFocus();
+ }
+ else
+ aLbUserDef.Disable();
+ }
+
+ return 0;
+}
+
+__EXPORT ScTpSubTotalGroup1::~ScTpSubTotalGroup1()
+{
+}
+
+__EXPORT ScTpSubTotalGroup2::~ScTpSubTotalGroup2()
+{
+}
+
+__EXPORT ScTpSubTotalGroup3::~ScTpSubTotalGroup3()
+{
+}
+
diff --git a/sc/source/ui/dbgui/validate.cxx b/sc/source/ui/dbgui/validate.cxx
new file mode 100644
index 000000000000..1ee02badefe1
--- /dev/null
+++ b/sc/source/ui/dbgui/validate.cxx
@@ -0,0 +1,1021 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#ifdef SC_DLLIMPLEMENTATION
+#undef SC_DLLIMPLEMENTATION
+#endif
+
+#include <vcl/svapp.hxx>
+#include <svl/aeitem.hxx>
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+#include <basic/sbmeth.hxx>
+#include <basic/sbstar.hxx>
+#include <basic/sbmod.hxx>
+#include <sfx2/app.hxx>
+
+#include "scresid.hxx"
+#include "sc.hrc" // -> Slot IDs
+
+#include "validat.hxx"
+#include "validate.hrc"
+#include "validate.hxx"
+#include "compiler.hxx"
+#include "formula/opcode.hxx" //CHINA001
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+#include "tabvwsh.hxx"
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/childwin.hxx>
+#include "reffact.hxx"
+//-->Added by PengYunQuan for Validity Cell Range Picker
+
+// ============================================================================
+
+static USHORT pValueRanges[] =
+{
+ FID_VALID_MODE, FID_VALID_ERRTEXT,
+ FID_VALID_LISTTYPE, FID_VALID_LISTTYPE,
+ 0
+};
+
+
+// ============================================================================
+
+//<!--Modified by PengYunQuan for Validity Cell Range Picker
+//ScValidationDlg::ScValidationDlg( Window* pParent, const SfxItemSet* pArgSet ) :
+// SfxTabDialog( pParent, ScResId( TAB_DLG_VALIDATION ), pArgSet )
+ScValidationDlg::ScValidationDlg( Window* pParent,
+ const SfxItemSet* pArgSet,
+ ScTabViewShell *pTabViewSh,
+ SfxBindings *pB /*= NULL*/
+ ) :
+ ScValidationDlgBase( pParent ? pParent : SFX_APP()->GetTopWindow(), TAB_DLG_VALIDATION, pArgSet, pB ),
+ m_bOwnRefHdlr( false ),
+ m_pTabVwSh( pTabViewSh ),
+ m_bRefInputting( false )
+//-->Modified by PengYunQuan for Validity Cell Range Picker
+{
+ AddTabPage( TP_VALIDATION_VALUES, ScTPValidationValue::Create, 0 );
+ AddTabPage( TP_VALIDATION_INPUTHELP, ScTPValidationHelp::Create, 0 );
+ AddTabPage( TP_VALIDATION_ERROR, ScTPValidationError::Create, 0 );
+ FreeResource();
+}
+
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+void ScTPValidationValue::SetReferenceHdl( const ScRange&rRange , ScDocument* pDoc )
+{
+ if ( rRange.aStart != rRange.aEnd )
+ if ( ScValidationDlg *pValidationDlg = GetValidationDlg() )
+ if( m_pRefEdit )
+ pValidationDlg/*->GetRefHandler()*/->RefInputStart( m_pRefEdit );
+
+ if ( m_pRefEdit )
+ {
+ String aStr;
+ rRange.Format( aStr, SCR_ABS_3D, pDoc );
+ m_pRefEdit->SetRefString( aStr );
+ //m_pRefEdit->SetRefString( rRange.aStart != rRange.aEnd ? aStr : String::CreateFromAscii("=").Append( aStr ) );
+ }
+}
+
+void ScTPValidationValue:: SetActiveHdl()
+{
+ if ( m_pRefEdit ) m_pRefEdit->GrabFocus();
+
+ if ( ScValidationDlg *pValidationDlg = GetValidationDlg() )
+ if( m_pRefEdit )
+ {
+ pValidationDlg/*->GetRefHandler()*/->RefInputDone();
+ }
+}
+
+void ScTPValidationValue::RefInputStartPreHdl( ScRefEdit* pEdit, ScRefButton* pButton )
+{
+ if ( ScValidationDlg *pValidationDlg = GetValidationDlg() )
+ {
+ if( pEdit == m_pRefEdit )
+ {
+ if( Window *pPreWnd = pEdit==&maEdMax?&maFtMax:(pEdit==&maEdMin?&maFtMin:NULL) )
+ {
+ pPreWnd->SetParent( pValidationDlg );
+ pPreWnd->Hide();
+ }
+
+ m_pRefEdit->SetParent( pValidationDlg );
+ }
+
+ if( pButton == &m_btnRef )m_btnRef.SetParent( pValidationDlg );
+ }
+}
+
+void ScTPValidationValue::RefInputDonePreHdl()
+{
+
+ if( m_pRefEdit && m_pRefEdit->GetParent()!= this )
+ {
+ if( Window *pPreWnd = m_pRefEdit==&maEdMax?&maFtMax:(m_pRefEdit==&maEdMin?&maFtMin:NULL) )
+ {
+ pPreWnd->SetParent( this );
+ pPreWnd->Show();
+ }
+
+ m_pRefEdit->SetParent( this );
+
+ m_btnRef.SetParent( m_pRefEdit ); //if Edit SetParent but button not, the tab order will be incorrect, need button to setparent to anthor window and restore parent later in order to restore the tab order
+// aExample1.SetParent( m_pRefEdit ); // the aExample1's child order will affect acc key
+ }
+
+ if( m_btnRef.GetParent()!=this ) m_btnRef.SetParent( this );
+// if( aExample1.GetParent()!=this ) aExample1.SetParent( this );
+}
+
+void ScTPValidationValue::RefInputDonePostHdl()
+{
+
+
+ if( m_pRefEdit && !m_pRefEdit->HasFocus() )
+ m_pRefEdit->GrabFocus();
+
+}
+
+
+BOOL ScValidationDlg::Close()
+{
+ if( m_bOwnRefHdlr )
+ if( SfxTabPage* pPage = GetTabPage( TP_VALIDATION_VALUES ) )
+ static_cast<ScTPValidationValue*>(pPage)->RemoveRefDlg();
+
+ return ScValidationDlgBase::Close();
+}
+//-->Added by PengYunQuan for Validity Cell Range Picker
+
+ScValidationDlg::~ScValidationDlg()
+{
+ //<!--Added by PengYunQuan for Validity Cell Range Picker
+ if( m_bOwnRefHdlr )
+ RemoveRefDlg( FALSE );
+ //-->Added by PengYunQuan for Validity Cell Range Picker
+}
+
+
+// ============================================================================
+
+namespace {
+
+/** Converts the passed ScValidationMode to the position in the list box. */
+USHORT lclGetPosFromValMode( ScValidationMode eValMode )
+{
+ USHORT nLbPos = SC_VALIDDLG_ALLOW_ANY;
+ switch( eValMode )
+ {
+ case SC_VALID_ANY: nLbPos = SC_VALIDDLG_ALLOW_ANY; break;
+ case SC_VALID_WHOLE: nLbPos = SC_VALIDDLG_ALLOW_WHOLE; break;
+ case SC_VALID_DECIMAL: nLbPos = SC_VALIDDLG_ALLOW_DECIMAL; break;
+ case SC_VALID_DATE: nLbPos = SC_VALIDDLG_ALLOW_DATE; break;
+ case SC_VALID_TIME: nLbPos = SC_VALIDDLG_ALLOW_TIME; break;
+ case SC_VALID_TEXTLEN: nLbPos = SC_VALIDDLG_ALLOW_TEXTLEN; break;
+ case SC_VALID_LIST: nLbPos = SC_VALIDDLG_ALLOW_RANGE; break;
+ case SC_VALID_CUSTOM: nLbPos = SC_VALIDDLG_ALLOW_ANY; break; // not supported
+ default: DBG_ERRORFILE( "lclGetPosFromValMode - unknown validity mode" );
+ }
+ return nLbPos;
+}
+
+/** Converts the passed list box position to an ScValidationMode. */
+ScValidationMode lclGetValModeFromPos( USHORT nLbPos )
+{
+ ScValidationMode eValMode = SC_VALID_ANY;
+ switch( nLbPos )
+ {
+ case SC_VALIDDLG_ALLOW_ANY: eValMode = SC_VALID_ANY; break;
+ case SC_VALIDDLG_ALLOW_WHOLE: eValMode = SC_VALID_WHOLE; break;
+ case SC_VALIDDLG_ALLOW_DECIMAL: eValMode = SC_VALID_DECIMAL; break;
+ case SC_VALIDDLG_ALLOW_DATE: eValMode = SC_VALID_DATE; break;
+ case SC_VALIDDLG_ALLOW_TIME: eValMode = SC_VALID_TIME; break;
+ case SC_VALIDDLG_ALLOW_RANGE: eValMode = SC_VALID_LIST; break;
+ case SC_VALIDDLG_ALLOW_LIST: eValMode = SC_VALID_LIST; break;
+ case SC_VALIDDLG_ALLOW_TEXTLEN: eValMode = SC_VALID_TEXTLEN; break;
+ default: DBG_ERRORFILE( "lclGetValModeFromPos - invalid list box position" );
+ }
+ return eValMode;
+}
+
+/** Converts the passed ScConditionMode to the position in the list box. */
+USHORT lclGetPosFromCondMode( ScConditionMode eCondMode )
+{
+ USHORT nLbPos = SC_VALIDDLG_DATA_EQUAL;
+ switch( eCondMode )
+ {
+ case SC_COND_NONE: // #111771# may occur in old XML files after Excel import
+ case SC_COND_EQUAL: nLbPos = SC_VALIDDLG_DATA_EQUAL; break;
+ case SC_COND_LESS: nLbPos = SC_VALIDDLG_DATA_LESS; break;
+ case SC_COND_GREATER: nLbPos = SC_VALIDDLG_DATA_GREATER; break;
+ case SC_COND_EQLESS: nLbPos = SC_VALIDDLG_DATA_EQLESS; break;
+ case SC_COND_EQGREATER: nLbPos = SC_VALIDDLG_DATA_EQGREATER; break;
+ case SC_COND_NOTEQUAL: nLbPos = SC_VALIDDLG_DATA_NOTEQUAL; break;
+ case SC_COND_BETWEEN: nLbPos = SC_VALIDDLG_DATA_BETWEEN; break;
+ case SC_COND_NOTBETWEEN: nLbPos = SC_VALIDDLG_DATA_NOTBETWEEN; break;
+ default: DBG_ERRORFILE( "lclGetPosFromCondMode - unknown condition mode" );
+ }
+ return nLbPos;
+}
+
+/** Converts the passed list box position to an ScConditionMode. */
+ScConditionMode lclGetCondModeFromPos( USHORT nLbPos )
+{
+ ScConditionMode eCondMode = SC_COND_EQUAL;
+ switch( nLbPos )
+ {
+ case SC_VALIDDLG_DATA_EQUAL: eCondMode = SC_COND_EQUAL; break;
+ case SC_VALIDDLG_DATA_LESS: eCondMode = SC_COND_LESS; break;
+ case SC_VALIDDLG_DATA_GREATER: eCondMode = SC_COND_GREATER; break;
+ case SC_VALIDDLG_DATA_EQLESS: eCondMode = SC_COND_EQLESS; break;
+ case SC_VALIDDLG_DATA_EQGREATER: eCondMode = SC_COND_EQGREATER; break;
+ case SC_VALIDDLG_DATA_NOTEQUAL: eCondMode = SC_COND_NOTEQUAL; break;
+ case SC_VALIDDLG_DATA_BETWEEN: eCondMode = SC_COND_BETWEEN; break;
+ case SC_VALIDDLG_DATA_NOTBETWEEN: eCondMode = SC_COND_NOTBETWEEN; break;
+ default: DBG_ERRORFILE( "lclGetCondModeFromPos - invalid list box position" );
+ }
+ return eCondMode;
+}
+
+/** Converts line feed separated string to a formula with strings separated by semicolons.
+ @descr Keeps all empty strings.
+ Example: abc\ndef\n\nghi -> "abc";"def";"";"ghi".
+ @param rFmlaStr (out-param) The converted formula string. */
+void lclGetFormulaFromStringList( String& rFmlaStr, const String& rStringList, sal_Unicode cFmlaSep )
+{
+ rFmlaStr.Erase();
+ xub_StrLen nTokenCnt = rStringList.GetTokenCount( '\n' );
+ for( xub_StrLen nToken = 0, nStringIx = 0; nToken < nTokenCnt; ++nToken )
+ {
+ String aToken( rStringList.GetToken( 0, '\n', nStringIx ) );
+ ScGlobal::AddQuotes( aToken, '"' );
+ ScGlobal::AddToken( rFmlaStr, aToken, cFmlaSep );
+ }
+ if( !rFmlaStr.Len() )
+ rFmlaStr.AssignAscii( "\"\"" );
+}
+
+
+/** Converts formula with strings separated by semicolons to line feed separated string.
+ @descr Keeps all empty strings. Ignores all empty tokens (multiple semicolons).
+ Example: "abc";;;"def";"";"ghi" -> abc\ndef\n\nghi.
+ @param rStringList (out-param) The converted line feed separated string list.
+ @return true = Conversion successful. */
+bool lclGetStringListFromFormula( String& rStringList, const String& rFmlaStr, sal_Unicode cFmlaSep )
+{
+ String aQuotes( RTL_CONSTASCII_USTRINGPARAM( "\"\"" ) );
+ xub_StrLen nTokenCnt = rFmlaStr.GetQuotedTokenCount( aQuotes, cFmlaSep );
+
+ rStringList.Erase();
+ bool bIsStringList = (nTokenCnt > 0);
+ bool bTokenAdded = false;
+
+ for( xub_StrLen nToken = 0, nStringIx = 0; bIsStringList && (nToken < nTokenCnt); ++nToken )
+ {
+ String aToken( rFmlaStr.GetQuotedToken( 0, aQuotes, cFmlaSep, nStringIx ) );
+ aToken.EraseLeadingAndTrailingChars();
+ if( aToken.Len() ) // ignore empty tokens, i.e. "a";;"b"
+ {
+ bIsStringList = ScGlobal::IsQuoted( aToken, '"' );
+ if( bIsStringList )
+ {
+ ScGlobal::EraseQuotes( aToken, '"' );
+ ScGlobal::AddToken( rStringList, aToken, '\n', 1, bTokenAdded );
+ bTokenAdded = true;
+ }
+ }
+ }
+
+ return bIsStringList;
+}
+
+} // namespace
+
+// ----------------------------------------------------------------------------
+
+ScTPValidationValue::ScTPValidationValue( Window* pParent, const SfxItemSet& rArgSet ) :
+ SfxTabPage( pParent, ScResId( TP_VALIDATION_VALUES ), rArgSet ),
+ maFtAllow ( this, ScResId( FT_ALLOW ) ),
+ maLbAllow ( this, ScResId( LB_ALLOW ) ),
+ maCbAllow ( this, ScResId( TSB_ALLOW_BLANKS ) ),
+ maCbShow ( this, ScResId( CB_SHOWLIST ) ),
+ maCbSort ( this, ScResId( CB_SORTLIST ) ),
+ maFtValue ( this, ScResId( FT_VALUE ) ),
+ maLbValue ( this, ScResId( LB_VALUE ) ),
+ maFtMin ( this, ScResId( FT_MIN ) ),
+ maEdMin ( this, ScResId( EDT_MIN ) ),
+ maEdList ( this, ScResId( EDT_LIST ) ),
+ maFtMax ( this, ScResId( FT_MAX ) ),
+ maEdMax ( this, ScResId( EDT_MAX ) ),
+ maFtHint ( this, ScResId( FT_SOURCEHINT ) ),
+ maStrMin ( ScResId( SCSTR_VALID_MINIMUM ) ),
+ maStrMax ( ScResId( SCSTR_VALID_MAXIMUM ) ),
+ maStrValue( ScResId( SCSTR_VALID_VALUE ) ),
+ maStrRange( ScResId( SCSTR_VALID_RANGE ) ),
+ maStrList ( ScResId( SCSTR_VALID_LIST ) ),
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+ m_btnRef( this, ScResId( RB_VALIDITY_REF ) )
+//-->Added by PengYunQuan for Validity Cell Range Picker
+{
+ Init();
+ FreeResource();
+
+ // list separator in formulas
+ //CHINA001 const String& rListSep = ScCompiler::pSymbolTableNative[ ocSep ];
+ String aListSep = ::GetScCompilerNativeSymbol( ocSep ); //CHINA001
+ DBG_ASSERT( aListSep.Len() == 1, "ScTPValidationValue::ScTPValidationValue - list separator error" );
+ mcFmlaSep = aListSep.Len() ? aListSep.GetChar( 0 ) : ';';
+ //<!--Added by PengYunQuan for Validity Cell Range Picker
+ m_btnRef.Hide();
+ //-->Added by PengYunQuan for Validity Cell Range Picker
+}
+
+ScTPValidationValue::~ScTPValidationValue()
+{
+}
+
+void ScTPValidationValue::Init()
+{
+ maLbAllow.SetSelectHdl( LINK( this, ScTPValidationValue, SelectHdl ) );
+ maLbValue.SetSelectHdl( LINK( this, ScTPValidationValue, SelectHdl ) );
+ maCbShow.SetClickHdl( LINK( this, ScTPValidationValue, CheckHdl ) );
+ //<!--Added by PengYunQuan for Validity Cell Range Picker
+ maEdMin.SetGetFocusHdl( LINK( this, ScTPValidationValue, EditSetFocusHdl ) );
+ maEdMin.SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) );
+ maEdMax.SetGetFocusHdl( LINK( this, ScTPValidationValue, EditSetFocusHdl ) );
+ m_btnRef.SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) );
+ maEdMax.SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) );
+ //-->Added by PengYunQuan for Validity Cell Range Picker
+
+ maLbAllow.SelectEntryPos( SC_VALIDDLG_ALLOW_ANY );
+ maLbValue.SelectEntryPos( SC_VALIDDLG_DATA_EQUAL );
+
+ SelectHdl( NULL );
+ CheckHdl( NULL );
+}
+
+SfxTabPage* ScTPValidationValue::Create( Window* pParent, const SfxItemSet& rArgSet )
+{
+ return( new ScTPValidationValue( pParent, rArgSet ) );
+}
+
+USHORT* ScTPValidationValue::GetRanges()
+{
+ return pValueRanges;
+}
+
+void ScTPValidationValue::Reset( const SfxItemSet& rArgSet )
+{
+ const SfxPoolItem* pItem;
+
+ USHORT nLbPos = SC_VALIDDLG_ALLOW_ANY;
+ if( rArgSet.GetItemState( FID_VALID_MODE, TRUE, &pItem ) == SFX_ITEM_SET )
+ nLbPos = lclGetPosFromValMode( static_cast< ScValidationMode >(
+ static_cast< const SfxAllEnumItem* >( pItem )->GetValue() ) );
+ maLbAllow.SelectEntryPos( nLbPos );
+
+ nLbPos = SC_VALIDDLG_DATA_EQUAL;
+ if( rArgSet.GetItemState( FID_VALID_CONDMODE, TRUE, &pItem ) == SFX_ITEM_SET )
+ nLbPos = lclGetPosFromCondMode( static_cast< ScConditionMode >(
+ static_cast< const SfxAllEnumItem* >( pItem )->GetValue() ) );
+ maLbValue.SelectEntryPos( nLbPos );
+
+ // *** check boxes ***
+ BOOL bCheck = TRUE;
+ if( rArgSet.GetItemState( FID_VALID_BLANK, TRUE, &pItem ) == SFX_ITEM_SET )
+ bCheck = static_cast< const SfxBoolItem* >( pItem )->GetValue();
+ maCbAllow.Check( bCheck );
+
+ sal_Int32 nListType = ValidListType::UNSORTED;
+ if( rArgSet.GetItemState( FID_VALID_LISTTYPE, TRUE, &pItem ) == SFX_ITEM_SET )
+ nListType = static_cast< const SfxInt16Item* >( pItem )->GetValue();
+ maCbShow.Check( nListType != ValidListType::INVISIBLE );
+ maCbSort.Check( nListType == ValidListType::SORTEDASCENDING );
+
+ // *** formulas ***
+ String aFmlaStr;
+ if ( rArgSet.GetItemState( FID_VALID_VALUE1, TRUE, &pItem ) == SFX_ITEM_SET )
+ aFmlaStr = static_cast< const SfxStringItem* >( pItem )->GetValue();
+ SetFirstFormula( aFmlaStr );
+
+ aFmlaStr.Erase();
+ if ( rArgSet.GetItemState( FID_VALID_VALUE2, TRUE, &pItem ) == SFX_ITEM_SET )
+ aFmlaStr = static_cast< const SfxStringItem* >( pItem )->GetValue();
+ SetSecondFormula( aFmlaStr );
+
+ SelectHdl( NULL );
+ CheckHdl( NULL );
+}
+
+BOOL ScTPValidationValue::FillItemSet( SfxItemSet& rArgSet )
+{
+ sal_Int16 nListType = maCbShow.IsChecked() ?
+ (maCbSort.IsChecked() ? ValidListType::SORTEDASCENDING : ValidListType::UNSORTED) :
+ ValidListType::INVISIBLE;
+
+ rArgSet.Put( SfxAllEnumItem( FID_VALID_MODE, sal::static_int_cast<USHORT>(
+ lclGetValModeFromPos( maLbAllow.GetSelectEntryPos() ) ) ) );
+ rArgSet.Put( SfxAllEnumItem( FID_VALID_CONDMODE, sal::static_int_cast<USHORT>(
+ lclGetCondModeFromPos( maLbValue.GetSelectEntryPos() ) ) ) );
+ rArgSet.Put( SfxStringItem( FID_VALID_VALUE1, GetFirstFormula() ) );
+ rArgSet.Put( SfxStringItem( FID_VALID_VALUE2, GetSecondFormula() ) );
+ rArgSet.Put( SfxBoolItem( FID_VALID_BLANK, maCbAllow.IsChecked() ) );
+ rArgSet.Put( SfxInt16Item( FID_VALID_LISTTYPE, nListType ) );
+ return TRUE;
+}
+
+String ScTPValidationValue::GetFirstFormula() const
+{
+ String aFmlaStr;
+ if( maLbAllow.GetSelectEntryPos() == SC_VALIDDLG_ALLOW_LIST )
+ lclGetFormulaFromStringList( aFmlaStr, maEdList.GetText(), mcFmlaSep );
+ else
+ aFmlaStr = maEdMin.GetText();
+ return aFmlaStr;
+}
+
+String ScTPValidationValue::GetSecondFormula() const
+{
+ return maEdMax.GetText();
+}
+
+void ScTPValidationValue::SetFirstFormula( const String& rFmlaStr )
+{
+ // try if formula is a string list, validation mode must already be set
+ String aStringList;
+ if( (maLbAllow.GetSelectEntryPos() == SC_VALIDDLG_ALLOW_RANGE) &&
+ lclGetStringListFromFormula( aStringList, rFmlaStr, mcFmlaSep ) )
+ {
+ maEdList.SetText( aStringList );
+ maEdMin.SetText( EMPTY_STRING );
+ // change validation mode to string list
+ maLbAllow.SelectEntryPos( SC_VALIDDLG_ALLOW_LIST );
+ }
+ else
+ {
+ maEdMin.SetText( rFmlaStr );
+ maEdList.SetText( EMPTY_STRING );
+ }
+}
+
+void ScTPValidationValue::SetSecondFormula( const String& rFmlaStr )
+{
+ maEdMax.SetText( rFmlaStr );
+}
+
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+ScValidationDlg * ScTPValidationValue::GetValidationDlg()
+{
+ if( Window *pParent = GetParent() )
+ do{
+ if ( dynamic_cast<ScValidationDlg*>( pParent ) )
+ return static_cast< ScValidationDlg * >( pParent );
+ }while ( NULL != ( pParent = pParent->GetParent() ) );
+ return NULL;
+}
+void ScTPValidationValue::SetupRefDlg()
+{
+ if( ScValidationDlg *pValidationDlg = GetValidationDlg() )
+ if( pValidationDlg->SetupRefDlg() )
+ {
+ pValidationDlg->SetHandler( this );
+ pValidationDlg->SetSetRefHdl( (ScRefHandlerHelper::PFUNCSETREFHDLTYPE)( &ScTPValidationValue::SetReferenceHdl ) );
+ pValidationDlg->SetSetActHdl( (ScRefHandlerHelper::PCOMMONHDLTYPE)( &ScTPValidationValue::SetActiveHdl ) );
+ pValidationDlg->SetRefInputStartPreHdl( (ScRefHandlerHelper::PINPUTSTARTDLTYPE)( &ScTPValidationValue::RefInputStartPreHdl ) );
+ pValidationDlg->SetRefInputDonePreHdl( (ScRefHandlerHelper::PCOMMONHDLTYPE)( &ScTPValidationValue::RefInputDonePreHdl ) );
+ pValidationDlg->SetRefInputDonePostHdl( (ScRefHandlerHelper::PCOMMONHDLTYPE)( &ScTPValidationValue::RefInputDonePostHdl ) );
+
+ if ( maEdMax.IsVisible() ) { m_pRefEdit = &maEdMax; }
+ else if ( maEdMin.IsVisible() ) { m_pRefEdit = &maEdMin; }
+
+ if( m_pRefEdit && !m_pRefEdit->HasFocus() ) m_pRefEdit->GrabFocus();
+
+ if( m_pRefEdit ) m_pRefEdit->SetRefDialog( pValidationDlg );
+ m_btnRef.SetReferences( pValidationDlg, m_pRefEdit );
+ }
+}
+
+void ScTPValidationValue::RemoveRefDlg()
+{
+ if( ScValidationDlg *pValidationDlg = GetValidationDlg() )
+ if( pValidationDlg->RemoveRefDlg() )
+ {
+ pValidationDlg->SetHandler( NULL );
+ pValidationDlg->SetSetRefHdl( NULL );
+ pValidationDlg->SetSetActHdl( NULL );
+ pValidationDlg->SetRefInputStartPreHdl( NULL );
+ pValidationDlg->SetRefInputDonePreHdl( NULL );
+ pValidationDlg->SetRefInputDonePostHdl( NULL );
+
+ if( m_pRefEdit ) m_pRefEdit->SetRefDialog( NULL );
+ m_pRefEdit = NULL;
+
+ m_btnRef.SetReferences( NULL, NULL );
+
+#if ! defined( WNT ) && !defined( _MSC_VER )
+ TidyListBoxes();
+#endif
+ }
+}
+
+void ScTPValidationValue::TidyListBoxes()
+{
+ if ( Window *pWnd = GetChild( 0 ) )
+ {
+ bool bFindLst = false;
+ std::list<Window*> alstOrder;
+
+ do{
+ if( pWnd->GetParent() == this )
+ {
+ if ( !bFindLst )
+ {
+ try{
+ if( dynamic_cast<ListBox*>(pWnd)||dynamic_cast<ListBox*>(pWnd->GetWindow(WINDOW_CLIENT) ) )
+ bFindLst = true;
+ }
+ catch( ... )
+ {
+ if ( *(void**)pWnd == *(void**)&maLbValue )
+ bFindLst = true;
+ else if ( Window *pClient = pWnd->GetWindow( WINDOW_CLIENT ) )
+ if ( *(void**)pClient == *(void**)&maLbValue )
+ bFindLst = true;
+ }
+ }
+
+ if ( bFindLst )
+ alstOrder.push_back( pWnd->GetWindow( WINDOW_CLIENT ) );
+ }
+ }while( NULL != ( pWnd = pWnd->GetWindow( WINDOW_NEXT ) ) );
+
+ pWnd = GetChild(0);
+
+ while( std::find( alstOrder.begin(), alstOrder.end(), pWnd ) != alstOrder.end() && NULL != ( pWnd = pWnd->GetWindow( WINDOW_NEXT) ) ) ;
+
+ if ( pWnd )
+ {
+ for ( std::list<Window*>::iterator i = alstOrder.begin(); i!=alstOrder.end(); i++ )
+ {
+ Window *pParent = (*i)->GetParent();
+ (*i)->SetParent( pWnd );
+ (*i)->SetParent( pParent );
+ }
+ }
+ }
+}
+
+IMPL_LINK( ScTPValidationValue, EditSetFocusHdl, Edit *, /*pEdit*/ )
+{
+ USHORT nPos=maLbAllow.GetSelectEntryPos();
+
+ if ( nPos == SC_VALIDDLG_ALLOW_RANGE )
+ {
+ SetupRefDlg();
+ }
+
+ return 0;
+}
+
+IMPL_LINK( ScTPValidationValue, KillFocusHdl, Window *, pWnd )
+{
+ if( pWnd == m_pRefEdit || pWnd == &m_btnRef )
+ if( ScValidationDlg *pValidationDlg = GetValidationDlg() )
+ if ( (pValidationDlg->IsActive() || pValidationDlg->IsChildFocus() ) && !pValidationDlg->IsRefInputting() )
+ if( ( !m_pRefEdit || !m_pRefEdit->HasFocus()) && !m_btnRef.HasFocus() )
+ {
+ RemoveRefDlg();
+ }
+
+ return 0;
+}
+//-->Added by PengYunQuan for Validity Cell Range Picker
+
+// ----------------------------------------------------------------------------
+
+IMPL_LINK( ScTPValidationValue, SelectHdl, ListBox*, EMPTYARG )
+{
+ USHORT nLbPos = maLbAllow.GetSelectEntryPos();
+ bool bEnable = (nLbPos != SC_VALIDDLG_ALLOW_ANY);
+ bool bRange = (nLbPos == SC_VALIDDLG_ALLOW_RANGE);
+ bool bList = (nLbPos == SC_VALIDDLG_ALLOW_LIST);
+
+ maCbAllow.Enable( bEnable ); // Leerzellen
+ maFtValue.Enable( bEnable );
+ maLbValue.Enable( bEnable );
+ maFtMin.Enable( bEnable );
+ maEdMin.Enable( bEnable );
+ maEdList.Enable( bEnable );
+ maFtMax.Enable( bEnable );
+ maEdMax.Enable( bEnable );
+
+ bool bShowMax = false;
+ if( bRange )
+ maFtMin.SetText( maStrRange );
+ else if( bList )
+ maFtMin.SetText( maStrList );
+ else
+ {
+ switch( maLbValue.GetSelectEntryPos() )
+ {
+ case SC_VALIDDLG_DATA_EQUAL:
+ case SC_VALIDDLG_DATA_NOTEQUAL: maFtMin.SetText( maStrValue ); break;
+
+ case SC_VALIDDLG_DATA_LESS:
+ case SC_VALIDDLG_DATA_EQLESS: maFtMin.SetText( maStrMax ); break;
+
+ case SC_VALIDDLG_DATA_BETWEEN:
+ case SC_VALIDDLG_DATA_NOTBETWEEN: bShowMax = true; // fall through
+ case SC_VALIDDLG_DATA_GREATER:
+ case SC_VALIDDLG_DATA_EQGREATER: maFtMin.SetText( maStrMin ); break;
+
+ default:
+ DBG_ERRORFILE( "ScTPValidationValue::SelectHdl - unknown condition mode" );
+ }
+ }
+
+ maCbShow.Show( bRange || bList );
+ maCbSort.Show( bRange || bList );
+ maFtValue.Show( !bRange && !bList );
+ maLbValue.Show( !bRange && !bList );
+ maEdMin.Show( !bList );
+ maEdList.Show( bList );
+ maFtMax.Show( bShowMax );
+ maEdMax.Show( bShowMax );
+ maFtHint.Show( bRange );
+ //<!--Added by PengYunQuan for Validity Cell Range Picker
+ m_btnRef.Show( bRange );
+ //-->Added by PengYunQuan for Validity Cell Range Picker
+ return 0;
+}
+
+IMPL_LINK( ScTPValidationValue, CheckHdl, CheckBox*, EMPTYARG )
+{
+ maCbSort.Enable( maCbShow.IsChecked() );
+ return 0;
+}
+
+
+//========================================================================
+//========================================================================
+// Input Help Page
+
+ScTPValidationHelp::ScTPValidationHelp( Window* pParent,
+ const SfxItemSet& rArgSet )
+
+ : SfxTabPage ( pParent,
+ ScResId( TP_VALIDATION_INPUTHELP ),
+ rArgSet ),
+ aTsbHelp ( this, ScResId( TSB_HELP ) ),
+ aFlContent ( this, ScResId( FL_CONTENT ) ),
+ aFtTitle ( this, ScResId( FT_TITLE ) ),
+ aEdtTitle ( this, ScResId( EDT_TITLE ) ),
+ aFtInputHelp ( this, ScResId( FT_INPUTHELP ) ),
+ aEdInputHelp ( this, ScResId( EDT_INPUTHELP ) ),
+
+ mrArgSet ( rArgSet )
+{
+ Init();
+ FreeResource();
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT ScTPValidationHelp::~ScTPValidationHelp()
+{
+}
+
+// -----------------------------------------------------------------------
+
+void ScTPValidationHelp::Init()
+{
+ //aLb.SetSelectHdl( LINK( this, ScTPValidationHelp, SelectHdl ) );
+
+ aTsbHelp.EnableTriState( FALSE );
+}
+
+//------------------------------------------------------------------------
+
+USHORT* __EXPORT ScTPValidationHelp::GetRanges()
+{
+ return pValueRanges;
+}
+
+// -----------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScTPValidationHelp::Create( Window* pParent,
+ const SfxItemSet& rArgSet )
+{
+ return ( new ScTPValidationHelp( pParent, rArgSet ) );
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScTPValidationHelp::Reset( const SfxItemSet& rArgSet )
+{
+ const SfxPoolItem* pItem;
+
+ if ( rArgSet.GetItemState( FID_VALID_SHOWHELP, TRUE, &pItem ) == SFX_ITEM_SET )
+ aTsbHelp.SetState( ((const SfxBoolItem*)pItem)->GetValue() ? STATE_CHECK : STATE_NOCHECK );
+ else
+ aTsbHelp.SetState( STATE_NOCHECK );
+
+ if ( rArgSet.GetItemState( FID_VALID_HELPTITLE, TRUE, &pItem ) == SFX_ITEM_SET )
+ aEdtTitle.SetText( ((const SfxStringItem*)pItem)->GetValue() );
+ else
+ aEdtTitle.SetText( EMPTY_STRING );
+
+ if ( rArgSet.GetItemState( FID_VALID_HELPTEXT, TRUE, &pItem ) == SFX_ITEM_SET )
+ aEdInputHelp.SetText( ((const SfxStringItem*)pItem)->GetValue() );
+ else
+ aEdInputHelp.SetText( EMPTY_STRING );
+}
+
+// -----------------------------------------------------------------------
+
+BOOL __EXPORT ScTPValidationHelp::FillItemSet( SfxItemSet& rArgSet )
+{
+ rArgSet.Put( SfxBoolItem( FID_VALID_SHOWHELP, aTsbHelp.GetState() == STATE_CHECK ) );
+ rArgSet.Put( SfxStringItem( FID_VALID_HELPTITLE, aEdtTitle.GetText() ) );
+ rArgSet.Put( SfxStringItem( FID_VALID_HELPTEXT, aEdInputHelp.GetText() ) );
+
+ return TRUE;
+}
+
+//========================================================================
+//========================================================================
+// Error Alert Page
+
+ScTPValidationError::ScTPValidationError( Window* pParent,
+ const SfxItemSet& rArgSet )
+
+ : SfxTabPage ( pParent,
+ ScResId( TP_VALIDATION_ERROR ),
+ rArgSet ),
+ aTsbShow ( this, ScResId( TSB_SHOW ) ),
+ aFlContent ( this, ScResId( FL_CONTENT ) ),
+ aFtAction ( this, ScResId( FT_ACTION ) ),
+ aLbAction ( this, ScResId( LB_ACTION ) ),
+ aBtnSearch ( this, ScResId( BTN_SEARCH ) ),
+ aFtTitle ( this, ScResId( FT_TITLE ) ),
+ aEdtTitle ( this, ScResId( EDT_TITLE ) ),
+ aFtError ( this, ScResId( FT_ERROR ) ),
+ aEdError ( this, ScResId( EDT_ERROR ) ),
+
+ mrArgSet ( rArgSet )
+{
+ Init();
+ FreeResource();
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT ScTPValidationError::~ScTPValidationError()
+{
+}
+
+// -----------------------------------------------------------------------
+
+void ScTPValidationError::Init()
+{
+ aLbAction.SetSelectHdl( LINK( this, ScTPValidationError, SelectActionHdl ) );
+ aBtnSearch.SetClickHdl( LINK( this, ScTPValidationError, ClickSearchHdl ) );
+
+ aLbAction.SelectEntryPos( 0 );
+ aTsbShow.EnableTriState( FALSE );
+
+ SelectActionHdl( NULL );
+}
+
+//------------------------------------------------------------------------
+
+USHORT* __EXPORT ScTPValidationError::GetRanges()
+{
+ return pValueRanges;
+}
+
+// -----------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScTPValidationError::Create( Window* pParent,
+ const SfxItemSet& rArgSet )
+{
+ return ( new ScTPValidationError( pParent, rArgSet ) );
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScTPValidationError::Reset( const SfxItemSet& rArgSet )
+{
+ const SfxPoolItem* pItem;
+
+ if ( rArgSet.GetItemState( FID_VALID_SHOWERR, TRUE, &pItem ) == SFX_ITEM_SET )
+ aTsbShow.SetState( ((const SfxBoolItem*)pItem)->GetValue() ? STATE_CHECK : STATE_NOCHECK );
+ else
+ aTsbShow.SetState( STATE_CHECK ); // #111720# check by default
+
+ if ( rArgSet.GetItemState( FID_VALID_ERRSTYLE, TRUE, &pItem ) == SFX_ITEM_SET )
+ aLbAction.SelectEntryPos( ((const SfxAllEnumItem*)pItem)->GetValue() );
+ else
+ aLbAction.SelectEntryPos( 0 );
+
+ if ( rArgSet.GetItemState( FID_VALID_ERRTITLE, TRUE, &pItem ) == SFX_ITEM_SET )
+ aEdtTitle.SetText( ((const SfxStringItem*)pItem)->GetValue() );
+ else
+ aEdtTitle.SetText( EMPTY_STRING );
+
+ if ( rArgSet.GetItemState( FID_VALID_ERRTEXT, TRUE, &pItem ) == SFX_ITEM_SET )
+ aEdError.SetText( ((const SfxStringItem*)pItem)->GetValue() );
+ else
+ aEdError.SetText( EMPTY_STRING );
+
+ SelectActionHdl( NULL );
+}
+
+// -----------------------------------------------------------------------
+
+BOOL __EXPORT ScTPValidationError::FillItemSet( SfxItemSet& rArgSet )
+{
+ rArgSet.Put( SfxBoolItem( FID_VALID_SHOWERR, aTsbShow.GetState() == STATE_CHECK ) );
+ rArgSet.Put( SfxAllEnumItem( FID_VALID_ERRSTYLE, aLbAction.GetSelectEntryPos() ) );
+ rArgSet.Put( SfxStringItem( FID_VALID_ERRTITLE, aEdtTitle.GetText() ) );
+ rArgSet.Put( SfxStringItem( FID_VALID_ERRTEXT, aEdError.GetText() ) );
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( ScTPValidationError, SelectActionHdl, ListBox*, EMPTYARG )
+{
+ ScValidErrorStyle eStyle = (ScValidErrorStyle) aLbAction.GetSelectEntryPos();
+ BOOL bMacro = ( eStyle == SC_VALERR_MACRO );
+
+ aBtnSearch.Enable( bMacro );
+ aFtError.Enable( !bMacro );
+ aEdError.Enable( !bMacro );
+
+ return( 0L );
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( ScTPValidationError, ClickSearchHdl, PushButton*, EMPTYARG )
+{
+ Window* pOld = Application::GetDefDialogParent();
+ Application::SetDefDialogParent( this );
+
+ // Use static SfxApplication method to bring up selector dialog for
+ // choosing a script
+ ::rtl::OUString aScriptURL = SfxApplication::ChooseScript();
+
+ Application::SetDefDialogParent( pOld );
+
+ if ( aScriptURL != NULL && aScriptURL.getLength() != 0 )
+ {
+ aEdtTitle.SetText( aScriptURL );
+ }
+
+ return( 0L );
+}
+
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+bool ScValidationDlg::EnterRefStatus()
+{
+ ScTabViewShell *pTabViewShell = GetTabViewShell();
+
+ if( !pTabViewShell ) return false;
+
+ USHORT nId = SLOTID;
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ if ( pWnd && pWnd->GetWindow()!= this ) pWnd = NULL;
+
+ SC_MOD()->SetRefDialog( nId, pWnd ? FALSE : TRUE );
+
+ return true;
+}
+
+bool ScValidationDlg::LeaveRefStatus()
+{
+ ScTabViewShell *pTabViewShell = GetTabViewShell();
+
+ if( !pTabViewShell ) return false;
+
+ USHORT nId = SLOTID;
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ //SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+ if ( pViewFrm->GetChildWindow( nId ) )
+ {
+ DoClose( nId );
+ }
+ return true;
+}
+
+bool ScValidationDlg::SetupRefDlg()
+{
+ if ( m_bOwnRefHdlr ) return false;
+ if( EnterRefMode() )
+ {
+ SetModal( FALSE );
+ return /*SetChkShell( GetDocShell() ),*/ m_bOwnRefHdlr = true && EnterRefStatus();
+ }
+
+ return false;
+}
+
+bool ScValidationDlg::RemoveRefDlg( BOOL bRestoreModal /* = TRUE */ )
+{
+ bool bVisLock = false;
+ bool bFreeWindowLock = false;
+
+ ScTabViewShell *pTabVwSh = GetTabViewShell();
+
+ if( !pTabVwSh ) return false;
+
+ if ( SfxChildWindow* pWnd = pTabVwSh->GetViewFrame()->GetChildWindow( SID_VALIDITY_REFERENCE ) )
+ {
+ bVisLock = static_cast<ScValidityRefChildWin*>(pWnd)->LockVisible( true );
+ bFreeWindowLock = static_cast<ScValidityRefChildWin*>(pWnd)->LockFreeWindow( true );
+ }
+
+ if ( !m_bOwnRefHdlr ) return false;
+ if( LeaveRefStatus() && LeaveRefMode() )
+ {
+ m_bOwnRefHdlr = false;
+
+ if( bRestoreModal )
+ SetModal( TRUE );
+ }
+
+ if ( SfxChildWindow* pWnd = pTabVwSh->GetViewFrame()->GetChildWindow( SID_VALIDITY_REFERENCE ) )
+ {
+ static_cast<ScValidityRefChildWin*>(pWnd)->LockVisible( bVisLock );
+ static_cast<ScValidityRefChildWin*>(pWnd)->LockFreeWindow( bFreeWindowLock );
+ }
+
+ return true;
+}
+
+//TYPEINIT1( ScTPValidationValue, SfxTabPage )
+
+void ScTPValidationValue::ScRefButtonEx::Click()
+{
+ if( ScTPValidationValue *pParent = dynamic_cast< ScTPValidationValue*>( GetParent() ) )
+ pParent->OnClick( this );
+
+ ScRefButton::Click();
+}
+
+void ScTPValidationValue::OnClick( Button *pBtn )
+{
+ if( pBtn == &m_btnRef )
+ SetupRefDlg();
+}
+
+BOOL ScValidationDlg::IsChildFocus()
+{
+ if ( const Window *pWin = Application::GetFocusWindow() )
+ while( NULL != ( pWin = pWin->GetParent() ) )
+ if( pWin == this )
+ return TRUE;
+
+ return FALSE;
+}
+
+
+bool ScValidationDlg::IsAlive()
+{
+ return SC_MOD()->IsAliveRefDlg( SLOTID, this );
+}
+//-->Added by PengYunQuan for Validity Cell Range Picker
diff --git a/sc/source/ui/dbgui/validate.src b/sc/source/ui/dbgui/validate.src
new file mode 100644
index 000000000000..9f4b27fb9967
--- /dev/null
+++ b/sc/source/ui/dbgui/validate.src
@@ -0,0 +1,427 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "validate.hrc"
+
+
+TabDialog TAB_DLG_VALIDATION
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 289 , 176 ) ;
+ Moveable = TRUE ;
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = TP_VALIDATION_VALUES ;
+ PageResID = TP_VALIDATION_VALUES ;
+ Text [ en-US ] = "Criteria";
+ };
+ PageItem
+ {
+ Identifier = TP_VALIDATION_INPUTHELP ;
+ PageResID = TP_VALIDATION_INPUTHELP ;
+ Text [ en-US ] = "Input Help" ;
+ };
+ PageItem
+ {
+ Identifier = TP_VALIDATION_ERROR ;
+ PageResID = TP_VALIDATION_ERROR ;
+ Text [ en-US ] = "Error Alert" ;
+ };
+ };
+ };
+ Text [ en-US ] = "Validity" ;
+};
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+#define OFFSET_X 30
+//-->Added by PengYunQuan for Validity Cell Range Picker
+TabPage TP_VALIDATION_VALUES
+{
+ HelpID = "sc:TabPage:TP_VALIDATION_VALUES";
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ Text [ en-US ] = "Values" ;
+ FixedText FT_ALLOW
+ {
+ Pos = MAP_APPFONT ( 6 , 16 ) ;
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Size = MAP_APPFONT ( 70 , 8 ) ;
+ Size = MAP_APPFONT ( 70 - OFFSET_X , 8 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ Text [ en-US ] = "~Allow" ;
+ };
+ ListBox LB_ALLOW
+ {
+ HelpID = "sc:ListBox:TP_VALIDATION_VALUES:LB_ALLOW";
+ Border = TRUE ;
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Pos = MAP_APPFONT ( 80 , 14 ) ;
+ Pos = MAP_APPFONT ( 80 - OFFSET_X , 14 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ Size = MAP_APPFONT ( 90 , 80 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "All values" ; SC_VALIDDLG_ALLOW_ANY ; > ;
+ < "Whole Numbers" ; SC_VALIDDLG_ALLOW_WHOLE ; > ;
+ < "Decimal" ; SC_VALIDDLG_ALLOW_DECIMAL ; > ;
+ < "Date" ; SC_VALIDDLG_ALLOW_DATE ; > ;
+ < "Time" ; SC_VALIDDLG_ALLOW_TIME ; > ;
+ < "Cell range" ; SC_VALIDDLG_ALLOW_RANGE ; > ;
+ < "List" ; SC_VALIDDLG_ALLOW_LIST ; > ;
+ < "Text length" ; SC_VALIDDLG_ALLOW_TEXTLEN ; > ;
+ };
+ };
+ FixedText FT_VALUE
+ {
+ Pos = MAP_APPFONT ( 6 , 58 ) ;
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Size = MAP_APPFONT ( 70 , 8 ) ;
+ Size = MAP_APPFONT ( 70 - OFFSET_X , 8 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ Text [ en-US ] = "~Data" ;
+ };
+ ListBox LB_VALUE
+ {
+ HelpID = "sc:ListBox:TP_VALIDATION_VALUES:LB_VALUE";
+ Border = TRUE ;
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Pos = MAP_APPFONT ( 80 , 56 ) ;
+ Pos = MAP_APPFONT ( 80 - OFFSET_X , 56 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ Size = MAP_APPFONT ( 90 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ // Reihenfolge entspricht enum ScConditionMode
+ StringList [ en-US ] =
+ {
+ < "equal" ; SC_VALIDDLG_DATA_EQUAL ; > ;
+ < "less than" ; SC_VALIDDLG_DATA_LESS ; > ;
+ < "greater than" ; SC_VALIDDLG_DATA_GREATER ; > ;
+ < "less than or equal" ; SC_VALIDDLG_DATA_EQLESS ; > ;
+ < "greater than or equal to" ; SC_VALIDDLG_DATA_EQGREATER ; > ;
+ < "not equal" ; SC_VALIDDLG_DATA_NOTEQUAL ; > ;
+ < "between" ; SC_VALIDDLG_DATA_BETWEEN ; > ;
+ < "not between" ; SC_VALIDDLG_DATA_NOTBETWEEN ; > ;
+ };
+ };
+ FixedText FT_MIN
+ {
+ Pos = MAP_APPFONT ( 6 , 76 ) ;
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Size = MAP_APPFONT ( 70 , 8 ) ;
+ Size = MAP_APPFONT ( 70 - OFFSET_X , 8 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ Text [ en-US ] = "~Minimum" ;
+ };
+ Edit EDT_MIN
+ {
+ HelpID = "sc:Edit:TP_VALIDATION_VALUES:EDT_MIN";
+ Border = TRUE ;
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Pos = MAP_APPFONT ( 80 , 74 ) ;
+ //Size = MAP_APPFONT ( 174 , 12 ) ;
+ Pos = MAP_APPFONT ( 80 - OFFSET_X , 74 ) ;
+ Size = MAP_APPFONT ( 90 , 12 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ TabStop = TRUE ;
+ };
+ MultiLineEdit EDT_LIST
+ {
+ HelpID = "sc:MultiLineEdit:TP_VALIDATION_VALUES:EDT_LIST";
+ Border = TRUE ;
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Pos = MAP_APPFONT ( 80 , 74 ) ;
+ //Size = MAP_APPFONT ( 174 , 105 ) ;
+ Pos = MAP_APPFONT ( 80 - OFFSET_X , 74 ) ;
+ Size = MAP_APPFONT ( 174 + OFFSET_X , 105 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ VScroll = TRUE ;
+ IgnoreTab = TRUE ;
+ };
+ FixedText FT_MAX
+ {
+ Pos = MAP_APPFONT ( 6 , 92 ) ;
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Size = MAP_APPFONT ( 70 , 8 ) ;
+ Size = MAP_APPFONT ( 70 - OFFSET_X , 8 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ Text [ en-US ] = "Ma~ximum" ;
+ };
+ Edit EDT_MAX
+ {
+ HelpID = "sc:Edit:TP_VALIDATION_VALUES:EDT_MAX";
+ Border = TRUE ;
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Pos = MAP_APPFONT ( 80 , 90 ) ;
+ //Size = MAP_APPFONT ( 174 , 12 ) ;
+ Pos = MAP_APPFONT ( 80 - OFFSET_X , 90 ) ;
+ Size = MAP_APPFONT ( 90 , 12 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ TabStop = TRUE ;
+ };
+ CheckBox TSB_ALLOW_BLANKS
+ {
+ HelpID = "sc:CheckBox:TP_VALIDATION_VALUES:TSB_ALLOW_BLANKS";
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Pos = MAP_APPFONT ( 80 , 30 ) ;
+ Pos = MAP_APPFONT ( 80 - OFFSET_X , 30 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ Size = MAP_APPFONT ( 174 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Allow ~blank cells" ;
+ };
+ CheckBox CB_SHOWLIST
+ {
+ HelpID = "sc:CheckBox:TP_VALIDATION_VALUES:CB_SHOWLIST";
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Pos = MAP_APPFONT ( 80 , 44 ) ;
+ Pos = MAP_APPFONT ( 80 - OFFSET_X , 44 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ Size = MAP_APPFONT ( 174 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Show selection ~list" ;
+ };
+ CheckBox CB_SORTLIST
+ {
+ HelpID = "sc:CheckBox:TP_VALIDATION_VALUES:CB_SORTLIST";
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Pos = MAP_APPFONT ( 90 , 58 ) ;
+ Pos = MAP_APPFONT ( 90 - OFFSET_X , 58 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ Size = MAP_APPFONT ( 164 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Sor~t entries ascending" ;
+ };
+ FixedText FT_SOURCEHINT
+ {
+ Pos = MAP_APPFONT ( 80 , 90 ) ;
+ Size = MAP_APPFONT ( 174 , 64 ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "A valid source can only consist of a contiguous selection of rows and columns, or a formula that results in an area or array.";
+ };
+ //<!--Added by PengYunQuan for Validity Cell Range Picker
+ ImageButton RB_VALIDITY_REF
+ {
+ HelpID = "sc:ImageButton:TP_VALIDATION_VALUES:RB_VALIDITY_REF";
+ Pos = MAP_APPFONT ( 142 , 73 ) ;
+ Size = MAP_APPFONT ( 13 , 14 ) ;
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ //-->Added by PengYunQuan for Validity Cell Range Picker
+};
+
+TabPage TP_VALIDATION_INPUTHELP
+{
+ HelpID = "sc:TabPage:TP_VALIDATION_INPUTHELP";
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ Text = "Eingabehilfe" ;
+ TriStateBox TSB_HELP
+ {
+ HelpID = "sc:TriStateBox:TP_VALIDATION_INPUTHELP:TSB_HELP";
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 248 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Show input help when cell is selected" ;
+ };
+ FixedLine FL_CONTENT
+ {
+ Pos = MAP_APPFONT ( 6 , 22 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Contents" ;
+ };
+ FixedText FT_TITLE
+ {
+ Pos = MAP_APPFONT ( 12 , 35 ) ;
+ Size = MAP_APPFONT ( 64 , 8 ) ;
+ Text [ en-US ] = "~Title" ;
+ };
+ FixedText FT_INPUTHELP
+ {
+ Pos = MAP_APPFONT ( 12 , 53 ) ;
+ Size = MAP_APPFONT ( 64 , 8 ) ;
+ Text [ en-US ] = "~Input help" ;
+ };
+ Edit EDT_TITLE
+ {
+ HelpID = "sc:Edit:TP_VALIDATION_INPUTHELP:EDT_TITLE";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 80 , 33 ) ;
+ Size = MAP_APPFONT ( 171 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ MultiLineEdit EDT_INPUTHELP
+ {
+ HelpID = "sc:MultiLineEdit:TP_VALIDATION_INPUTHELP:EDT_INPUTHELP";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 80 , 51 ) ;
+ Size = MAP_APPFONT ( 171 , 128 ) ;
+ TabStop = TRUE ;
+ VScroll = TRUE ;
+ IgnoreTab = TRUE ;
+ };
+};
+
+TabPage TP_VALIDATION_ERROR
+{
+ HelpID = "sc:TabPage:TP_VALIDATION_ERROR";
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ FixedLine FL_CONTENT
+ {
+ Pos = MAP_APPFONT ( 6 , 22 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Contents" ;
+ };
+ TriStateBox TSB_SHOW
+ {
+ HelpID = "sc:TriStateBox:TP_VALIDATION_ERROR:TSB_SHOW";
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 248 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Show error ~message when invalid values are entered" ;
+ };
+ MultiLineEdit EDT_ERROR
+ {
+ HelpID = "sc:MultiLineEdit:TP_VALIDATION_ERROR:EDT_ERROR";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 80 , 69 ) ;
+ Size = MAP_APPFONT ( 171 , 110 ) ;
+ TabStop = TRUE ;
+ VScroll = TRUE ;
+ IgnoreTab = TRUE ;
+ };
+ Edit EDT_TITLE
+ {
+ HelpID = "sc:Edit:TP_VALIDATION_ERROR:EDT_TITLE";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 80 , 51 ) ;
+ Size = MAP_APPFONT ( 171 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_ERROR
+ {
+ Pos = MAP_APPFONT ( 12 , 71 ) ;
+ Size = MAP_APPFONT ( 64 , 8 ) ;
+ Text [ en-US ] = "~Error message" ;
+ };
+ FixedText FT_TITLE
+ {
+ Pos = MAP_APPFONT ( 12 , 53 ) ;
+ Size = MAP_APPFONT ( 64 , 8 ) ;
+ Text [ en-US ] = "~Title" ;
+ };
+ FixedText FT_ACTION
+ {
+ Pos = MAP_APPFONT ( 12 , 35 ) ;
+ Size = MAP_APPFONT ( 64 , 8 ) ;
+ Text [ en-US ] = "~Action" ;
+ };
+ ListBox LB_ACTION
+ {
+ HelpID = "sc:ListBox:TP_VALIDATION_ERROR:LB_ACTION";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 80 , 33 ) ;
+ Size = MAP_APPFONT ( 107 , 76 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ // Reihenfolge entspricht enum ScValidErrorStyle
+ StringList [ en-US ] =
+ {
+ < "Stop" ; Default ; > ;
+ < "Warning" ; Default ; > ;
+ < "Information" ; Default ; > ;
+ < "Macro" ; Default ; > ;
+ };
+ };
+ PushButton BTN_SEARCH
+ {
+ HelpID = "sc:PushButton:TP_VALIDATION_ERROR:BTN_SEARCH";
+ Pos = MAP_APPFONT ( 191 , 32 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Browse..." ;
+ };
+ Text [ en-US ] = "Error Alert" ;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+