You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openoffice.apache.org by bu...@apache.org on 2015/09/01 20:35:01 UTC

[Issue 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

https://bz.apache.org/ooo/show_bug.cgi?id=123544

--- Comment #25 from brinzing <ol...@gmx.de> ---
i think there is a "workaround" for the "setDisplayDirectory" problem:
setting "/org.openoffice.Office.Common/Path/Info.WorkPathChanged" = true
seems to force the folder change. see attached macro for details.

VistaFilePickerImpl.cxx:
void VistaFilePickerImpl::impl_sta_SetDirectory(const RequestRef& rRequest)
{
    bool            bForce     = rRequest->getArgumentOrDefault(PROP_FORCE,
false);
    [...]
   if ( m_bInExecute || bForce )
        iDialog->SetFolder(pFolder);
}

VistaFilePicker.cxx:
void SAL_CALL VistaFilePicker::setDisplayDirectory(const ::rtl::OUString&
sDirectory) 
{ 
[..]
    bool bChanged(false);
    if (( aValue >>= bChanged ) && bChanged )
    {
        ::comphelper::ConfigurationHelper::writeDirectKey(
            m_xSMGR, aPackage, aRelPath, aKey, css::uno::makeAny(false),  
::comphelper::ConfigurationHelper::E_STANDARD);
    }
[...]
    rRequest->setArgument(PROP_FORCE, bChanged);
}


OPTION EXPLICIT

Sub Main()
    Call TestSetdialog("file:///d:/test")
    Call TestSetdialog("file:///d:/temp")
    Call TestSetdialog("file:///d:/test")
    Call TestSetdialog("file:///d:/temp")
End Sub

Sub TestSetdialog(ByVal sPath as String)
    Dim dlg as Object
    Dim oDoc as Object
    Dim mNoArgs()
    Dim sURL as String

    dlg = CreateUnoService( "com.sun.star.ui.dialogs.FilePicker" )

    Dim Dialogtyp(0)
    DialogTyp(0) =
com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_AUTOEXTENSION

    dlg.initialize(DialogTyp())
    dlg.Title = "Test"

    sURL = "private:factory/swriter"
    oDoc = StarDesktop.loadComponentFromURL(sURL, "_blank", 0, mNoArgs)

    Dim oConfigProvider as Object
    Dim oRegistryKeyContent as Object
    Dim aNodePath(0) as new com.sun.star.beans.PropertyValue
    oConfigProvider =
createUnoService("com.sun.star.configuration.ConfigurationProvider")
    aNodePath(0).Name = "nodepath"
    aNodePath(0).Value = "/org.openoffice.Office.Common/Path/Info"
    oRegistryKeyContent =
oConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess",
aNodePath())
    oRegistryKeyContent.WorkPathChanged = true
    oRegistryKeyContent.commitChanges

    dlg.DisplayDirectory = sPath

    If dlg.Execute = 1 Then 
        sURL = dlg.Files(0)
        oDoc.storeAsURL(sURL, mNoArgs)
    EndIf

End Sub

-- 
You are receiving this mail because:
You are the assignee for the issue.
You are on the CC list for the issue.