• Maxim Monastirsky's avatar
    Fix wrong use of OUString::copy · 0dbe3d40
    Maxim Monastirsky yazdı
    Code like:
    
    if( aCommandURL.copy(5) != ".uno:" )
    
    is obviously wrong, as OUString::copy(sal_Int32) takes the _beginning_
    index, so for this condition to be false the command URL must have
    ".uno:" in the _middle_ of the string. This created some weird things
    like an empty label attribute added to any submenu item. Moreover, the
    command URL can be easily shorter than 5 (like when a custom submenu
    added by the user). Using copy(5) in such case officially considered as
    "undefined behavior" and will trigger an assert in debug build (that's
    how I discovered this code actually).
    
    Most likely the original intent was to check whether the command URL
    doesn't start with ".uno:", and so should be changed to use
    OUString::startsWith. But doing that will create a regression, as it
    won't be possible anymore to change labels of commands that start with
    ".uno:". Simply dropping this check seems to be better solution here.
    
    Change-Id: I2f88807eceae1006066a14750f2003e235f49ad4
    0dbe3d40
menudocumenthandler.cxx 32.2 KB