%% start of file `moderncvskillmatrix.sty'.
%% Copyright 2021 David Seus (cryptointerest@posteo.de).
%
% This package provides a skill matrix template for the moderncv package.
% Some recruiting firms require applicants to rate their skills, computer
% skills, management tools, or similar in a table involving a graphical
% illustration of their skill level. This package implements this idea
% and provides the following commands to use within the moderncv
% package:
%
%
% PUBLIC COMMANDS
%     \cvskill{<1-5>}
%         Illustrate skill level with little colored boxes.
%         By default five skill levels are predefined.
%
%         Input:
%             input_1:    integer between 0 and 5
%
%         Example usages:
%             \cvskill{3}
%
%
%     \cvskilllegend[*][<post_padding>][<first_level>][<second_level>][<third_level>][<fourth_level>][<fifth_level>]{<name>}
%         Print legend table explaining the meaning of \cvskill{1}...\cvskill{5}.
%
%         Input:
%             asterix (optional): include vertical (dashed) lines. This behaviour depends on the body style.
%                                 For the fancy style, the asterix has no meaning.
%             input_1 (optional): padding length appended to the legend, default: <0.25em>
%             input_2 (optional): string describing meaning of \cvskill{1}, default: <basic knowledge>
%             input_3 (optional): string describing meaning of \cvskill{2}, default: <intermediate knowledge with some project experience>
%             input_4 (optional): string describing meaning of \cvskill{3}, default: <extensive project experience>
%             input_5 (optional): string describing meaning of \cvskill{4}, default: <deepened expert knowledge>
%             input_6 (optional): string describing meaning of \cvskill{5}, default: <expert/guru>
%             input_7:            string giving a name to the legend, default: <>
%
%         Example usages:
%             \cvskilllegend{}    print default legend
%             \cvskilllegend[0.5em]{Legend}   print default legend, but adjust post padding and display the word ``Legend''.
%             \cvskilllegend*[0.2em][Grundkenntnisse][Grundkenntnisse und eigene Erfahrung in Projekten][Umfangreiche Erfahrung in Projekten][Vertiefte Expertenkenntnisse][Experte/Guru]{Legende}     Fully adjust legend to German example and including dashed lines
%
%         Note:
%             -The width of the columns can be adjusted by the \setcvskilllegendcolumns, see \setcvskilllegendcolumns
%             -The design of the table is such that the <second_level> entry stands in the first column but
%             occupies rows two and three. This has been done to accomodate english and german defaults.
%             An alternative is provided by \cvskillplainlegend
%
%
%     \cvskillplainlegend[*][<post_padding>][<first_level>][<second_level>][<third_level>][<fourth_level>][<fifth_level>]{<name>}
%         Print alternative legend table explaining the meaning of \cvskill{1}...\cvskill{5}.
%         In this legend, the first three skill levels are in one column
%
%         Input:
%             asterix (optional): include vertical (dashed) lines. This behaviour depends on the body style.
%                                 For the fancy style, the asterix has no meaning.
%             input_1 (optional): padding length appended to the legend, default: <0.25em>
%             input_2 (optional): string describing meaning of \cvskill{1}, default: <basic knowledge>
%             input_3 (optional): string describing meaning of \cvskill{2}, default: <intermediate knowledge with some project experience>
%             input_4 (optional): string describing meaning of \cvskill{3}, default: <extensive project experience>
%             input_5 (optional): string describing meaning of \cvskill{4}, default: <deepened expert knowledge>
%             input_6 (optional): string describing meaning of \cvskill{5}, default: <expert/guru>
%             input_7:            string giving a name to the legend, default: <>
%
%         Example usages:
%             \cvskillplainlegend{}    print default legend
%             \cvskillplainlegend[0.5em]{Legend}   print default legend, but adjust post padding and display the word ``Legend''.
%             \cvskillplainlegend*[0.2em][Grundkenntnisse][Grundkenntnisse und eigene Erfahrung in Projekten][Umfangreiche Erfahrung in Projekten][Vertiefte Expertenkenntnisse][Experte/Guru]{Legende}     Fully adjust legend to German example and including dashed lines
%
%         Note:
%             -The width of the columns can be adjusted by the \setcvskilllegendcolumns, see \setcvskilllegendcolumns
%
%
%     \cvskillhead[<post_padding>][<Level>][<Skill>][<Years>][<Comment>]%
%         add skill matrix line acting as header explaining the meaning of columns.
%
%         Input:
%             input_1 (optional): padding length appended to the legend, default: <0.25em>
%             input_2 (optional): string naming the level column (2nd column), default: <Level>
%             input_3 (optional): string naming the skill column (3nd column), default: <Skill>
%             input_4 (optional): string naming the experience-in-years column (4th column), default: <Years>
%             input_5 (optional): string naming the comment column (5th column), default: <Comment>
%
%         Example usages:
%             \cvskillhead    print default head.
%             \cvskillhead[0.5em]   print default head, but adjust post padding.
%             \cvskillhead[0.25em][Level][F\"ahigkeit][Jahre][Bemerkung]     Fully adjust head to German example
%
%         Note:
%             - The width of the columns can be adjusted by the \setcvskillcolumns command, see \setcvskillcolumns.
%
%
%     \cvskillentry[*][<post_padding>]{<skill_cathegory>}{<0-5>}{<skill_name>}{<years_of_experience>}{<comment>}%
%         add cvskill matrix row.
%
%         Input:
%             asterix (optional): include horizontal (dashed) line above the entered line. This behaviour depends on the body style.
%                                 For the fancy style, the asterix has no meaning.
%             input_1 (optional): padding length appended to the legend, default: <0.25em>
%             input_2: string, naming skill cathegory, default: <>
%             input_3: integer between 0 and 5, describing level of skill. \cvskill{input_2} is called internally, default: <>
%             input_4: string, naming the skill, default: <>
%             input_5: positive real number, stating the number of years of experience with this skill , default: <>
%             input_6: string, explaining details w.r.t. that particual skill default: <>
%
%         Example usages:
%             \cvskillentry*{Language:}{3}{Python}{2}{I have done a million projects with Python}
%             \cvskillentry{}{2}{Lilypond}{14}{So much sheet music! Man I'm the best!}
%             \cvskillentry{}{3}{\LaTeX}{14}{Clearly I rock at \LaTeX}
%             \cvskillentry*[1.5em]{OS:}{3}{Linux}{2}{I only use Archlinux}
%
%         Note:
%             - The width of the columns can be adjusted by the \setcvskillcolumns command, see \setcvskillcolumns.
%
%
%     \setcvskillcolumns[<width>][<factor>][<exp_width>]
%         adjust column width of skill table
%
%         The \cvskillentry command comes with default FIXED width definitions of the kill matrix for the columns
%         based on the author's own skill matrix. This is necessary to ensure that the entries are nicely aligned
%         and actually yield a decent looking table. The defaults depend on the style used and are chosen reasonably.
%         However, depending on the user input and the style that is used some of the columns might need adjustments.
%         The \setcvskillcolumns command provides means to influence the width of the first, the third and the fourth
%         skill matrix column. The second column containg the output of \cvskill remains fixed width. The last column,
%         the comment column gets recalculated according to the setting of the other columns.
%
%         Input
%             Input_1 (optional):     width smaller than \textwidth,  default <\skillmatrix@hintscolumnwidth>
%             Input_2 (optional):     float between 0 and 1 adjusting how much percent of the table width without
%                                     the first column is used columns two, three and four. Through this parameter
%                                     the width of the 3rd column (skill name) can be adjusted,   default <\skillmatrix@columnwidth>
%             Input_3 (optional):     width smaller than \textwidth, setting the width of the 4th column
%                                     (Years of experience), default <\cvskill@experiencewidth>
%
%         Example usage
%             \setcvskillcolumns[5em][][]%    adjust first column. Same as \setcvskillcolumns[5em]
%             \setcvskillcolumns[][0.45][]%   adjust third (skill) column. Same as \setcvskillcolumns[][0.45]
%             \setcvskillcolumns[][][\widthof{``Year''}]%     adjust fourth (years) column.
%             \setcvskillcolumns[\widthof{``Language''}][0.48][]%     adjust 1st and 3rd columns. Same as \setcvskillcolumns[\widthof{``Language''}][0.45]
%             \setcvskillcolumns[\widthof{``Management Tools''}][0.6][3em]%   ajust all at once.
%
%         Note
%             - For the styles 'classic' and 'casual' the first column is set to hintscolumnwidth such that
%                 it aligns with the rest of the entries. A readjustment of the first column should therefor
%                 be avoided. It is recomended to only use \setcvskillcolumns in the form of
%                 \setcvskillcolumns[][<factor>][<width>], thereby leaving the defaults in place for the first column.
%
%
%     \setcvskilllegendcolumns[<width>][<factor>]
%         adjust column width of legend
%
%         The \cvskilllegend command comes with default FIXED width definitions for the columns of the legend matrix
%         such that the default english and german examples look good.
%         However, depending on the user input (translation) and the style that is used some adjustment might be needed.
%         The \setcvskilllegendcolumns command provides means to influence all columns except the ones containing
%         \cvskill commands. The second column containg the output of \cvskill remains fixed width. The last column,
%         the comment column gets recalculated according to the setting of the other columns.
%
%         Input
%             Input_1 (optional):     length smaller than \textwidth influencing the width of the first column
%                                     where depending on the style the legend_string gets printed. In case the
%                                     string is left empty adjusting this width allows moving the legend horizontally.
%                                     Default <\skilllegend@hintscolumnwidth>
%             Input_2 (optional):     float between 0 and 1 influencing the width of the left legend descritor column,
%                                     aka \cvskilllegend@leftdescriptorwidth. The desriptor column on the right,
%                                     \cvskilllegend@rightdescriptorwidth is influenced by the factor 1-<factor>.
%                                     Default <\skilllegend@leftdesriptorfactor>
%
%         Example usage
%             \setcvskilllegendcolumns[][0.45]%%    adjust left desriptor column.
%             \setcvskilllegendcolumns[\widthof{``Legend''}][0.45]%   adjust both left descriptor column and string column
%
%         Note
%             - Due to implementation of \cvskilllegend for style 'fancy' (moderncvbodyv)
%                 the first optional variable has no effect in this case.
%             - For the styles 'classic' and 'casual' the first column is set to hintscolumnwidth such that
%                 it aligns with the rest of the entries. A readjustment of the first column should therefor
%                 be avoided. It is recomended to only use \cvskilllegend in the form of
%                 \cvskilllegend[][<factor>], thereby leaving the defaults in place for the first column.
%             - For style 'banking' the first column is set to align with the rest of the \cvskillentry entries
%                 Therefor adjusting the first column can be used to widen the table while moving it around. If no
%                 legend string is used, setting \cvskilllegend[0em] maximises the real enstate for the legend.
%
%
% PRIVATE COMMANDS
%
%    \recompute@cvskillmatrix@lengths
%         compute all lengths necessary for the skill matrix depending on
%         the moderncv style (moderncvbody)
%
%         Input:  none
%
%         Example usage (only internally in moderncvbody<i-v>.sty)
%             \recompute@cvskillmatrix@lengths
%
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License version 1.3c,
% available at http://www.latex-project.org/lppl/.


%-------------------------------------------------------------------------------
%                identification
%-------------------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{moderncvskillmatrix}[2024-07-18 v2.4.1 modern curriculum vitae and letter skill matrix]

% The definitions need to be adjusted depending on which moderncvbody<i-v>.sty style is usde.
% body type options: "moderncvbodyi" (default), "moderncvbodyii", "moderncvbodyiii", "moderncvbodyiv" or "moderncvbodyv"
\@initializeif{\if@moderncvbodyi}\@moderncvbodyifalse
\DeclareOption{moderncvbodyi}{\@moderncvbodyitrue\@moderncvbodyiifalse\@moderncvbodyiiifalse\@moderncvbodyivfalse\@moderncvbodyvfalse}
\@initializeif{\if@moderncvbodyii}\@moderncvbodyiifalse % this option is added in case moderncvbodyii gets implemented standalone
\DeclareOption{moderncvbodyii}{\@moderncvbodyifalse\@moderncvbodyiitrue\@moderncvbodyiiifalse\@moderncvbodyivfalse\@moderncvbodyvfalse}
\@initializeif{\if@moderncvbodyiii}\@moderncvbodyiiifalse
\DeclareOption{moderncvbodyiii}{\@moderncvbodyifalse\@moderncvbodyiifalse\@moderncvbodyiiitrue\@moderncvbodyivfalse\@moderncvbodyvfalse}
\@initializeif{\if@moderncvbodyiv}\@moderncvbodyivfalse
\DeclareOption{moderncvbodyiv}{\@moderncvbodyifalse\@moderncvbodyiifalse\@moderncvbodyiiifalse\@moderncvbodyivtrue\@moderncvbodyvfalse}
\@initializeif{\if@moderncvbodyv}\@moderncvbodyvfalse
\DeclareOption{moderncvbodyv}{\@moderncvbodyifalse\@moderncvbodyiifalse\@moderncvbodyiiifalse\@moderncvbodyivfalse\@moderncvbodyvtrue}

% If option `circle` is specified, use circles instead of small rectangles for rating skills
\@initializeif{\if@cvskillcircle}\@cvskillcirclefalse
\DeclareOption{circle}{\@cvskillcircletrue}

\DeclareOption*{}% avoid choking on unknown options
\ExecuteOptions{moderncvbodyi}
\ProcessOptions*\relax% \ProcessOptions* processes the options in the order provided (i.e., with the later ones possibly overriding the former ones), while \ProcessOptions processes them in the order of the package

%-------------------------------------------------------------------------------
%                required packages
%-------------------------------------------------------------------------------
\RequirePackage{tikz}
\RequirePackage{multirow}
% package arydshln is needed for the dashed lines but is incompatible with fancy style
\if@moderncvbodyv%
%     \RequirePackage{arydshln} % incompatible with fancy style
\else%
    \RequirePackage{arydshln} % incompatible with fancy style
\fi

% %-------------------------------------------------------------------------------
% %                \cvskill command
% %-------------------------------------------------------------------------------
% The code for the Skilllevel illustration with the little boxes.
% This is idea stolen from the limecv package, see https://github.com/opieters/limecv.git
\@initializelength{\cvSkill@ShapeSize}
\if@cvskillcircle%
    \setlength{\cvSkill@ShapeSize}{.7ex}%
    \def\cvSkill@Shape#1{\tikz\filldraw[#1] (0, 0) circle (\cvSkill@ShapeSize);}
\else
    \setlength{\cvSkill@ShapeSize}{1.2ex}
    \def\cvSkill@Shape#1{\tikz\filldraw[#1] (0, 0) rectangle (\cvSkill@ShapeSize, \cvSkill@ShapeSize);}
\fi
\newcount\my@repeat@count
\DeclareDocumentCommand{\cvskill}{m}{%
%   Illustrate skill level with little colored boxes.
%   By default five skill levels are predefined.
%
%   Input:
%       integer between 0 and 5
%   Example usage:
%       \cvskill{3}
    \begingroup
        \my@repeat@count=\z@
        \@whilenum\my@repeat@count<#1\do{\cvSkill@Shape{skillmatrixfullcolor}\advance%
        \my@repeat@count\@ne\,}%
        \my@repeat@count=\numexpr5-\z@\relax
        \@whilenum\my@repeat@count>#1\do{\cvSkill@Shape{skillmatrixemptycolor}\advance%
        \my@repeat@count\m@ne\,}%
    \endgroup
}% end \cvskill

% %-------------------------------------------------------------------------------
% %                \recompute@cvskillmatrix@lengths
% %-------------------------------------------------------------------------------

% initialise lengths needed for the skillmatrix
\@initializelength{\cvskill@width}
\@initializelength{\cvskill@descriptorwidth}
\@initializelength{\cvskill@experiencewidth}
\@initializelength{\skillmatrix@columnwidth}
\@initializelength{\skillmatrix@commentwidth}
\@initializelength{\skillmatrix@padding}
\@initializelength{\skillmatrix@hintscolumnwidth}
\@initializelength{\skillmatrix@bodylength}
\@initializelength{\cvskilllegend@leftdescriptorwidth}
\@initializelength{\cvskilllegend@rightdescriptorwidth}
\@initializelength{\skilllegend@hintscolumnwidth}
\@initializelength{\skilllegend@padding}
\@initializelength{\skilllegend@bodylength}

% \separatorrulewidth is defined in moderncvbodyv.sty and we need to
% define it to not throw an error in the other cases
\if@moderncvbodyv%
%
\else%
    \@initializelength{\separatorrulewidth}
    \setlength{\separatorrulewidth}{1ex}
\fi

\DeclareDocumentCommand{\skilllegend@leftdesriptorfactor}{}{}%
%% DEFINITION \recompute@cvskillmatrix@lengths
% declare the command \recompute@cvskillmatrix@lengths empty
\DeclareDocumentCommand{\recompute@cvskillmatrix@lengths}{}{}%
%   compute all lengths necessary for the skill matrix depending on
%   the moderncv style (moderncvbody)
%
%   Input:  none
%
%   Example usage (only internally in moderncvbody<i-v>.sty)
%       \recompute@cvskillmatrix@lengths

% Definition of \recompute@cvskillmatrix@lengths for moderncvbodyi
\if@moderncvbodyi%
    \RenewDocumentCommand{\recompute@cvskillmatrix@lengths}{}{%
        \setlength{\skillmatrix@padding}{1ex}%
        \setlength{\skillmatrix@hintscolumnwidth}{\hintscolumnwidth}%
        \setlength{\cvskill@width}{\widthof{\cvskill{5}}}%
        \setlength{\cvskill@experiencewidth}{\widthof{``Year''}}%
        \setlength{\skillmatrix@bodylength}{\maincolumnwidth}%
        \setlength{\skillmatrix@columnwidth}{0.45\skillmatrix@bodylength}%
        \setlength{\cvskill@descriptorwidth}{\skillmatrix@columnwidth-\cvskill@width-\cvskill@experiencewidth}%
        \setlength{\skillmatrix@commentwidth}{\skillmatrix@bodylength-\skillmatrix@columnwidth-3\skillmatrix@padding}%
        % lengths and definitions needed for the legends
        % note that \skillmatrix@padding also affects the appearance of legends
        \setlength{\skilllegend@padding}{0.25ex}%
        \setlength{\skilllegend@hintscolumnwidth}{\hintscolumnwidth}%
        \setlength{\skilllegend@bodylength}{\skillmatrix@bodylength}%
        \RenewDocumentCommand{\skilllegend@leftdesriptorfactor}{}{0.5}%
    }
\fi
% Definition of \recompute@cvskillmatrix@lengths for moderncvbodyiii
\if@moderncvbodyiii%
    \RenewDocumentCommand{\recompute@cvskillmatrix@lengths}{}{%
        \setlength{\skillmatrix@padding}{1ex}%
        \setlength{\separatorcolumnwidth}{\skillmatrix@padding}%
        \setlength{\skillmatrix@hintscolumnwidth}{\widthof{``Language''}}%
        \setlength{\cvskill@width}{\widthof{\cvskill{5}}}%
        \setlength{\cvskill@experiencewidth}{\widthof{``Year''}}%
        \setlength{\skillmatrix@bodylength}{\maincolumnwidth-\skillmatrix@hintscolumnwidth-\separatorcolumnwidth}%
        \setlength{\skillmatrix@columnwidth}{0.45\skillmatrix@bodylength}%
        \setlength{\cvskill@descriptorwidth}{\skillmatrix@columnwidth-\cvskill@width-\cvskill@experiencewidth}%
        \setlength{\skillmatrix@commentwidth}{\skillmatrix@bodylength-\skillmatrix@columnwidth-3\skillmatrix@padding}%
        % lengths and definitions needed for the legends
        % note that \skillmatrix@padding also affects the appearance of legends
        \setlength{\skilllegend@padding}{0.25ex}%
        \setlength{\skilllegend@hintscolumnwidth}{\skillmatrix@hintscolumnwidth}%
        \setlength{\skilllegend@bodylength}{\skillmatrix@bodylength}%
        \RenewDocumentCommand{\skilllegend@leftdesriptorfactor}{}{0.5}%
    }
\fi
% Definition of \recompute@cvskillmatrix@lengths for moderncvbodyiv
\if@moderncvbodyiv%
    \RenewDocumentCommand{\recompute@cvskillmatrix@lengths}{}{%
        \setlength{\skillmatrix@padding}{1ex}
        \setlength{\separatorcolumnwidth}{\skillmatrix@padding}
        \setlength{\skillmatrix@hintscolumnwidth}{\widthof{``Languagi''}}
        \setlength{\cvskill@width}{\widthof{\cvskill{5}}}
        \setlength{\cvskill@experiencewidth}{\widthof{``Year''}}
        \setlength{\skillmatrix@bodylength}{\maincolumnwidth-\skillmatrix@hintscolumnwidth-\separatorcolumnwidth}
        \setlength{\skillmatrix@columnwidth}{0.45\skillmatrix@bodylength}%
        \setlength{\cvskill@descriptorwidth}{\skillmatrix@columnwidth-\cvskill@width-\cvskill@experiencewidth}
        \setlength{\skillmatrix@commentwidth}{\skillmatrix@bodylength-\skillmatrix@columnwidth-3\skillmatrix@padding}%
        % lengths and definitions needed for the legends
        % note that \skillmatrix@padding also affects the appearance of legends
        \setlength{\skilllegend@padding}{0.25ex}
        \setlength{\skilllegend@hintscolumnwidth}{0ex}%\skillmatrix@hintscolumnwidth
        \setlength{\skilllegend@bodylength}{\maincolumnwidth}
        \RenewDocumentCommand{\skilllegend@leftdesriptorfactor}{}{0.45}%
    }
\fi
% Definition of \recompute@cvskillmatrix@lengths for moderncvbodyv
\if@moderncvbodyv%
    \RenewDocumentCommand{\recompute@cvskillmatrix@lengths}{}{%
        \setlength{\skillmatrix@padding}{1ex}%
        \setlength{\skillmatrix@hintscolumnwidth}{\widthof{``Languages''}}%
        \setlength{\cvskill@width}{\widthof{\cvskill{5}}}%
        \setlength{\cvskill@experiencewidth}{\widthof{``Year''}}%
        \setlength{\skillmatrix@bodylength}{\maincolumnwidth-\skillmatrix@hintscolumnwidth-\skillmatrix@padding}%\skillmatrix@hintscolumnwidth
        \setlength{\skillmatrix@columnwidth}{0.45\skillmatrix@bodylength}%
        \setlength{\cvskill@descriptorwidth}{\skillmatrix@columnwidth-\cvskill@width-\cvskill@experiencewidth}%
        \setlength{\skillmatrix@commentwidth}{\skillmatrix@bodylength-\skillmatrix@columnwidth-3\skillmatrix@padding}%
        % lengths and definitions needed for the legends
        % note that \skillmatrix@padding also affects the appearance of legends
        \setlength{\skilllegend@padding}{0.25ex}%
        \setlength{\skilllegend@hintscolumnwidth}{\skillmatrix@hintscolumnwidth}%
        \setlength{\skilllegend@bodylength}{\maincolumnwidth}%
        \RenewDocumentCommand{\skilllegend@leftdesriptorfactor}{}{0.48}%
    }%
\fi

% %-------------------------------------------------------------------------------
% %                \setcvskillcolumns and \setcvskilllegendcolumns
% %-------------------------------------------------------------------------------
% \setcvskillcolumns[<width>][<factor>][<exp_width>]
\DeclareDocumentCommand{\setcvskillcolumns}{+O{\skillmatrix@hintscolumnwidth} +O{\skillmatrix@columnwidth} +O{\cvskill@experiencewidth}}{%
%   adjust column width of skill table
%
%   The \cvskillentry command comes with default FIXED width definitions of the kill matrix for the columns
%   based on the author's own skill matrix. This is necessary to ensure that the entries are nicely aligned
%   and actually yield a decent looking table. The defaults depend on the style used and are chosen reasonably.
%   However, depending on the user input and the style that is used some of the columns might need adjustments.
%   The \setcvskillcolumns command provides means to influence the width of the first, the third and the fourth
%   skill matrix column. The second column containg the output of \cvskill remains fixed width. The last column,
%   the comment column gets recalculated according to the setting of the other columns.
%
%   Input
%       Input_1 (optional):     width smaller than \textwidth,  default <\skillmatrix@hintscolumnwidth>
%       Input_2 (optional):     float between 0 and 1 adjusting how much percent of the table width without
%                               the first column is used columns two, three and four. Through this parameter
%                               the width of the 3rd column (skill name) can be adjusted,   default <\skillmatrix@columnwidth>
%       Input_3 (optional):     width smaller than \textwidth, setting the width of the 4th column
%                               (Years of experience), default <\cvskill@experiencewidth>
%
%   Example usage
%       \setcvskillcolumns[5em][][]%    adjust first column. Same as \setcvskillcolumns[5em]
%       \setcvskillcolumns[][0.45][]%   adjust third (skill) column. Same as \setcvskillcolumns[][0.45]
%       \setcvskillcolumns[][][\widthof{``Year''}]%     adjust fourth (years) column.
%       \setcvskillcolumns[\widthof{``Language''}][0.48][]%     adjust 1st and 3rd columns. Same as \setcvskillcolumns[\widthof{``Language''}][0.45]
%       \setcvskillcolumns[\widthof{``Management Tools''}][0.6][3em]%   ajust all at once.
%
%   Note
%       - For the styles 'classic' and 'casual' the first column is set to hintscolumnwidth such that
%         it aligns with the rest of the entries. A readjustment of the first column should therefor
%         be avoided. It is recomended to only use \setcvskillcolumns in the form of
%         \setcvskillcolumns[][<factor>][<width>], thereby leaving the defaults in place for the first column.
%
    \def\arg@new@hintscolumnwidth{#1}% <-- all these terminal % signs are necessary for the fancy style to not show weird spaces!!!
    \def\arg@new@bodyLengthFactor{#2}%
    \def\arg@new@experienceWidth{#3}%
    % Check for empty arguments. Defaults are given. Thus a call of \setcvskillcolumns
    % without any arguments leads to nonempty arguments \arg@new@hintscolumnwidth and
    % \def\arg@new@bodyLengthFactor{#2}. However, we need to take care of calls like
    % \setcvskillcolumns[], \setcvskillcolumns[][], \setcvskillcolumns[][][] or even
    % \setcvskillcolumns[<somelength>][], \setcvskillcolumns[][<somefactor>]  \setcvskillcolumns[][][<length>]
    \ifdefempty{\arg@new@hintscolumnwidth}{%
        % Case \setcvskillcolumns[], \setcvskillcolumns[][] or \setcvskillcolumns[][<somefactor>]
        \ifdefempty{\arg@new@bodyLengthFactor}{%
            % Case \setcvskillcolumns[][] do nothing here and check if third argument is empty
            \ifdefempty{\arg@new@experienceWidth}{%
                % Case \setcvskillcolumns[][][] do nothing here
            }{%
                % Case \setcvskillcolumns[][][<length>]. reset \cvskill@experiencewidth and
                % \cvskill@descriptorwidth accordingly
                \setlength{\cvskill@experiencewidth}{\arg@new@experienceWidth}%
                \setlength{\cvskill@descriptorwidth}{\skillmatrix@columnwidth-\cvskill@width-\cvskill@experiencewidth}%
            }%
        }{%
            % Case \setcvskillcolumns[][<somefactor>], \setcvskillcolumns[][<somefactor>][<possilly length>]
            \setlength{\skillmatrix@columnwidth}{\arg@new@bodyLengthFactor\skillmatrix@bodylength}%
            \ifdefempty{\arg@new@experienceWidth}{%
                % Case \setcvskillcolumns[][<somefactor>][] do nothing here
            }{%
                % Case \setcvskillcolumns[][<somefactor>][<length>]. reset \cvskill@experiencewidth and
                % \cvskill@descriptorwidth accordingly
                \setlength{\cvskill@experiencewidth}{\arg@new@experienceWidth}%
                \setlength{\cvskill@descriptorwidth}{\skillmatrix@columnwidth-\cvskill@width-\cvskill@experiencewidth}%
            }%
            \setlength{\cvskill@descriptorwidth}{\skillmatrix@columnwidth-\cvskill@width-\cvskill@experiencewidth}%
            \setlength{\skillmatrix@commentwidth}{\skillmatrix@bodylength-\skillmatrix@columnwidth-3\skillmatrix@padding}%
        }%
        % Case \setcvskillcolumns[] nothing needs to be done here recalculate lengths affected by the change
    }{%
        % Case \setcvskillcolumns, \setcvskillcolumns[<width>], \setcvskillcolumns[<width>][]
        % or \setcvskillcolumns[<width>][<somefactor>]
        \setlength{\skillmatrix@hintscolumnwidth}{\arg@new@hintscolumnwidth}%
        \setlength{\skillmatrix@bodylength}{\maincolumnwidth-\skillmatrix@hintscolumnwidth-\separatorcolumnwidth}%
        % in case second argument is given but left empty use default
        \ifdefempty{\arg@new@bodyLengthFactor}{%
            % Case \setcvskillcolumns[<width>][] do nothing here and use default
            % \skillmatrix@columnwidth and check third argument
            \ifdefempty{\arg@new@experienceWidth}{%
                % Case \setcvskillcolumns[<width>][][] do nothing here
            }{%
                % Case \setcvskillcolumns[<width>][][<length>]. reset \cvskill@experiencewidth and
                % \cvskill@descriptorwidth accordingly
                \setlength{\cvskill@experiencewidth}{\arg@new@experienceWidth}%
%                 \setlength{\cvskill@descriptorwidth}{\skillmatrix@columnwidth-\cvskill@width-\cvskill@experiencewidth}%
            }%
        }{%
            % Case \setcvskillcolumns, \setcvskillcolumns[<width>], \setcvskillcolumns[<width>][<somefactor>]
            \setlength{\skillmatrix@columnwidth}{\arg@new@bodyLengthFactor\skillmatrix@bodylength}%
            \ifdefempty{\arg@new@experienceWidth}{%
                % Case \setcvskillcolumns[<width>][<somefactor>][] do nothing here
            }{%
                % Case \setcvskillcolumns[<width>][<somefactor>][<length>]. reset \cvskill@experiencewidth and
                % \cvskill@descriptorwidth accordingly
                \setlength{\cvskill@experiencewidth}{\arg@new@experienceWidth}%
%                 \setlength{\cvskill@descriptorwidth}{\skillmatrix@columnwidth-\cvskill@width-\cvskill@experiencewidth}%
            }%
        }%
        \setlength{\cvskill@descriptorwidth}{\skillmatrix@columnwidth-\cvskill@width-\cvskill@experiencewidth}%
        \setlength{\skillmatrix@commentwidth}{\skillmatrix@bodylength-\skillmatrix@columnwidth-3\skillmatrix@padding}%
    }%
}%
%
% \setcvskilllegendcolumns[<width>][<factor>]
\DeclareDocumentCommand{\setcvskilllegendcolumns}{+O{\skilllegend@hintscolumnwidth} +O{\skilllegend@leftdesriptorfactor}}{%
%   adjust column width of legend
%
%   The \cvskilllegend command comes with default FIXED width definitions for the columns of the legend matrix
%   such that the default english and german examples look good.
%   However, depending on the user input (translation) and the style that is used some adjustment might be needed.
%   The \setcvskilllegendcolumns command provides means to influence all columns except the ones containing
%   \cvskill commands. The second column containg the output of \cvskill remains fixed width. The last column,
%   the comment column gets recalculated according to the setting of the other columns.
%
%   Input
%       Input_1 (optional):     length smaller than \textwidth influencing the width of the first column
%                               where depending on the style the legend_string gets printed. In case the
%                               string is left empty adjusting this width allows moving the legend horizontally.
%                               Default <\skilllegend@hintscolumnwidth>
%       Input_2 (optional):     float between 0 and 1 influencing the width of the left legend descritor column,
%                               aka \cvskilllegend@leftdescriptorwidth. The desriptor column on the right,
%                               \cvskilllegend@rightdescriptorwidth is influenced by the factor 1-<factor>.
%                               Default <\skilllegend@leftdesriptorfactor>
%
%   Example usage
%       \setcvskilllegendcolumns[][0.45]%%    adjust left desriptor column.
%       \setcvskilllegendcolumns[\widthof{``Legend''}][0.45]%   adjust both left descriptor column and string column
%
%   Note
%       - Due to implementation of \cvskilllegend for style 'fancy' (moderncvbodyv)
%         the first optional variable has no effect in this case.
%       - For the styles 'classic' and 'casual' the first column is set to hintscolumnwidth such that
%         it aligns with the rest of the entries. A readjustment of the first column should therefor
%         be avoided. It is recomended to only use \cvskilllegend in the form of
%         \cvskilllegend[][<factor>], thereby leaving the defaults in place for the first column.
%       - For style 'banking' the first column is set to align with the rest of the \cvskillentry entries
%         Therefor adjusting the first column can be used to widen the table while moving it around. If no
%         legend string is used, setting \cvskilllegend[0em] maximises the real enstate for the legend.
%
    \def\arg@new@legend@hintscolumnwidth{#1}%
    \def\arg@new@legend@leftDescriptorFactor{#2}%
    % Check for empty arguments. See explanation above
    \ifdefempty{\arg@new@legend@hintscolumnwidth}{%
        % Case \setcvskilllegendcolumns[], \setcvskilllegendcolumns[][] or \setcvskilllegendcolumns[][<somefactor>]
        \ifdefempty{\arg@new@legend@leftDescriptorFactor}{%
%             % Case \setcvskilllegendcolumns[][] do nothing here, i.e. leave default values unaltered
        }{%
            % Case \setcvskilllegendcolumns[][<somefactor>], \setcvskilllegendcolumns[][<somefactor>]
            \RenewDocumentCommand{\skilllegend@leftdesriptorfactor}{}{\arg@new@legend@leftDescriptorFactor}%
        }%
%         % Case \setcvskilllegendcolumns[] nothing needs to be done here i.e. leave default values unaltered
    }{%
        % Case \setcvskilllegendcolumns, \setcvskilllegendcolumns[<width>], \setcvskilllegendcolumns[<width>][]
        % or \setcvskilllegendcolumns[<width>][<somefactor>]
        \setlength{\skilllegend@hintscolumnwidth}{\arg@new@legend@hintscolumnwidth}%
        \if@moderncvbodyi%
            \setlength{\skilllegend@bodylength}{\textwidth-\skilllegend@hintscolumnwidth-\separatorcolumnwidth}%
        \fi%
        \if@moderncvbodyiii%
            \setlength{\skilllegend@bodylength}{\textwidth-\skilllegend@hintscolumnwidth-\separatorcolumnwidth}%
        \fi%
        \if@moderncvbodyiv%
            \setlength{\skilllegend@bodylength}{\maincolumnwidth-\skilllegend@hintscolumnwidth-\separatorcolumnwidth}%
        \fi%
        % in case second argument is given but left empty use default
        \ifdefempty{\arg@new@legend@leftDescriptorFactor}{%
            % Case \setcvskilllegendcolumns[<width>][] do nothing here and leave default values unaltered
        }{%
            % Case \setcvskilllegendcolumns, \setcvskilllegendcolumns[<width>], \setcvskilllegendcolumns[<width>][<somefactor>]
            \RenewDocumentCommand{\skilllegend@leftdesriptorfactor}{}{\arg@new@legend@leftDescriptorFactor}%
        }%
    }%
}%
%
% %-------------------------------------------------------------------------------
% %                \cvskilllegend
% %-------------------------------------------------------------------------------
% default legend style
% \cvskilllegend[*][<post_padding>][<first_level>][<second_level>][<third_level>][<fourth_level>][<fifth_level>]{<name>}
\NewDocumentCommand\skillLegend@FontSize{}{\scriptsize}
\DeclareDocumentCommand\cvskilllegend{s +O{} +O{} +O{} +O{} +O{} +O{} +m}{}%
%   Print legend table explaining the meaning of \cvskill{1}...\cvskill{5}.
%
%   Input:
%       asterix (optional): include vertical (dashed) lines. This behaviour depends on the body style.
%                           For the fancy style, the asterix has no meaning.
%       input_1 (optional): padding length appended to the legend, default: <0.25em>
%       input_2 (optional): string describing meaning of \cvskill{1}, default: <basic knowledge>
%       input_3 (optional): string describing meaning of \cvskill{2}, default: <intermediate knowledge with some project experience>
%       input_4 (optional): string describing meaning of \cvskill{3}, default: <extensive project experience>
%       input_5 (optional): string describing meaning of \cvskill{4}, default: <deepened expert knowledge>
%       input_6 (optional): string describing meaning of \cvskill{5}, default: <expert/guru>
%       input_7:            string giving a name to the legend, default: <>
%
%   Example usages:
%       \cvskilllegend{}    print default legend
%       \cvskilllegend[0.5em]{Legend}   print default legend, but adjust post padding and display the word ``Legend''.
%       \cvskilllegend*[0.2em][Grundkenntnisse][Grundkenntnisse und eigene Erfahrung in Projekten][Umfangreiche Erfahrung in Projekten][Vertiefte Expertenkenntnisse][Experte/Guru]{Legende}     Fully adjust legend to German example and including dashed lines
%
%   Note:
%       -The width of the columns can be adjusted by the \setcvskilllegendcolumns, see \setcvskilllegendcolumns
%       -The design of the table is such that the <second_level> entry stands in the first column but
%       occupies rows two and three. This has been done to accomodate english and german defaults.
%       An alternative is provided by \cvskillplainlegend

% declare default legend entries
\NewDocumentCommand\skillLegend@defaultLevelOne{}{basic knowledge}
\NewDocumentCommand\skillLegend@defaultLevelTwo{}{intermediate knowledge with some project experience}
\NewDocumentCommand\skillLegend@defaultLevelThree{}{extensive project experience}
\NewDocumentCommand\skillLegend@defaultLevelFour{}{deepened expert knowledge}
\NewDocumentCommand\skillLegend@defaultLevelFive{}{expert\,/\,specialist}
% Redefinition of \cvskilllegend valid for moderncvbodyi, moderncvbodyii, moderncvbodyiii
\RenewDocumentCommand\cvskilllegend{s +O{.25em} +O{\skillLegend@defaultLevelOne} +O{\skillLegend@defaultLevelTwo} +O{\skillLegend@defaultLevelThree} +O{\skillLegend@defaultLevelFour} +O{\skillLegend@defaultLevelFive} +m}{%
    \IfBooleanTF#1{% if a star is given, add dashed line
        \begingroup%
            \arrayrulecolor{bodyrulecolor}%
            % calculate descriptor widths
            \setlength{\cvskilllegend@leftdescriptorwidth}{\skilllegend@leftdesriptorfactor\skilllegend@bodylength-\cvskill@width-\skillmatrix@padding-3\skilllegend@padding}%
            \setlength{\cvskilllegend@rightdescriptorwidth}{\skilllegend@bodylength-\skilllegend@leftdesriptorfactor\skilllegend@bodylength-\cvskill@width-\skillmatrix@padding-3\skilllegend@padding}%
            \begin{tabular}{@{}p{\skilllegend@hintscolumnwidth}%
                            @{\hspace{\separatorcolumnwidth}}%
                            p{\cvskill@width}@{\hspace{\skilllegend@padding}};{.6pt/1pt}%%
                            p{2\skilllegend@padding}p{\cvskilllegend@leftdescriptorwidth}@{}@{\hspace{2\skillmatrix@padding}}%
                            p{\cvskill@width}@{\hspace{\skilllegend@padding}};{.6pt/1pt}%
                            p{2\skilllegend@padding}%
                            p{\cvskilllegend@rightdescriptorwidth}@{}}%
                \raggedleft\hintstyle{#8}  & \cvskill{1}& & {\skillLegend@FontSize #3} & \cvskill{3}& &{\skillLegend@FontSize #5 } \\%
                            %
                        & \cvskill{2} & & \multirow{2}{\cvskilllegend@leftdescriptorwidth}{{\skillLegend@FontSize #4}} & \cvskill{4}& & {\skillLegend@FontSize #6 } \\%
                    %
                        &  & &  & \cvskill{5}& & {\skillLegend@FontSize #7 }%
            \end{tabular}%
        \endgroup
        \par\addvspace{#2}}{%
        % if no star is given, do not add dashed line. We need less padding in this case
        \begingroup%
            % calculate descriptor columns width. note the adjusted padding
            \setlength{\cvskilllegend@leftdescriptorwidth}{\skilllegend@leftdesriptorfactor\skilllegend@bodylength-\cvskill@width-\skillmatrix@padding-1\skilllegend@padding}%
            \setlength{\cvskilllegend@rightdescriptorwidth}{\skilllegend@bodylength-\skilllegend@leftdesriptorfactor\skilllegend@bodylength-\cvskill@width-\skillmatrix@padding-1\skilllegend@padding}%
            \begin{tabular}{@{}p{\skilllegend@hintscolumnwidth}%
                            @{\hspace{\separatorcolumnwidth}}%
                            p{\cvskill@width}@{\hspace{\skilllegend@padding}}%
                            p{\cvskilllegend@leftdescriptorwidth}@{\hspace{2\skillmatrix@padding}}%
                            p{\cvskill@width}@{\hspace{\skilllegend@padding}}%
                            p{\cvskilllegend@rightdescriptorwidth}@{}}%
                \raggedleft\hintstyle{#8}  & \cvskill{1}\, & \,{\skillLegend@FontSize #3} & \cvskill{3}\, &\,{\skillLegend@FontSize #5 } \\%
                            %
                        & \cvskill{2}\, & \,\multirow{2}{\cvskilllegend@leftdescriptorwidth}{{\skillLegend@FontSize #4}} & \cvskill{4}\,  &\,{\skillLegend@FontSize #6 } \\%
                    %
                        &  &   & \cvskill{5}\, &\,{\skillLegend@FontSize #7 }%
            \end{tabular}%
        \endgroup%
        \par\addvspace{#2}%
    }%
}%
% Redefinition of \cvskilllegend valid for moderncvbodyiv
\if@moderncvbodyiv%
    \RenewDocumentCommand\cvskilllegend{s +O{.25em} +O{\skillLegend@defaultLevelOne} +O{\skillLegend@defaultLevelTwo} +O{\skillLegend@defaultLevelThree} +O{\skillLegend@defaultLevelFour} +O{\skillLegend@defaultLevelFive} +m}{%
        \def\arg@legendString{#8}%
        \ifdefempty{\arg@legendString}{%
        }{%
            \cvitem[0.25em]{\hintstyle{#8}}{}%
        }%
        \IfBooleanTF#1{% if a star is given, add dashed line
            \begingroup%
                % recalculate desrciptor widths on the fly. Allows for different padding
                % in the stared and nonstared case
                \setlength{\cvskilllegend@leftdescriptorwidth}{\skilllegend@leftdesriptorfactor\skilllegend@bodylength-\cvskill@width-\skillmatrix@padding-4\skilllegend@padding}%
                \setlength{\cvskilllegend@rightdescriptorwidth}{\skilllegend@bodylength-\skilllegend@leftdesriptorfactor\skilllegend@bodylength-\cvskill@width-\skillmatrix@padding-4\skilllegend@padding}%
                \arrayrulecolor{bodyrulecolor}
                \begin{tabular}{@{}p{\skilllegend@hintscolumnwidth}
                                @{\hspace{\separatorcolumnwidth}}p{\cvskill@width}@{\hspace{\skilllegend@padding}};{.6pt/1pt}%
                                p{2\skilllegend@padding}%
                                p{\cvskilllegend@leftdescriptorwidth}@{\hspace{\skillmatrix@padding}}%
                                p{\cvskill@width}@{\hspace{\skilllegend@padding}};{.6pt/1pt}%
                                p{2\skilllegend@padding}p{\cvskilllegend@rightdescriptorwidth}@{}}%
                    \raggedleft\hintstyle{}  & \cvskill{1} & & {\skillLegend@FontSize #3} & \cvskill{3} & & {\skillLegend@FontSize #5 } \\
                                %
                            & \cvskill{2} & & \multirow{2}{\cvskilllegend@leftdescriptorwidth}{{\skillLegend@FontSize #4}} & \cvskill{4} &  &{\skillLegend@FontSize #6 } \\
                        %
                            & & &   & \cvskill{5}& & {\skillLegend@FontSize #7 }
                \end{tabular}%
            \endgroup%
            \par\addvspace{#2}}{
            \begingroup%
                % oddly enough, we should only need to subtract 2 paddings in the descritorwidths.
                % but while testing I got overflow of text into the margin
                \setlength{\cvskilllegend@leftdescriptorwidth}{\skilllegend@leftdesriptorfactor\skilllegend@bodylength-\cvskill@width-\skillmatrix@padding-4\skilllegend@padding}%
                \setlength{\cvskilllegend@rightdescriptorwidth}{\skilllegend@bodylength-\skilllegend@leftdesriptorfactor\skilllegend@bodylength-\cvskill@width-\skillmatrix@padding-5\skilllegend@padding}%
                \begin{tabular}{@{}p{\skilllegend@hintscolumnwidth}
                                @{\hspace{\separatorcolumnwidth}}p{\cvskill@width}@{\hspace{2\skilllegend@padding}}%
                                p{\cvskilllegend@leftdescriptorwidth}@{\hspace{2\skillmatrix@padding}}%
                                p{\cvskill@width}@{\hspace{2\skilllegend@padding}}%
                                p{\cvskilllegend@rightdescriptorwidth}@{}}%
                    \raggedleft\hintstyle{}  & \cvskill{1} & {\skillLegend@FontSize #3} & \cvskill{3} & {\skillLegend@FontSize #5 } \\
                                %
                            & \cvskill{2} & \multirow{2}{\cvskilllegend@leftdescriptorwidth}{{\skillLegend@FontSize #4}} & \cvskill{4} &{\skillLegend@FontSize #6 } \\
                        %
                            & &   & \cvskill{5} & {\skillLegend@FontSize #7 }
                \end{tabular}%
            \endgroup%
            \par\addvspace{#2}
        }
    }
\fi
% Redefinition of \cvskilllegend valid for moderncvbodyv
\if@moderncvbodyv%
    \DeclareDocumentCommand\@starIndependentTabular{}{}%
    \RenewDocumentCommand\cvskilllegend{s +O{.25em} +O{\skillLegend@defaultLevelOne} +O{\skillLegend@defaultLevelTwo} +O{\skillLegend@defaultLevelThree} +O{\skillLegend@defaultLevelFour} +O{\skillLegend@defaultLevelFive} +m}{%
        % check whether Argument #8 is given and if so provide it as cvitem
        \def\arg@legendString{#8}%
        \ifdefempty{\arg@legendString}{%
            \vspace*{-\separatorrulewidth}% HACK; I don't understand where the space is coming from, nor what it's exact value is :(
        }{%
            \cvitem[-0.5em]{#8}{}%
        }%
        \arrayrulecolor{bodyrulecolor}%
        \setlength\arrayrulewidth{\separatorrulewidth}%
        \RenewDocumentCommand{\@starIndependentTabular}{}{%
            \begingroup%
            \setlength{\cvskilllegend@leftdescriptorwidth}{\skilllegend@leftdesriptorfactor\skilllegend@bodylength-\cvskill@width-\skillmatrix@padding-3\skilllegend@padding}%
            \setlength{\cvskilllegend@rightdescriptorwidth}{\skilllegend@bodylength-\skilllegend@leftdesriptorfactor\skilllegend@bodylength-\cvskill@width-\skillmatrix@padding-3\skilllegend@padding}%
%             \renewcommand{\arraystretch}{1.0}%
            \begin{tabular}[t]{@{}p{\hintscolumnwidth}%\skilllegend@hintscolumnwidth
                    @{\hspace{\separatorcolumnwidth}}|@{\hspace{\separatorcolumnwidth}}%
                    p{\cvskill@width}@{\hspace{3\skilllegend@padding}}%
                    p{\cvskilllegend@leftdescriptorwidth}@{\hspace{2\skillmatrix@padding}}%
                    p{\cvskill@width}@{\hspace{3\skilllegend@padding}}%
                    p{\cvskilllegend@rightdescriptorwidth}@{}}%
                \@moderncvstrut{4pt}{16pt}  & \cvskill{1}& {\skillLegend@FontSize #3} & \cvskill{3}& {\skillLegend@FontSize #5 }\\%
                            %
                        & \cvskill{2}& \multirow{2}{\cvskilllegend@leftdescriptorwidth}{{\skillLegend@FontSize #4}} & \cvskill{4}& {\skillLegend@FontSize #6 }\\%
                    %
                        & & & \cvskill{5} & {\skillLegend@FontSize #7 }\\[#2]% the spacing needs to be inside the cell for the vertical rule to extend correctly
            \end{tabular}%
            \endgroup%
            \par\@aftersectionfalse\ignorespaces%
        }%
        % because of this weird style and the position of the parameter [#2], the dashed lines of the other version look bad. So no lines.
        \IfBooleanTF#1{%
                \@starIndependentTabular%
            }{%
                \@starIndependentTabular%
        }%
    }%
\fi

% %-------------------------------------------------------------------------------
% %                \cvskillplainlegend
% %-------------------------------------------------------------------------------
% alternative legend style
% \cvskillplainlegend[*][<post_padding>][<first_level>][<second_level>][<third_level>][<fourth_level>][<fifth_level>]{<name>}
\DeclareDocumentCommand\cvskillplainlegend{s +O{} +O{} +O{} +O{} +O{} +O{} +m}{}%
%   Print alternative legend table explaining the meaning of \cvskill{1}...\cvskill{5}.
%   In this legend, the first three skill levels are in one column
%
%   Input:
%       asterix (optional): include vertical (dashed) lines. This behaviour depends on the body style.
%                           For the fancy style, the asterix has no meaning.
%       input_1 (optional): padding length appended to the legend, default: <0.25em>
%       input_2 (optional): string describing meaning of \cvskill{1}, default: <basic knowledge>
%       input_3 (optional): string describing meaning of \cvskill{2}, default: <intermediate knowledge with some project experience>
%       input_4 (optional): string describing meaning of \cvskill{3}, default: <extensive project experience>
%       input_5 (optional): string describing meaning of \cvskill{4}, default: <deepened expert knowledge>
%       input_6 (optional): string describing meaning of \cvskill{5}, default: <expert/guru>
%       input_7:            string giving a name to the legend, default: <>
%
%   Example usages:
%       \cvskillplainlegend{}    print default legend
%       \cvskillplainlegend[0.5em]{Legend}   print default legend, but adjust post padding and display the word ``Legend''.
%       \cvskillplainlegend*[0.2em][Grundkenntnisse][Grundkenntnisse und eigene Erfahrung in Projekten][Umfangreiche Erfahrung in Projekten][Vertiefte Expertenkenntnisse][Experte/Guru]{Legende}     Fully adjust legend to German example and including dashed lines
%
%   Note:
%       -The width of the columns can be adjusted by the \setcvskilllegendcolumns, see \setcvskilllegendcolumns

% declare default legend entries
\NewDocumentCommand\skillPlainLegend@defaultLevelOne{}{basic knowlegde}
\NewDocumentCommand\skillPlainLegend@defaultLevelTwo{}{intermediate knowledge, some project experience}
\NewDocumentCommand\skillPlainLegend@defaultLevelThree{}{extensive project experience}
\NewDocumentCommand\skillPlainLegend@defaultLevelFour{}{deepened expert knowledge}
\NewDocumentCommand\skillPlainLegend@defaultLevelFive{}{expert/guru}
% Redefinition of \cvskillplainlegend valid for moderncvbodyi, moderncvbodyii, moderncvbodyiii
\RenewDocumentCommand\cvskillplainlegend{s +O{.25em} +O{\skillPlainLegend@defaultLevelOne} +O{\skillPlainLegend@defaultLevelTwo} +O{\skillPlainLegend@defaultLevelThree} +O{\skillPlainLegend@defaultLevelFour} +O{\skillPlainLegend@defaultLevelFive} +m}{%
    \IfBooleanTF#1{% if a star is given, add dashed line
        \begingroup%
            \arrayrulecolor{bodyrulecolor}%
            % calculate descriptor widths
            \setlength{\cvskilllegend@leftdescriptorwidth}{\skilllegend@leftdesriptorfactor\skilllegend@bodylength-\cvskill@width-\skillmatrix@padding-3\skilllegend@padding}%
            \setlength{\cvskilllegend@rightdescriptorwidth}{\skilllegend@bodylength-\skilllegend@leftdesriptorfactor\skilllegend@bodylength-\cvskill@width-\skillmatrix@padding-3\skilllegend@padding}%
            \begin{tabular}{@{}p{\skilllegend@hintscolumnwidth}%
                            @{\hspace{\separatorcolumnwidth}}%
                            p{\cvskill@width}@{\hspace{\skilllegend@padding}};{.6pt/1pt}%%
                            p{2\skilllegend@padding}p{\cvskilllegend@leftdescriptorwidth}@{}@{\hspace{2\skillmatrix@padding}}%
                            p{\cvskill@width}@{\hspace{\skilllegend@padding}};{.6pt/1pt}%
                            p{2\skilllegend@padding}%
                            p{\cvskilllegend@rightdescriptorwidth}@{}}%
                \raggedleft\hintstyle{#8}  & \cvskill{1}& & {\skillLegend@FontSize #3} & \cvskill{4}& &{\skillLegend@FontSize #6} \\%
                            %
                        & \cvskill{2} & & {\skillLegend@FontSize #4} & \cvskill{5}& & {\skillLegend@FontSize #7} \\%
                    %
                        & \cvskill{3} & & {\skillLegend@FontSize #5} & & & %
            \end{tabular}%
        \endgroup%
        \par\addvspace{#2}}{%
        % if no star is given, do not add dashed line
        \begingroup%
            % calculate descriptor widths, note that we use less padding
            \setlength{\cvskilllegend@leftdescriptorwidth}{\skilllegend@leftdesriptorfactor\skilllegend@bodylength-\cvskill@width-\skillmatrix@padding-2\skilllegend@padding}%
            \setlength{\cvskilllegend@rightdescriptorwidth}{\skilllegend@bodylength-\skilllegend@leftdesriptorfactor\skilllegend@bodylength-\cvskill@width-\skillmatrix@padding-2\skilllegend@padding}%
            \begin{tabular}{@{}p{\skilllegend@hintscolumnwidth}%
                            @{\hspace{\separatorcolumnwidth}}%
                            p{\cvskill@width}@{\hspace{2\skilllegend@padding}}%
                            p{\cvskilllegend@leftdescriptorwidth}@{\hspace{2\skillmatrix@padding}}%
                            p{\cvskill@width}@{\hspace{2\skilllegend@padding}}%
                            p{\cvskilllegend@rightdescriptorwidth}@{}}%
                \raggedleft\hintstyle{#8}  & \cvskill{1} & {\skillLegend@FontSize #3} & \cvskill{4} &{\skillLegend@FontSize #6} \\%
                            %
                        & \cvskill{2} & {\skillLegend@FontSize #4} & \cvskill{5}  &{\skillLegend@FontSize #7} \\%
                    %
                        & \cvskill{3} & {\skillLegend@FontSize #5 }  &  & %
            \end{tabular}%
        \endgroup%
        \par\addvspace{#2}%
    }%
}%
% Redefinition of \cvskillplainlegend valid for moderncvbodyiv
\if@moderncvbodyiv%
    \RenewDocumentCommand\cvskillplainlegend{s +O{.25em} +O{\skillPlainLegend@defaultLevelOne} +O{\skillPlainLegend@defaultLevelTwo} +O{\skillPlainLegend@defaultLevelThree} +O{\skillPlainLegend@defaultLevelFour} +O{\skillPlainLegend@defaultLevelFive} +m}{%
        \def\arg@legendString{#8}%
        \ifdefempty{\arg@legendString}{%
        }{%
            \cvitem[0.25em]{\hintstyle{#8}}{}%
        }%
        \IfBooleanTF#1{% if a star is given, add dashed line
            \begingroup%
                \arrayrulecolor{bodyrulecolor}
                \setlength{\cvskilllegend@leftdescriptorwidth}{\skilllegend@leftdesriptorfactor\skilllegend@bodylength-\cvskill@width-\skillmatrix@padding-6\skilllegend@padding}%
                \setlength{\cvskilllegend@rightdescriptorwidth}{\skilllegend@bodylength-\skilllegend@leftdesriptorfactor\skilllegend@bodylength-\cvskill@width-\skillmatrix@padding-6\skilllegend@padding}%
                \begin{tabular}{@{}p{\skilllegend@hintscolumnwidth}
                                @{\hspace{\separatorcolumnwidth}}p{\cvskill@width}@{\hspace{\skilllegend@padding}};{.6pt/1pt}%
                                p{2\skilllegend@padding}%
                                p{\cvskilllegend@leftdescriptorwidth}@{\hspace{2\skillmatrix@padding}}%
                                p{\cvskill@width}@{\hspace{\skilllegend@padding}};{.6pt/1pt}%
                                p{2\skilllegend@padding}p{\cvskilllegend@rightdescriptorwidth}@{}}%
                    \raggedleft\hintstyle{} & \cvskill{1} & & {\skillLegend@FontSize#3} & \cvskill{4} & & {\skillLegend@FontSize#6}\\%
                                %
                            & \cvskill{2} & &{\skillLegend@FontSize#4} & \cvskill{5} &  &{\skillLegend@FontSize#7}\\%
                        %
                            & \cvskill{3} & &{\skillLegend@FontSize#5} & & &%
                \end{tabular}%
            \endgroup%
            \par\addvspace{#2}}{
            % if no star is given, do not add dashed line
            \begingroup
                \setlength{\cvskilllegend@leftdescriptorwidth}{\skilllegend@leftdesriptorfactor\skilllegend@bodylength-\cvskill@width-\skillmatrix@padding-3\skilllegend@padding}%
                \setlength{\cvskilllegend@rightdescriptorwidth}{\skilllegend@bodylength-\skilllegend@leftdesriptorfactor\skilllegend@bodylength-\cvskill@width-\skillmatrix@padding-4\skilllegend@padding}%
                \begin{tabular}{@{}p{\skilllegend@hintscolumnwidth}
                                @{\hspace{\separatorcolumnwidth}}p{\cvskill@width}@{\hspace{\skilllegend@padding}}%
                                p{\cvskilllegend@leftdescriptorwidth}@{\hspace{2\skillmatrix@padding}}%
                                p{\cvskill@width}@{\hspace{\skilllegend@padding}}%
                                p{\cvskilllegend@rightdescriptorwidth}@{}}%
                    \raggedleft\hintstyle{}  & \cvskill{1} & {\skillLegend@FontSize #3} & \cvskill{4} & {\skillLegend@FontSize #6} \\
                                %
                            & \cvskill{2} & {\skillLegend@FontSize #4} & \cvskill{5} & {\skillLegend@FontSize #7} \\
                        %
                            & \cvskill{3} & {\skillLegend@FontSize #5}  & & %
                \end{tabular}%
            \endgroup
            \par\addvspace{#2}
        }
    }
\fi
% Redefinition of \cvskillplainlegend valid for moderncvbodyv
\if@moderncvbodyv%
    \RenewDocumentCommand\cvskillplainlegend{s +O{.25em} +O{\skillPlainLegend@defaultLevelOne} +O{\skillPlainLegend@defaultLevelTwo} +O{\skillPlainLegend@defaultLevelThree} +O{\skillPlainLegend@defaultLevelFour} +O{\skillPlainLegend@defaultLevelFive} +m}{%
        % check whether Argument #8 is given and if so provide it as cvitem
        \def\arg@legendString{#8}%
        \ifdefempty{\arg@legendString}{%
            \vspace*{-\separatorrulewidth}% HACK; I don't understand where the space is coming from, nor what it's exact value is :(
        }{%
            \cvitem[-0.5em]{#8}{}%
        }%
        \arrayrulecolor{bodyrulecolor}%
        \setlength\arrayrulewidth{\separatorrulewidth}%
        \RenewDocumentCommand{\@starIndependentTabular}{}{%
            \begingroup%
%             \renewcommand{\arraystretch}{1.0}%
            \setlength{\cvskilllegend@leftdescriptorwidth}{\skilllegend@leftdesriptorfactor\skilllegend@bodylength-\cvskill@width-\skillmatrix@padding-2\skilllegend@padding}%
            \setlength{\cvskilllegend@rightdescriptorwidth}{\skilllegend@bodylength-\skilllegend@leftdesriptorfactor\skilllegend@bodylength-\cvskill@width-\skillmatrix@padding-2\skilllegend@padding}%
            \begin{tabular}[t]{@{}p{\hintscolumnwidth}%\skilllegend@hintscolumnwidth
                    @{\hspace{\separatorcolumnwidth}}|@{\hspace{\separatorcolumnwidth}}%
                    p{\cvskill@width}@{\hspace{2\skilllegend@padding}}%
                    p{\cvskilllegend@leftdescriptorwidth}@{\hspace{2\skillmatrix@padding}}%
                    p{\cvskill@width}@{\hspace{2\skilllegend@padding}}%
                    p{\cvskilllegend@rightdescriptorwidth}@{}}%
                \@moderncvstrut{4pt}{16pt}  & \cvskill{1} & {\skillLegend@FontSize #3} & \cvskill{4} & {\skillLegend@FontSize #6}\\%
                            %
                        & \cvskill{2} & {\skillLegend@FontSize #4} & \cvskill{5} & {\skillLegend@FontSize #7}\\%
                    %
                        & \cvskill{3} & {\skillLegend@FontSize #5}  & & \\[#2]% the spacing needs to be inside the cell for the vertical rule to extend correctly
            \end{tabular}%
            \endgroup%
            \par\@aftersectionfalse\ignorespaces%
        }%
        % because of this weird style and the position of the parameter [#2], the dashed lines of the other version look bad. So no lines.
        \IfBooleanTF#1{%
                \@starIndependentTabular%
            }{%
                \@starIndependentTabular%
        }%
    }%
\fi

% %-------------------------------------------------------------------------------
% %                \cvskillhead
% %-------------------------------------------------------------------------------
\NewDocumentCommand\cvSkillMatrix@HeadFont{}{\normalfont}
\DeclareDocumentCommand\cvskillhead{+O{} +O{} +O{} +O{} +O{}}{}%
%   add skill matrix line acting as header explaining the meaning of columns.
%
%   Input:
%       input_1 (optional): padding length appended to the legend, default: <0.25em>
%       input_2 (optional): string naming the level column (2nd column), default: <Level>
%       input_3 (optional): string naming the skill column (3nd column), default: <Skill>
%       input_4 (optional): string naming the experience-in-years column (4th column), default: <Years>
%       input_5 (optional): string naming the comment column (5th column), default: <Comment>
%
%   Example usages:
%       \cvskillhead    print default head.
%       \cvskillhead[0.5em]   print default head, but adjust post padding.
%       \cvskillhead[0.25em][Level][F\"ahigkeit][Jahre][Bemerkung]     Fully adjust head to German example
%
%   Note:
%       - The width of the columns can be adjusted by the \setcvskillcolumns command, see \setcvskillcolumns.

\NewDocumentCommand\skillMatrix@HeaderDefaultOne{}{Level}
\NewDocumentCommand\skillMatrix@HeaderDefaultTwo{}{Skill}
\NewDocumentCommand\skillMatrix@HeaderDefaultThree{}{Years}
\NewDocumentCommand\skillMatrix@HeaderDefaultFour{}{Comment}
% Definition of \cvskillhead valid for moderncvbodyi, moderncvbodyii, moderncvbodyiii, moderncvbodyiv
\RenewDocumentCommand\cvskillhead{O{.25em} +O{\skillMatrix@HeaderDefaultOne} +O{\skillMatrix@HeaderDefaultTwo} +O{\skillMatrix@HeaderDefaultThree} +O{\skillMatrix@HeaderDefaultFour}}{%
    \begingroup
        \renewcommand{\arraystretch}{1.25}
        \arrayrulecolor{bodyrulecolor}
        \begin{tabular}{@{}p{\skillmatrix@hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}%
                p{\cvskill@width}@{\hspace{\skillmatrix@padding}}%
                p{\cvskill@descriptorwidth}@{\hspace{\skillmatrix@padding}}%
                p{\cvskill@experiencewidth}@{\hspace{\skillmatrix@padding}}
                p{\skillmatrix@commentwidth}@{}}%
            & \centering{\cvSkillMatrix@HeadFont #2} & \centering{\cvSkillMatrix@HeadFont #3} & \centering{\cvSkillMatrix@HeadFont #4} & {\cvSkillMatrix@HeadFont #5}
        \end{tabular}%
    \endgroup
    \par\addvspace{#1}
}
% Definition of \cvskillhead valid moderncvbodyv
\if@moderncvbodyv%
    \RenewDocumentCommand\cvskillhead{O{.25em} +O{\skillMatrix@HeaderDefaultOne} +O{\skillMatrix@HeaderDefaultTwo} +O{\skillMatrix@HeaderDefaultThree} +O{\skillMatrix@HeaderDefaultFour}}{%
        \arrayrulecolor{bodyrulecolor}%
        \setlength\arrayrulewidth{\separatorrulewidth}%
        \vspace*{-\separatorrulewidth}% HACK; I don't understand where the space is coming from, nor what it's exact value is :(
        \begingroup%
    %     \renewcommand{\arraystretch}{1.25}%
        \begin{tabular}[t]{@{}p{\hintscolumnwidth}%
                @{\hspace{\separatorcolumnwidth}}|@{\hspace{\separatorcolumnwidth}}%
                p{\skillmatrix@hintscolumnwidth}%
                @{\hspace{\skillmatrix@padding}}%
                p{\cvskill@width}@{\hspace{\skillmatrix@padding}}%
                p{\cvskill@descriptorwidth}@{\hspace{\skillmatrix@padding}}%
                p{\cvskill@experiencewidth}@{\hspace{\skillmatrix@padding}}%
                p{\skillmatrix@commentwidth}@{}}%
            & & \centering{\cvSkillMatrix@HeadFont#2} & \centering{\cvSkillMatrix@HeadFont#3} & \centering{\cvSkillMatrix@HeadFont#4} & {\cvSkillMatrix@HeadFont#5} \\[#1]% the spacing needs to be inside the cell for the vertical rule to extend correctly
        \end{tabular}%
        \endgroup%
        \par\@aftersectionfalse\ignorespaces%
    }%
\fi

% %-------------------------------------------------------------------------------
% %                \cvskillentry
% %-------------------------------------------------------------------------------
% \cvskillentry[*][<post_padding>]{<skill_cathegory>}{<0-5>}{<skill_name>}{<years_of_experience>}{<comment>}%
\DeclareDocumentCommand\cvskillentry{s +O{} +m +m +m +m +m}{}%
%     add cvskill matrix row.
%
%     Input:
%         asterix (optional): include horizontal (dashed) line above the entered line. This behaviour depends on the body style.
%                             For the fancy style, the asterix has no meaning.
%         input_1 (optional): padding length appended to the legend, default: <0.25em>
%         input_2: string, naming skill cathegory, default: <>
%         input_3: integer between 0 and 5, describing level of skill. \cvskill{input_2} is called internally, default: <>
%         input_4: string, naming the skill, default: <>
%         input_5: positive real number, stating the number of years of experience with this skill , default: <>
%         input_6: string, explaining details w.r.t. that particual skill default: <>
%
%     Example usages:
%         \cvskillentry*{Language:}{3}{Python}{2}{I have done a million projects with Python}
%         \cvskillentry{}{2}{Lilypond}{14}{So much sheet music! Man I'm the best!}
%         \cvskillentry{}{3}{\LaTeX}{14}{Clearly I rock at \LaTeX}
%         \cvskillentry*[1.5em]{OS:}{3}{Linux}{2}{I only use Archlinux}
%
%     Note:
%         - The width of the columns can be adjusted by the \setcvskillcolumns command, see \setcvskillcolumns.

% Definition of \cvskillentry valid for moderncvbodyi, moderncvbodyii, moderncvbodyiii, moderncvbodyiv
\RenewDocumentCommand\cvskillentry{s +O{.25em} +m +m +m +m +m}{%
    %test for the star * in the command
    \IfBooleanTF{#1}{% If a star is seen a dotted line is drawn above the entry
        \begingroup
            \renewcommand{\arraystretch}{1.25}
            \arrayrulecolor{bodyrulecolor}
            \begin{tabular}{@{}p{\skillmatrix@hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}%
                    p{\cvskill@width}@{\hspace{\skillmatrix@padding}}%
                    p{\cvskill@descriptorwidth}@{\hspace{\skillmatrix@padding}}%
                    p{\cvskill@experiencewidth} @{\hspace{\skillmatrix@padding}}%
                    p{\skillmatrix@commentwidth}@{}}%
                \cdashline{2-5}[.6pt/1pt]
                \raggedleft\hintstyle{#3} &\centering \cvskill{#4} &\centering {#5} & \centering {#6} &{\itshape#7}%
            \end{tabular}%
        \endgroup
        \par\addvspace{#2}
    }{% If no star is seen no line is drawn
        \begin{tabular}{@{}p{\skillmatrix@hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}%
                p{\cvskill@width}@{\hspace{\skillmatrix@padding}}%
                p{\cvskill@descriptorwidth}@{\hspace{\skillmatrix@padding}}%
                p{\cvskill@experiencewidth}%
                @{\hspace{\skillmatrix@padding}}%
                p{\skillmatrix@commentwidth}@{}}%
            \raggedleft\hintstyle{#3} &\centering \cvskill{#4} &\centering {#5} & \centering {#6} &{\itshape#7}%
        \end{tabular}%
        \par\addvspace{#2}
    }
}

% Definition of \cvskillentry valid for moderncvbodyv
\if@moderncvbodyv%
    \DeclareDocumentCommand\@starIndependentMatrixEntry{}{}%
    \RenewDocumentCommand\cvskillentry{s O{.25em} +m +m +m +m +m}{%
        \arrayrulecolor{bodyrulecolor}%
        \setlength\arrayrulewidth{\separatorrulewidth}%
        \vspace*{-\separatorrulewidth}% HACK; I don't understand where the space is coming from, nor what it's exact value is :(
        %test for the star * in the command
        \RenewDocumentCommand{\@starIndependentMatrixEntry}{}{%
            \begingroup%
                \renewcommand{\arraystretch}{1.25}%
                \begin{tabular}[t]{@{}p{\hintscolumnwidth}%
                                @{\hspace{\separatorcolumnwidth}}|@{\hspace{\separatorcolumnwidth}}p{\skillmatrix@hintscolumnwidth}
                                @{\hspace{\skillmatrix@padding}}%
                                p{\cvskill@width}@{\hspace{\skillmatrix@padding}}%
                                p{\cvskill@descriptorwidth}@{\hspace{\skillmatrix@padding}}%
                                p{\cvskill@experiencewidth} @{\hspace{\skillmatrix@padding}}p{\skillmatrix@commentwidth}@{}}%
    %                 \cline{3-6}%
                    & \raggedleft\hintstyle{#3} &\centering \cvskill{#4} &\centering {#5} & \centering {#6} &{\itshape#7}\\[#2]%
                \end{tabular}%
            \endgroup%
        }%
        \IfBooleanTF{#1}{% the star does not do anything here
            \@starIndependentMatrixEntry%
        }{%
            \@starIndependentMatrixEntry%
        }%
        \par\@aftersectionfalse\ignorespaces%
    }%
\fi
%
\endinput


%% end of file `moderncvskillmatrix.sty'.