A search for ".component:DB/FormGridView" in http://lxr.go-oo.org gives us 4 file 
founds http://lxr.go-oo.org/search?filestring=&string=%22.component%3ADB%2FFormGridView%22

One 
(http://lxr.go-oo.org/source/dba/dbaccess/source/ui/browser/exsrcbrw.cxx#333) 
shows us that we may be in the right direction using a dispatch object.

What is sure, is that internally they use other things (as the search returns 
only 4 files).

It would be nice to search what they do to open the query designer for editing 
a SQL command in a form control (this is a new feature).



If I'm not wrong, they implement this as follows:

extensions/source/propctrlr is where the property browser is
implemented

extensions/source/propctrlr/formcomponenthandler.cxx
FormComponentPropertyHandler::impl_doDesignSQLCommand_nothrow is what I
was looking for:

 m_xCommandDesigner.set( new SQLCommandDesigner(
m_aContext.getUNOContext(), xCommandUI.get(), m_xRowSetConnection, LINK(
this, FormComponentPropertyHandler, OnDesignerClosed ) ) );


has taken me to SQLCommandDesigner in
extensions/source/propctrlr/sqlcommanddesign.cxx


And SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow() shows us we
were not so wrong:

*************************************************************************
Reference< XComponentLoader > xLoader(
impl_createEmptyParentlessTask_nothrow(), UNO_QUERY_THROW );
            Sequence< PropertyValue > aArgs( 5 );
            aArgs[0].Name = PROPERTY_ACTIVE_CONNECTION;
            aArgs[0].Value <<= m_xConnection.getTyped();

            aArgs[1].Name  = PROPERTY_COMMAND;
            aArgs[1].Value <<= m_xObjectAdapter->getSQLCommand();
            aArgs[2].Name  = PROPERTY_COMMANDTYPE;
            aArgs[2].Value <<= (sal_Int32)CommandType::COMMAND;
            aArgs[3].Name  = PROPERTY_ESCAPE_PROCESSING;
            aArgs[3].Value <<= m_xObjectAdapter->getEscapeProcessing();

            aArgs[4].Name  = ::rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( "GraphicalDesign" ) );
            aArgs[4].Value <<= m_xObjectAdapter->getEscapeProcessing();

                        Reference< XComponent > xQueryDesign = 
xLoader->loadComponentFromURL(
                ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
".component:DB/QueryDesign" ) ),
                                ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 
"_self" ) ),
                                FrameSearchFlag::TASKS | 
FrameSearchFlag::CREATE,
                                aArgs
                        );

            // remember this newly loaded component - we need to care
for it e.g. when we're suspended
            m_xDesigner = m_xDesigner.query( xQueryDesign );
            OSL_ENSURE( m_xDesigner.is() || !xQueryDesign.is(),
"SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: the component is
expected to be a controller!" );
            if ( m_xDesigner.is() )
            {
                Reference< XPropertySet > xQueryDesignProps(
m_xDesigner, UNO_QUERY );
                OSL_ENSURE( xQueryDesignProps.is(),
"SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: the controller
should have properties!" );
                if ( xQueryDesignProps.is() )
                {
                    xQueryDesignProps->addPropertyChangeListener(
PROPERTY_ACTIVECOMMAND, this );
                    xQueryDesignProps->addPropertyChangeListener(
PROPERTY_ESCAPE_PROCESSING, this );
                }
            }

            // get the frame which we just opened and set it's title
            Reference< XPropertySet > xFrameProps;
            Reference< XController > xController( xQueryDesign,
UNO_QUERY );
            if ( xController.is() )
                xFrameProps = xFrameProps.query( xController->getFrame() );

            if ( xFrameProps.is() )
            {
                Reference< XPropertySetInfo > xInfo =
xFrameProps->getPropertySetInfo();
                if ( xInfo.is() && xInfo->hasPropertyByName(
PROPERTY_TITLE ) )
                {
                        ::svt::OLocalResourceAccess aEnumStrings( PcrRes(
RID_RSC_ENUM_COMMAND_TYPE ), RSC_RESOURCE );
                        ::rtl::OUString sDisplayName = String( PcrRes(
CommandType::COMMAND + 1 ) );
                    xFrameProps->setPropertyValue( PROPERTY_TITLE,
makeAny( sDisplayName ) );
                }
            }
*********************************************************************

As you can see, they use XComponentLoader::loadComponentFromURL as my
first example, instead of querying a dispatch object.

My guessing is they work the same: when using loadComponentFromURL() we
pass an internal URL ".component:DB/QueryDesign" (not the URL of a
file), so the loader implementation queries for a dispatch registered
for this command URL, and finds the css.sdb.ContentLoader.

But XComponentLoader::loadComponentFromURL is better because it return a reference to the loaded component, while XDispatch::dispatch() returns void.


To see the glass half-full and not half-empty: we've done too much, with
too little (documentation).

To Andrew:
It appears to work - but can also get the OpenOffice process very confused...as 
in totally hung...

could this be one of this cases "no one has ever tried/tested this"?

Another possibility could be that that the implementation does not
support drag&drop etc. by itself: I mean, if you tested opening the
query designer, you can create a query and press the button save, but it
does not get saved in the DatabaseDocument (at least that's what I've
seen in the few tests I've done last night).

My guessing is that this could be like the css.ui.dialogs.FilePicker: it
only shows a dialog, you must take care of saving/opening/showing a
preview/or anything else you're trying to achieve with this FilePicker.

Applied to our case: if we open a QueryDesigner, do we have to care of
saving the query definition/etc.? :-(

At least we have come to this:

********************************************************
Sub Test
    Dim aProps(5) as New com.sun.star.beans.PropertyValue
    aProps(0).Name = "DataSourceName"
    aProps(0).Value = "Bibliography"
    aProps(1).Name = "CommandType"
    aProps(1).Value = com.sun.star.sdb.CommandType.TABLE
    aProps(2).Name = "Command"
    aProps(2).Value = "biblio"
    aProps(3).Name = "ShowTreeView"
    aProps(3).Value = false
    aProps(4).Name = "ShowTreeViewButton"
    aProps(4).Value = false
    aProps(5).Name = "ShowMenu"
    aProps(5).Value = true

    oComp = StarDesktop.loadComponentFromURL(_
        ".component:DB/DataSourceBrowser", "_blank", 0, aProps)
    oComp.getFrame().Title = "This works... but..."

End Sub
*********************************************************************

Not so bad... but...


Regards
Ariel.



--
Ariel Constenla-Haile
La Plata, Argentina

[EMAIL PROTECTED]
[EMAIL PROTECTED]

http://www.ArielConstenlaHaile.com.ar/ooo/



"Aus der Kriegsschule des Lebens
                - Was mich nicht umbringt,
        macht mich härter."
                Nietzsche Götzendämmerung, Sprüche und Pfeile, 8.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to