1*38d50f7bSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*38d50f7bSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*38d50f7bSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*38d50f7bSAndrew Rist * distributed with this work for additional information 6*38d50f7bSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*38d50f7bSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*38d50f7bSAndrew Rist * "License"); you may not use this file except in compliance 9*38d50f7bSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*38d50f7bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*38d50f7bSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*38d50f7bSAndrew Rist * software distributed under the License is distributed on an 15*38d50f7bSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*38d50f7bSAndrew Rist * KIND, either express or implied. See the License for the 17*38d50f7bSAndrew Rist * specific language governing permissions and limitations 18*38d50f7bSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*38d50f7bSAndrew Rist *************************************************************/ 21*38d50f7bSAndrew Rist 22*38d50f7bSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // ============================================================================ 25cdf0e10cSrcweir 26cdf0e10cSrcweir #ifndef _SC_CSVTABLEBOX_HXX 27cdf0e10cSrcweir #define _SC_CSVTABLEBOX_HXX 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <vcl/ctrl.hxx> 30cdf0e10cSrcweir #include <vcl/scrbar.hxx> 31cdf0e10cSrcweir #include "scdllapi.h" 32cdf0e10cSrcweir #include "csvcontrol.hxx" 33cdf0e10cSrcweir #include "csvruler.hxx" 34cdf0e10cSrcweir #include "csvgrid.hxx" 35cdf0e10cSrcweir 36cdf0e10cSrcweir 37cdf0e10cSrcweir class ListBox; 38cdf0e10cSrcweir class ScAsciiOptions; 39cdf0e10cSrcweir 40cdf0e10cSrcweir 41cdf0e10cSrcweir /* ============================================================================ 42cdf0e10cSrcweir Position: Positions between the characters (the dots in the ruler). 43cdf0e10cSrcweir Character: The characters (the range from one position to the next). 44cdf0e10cSrcweir Split: Positions which contain a split to divide characters into groups (columns). 45cdf0e10cSrcweir Column: The range between two splits. 46cdf0e10cSrcweir ============================================================================ */ 47cdf0e10cSrcweir 48cdf0e10cSrcweir /** The control in the CSV import dialog that contains a ruler and a data grid 49cdf0e10cSrcweir to visualize and modify the current import settings. */ 50cdf0e10cSrcweir class SC_DLLPUBLIC ScCsvTableBox : public ScCsvControl 51cdf0e10cSrcweir { 52cdf0e10cSrcweir private: 53cdf0e10cSrcweir ScCsvLayoutData maData; /// Current layout data of the controls. 54cdf0e10cSrcweir 55cdf0e10cSrcweir ScCsvRuler maRuler; /// The ruler for fixed width mode. 56cdf0e10cSrcweir ScCsvGrid maGrid; /// Calc-like data table for fixed width mode. 57cdf0e10cSrcweir ScrollBar maHScroll; /// Horizontal scroll bar. 58cdf0e10cSrcweir ScrollBar maVScroll; /// Vertical scroll bar. 59cdf0e10cSrcweir ScrollBarBox maScrollBox; /// For the bottom right edge. 60cdf0e10cSrcweir 61cdf0e10cSrcweir Link maUpdateTextHdl; /// Updates all cell texts. 62cdf0e10cSrcweir Link maColTypeHdl; /// Handler for exporting the column type. 63cdf0e10cSrcweir 64cdf0e10cSrcweir ScCsvColStateVec maFixColStates; /// Column states in fixed width mode. 65cdf0e10cSrcweir ScCsvColStateVec maSepColStates; /// Column states in separators mode. 66cdf0e10cSrcweir 67cdf0e10cSrcweir sal_Int32 mnFixedWidth; /// Cached total width for fixed width mode. 68cdf0e10cSrcweir 69cdf0e10cSrcweir bool mbFixedMode; /// false = Separators, true = Fixed width. 70cdf0e10cSrcweir 71cdf0e10cSrcweir // ------------------------------------------------------------------------ 72cdf0e10cSrcweir public: 73cdf0e10cSrcweir //UNUSED2009-05 explicit ScCsvTableBox( Window* pParent ); 74cdf0e10cSrcweir explicit ScCsvTableBox( Window* pParent, const ResId& rResId ); 75cdf0e10cSrcweir 76cdf0e10cSrcweir // common table box handling ---------------------------------------------- 77cdf0e10cSrcweir public: 78cdf0e10cSrcweir /** Sets the control to separators mode. */ 79cdf0e10cSrcweir void SetSeparatorsMode(); 80cdf0e10cSrcweir /** Sets the control to fixed width mode. */ 81cdf0e10cSrcweir void SetFixedWidthMode(); 82cdf0e10cSrcweir 83cdf0e10cSrcweir private: 84cdf0e10cSrcweir /** Initialisation on construction. */ 85cdf0e10cSrcweir SC_DLLPRIVATE void Init(); 86cdf0e10cSrcweir /** Initializes the children controls (pos/size, scroll bars, ...). */ 87cdf0e10cSrcweir SC_DLLPRIVATE void InitControls(); 88cdf0e10cSrcweir /** Initializes size and position data of horizontal scrollbar. */ 89cdf0e10cSrcweir SC_DLLPRIVATE void InitHScrollBar(); 90cdf0e10cSrcweir /** Initializes size and position data of vertical scrollbar. */ 91cdf0e10cSrcweir SC_DLLPRIVATE void InitVScrollBar(); 92cdf0e10cSrcweir 93cdf0e10cSrcweir /** Calculates and sets valid position offset nearest to nPos. */ ImplSetPosOffset(sal_Int32 nPos)94cdf0e10cSrcweir SC_DLLPRIVATE inline void ImplSetPosOffset( sal_Int32 nPos ) 95cdf0e10cSrcweir { maData.mnPosOffset = Max( Min( nPos, GetMaxPosOffset() ), sal_Int32( 0 ) ); } 96cdf0e10cSrcweir /** Calculates and sets valid line offset nearest to nLine. */ ImplSetLineOffset(sal_Int32 nLine)97cdf0e10cSrcweir SC_DLLPRIVATE inline void ImplSetLineOffset( sal_Int32 nLine ) 98cdf0e10cSrcweir { maData.mnLineOffset = Max( Min( nLine, GetMaxLineOffset() ), sal_Int32( 0 ) ); } 99cdf0e10cSrcweir /** Moves controls (not cursors!) so that nPos becomes visible. */ 100cdf0e10cSrcweir SC_DLLPRIVATE void MakePosVisible( sal_Int32 nPos ); 101cdf0e10cSrcweir 102cdf0e10cSrcweir // cell contents ---------------------------------------------------------- 103cdf0e10cSrcweir public: 104cdf0e10cSrcweir /** Fills all cells of all lines with the passed texts (Unicode strings). */ 105cdf0e10cSrcweir void SetUniStrings( 106cdf0e10cSrcweir const String* pTextLines, const String& rSepChars, 107cdf0e10cSrcweir sal_Unicode cTextSep, bool bMergeSep ); 108cdf0e10cSrcweir //UNUSED2009-05 /** Fills all cells of all lines with the passed texts (ByteStrings). */ 109cdf0e10cSrcweir //UNUSED2009-05 void SetByteStrings( 110cdf0e10cSrcweir //UNUSED2009-05 const ByteString* pLineTexts, CharSet eCharSet, 111cdf0e10cSrcweir //UNUSED2009-05 const String& rSepChars, sal_Unicode cTextSep, bool bMergeSep ); 112cdf0e10cSrcweir 113cdf0e10cSrcweir // column settings -------------------------------------------------------- 114cdf0e10cSrcweir public: 115cdf0e10cSrcweir /** Reads UI strings for data types from the list box. */ 116cdf0e10cSrcweir void InitTypes( const ListBox& rListBox ); 117cdf0e10cSrcweir /** Returns the data type of the selected columns. */ GetSelColumnType() const118cdf0e10cSrcweir inline sal_Int32 GetSelColumnType() const { return maGrid.GetSelColumnType(); } 119cdf0e10cSrcweir 120cdf0e10cSrcweir /** Fills the options object with current column data. */ 121cdf0e10cSrcweir void FillColumnData( ScAsciiOptions& rOptions ) const; 122cdf0e10cSrcweir 123cdf0e10cSrcweir // event handling --------------------------------------------------------- 124cdf0e10cSrcweir public: 125cdf0e10cSrcweir /** Sets a new handler for "update cell texts" requests. */ SetUpdateTextHdl(const Link & rHdl)126cdf0e10cSrcweir inline void SetUpdateTextHdl( const Link& rHdl ) { maUpdateTextHdl = rHdl; } 127cdf0e10cSrcweir /** Returns the handler for "update cell texts" requests. */ GetUpdateTextHdl() const128cdf0e10cSrcweir inline const Link& GetUpdateTextHdl() const { return maUpdateTextHdl; } 129cdf0e10cSrcweir /** Sets a new handler for "column selection changed" events. */ SetColTypeHdl(const Link & rHdl)130cdf0e10cSrcweir inline void SetColTypeHdl( const Link& rHdl ) { maColTypeHdl = rHdl; } 131cdf0e10cSrcweir /** Returns the handler for "column selection changed" events. */ GetColTypeHdl() const132cdf0e10cSrcweir inline const Link& GetColTypeHdl() const { return maColTypeHdl; } 133cdf0e10cSrcweir 134cdf0e10cSrcweir protected: 135cdf0e10cSrcweir virtual void Resize(); 136cdf0e10cSrcweir virtual void DataChanged( const DataChangedEvent& rDCEvt ); 137cdf0e10cSrcweir 138cdf0e10cSrcweir private: 139cdf0e10cSrcweir SC_DLLPRIVATE DECL_LINK( CsvCmdHdl, ScCsvControl* ); 140cdf0e10cSrcweir SC_DLLPRIVATE DECL_LINK( ScrollHdl, ScrollBar* ); 141cdf0e10cSrcweir SC_DLLPRIVATE DECL_LINK( ScrollEndHdl, ScrollBar* ); 142cdf0e10cSrcweir 143cdf0e10cSrcweir // accessibility ---------------------------------------------------------- 144cdf0e10cSrcweir public: 145cdf0e10cSrcweir /** Creates and returns the accessible object of this control. */ 146cdf0e10cSrcweir virtual XAccessibleRef CreateAccessible(); 147cdf0e10cSrcweir 148cdf0e10cSrcweir protected: 149cdf0e10cSrcweir /** Creates a new accessible object. */ 150cdf0e10cSrcweir virtual ScAccessibleCsvControl* ImplCreateAccessible(); 151cdf0e10cSrcweir }; 152cdf0e10cSrcweir 153cdf0e10cSrcweir 154cdf0e10cSrcweir // ============================================================================ 155cdf0e10cSrcweir 156cdf0e10cSrcweir #endif 157cdf0e10cSrcweir 158