There are laws regulating layoffs due to operating conditions (Kuendigungsschutzgesetz). But these laws do not allow the government to intervene directly in company affairs - that would be communism! If a company wants to restructure "for internal reasons" (rationalizations are specifically mentioned) it is allowed to do so. This includes offshoring, moving workload to contractors, or simply getting rid of a department.
However: many of the large companies (eg. SAP, BASF, carmakers,...) have collective labor agreements. These agreements often exclude layoffs due to operational conditions within a certain period. Under very special circumstances layoffs are still possible in such arrangements, but the companies have to prove their economic hardship and the layoffs often end with a sort of golden handshake. If they happen at all :)