Kaydet (Commit) c29cc3f4 authored tarafından Markus Mohrhard's avatar Markus Mohrhard Kaydeden (comit) Kohei Yoshida

make VbaWorksheet Autofilter work with sheet local DBData

üst 3965636e
...@@ -529,7 +529,7 @@ public: ...@@ -529,7 +529,7 @@ public:
SC_DLLPUBLIC sal_Bool GetTable( const String& rName, SCTAB& rTab ) const; SC_DLLPUBLIC sal_Bool GetTable( const String& rName, SCTAB& rTab ) const;
void SetAnonymousDBData(SCTAB nTab, ScDBData* pDBData); void SetAnonymousDBData(SCTAB nTab, ScDBData* pDBData);
ScDBData* GetAnonymousDBData(SCTAB nTab); SC_DLLPUBLIC ScDBData* GetAnonymousDBData(SCTAB nTab);
SC_DLLPUBLIC inline SCTAB GetTableCount() const { return nMaxTableNumber; } SC_DLLPUBLIC inline SCTAB GetTableCount() const { return nMaxTableNumber; }
SvNumberFormatterIndexTable* GetFormatExchangeList() const { return pFormatExchangeList; } SvNumberFormatterIndexTable* GetFormatExchangeList() const { return pFormatExchangeList; }
...@@ -1238,7 +1238,7 @@ public: ...@@ -1238,7 +1238,7 @@ public:
SC_DLLPUBLIC sal_Bool ApplyFlagsTab( SCCOL nStartCol, SCROW nStartRow, SC_DLLPUBLIC sal_Bool ApplyFlagsTab( SCCOL nStartCol, SCROW nStartRow,
SCCOL nEndCol, SCROW nEndRow, SCCOL nEndCol, SCROW nEndRow,
SCTAB nTab, sal_Int16 nFlags ); SCTAB nTab, sal_Int16 nFlags );
sal_Bool RemoveFlagsTab( SCCOL nStartCol, SCROW nStartRow, SC_DLLPUBLIC sal_Bool RemoveFlagsTab( SCCOL nStartCol, SCROW nStartRow,
SCCOL nEndCol, SCROW nEndRow, SCCOL nEndCol, SCROW nEndRow,
SCTAB nTab, sal_Int16 nFlags ); SCTAB nTab, sal_Int16 nFlags );
......
...@@ -108,6 +108,8 @@ ...@@ -108,6 +108,8 @@
#include "vbasheetobjects.hxx" #include "vbasheetobjects.hxx"
#include "viewuno.hxx" #include "viewuno.hxx"
#include "attrib.hxx"
#define STANDARDWIDTH 2267 #define STANDARDWIDTH 2267
#define STANDARDHEIGHT 427 #define STANDARDHEIGHT 427
#define DOESNOTEXIST -1 #define DOESNOTEXIST -1
...@@ -444,38 +446,39 @@ ScVbaWorksheet::setEnableSelection( sal_Int32 nSelection ) throw (uno::RuntimeEx ...@@ -444,38 +446,39 @@ ScVbaWorksheet::setEnableSelection( sal_Int32 nSelection ) throw (uno::RuntimeEx
} }
uno::Reference< beans::XPropertySet > ScVbaWorksheet::getFirstDBRangeProperties() throw (uno::RuntimeException)
{
uno::Reference< beans::XPropertySet > xModelProps( mxModel, uno::UNO_QUERY_THROW );
uno::Reference< container::XIndexAccess > xDBRangesIA( xModelProps->getPropertyValue(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DatabaseRanges" ) ) ), uno::UNO_QUERY_THROW );
for( sal_Int32 nIndex = 0, nCount = xDBRangesIA->getCount(); nIndex < nCount; ++nIndex )
{
uno::Reference< sheet::XCellRangeReferrer > xDBRange( xDBRangesIA->getByIndex( nIndex ), uno::UNO_QUERY_THROW );
// check if the database area is on this sheet
uno::Reference< sheet::XCellRangeAddressable > xRangeAddr( xDBRange->getReferredCells(), uno::UNO_QUERY_THROW );
if( getSheetID() == xRangeAddr->getRangeAddress().Sheet )
return uno::Reference< beans::XPropertySet >( xDBRange, uno::UNO_QUERY_THROW );
}
return uno::Reference< beans::XPropertySet >();
}
sal_Bool SAL_CALL ScVbaWorksheet::getAutoFilterMode() throw (uno::RuntimeException) sal_Bool SAL_CALL ScVbaWorksheet::getAutoFilterMode() throw (uno::RuntimeException)
{ {
uno::Reference< beans::XPropertySet > xDBRangeProps = getFirstDBRangeProperties(); uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
sal_Bool bAutoFilterMode = false; ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument();
return ScDBData* pDBData = pDoc->GetAnonymousDBData(getSheetID());
xDBRangeProps.is() && if (pDBData)
(xDBRangeProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutoFilter" ) ) ) >>= bAutoFilterMode) && return pDBData->HasAutoFilter();
bAutoFilterMode; return false;
} }
void SAL_CALL ScVbaWorksheet::setAutoFilterMode( sal_Bool bAutoFilterMode ) throw (uno::RuntimeException) void SAL_CALL ScVbaWorksheet::setAutoFilterMode( sal_Bool bAutoFilterMode ) throw (uno::RuntimeException)
{ {
uno::Reference< beans::XPropertySet > xDBRangeProps = getFirstDBRangeProperties(); uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
if( xDBRangeProps.is() ) ScDocShell* pDocShell = excel::getDocShell( xModel );
xDBRangeProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutoFilter" ) ), uno::Any( bAutoFilterMode ) ); ScDocument* pDoc = pDocShell->GetDocument();
ScDBData* pDBData = pDoc->GetAnonymousDBData(getSheetID());
if (pDBData)
{
pDBData->SetAutoFilter(bAutoFilterMode);
ScRange aRange;
pDBData->GetArea(aRange);
if (bAutoFilterMode && pDoc)
pDoc->ApplyFlagsTab( aRange.aStart.Col(), aRange.aStart.Row(),
aRange.aEnd.Col(), aRange.aStart.Row(),
aRange.aStart.Tab(), SC_MF_AUTO );
else if (!bAutoFilterMode && pDoc)
pDoc->RemoveFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(),
aRange.aEnd.Col(), aRange.aStart.Row(),
aRange.aStart.Tab(), SC_MF_AUTO );
ScRange aPaintRange(aRange.aStart, aRange.aEnd);
aPaintRange.aEnd.SetRow(aPaintRange.aStart.Row());
pDocShell->PostPaint(aPaintRange, PAINT_GRID);
}
} }
uno::Reference< excel::XRange > uno::Reference< excel::XRange >
......
...@@ -72,8 +72,6 @@ class ScVbaWorksheet : public WorksheetImpl_BASE ...@@ -72,8 +72,6 @@ class ScVbaWorksheet : public WorksheetImpl_BASE
css::uno::Reference< css::container::XNameAccess > getFormControls(); css::uno::Reference< css::container::XNameAccess > getFormControls();
css::uno::Any getControlShape( const rtl::OUString& sName ); css::uno::Any getControlShape( const rtl::OUString& sName );
css::uno::Reference< css::beans::XPropertySet > getFirstDBRangeProperties() throw (css::uno::RuntimeException);
protected: protected:
ScVbaWorksheet( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ); ScVbaWorksheet( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment