[ooo-build] 2 problems with KDE4 integration

Rafael Cabral cabral at mandriva.com
Thu Sep 3 13:28:08 PDT 2009


Jan Holesovsky wrote:
> Hi Roman,
>
> We got 2 reports of problems with the KDE4 integration - do you think you 
> would have some time to have a look at them, please?
>
> https://bugzilla.novell.com/show_bug.cgi?id=535944
> https://bugzilla.novell.com/show_bug.cgi?id=536581
>
> Thank you a lot,
> Kendy
> _______________________________________________
> ooo-build mailing list
> ooo-build at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/ooo-build
>   
Hi,

About #535944, I've sent a solution to Roman to a similar bug. Maybe
that solves this too. See
(http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=536664).  About the
auto-extension and another KDE4 bug I've solved, you could either
replace or patch KDE4FilePicker::getFiles in the
unx/kde4/KDE4FilePicker.cxx , by this:

uno::Sequence< ::rtl::OUString > SAL_CALL KDE4FilePicker::getFiles()

    throw( uno::RuntimeException )
{
       QStringList files = _dialog->selectedFiles();
       USHORT i, nCount = files.size();
       /*Workarround for the double click selection KDE4 bug */
       const QString dir = "file://" + KUrl(files[0]).directory();
       for (i = 0; i < files.size(); i++) {
                const QString test = "file://" + files[i];
                if ((dir + "/") == test)
                        nCount--;
       }
       USHORT nTotal = nCount > 1 ? nCount+1: nCount;

       uno::Sequence< ::rtl::OUString > seq(nTotal);
       if ( nCount == 1 ) {
                // add file extension since it was a saving dialog and
                // the autoextension checkbox was checked
                QString extension = "";
                if ( _dialog->operationMode() == KFileDialog::Saving )
                {
                        QCheckBox *cb = dynamic_cast<QCheckBox*> ( _customWidgets [ ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION ] );
                        if (cb->isChecked()) {
                                extension =  _dialog->currentFilter(); // assuming filter value is like this *.ext
                                extension.replace("*","");
                        }
                }
                const QString fileName = "file://" + files[0] + extension;
                seq[0] = toOUString(fileName);
       }
       else if (nCount > 1)
       {
                seq[0] = toOUString( dir );
                for (i = 0; i < nCount; ) {
                        const QString fileName = KUrl(files[i++]).fileName();
                        seq[i] = toOUString(fileName);
                }
        }
       return seq;
}


To fill in the filters you could use this:

void SAL_CALL KDE4FilePicker::appendFilter( const ::rtl::OUString
&title, const ::rtl::OUString &filter )
    throw( lang::IllegalArgumentException, uno::RuntimeException )
{
        QString t = toQString(title);
        QString f = toQString(filter);

        if (!_filter.isNull())
        {
                _filter.append("\n");
        }

        //add to hash map for reverse lookup in getCurrentFilter
        _filters.insert(f, t);

        // '/' meed to be escaped to else they are assumed to be mime
types by kfiledialog
        //see the docs
        t.replace("/", "\\/");

        _filter.append(QString("%1|%2").arg(f).arg(t));
}

void SAL_CALL KDE4FilePicker::appendFilterGroup( const rtl::OUString&,
const uno::Sequence<beans::StringPair>& aFilters)
    throw( lang::IllegalArgumentException, uno::RuntimeException )
{
        USHORT i;
        if (!_filter.isNull())
                _filter.append(QString("\n"));
        for (i = 0; i < aFilters.getLength(); i++)
        {
                beans::StringPair aPair = aFilters[i];
                _filter.append(QString("%1|%2").arg( toQString
(aPair.Second).replace(";", " ")  ).arg(
toQString(aPair.First).replace("/","\\/")+"\n" ) );
        }
        if (i > 0)
                _filter.append(QString("*.*|*.*"));
}

About #536581, the first problem, I think that is because the vcl kde4 implementation needs some sort of optimization such as a cache mechanism for the KDE/QT widgets (when drawControl of the kde style is called) since the previous version (kde3 integration) has one and IIRC it used to work as fast as gnome did. Another problem might be because combining events loops of QT and OOo is not properly implemented. I've been studying these problems over last weeks. As soon as I've some solution I will send this. 

About the second problem, replacing the x11EventFilter in the vcl/unx/kde4/VCLKDEApplication.cxx could solve. At least it makes OOo screen behind kde4 pickers to be properly painted when you need drag the pickers.

bool VCLKDEApplication::x11EventFilter(XEvent* event)
{
        disp->DispatchInternalEvent();
        disp->GetXLib()->CheckTimeout( true );
        //if we have a display and the display consumes the event
        //do not process the event in qt
        if (disp && disp->Dispatch(event) > 0)
        {
                return true;
        }

        return false;
}


Further,  I'm so sorry why I don't send those patches yet since I've done many changes and the patches to learn how thinks work and it will look horrible and further I'm in moving process and next week things get better and I can send those patches if one might not.

Many thanks to Phillip from Sun who has greatly helped me to understand
about OOo vcl layer and others.

Rafael Cabral
Mandriva




More information about the ooo-build mailing list