xref: /trunk/main/sc/source/core/data/scdpoutputimpl.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1*d0626817SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*d0626817SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*d0626817SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*d0626817SAndrew Rist  * distributed with this work for additional information
6*d0626817SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*d0626817SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*d0626817SAndrew Rist  * "License"); you may not use this file except in compliance
9*d0626817SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*d0626817SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*d0626817SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*d0626817SAndrew Rist  * software distributed under the License is distributed on an
15*d0626817SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d0626817SAndrew Rist  * KIND, either express or implied.  See the License for the
17*d0626817SAndrew Rist  * specific language governing permissions and limitations
18*d0626817SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*d0626817SAndrew Rist  *************************************************************/
21*d0626817SAndrew Rist 
22*d0626817SAndrew Rist 
23cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
24cdf0e10cSrcweir #include "precompiled_sc.hxx"
25cdf0e10cSrcweir 
26cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
27cdf0e10cSrcweir #include "scdpoutputimpl.hxx"
28cdf0e10cSrcweir #include "scitems.hxx"
29cdf0e10cSrcweir #include <editeng/boxitem.hxx>
30cdf0e10cSrcweir // -----------------------------------------------------------------------
31cdf0e10cSrcweir 
32cdf0e10cSrcweir namespace
33cdf0e10cSrcweir {
lcl_compareColfuc(SCCOL i,SCCOL j)34cdf0e10cSrcweir     bool lcl_compareColfuc ( SCCOL i,  SCCOL j) { return (i<j); }
lcl_compareRowfuc(SCROW i,SCROW j)35cdf0e10cSrcweir     bool lcl_compareRowfuc ( SCROW i,  SCROW j) { return (i<j); }
36cdf0e10cSrcweir }
37cdf0e10cSrcweir 
38cdf0e10cSrcweir 
OutputDataArea()39cdf0e10cSrcweir void OutputImpl::OutputDataArea()
40cdf0e10cSrcweir {
41cdf0e10cSrcweir     AddRow( mnDataStartRow );
42cdf0e10cSrcweir     AddCol( mnDataStartCol );
43cdf0e10cSrcweir 
44cdf0e10cSrcweir     mnCols.push_back( mnTabEndCol+1); //set last row bottom
45cdf0e10cSrcweir     mnRows.push_back( mnTabEndRow+1); //set last col bottom
46cdf0e10cSrcweir 
47cdf0e10cSrcweir     sal_Bool bAllRows = ( ( mnTabEndRow - mnDataStartRow + 2 ) == (SCROW) mnRows.size() );
48cdf0e10cSrcweir 
49cdf0e10cSrcweir     std::sort( mnCols.begin(), mnCols.end(), lcl_compareColfuc );
50cdf0e10cSrcweir     std::sort( mnRows.begin(), mnRows.end(), lcl_compareRowfuc );
51cdf0e10cSrcweir 
52cdf0e10cSrcweir     for( SCCOL nCol = 0; nCol < (SCCOL)mnCols.size()-1; nCol ++ )
53cdf0e10cSrcweir     {
54cdf0e10cSrcweir         if ( !bAllRows )
55cdf0e10cSrcweir         {
56cdf0e10cSrcweir             if ( nCol < (SCCOL)mnCols.size()-2)
57cdf0e10cSrcweir             {
58cdf0e10cSrcweir                 for ( SCROW i = nCol%2; i < (SCROW)mnRows.size()-2; i +=2 )
59cdf0e10cSrcweir                     OutputBlockFrame( mnCols[nCol], mnRows[i], mnCols[nCol+1]-1, mnRows[i+1]-1 );
60cdf0e10cSrcweir                 if ( mnRows.size()>=2 )
61cdf0e10cSrcweir                     OutputBlockFrame(  mnCols[nCol], mnRows[mnRows.size()-2], mnCols[nCol+1]-1, mnRows[mnRows.size()-1]-1 );
62cdf0e10cSrcweir             }
63cdf0e10cSrcweir             else
64cdf0e10cSrcweir             {
65cdf0e10cSrcweir                 for ( SCROW i = 0 ; i < (SCROW)mnRows.size()-1; i++ )
66cdf0e10cSrcweir                     OutputBlockFrame(  mnCols[nCol], mnRows[i], mnCols[nCol+1]-1,  mnRows[i+1]-1 );
67cdf0e10cSrcweir             }
68cdf0e10cSrcweir         }
69cdf0e10cSrcweir         else
70cdf0e10cSrcweir             OutputBlockFrame( mnCols[nCol], mnRows.front(), mnCols[nCol+1]-1, mnRows.back()-1, bAllRows );
71cdf0e10cSrcweir     }
72cdf0e10cSrcweir     //out put rows area outer framer
73cdf0e10cSrcweir     if ( mnTabStartCol != mnDataStartCol )
74cdf0e10cSrcweir     {
75cdf0e10cSrcweir         if ( mnTabStartRow != mnDataStartRow )
76cdf0e10cSrcweir             OutputBlockFrame( mnTabStartCol, mnTabStartRow, mnDataStartCol-1, mnDataStartRow-1 );
77cdf0e10cSrcweir         OutputBlockFrame( mnTabStartCol, mnDataStartRow, mnDataStartCol-1, mnTabEndRow );
78cdf0e10cSrcweir     }
79cdf0e10cSrcweir     //out put cols area outer framer
80cdf0e10cSrcweir     OutputBlockFrame( mnDataStartCol, mnTabStartRow, mnTabEndCol, mnDataStartRow-1 );
81cdf0e10cSrcweir }
82cdf0e10cSrcweir 
OutputImpl(ScDocument * pDoc,sal_uInt16 nTab,SCCOL nTabStartCol,SCROW nTabStartRow,SCCOL nMemberStartCol,SCROW nMemberStartRow,SCCOL nDataStartCol,SCROW nDataStartRow,SCCOL nTabEndCol,SCROW nTabEndRow)83cdf0e10cSrcweir OutputImpl::OutputImpl( ScDocument* pDoc, sal_uInt16 nTab,
84cdf0e10cSrcweir         SCCOL   nTabStartCol,
85cdf0e10cSrcweir         SCROW   nTabStartRow,
86cdf0e10cSrcweir         SCCOL   nMemberStartCol,
87cdf0e10cSrcweir         SCROW   nMemberStartRow,
88cdf0e10cSrcweir         SCCOL nDataStartCol,
89cdf0e10cSrcweir         SCROW nDataStartRow,
90cdf0e10cSrcweir         SCCOL nTabEndCol,
91cdf0e10cSrcweir         SCROW nTabEndRow ):
92cdf0e10cSrcweir     mpDoc( pDoc ),
93cdf0e10cSrcweir     mnTab( nTab ),
94cdf0e10cSrcweir     mnTabStartCol( nTabStartCol ),
95cdf0e10cSrcweir     mnTabStartRow( nTabStartRow ),
96cdf0e10cSrcweir     mnMemberStartCol( nMemberStartCol),
97cdf0e10cSrcweir     mnMemberStartRow( nMemberStartRow),
98cdf0e10cSrcweir     mnDataStartCol ( nDataStartCol ),
99cdf0e10cSrcweir     mnDataStartRow ( nDataStartRow ),
100cdf0e10cSrcweir     mnTabEndCol(  nTabEndCol ),
101cdf0e10cSrcweir     mnTabEndRow(  nTabEndRow )
102cdf0e10cSrcweir {
103cdf0e10cSrcweir     mbNeedLineCols.resize( nTabEndCol-nDataStartCol+1, false );
104cdf0e10cSrcweir     mbNeedLineRows.resize( nTabEndRow-nDataStartRow+1, false );
105cdf0e10cSrcweir 
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
AddRow(SCROW nRow)108cdf0e10cSrcweir sal_Bool OutputImpl::AddRow( SCROW nRow )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir     if ( !mbNeedLineRows[ nRow - mnDataStartRow ] )
111cdf0e10cSrcweir     {
112cdf0e10cSrcweir         mbNeedLineRows[ nRow - mnDataStartRow ] = true;
113cdf0e10cSrcweir         mnRows.push_back( nRow );
114cdf0e10cSrcweir         return sal_True;
115cdf0e10cSrcweir     }
116cdf0e10cSrcweir     else
117cdf0e10cSrcweir         return sal_False;
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
AddCol(SCCOL nCol)120cdf0e10cSrcweir sal_Bool OutputImpl::AddCol( SCCOL nCol )
121cdf0e10cSrcweir {
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     if ( !mbNeedLineCols[ nCol - mnDataStartCol ] )
124cdf0e10cSrcweir     {
125cdf0e10cSrcweir         mbNeedLineCols[ nCol - mnDataStartCol ] = true;
126cdf0e10cSrcweir         mnCols.push_back( nCol );
127cdf0e10cSrcweir         return sal_True;
128cdf0e10cSrcweir     }
129cdf0e10cSrcweir     else
130cdf0e10cSrcweir         return sal_False;
131cdf0e10cSrcweir }
132cdf0e10cSrcweir 
OutputBlockFrame(SCCOL nStartCol,SCROW nStartRow,SCCOL nEndCol,SCROW nEndRow,sal_Bool bHori)133cdf0e10cSrcweir void OutputImpl::OutputBlockFrame ( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, sal_Bool bHori )
134cdf0e10cSrcweir {
135cdf0e10cSrcweir 
136cdf0e10cSrcweir     SvxBorderLine aLine, aOutLine;
137cdf0e10cSrcweir     aLine.SetColor( SC_DP_FRAME_COLOR );
138cdf0e10cSrcweir     aLine.SetOutWidth( SC_DP_FRAME_INNER_BOLD );
139cdf0e10cSrcweir     aOutLine.SetColor( SC_DP_FRAME_COLOR );
140cdf0e10cSrcweir     aOutLine.SetOutWidth( SC_DP_FRAME_OUTER_BOLD );
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     SvxBoxItem aBox( ATTR_BORDER );
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     if ( nStartCol == mnTabStartCol )
145cdf0e10cSrcweir         aBox.SetLine(&aOutLine, BOX_LINE_LEFT);
146cdf0e10cSrcweir     else
147cdf0e10cSrcweir         aBox.SetLine(&aLine, BOX_LINE_LEFT);
148cdf0e10cSrcweir 
149cdf0e10cSrcweir     if ( nStartRow == mnTabStartRow )
150cdf0e10cSrcweir         aBox.SetLine(&aOutLine, BOX_LINE_TOP);
151cdf0e10cSrcweir     else
152cdf0e10cSrcweir         aBox.SetLine(&aLine, BOX_LINE_TOP);
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     if ( nEndCol == mnTabEndCol ) //bottom row
155cdf0e10cSrcweir         aBox.SetLine(&aOutLine, BOX_LINE_RIGHT);
156cdf0e10cSrcweir     else
157cdf0e10cSrcweir         aBox.SetLine(&aLine,  BOX_LINE_RIGHT);
158cdf0e10cSrcweir 
159cdf0e10cSrcweir     if ( nEndRow == mnTabEndRow ) //bottom
160cdf0e10cSrcweir         aBox.SetLine(&aOutLine,  BOX_LINE_BOTTOM);
161cdf0e10cSrcweir     else
162cdf0e10cSrcweir         aBox.SetLine(&aLine,  BOX_LINE_BOTTOM);
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 
165cdf0e10cSrcweir     SvxBoxInfoItem aBoxInfo( ATTR_BORDER_INNER );
166cdf0e10cSrcweir     aBoxInfo.SetValid(VALID_VERT,sal_False );
167cdf0e10cSrcweir     if ( bHori )
168cdf0e10cSrcweir     {
169cdf0e10cSrcweir         aBoxInfo.SetValid(VALID_HORI,sal_True);
170cdf0e10cSrcweir         aBoxInfo.SetLine( &aLine, BOXINFO_LINE_HORI );
171cdf0e10cSrcweir     }
172cdf0e10cSrcweir     else
173cdf0e10cSrcweir         aBoxInfo.SetValid(VALID_HORI,sal_False );
174cdf0e10cSrcweir 
175cdf0e10cSrcweir     aBoxInfo.SetValid(VALID_DISTANCE,sal_False);
176cdf0e10cSrcweir 
177cdf0e10cSrcweir     mpDoc->ApplyFrameAreaTab( ScRange(  nStartCol, nStartRow, mnTab, nEndCol, nEndRow , mnTab ), &aBox, &aBoxInfo );
178cdf0e10cSrcweir 
179cdf0e10cSrcweir }
180