incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject svn commit: r1372767 - in /incubator/ooo/trunk/main/sc: inc/ source/core/data/ source/core/tool/ source/ui/dbgui/ source/ui/docshell/ source/ui/inc/ source/ui/navipi/ source/ui/undo/ source/ui/view/
Date Tue, 14 Aug 2012 08:22:34 GMT
Author: leiw
Date: Tue Aug 14 08:22:33 2012
New Revision: 1372767

URL: http://svn.apache.org/viewvc?rev=1372767&view=rev
Log:
Fix i12666 autofilter works just on one sheet (only one auto-range per document)

Patch by: zhanglu.aoo
Submit by: Wang Lei


Modified:
    incubator/ooo/trunk/main/sc/inc/dbcolect.hxx
    incubator/ooo/trunk/main/sc/inc/document.hxx
    incubator/ooo/trunk/main/sc/inc/global.hxx
    incubator/ooo/trunk/main/sc/source/core/data/documen3.cxx
    incubator/ooo/trunk/main/sc/source/core/tool/dbcolect.cxx
    incubator/ooo/trunk/main/sc/source/core/tool/rangeutl.cxx
    incubator/ooo/trunk/main/sc/source/ui/dbgui/dbnamdlg.cxx
    incubator/ooo/trunk/main/sc/source/ui/dbgui/foptmgr.cxx
    incubator/ooo/trunk/main/sc/source/ui/docshell/dbdocfun.cxx
    incubator/ooo/trunk/main/sc/source/ui/docshell/docsh5.cxx
    incubator/ooo/trunk/main/sc/source/ui/inc/dbfunc.hxx
    incubator/ooo/trunk/main/sc/source/ui/inc/docsh.hxx
    incubator/ooo/trunk/main/sc/source/ui/navipi/content.cxx
    incubator/ooo/trunk/main/sc/source/ui/undo/undobase.cxx
    incubator/ooo/trunk/main/sc/source/ui/undo/undoutil.cxx
    incubator/ooo/trunk/main/sc/source/ui/view/cellsh2.cxx
    incubator/ooo/trunk/main/sc/source/ui/view/dbfunc.cxx
    incubator/ooo/trunk/main/sc/source/ui/view/tabvwshc.cxx

Modified: incubator/ooo/trunk/main/sc/inc/dbcolect.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/inc/dbcolect.hxx?rev=1372767&r1=1372766&r2=1372767&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/inc/dbcolect.hxx (original)
+++ incubator/ooo/trunk/main/sc/inc/dbcolect.hxx Tue Aug 14 08:22:33 2012
@@ -136,6 +136,8 @@ 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);
 			sal_Bool		IsByRow() const 				{ return bByRow; }
 			void		SetByRow(sal_Bool bByR) 			{ bByRow = bByR; }
@@ -216,6 +218,7 @@ public:
 			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*       GetFilterDBAtTable(SCTAB nTab) const;
+            ScDBData*	GetDBAtTable(SCTAB nTab, ScGetDBMode eMode) const;
 
 	sal_Bool	SearchName( const String& rName, sal_uInt16& rIndex ) const;
 
@@ -234,6 +237,8 @@ public:
 	void			SetRefreshHandler( const Link& rLink )
 						{ aRefreshHandler = rLink; }
 	const Link&		GetRefreshHandler() const	{ return aRefreshHandler; }
+    String      GetNewDefaultDBName();
+    /*sal_Bool        IsFiltered(SCTAB nTab, SCROW nRow);*/
 };
 
 #endif

Modified: incubator/ooo/trunk/main/sc/inc/document.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/inc/document.hxx?rev=1372767&r1=1372766&r2=1372767&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/inc/document.hxx (original)
+++ incubator/ooo/trunk/main/sc/inc/document.hxx Tue Aug 14 08:22:33 2012
@@ -505,6 +505,7 @@ public:
 //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;

