avoid negative offsets to OUString::copy

Change-Id: I0a62f8a38694a4a7662fe376aaabc35dca817d33
(cherry picked from commit c2f0845931b7cb1007d54173c2633c44123a137c)
fix caption dialog

Change-Id: I499f47b116ff6957bbbc20b91224fe95593d1da1
(cherry picked from commit 2e4360815b08e1b5bd7233509d033b5a49b7c61e)