1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #ifndef INCLUDED_REPORTDESIGN_SOURCE_UI_INC_CONDFORMAT_HXX 21 #define INCLUDED_REPORTDESIGN_SOURCE_UI_INC_CONDFORMAT_HXX 22 23 #include <com/sun/star/report/XReportControlModel.hpp> 24 #include <vcl/weld.hxx> 25 #include <vector> 26 27 namespace rptui 28 { 29 30 31 constexpr size_t MAX_CONDITIONS = 3; 32 33 class OReportController; 34 class Condition; 35 36 37 //= IConditionalFormatAction 38 39 class SAL_NO_VTABLE IConditionalFormatAction 40 { 41 public: 42 virtual void addCondition( size_t _nAddAfterIndex ) = 0; 43 virtual void deleteCondition( size_t _nCondIndex ) = 0; 44 virtual void applyCommand( size_t _nCondIndex, sal_uInt16 _nCommandId, const ::Color& rColor ) = 0; 45 virtual void moveConditionUp( size_t _nCondIndex ) = 0; 46 virtual void moveConditionDown( size_t _nCondIndex ) = 0; 47 virtual OUString getDataField() const = 0; 48 49 protected: ~IConditionalFormatAction()50 ~IConditionalFormatAction() {} 51 }; 52 53 /************************************************************************* 54 |* 55 |* Conditional formatting dialog 56 |* 57 \************************************************************************/ 58 class ConditionalFormattingDialog : public weld::GenericDialogController 59 , public IConditionalFormatAction 60 { 61 typedef ::std::vector< std::unique_ptr<Condition> > Conditions; 62 63 ::rptui::OReportController& m_rController; 64 css::uno::Reference< css::report::XReportControlModel > 65 m_xFormatConditions; 66 css::uno::Reference< css::report::XReportControlModel > 67 m_xCopy; 68 69 bool m_bConstructed; 70 71 std::unique_ptr<weld::ScrolledWindow> m_xScrollWindow; 72 std::unique_ptr<weld::Box> m_xConditionPlayground; 73 Conditions m_aConditions; 74 75 public: 76 ConditionalFormattingDialog( 77 weld::Window* pParent, 78 const css::uno::Reference< css::report::XReportControlModel>& _xHoldAlive, 79 ::rptui::OReportController& _rController 80 ); 81 virtual ~ConditionalFormattingDialog() override; 82 // Dialog overridables 83 virtual short run() override; 84 85 // IConditionalFormatAction overridables 86 virtual void addCondition( size_t _nAddAfterIndex ) override; 87 virtual void deleteCondition( size_t _nCondIndex ) override; 88 virtual void applyCommand( size_t _nCondIndex, sal_uInt16 _nCommandId, const ::Color& rColor ) override; 89 virtual void moveConditionUp( size_t _nCondIndex ) override; 90 virtual void moveConditionDown( size_t _nCondIndex ) override; 91 virtual OUString getDataField() const override; 92 93 private: 94 DECL_LINK(OnScroll, weld::ScrolledWindow&, void); 95 96 private: 97 /// returns the current number of conditions impl_getConditionCount() const98 size_t impl_getConditionCount() const { return m_aConditions.size(); } 99 100 /** adds a condition 101 @param _nNewCondIndex 102 the index of the to-be-inserted condition 103 */ 104 void impl_addCondition_nothrow( size_t _nNewCondIndex ); 105 106 /// deletes the condition with the given index 107 void impl_deleteCondition_nothrow( size_t _nCondIndex ); 108 109 /// moves the condition with the given index one position 110 void impl_moveCondition_nothrow( size_t _nCondIndex, bool _bMoveUp ); 111 112 /// does the dialog layouting 113 void impl_layoutAll(); 114 115 /// called when the number of conditions has changed in any way 116 void impl_conditionCountChanged(); 117 118 /// initializes the conditions from m_xCopy 119 void impl_initializeConditions(); 120 121 /// tells all our Condition instances their new index 122 void impl_updateConditionIndicies(); 123 124 /// returns the number of the condition which has the (child path) focus 125 size_t impl_getFocusedConditionIndex( sal_Int32 _nFallBackIfNone ) const; 126 127 /// returns the index of the first visible condition 128 size_t impl_getFirstVisibleConditionIndex() const; 129 130 /// returns the index of the last visible condition 131 size_t impl_getLastVisibleConditionIndex() const; 132 133 /// focuses the condition with the given index, making it visible if necessary 134 void impl_focusCondition( size_t _nCondIndex ); 135 136 /// scrolls the condition with the given index to the top position 137 void impl_scrollTo( size_t _nTopCondIndex ); 138 139 /// ensures the condition with the given index is visible 140 void impl_ensureConditionVisible( size_t _nCondIndex ); 141 142 /// set the preferred height of the action_area 143 void impl_setPrefHeight(bool bFirst); 144 }; 145 146 147 } // namespace rptui 148 149 150 #endif // INCLUDED_REPORTDESIGN_SOURCE_UI_INC_CONDFORMAT_HXX 151 152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 153
