Kaydet (Commit) 45511b36 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

deal with code duplication at drawing from a definition file

Change-Id: Ie2f6ace37562a251d639c5049c91a4ba09576c0b
Reviewed-on: https://gerrit.libreoffice.org/68754
Tested-by: Jenkins
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 07cb5f46
...@@ -259,85 +259,34 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart ...@@ -259,85 +259,34 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart
break; break;
case ControlType::Pushbutton: case ControlType::Pushbutton:
{ {
std::shared_ptr<WidgetDefinitionPart> pPart /*bool bIsAction = false;
= m_aWidgetDefinition.getDefinition(eType, ePart); const PushButtonValue* pPushButtonValue = static_cast<const PushButtonValue*>(&rValue);
if (pPart) if (pPushButtonValue)
{ bIsAction = pPushButtonValue->mbIsAction;*/
auto aStates = pPart->getStates(eState, rValue);
if (!aStates.empty()) bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
{
std::shared_ptr<WidgetDefinitionState> pState = aStates.back();
{
munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth,
nHeight);
bOK = true;
}
}
}
} }
break; break;
case ControlType::Radiobutton: case ControlType::Radiobutton:
{ {
std::shared_ptr<WidgetDefinitionPart> pPart bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
= m_aWidgetDefinition.getDefinition(eType, ePart);
if (pPart)
{
std::shared_ptr<WidgetDefinitionState> pState
= pPart->getStates(eState, rValue).back();
{
munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth, nHeight);
bOK = true;
}
}
} }
break; break;
case ControlType::Checkbox: case ControlType::Checkbox:
{ {
std::shared_ptr<WidgetDefinitionPart> pPart bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
= m_aWidgetDefinition.getDefinition(eType, ePart);
if (pPart)
{
auto aStates = pPart->getStates(eState, rValue);
if (!aStates.empty())
{
std::shared_ptr<WidgetDefinitionState> pState = aStates.back();
munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth, nHeight);
bOK = true;
}
}
} }
break; break;
case ControlType::Combobox: case ControlType::Combobox:
{ {
std::shared_ptr<WidgetDefinitionPart> pPart bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
= m_aWidgetDefinition.getDefinition(eType, ePart);
if (pPart)
{
auto aStates = pPart->getStates(eState, rValue);
if (!aStates.empty())
{
std::shared_ptr<WidgetDefinitionState> pState = aStates.back();
munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth, nHeight);
bOK = true;
}
}
} }
break; break;
case ControlType::Editbox: case ControlType::Editbox:
case ControlType::EditboxNoBorder: case ControlType::EditboxNoBorder:
case ControlType::MultilineEditbox: case ControlType::MultilineEditbox:
{ {
std::shared_ptr<WidgetDefinitionPart> pPart bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
= m_aWidgetDefinition.getDefinition(eType, ePart);
if (pPart)
{
std::shared_ptr<WidgetDefinitionState> pState
= pPart->getStates(eState, rValue).back();
{
munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth, nHeight);
bOK = true;
}
}
} }
break; break;
case ControlType::Listbox: case ControlType::Listbox:
...@@ -348,61 +297,38 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart ...@@ -348,61 +297,38 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart
{ {
const SpinbuttonValue* pSpinVal = static_cast<const SpinbuttonValue*>(&rValue); const SpinbuttonValue* pSpinVal = static_cast<const SpinbuttonValue*>(&rValue);
{
ControlPart eUpButtonPart = pSpinVal->mnUpperPart; ControlPart eUpButtonPart = pSpinVal->mnUpperPart;
ControlState eUpButtonState = pSpinVal->mnUpperState; ControlState eUpButtonState = pSpinVal->mnUpperState;
ControlPart eDownButtonPart = pSpinVal->mnLowerPart; long nUpperX = pSpinVal->maUpperRect.Left();
ControlState eDownButtonState = pSpinVal->mnLowerState; long nUpperY = pSpinVal->maUpperRect.Top();
long nUpperWidth = pSpinVal->maUpperRect.GetWidth() - 1;
long nUpperHeight = pSpinVal->maUpperRect.GetHeight() - 1;
{ bOK = resolveDefinition(eType, eUpButtonPart, eUpButtonState,
std::shared_ptr<WidgetDefinitionPart> pPart ImplControlValue(), nUpperX, nUpperY, nUpperWidth,
= m_aWidgetDefinition.getDefinition(eType, eUpButtonPart); nUpperHeight);
if (pPart)
{
std::shared_ptr<WidgetDefinitionState> pState
= pPart->getStates(eUpButtonState, ImplControlValue()).back();
{
munchDrawCommands(
pState->mpDrawCommands, m_rGraphics, pSpinVal->maUpperRect.Left(),
pSpinVal->maUpperRect.Top(), pSpinVal->maUpperRect.GetWidth() - 1,
pSpinVal->maUpperRect.GetHeight() - 1);
bOK = true;
}
}
} }
if (bOK) if (bOK)
{ {
std::shared_ptr<WidgetDefinitionPart> pPart ControlPart eDownButtonPart = pSpinVal->mnLowerPart;
= m_aWidgetDefinition.getDefinition(eType, eDownButtonPart); ControlState eDownButtonState = pSpinVal->mnLowerState;
if (pPart)
{ long nLowerX = pSpinVal->maLowerRect.Left();
std::shared_ptr<WidgetDefinitionState> pState long nLowerY = pSpinVal->maLowerRect.Top();
= pPart->getStates(eDownButtonState, ImplControlValue()).back(); long nLowerWidth = pSpinVal->maLowerRect.GetWidth() - 1;
{ long nLowerHeight = pSpinVal->maLowerRect.GetHeight() - 1;
munchDrawCommands(
pState->mpDrawCommands, m_rGraphics, pSpinVal->maLowerRect.Left(), bOK = resolveDefinition(eType, eDownButtonPart, eDownButtonState,
pSpinVal->maLowerRect.Top(), pSpinVal->maLowerRect.GetWidth() - 1, ImplControlValue(), nLowerX, nLowerY, nLowerWidth,
pSpinVal->maLowerRect.GetHeight() - 1); nLowerHeight);
bOK = true;
}
}
} }
} }
else else
{ {
std::shared_ptr<WidgetDefinitionPart> pPart bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
= m_aWidgetDefinition.getDefinition(eType, ePart);
if (pPart)
{
std::shared_ptr<WidgetDefinitionState> pState
= pPart->getStates(eState, ImplControlValue()).back();
{
munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth,
nHeight);
bOK = true;
}
}
} }
} }
break; break;
...@@ -423,65 +349,26 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart ...@@ -423,65 +349,26 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart
break; break;
case ControlType::Slider: case ControlType::Slider:
{ {
{ bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
std::shared_ptr<WidgetDefinitionPart> pPart
= m_aWidgetDefinition.getDefinition(eType, ePart);
if (pPart)
{
auto aStates = pPart->getStates(eState, rValue);
if (!aStates.empty())
{
std::shared_ptr<WidgetDefinitionState> pState = aStates.back();
{
munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth,
nHeight);
bOK = true;
}
}
}
}
if (bOK) if (bOK)
{ {
const SliderValue* pSliderValue = static_cast<const SliderValue*>(&rValue); const SliderValue* pSliderValue = static_cast<const SliderValue*>(&rValue);
std::shared_ptr<WidgetDefinitionPart> pPart long nThumbX = pSliderValue->maThumbRect.Left();
= m_aWidgetDefinition.getDefinition(eType, ControlPart::Button); long nThumbY = pSliderValue->maThumbRect.Top();
if (pPart) long nThumbWidth = pSliderValue->maThumbRect.GetWidth() - 1;
{ long nThumbHeight = pSliderValue->maThumbRect.GetHeight() - 1;
auto aStates = pPart->getStates(eState | pSliderValue->mnThumbState, rValue);
if (!aStates.empty()) bOK = resolveDefinition(eType, ControlPart::Button,
{ eState | pSliderValue->mnThumbState, rValue, nThumbX,
std::shared_ptr<WidgetDefinitionState> pState = aStates.back(); nThumbY, nThumbWidth, nThumbHeight);
{
munchDrawCommands(pState->mpDrawCommands, m_rGraphics,
pSliderValue->maThumbRect.Left(),
pSliderValue->maThumbRect.Top(),
pSliderValue->maThumbRect.GetWidth() - 1,
pSliderValue->maThumbRect.GetHeight() - 1);
bOK = true;
}
}
}
} }
} }
break; break;
case ControlType::Fixedline: case ControlType::Fixedline:
{ {
std::shared_ptr<WidgetDefinitionPart> pPart bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
= m_aWidgetDefinition.getDefinition(eType, ePart);
if (pPart)
{
auto aStates = pPart->getStates(eState, rValue);
if (!aStates.empty())
{
std::shared_ptr<WidgetDefinitionState> pState = aStates.back();
{
munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth,
nHeight);
bOK = true;
}
}
}
} }
break; break;
case ControlType::Toolbar: case ControlType::Toolbar:
...@@ -492,21 +379,7 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart ...@@ -492,21 +379,7 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart
case ControlType::Progress: case ControlType::Progress:
case ControlType::IntroProgress: case ControlType::IntroProgress:
{ {
std::shared_ptr<WidgetDefinitionPart> pPart bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
= m_aWidgetDefinition.getDefinition(eType, ePart);
if (pPart)
{
auto aStates = pPart->getStates(eState, rValue);
if (!aStates.empty())
{
std::shared_ptr<WidgetDefinitionState> pState = aStates.back();
{
munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth,
nHeight);
bOK = true;
}
}
}
} }
break; break;
case ControlType::Tooltip: case ControlType::Tooltip:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment