1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 #ifndef SW_SIDEBAR_PAGE_PROPERTY_PANEL_HXX 23 #define SW_SIDEBAR_PAGE_PROPERTY_PANEL_HXX 24 25 #include <svx/sidebar/Popup.hxx> 26 27 #include <sfx2/sidebar/IContextChangeReceiver.hxx> 28 #include <sfx2/sidebar/ControllerItem.hxx> 29 30 namespace svx { namespace sidebar { 31 class PopupControl; 32 } } 33 34 #include <i18npool/paper.hxx> 35 36 #include <svx/pageitem.hxx> 37 #include <svx/rulritem.hxx> 38 #include <editeng/sizeitem.hxx> 39 40 #include <vcl/ctrl.hxx> 41 #include <vcl/fixed.hxx> 42 #include <vcl/button.hxx> 43 #include <vcl/toolbox.hxx> 44 #include <vcl/lstbox.hxx> 45 #include <vcl/field.hxx> 46 #include <svl/intitem.hxx> 47 48 #include <com/sun/star/frame/XFrame.hpp> 49 #include <boost/scoped_ptr.hpp> 50 51 52 namespace css = ::com::sun::star; 53 namespace cssu = ::com::sun::star::uno; 54 55 namespace sw { namespace sidebar { 56 57 class PagePropertyPanel 58 : public Control, 59 public ::sfx2::sidebar::IContextChangeReceiver, 60 public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface 61 { 62 public: 63 static PagePropertyPanel* Create( 64 Window* pParent, 65 const cssu::Reference<css::frame::XFrame>& rxFrame, 66 SfxBindings* pBindings); 67 68 // override Window::DataChanged(..) inherited via Control to react on certain changes 69 virtual void DataChanged( const DataChangedEvent& rEvent ); 70 71 // interface of ::sfx2::sidebar::IContextChangeReceiver 72 virtual void HandleContextChange( 73 const ::sfx2::sidebar::EnumContext aContext); 74 75 // interface of ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface 76 virtual void NotifyItemUpdate( 77 const sal_uInt16 nSId, 78 const SfxItemState eState, 79 const SfxPoolItem* pState); 80 81 // action on 'More Options' button in panel title 82 void ShowPageStyleFormatDialog( void ); 83 84 SfxBindings* GetBindings() const 85 { 86 return mpBindings; 87 } 88 89 90 ::svx::sidebar::PopupControl* CreatePageOrientationControl( ::svx::sidebar::PopupContainer* pParent ); 91 void ExecuteOrientationChange( const sal_Bool bLandscape ); 92 void ClosePageOrientationPopup(); 93 94 ::svx::sidebar::PopupControl* CreatePageMarginControl( ::svx::sidebar::PopupContainer* pParent ); 95 void ExecuteMarginLRChange( 96 const long nPageLeftMargin, 97 const long nPageRightMargin ); 98 void ExecuteMarginULChange( 99 const long nPageTopMargin, 100 const long nPageBottomMargin ); 101 void ExecutePageLayoutChange( const bool bMirrored ); 102 void ClosePageMarginPopup(); 103 104 ::svx::sidebar::PopupControl* CreatePageSizeControl( ::svx::sidebar::PopupContainer* pParent ); 105 void ExecuteSizeChange( const Paper ePaper ); 106 void ClosePageSizePopup(); 107 108 ::svx::sidebar::PopupControl* CreatePageColumnControl( ::svx::sidebar::PopupContainer* pParent ); 109 void ExecuteColumnChange( const sal_uInt16 nColumnType ); 110 void ClosePageColumnPopup(); 111 112 private: 113 PagePropertyPanel( 114 Window* pParent, 115 const cssu::Reference<css::frame::XFrame>& rxFrame, 116 SfxBindings* pBindings); 117 virtual ~PagePropertyPanel(void); 118 119 cssu::Reference<css::frame::XFrame> mxFrame; 120 ::sfx2::sidebar::EnumContext maContext; 121 SfxBindings* mpBindings; 122 123 // toolboxes - on click open corresponding popup 124 FixedText maFtOrientation; 125 ::boost::scoped_ptr<Window> mpToolBoxOrientationBackground; 126 ::boost::scoped_ptr<ToolBox> mpToolBoxOrientation; 127 FixedText maFtMargin; 128 ::boost::scoped_ptr<Window> mpToolBoxMarginBackground; 129 ::boost::scoped_ptr<ToolBox> mpToolBoxMargin; 130 FixedText maFtSize; 131 ::boost::scoped_ptr<Window> mpToolBoxSizeBackground; 132 ::boost::scoped_ptr<ToolBox> mpToolBoxSize; 133 FixedText maFtColumn; 134 ::boost::scoped_ptr<Window> mpToolBoxColumnBackground; 135 ::boost::scoped_ptr<ToolBox> mpToolBoxColumn; 136 137 Image* maImgSize; 138 Image* maImgSize_L; 139 Image mImgPortrait; 140 Image mImgLandscape; 141 Image mImgNarrow; 142 Image mImgNormal; 143 Image mImgWide; 144 Image mImgMirrored; 145 Image mImgMarginCustom; 146 Image mImgNarrow_L; 147 Image mImgNormal_L; 148 Image mImgWide_L; 149 Image mImgMirrored_L; 150 Image mImgMarginCustom_L; 151 Image mImgA3; 152 Image mImgA4; 153 Image mImgA5; 154 Image mImgB4; 155 Image mImgB5; 156 Image mImgC5; 157 Image mImgLetter; 158 Image mImgLegal; 159 Image mImgSizeNone; 160 Image mImgA3_L; 161 Image mImgA4_L; 162 Image mImgA5_L; 163 Image mImgB4_L; 164 Image mImgB5_L; 165 Image mImgC5_L; 166 Image mImgLetter_L; 167 Image mImgLegal_L; 168 Image mImgSizeNone_L; 169 Image mImgColumn1; 170 Image mImgColumn2; 171 Image mImgColumn3; 172 Image mImgLeft; 173 Image mImgRight; 174 Image mImgColumnNone; 175 Image mImgColumn1_L; 176 Image mImgColumn2_L; 177 Image mImgColumn3_L; 178 Image mImgLeft_L; 179 Image mImgRight_L; 180 Image mImgColumnNone_L; 181 182 // item keeping the following page style attributes: 183 // - page orientation 184 // - page usage - only left, only right, both, mirrored 185 // item also hold the numbering type for the page style which should 186 // be kept stable. 187 ::boost::scoped_ptr<SvxPageItem> mpPageItem; 188 189 // item keeping the page style's left and right margins 190 ::boost::scoped_ptr<SvxLongLRSpaceItem> mpPageLRMarginItem; 191 // item keeping the page style's top and bottom margins 192 ::boost::scoped_ptr<SvxLongULSpaceItem> mpPageULMarginItem; 193 194 // item keeping the page style's page size 195 ::boost::scoped_ptr<SvxSizeItem> mpPageSizeItem; 196 // Paper corresponding to the page style's page size 197 Paper mePaper; 198 199 // item keeping the page column type 200 ::boost::scoped_ptr<SfxInt16Item> mpPageColumnTypeItem; 201 202 FieldUnit meFUnit; 203 SfxMapUnit meUnit; 204 205 // controller items 206 ::sfx2::sidebar::ControllerItem m_aSwPagePgULControl; 207 ::sfx2::sidebar::ControllerItem m_aSwPagePgLRControl; 208 ::sfx2::sidebar::ControllerItem m_aSwPagePgSizeControl; 209 ::sfx2::sidebar::ControllerItem m_aSwPagePgControl; 210 ::sfx2::sidebar::ControllerItem m_aSwPageColControl; 211 ::sfx2::sidebar::ControllerItem m_aSwPagePgMetricControl; 212 213 // popups 214 ::boost::scoped_ptr< ::svx::sidebar::Popup > mpOrientationPopup; 215 ::boost::scoped_ptr< ::svx::sidebar::Popup > mpMarginPopup; 216 ::boost::scoped_ptr< ::svx::sidebar::Popup > mpSizePopup; 217 ::boost::scoped_ptr< ::svx::sidebar::Popup > mpColumnPopup; 218 219 bool mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify; 220 221 // handler for popup toolboxes to show the popups 222 DECL_LINK(ClickOrientationHdl, ToolBox* ); 223 DECL_LINK(ClickMarginHdl, ToolBox* ); 224 DECL_LINK(ClickSizeHdl, ToolBox* ); 225 DECL_LINK(ClickColumnHdl, ToolBox* ); 226 227 void Initialize(); 228 229 void MetricState( SfxItemState eState, const SfxPoolItem* pState ); 230 231 // helper to adjust popup toolbox' images 232 void ChangeMarginImage(); 233 void ChangeSizeImage(); 234 void ChangeColumnImage( const sal_uInt16 nColumnType ); 235 236 }; 237 238 } } // end of namespace ::sw::sidebar 239 240 #endif 241