Modified: incubator/ooo/trunk/main/sc/inc/global.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/inc/global.hxx?rev=1372767&r1=1372766&r2=1372767&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/inc/global.hxx (original)
+++ incubator/ooo/trunk/main/sc/inc/global.hxx Tue Aug 14 08:22:33 2012
@@ -406,7 +406,11 @@ enum ScGetDBMode
 {
 	SC_DB_MAKE,		// wenn noetig, "unbenannt" anlegen
 	SC_DB_IMPORT,	// wenn noetig, "Importx" anlegen
-	SC_DB_OLD		// nicht neu 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
 };
 
 /// For ScDBFunc::GetDBData()

Modified: incubator/ooo/trunk/main/sc/source/core/data/documen3.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/core/data/documen3.cxx?rev=1372767&r1=1372766&r2=1372767&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/core/data/documen3.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/core/data/documen3.cxx Tue Aug 14 08:22:33 2012
@@ -192,6 +192,13 @@ 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
 {
@@ -1291,7 +1298,8 @@ sal_Bool ScDocument::CreateQueryParam(SC
 
 sal_Bool ScDocument::HasAutoFilter( SCCOL nCurCol, SCROW nCurRow, SCTAB nCurTab )
 {
-	ScDBData*		pDBData			= GetDBAtCursor( nCurCol, nCurRow, nCurTab );
+	//ScDBData*		pDBData			= GetDBAtCursor( nCurCol, nCurRow, nCurTab );
+	ScDBData*		pDBData			= GetDBAtTable(nCurTab, SC_DB_OLD_FILTER);
 	sal_Bool			bHasAutoFilter	= ( pDBData != NULL );
 
 	if ( pDBData )

Modified: incubator/ooo/trunk/main/sc/source/core/tool/dbcolect.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/core/tool/dbcolect.cxx?rev=1372767&r1=1372766&r2=1372767&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/core/tool/dbcolect.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/core/tool/dbcolect.cxx Tue Aug 14 08:22:33 2012
@@ -36,6 +36,7 @@
 #include "queryparam.hxx"
 #include "globstr.hrc"
 
+#define SC_DBNAME_UNNAMED "__Anonymous_Sheet_DB__"
 
 //---------------------------------------------------------------------------------------
 
@@ -690,7 +691,12 @@ ScDataObject*	ScDBData::Clone() const
 {
 	return new ScDBData(*this);
 }
-
+sal_Bool    ScDBData::IsBuildin()
+{
+    String  aNoName = String::CreateFromAscii(SC_DBNAME_UNNAMED);
+    String  aBeginName = aName.Copy(0,22);
+    return  (sal_Bool)(!ScGlobal::GetpTransliteration()->compareString( aNoName, aBeginName
));
+}
 
 //---------------------------------------------------------------------------------------
 //	Compare zum Sortieren
@@ -714,13 +720,12 @@ ScDBData* ScDBCollection::GetDBAtCursor(
 	ScDBData* pNoNameData = NULL;
 	if (pItems)
 	{
-		const String& rNoName = ScGlobal::GetRscString( STR_DB_NONAME );
 
 		for (sal_uInt16 i = 0; i < nCount; i++)
 			if (((ScDBData*)pItems[i])->IsDBAtCursor(nCol, nRow, nTab, bStartOnly))
 			{
 				ScDBData* pDB = (ScDBData*)pItems[i];
-				if ( pDB->GetName() == rNoName )
+                if ( pDB->IsBuildin() )
 					pNoNameData = pDB;
 				else
 					return pDB;
@@ -734,13 +739,12 @@ ScDBData* ScDBCollection::GetDBAtArea(SC
 	ScDBData* pNoNameData = NULL;
 	if (pItems)
 	{
-		const String& rNoName = ScGlobal::GetRscString( STR_DB_NONAME );
 
 		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->GetName() == rNoName )
+				if ( pDB->IsBuildin() )
 					pNoNameData = pDB;
 				else
 					return pDB;
@@ -903,6 +907,67 @@ sal_Bool ScDBCollection::Insert(ScDataOb
 	return bInserted;
 }
 
+String ScDBCollection::GetNewDefaultDBName()
+{
+    String  aNoName = String::CreateFromAscii(SC_DBNAME_UNNAMED);
+    String  aNewName;
+    unsigned short  nDummy;
+    int     i = 1;
+    do
+    {
+        aNewName = aNoName;
+        aNewName += String::CreateFromInt32( i++ );
+    }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: incubator/ooo/trunk/main/sc/source/core/tool/rangeutl.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/core/tool/rangeutl.cxx?rev=1372767&r1=1372766&r2=1372767&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/core/tool/rangeutl.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/core/tool/rangeutl.cxx Tue Aug 14 08:22:33 2012
@@ -1032,7 +1032,8 @@ sal_Bool ScAreaNameIterator::Next( Strin
 			if ( pDBCollection && nPos < pDBCollection->GetCount() )
 			{
 				ScDBData* pData = (*pDBCollection)[nPos++];
-				if (pData && pData->GetName() != aStrNoName)
+//				if (pData && pData->GetName() != aStrNoName)
+				if (pData && !pData->IsBuildin())
 				{
 					pData->GetArea( rRange );
 					rName = pData->GetName();

Modified: incubator/ooo/trunk/main/sc/source/ui/dbgui/dbnamdlg.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/dbgui/dbnamdlg.cxx?rev=1372767&r1=1372766&r2=1372767&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/dbgui/dbnamdlg.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/dbgui/dbnamdlg.cxx Tue Aug 14 08:22:33 2012
@@ -266,7 +266,8 @@ void ScDbNameDlg::Init()
 					&& (rEnd.Col()   == nCol2) && (rEnd.Row()   == nRow2 ) )
 				{
 					pDBData->GetName( theDbName );
-					if ( theDbName != aStrNoName )
+					//if ( theDbName != aStrNoName )
+					if ( !pDBData->IsBuildin() )
 						aEdName.SetText( theDbName );
 					else
 						aEdName.SetText( EMPTY_STRING );
@@ -378,7 +379,8 @@ void ScDbNameDlg::UpdateNames()
 			if ( pDbData )
 			{
 				pDbData->GetName( aString );
-				if ( aString != aStrNoName )
+				//if ( aString != aStrNoName )
+				if ( !pDbData->IsBuildin() )
 					aEdName.InsertEntry( aString );
 			}
 		}

Modified: incubator/ooo/trunk/main/sc/source/ui/dbgui/foptmgr.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/dbgui/foptmgr.cxx?rev=1372767&r1=1372766&r2=1372767&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/dbgui/foptmgr.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/dbgui/foptmgr.cxx Tue Aug 14 08:22:33 2012
@@ -186,7 +186,7 @@ void ScFilterOptionsMgr::Init()
 				rBtnHeader.Check( pDBData->HasHeader() );
 				pDBData->GetName( theDbName );
 
-				if ( theDbName != rStrNoName )
+                if ( !pDBData->IsBuildin() )
 				{
 					rBtnHeader.Disable();
 				}

Modified: incubator/ooo/trunk/main/sc/source/ui/docshell/dbdocfun.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/docshell/dbdocfun.cxx?rev=1372767&r1=1372766&r2=1372767&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/docshell/dbdocfun.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/docshell/dbdocfun.cxx Tue Aug 14 08:22:33 2012
@@ -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, SC_DBSEL_FORCE_MARK );
+			pNewData = rDocShell.GetDBData(aDestPos, SC_DB_MAKE_SORT, 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, SC_DBSEL_FORCE_MARK );
+							SC_DB_MAKE_FILTER, SC_DBSEL_FORCE_MARK );
 
 		if (pNewData)
 		{

Modified: incubator/ooo/trunk/main/sc/source/ui/docshell/docsh5.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/docshell/docsh5.cxx?rev=1372767&r1=1372766&r2=1372767&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/docshell/docsh5.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/docshell/docsh5.cxx Tue Aug 14 08:22:33 2012
@@ -150,6 +150,8 @@ ScDBData* lcl_GetDBNearCursor( ScDBColle
 
 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();
@@ -184,7 +186,8 @@ ScDBData* ScDocShell::GetDBData( const S
 		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->GetName() == ScGlobal::GetRscString( STR_DB_NONAME )
);
+		sal_Bool bIsNoName = pData->IsBuildin();
 
 		if (!bSelected)
 		{
@@ -322,7 +325,9 @@ ScDBData* ScDocShell::GetDBData( const S
 				while (pColl->SearchName( aNewName, nDummy ));
 			}
 			else
-				aNewName = ScGlobal::GetRscString( STR_DB_NONAME );
+				//aNewName = ScGlobal::GetRscString( STR_DB_NONAME );
+				aNewName = pColl->GetNewDefaultDBName();
+
 			pNoNameData = new ScDBData( aNewName, nTab,
 								nStartCol,nStartRow, nEndCol,nEndRow,
 								sal_True, bHasHeader );
@@ -351,6 +356,170 @@ ScDBData* ScDocShell::GetDBData( const S
 	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;
+    SCTAB nStartTab = nTab;
+    SCCOL nEndCol = rMarked.aEnd.Col();
+    SCROW nEndRow = rMarked.aEnd.Row();
+    SCTAB nEndTab = rMarked.aEnd.Tab();
+
+    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 );
+            }
+
+            DBAreaDeleted( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 );
+            pTableData->SetQueryParam( ScQueryParam() );
+            pTableData->SetAutoFilter( sal_False );
+        }
+
+    }
+    else
+    {
+        if ( bSelected )
+        {
+//			bMark = 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 );
+
+            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 );
+            }
+
+                DBAreaDeleted( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 );
+
+            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 );
+        }
+        pData = pTableData;
+    }
+
+    return pData;
+}
+
+
 ScDBData* ScDocShell::GetOldAutoDBRange()
 {
     ScDBData* pRet = pOldAutoDBRange;

Modified: incubator/ooo/trunk/main/sc/source/ui/inc/dbfunc.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/inc/dbfunc.hxx?rev=1372767&r1=1372766&r2=1372767&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/inc/dbfunc.hxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/inc/dbfunc.hxx Tue Aug 14 08:22:33 2012
@@ -75,6 +75,7 @@ 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: incubator/ooo/trunk/main/sc/source/ui/inc/docsh.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/inc/docsh.hxx?rev=1372767&r1=1372766&r2=1372767&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/inc/docsh.hxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/inc/docsh.hxx Tue Aug 14 08:22:33 2012
@@ -158,6 +158,7 @@ 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();
 
@@ -306,6 +307,7 @@ 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: incubator/ooo/trunk/main/sc/source/ui/navipi/content.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/navipi/content.cxx?rev=1372767&r1=1372766&r2=1372767&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/navipi/content.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/navipi/content.cxx Tue Aug 14 08:22:33 2012
@@ -734,7 +734,8 @@ void ScContentTree::GetDbNames()
 		{
 			ScDBData* pData = (*pDbNames)[i];
 			String aStrName = pData->GetName();
-			if ( aStrName != aStrNoName )
+			//if ( aStrName != aStrNoName )
+			if ( !pData->IsBuildin() )
 				InsertContent( SC_CONTENT_DBAREA, aStrName );
 		}
 	}

Modified: incubator/ooo/trunk/main/sc/source/ui/undo/undobase.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/undo/undobase.cxx?rev=1372767&r1=1372766&r2=1372767&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/undo/undobase.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/undo/undobase.cxx Tue Aug 14 08:22:33 2012
@@ -33,6 +33,7 @@
 #include "undobase.hxx"
 #include "refundo.hxx"
 #include "docsh.hxx"
+#include "dbdocfun.hxx"
 #include "tabvwsh.hxx"
 #include "undoolk.hxx"
 #include "undodraw.hxx"
@@ -390,7 +391,7 @@ void ScDBFuncUndo::EndUndo()
         sal_uInt16 nNoNameIndex;
         ScDocument* pDoc = pDocShell->GetDocument();
         ScDBCollection* pColl = pDoc->GetDBCollection();
-        if ( pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nNoNameIndex
) )
+        if ( pColl->SearchName( pAutoDBRange->GetName(), nNoNameIndex ) )
         {
             ScDBData* pNoNameData = (*pColl)[nNoNameIndex];
 
@@ -403,6 +404,13 @@ void ScDBFuncUndo::EndUndo()
             pDocShell->DBAreaDeleted( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2
);
 
             *pNoNameData = *pAutoDBRange;
+            /*if (pAutoDBRange->HasQueryParam())   //maybe conflict with AOO
+            {
+                ScQueryParam    aParam;
+                pAutoDBRange->GetQueryParam(aParam);
+                ScDBDocFunc aDBDocFunc( *pDocShell );
+                aDBDocFunc.Query( nRangeTab, aParam, NULL, sal_False, sal_False );
+            }*/
 
             if ( pAutoDBRange->HasAutoFilter() )
             {
@@ -425,7 +433,7 @@ void ScDBFuncUndo::BeginRedo()
         sal_uInt16 nNoNameIndex;
         ScDocument* pDoc = pDocShell->GetDocument();
         ScDBCollection* pColl = pDoc->GetDBCollection();
-        if ( pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nNoNameIndex
) )
+        if ( pColl->SearchName( pAutoDBRange->GetName(), nNoNameIndex ) )
         {
             ScDBData* pNoNameData = (*pColl)[nNoNameIndex];
 
@@ -435,6 +443,17 @@ void ScDBFuncUndo::BeginRedo()
             SCROW nRangeY2;
             SCTAB nRangeTab;
             pNoNameData->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 );
+            /*if (pAutoDBRange->HasQueryParam())
+            {
+                ScQueryParam    aParam;
+                pAutoDBRange->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( *pDocShell );
+                aDBDocFunc.Query( nRangeTab, aParam, NULL, sal_False, sal_False );
+            }*/
             pDocShell->DBAreaDeleted( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2
);
 
             pNoNameData->SetSortParam( ScSortParam() );

Modified: incubator/ooo/trunk/main/sc/source/ui/undo/undoutil.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/undo/undoutil.cxx?rev=1372767&r1=1372766&r2=1372767&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/undo/undoutil.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/undo/undoutil.cxx Tue Aug 14 08:22:33 2012
@@ -93,7 +93,8 @@ ScDBData* ScUndoUtil::GetOldDBData( ScDB
 		{
 			String aName;
 			pUndoData->GetName( aName );
-			if ( aName == ScGlobal::GetRscString( STR_DB_NONAME ) )
+//			if ( aName == ScGlobal::GetRscString( STR_DB_NONAME ) )
+			if (pUndoData->IsBuildin())
 				bWasTemp = sal_True;
 		}
         DBG_ASSERT(bWasTemp, "Undo: didn't find database range");
@@ -104,7 +105,8 @@ ScDBData* ScUndoUtil::GetOldDBData( ScDB
 			pRet = (*pColl)[nIndex];
 		else
 		{
-			pRet = new ScDBData( ScGlobal::GetRscString( STR_DB_NONAME ), nTab,
+            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 );

Modified: incubator/ooo/trunk/main/sc/source/ui/view/cellsh2.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/view/cellsh2.cxx?rev=1372767&r1=1372766&r2=1372767&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/view/cellsh2.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/view/cellsh2.cxx Tue Aug 14 08:22:33 2012
@@ -357,7 +357,8 @@ void ScCellShell::ExecuteDB( SfxRequest&
 					ScSubTotalParam aSubTotalParam;
 					SfxItemSet		aArgSet( GetPool(), SCITEM_SUBTDATA, SCITEM_SUBTDATA );
 
-					ScDBData* pDBData = pTabViewShell->GetDBData();
+					//ScDBData* pDBData = pTabViewShell->GetDBData();
+                    ScDBData* pDBData = pTabViewShell->GetDBData(sal_True, SC_DB_MAKE_SUBTOTAL);
 					pDBData->GetSubTotalParam( aSubTotalParam );
 					aSubTotalParam.bRemoveOnly = sal_False;
 
@@ -411,7 +412,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();
+                ScDBData*	pDBData = pTabViewShell->GetDBData(sal_True, SC_DB_MAKE_SORT);
                 ScViewData* pData   = GetViewData();
 
                 pDBData->GetSortParam( aSortParam );
@@ -462,7 +463,7 @@ void ScCellShell::ExecuteDB( SfxRequest&
                 if ( pArgs )		// Basic
                 {
                     ScSortParam aSortParam;
-                    ScDBData*	pDBData = pTabViewShell->GetDBData();
+                    ScDBData*	pDBData = pTabViewShell->GetDBData(sal_True, SC_DB_MAKE_SORT);
                     ScViewData* pData   = GetViewData();
 
                     pDBData->GetSortParam( aSortParam );
@@ -525,7 +526,7 @@ void ScCellShell::ExecuteDB( SfxRequest&
                 else
                 {
                     ScSortParam aSortParam;
-                    ScDBData*	pDBData = pTabViewShell->GetDBData();
+                    ScDBData*	pDBData = pTabViewShell->GetDBData(sal_True, SC_DB_MAKE_SORT);
                     ScViewData* pData   = GetViewData();
 
                     pDBData->GetSortParam( aSortParam );
@@ -680,7 +681,7 @@ void ScCellShell::ExecuteDB( SfxRequest&
 		case SID_UNFILTER:
 			{
 				ScQueryParam aParam;
-				ScDBData*	 pDBData = pTabViewShell->GetDBData();
+				ScDBData*	 pDBData = pTabViewShell->GetDBData(sal_True, SC_DB_OLD_FILTER);
 
 				pDBData->GetQueryParam( aParam );
 				SCSIZE nEC = aParam.GetEntryCount();

Modified: incubator/ooo/trunk/main/sc/source/ui/view/dbfunc.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/view/dbfunc.cxx?rev=1372767&r1=1372766&r2=1372767&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/view/dbfunc.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/view/dbfunc.cxx Tue Aug 14 08:22:33 2012
@@ -334,35 +334,37 @@ void ScDBFunc::ToggleAutoFilter()
 
 	ScQueryParam	aParam;
 	ScDocument*		pDoc	= GetViewData()->GetDocument();
-	ScDBData*		pDBData = GetDBData( sal_False, SC_DB_MAKE, SC_DBSEL_ROW_DOWN );
+	ScDBData*		pDBData = GetDBData( sal_False, SC_DB_OLD_FILTER, SC_DBSEL_ROW_DOWN );
 
-	pDBData->SetByRow( sal_True );				//! Undo, vorher abfragen ??
-	pDBData->GetQueryParam( aParam );
+	
 
 
 	SCCOL  nCol;
-	SCROW  nRow = aParam.nRow1;
+	SCROW  nRow;
 	SCTAB  nTab = GetViewData()->GetTabNo();
 	sal_Int16   nFlag;
-	sal_Bool	bHasAuto = sal_True;
-	sal_Bool	bHeader  = pDBData->HasHeader();
+	//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++)
+	/*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 (bHasAuto)								// aufheben
+	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->
@@ -396,6 +398,12 @@ void ScDBFunc::ToggleAutoFilter()
 	}
 	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 ) )
@@ -457,7 +465,8 @@ void ScDBFunc::HideAutoFilter()
 	ScDocument* pDoc = pDocSh->GetDocument();
 
 	ScQueryParam aParam;
-	ScDBData* pDBData = GetDBData( sal_False );
+	//ScDBData* pDBData = GetDBData( FALSE );
+    ScDBData* pDBData = GetDBData(sal_False, SC_DB_OLD_FILTER);
 
 	SCTAB nTab;
 	SCCOL nCol1, nCol2;

Modified: incubator/ooo/trunk/main/sc/source/ui/view/tabvwshc.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/view/tabvwshc.cxx?rev=1372767&r1=1372766&r2=1372767&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/view/tabvwshc.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/view/tabvwshc.cxx Tue Aug 14 08:22:33 2012
@@ -171,7 +171,7 @@ SfxModelessDialog* ScTabViewShell::Creat
 									 SCITEM_QUERYDATA,
 									 SCITEM_QUERYDATA );
 
-			ScDBData* pDBData = GetDBData( sal_True, SC_DB_MAKE, SC_DBSEL_ROW_DOWN);
+			ScDBData* pDBData = GetDBData( sal_True, SC_DB_MAKE_FILTER, 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, SC_DBSEL_ROW_DOWN);
+			ScDBData* pDBData = GetDBData( sal_True, SC_DB_MAKE_FILTER, SC_DBSEL_ROW_DOWN);
 			pDBData->GetQueryParam( aQueryParam );
 
 			aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA,



Mime
View raw message