%%
%% This is file `hvfloat-xetex-bidi.def',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% bidi.dtx  (with options: `hvfloat-xetex-bidi.def')
%% 
%%   ______________________________________
%%   Copyright © 2009–2013  Persian TeX Group
%% 
%%   License information appended.
%% 
%% 
\ProvidesFile{hvfloat-xetex-bidi.def}[2012/04/18 v0.2 bidi adaptations for hvfloat package for XeTeX engine]
\def\do@@hvFloat[#1]#2#3{%
\def\hv@shortCap{#1}
\def\hv@longCap{#2}
\def\hv@label{#3}
  \def\@tempa{90}%
  \ifx\hvSet@rotAngle\@tempa \setlength{\hvMaxCapWidth}{\textheight}
  \else                      \setlength{\hvMaxCapWidth}{\linewidth}
  \fi
  \ifx\hvSet@objectAngle\hv@Zero % rotate the object?
    \savebox{\hvObjectBox}{\ifhv@useOBox\usebox{\hvOBox}\else\hv@floatObject\fi}
  \else
    \savebox{\hvObjectBox}{%
    \rotatebox{\hvSet@objectAngle}{%
    \ifhv@useOBox\usebox{\hvOBox}\else\hv@floatObject\fi}}
  \fi
  \setlength{\hvObjectWidth}{\wd\hvObjectBox}
  \ifx\hvSet@capWidth\hv@Width\setlength{\hvCapWidth}{\hvObjectWidth}
  \else
    \ifx\hvSet@capWidth\hv@Height\setlength{\hvCapWidth}{\ht\hvObjectBox}
    \else
      \setlength{\hvCapWidth}{\hvObjectWidth}
      \ifx\hvSet@capPos\hv@Left\addtolength{\hvMaxCapWidth}{-\hvObjectWidth}\fi
      \ifx\hvSet@capPos\hv@Right\addtolength{\hvMaxCapWidth}{-\hvObjectWidth}\fi
      \ifdim\hvSet@capWidth\columnwidth<\hvMaxCapWidth
\setlength{\hvCapWidth}{\hvSet@capWidth\columnwidth}
      \else
\setlength{\hvCapWidth}{\hvMaxCapWidth}
      \fi
    \fi
  \fi
  \def\fps@figure{\hvSet@floatPos}
  \ifhv@nonFloat\begingroup% Start the nonfloat part
  \else         \begin{\hv@floatType}% Start the floating environment
  \fi%
  \saveCaptionSkip% we put this space ourselve
  \ifx\hvSet@capAngle\hv@Width % need rotation?
    \sbox{\hvCaptionBox}{%
      \begin{minipage}[b]{\hvCapWidth}% minipage, to get hyphenation
        \ifhv@nonFloat%
  \ifhv@onlyText#2%
     \else%
    \ifx\hv@floatType\hv@figure
      \ifx\relax#1\relax \figcaption{#2}\else\figcaption[#1]{#2}\fi
    \else
      \ifx\relax#1\relax \tabcaption{#2}\else\tabcaption[#1]{#2}\fi%
    \fi
  \fi
\else\ifx\relax\hv@shortCap\relax\caption{#2}\else\caption[#1]{#2}\fi%
\fi%
\label{#3}%
      \end{minipage}%
    }%
  \else%
    \sbox{\hvCaptionBox}{%
      \rotatebox{\hvSet@capAngle}{%
      \begin{minipage}[b]{\hvCapWidth}% minipage, to get hyphenation
\ifhv@nonFloat%
     \ifhv@onlyText#2%
     \else%
    \ifx\hv@floatType\hv@figure
      \ifx\relax#1\relax \figcaption{#2}\else\figcaption[#1]{#2}\fi
    \else
      \ifx\relax#1\relax \tabcaption{#2}\else\tabcaption[#1]{#2}\fi%
    \fi
  \fi
\else\ifx\relax\hv@shortCap\relax\caption{#2}\else\caption[#1]{#2}\fi%
        \fi%
        \label{#3}%
      \end{minipage}%
      }%
    }%
  \fi%
%%
  \restoreCaptionSkip% save old values
  \ifx\hvSet@objectPos\hv@Right\bidi@raggedleft%
  \else%
    \ifx\hvSet@objectPos\hv@Center
      \ifhv@nonFloat\hspace*{\fill}\else\centering\fi%
    \fi%
  \fi%
  \savebox{\@tempboxa}{%
  \ifx\hvSet@capPos\hv@Left  %  caption on left side
\if@RTL%
\ifx\hvSet@capVPos\hv@Center%
\ifhv@fbox
\fbox{\parbox{\wd\hvObjectBox}{\usebox{\hvObjectBox}}}
\else
\parbox{\wd\hvObjectBox}{\usebox{\hvObjectBox}}
\fi%
\hspace{\hvSet@floatCapSep pt}%
\ifhv@fbox
\fbox{\parbox{\wd\hvCaptionBox}{\usebox{\hvCaptionBox}}}%
\else
\parbox{\wd\hvCaptionBox}{\usebox{\hvCaptionBox}}
\fi%
\else%
\ifx\hvSet@capVPos\hv@Top
\ifhv@fbox
\fbox{\raisebox{-\height}{\usebox{\hvObjectBox}}}%
\else
\raisebox{-\height}{\usebox{\hvObjectBox}}%
\fi%
\hspace{\hvSet@floatCapSep pt}%
\ifhv@fbox
\fbox{\raisebox{-\height}{\usebox{\hvCaptionBox}}}%
\else
\raisebox{-\height}{\usebox{\hvCaptionBox}}%
\fi
\else
\ifhv@fbox
\fbox{\usebox{\hvObjectBox}}%
\else
\usebox{\hvObjectBox}%
\fi
\hspace{\hvSet@floatCapSep pt}%
\ifhv@fbox
\fbox{\usebox{\hvCaptionBox}}%
\else
\usebox{\hvCaptionBox}%
\fi%
\fi%
\fi%
\else% not RTL
    \ifx\hvSet@capVPos\hv@Center%
      \ifhv@fbox\fbox{\parbox{\wd\hvCaptionBox}{\usebox{\hvCaptionBox}}}%
      \else     \parbox{\wd\hvCaptionBox}{\usebox{\hvCaptionBox}}%
      \fi%
    \hspace{\hvSet@floatCapSep pt}% capfloatsep
    \ifhv@fbox\fbox{\parbox{\wd\hvObjectBox}{\usebox{\hvObjectBox}}}
    \else     \parbox{\wd\hvObjectBox}{\usebox{\hvObjectBox}}
    \fi%
  \else%
    \ifx\hvSet@capVPos\hv@Top % caption at top
      \ifhv@fbox\fbox{\raisebox{-\height}{\usebox{\hvCaptionBox}}}%
      \else     \raisebox{-\height}{\usebox{\hvCaptionBox}}%
      \fi
      \hspace{\hvSet@floatCapSep pt}% capfloatsep
      \ifhv@fbox\fbox{\raisebox{-\height}{\usebox{\hvObjectBox}}}%
      \else     \raisebox{-\height}{\usebox{\hvObjectBox}}%
      \fi%
    \else% caption on bottom
      \ifhv@fbox\fbox{\usebox{\hvCaptionBox}}
                \else\usebox{\hvCaptionBox}
      \fi%
      \hspace{\hvSet@floatCapSep pt}%
      \ifhv@fbox\fbox{\usebox{\hvObjectBox}}
      \else     \usebox{\hvObjectBox}
      \fi%
    \fi%
\fi% end of RTL
  \fi%
  \else
\ifx\hvSet@capPos\hv@Top
\ifdim\wd\hvCaptionBox>\wd\hvObjectBox
\begin{minipage}{\wd\hvCaptionBox}
\else
\begin{minipage}{\wd\hvObjectBox}
\fi
\centering
\ifhv@fbox
\fbox{\usebox{\hvCaptionBox}}\\[\hvBelowCaptionSkip]
\fbox{\usebox{\hvObjectBox}}
\else
\usebox{\hvCaptionBox}\\[\hvBelowCaptionSkip]
\usebox{\hvObjectBox}
\fi%
\end{minipage}
\else
\ifx\hvSet@capPos\hv@Bottom
\ifdim\wd\hvCaptionBox>\wd\hvObjectBox
\begin{minipage}{\wd\hvCaptionBox}
\else
\begin{minipage}{\wd\hvObjectBox}
\fi
\centering
\ifhv@fbox
\fbox{\usebox{\hvObjectBox}}\\[\hvAboveCaptionSkip]
\fbox{\usebox{\hvCaptionBox}}
\else
\usebox{\hvObjectBox}\\[\hvAboveCaptionSkip]
\usebox{\hvCaptionBox}
\fi%
\end{minipage}
\else% the last option: put the caption on the right
\if@RTL%
    \ifx\hvSet@capVPos\hv@Center%
      \ifhv@fbox\fbox{\parbox{\wd\hvCaptionBox}{\usebox{\hvCaptionBox}}}%
      \else     \parbox{\wd\hvCaptionBox}{\usebox{\hvCaptionBox}}%
      \fi%
    \hspace{\hvSet@floatCapSep pt}% capfloatsep
    \ifhv@fbox\fbox{\parbox{\wd\hvObjectBox}{\usebox{\hvObjectBox}}}
    \else     \parbox{\wd\hvObjectBox}{\usebox{\hvObjectBox}}
    \fi%
  \else%
    \ifx\hvSet@capVPos\hv@Top % caption at top
      \ifhv@fbox\fbox{\raisebox{-\height}{\usebox{\hvCaptionBox}}}%
      \else     \raisebox{-\height}{\usebox{\hvCaptionBox}}%
      \fi
      \hspace{\hvSet@floatCapSep pt}% capfloatsep
      \ifhv@fbox\fbox{\raisebox{-\height}{\usebox{\hvObjectBox}}}%
      \else     \raisebox{-\height}{\usebox{\hvObjectBox}}%
      \fi%
    \else% caption on bottom
      \ifhv@fbox\fbox{\usebox{\hvCaptionBox}}
                \else\usebox{\hvCaptionBox}
      \fi%
      \hspace{\hvSet@floatCapSep pt}%
      \ifhv@fbox\fbox{\usebox{\hvObjectBox}}
      \else     \usebox{\hvObjectBox}
      \fi%
    \fi%
  \fi%
\else% not RTL
\ifx\hvSet@capVPos\hv@Center%
\ifhv@fbox
\fbox{\parbox{\wd\hvObjectBox}{\usebox{\hvObjectBox}}}
\else
\parbox{\wd\hvObjectBox}{\usebox{\hvObjectBox}}
\fi%
\hspace{\hvSet@floatCapSep pt}%
\ifhv@fbox
\fbox{\parbox{\wd\hvCaptionBox}{\usebox{\hvCaptionBox}}}%
\else
\parbox{\wd\hvCaptionBox}{\usebox{\hvCaptionBox}}
\fi%
\else%
\ifx\hvSet@capVPos\hv@Top
\ifhv@fbox
\fbox{\raisebox{-\height}{\usebox{\hvObjectBox}}}%
\else
\raisebox{-\height}{\usebox{\hvObjectBox}}%
\fi%
\hspace{\hvSet@floatCapSep pt}%
\ifhv@fbox
\fbox{\raisebox{-\height}{\usebox{\hvCaptionBox}}}%
\else
\raisebox{-\height}{\usebox{\hvCaptionBox}}%
\fi
\else
\ifhv@fbox
\fbox{\usebox{\hvObjectBox}}%
\else
\usebox{\hvObjectBox}%
\fi
\hspace{\hvSet@floatCapSep pt}%
\ifhv@fbox
\fbox{\usebox{\hvCaptionBox}}%
\else
\usebox{\hvCaptionBox}%
\fi%
\fi%
\fi
\fi% end of RTL
\fi
\fi
\fi
}% End savebox Object and caption
\ifx\hvSet@rotAngle\hv@Zero
\usebox{\@tempboxa}
\else
\rotatebox{\hvSet@rotAngle}{\usebox{\@tempboxa}}
\fi
\ifhv@nonFloat
\ifx\hvSet@objectPos\hv@Center
\ifhv@nonFloat
\hspace{\fill}
\fi
\fi
\endgroup% End the nonfloat part
\else
\end{\hv@floatType}% End the floating environment
\fi
}
%% 
%% Copyright © 2009–2013  Persian TeX Group <persian-tex@tug.org>
%% 
%% It may be distributed and/or modified under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of
%% this license is at: http://www.latex-project.org/lppl.txt
%% 
%% This work is “maintained” (as per LPPL maintenance status)
%% by Persian TeX Group.
%% 
%% 
%% 
%%
%% End of file `hvfloat-xetex-bidi.def'.
