24#include <core_resource.hxx>
28#include <com/sun/star/lang/IllegalArgumentException.hpp>
38#include <UndoActions.hxx>
45 using ::com::sun::star::uno::Reference;
46 using ::com::sun::star::uno::UNO_QUERY_THROW;
47 using ::com::sun::star::uno::UNO_QUERY;
48 using ::com::sun::star::uno::Exception;
49 using ::com::sun::star::lang::IllegalArgumentException;
50 using ::com::sun::star::uno::Sequence;
51 using ::com::sun::star::beans::PropertyValue;
52 using ::com::sun::star::uno::Any;
66 auto nHeight =
m_aConditions[0]->get_preferred_size().Height();
68 nHeight *= nVisibleConditions;
80 : GenericDialogController(_pParent,
"modules/dbreport/ui/condformatdialog.ui",
"CondFormat")
82 , m_xFormatConditions(_rxFormatConditions)
83 , m_bConstructed(false)
84 , m_xScrollWindow(m_xBuilder->weld_scrolled_window(
"scrolledwindow"))
85 , m_xConditionPlayground(m_xBuilder->weld_box(
"condPlaygroundDrawingarea"))
87 OSL_ENSURE(
m_xFormatConditions.is(),
"ConditionalFormattingDialog::ConditionalFormattingDialog: ReportControlModel is NULL -> Prepare for GPF!" );
128 OSL_PRECOND( _nAddAfterIndex <
impl_getConditionCount(),
"ConditionalFormattingDialog::addCondition: illegal condition index!" );
144 throw IllegalArgumentException();
147 ::comphelper::copyProperties(
m_xCopy, xCond);
148 m_xCopy->insertByIndex( _nNewCondIndex,
Any( xCond ) );
150 xCon->setCondition(xCond);
167 "ConditionalFormattingDialog::impl_focusCondition: illegal index!" );
176 "ConditionalFormattingDialog::impl_deleteCondition_nothrow: illegal index!" );
180 bool bSetNewFocus =
false;
181 size_t nNewFocusIndex( _nCondIndex );
184 if ( !bLastCondition )
185 m_xCopy->removeByIndex( _nCondIndex );
188 if ( bLastCondition )
191 xFormatCondition->setFormula( OUString() );
192 (*pos)->setCondition( xFormatCondition );
196 bSetNewFocus = (*pos)->has_focus();
198 auto xMovedCondition = std::move(*
pos);
222 size_t nOldConditionIndex( _nCondIndex );
223 size_t nNewConditionIndex( _bMoveUp ? _nCondIndex - 1 : _nCondIndex + 1 );
227 std::unique_ptr<Condition> xMovedCondition;
230 aMovedCondition =
m_xCopy->getByIndex(
static_cast<sal_Int32
>(nOldConditionIndex) );
231 m_xCopy->removeByIndex(
static_cast<sal_Int32
>(nOldConditionIndex) );
233 Conditions::iterator aRemovePos(
m_aConditions.begin() + nOldConditionIndex );
234 xMovedCondition = std::move(*aRemovePos);
245 m_xCopy->insertByIndex(
static_cast<sal_Int32
>(nNewConditionIndex), aMovedCondition );
262 size_t nFirstCondIndex( impl_getFirstVisibleConditionIndex() );
263 size_t nFocusCondIndex = impl_getFocusedConditionIndex( nFirstCondIndex );
265 if ( nFocusCondIndex < nFirstCondIndex )
266 impl_focusCondition( nFirstCondIndex );
284 for ( sal_Int32
i = 0;
i <
nCount ; ++
i )
289 xCon->setCondition(xCond);
290 xCon->updateToolbar(xCond);
296 OSL_FAIL(
"Can not access format condition!");
304 OSL_PRECOND( _nCommandId,
"ConditionalFormattingDialog::applyCommand: illegal command id!" );
317 m_aConditions[ _nCondIndex ]->updateToolbar(xReportControlFormat);
328 OSL_PRECOND( _nCondIndex > 0,
"ConditionalFormattingDialog::moveConditionUp: cannot move up the first condition!" );
329 if ( _nCondIndex > 0 )
336 OSL_PRECOND( _nCondIndex <
impl_getConditionCount(),
"ConditionalFormattingDialog::moveConditionDown: cannot move down the last condition!" );
357 short nRet = GenericDialogController::run();
360 const OUString sUndoAction(
RptResId( RID_STR_UNDO_CONDITIONAL_FORMATTING ) );
364 sal_Int32 j(0),
i(0);
365 for ( Conditions::const_iterator cond =
m_aConditions.begin();
371 (*cond)->fillFormatCondition( xCond );
373 if ( (*cond)->isEmpty() )
387 ::comphelper::copyProperties(xCond, xNewCond);
406 auto nHeight =
m_aConditions[0]->get_preferred_size().Height();
418 [](
const std::unique_ptr<Condition>& rxCondition) { return rxCondition->has_focus(); });
420 return static_cast<size_t>(std::distance(
m_aConditions.begin(), cond));
421 return _nFallBackIfNone;
427 "ConditionalFormattingDialog::impl_scrollTo: illegal index!" );
429 auto nHeight =
m_aConditions[0]->get_preferred_size().Height();
437 "ConditionalFormattingDialog::impl_ensureConditionVisible: illegal index!" );
ClassificationCategoriesController & m_rController
SfxUndoManager & getUndoManager() const
std::shared_ptr< weld::Dialog > m_xDialog
OUString RptResId(TranslateId aId)
#define DBG_UNHANDLED_EXCEPTION(...)
#define LINK(Instance, Class, Member)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
IMPL_LINK_NOARG(OAddFieldWindow, FocusChangeHdl, weld::Container &, void)
constexpr size_t MAX_CONDITIONS
constexpr OUStringLiteral REPORTCONTROLFORMAT
constexpr OUStringLiteral PROPERTY_FONTCOLOR
constexpr OUStringLiteral CURRENT_WINDOW