There is a valid reason why this happens. Most CFD's are synthetic derivatives that extract their pricing from an underlying instrument. Often the CFD pricing can "drift" away from the underlying asset, especially as the contract approaches expiry....I assume this is because the CFD has variables in the pricing(like time before expiry) that do not affect the underlying asset.
When the contract expires, the broker has 2 options:-
1. Close your trade. Generally they will introduce a new contract where you need to open you position again.
2. Rollover your trade into the new contract without closing it.
The moment the new contract is available and priced, the pricing should match the underlying asset. Using your long as an example, the CFD has drifted well below the price of the underlying asset. You can see the new pricing involved a massive jump in price. As you can imagine, the broker needs to find a way to reset the pricing without affecting the underlying position which is why they charge a 1 time swap equivalent to the change in price.
You have already noticed that the floating loss was transferred to swap. This is a good example of the price reset at work. The price is rolled over to the new contract without affecting the value of your position. I know this may appear as the broker messing with you but think of it this way.....the underlying asset did not jump in value, so the increase in price was not justified by the underlying asset. Also think of how you would have felt if this was a short position and the price reset occurred. A short position would have paid an equivalent amount of swap to the trader to compensate for the price reset.
This jump will happen every time the contract expires, so you should pay attention to expiry dates. Some brokers will just close your position which can be just as shocking if you do not expect it.
As a side note many CFD's can start their pricing quite far off the underlying asset and the price converges towards the price of the asset, producing a potential arbitrage opportunity. Unfortunately brokers will apply swap charges in a way that removes this arbitrage.