1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef _CONTROLHELPER_HXX_ 29*cdf0e10cSrcweir #define _CONTROLHELPER_HXX_ 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <rtl/ustring.hxx> 32*cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include <list> 35*cdf0e10cSrcweir #include <map> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <premac.h> 38*cdf0e10cSrcweir #include <Cocoa/Cocoa.h> 39*cdf0e10cSrcweir #include <postmac.h> 40*cdf0e10cSrcweir #include "SalAquaConstants.h" 41*cdf0e10cSrcweir #include "FilterHelper.hxx" 42*cdf0e10cSrcweir #include "AquaFilePickerDelegate.hxx" 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir using namespace com::sun::star; 45*cdf0e10cSrcweir using namespace rtl; 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir class ControlHelper { 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir public: 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 52*cdf0e10cSrcweir // Constructor / Destructor 53*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 54*cdf0e10cSrcweir ControlHelper(); 55*cdf0e10cSrcweir virtual ~ControlHelper(); 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir //------------------------------------------------ 58*cdf0e10cSrcweir // XInitialization delegate 59*cdf0e10cSrcweir //------------------------------------------------ 60*cdf0e10cSrcweir void initialize( sal_Int16 templateId ); 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 63*cdf0e10cSrcweir // XFilePickerControlAccess function delegates 64*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 65*cdf0e10cSrcweir void setValue( sal_Int16 nControlId, sal_Int16 nControlAction, const uno::Any& rValue ); 66*cdf0e10cSrcweir uno::Any getValue( sal_Int16 nControlId, sal_Int16 nControlAction ) const; 67*cdf0e10cSrcweir void enableControl( sal_Int16 nControlId, sal_Bool bEnable ) const; 68*cdf0e10cSrcweir OUString getLabel( sal_Int16 nControlId ); 69*cdf0e10cSrcweir void setLabel( sal_Int16 nControlId, const NSString* aLabel ); 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 72*cdf0e10cSrcweir // other stuff 73*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 74*cdf0e10cSrcweir void updateFilterUI(); 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 77*cdf0e10cSrcweir // Type definitions 78*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 79*cdf0e10cSrcweir enum ToggleType { 80*cdf0e10cSrcweir AUTOEXTENSION, //but autoextension is handled differently on MacOSX 81*cdf0e10cSrcweir PASSWORD, 82*cdf0e10cSrcweir FILTEROPTIONS, 83*cdf0e10cSrcweir READONLY, 84*cdf0e10cSrcweir LINK, 85*cdf0e10cSrcweir PREVIEW, 86*cdf0e10cSrcweir SELECTION, 87*cdf0e10cSrcweir TOGGLE_LAST 88*cdf0e10cSrcweir }; 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir enum ListType { 91*cdf0e10cSrcweir VERSION, 92*cdf0e10cSrcweir TEMPLATE, 93*cdf0e10cSrcweir IMAGE_TEMPLATE, 94*cdf0e10cSrcweir LIST_LAST 95*cdf0e10cSrcweir }; 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 98*cdf0e10cSrcweir // inline functions 99*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 100*cdf0e10cSrcweir inline NSView* getUserPane() { 101*cdf0e10cSrcweir if (m_bIsUserPaneLaidOut == false) { 102*cdf0e10cSrcweir createUserPane(); 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir return m_pUserPane; 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir inline bool getVisibility(ToggleType tToggle) { 108*cdf0e10cSrcweir return m_bToggleVisibility[tToggle]; 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir inline void setFilterControlNeeded(bool bNeeded) { 112*cdf0e10cSrcweir m_bIsFilterControlNeeded = bNeeded; 113*cdf0e10cSrcweir if (bNeeded == true) { 114*cdf0e10cSrcweir m_bUserPaneNeeded = true; 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir inline void setFilterHelper(FilterHelper* pFilterHelper) { 119*cdf0e10cSrcweir m_pFilterHelper = pFilterHelper; 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir inline void setFilePickerDelegate(AquaFilePickerDelegate* pDelegate) { 123*cdf0e10cSrcweir m_pDelegate = pDelegate; 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir inline bool isAutoExtensionEnabled() { 127*cdf0e10cSrcweir return ([((NSButton*) m_pToggles[AUTOEXTENSION]) state] == NSOnState); 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir private: 131*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 132*cdf0e10cSrcweir // private member variables 133*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir /** the native view object */ 136*cdf0e10cSrcweir NSView* m_pUserPane; 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir /** the checkbox controls */ 139*cdf0e10cSrcweir NSControl* m_pToggles[ TOGGLE_LAST ]; 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir /** the visibility flags for the checkboxes */ 142*cdf0e10cSrcweir bool m_bToggleVisibility[TOGGLE_LAST]; 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir /** the special filter control */ 145*cdf0e10cSrcweir NSPopUpButton *m_pFilterControl; 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir /** the popup menu controls (except for the filter control) */ 148*cdf0e10cSrcweir NSControl* m_pListControls[ LIST_LAST ]; 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir /** a map to store a control's label text */ 151*cdf0e10cSrcweir ::std::map<NSControl *, NSString *> m_aMapListLabels; 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir /** a map to store a popup menu's label text field */ 154*cdf0e10cSrcweir ::std::map<NSPopUpButton *, NSTextField *> m_aMapListLabelFields; 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir /** the visibility flags for the popup menus */ 157*cdf0e10cSrcweir bool m_bListVisibility[ LIST_LAST ]; 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir /** indicates if a user pane is needed */ 160*cdf0e10cSrcweir bool m_bUserPaneNeeded; 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir /** indicates if the user pane was laid out already */ 163*cdf0e10cSrcweir bool m_bIsUserPaneLaidOut; 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir /** indicates if a filter control is needed */ 166*cdf0e10cSrcweir bool m_bIsFilterControlNeeded; 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir /** a list with all actively used controls */ 169*cdf0e10cSrcweir ::std::list<NSControl*> m_aActiveControls; 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir /** the filter helper */ 172*cdf0e10cSrcweir FilterHelper *m_pFilterHelper; 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir /** the save or open panel's delegate */ 175*cdf0e10cSrcweir AquaFilePickerDelegate *m_pDelegate; 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 178*cdf0e10cSrcweir // private methods 179*cdf0e10cSrcweir //------------------------------------------------------------------------------------ 180*cdf0e10cSrcweir void HandleSetListValue(const NSControl* pControl, const sal_Int16 nControlAction, const uno::Any& rValue); 181*cdf0e10cSrcweir uno::Any HandleGetListValue(const NSControl* pControl, const sal_Int16 nControlAction) const; 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir void createControls(); 184*cdf0e10cSrcweir void createFilterControl(); 185*cdf0e10cSrcweir void createUserPane(); 186*cdf0e10cSrcweir NSTextField* createLabelWithString(const NSString* label); 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir int getControlElementName(const Class clazz, const int nControlId) const; 189*cdf0e10cSrcweir NSControl* getControl( const sal_Int16 nControlId ) const; 190*cdf0e10cSrcweir static int getVerticalDistance(const NSControl* first, const NSControl* second); 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir void layoutControls(); 193*cdf0e10cSrcweir }; 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir #endif //_CONTROLHELPER_HXX_ 196