You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by or...@apache.org on 2013/09/11 16:48:15 UTC
svn commit: r1521881 - in /openoffice/branches/AOO401: ./ main/ main/sc/inc/
main/sc/source/core/data/ main/sc/source/core/tool/
main/sc/source/ui/dbgui/ main/sc/source/ui/docshell/ main/sc/source/ui/inc/
main/sc/source/ui/navipi/ main/sc/source/ui/und...
Author: orw
Date: Wed Sep 11 14:48:14 2013
New Revision: 1521881
URL: http://svn.apache.org/r1521881
Log:
122862: adjust code for issue 12666 in order to solve regressions 122862, 122870, 122955, 123161 and 123163
For 12666 new internal database ranges have been introduced. The fix reduced its usage to the once needed
for the Auto Filter function. Standard Filter and Special Filter should be untouched now.
cherry-picked from trunk
Modified:
openoffice/branches/AOO401/ (props changed)
openoffice/branches/AOO401/main/ (props changed)
openoffice/branches/AOO401/main/sc/inc/dbcolect.hxx
openoffice/branches/AOO401/main/sc/inc/document.hxx
openoffice/branches/AOO401/main/sc/inc/global.hxx
openoffice/branches/AOO401/main/sc/inc/rangeutl.hxx
openoffice/branches/AOO401/main/sc/source/core/data/documen3.cxx
openoffice/branches/AOO401/main/sc/source/core/tool/dbcolect.cxx
openoffice/branches/AOO401/main/sc/source/core/tool/rangeutl.cxx
openoffice/branches/AOO401/main/sc/source/ui/dbgui/dbnamdlg.cxx
openoffice/branches/AOO401/main/sc/source/ui/dbgui/foptmgr.cxx
openoffice/branches/AOO401/main/sc/source/ui/docshell/dbdocfun.cxx
openoffice/branches/AOO401/main/sc/source/ui/docshell/docsh5.cxx
openoffice/branches/AOO401/main/sc/source/ui/inc/dbfunc.hxx
openoffice/branches/AOO401/main/sc/source/ui/inc/docsh.hxx
openoffice/branches/AOO401/main/sc/source/ui/navipi/content.cxx
openoffice/branches/AOO401/main/sc/source/ui/undo/undoutil.cxx
openoffice/branches/AOO401/main/sc/source/ui/view/cellsh2.cxx
openoffice/branches/AOO401/main/sc/source/ui/view/dbfunc.cxx
openoffice/branches/AOO401/main/sc/source/ui/view/tabvwshc.cxx
Propchange: openoffice/branches/AOO401/
------------------------------------------------------------------------------
Merged /openoffice/trunk:r1520602
Propchange: openoffice/branches/AOO401/main/
------------------------------------------------------------------------------
Merged /openoffice/trunk/main:r1520602
Modified: openoffice/branches/AOO401/main/sc/inc/dbcolect.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/inc/dbcolect.hxx?rev=1521881&r1=1521880&r2=1521881&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/inc/dbcolect.hxx (original)
+++ openoffice/branches/AOO401/main/sc/inc/dbcolect.hxx Wed Sep 11 14:48:14 2013
@@ -136,9 +136,11 @@ public:
void GetArea(SCTAB& rTab, SCCOL& rCol1, SCROW& rRow1, SCCOL& rCol2, SCROW& rRow2) const;
SC_DLLPUBLIC void GetArea(ScRange& rRange) const;
void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
- //If the name of DBData is started with "unnamed", it will be recognized as build in DBData
- sal_Bool IsBuildin();
- void MoveTo(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
+
+ bool IsInternalUnnamed() const;
+ bool IsInternalForAutoFilter() const;
+
+ void MoveTo(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
sal_Bool IsByRow() const { return bByRow; }
void SetByRow(sal_Bool bByR) { bByRow = bByR; }
sal_Bool HasHeader() const { return bHasHeader; }
@@ -216,9 +218,13 @@ public:
virtual short Compare(ScDataObject* pKey1, ScDataObject* pKey2) const;
virtual sal_Bool IsEqual(ScDataObject* pKey1, ScDataObject* pKey2) const;
ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly) const;
- ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
+ ScDBData* GetDBAtArea(
+ const SCTAB nTab,
+ const SCCOL nCol1,
+ const SCROW nRow1,
+ const SCCOL nCol2,
+ const SCROW nRow2 ) const;
ScDBData* GetFilterDBAtTable(SCTAB nTab) const;
- ScDBData* GetDBAtTable(SCTAB nTab, ScGetDBMode eMode) const;
sal_Bool SearchName( const String& rName, sal_uInt16& rIndex ) const;
Modified: openoffice/branches/AOO401/main/sc/inc/document.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/inc/document.hxx?rev=1521881&r1=1521880&r2=1521881&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/inc/document.hxx (original)
+++ openoffice/branches/AOO401/main/sc/inc/document.hxx Wed Sep 11 14:48:14 2013
@@ -505,10 +505,7 @@ public:
sal_Bool bStartOnly = sal_False) const;
ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
ScDBData* GetFilterDBAtTable(SCTAB nTab) const;
-//UNUSED2008-05 ScRangeData* GetRangeAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab,
-//UNUSED2008-05 sal_Bool bStartOnly = sal_False) const;
SC_DLLPUBLIC ScRangeData* GetRangeAtBlock( const ScRange& rBlock, String* pName=NULL ) const;
- ScDBData* GetDBAtTable(SCTAB nTab, ScGetDBMode eMode) const;
SC_DLLPUBLIC ScDPCollection* GetDPCollection();
ScDPObject* GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
@@ -1514,7 +1511,10 @@ public:
TypedScStrCollection& rStrings, sal_Bool bLimit = sal_False );
sal_Bool GetFormulaEntries( TypedScStrCollection& rStrings );
- sal_Bool HasAutoFilter( SCCOL nCol, SCROW nRow, SCTAB nTab );
+ sal_Bool HasAutoFilter(
+ const SCCOL nCol,
+ const SCROW nRow,
+ const SCTAB nTab );
SC_DLLPUBLIC sal_Bool HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
SCTAB nTab );
Modified: openoffice/branches/AOO401/main/sc/inc/global.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/inc/global.hxx?rev=1521881&r1=1521880&r2=1521881&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/inc/global.hxx (original)
+++ openoffice/branches/AOO401/main/sc/inc/global.hxx Wed Sep 11 14:48:14 2013
@@ -404,13 +404,10 @@ enum ScAnchorType // Verankerung ei
enum ScGetDBMode
{
- SC_DB_MAKE, // wenn noetig, "unbenannt" anlegen
- SC_DB_IMPORT, // wenn noetig, "Importx" anlegen
- SC_DB_OLD, // nicht neu anlegen
- SC_DB_MAKE_FILTER, // to create a new filter/sort/subtotal
- SC_DB_MAKE_SORT,
- SC_DB_MAKE_SUBTOTAL,
- SC_DB_OLD_FILTER //to find a existed filter
+ SC_DB_MAKE, // if needed create database range with name $STR_DB_NONAME
+ SC_DB_IMPORT, // if needed create database range with name $STR_DBNAME_IMPORT[X]
+ SC_DB_OLD, // do not create new database range, provide only existing one
+ SC_DB_MAKE_AUTOFILTER // if needed create database range with name $SC_DBNAME_UNNAMED[X]
};
/// For ScDBFunc::GetDBData()
Modified: openoffice/branches/AOO401/main/sc/inc/rangeutl.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/inc/rangeutl.hxx?rev=1521881&r1=1521880&r2=1521881&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/inc/rangeutl.hxx (original)
+++ openoffice/branches/AOO401/main/sc/inc/rangeutl.hxx Wed Sep 11 14:48:14 2013
@@ -302,7 +302,6 @@ private:
ScDBCollection* pDBCollection;
sal_Bool bFirstPass;
sal_uInt16 nPos;
- String aStrNoName;
public:
ScAreaNameIterator( ScDocument* pDoc );
Modified: openoffice/branches/AOO401/main/sc/source/core/data/documen3.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/source/core/data/documen3.cxx?rev=1521881&r1=1521880&r2=1521881&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/source/core/data/documen3.cxx (original)
+++ openoffice/branches/AOO401/main/sc/source/core/data/documen3.cxx Wed Sep 11 14:48:14 2013
@@ -192,13 +192,6 @@ ScDBData* ScDocument::GetDBAtArea(SCTAB
else
return NULL;
}
-ScDBData* ScDocument::GetDBAtTable(SCTAB nTab, ScGetDBMode eMode) const
-{
- if (pDBCollection)
- return pDBCollection->GetDBAtTable(nTab, eMode);
- else
- return NULL;
-}
ScDBData* ScDocument::GetFilterDBAtTable(SCTAB nTab) const
{
@@ -1296,10 +1289,12 @@ sal_Bool ScDocument::CreateQueryParam(SC
return sal_False;
}
-sal_Bool ScDocument::HasAutoFilter( SCCOL /*nCurCol*/, SCROW /*nCurRow*/, SCTAB nCurTab )
+sal_Bool ScDocument::HasAutoFilter(
+ const SCCOL nCurCol,
+ const SCROW nCurRow,
+ const SCTAB nCurTab )
{
- //ScDBData* pDBData = GetDBAtCursor( nCurCol, nCurRow, nCurTab );
- ScDBData* pDBData = GetDBAtTable(nCurTab, SC_DB_OLD_FILTER);
+ ScDBData* pDBData = GetDBAtCursor( nCurCol, nCurRow, nCurTab );
sal_Bool bHasAutoFilter = ( pDBData != NULL );
if ( pDBData )
Modified: openoffice/branches/AOO401/main/sc/source/core/tool/dbcolect.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/source/core/tool/dbcolect.cxx?rev=1521881&r1=1521880&r2=1521881&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/source/core/tool/dbcolect.cxx (original)
+++ openoffice/branches/AOO401/main/sc/source/core/tool/dbcolect.cxx Wed Sep 11 14:48:14 2013
@@ -691,11 +691,18 @@ ScDataObject* ScDBData::Clone() const
{
return new ScDBData(*this);
}
-sal_Bool ScDBData::IsBuildin()
+
+
+bool ScDBData::IsInternalUnnamed() const
{
- String aNoName = String::CreateFromAscii(SC_DBNAME_UNNAMED);
- String aBeginName = aName.Copy(0,22);
- return (sal_Bool)(!ScGlobal::GetpTransliteration()->compareString( aNoName, aBeginName ));
+ return GetName() == ScGlobal::GetRscString( STR_DB_NONAME );
+}
+
+bool ScDBData::IsInternalForAutoFilter() const
+{
+ const String aNoName = String::CreateFromAscii(SC_DBNAME_UNNAMED);
+ const String aBeginName = aName.Copy( 0, aNoName.Len() );
+ return aBeginName == aNoName;
}
//---------------------------------------------------------------------------------------
@@ -717,40 +724,50 @@ sal_Bool ScDBCollection::IsEqual(ScDataO
ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly) const
{
- ScDBData* pNoNameData = NULL;
- if (pItems)
- {
+ ScDBData* pInternalDBData = NULL;
+ if (pItems)
+ {
- for (sal_uInt16 i = 0; i < nCount; i++)
- if (((ScDBData*)pItems[i])->IsDBAtCursor(nCol, nRow, nTab, bStartOnly))
- {
- ScDBData* pDB = (ScDBData*)pItems[i];
- if ( pDB->IsBuildin() )
- pNoNameData = pDB;
- else
- return pDB;
- }
- }
- return pNoNameData; // "unbenannt" nur zurueck, wenn sonst nichts gefunden
+ for (sal_uInt16 i = 0; i < nCount; i++)
+ if (((ScDBData*)pItems[i])->IsDBAtCursor(nCol, nRow, nTab, bStartOnly))
+ {
+ ScDBData* pDB = (ScDBData*)pItems[i];
+ if ( pDB->IsInternalUnnamed()
+ || pDB->IsInternalForAutoFilter() )
+ {
+ pInternalDBData = pDB;
+ }
+ else
+ {
+ return pDB;
+ }
+ }
+ }
+ return pInternalDBData;
}
-ScDBData* ScDBCollection::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const
+ScDBData* ScDBCollection::GetDBAtArea(
+ const SCTAB nTab,
+ const SCCOL nCol1,
+ const SCROW nRow1,
+ const SCCOL nCol2,
+ const SCROW nRow2 ) const
{
- ScDBData* pNoNameData = NULL;
- if (pItems)
- {
-
- for (sal_uInt16 i = 0; i < nCount; i++)
- if (((ScDBData*)pItems[i])->IsDBAtArea(nTab, nCol1, nRow1, nCol2, nRow2))
- {
- ScDBData* pDB = (ScDBData*)pItems[i];
- if ( pDB->IsBuildin() )
- pNoNameData = pDB;
- else
- return pDB;
- }
- }
- return pNoNameData; // "unbenannt" nur zurueck, wenn sonst nichts gefunden
+ ScDBData* pInternalDBData = NULL;
+ if (pItems)
+ {
+ for (sal_uInt16 i = 0; i < nCount; i++)
+ if (((ScDBData*)pItems[i])->IsDBAtArea(nTab, nCol1, nRow1, nCol2, nRow2))
+ {
+ ScDBData* pDB = (ScDBData*)pItems[i];
+ if ( pDB->IsInternalUnnamed()
+ || pDB->IsInternalForAutoFilter() )
+ pInternalDBData = pDB;
+ else
+ return pDB;
+ }
+ }
+ return pInternalDBData;
}
ScDBData* ScDBCollection::GetFilterDBAtTable(SCTAB nTab) const
@@ -920,54 +937,3 @@ String ScDBCollection::GetNewDefaultDBNa
}while(SearchName(aNewName,nDummy));
return aNewName;
}
-/*
-sal_Bool ScDBCollection::IsFiltered(SCTAB nTab, SCROW nRow)
-{
- SCCOL nLastCol;
- SCROW nLastRow;
- pDoc->GetLastAttrCellArea(nTab, nLastCol, nLastRow);
-
- if ( pItems )
- {
- for (unsigned short i = 0; i < nCount; i++)
- {
- ScDBData* pData = (ScDBData*)pItems[i];
- if ( pData->nTable == nTab && pData->HasQueryParam() && pData->bQueryInplace )
- if ( nRow >= (pData->nStartRow + (pData->HasHeader()?1:0)) && nRow <= pData->nEndRow && nRow <= nLastRow )
- return sal_True;
- }
- }
- return sal_False;
-}
-*/
-ScDBData* ScDBCollection::GetDBAtTable(SCTAB nTab, ScGetDBMode eMode) const
-{
- ScDBData* pDataEmpty = NULL;
- if (pItems)
- {
- for (unsigned short i = 0; i < nCount; i++)
- {
- ScDBData* pDBTemp = (ScDBData*)pItems[i];
- if ( pDBTemp->nTable == nTab ) //Sym2_7885 mod
- {
- sal_Bool bImport = pDBTemp->HasImportParam();
- sal_Bool bFilter = pDBTemp->HasAutoFilter() || pDBTemp->HasQueryParam();
- sal_Bool bSort = pDBTemp->HasSortParam();
- sal_Bool bSubtotal = pDBTemp->HasSubTotalParam();
- sal_Bool bAnyParam = bImport || bFilter || bSort || bSubtotal;
- if ( ((eMode == SC_DB_MAKE_SORT) && bSort && !bFilter) || //Sym2_7334 mod 20100420
- ((eMode == SC_DB_MAKE_SUBTOTAL) && bSubtotal && !bFilter ) ||
- ((eMode == SC_DB_MAKE_FILTER || eMode == SC_DB_OLD_FILTER) && bFilter ) )
- {
- return pDBTemp;
- }
- else if ( pDBTemp->IsBuildin() && !bAnyParam ) //Sym2_7885 mod
- {
- pDataEmpty = pDBTemp;
- }
- }
- }
- }
-
- return pDataEmpty;
-}
Modified: openoffice/branches/AOO401/main/sc/source/core/tool/rangeutl.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/source/core/tool/rangeutl.cxx?rev=1521881&r1=1521880&r2=1521881&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/source/core/tool/rangeutl.cxx (original)
+++ openoffice/branches/AOO401/main/sc/source/core/tool/rangeutl.cxx Wed Sep 11 14:48:14 2013
@@ -997,8 +997,7 @@ sal_Bool ScArea::operator==( const ScAre
//------------------------------------------------------------------------
-ScAreaNameIterator::ScAreaNameIterator( ScDocument* pDoc ) :
- aStrNoName( ScGlobal::GetRscString(STR_DB_NONAME) )
+ScAreaNameIterator::ScAreaNameIterator( ScDocument* pDoc )
{
pRangeName = pDoc->GetRangeName();
pDBCollection = pDoc->GetDBCollection();
@@ -1008,42 +1007,43 @@ ScAreaNameIterator::ScAreaNameIterator(
sal_Bool ScAreaNameIterator::Next( String& rName, ScRange& rRange )
{
- for (;;)
- {
- if ( bFirstPass ) // erst Bereichsnamen
- {
- if ( pRangeName && nPos < pRangeName->GetCount() )
- {
- ScRangeData* pData = (*pRangeName)[nPos++];
- if ( pData && pData->IsValidReference(rRange) )
- {
- rName = pData->GetName();
- return sal_True; // gefunden
- }
- }
- else
- {
- bFirstPass = sal_False;
- nPos = 0;
- }
- }
- if ( !bFirstPass ) // dann DB-Bereiche
- {
- if ( pDBCollection && nPos < pDBCollection->GetCount() )
- {
- ScDBData* pData = (*pDBCollection)[nPos++];
-// if (pData && pData->GetName() != aStrNoName)
- if (pData && !pData->IsBuildin())
- {
- pData->GetArea( rRange );
- rName = pData->GetName();
- return sal_True; // gefunden
- }
- }
- else
- return sal_False; // gibt nichts mehr
- }
- }
+ for (;;)
+ {
+ if ( bFirstPass ) // erst Bereichsnamen
+ {
+ if ( pRangeName && nPos < pRangeName->GetCount() )
+ {
+ ScRangeData* pData = (*pRangeName)[nPos++];
+ if ( pData && pData->IsValidReference(rRange) )
+ {
+ rName = pData->GetName();
+ return sal_True; // gefunden
+ }
+ }
+ else
+ {
+ bFirstPass = sal_False;
+ nPos = 0;
+ }
+ }
+ if ( !bFirstPass ) // dann DB-Bereiche
+ {
+ if ( pDBCollection && nPos < pDBCollection->GetCount() )
+ {
+ ScDBData* pData = (*pDBCollection)[nPos++];
+ if ( pData
+ && !pData->IsInternalUnnamed()
+ && !pData->IsInternalForAutoFilter() )
+ {
+ pData->GetArea( rRange );
+ rName = pData->GetName();
+ return sal_True; // gefunden
+ }
+ }
+ else
+ return sal_False; // gibt nichts mehr
+ }
+ }
}
Modified: openoffice/branches/AOO401/main/sc/source/ui/dbgui/dbnamdlg.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/source/ui/dbgui/dbnamdlg.cxx?rev=1521881&r1=1521880&r2=1521881&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/source/ui/dbgui/dbnamdlg.cxx (original)
+++ openoffice/branches/AOO401/main/sc/source/ui/dbgui/dbnamdlg.cxx Wed Sep 11 14:48:14 2013
@@ -160,7 +160,6 @@ ScDbNameDlg::ScDbNameDlg( SfxBindings* p
aStrAdd ( ScResId( STR_ADD ) ),
aStrModify ( ScResId( STR_MODIFY ) ),
- aStrNoName ( ScGlobal::GetRscString(STR_DB_NONAME) ),
aStrInvalid ( ScResId( STR_DB_INVALID ) ),
//
pViewData ( ptrViewData ),
@@ -205,87 +204,91 @@ __EXPORT ScDbNameDlg::~ScDbNameDlg()
void ScDbNameDlg::Init()
{
- aBtnHeader.Check( sal_True ); // Default: mit Spaltenkoepfen
+ aBtnHeader.Check( sal_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, sal_True );
- if ( pDBData )
- {
- String theDbName;
- ScAddress& rStart = theCurArea.aStart;
- ScAddress& rEnd = theCurArea.aEnd;
+ 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, sal_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 );
+ 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 )
- if ( !pDBData->IsBuildin() )
- 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=sal_True;
- pSaveObj->Save();
- NameModifyHdl( 0 );
+ if ( (rStart.Tab() == nTab)
+ && (rStart.Col() == nCol1) && (rStart.Row() == nRow1)
+ && (rEnd.Col() == nCol2) && (rEnd.Row() == nRow2 ) )
+ {
+ pDBData->GetName( theDbName );
+ if ( !pDBData->IsInternalUnnamed()
+ && !pDBData->IsInternalForAutoFilter() )
+ {
+ 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=sal_True;
+ pSaveObj->Save();
+ NameModifyHdl( 0 );
}
@@ -361,39 +364,39 @@ void ScDbNameDlg::SetActive()
void ScDbNameDlg::UpdateNames()
{
- sal_uInt16 nNameCount = aLocalDbCol.GetCount();
-
- aEdName.SetUpdateMode( sal_False );
- //-----------------------------------------------------------
- aEdName.Clear();
- aEdAssign.SetText( EMPTY_STRING );
-
- if ( nNameCount > 0 )
- {
- ScDBData* pDbData = NULL;
- String aString;
+ sal_uInt16 nNameCount = aLocalDbCol.GetCount();
- for ( sal_uInt16 i=0; i<nNameCount; i++ )
- {
- pDbData = (ScDBData*)(aLocalDbCol.At( i ));
- if ( pDbData )
- {
- pDbData->GetName( aString );
- //if ( aString != aStrNoName )
- if ( !pDbData->IsBuildin() )
- aEdName.InsertEntry( aString );
- }
- }
- }
- else
- {
- aBtnAdd.SetText( aStrAdd );
- aBtnAdd.Disable();
- aBtnRemove.Disable();
- }
- //-----------------------------------------------------------
- aEdName.SetUpdateMode( sal_True );
- aEdName.Invalidate();
+ aEdName.SetUpdateMode( sal_False );
+ //-----------------------------------------------------------
+ aEdName.Clear();
+ aEdAssign.SetText( EMPTY_STRING );
+
+ if ( nNameCount > 0 )
+ {
+ ScDBData* pDbData = NULL;
+ String aString;
+
+ for ( sal_uInt16 i=0; i<nNameCount; i++ )
+ {
+ pDbData = (ScDBData*)(aLocalDbCol.At( i ));
+ if ( pDbData )
+ {
+ pDbData->GetName( aString );
+ if ( !pDbData->IsInternalUnnamed()
+ && !pDbData->IsInternalForAutoFilter() )
+ aEdName.InsertEntry( aString );
+ }
+ }
+ }
+ else
+ {
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ }
+ //-----------------------------------------------------------
+ aEdName.SetUpdateMode( sal_True );
+ aEdName.Invalidate();
}
//------------------------------------------------------------------------
Modified: openoffice/branches/AOO401/main/sc/source/ui/dbgui/foptmgr.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/source/ui/dbgui/foptmgr.cxx?rev=1521881&r1=1521880&r2=1521881&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/source/ui/dbgui/foptmgr.cxx (original)
+++ openoffice/branches/AOO401/main/sc/source/ui/dbgui/foptmgr.cxx Wed Sep 11 14:48:14 2013
@@ -174,24 +174,24 @@ void ScFilterOptionsMgr::Init()
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 ( !pDBData->IsBuildin() )
- {
- rBtnHeader.Disable();
- }
- }
- }
+ 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 ( !pDBData->IsInternalUnnamed()
+ && !pDBData->IsInternalForAutoFilter() )
+ {
+ rBtnHeader.Disable();
+ }
+ }
+ }
theDbArea.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" ("));
theDbArea += theDbName;
Modified: openoffice/branches/AOO401/main/sc/source/ui/docshell/dbdocfun.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/source/ui/docshell/dbdocfun.cxx?rev=1521881&r1=1521880&r2=1521881&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/source/ui/docshell/dbdocfun.cxx (original)
+++ openoffice/branches/AOO401/main/sc/source/ui/docshell/dbdocfun.cxx Wed Sep 11 14:48:14 2013
@@ -592,7 +592,7 @@ sal_Bool ScDBDocFunc::Sort( SCTAB nTab,
if (pDestData)
pNewData = pDestData; // Bereich vorhanden -> anpassen
else // Bereich ab Cursor/Markierung wird angelegt
- pNewData = rDocShell.GetDBData(aDestPos, SC_DB_MAKE_SORT, SC_DBSEL_FORCE_MARK );
+ pNewData = rDocShell.GetDBData(aDestPos, SC_DB_MAKE, SC_DBSEL_FORCE_MARK );
if (pNewData)
{
pNewData->SetArea( nTab,
@@ -919,7 +919,7 @@ sal_Bool ScDBDocFunc::Query( SCTAB nTab,
pNewData = rDocShell.GetDBData(
ScRange( aLocalParam.nCol1, aLocalParam.nRow1, nDestTab,
aLocalParam.nCol2, aLocalParam.nRow2, nDestTab ),
- SC_DB_MAKE_FILTER, SC_DBSEL_FORCE_MARK );
+ SC_DB_MAKE, SC_DBSEL_FORCE_MARK );
if (pNewData)
{
Modified: openoffice/branches/AOO401/main/sc/source/ui/docshell/docsh5.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/source/ui/docshell/docsh5.cxx?rev=1521881&r1=1521880&r2=1521881&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/source/ui/docshell/docsh5.cxx (original)
+++ openoffice/branches/AOO401/main/sc/source/ui/docshell/docsh5.cxx Wed Sep 11 14:48:14 2013
@@ -111,94 +111,101 @@ void ScDocShell::DBAreaDeleted( SCTAB nT
aDocument.BroadcastUno( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
}
-ScDBData* lcl_GetDBNearCursor( ScDBCollection* pColl, SCCOL nCol, SCROW nRow, SCTAB nTab )
-{
- //! nach document/dbcolect verschieben
-
- if (!pColl)
- return NULL;
- ScDBData* pNoNameData = NULL;
- ScDBData* pNearData = NULL;
- sal_uInt16 nCount = pColl->GetCount();
- String aNoName = ScGlobal::GetRscString( STR_DB_NONAME );
- SCTAB nAreaTab;
- SCCOL nStartCol, nEndCol;
- SCROW nStartRow, nEndRow;
- for (sal_uInt16 i = 0; i < nCount; i++)
- {
- ScDBData* pDB = (*pColl)[i];
- pDB->GetArea( nAreaTab, nStartCol, nStartRow, nEndCol, nEndRow );
- if ( nTab == nAreaTab && nCol+1 >= nStartCol && nCol <= nEndCol+1 &&
- nRow+1 >= nStartRow && nRow <= nEndRow+1 )
- {
- if ( pDB->GetName() == aNoName )
- pNoNameData = pDB;
- else if ( nCol < nStartCol || nCol > nEndCol || nRow < nStartRow || nRow > nEndRow )
- {
- if (!pNearData)
- pNearData = pDB; // ersten angrenzenden Bereich merken
- }
- else
- return pDB; // nicht "unbenannt" und Cursor steht wirklich drin
- }
- }
- if (pNearData)
- return pNearData; // angrenzender, wenn nichts direkt getroffen
- return pNoNameData; // "unbenannt" nur zurueck, wenn sonst nichts gefunden
+ScDBData* lcl_GetDBNearCursor(
+ const ScDBCollection* pColl,
+ const SCCOL nCol,
+ const SCROW nRow,
+ const SCTAB nTab )
+{
+ //! nach document/dbcolect verschieben
+
+ if (!pColl)
+ return NULL;
+
+ ScDBData* pInternalDBData = NULL;
+ ScDBData* pNearData = NULL;
+ sal_uInt16 nCount = pColl->GetCount();
+ SCTAB nAreaTab;
+ SCCOL nStartCol, nEndCol;
+ SCROW nStartRow, nEndRow;
+ for (sal_uInt16 i = 0; i < nCount; i++)
+ {
+ ScDBData* pDB = (*pColl)[i];
+ pDB->GetArea( nAreaTab, nStartCol, nStartRow, nEndCol, nEndRow );
+ if ( nTab == nAreaTab
+ && nCol+1 >= nStartCol
+ && nCol <= nEndCol+1
+ && nRow+1 >= nStartRow
+ && nRow <= nEndRow+1 )
+ {
+ if ( pDB->IsInternalUnnamed()
+ || pDB->IsInternalForAutoFilter() )
+ {
+ pInternalDBData = pDB;
+ }
+ else if ( nCol < nStartCol || nCol > nEndCol || nRow < nStartRow || nRow > nEndRow )
+ {
+ if ( !pNearData )
+ pNearData = pDB; // ersten angrenzenden Bereich merken
+ }
+ else
+ return pDB; // nicht "unbenannt" und Cursor steht wirklich drin
+ }
+ }
+ if (pNearData)
+ return pNearData; // angrenzender, wenn nichts direkt getroffen
+ return pInternalDBData;
}
ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel )
{
- if ( eMode == SC_DB_MAKE_FILTER || eMode == SC_DB_MAKE_SORT || eMode == SC_DB_MAKE_SUBTOTAL || eMode == SC_DB_OLD_FILTER )
- return GetDBDataAdd(rMarked, eMode, eSel);
- SCCOL nCol = rMarked.aStart.Col();
- SCROW nRow = rMarked.aStart.Row();
- SCTAB nTab = rMarked.aStart.Tab();
-
- SCCOL nStartCol = nCol;
- SCROW nStartRow = nRow;
- SCTAB nStartTab = nTab;
- SCCOL nEndCol = rMarked.aEnd.Col();
- SCROW nEndRow = rMarked.aEnd.Row();
- SCTAB nEndTab = rMarked.aEnd.Tab();
-
- // Wegen #49655# nicht einfach GetDBAtCursor: Der zusammenhaengende Datenbereich
- // fuer "unbenannt" (GetDataArea) kann neben dem Cursor legen, also muss auch ein
- // benannter DB-Bereich dort gesucht werden.
-
- ScDBData* pData = aDocument.GetDBAtArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow );
- if (!pData)
- pData = lcl_GetDBNearCursor( aDocument.GetDBCollection(), nCol, nRow, nTab );
-
- sal_Bool bSelected = ( eSel == SC_DBSEL_FORCE_MARK ||
- (rMarked.aStart != rMarked.aEnd && eSel != SC_DBSEL_ROW_DOWN) );
- bool bOnlyDown = (!bSelected && eSel == SC_DBSEL_ROW_DOWN && rMarked.aStart.Row() == rMarked.aEnd.Row());
+ const SCCOL nCol = rMarked.aStart.Col();
+ const SCROW nRow = rMarked.aStart.Row();
+ const SCTAB nTab = rMarked.aStart.Tab();
- sal_Bool bUseThis = sal_False;
- if (pData)
- {
- // Bereich nehmen, wenn nichts anderes markiert
+ SCCOL nStartCol = nCol;
+ SCROW nStartRow = nRow;
+ SCCOL nEndCol = rMarked.aEnd.Col();
+ SCROW nEndRow = rMarked.aEnd.Row();
+
+ ScDBData* pFoundDBData = aDocument.GetDBAtArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow );
+ if ( pFoundDBData == NULL )
+ {
+ pFoundDBData = lcl_GetDBNearCursor( aDocument.GetDBCollection(), nCol, nRow, nTab );
+ }
- SCTAB nDummy;
- SCCOL nOldCol1;
- SCROW nOldRow1;
- SCCOL nOldCol2;
- SCROW nOldRow2;
- pData->GetArea( nDummy, nOldCol1,nOldRow1, nOldCol2,nOldRow2 );
-// sal_Bool bIsNoName = ( pData->GetName() == ScGlobal::GetRscString( STR_DB_NONAME ) );
- sal_Bool bIsNoName = pData->IsBuildin();
+ const bool bSelected =
+ ( eSel == SC_DBSEL_FORCE_MARK
+ || ( rMarked.aStart != rMarked.aEnd
+ && eSel != SC_DBSEL_ROW_DOWN ) );
+ const bool bOnlyDown = ( !bSelected
+ && eSel == SC_DBSEL_ROW_DOWN
+ && rMarked.aStart.Row() == rMarked.aEnd.Row());
- if (!bSelected)
- {
- bUseThis = sal_True;
- if ( bIsNoName && eMode == SC_DB_MAKE )
- {
- // If nothing marked or only one row marked, adapt
- // "unbenannt"/"unnamed" to contiguous area.
+ bool bUseFoundDBData = false;
+ if ( pFoundDBData )
+ {
+ // check, if found database range can be used
+ SCTAB nDummy;
+ SCCOL nOldCol1;
+ SCROW nOldRow1;
+ SCCOL nOldCol2;
+ SCROW nOldRow2;
+ pFoundDBData->GetArea( nDummy, nOldCol1, nOldRow1, nOldCol2, nOldRow2 );
+
+ const bool bIsUnnamedOne = pFoundDBData->IsInternalUnnamed();
+ const bool bIsInternalForAutoFilter = pFoundDBData->IsInternalForAutoFilter();
+ if ( !bSelected )
+ {
+ bUseFoundDBData = true;
+ if ( ( bIsUnnamedOne || bIsInternalForAutoFilter )
+ && ( eMode == SC_DB_MAKE || eMode == SC_DB_MAKE_AUTOFILTER ) )
+ {
+ // If nothing marked or only one row marked, adapt found database range to contiguous area.
nStartCol = nCol;
nStartRow = nRow;
- if (bOnlyDown)
+ if ( bOnlyDown )
{
nEndCol = rMarked.aEnd.Col();
nEndRow = rMarked.aEnd.Row();
@@ -208,54 +215,67 @@ ScDBData* ScDocShell::GetDBData( const S
nEndCol = nStartCol;
nEndRow = nStartRow;
}
- aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, sal_False, bOnlyDown );
- if ( nOldCol1 != nStartCol || nOldCol2 != nEndCol || nOldRow1 != nStartRow )
- bUseThis = sal_False; // passt gar nicht
- else if ( nOldRow2 != nEndRow )
- {
- // Bereich auf neue End-Zeile erweitern
- pData->SetArea( nTab, nOldCol1,nOldRow1, nOldCol2,nEndRow );
- }
- }
- }
- else
- {
- if ( nOldCol1 == nStartCol && nOldRow1 == nStartRow &&
- nOldCol2 == nEndCol && nOldRow2 == nEndRow ) // genau markiert?
- bUseThis = sal_True;
- else
- bUseThis = sal_False; // immer Markierung nehmen (Bug 11964)
- }
+ aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, sal_False, bOnlyDown );
+ if ( nOldCol1 != nStartCol || nOldCol2 != nEndCol || nOldRow1 != nStartRow )
+ {
+ bUseFoundDBData = false;
+ }
+ else if ( nOldRow2 != nEndRow )
+ {
+ // adapt found internal database range to new end row
+ pFoundDBData->SetArea( nTab, nOldCol1,nOldRow1, nOldCol2,nEndRow );
+ }
+ }
+ }
+ else
+ {
+ if ( nOldCol1 == nStartCol
+ && nOldRow1 == nStartRow
+ && nOldCol2 == nEndCol
+ && nOldRow2 == nEndRow )
+ {
+ bUseFoundDBData = true;
+ }
+ else
+ {
+ bUseFoundDBData = false;
+ }
+ }
- // fuer Import nie "unbenannt" nehmen
+ // adapt internal unnamed database range to an auto filter one
+ // otherwise the auto filter is lost when the internal unnamed one is changed/reused/deleted
+ if ( bUseFoundDBData
+ && eMode == SC_DB_MAKE_AUTOFILTER
+ && bIsUnnamedOne )
+ {
+ pFoundDBData->SetName( aDocument.GetDBCollection()->GetNewDefaultDBName() );
+ }
- if ( bUseThis && eMode == SC_DB_IMPORT && bIsNoName )
- bUseThis = sal_False;
- }
+ // no internal database range for Import
+ if ( bUseFoundDBData
+ && eMode == SC_DB_IMPORT
+ && ( bIsUnnamedOne || bIsInternalForAutoFilter ) )
+ {
+ bUseFoundDBData = false;
+ }
+ }
- if ( bUseThis )
- {
- pData->GetArea( nStartTab, nStartCol,nStartRow, nEndCol,nEndRow );
- nEndTab = nStartTab;
- }
- else if ( eMode == SC_DB_OLD )
- {
- pData = NULL; // nichts gefunden
- nStartCol = nEndCol = nCol;
- nStartRow = nEndRow = nRow;
- nStartTab = nEndTab = nTab;
-// bMark = sal_False; // nichts zu markieren
- }
- else
- {
- if ( bSelected )
- {
-// bMark = sal_False;
- }
- else
- { // zusammenhaengender Bereich
- nStartCol = nCol;
- nStartRow = nRow;
+ if ( bUseFoundDBData )
+ {
+ return pFoundDBData;
+ }
+
+ if ( eMode == SC_DB_OLD )
+ {
+ // no existing database range found
+ return NULL;
+ }
+ else // eMode == SC_DB_MAKE||SC_DB_IMPORT||SC_DB_MAKE_AUTOFILTER
+ {
+ if ( !bSelected )
+ {
+ nStartCol = nCol;
+ nStartRow = nRow;
if (bOnlyDown)
{
nEndCol = rMarked.aEnd.Col();
@@ -266,255 +286,112 @@ ScDBData* ScDocShell::GetDBData( const S
nEndCol = nStartCol;
nEndRow = nStartRow;
}
- aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, sal_False, bOnlyDown );
- }
+ aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, sal_False, bOnlyDown );
+ }
- sal_Bool bHasHeader = aDocument.HasColHeader( nStartCol,nStartRow, nEndCol,nEndRow, nTab );
+ const sal_Bool bHasHeader = aDocument.HasColHeader( nStartCol, nStartRow, nEndCol, nEndRow, nTab );
- ScDBData* pNoNameData;
- sal_uInt16 nNoNameIndex;
- ScDBCollection* pColl = aDocument.GetDBCollection();
- if ( eMode != SC_DB_IMPORT &&
- pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nNoNameIndex ) )
- {
- pNoNameData = (*pColl)[nNoNameIndex];
+ ScDBData* pDBData = NULL;
+ sal_uInt16 nUnnamedDBIndex;
+ ScDBCollection* pColl = aDocument.GetDBCollection();
+ if ( eMode == SC_DB_MAKE &&
+ pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nUnnamedDBIndex ) )
+ {
+ // adapt existing unnamed database range
+ pDBData = (*pColl)[nUnnamedDBIndex];
if ( !pOldAutoDBRange )
{
// store the old unnamed database range with its settings for undo
// (store at the first change, get the state before all changes)
- pOldAutoDBRange = new ScDBData( *pNoNameData );
+ pOldAutoDBRange = new ScDBData( *pDBData );
}
- SCCOL nOldX1; // alten Bereich sauber wegnehmen
- SCROW nOldY1; //! (UNDO ???)
- SCCOL nOldX2;
- SCROW nOldY2;
- SCTAB nOldTab;
- pNoNameData->GetArea( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 );
- DBAreaDeleted( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 );
-
- pNoNameData->SetSortParam( ScSortParam() ); // Parameter zuruecksetzen
- pNoNameData->SetQueryParam( ScQueryParam() );
- pNoNameData->SetSubTotalParam( ScSubTotalParam() );
-
- pNoNameData->SetArea( nTab, nStartCol,nStartRow, nEndCol,nEndRow ); // neu setzen
- pNoNameData->SetByRow( sal_True );
- pNoNameData->SetHeader( bHasHeader );
- pNoNameData->SetAutoFilter( sal_False );
- }
- else
- {
- ScDBCollection* pUndoColl = NULL;
-
- String aNewName;
- if (eMode==SC_DB_IMPORT)
- {
- aDocument.CompileDBFormula( sal_True ); // CreateFormulaString
- pUndoColl = new ScDBCollection( *pColl ); // Undo fuer Import1-Bereich
-
- String aImport = ScGlobal::GetRscString( STR_DBNAME_IMPORT );
- long nCount = 0;
- sal_uInt16 nDummy;
- do
- {
- ++nCount;
- aNewName = aImport;
- aNewName += String::CreateFromInt32( nCount );
- }
- while (pColl->SearchName( aNewName, nDummy ));
- }
- else
- //aNewName = ScGlobal::GetRscString( STR_DB_NONAME );
- aNewName = pColl->GetNewDefaultDBName();
-
- pNoNameData = new ScDBData( aNewName, nTab,
- nStartCol,nStartRow, nEndCol,nEndRow,
- sal_True, bHasHeader );
- pColl->Insert( pNoNameData );
-
- if ( pUndoColl )
- {
- aDocument.CompileDBFormula( sal_False ); // CompileFormulaString
-
- ScDBCollection* pRedoColl = new ScDBCollection( *pColl );
- GetUndoManager()->AddUndoAction( new ScUndoDBData( this, pUndoColl, pRedoColl ) );
- }
-
- // neuen Bereich am Sba anmelden nicht mehr noetig
-
- // "Import1" etc am Navigator bekanntmachen
- if (eMode==SC_DB_IMPORT)
- SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
- }
- pData = pNoNameData;
- }
-
-// if (bMark)
-// MarkRange( ScRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab ), sal_False );
-
- return pData;
-}
-
-ScDBData* ScDocShell::GetDBDataAdd( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel )
-{
- SCCOL nCol = rMarked.aStart.Col();
- SCROW nRow = rMarked.aStart.Row();
- SCTAB nTab = rMarked.aStart.Tab();
-
- SCCOL nStartCol = nCol;
- SCROW nStartRow = nRow;
- SCCOL nEndCol = rMarked.aEnd.Col();
- SCROW nEndRow = rMarked.aEnd.Row();
-
- ScDBData* pData = NULL;
- ScDBData* pCursorData;
- pCursorData = aDocument.GetDBAtArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow );
- if ( !pCursorData )
- pCursorData = aDocument.GetDBAtCursor( nStartCol, nStartRow, nTab );
-
- //Get DBData at current table
- ScDBData* pTableData = aDocument.GetDBAtTable( nTab, eMode );
-
- if ( eMode == SC_DB_OLD_FILTER )
- return pTableData;
-
- sal_Bool bSelected = ( eSel == SC_DBSEL_FORCE_MARK || rMarked.aStart != rMarked.aEnd );
- bool bOnlyDown = (!bSelected && eSel == SC_DBSEL_ROW_DOWN && rMarked.aStart.Row() == rMarked.aEnd.Row());
-
- sal_Bool bUseThis = sal_False;
- if (pCursorData)
- {
- SCTAB nDummy;
- SCCOL nOldCol1;
- SCROW nOldRow1;
- SCCOL nOldCol2;
- SCROW nOldRow2;
- pCursorData->GetArea( nDummy, nOldCol1,nOldRow1, nOldCol2,nOldRow2 );
- if ( !bSelected )
- {
- ScRange tmpRange;
- if ( !pCursorData->IsBuildin() && pCursorData->GetAdvancedQuerySource(tmpRange))
- bUseThis = sal_True;
- else
- {
- nStartCol = nCol;
- nStartRow = nRow;
- nEndCol = nStartCol;
- nEndRow = nStartRow;
- aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, sal_False, bOnlyDown );
- if ( nOldCol1 != nStartCol || nOldCol2 != nEndCol || nOldRow1 != nStartRow )
- bUseThis = sal_False;
- else
- {
- bUseThis = sal_True;
- if ( nOldRow2 != nEndRow )// Range of new end-line expand
- pCursorData->SetArea( nTab, nOldCol1,nOldRow1, nOldCol2,nEndRow );
- }
- }
-
- }
- else
- {
- if ( nOldCol1 == nStartCol && nOldRow1 == nStartRow && nOldCol2 == nEndCol && nOldRow2 == nEndRow )
- bUseThis = sal_True;
- else
- bUseThis = sal_False; // Always take mark (Bug 11964)
- }
- }
-
- if ( bUseThis )
- {
- pData = pCursorData;
- if ( pTableData && eMode == SC_DB_MAKE_FILTER && !(*pTableData == *pCursorData ) )
- {
- if ( !pOldAutoDBRange )
- pOldAutoDBRange = new ScDBData(*pTableData);
SCCOL nOldX1;
SCROW nOldY1;
SCCOL nOldX2;
SCROW nOldY2;
SCTAB nOldTab;
- pTableData->GetArea( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 );
-
- if (pTableData->HasQueryParam())
- {
- ScQueryParam aParam;
- pTableData->GetQueryParam(aParam);
- SCSIZE nEC = aParam.GetEntryCount();
- for (SCSIZE i=0; i<nEC; i++)
- aParam.GetEntry(i).bDoQuery = sal_False;
- aParam.bDuplicate = sal_True;
- ScDBDocFunc aDBDocFunc( *this );
- aDBDocFunc.Query( nTab, aParam, NULL, sal_False, sal_False );
- }
-
+ pDBData->GetArea( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 );
DBAreaDeleted( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 );
- pTableData->SetQueryParam( ScQueryParam() );
- pTableData->SetAutoFilter( sal_False );
- }
- }
- else
- {
- if ( bSelected )
- {
-// bMark = sal_False;
+ pDBData->SetSortParam( ScSortParam() );
+ pDBData->SetQueryParam( ScQueryParam() );
+ pDBData->SetSubTotalParam( ScSubTotalParam() );
+
+ pDBData->SetArea( nTab, nStartCol,nStartRow, nEndCol,nEndRow );
+ pDBData->SetByRow( sal_True );
+ pDBData->SetHeader( bHasHeader );
+ pDBData->SetAutoFilter( sal_False );
}
else
{
- nStartCol = nCol;
- nStartRow = nRow;
- nEndCol = nStartCol;
- nEndRow = nStartRow;
- aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, sal_False, bOnlyDown );
- }
- sal_Bool bHasHeader = aDocument.HasColHeader( nStartCol,nStartRow, nEndCol,nEndRow, nTab );
- ScDBCollection* pColl = aDocument.GetDBCollection();
- if ( pTableData )
- {
- if ( !pOldAutoDBRange )
- pOldAutoDBRange = new ScDBData(*pTableData);
- SCCOL nOldX1;
- SCROW nOldY1;
- SCCOL nOldX2;
- SCROW nOldY2;
- SCTAB nOldTab;
- pTableData->GetArea( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 );
+ ScDBCollection* pUndoColl = NULL;
- if (pTableData->HasQueryParam())
+ String aNewName;
+ switch ( eMode )
+ {
+ case SC_DB_IMPORT:
{
- ScQueryParam aParam;
- pTableData->GetQueryParam(aParam);
- SCSIZE nEC = aParam.GetEntryCount();
- for (SCSIZE i=0; i<nEC; i++)
- aParam.GetEntry(i).bDoQuery = sal_False;
- aParam.bDuplicate = sal_True;
- ScDBDocFunc aDBDocFunc( *this );
- aDBDocFunc.Query( nTab, aParam, NULL, sal_False, sal_False );
+ aDocument.CompileDBFormula( sal_True );
+ pUndoColl = new ScDBCollection( *pColl );
+
+ String aImport = ScGlobal::GetRscString( STR_DBNAME_IMPORT );
+ long nCount = 0;
+ sal_uInt16 nDummy;
+ do
+ {
+ ++nCount;
+ aNewName = aImport;
+ aNewName += String::CreateFromInt32( nCount );
+ }
+ while (pColl->SearchName( aNewName, nDummy ));
}
+ break;
- DBAreaDeleted( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 );
+ case SC_DB_MAKE_AUTOFILTER:
+ {
+ aDocument.CompileDBFormula( sal_True );
+ pUndoColl = new ScDBCollection( *pColl );
- pTableData->SetSortParam( ScSortParam() );
- pTableData->SetQueryParam( ScQueryParam() );
- pTableData->SetSubTotalParam( ScSubTotalParam() );
-
- pTableData->SetArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow );
- pTableData->SetByRow( sal_True );
- pTableData->SetHeader( bHasHeader );
- pTableData->SetAutoFilter( sal_False );
- }
- else
- {
- String aNewName = pColl->GetNewDefaultDBName();
- pTableData = new ScDBData( aNewName, nTab, nStartCol,nStartRow, nEndCol,nEndRow, sal_True, bHasHeader );
- pColl->Insert( pTableData );
+ aNewName = pColl->GetNewDefaultDBName();
+ }
+ break;
+
+ case SC_DB_MAKE:
+ {
+ aNewName = ScGlobal::GetRscString( STR_DB_NONAME );
+ }
+ break;
+
+ default:
+ DBG_ERROR( "<ScDocShell::GetDBData(..)> - unexcepted <eMode>" );
+ break;
+ }
+
+ pDBData = new ScDBData(
+ aNewName, nTab, nStartCol, nStartRow, nEndCol, nEndRow, sal_True, bHasHeader );
+ pColl->Insert( pDBData );
+
+ if ( pUndoColl )
+ {
+ aDocument.CompileDBFormula( sal_False );
+
+ ScDBCollection* pRedoColl = new ScDBCollection( *pColl );
+ GetUndoManager()->AddUndoAction( new ScUndoDBData( this, pUndoColl, pRedoColl ) );
+ }
+
+ // notify Navigator about database range "Import[X]"
+ if ( eMode==SC_DB_IMPORT )
+ {
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
+ }
}
- pData = pTableData;
+
+ return pDBData;
}
- return pData;
+ return NULL; // never reached
}
@@ -656,21 +533,22 @@ void ScDocShell::RefreshPivotTables( con
String lcl_GetAreaName( ScDocument* pDoc, ScArea* pArea )
{
- String aName;
- sal_Bool bOk = sal_False;
- ScDBData* pData = pDoc->GetDBAtArea( pArea->nTab, pArea->nColStart, pArea->nRowStart,
- pArea->nColEnd, pArea->nRowEnd );
- if (pData)
- {
- pData->GetName( aName );
- if ( aName != ScGlobal::GetRscString( STR_DB_NONAME ) )
- bOk = sal_True;
- }
+ String aName;
+ bool bOk = false;
+ ScDBData* pData = pDoc->GetDBAtArea( pArea->nTab, pArea->nColStart, pArea->nRowStart, pArea->nColEnd, pArea->nRowEnd );
+ if (pData)
+ {
+ pData->GetName( aName );
+ if ( !pData->IsInternalUnnamed() )
+ bOk = true;
+ }
- if (!bOk)
- pDoc->GetName( pArea->nTab, aName );
+ if (!bOk)
+ {
+ pDoc->GetName( pArea->nTab, aName );
+ }
- return aName;
+ return aName;
}
void ScDocShell::DoConsolidate( const ScConsolidateParam& rParam, sal_Bool bRecord )
Modified: openoffice/branches/AOO401/main/sc/source/ui/inc/dbfunc.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/source/ui/inc/dbfunc.hxx?rev=1521881&r1=1521880&r2=1521881&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/source/ui/inc/dbfunc.hxx (original)
+++ openoffice/branches/AOO401/main/sc/source/ui/inc/dbfunc.hxx Wed Sep 11 14:48:14 2013
@@ -75,7 +75,6 @@ public:
// DB-Bereich vom Cursor
ScDBData* GetDBData( sal_Bool bMarkArea = sal_True, ScGetDBMode eMode = SC_DB_MAKE, ScGetDBSelection eSel = SC_DBSEL_KEEP );
- //ScRange GetDBRange( BOOL bMark, bool bIgnoreNotes );
void NotifyCloseDbNameDlg( const ScDBCollection& rNewColl, const List& rDelAreaList );
void Consolidate( const ScConsolidateParam& rParam, sal_Bool bRecord = sal_True );
Modified: openoffice/branches/AOO401/main/sc/source/ui/inc/docsh.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/source/ui/inc/docsh.hxx?rev=1521881&r1=1521880&r2=1521881&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/source/ui/inc/docsh.hxx (original)
+++ openoffice/branches/AOO401/main/sc/source/ui/inc/docsh.hxx Wed Sep 11 14:48:14 2013
@@ -158,7 +158,6 @@ class SC_DLLPUBLIC ScDocShell: public Sf
SC_DLLPRIVATE void EnableSharedSettings( bool bEnable );
SC_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > LoadSharedDocument();
- ScDBData* GetDBDataAdd( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel );
SC_DLLPRIVATE void UseSheetSaveEntries();
@@ -307,7 +306,6 @@ public:
ScDBData* GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel );
ScDBData* GetOldAutoDBRange(); // has to be deleted by caller!
void CancelAutoDBRange(); // called when dialog is cancelled
- ScDBCollection* GetDBCollection(){ return aDocument.GetDBCollection();}
void UpdateLinks(); // Link-Eintraege aktuallisieren
sal_Bool ReloadTabLinks(); // Links ausfuehren (Inhalt aktualisieren)
Modified: openoffice/branches/AOO401/main/sc/source/ui/navipi/content.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/source/ui/navipi/content.cxx?rev=1521881&r1=1521880&r2=1521881&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/source/ui/navipi/content.cxx (original)
+++ openoffice/branches/AOO401/main/sc/source/ui/navipi/content.cxx Wed Sep 11 14:48:14 2013
@@ -718,27 +718,28 @@ void ScContentTree::GetAreaNames()
void ScContentTree::GetDbNames()
{
- if ( nRootType && nRootType != SC_CONTENT_DBAREA ) // ausgeblendet ?
- return;
+ if ( nRootType && nRootType != SC_CONTENT_DBAREA ) // ausgeblendet ?
+ return;
- ScDocument* pDoc = GetSourceDocument();
- if (!pDoc)
- return;
-
- ScDBCollection* pDbNames = pDoc->GetDBCollection();
- sal_uInt16 nCount = pDbNames->GetCount();
- if ( nCount > 0 )
- {
- String aStrNoName( ScGlobal::GetRscString(STR_DB_NONAME) );
- for ( sal_uInt16 i=0; i<nCount; i++ )
- {
- ScDBData* pData = (*pDbNames)[i];
- String aStrName = pData->GetName();
- //if ( aStrName != aStrNoName )
- if ( !pData->IsBuildin() )
- InsertContent( SC_CONTENT_DBAREA, aStrName );
- }
- }
+ ScDocument* pDoc = GetSourceDocument();
+ if (!pDoc)
+ return;
+
+ ScDBCollection* pDbNames = pDoc->GetDBCollection();
+ sal_uInt16 nCount = pDbNames->GetCount();
+ if ( nCount > 0 )
+ {
+ for ( sal_uInt16 i=0; i<nCount; i++ )
+ {
+ ScDBData* pData = (*pDbNames)[i];
+ String aStrName = pData->GetName();
+ if ( !pData->IsInternalUnnamed()
+ && !pData->IsInternalForAutoFilter() )
+ {
+ InsertContent( SC_CONTENT_DBAREA, aStrName );
+ }
+ }
+ }
}
bool ScContentTree::IsPartOfType( sal_uInt16 nContentType, sal_uInt16 nObjIdentifier ) // static
Modified: openoffice/branches/AOO401/main/sc/source/ui/undo/undoutil.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/source/ui/undo/undoutil.cxx?rev=1521881&r1=1521880&r2=1521881&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/source/ui/undo/undoutil.cxx (original)
+++ openoffice/branches/AOO401/main/sc/source/ui/undo/undoutil.cxx Wed Sep 11 14:48:14 2013
@@ -82,38 +82,49 @@ void ScUndoUtil::MarkSimpleBlock( ScDocS
ScDBData* ScUndoUtil::GetOldDBData( ScDBData* pUndoData, ScDocument* pDoc, SCTAB nTab,
- SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
+ SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
{
- ScDBData* pRet = pDoc->GetDBAtArea( nTab, nCol1, nRow1, nCol2, nRow2 );
+ ScDBData* pRet = pDoc->GetDBAtArea( nTab, nCol1, nRow1, nCol2, nRow2 );
- if (!pRet)
- {
- sal_Bool bWasTemp = sal_False;
- if ( pUndoData )
- {
- String aName;
- pUndoData->GetName( aName );
-// if ( aName == ScGlobal::GetRscString( STR_DB_NONAME ) )
- if (pUndoData->IsBuildin())
- bWasTemp = sal_True;
- }
- DBG_ASSERT(bWasTemp, "Undo: didn't find database range");
-
- sal_uInt16 nIndex;
- ScDBCollection* pColl = pDoc->GetDBCollection();
- if (pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nIndex ))
- pRet = (*pColl)[nIndex];
- else
- {
- String aNoNamed = pColl->GetNewDefaultDBName();
- pRet = new ScDBData( aNoNamed/*ScGlobal::GetRscString( STR_DB_NONAME )*/, nTab,
- nCol1,nRow1, nCol2,nRow2, sal_True,
- pDoc->HasColHeader( nCol1,nRow1,nCol2,nRow2,nTab ) );
- pColl->Insert( pRet );
- }
- }
+ if (!pRet)
+ {
+ bool bWasInternalUnnamed = false;
+ bool bWasInternalForAutoFilter = false;
+ if ( pUndoData )
+ {
+ String aName;
+ pUndoData->GetName( aName );
+ if ( pUndoData->IsInternalUnnamed() )
+ {
+ bWasInternalUnnamed = true;
+ }
+ else if (pUndoData->IsInternalForAutoFilter())
+ {
+ bWasInternalForAutoFilter = true;
+ }
+ }
+ DBG_ASSERT( bWasInternalUnnamed || bWasInternalForAutoFilter, "Undo: didn't find database range");
+
+ sal_uInt16 nIndex;
+ ScDBCollection* pColl = pDoc->GetDBCollection();
+ if ( bWasInternalUnnamed
+ && pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nIndex ))
+ {
+ pRet = (*pColl)[nIndex];
+ }
+ else
+ {
+ String aNewNamed = bWasInternalForAutoFilter
+ ? pColl->GetNewDefaultDBName()
+ : ScGlobal::GetRscString( STR_DB_NONAME );
+ pRet = new ScDBData(
+ aNewNamed, nTab, nCol1,nRow1, nCol2,nRow2, sal_True,
+ pDoc->HasColHeader( nCol1,nRow1,nCol2,nRow2,nTab ) );
+ pColl->Insert( pRet );
+ }
+ }
- return pRet;
+ return pRet;
}
Modified: openoffice/branches/AOO401/main/sc/source/ui/view/cellsh2.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/source/ui/view/cellsh2.cxx?rev=1521881&r1=1521880&r2=1521881&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/source/ui/view/cellsh2.cxx (original)
+++ openoffice/branches/AOO401/main/sc/source/ui/view/cellsh2.cxx Wed Sep 11 14:48:14 2013
@@ -357,8 +357,7 @@ void ScCellShell::ExecuteDB( SfxRequest&
ScSubTotalParam aSubTotalParam;
SfxItemSet aArgSet( GetPool(), SCITEM_SUBTDATA, SCITEM_SUBTDATA );
- //ScDBData* pDBData = pTabViewShell->GetDBData();
- ScDBData* pDBData = pTabViewShell->GetDBData(sal_True, SC_DB_MAKE_SUBTOTAL);
+ ScDBData* pDBData = pTabViewShell->GetDBData();
pDBData->GetSubTotalParam( aSubTotalParam );
aSubTotalParam.bRemoveOnly = sal_False;
@@ -412,7 +411,7 @@ void ScCellShell::ExecuteDB( SfxRequest&
//#i60401 ux-ctest: Calc does not support all users' strategies regarding sorting data
//the patch comes from maoyg
ScSortParam aSortParam;
- ScDBData* pDBData = pTabViewShell->GetDBData(sal_True, SC_DB_MAKE_SORT);
+ ScDBData* pDBData = pTabViewShell->GetDBData();
ScViewData* pData = GetViewData();
pDBData->GetSortParam( aSortParam );
@@ -463,7 +462,7 @@ void ScCellShell::ExecuteDB( SfxRequest&
if ( pArgs ) // Basic
{
ScSortParam aSortParam;
- ScDBData* pDBData = pTabViewShell->GetDBData(sal_True, SC_DB_MAKE_SORT);
+ ScDBData* pDBData = pTabViewShell->GetDBData();
ScViewData* pData = GetViewData();
pDBData->GetSortParam( aSortParam );
@@ -526,7 +525,7 @@ void ScCellShell::ExecuteDB( SfxRequest&
else
{
ScSortParam aSortParam;
- ScDBData* pDBData = pTabViewShell->GetDBData(sal_True, SC_DB_MAKE_SORT);
+ ScDBData* pDBData = pTabViewShell->GetDBData();
ScViewData* pData = GetViewData();
pDBData->GetSortParam( aSortParam );
@@ -681,7 +680,7 @@ void ScCellShell::ExecuteDB( SfxRequest&
case SID_UNFILTER:
{
ScQueryParam aParam;
- ScDBData* pDBData = pTabViewShell->GetDBData(sal_True, SC_DB_OLD_FILTER);
+ ScDBData* pDBData = pTabViewShell->GetDBData();
pDBData->GetQueryParam( aParam );
SCSIZE nEC = aParam.GetEntryCount();
@@ -945,7 +944,6 @@ void ScCellShell::ExecuteDB( SfxRequest&
if ( pDBCol )
{
- const String aStrNoName( ScGlobal::GetRscString(STR_DB_NONAME) );
List aList;
sal_uInt16 nDBCount = pDBCol->GetCount();
ScDBData* pDbData = NULL;
@@ -959,18 +957,13 @@ void ScCellShell::ExecuteDB( SfxRequest&
pDBName = new String;
pDbData->GetName( *pDBName );
- if ( *pDBName != aStrNoName )
+ if ( !pDbData->IsInternalUnnamed() )
aList.Insert( pDBName );
else
DELETEZ(pDBName);
}
}
-//CHINA001 ScSelEntryDlg* pDlg =
-//CHINA001 new ScSelEntryDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_SELECTDB,
-//CHINA001 String(ScResId(SCSTR_SELECTDB)),
-//CHINA001 String(ScResId(SCSTR_AREAS)),
-//CHINA001 aList );
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
Modified: openoffice/branches/AOO401/main/sc/source/ui/view/dbfunc.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/source/ui/view/dbfunc.cxx?rev=1521881&r1=1521880&r2=1521881&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/source/ui/view/dbfunc.cxx (original)
+++ openoffice/branches/AOO401/main/sc/source/ui/view/dbfunc.cxx Wed Sep 11 14:48:14 2013
@@ -332,127 +332,127 @@ void ScDBFunc::ToggleAutoFilter()
ScDocShell* pDocSh = GetViewData()->GetDocShell();
ScDocShellModificator aModificator( *pDocSh );
- ScQueryParam aParam;
- ScDocument* pDoc = GetViewData()->GetDocument();
- ScDBData* pDBData = GetDBData( sal_False, SC_DB_OLD_FILTER, SC_DBSEL_ROW_DOWN );
-
-
-
-
- SCCOL nCol;
- SCROW nRow;
- SCTAB nTab = GetViewData()->GetTabNo();
- sal_Int16 nFlag;
- //sal_Bool bHasAuto = sal_True;
- sal_Bool bHeader;
- sal_Bool bPaint = sal_False;
-
- //! stattdessen aus DB-Bereich abfragen?
-
- /*for (nCol=aParam.nCol1; nCol<=aParam.nCol2 && bHasAuto; nCol++)
- {
- nFlag = ((ScMergeFlagAttr*) pDoc->
- GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue();
-
- if ( (nFlag & SC_MF_AUTO) == 0 )
- bHasAuto = sal_False;
- }*/
-
- if (pDBData && pDBData->HasAutoFilter()) // aufheben
- {
- // Filterknoepfe ausblenden
- pDBData->SetByRow( sal_True ); //! Undo, vorher abfragen ??
- pDBData->GetQueryParam( aParam );
- nRow = aParam.nRow1;
- bHeader = pDBData->HasHeader();
- for (nCol=aParam.nCol1; nCol<=aParam.nCol2; nCol++)
- {
- nFlag = ((ScMergeFlagAttr*) pDoc->
- GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue();
- pDoc->ApplyAttr( nCol, nRow, nTab, ScMergeFlagAttr( nFlag & ~SC_MF_AUTO ) );
- }
-
- // use a list action for the AutoFilter buttons (ScUndoAutoFilter) and the filter operation
-
- String aUndo = ScGlobal::GetRscString( STR_UNDO_QUERY );
- pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
+ ScDBData* pDBData = GetDBData( sal_False, SC_DB_MAKE_AUTOFILTER, SC_DBSEL_ROW_DOWN );
+ if ( pDBData == NULL )
+ {
+ return;
+ }
+
+ // use a list action for the AutoFilter buttons (ScUndoAutoFilter) and the filter operation
+ const String aUndo = ScGlobal::GetRscString( STR_UNDO_QUERY );
+ pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
+
+ pDBData->SetByRow( sal_True );
+ ScQueryParam aParam;
+ pDBData->GetQueryParam( aParam );
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+
+ bool bHasAutoFilter = true;
+ const SCROW nRow = aParam.nRow1;
+ const SCTAB nTab = GetViewData()->GetTabNo();
+ for ( SCCOL nCol=aParam.nCol1; nCol<=aParam.nCol2 && bHasAutoFilter; ++nCol )
+ {
+ const sal_Int16 nFlag =
+ ((ScMergeFlagAttr*) pDoc->GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue();
+
+ if ( (nFlag & SC_MF_AUTO) == 0 )
+ bHasAutoFilter = false;
+ }
+
+ bool bPaint = false;
+
+ if ( bHasAutoFilter )
+ {
+ // switch filter buttons
+ for ( SCCOL nCol=aParam.nCol1; nCol<=aParam.nCol2; ++nCol )
+ {
+ const sal_Int16 nFlag =
+ ((ScMergeFlagAttr*) pDoc->GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue();
+ pDoc->ApplyAttr( nCol, nRow, nTab, ScMergeFlagAttr( nFlag & ~SC_MF_AUTO ) );
+ }
ScRange aRange;
pDBData->GetArea( aRange );
- pDocSh->GetUndoManager()->AddUndoAction(
- new ScUndoAutoFilter( pDocSh, aRange, pDBData->GetName(), sal_False ) );
-
- pDBData->SetAutoFilter(sal_False);
+ pDocSh->GetUndoManager()->AddUndoAction( new ScUndoAutoFilter( pDocSh, aRange, pDBData->GetName(), sal_False ) );
- // Filter aufheben (incl. Paint / Undo)
+ pDBData->SetAutoFilter(sal_False);
- SCSIZE nEC = aParam.GetEntryCount();
- for (SCSIZE i=0; i<nEC; i++)
- aParam.GetEntry(i).bDoQuery = sal_False;
- aParam.bDuplicate = sal_True;
- Query( aParam, NULL, sal_True );
-
- pDocSh->GetUndoManager()->LeaveListAction();
-
- bPaint = sal_True;
- }
- else // Filterknoepfe einblenden
- {
- pDBData = GetDBData(sal_False, SC_DB_MAKE_FILTER);
- pDBData->SetByRow(sal_True);
- pDBData->GetQueryParam(aParam);
- nRow = aParam.nRow1;
- bHeader = pDBData->HasHeader();
-
- if ( !pDoc->IsBlockEmpty( nTab,
- aParam.nCol1, aParam.nRow1,
- aParam.nCol2, aParam.nRow2 ) )
- {
- if (!bHeader)
- {
- if ( MessBox( GetViewData()->GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
- ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), // "StarCalc"
- ScGlobal::GetRscString( STR_MSSG_MAKEAUTOFILTER_0 ) // Koepfe aus erster Zeile?
- ).Execute() == RET_YES )
- {
- pDBData->SetHeader( sal_True ); //! Undo ??
- bHeader = sal_True;
- }
- }
+ // switch off filter
+ const SCSIZE nEC = aParam.GetEntryCount();
+ for ( SCSIZE i=0; i<nEC; ++i )
+ {
+ aParam.GetEntry(i).bDoQuery = sal_False;
+ }
+ aParam.bDuplicate = sal_True;
+ Query( aParam, NULL, sal_True );
+
+ // delete internal database range for auto filter
+ if ( pDBData->IsInternalForAutoFilter() )
+ {
+ ScDBDocFunc aFunc(*pDocSh);
+ aFunc.DeleteDBRange( pDBData->GetName(), sal_False );
+ }
+ pDBData = NULL;
+
+ bPaint = true;
+ }
+ else
+ {
+ if ( !pDoc->IsBlockEmpty(
+ nTab,
+ aParam.nCol1,
+ aParam.nRow1,
+ aParam.nCol2,
+ aParam.nRow2 ) )
+ {
+ if ( !pDBData->HasHeader() )
+ {
+ if ( MessBox(
+ GetViewData()->GetDialogParent(),
+ WinBits(WB_YES_NO | WB_DEF_YES),
+ ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ),
+ ScGlobal::GetRscString( STR_MSSG_MAKEAUTOFILTER_0 ) ).Execute() == RET_YES )
+ {
+ pDBData->SetHeader( sal_True );
+ }
+ }
ScRange aRange;
pDBData->GetArea( aRange );
- pDocSh->GetUndoManager()->AddUndoAction(
- new ScUndoAutoFilter( pDocSh, aRange, pDBData->GetName(), sal_True ) );
-
- pDBData->SetAutoFilter(sal_True);
-
- for (nCol=aParam.nCol1; nCol<=aParam.nCol2; nCol++)
- {
- nFlag = ((ScMergeFlagAttr*) pDoc->
- GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue();
- pDoc->ApplyAttr( nCol, nRow, nTab, ScMergeFlagAttr( nFlag | SC_MF_AUTO ) );
- }
- pDocSh->PostPaint( aParam.nCol1, nRow, nTab, aParam.nCol2, nRow, nTab,
- PAINT_GRID );
- bPaint = sal_True;
- }
- else
- {
- ErrorBox aErrorBox( GetViewData()->GetDialogParent(), WinBits( WB_OK | WB_DEF_OK ),
- ScGlobal::GetRscString( STR_ERR_AUTOFILTER ) );
- aErrorBox.Execute();
- }
- }
+ pDocSh->GetUndoManager()->AddUndoAction( new ScUndoAutoFilter( pDocSh, aRange, pDBData->GetName(), sal_True ) );
- if ( bPaint )
- {
- aModificator.SetDocumentModified();
+ pDBData->SetAutoFilter(sal_True);
- SfxBindings& rBindings = GetViewData()->GetBindings();
- rBindings.Invalidate( SID_AUTO_FILTER );
- rBindings.Invalidate( SID_AUTOFILTER_HIDE );
- }
+ for ( SCCOL nCol=aParam.nCol1; nCol<=aParam.nCol2; ++nCol )
+ {
+ const sal_Int16 nFlag =
+ ((ScMergeFlagAttr*) pDoc->GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue();
+ pDoc->ApplyAttr( nCol, nRow, nTab, ScMergeFlagAttr( nFlag | SC_MF_AUTO ) );
+ }
+ pDocSh->PostPaint( aParam.nCol1, nRow, nTab, aParam.nCol2, nRow, nTab, PAINT_GRID );
+ bPaint = true;
+ }
+ else
+ {
+ ErrorBox aErrorBox(
+ GetViewData()->GetDialogParent(),
+ WinBits( WB_OK | WB_DEF_OK ),
+ ScGlobal::GetRscString( STR_ERR_AUTOFILTER ) );
+ aErrorBox.Execute();
+ }
+ }
+
+ pDocSh->GetUndoManager()->LeaveListAction();
+
+ if ( bPaint )
+ {
+ aModificator.SetDocumentModified();
+
+ SfxBindings& rBindings = GetViewData()->GetBindings();
+ rBindings.Invalidate( SID_AUTO_FILTER );
+ rBindings.Invalidate( SID_AUTOFILTER_HIDE );
+ }
}
// nur ausblenden, keine Daten veraendern
@@ -462,37 +462,48 @@ void ScDBFunc::HideAutoFilter()
ScDocShell* pDocSh = GetViewData()->GetDocShell();
ScDocShellModificator aModificator( *pDocSh );
- ScDocument* pDoc = pDocSh->GetDocument();
-
- ScQueryParam aParam;
- //ScDBData* pDBData = GetDBData( FALSE );
- ScDBData* pDBData = GetDBData(sal_False, SC_DB_OLD_FILTER);
-
- SCTAB nTab;
- SCCOL nCol1, nCol2;
- SCROW nRow1, nRow2;
- pDBData->GetArea(nTab, nCol1, nRow1, nCol2, nRow2);
-
- for (SCCOL nCol=nCol1; nCol<=nCol2; nCol++)
- {
- sal_Int16 nFlag = ((ScMergeFlagAttr*) pDoc->
- GetAttr( nCol, nRow1, nTab, ATTR_MERGE_FLAG ))->GetValue();
- pDoc->ApplyAttr( nCol, nRow1, nTab, ScMergeFlagAttr( nFlag & ~SC_MF_AUTO ) );
- }
+ ScDBData* pDBData = GetDBData( sal_False );
+ SCTAB nTab;
+ SCCOL nCol1, nCol2;
+ SCROW nRow1, nRow2;
+ pDBData->GetArea(nTab, nCol1, nRow1, nCol2, nRow2);
+
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ for (SCCOL nCol=nCol1; nCol<=nCol2; nCol++)
+ {
+ const sal_Int16 nFlag =
+ ((ScMergeFlagAttr*) pDoc->GetAttr( nCol, nRow1, nTab, ATTR_MERGE_FLAG ))->GetValue();
+ pDoc->ApplyAttr( nCol, nRow1, nTab, ScMergeFlagAttr( nFlag & ~SC_MF_AUTO ) );
+ }
+ }
+
+ const String aUndo = ScGlobal::GetRscString( STR_UNDO_QUERY );
+ pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
+ {
+ ScRange aRange;
+ pDBData->GetArea( aRange );
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoAutoFilter( pDocSh, aRange, pDBData->GetName(), sal_False ) );
- ScRange aRange;
- pDBData->GetArea( aRange );
- pDocSh->GetUndoManager()->AddUndoAction(
- new ScUndoAutoFilter( pDocSh, aRange, pDBData->GetName(), sal_False ) );
+ pDBData->SetAutoFilter(sal_False);
- pDBData->SetAutoFilter(sal_False);
+ // delete internal database range for auto filter
+ if ( pDBData->IsInternalForAutoFilter() )
+ {
+ ScDBDocFunc aFunc(*pDocSh);
+ aFunc.DeleteDBRange( pDBData->GetName(), sal_False );
+ }
+ pDBData = NULL;
+ }
+ pDocSh->GetUndoManager()->LeaveListAction();
- pDocSh->PostPaint( nCol1,nRow1,nTab, nCol2,nRow1,nTab, PAINT_GRID );
+ pDocSh->PostPaint( nCol1,nRow1,nTab, nCol2,nRow1,nTab, PAINT_GRID );
aModificator.SetDocumentModified();
- SfxBindings& rBindings = GetViewData()->GetBindings();
- rBindings.Invalidate( SID_AUTO_FILTER );
- rBindings.Invalidate( SID_AUTOFILTER_HIDE );
+ SfxBindings& rBindings = GetViewData()->GetBindings();
+ rBindings.Invalidate( SID_AUTO_FILTER );
+ rBindings.Invalidate( SID_AUTOFILTER_HIDE );
}
// Re-Import
Modified: openoffice/branches/AOO401/main/sc/source/ui/view/tabvwshc.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/source/ui/view/tabvwshc.cxx?rev=1521881&r1=1521880&r2=1521881&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/source/ui/view/tabvwshc.cxx (original)
+++ openoffice/branches/AOO401/main/sc/source/ui/view/tabvwshc.cxx Wed Sep 11 14:48:14 2013
@@ -171,7 +171,7 @@ SfxModelessDialog* ScTabViewShell::Creat
SCITEM_QUERYDATA,
SCITEM_QUERYDATA );
- ScDBData* pDBData = GetDBData( sal_True, SC_DB_MAKE_FILTER, SC_DBSEL_ROW_DOWN);
+ ScDBData* pDBData = GetDBData( sal_True, SC_DB_MAKE, SC_DBSEL_ROW_DOWN);
pDBData->GetQueryParam( aQueryParam );
ScQueryItem aItem( SCITEM_QUERYDATA, GetViewData(), &aQueryParam );
@@ -196,7 +196,7 @@ SfxModelessDialog* ScTabViewShell::Creat
SCITEM_QUERYDATA,
SCITEM_QUERYDATA );
- ScDBData* pDBData = GetDBData( sal_True, SC_DB_MAKE_FILTER, SC_DBSEL_ROW_DOWN);
+ ScDBData* pDBData = GetDBData( sal_True, SC_DB_MAKE, SC_DBSEL_ROW_DOWN);
pDBData->GetQueryParam( aQueryParam );
aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA,