In the manga and the anime, Vivi was being held captive by CPO, until she was unexpectedly saved by Wapol. According to the manga and the anime, after Wapol witnessed the murder of Vivi's father, King Cobra, he freaked out, and started eating his way out. That's when he ran into Vivi, who jumped into Wapol's mouth as a means of escape. However, there are some things that I'm still trying to figure out: how exactly did Vivi get inside of Wapol's when she was tied up? Also, how is it that Wapol didn't swallow her by accident? What are you thoughts?
(References: One Piece Manga 1086; Google Images- One Piece- YouTube- Princess Vivi Saved by Wapol)