Partial Fractions decomposition

I have an example of **Partial Fractions decomposition**, but cant understand it.

Here we have $\displaystyle \frac{2x^3+4x^2+x+2}{(x-1)^2(x^2+x+1)}$

$\displaystyle \frac{2x^3+4x^2+x+2}{(x-1)^2(x^2+x+1)}=\frac{A}{(x-2)^2}+\frac{B}{x-1}+\frac{C_x+D}{x^2+x+1}$

$\displaystyle \frac{2x^3+4x^2+x+2}{(x-1)^2(x^2+x+1)}=\frac{A(x^2+x+1)+B(x-1)(x^2+x+1)+(C_x+D)(x-1)^2}{(x-1)^2(x^2+x+1)}$

$\displaystyle 2x^3+4x^2+x+2=A(x^2+x+1)+B(x-1)(x^2+x+1)+(C_x+D)(x-1)^2$

And whats goes next, I __totally__ don't get

x^3 $\displaystyle B+C=2$

x^2 $\displaystyle A-2C+D=4$

x^1 $\displaystyle A+C-2D=1$

x^0 $\displaystyle A-B+D=2$

$\displaystyle A=3$; $\displaystyle B=2$; $\displaystyle C=0$; $\displaystyle D=1$

So could anyone explain me that most imprtant part?

Now that I think more, it seems that I posted it on wrong section. It's just that later that fromula will be integrated, so it should be known in calculus.

**Seems I used wrong name for this method**