1*ff0525f2SOliver-Rainer Wittmann /************************************************************** 2*ff0525f2SOliver-Rainer Wittmann * 3*ff0525f2SOliver-Rainer Wittmann * Licensed to the Apache Software Foundation (ASF) under one 4*ff0525f2SOliver-Rainer Wittmann * or more contributor license agreements. See the NOTICE file 5*ff0525f2SOliver-Rainer Wittmann * distributed with this work for additional information 6*ff0525f2SOliver-Rainer Wittmann * regarding copyright ownership. The ASF licenses this file 7*ff0525f2SOliver-Rainer Wittmann * to you under the Apache License, Version 2.0 (the 8*ff0525f2SOliver-Rainer Wittmann * "License"); you may not use this file except in compliance 9*ff0525f2SOliver-Rainer Wittmann * with the License. You may obtain a copy of the License at 10*ff0525f2SOliver-Rainer Wittmann * 11*ff0525f2SOliver-Rainer Wittmann * http://www.apache.org/licenses/LICENSE-2.0 12*ff0525f2SOliver-Rainer Wittmann * 13*ff0525f2SOliver-Rainer Wittmann * Unless required by applicable law or agreed to in writing, 14*ff0525f2SOliver-Rainer Wittmann * software distributed under the License is distributed on an 15*ff0525f2SOliver-Rainer Wittmann * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ff0525f2SOliver-Rainer Wittmann * KIND, either express or implied. See the License for the 17*ff0525f2SOliver-Rainer Wittmann * specific language governing permissions and limitations 18*ff0525f2SOliver-Rainer Wittmann * under the License. 19*ff0525f2SOliver-Rainer Wittmann * 20*ff0525f2SOliver-Rainer Wittmann *************************************************************/ 21*ff0525f2SOliver-Rainer Wittmann 22*ff0525f2SOliver-Rainer Wittmann #include "precompiled_sw.hxx" 23*ff0525f2SOliver-Rainer Wittmann 24*ff0525f2SOliver-Rainer Wittmann #include "PageOrientationControl.hxx" 25*ff0525f2SOliver-Rainer Wittmann #include "PagePropertyPanel.hxx" 26*ff0525f2SOliver-Rainer Wittmann #include "PagePropertyPanel.hrc" 27*ff0525f2SOliver-Rainer Wittmann 28*ff0525f2SOliver-Rainer Wittmann #include <swtypes.hxx> 29*ff0525f2SOliver-Rainer Wittmann 30*ff0525f2SOliver-Rainer Wittmann #include <svx/sidebar/ValueSetWithTextControl.hxx> 31*ff0525f2SOliver-Rainer Wittmann 32*ff0525f2SOliver-Rainer Wittmann namespace sw { namespace sidebar { 33*ff0525f2SOliver-Rainer Wittmann 34*ff0525f2SOliver-Rainer Wittmann PageOrientationControl::PageOrientationControl( 35*ff0525f2SOliver-Rainer Wittmann Window* pParent, 36*ff0525f2SOliver-Rainer Wittmann PagePropertyPanel& rPanel, 37*ff0525f2SOliver-Rainer Wittmann const sal_Bool bLandscape ) 38*ff0525f2SOliver-Rainer Wittmann : ::svx::sidebar::PopupControl( pParent, SW_RES(RID_POPUP_SWPAGE_ORIENTATION) ) 39*ff0525f2SOliver-Rainer Wittmann , mpOrientationValueSet( new ::svx::sidebar::ValueSetWithTextControl( ::svx::sidebar::ValueSetWithTextControl::IMAGE_TEXT, this, SW_RES(VS_ORIENTATION) ) ) 40*ff0525f2SOliver-Rainer Wittmann , mbLandscape( bLandscape ) 41*ff0525f2SOliver-Rainer Wittmann , mrPagePropPanel(rPanel) 42*ff0525f2SOliver-Rainer Wittmann { 43*ff0525f2SOliver-Rainer Wittmann mpOrientationValueSet->SetStyle( mpOrientationValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT ); 44*ff0525f2SOliver-Rainer Wittmann mpOrientationValueSet->SetColor(GetSettings().GetStyleSettings().GetMenuColor()); 45*ff0525f2SOliver-Rainer Wittmann 46*ff0525f2SOliver-Rainer Wittmann // initialize <ValueSetWithText> control 47*ff0525f2SOliver-Rainer Wittmann { 48*ff0525f2SOliver-Rainer Wittmann mpOrientationValueSet->AddItem( SW_RES(IMG_PORTRAIT), 0, SW_RES(STR_PORTRAIT), 0 ); 49*ff0525f2SOliver-Rainer Wittmann mpOrientationValueSet->AddItem( SW_RES(IMG_LANDSCAPE), 0, SW_RES(STR_LANDSCAPE), 0 ); 50*ff0525f2SOliver-Rainer Wittmann } 51*ff0525f2SOliver-Rainer Wittmann 52*ff0525f2SOliver-Rainer Wittmann Link aLink = LINK(this, PageOrientationControl,ImplOrientationHdl ); 53*ff0525f2SOliver-Rainer Wittmann mpOrientationValueSet->SetSelectHdl(aLink); 54*ff0525f2SOliver-Rainer Wittmann mpOrientationValueSet->SetNoSelection(); 55*ff0525f2SOliver-Rainer Wittmann mpOrientationValueSet->StartSelection(); 56*ff0525f2SOliver-Rainer Wittmann mpOrientationValueSet->Show(); 57*ff0525f2SOliver-Rainer Wittmann mpOrientationValueSet->SelectItem( (mbLandscape == sal_True) ? 2 : 1 ); 58*ff0525f2SOliver-Rainer Wittmann mpOrientationValueSet->GrabFocus(); 59*ff0525f2SOliver-Rainer Wittmann mpOrientationValueSet->Format(); 60*ff0525f2SOliver-Rainer Wittmann mpOrientationValueSet->StartSelection(); 61*ff0525f2SOliver-Rainer Wittmann 62*ff0525f2SOliver-Rainer Wittmann FreeResource(); 63*ff0525f2SOliver-Rainer Wittmann } 64*ff0525f2SOliver-Rainer Wittmann 65*ff0525f2SOliver-Rainer Wittmann 66*ff0525f2SOliver-Rainer Wittmann PageOrientationControl::~PageOrientationControl(void) 67*ff0525f2SOliver-Rainer Wittmann { 68*ff0525f2SOliver-Rainer Wittmann delete mpOrientationValueSet; 69*ff0525f2SOliver-Rainer Wittmann } 70*ff0525f2SOliver-Rainer Wittmann 71*ff0525f2SOliver-Rainer Wittmann 72*ff0525f2SOliver-Rainer Wittmann IMPL_LINK(PageOrientationControl, ImplOrientationHdl, void *, pControl) 73*ff0525f2SOliver-Rainer Wittmann { 74*ff0525f2SOliver-Rainer Wittmann mpOrientationValueSet->SetNoSelection(); 75*ff0525f2SOliver-Rainer Wittmann if ( pControl == mpOrientationValueSet ) 76*ff0525f2SOliver-Rainer Wittmann { 77*ff0525f2SOliver-Rainer Wittmann const sal_uInt32 iPos = mpOrientationValueSet->GetSelectItemId(); 78*ff0525f2SOliver-Rainer Wittmann const bool bChanged = ( ( iPos == 1 ) && mbLandscape ) || 79*ff0525f2SOliver-Rainer Wittmann ( ( iPos == 2 ) && !mbLandscape ); 80*ff0525f2SOliver-Rainer Wittmann if ( bChanged ) 81*ff0525f2SOliver-Rainer Wittmann { 82*ff0525f2SOliver-Rainer Wittmann mbLandscape = !mbLandscape; 83*ff0525f2SOliver-Rainer Wittmann mrPagePropPanel.ExecuteOrientationChange( mbLandscape ); 84*ff0525f2SOliver-Rainer Wittmann } 85*ff0525f2SOliver-Rainer Wittmann } 86*ff0525f2SOliver-Rainer Wittmann 87*ff0525f2SOliver-Rainer Wittmann mrPagePropPanel.ClosePageOrientationPopup(); 88*ff0525f2SOliver-Rainer Wittmann return 0; 89*ff0525f2SOliver-Rainer Wittmann } 90*ff0525f2SOliver-Rainer Wittmann 91*ff0525f2SOliver-Rainer Wittmann 92*ff0525f2SOliver-Rainer Wittmann } } // end of namespace sw::sidebar 93*ff0525f2SOliver-Rainer Wittmann 94