Now lets look at the factors from both sides for respect.
(M): Carry yourself in a manner which builds respect. Bosses or managers who are martinets, or conversely are everyone's pal do not put themselves in a place to be regarded with respect. On the one hand the tyrant builds resentment, which can be turned into actual or false accusations. The pal may put themselves in a position where they get too chummy and may say or do something, even in jest that could be construed as harassing. Respect others' space, physical and psychological.
(E): Respect yourself and others will treat you with respect. It is too easy to slip into familiarity with co-workers or management that goes beyond office decorum. Sometimes, because of the office culture, it is too easy to try to be "one of the boys", especially for women who have traditionally been left out. This can open you to remarks and behaviors that can rapidly deteriorate into discomfort, and possibly harassment. If this does not prevent harassment, respect yourself enough to take it to someone in the company who can help.