The civil service took steps to prevent women having to work alone with Alex Salmond at night, his trial has been told.
Chris Birt, a Scottish government civil servant, said new rotas were drawn up after two female colleagues told him about alleged incidents involving Mr Salmond.
But he said the new policy was never formally written down.
Mr Salmond denies 13 charges of sexual assault against nine women.
The alleged offences are all said to have happened when Mr Salmond was serving as Scotland’s first minister and the leader of the SNP.
Mr Salmond was cleared of a further charge of sexual assault against a 10th woman after it was dropped by the Crown when the prosecution case ended on Monday afternoon.
The defence will begin to set out its case on Tuesday, with Mr Salmond expected to give evidence.
Earlier on Monday, Mr Birt told the High Court in Edinburgh that “we changed the rota” in about April 2014 in an attempt to ensure that no female civil servant would be alone with Mr Salmond in his Bute House residence.
He said he did not think it was “ever written down”, but that the rotas would have shown two names against a particular task rather than one name.
Mr Birt said the aim was for another, “generally male”, civil servant to be working alongside any female civil servants.
He said this came after he was contacted by two of the complainers – known as Women F and Woman G.
Mr Salmond denies two charges of sexual assault against both women, including one which alleges that he intended to rape Woman F in December 2013.
Mr Birt said he had spoken to Woman F towards the end of 2013, when she had appeared “traumatised” and like “something clearly very upsetting had happened to her”.
He said Woman F told him about the alleged incident, adding: “I was shocked. Mr Salmond’s behaviour was often difficult. I didn’t really know what to say initially.”
Mr Birt said he had spoken to his superior and it was agreed that one of the first minister’s special advisors, Geoff Aberdein, should be told “with the aim of speaking to Alex Salmond”.
Woman F has previously told the trial that Mr Salmond told her to sit on a bed in his Bute House residence in December 2013, lifted up her skirt and told her she was “irresistible”.
She also said that Mr Salmond subsequently apologised to her for his behaviour after being asked to do so by Mr Aberdein.
Under cross-examination from Mr Salmond’s lawyer, Gordon Jackson QC, Mr Birt said that the civil service had been in a “difficult position” because it had “allowed this to build up over time”.
Mr Jackson put it to the witness: “This inappropriate behaviour had become part of the culture sadly, but that’s just what happened?”
Mr Birt replied: “Yes, sadly”.
He went on to say: “Frankly I can’t speak for the women involved, but for myself I would not have trusted the civil service procedures in place at that time to be able to handle such sensitive issues.”
Another civil servant, Michael McIlhenny, also told the court that efforts were made to either “double up” or “avoid single female contact with Mr Salmond after certain points of the evening”.
But he said this was “more an operational response than an official policy”.
Earlier on Monday, a civil servant known as Woman B said she had been at a meeting at Mr Salmond’s Bute House residence late one evening.
She said the topics had included a Christmas card that had been created by artist Jack Vettriano for Mr Salmond to send to a “very large” number of people.
Woman B said there had been agreement that the image was inappropriate and should not be used as it showed a younger, “scantily clad” woman leaning up to kiss an older man.
A different image by Mr Vettriano was eventually used for the Christmas card.
The other two people at the meeting left the room, leaving her and Mr Salmond alone, she said.
Woman B said she started to gather her papers so that she could also leave.
But she alleged that Mr Salmond suddenly “grabbed my wrists and pulled me towards him” and asked her to recreate the image on the Christmas card.
She said she had been “shocked” and had tried to remove his hands, but it “felt like every time I managed to get a hand off, another hand would appear.
“He was very persistent – it felt like I was sort of wrestling with an octopus, there was always another hand coming at my wrists.
“He was leaning towards me and trying to pull me in to him, and because he’d said let’s recreate the pose I knew it was a sexual approach.”
Woman B claimed that Mr Salmond stopped as soon as one of the other people who had been at the meeting returned to the room.
She said she told her husband about the alleged incident, and also told a colleague and her line manager – but “there wasn’t an option to take things further at that time in the Scottish government”.
She claimed the relationship between the civil service and Mr Salmond at that time meant that she would have been “removed” if she had formally complained.
What has the trial heard so far?
- Woman tells court Alex Salmond ‘pounced’ on her
- Alex Salmond trial witness denies making up allegations
- Woman claims former first minister gave her ‘very sloppy’ kisses
- Woman says former first minister ‘apologised’ for behaviour
- Woman says Salmond kissed her after ‘zombie walk’
Defence lawyer Shelagh McCall QC put it to Woman B that Mr Salmond had been in a “playful” mood and that the alleged incident had merely been “high jinks”.
Woman B dismissed this suggestion, adding: “Restraining someone’s wrists and trying to kiss them is more than inappropriate.”
When asked by Ms McCall why she had not formally complained at the time, Woman B replied: “If I had complained it would have been swept under the carpet and I would have suffered in my career as a result.
“I would have been moved. I never saw anyone in a senior position in the Scottish government tackle the first minister over his behaviour.”
The next witness said she had been a colleague of Woman B and had been told by her about the alleged incident the following day.
She also told Ms McCall that she thought Mr Salmond had been in a “cheerful and playful” mood that night.
Mr Salmond says he is innocent of all the allegations against him.
He has entered not guilty pleas to all 13 of the charges which he still faces, which include one charge of attempted rape, one of sexual assault with intent to rape, nine sexual assaults and two indecent assaults.