OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Filtering in Calc

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
EricR
General User
General User


Joined: 02 Aug 2004
Posts: 5

PostPosted: Fri Aug 06, 2004 6:40 am    Post subject: Filtering in Calc Reply with quote

Well. I first have to state that i'm a beginner in OOO and UNO.

My first try has been to write a macro to set up a filter from the current column and selected value and i've ended with the following :

Code:

Sub FiltrePareil
Dim MaCase As Object, MaFeuille as Object
MaFeuille = ThisComponent.CurrentController.ActiveSheet
MaCase = ThisComponent.CurrentSelection(0).GetCellByPosition(0,0)
MaColonne = MaCase.CellAddress.Column
MaValeur = MaCase.String
dim xFilterDesc as Object
xFilterDesc = MaFeuille.createFilterDescriptor(true)
dim aFilterFields(0) as new com.sun.star.sheet.TableFilterField
    aFilterFields(0).Field        = MaColonne
    aFilterFields(0).IsNumeric   = false
    aFilterFields(0).Operator     = com.sun.star.sheet.FilterOperator.EQUAL
    aFilterFields(0).StringValue = MaValeur
xFilterDesc.setFilterFields(aFilterFields())
xFilterDesc.ContainsHeader = true
MaFeuille.filter(xFilterDesc)
end sub


I'm sure there is a better way to do it(feel free to give any comment) but that's not my current problem (at least that code runs fine in my case Wink

In fact, i'd now like to be able to set the filtering off.
I've found that piece of code by recording a macro.
Code:

sub DesactiveFiltreStd
dim document   as object
dim dispatcher as object
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:DataFilterRemoveFilter", "", 0, Array())
end sub

but i'm not sure i'm ready to use that dispatch thing and i'd like to stick to "basic" basic Smile

So i wonder if a sheet (or a range) has a property indicating that a filter is active or not and if by setting that property to false i could do the job.
Or should i use the same kind of code with a empty FilterDescriptor ????

TIA for any hints

Eric
PS Sorry for my english. It's noot my native language Confused
Back to top
View user's profile Send private message
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3618
Location: Columbus, Ohio, USA

PostPosted: Fri Aug 06, 2004 1:29 pm    Post subject: Reply with quote

My guess is that you should simply set an empty filter descriptor....
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
EricR
General User
General User


Joined: 02 Aug 2004
Posts: 5

PostPosted: Wed Aug 11, 2004 7:33 am    Post subject: Reply with quote

Yep .... that works Very Happy
Thanks a lot

Eric
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group