Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <rangelst.hxx>
30 : :
31 : : #include <comphelper/string.hxx>
32 : : #include <sfx2/dispatch.hxx>
33 : : #include <svl/stritem.hxx>
34 : : #include <vcl/msgbox.hxx>
35 : : #include <unotools/charclass.hxx>
36 : : #include <stdlib.h>
37 : :
38 : : #define _AREASDLG_CXX
39 : : #include "areasdlg.hxx"
40 : : #undef _AREASDLG_CXX
41 : :
42 : : #include "scresid.hxx"
43 : : #include "rangenam.hxx"
44 : : #include "reffact.hxx"
45 : : #include "tabvwsh.hxx"
46 : : #include "docsh.hxx"
47 : : #include "globstr.hrc"
48 : : #include "pagedlg.hrc"
49 : : #include "compiler.hxx"
50 : : #include "markdata.hxx"
51 : :
52 : : // STATIC DATA ---------------------------------------------------------------
53 : :
54 : : // List box positions for print range (PR)
55 : : const sal_uInt16 SC_AREASDLG_PR_NONE = 0;
56 : : const sal_uInt16 SC_AREASDLG_PR_ENTIRE = 1;
57 : : const sal_uInt16 SC_AREASDLG_PR_USER = 2;
58 : : const sal_uInt16 SC_AREASDLG_PR_SELECT = 3;
59 : : const sal_uInt16 SC_AREASDLG_PR_OFFSET = 4;
60 : :
61 : : // List box positions for repeat ranges (RR)
62 : : const sal_uInt16 SC_AREASDLG_RR_NONE = 0;
63 : : const sal_uInt16 SC_AREASDLG_RR_USER = 1;
64 : : const sal_uInt16 SC_AREASDLG_RR_OFFSET = 2;
65 : :
66 : : //============================================================================
67 : :
68 : : using ::rtl::OUString;
69 : :
70 : : #define HDL(hdl) LINK( this, ScPrintAreasDlg, hdl )
71 : : #define ERRORBOX(nId) ErrorBox( this, WinBits(WB_OK|WB_DEF_OK), \
72 : : ScGlobal::GetRscString( nId ) ).Execute()
73 : : #define SWAP(x1,x2) { int n=x1; x1=x2; x2=n; }
74 : :
75 : : // globale Funktionen (->am Ende der Datei):
76 : :
77 : : bool lcl_CheckRepeatString( const String& rStr, ScDocument* pDoc, bool bIsRow, ScRange* pRange );
78 : : void lcl_GetRepeatRangeString( const ScRange* pRange, ScDocument* pDoc, bool bIsRow, String& rStr );
79 : 0 : void lcl_GetRepeatRangeString( const ScRange* pRange, ScDocument* pDoc, bool bIsRow, OUString& rStr )
80 : : {
81 [ # # ]: 0 : String aStr;
82 [ # # ]: 0 : lcl_GetRepeatRangeString(pRange, pDoc, bIsRow, aStr);
83 [ # # ][ # # ]: 0 : rStr = aStr;
84 : 0 : }
85 : :
86 : : #if 0
87 : : // this method is useful when debugging address flags.
88 : : static void printAddressFlags(sal_uInt16 nFlag)
89 : : {
90 : : if ((nFlag & SCA_COL_ABSOLUTE ) == SCA_COL_ABSOLUTE ) printf("SCA_COL_ABSOLUTE \n");
91 : : if ((nFlag & SCA_ROW_ABSOLUTE ) == SCA_ROW_ABSOLUTE ) printf("SCA_ROW_ABSOLUTE \n");
92 : : if ((nFlag & SCA_TAB_ABSOLUTE ) == SCA_TAB_ABSOLUTE ) printf("SCA_TAB_ABSOLUTE \n");
93 : : if ((nFlag & SCA_TAB_3D ) == SCA_TAB_3D ) printf("SCA_TAB_3D \n");
94 : : if ((nFlag & SCA_COL2_ABSOLUTE ) == SCA_COL2_ABSOLUTE ) printf("SCA_COL2_ABSOLUTE\n");
95 : : if ((nFlag & SCA_ROW2_ABSOLUTE ) == SCA_ROW2_ABSOLUTE ) printf("SCA_ROW2_ABSOLUTE\n");
96 : : if ((nFlag & SCA_TAB2_ABSOLUTE ) == SCA_TAB2_ABSOLUTE ) printf("SCA_TAB2_ABSOLUTE\n");
97 : : if ((nFlag & SCA_TAB2_3D ) == SCA_TAB2_3D ) printf("SCA_TAB2_3D \n");
98 : : if ((nFlag & SCA_VALID_ROW ) == SCA_VALID_ROW ) printf("SCA_VALID_ROW \n");
99 : : if ((nFlag & SCA_VALID_COL ) == SCA_VALID_COL ) printf("SCA_VALID_COL \n");
100 : : if ((nFlag & SCA_VALID_TAB ) == SCA_VALID_TAB ) printf("SCA_VALID_TAB \n");
101 : : if ((nFlag & SCA_FORCE_DOC ) == SCA_FORCE_DOC ) printf("SCA_FORCE_DOC \n");
102 : : if ((nFlag & SCA_VALID_ROW2 ) == SCA_VALID_ROW2 ) printf("SCA_VALID_ROW2 \n");
103 : : if ((nFlag & SCA_VALID_COL2 ) == SCA_VALID_COL2 ) printf("SCA_VALID_COL2 \n");
104 : : if ((nFlag & SCA_VALID_TAB2 ) == SCA_VALID_TAB2 ) printf("SCA_VALID_TAB2 \n");
105 : : if ((nFlag & SCA_VALID ) == SCA_VALID ) printf("SCA_VALID \n");
106 : : if ((nFlag & SCA_ABS ) == SCA_ABS ) printf("SCA_ABS \n");
107 : : if ((nFlag & SCR_ABS ) == SCR_ABS ) printf("SCR_ABS \n");
108 : : if ((nFlag & SCA_ABS_3D ) == SCA_ABS_3D ) printf("SCA_ABS_3D \n");
109 : : if ((nFlag & SCR_ABS_3D ) == SCR_ABS_3D ) printf("SCR_ABS_3D \n");
110 : : }
111 : : #endif
112 : :
113 : : //============================================================================
114 : : // class ScPrintAreasDlg
115 : :
116 : : //----------------------------------------------------------------------------
117 : :
118 : 0 : ScPrintAreasDlg::ScPrintAreasDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent )
119 : : : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_AREAS),
120 : : //
121 : : aFlPrintArea ( this, ScResId( FL_PRINTAREA ) ),
122 : : aLbPrintArea ( this, ScResId( LB_PRINTAREA ) ),
123 : : aEdPrintArea ( this, this, ScResId( ED_PRINTAREA ) ),
124 : : aRbPrintArea ( this, ScResId( RB_PRINTAREA ), &aEdPrintArea, this ),
125 : : //
126 : : aFlRepeatRow ( this, ScResId( FL_REPEATROW ) ),
127 : : aLbRepeatRow ( this, ScResId( LB_REPEATROW ) ),
128 : : aEdRepeatRow ( this, this, ScResId( ED_REPEATROW ) ),
129 : : aRbRepeatRow ( this, ScResId( RB_REPEATROW ), &aEdRepeatRow, this ),
130 : : //
131 : : aFlRepeatCol ( this, ScResId( FL_REPEATCOL ) ),
132 : : aLbRepeatCol ( this, ScResId( LB_REPEATCOL ) ),
133 : : aEdRepeatCol ( this, this, ScResId( ED_REPEATCOL ) ),
134 : : aRbRepeatCol ( this, ScResId( RB_REPEATCOL ), &aEdRepeatCol, this ),
135 : : //
136 : : aBtnOk ( this, ScResId( BTN_OK ) ),
137 : : aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
138 : : aBtnHelp ( this, ScResId( BTN_HELP ) ),
139 : : //
140 : : bDlgLostFocus ( false ),
141 : : pRefInputEdit ( &aEdPrintArea ),
142 : : pDoc ( NULL ),
143 : : pViewData ( NULL ),
144 [ # # ][ # # ]: 0 : nCurTab ( 0 )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
145 : : {
146 [ # # ][ # # ]: 0 : ScTabViewShell* pScViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
147 [ # # ][ # # ]: 0 : ScDocShell* pScDocSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
148 : :
149 : : OSL_ENSURE( pScDocSh, "Current DocumentShell not found :-(" );
150 : :
151 : 0 : pDoc = pScDocSh->GetDocument();
152 : :
153 [ # # ]: 0 : if ( pScViewSh )
154 : : {
155 : 0 : pViewData = pScViewSh->GetViewData();
156 : 0 : nCurTab = pViewData->GetTabNo();
157 : : }
158 : :
159 [ # # ]: 0 : Impl_Reset();
160 : :
161 : : //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
162 : : //SFX_APPWINDOW->Enable();
163 : :
164 [ # # ]: 0 : FreeResource();
165 : 0 : }
166 : :
167 : :
168 : : //----------------------------------------------------------------------------
169 : :
170 [ # # ][ # # ]: 0 : ScPrintAreasDlg::~ScPrintAreasDlg()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
171 : : {
172 : : // Extra-Data an ListBox-Entries abraeumen
173 : 0 : ListBox* pLb[3] = { &aLbPrintArea, &aLbRepeatRow, &aLbRepeatCol };
174 : :
175 [ # # ]: 0 : for ( sal_uInt16 i=0; i<3; i++ )
176 : : {
177 [ # # ]: 0 : sal_uInt16 nCount = pLb[i]->GetEntryCount();
178 [ # # ]: 0 : for ( sal_uInt16 j=0; j<nCount; j++ )
179 [ # # ][ # # ]: 0 : delete (String*)pLb[i]->GetEntryData(j);
[ # # ]
180 : : }
181 [ # # ]: 0 : }
182 : :
183 : :
184 : : //----------------------------------------------------------------------------
185 : :
186 : 0 : sal_Bool ScPrintAreasDlg::Close()
187 : : {
188 : 0 : return DoClose( ScPrintAreasDlgWrapper::GetChildWindowId() );
189 : : }
190 : :
191 : :
192 : : //----------------------------------------------------------------------------
193 : :
194 : 0 : sal_Bool ScPrintAreasDlg::IsTableLocked() const
195 : : {
196 : : // Druckbereiche gelten pro Tabelle, darum macht es keinen Sinn,
197 : : // bei der Eingabe die Tabelle umzuschalten
198 : :
199 : 0 : return sal_True;
200 : : }
201 : :
202 : :
203 : : //----------------------------------------------------------------------------
204 : :
205 : 0 : void ScPrintAreasDlg::SetReference( const ScRange& rRef, ScDocument* /* pDoc */ )
206 : : {
207 [ # # ]: 0 : if ( pRefInputEdit )
208 : : {
209 [ # # ]: 0 : if ( rRef.aStart != rRef.aEnd )
210 [ # # ]: 0 : RefInputStart( pRefInputEdit );
211 : :
212 [ # # ]: 0 : String aStr;
213 [ # # ]: 0 : const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
214 : :
215 [ # # ]: 0 : if ( &aEdPrintArea == pRefInputEdit )
216 : : {
217 [ # # ]: 0 : rRef.Format( aStr, SCR_ABS, pDoc, eConv );
218 [ # # ]: 0 : String aVal = aEdPrintArea.GetText();
219 [ # # ]: 0 : Selection aSel = aEdPrintArea.GetSelection();
220 : 0 : aSel.Justify();
221 [ # # ]: 0 : aVal.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() );
222 [ # # ]: 0 : aVal.Insert( aStr, (xub_StrLen)aSel.Min() );
223 : 0 : Selection aNewSel( aSel.Min(), aSel.Min()+aStr.Len() );
224 [ # # ]: 0 : aEdPrintArea.SetRefString( aVal );
225 [ # # ][ # # ]: 0 : aEdPrintArea.SetSelection( aNewSel );
226 : : }
227 : : else
228 : : {
229 : 0 : sal_Bool bRow = ( &aEdRepeatRow == pRefInputEdit );
230 [ # # ]: 0 : lcl_GetRepeatRangeString(&rRef, pDoc, bRow, aStr);
231 [ # # ]: 0 : pRefInputEdit->SetRefString( aStr );
232 [ # # ]: 0 : }
233 : : }
234 : :
235 : 0 : Impl_ModifyHdl( pRefInputEdit );
236 : 0 : }
237 : :
238 : :
239 : : //----------------------------------------------------------------------------
240 : :
241 : 0 : void ScPrintAreasDlg::AddRefEntry()
242 : : {
243 [ # # ]: 0 : if ( pRefInputEdit == &aEdPrintArea )
244 : : {
245 [ # # ]: 0 : const sal_Unicode sep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
246 [ # # ]: 0 : String aVal = aEdPrintArea.GetText();
247 [ # # ]: 0 : aVal += sep;
248 [ # # ]: 0 : aEdPrintArea.SetText(aVal);
249 : :
250 : 0 : xub_StrLen nLen = aVal.Len();
251 [ # # ]: 0 : aEdPrintArea.SetSelection( Selection( nLen, nLen ) );
252 : :
253 [ # # ][ # # ]: 0 : Impl_ModifyHdl( &aEdPrintArea );
254 : : }
255 : 0 : }
256 : :
257 : :
258 : : //----------------------------------------------------------------------------
259 : :
260 : 0 : void ScPrintAreasDlg::Deactivate()
261 : : {
262 : 0 : bDlgLostFocus = sal_True;
263 : 0 : }
264 : :
265 : :
266 : : //----------------------------------------------------------------------------
267 : :
268 : 0 : void ScPrintAreasDlg::SetActive()
269 : : {
270 [ # # ]: 0 : if ( bDlgLostFocus )
271 : : {
272 : 0 : bDlgLostFocus = false;
273 : :
274 [ # # ]: 0 : if ( pRefInputEdit )
275 : : {
276 : 0 : pRefInputEdit->GrabFocus();
277 : 0 : Impl_ModifyHdl( pRefInputEdit );
278 : : }
279 : : }
280 : : else
281 : 0 : GrabFocus();
282 : :
283 : 0 : RefInputDone();
284 : 0 : }
285 : :
286 : :
287 : : //----------------------------------------------------------------------------
288 : :
289 : 0 : void ScPrintAreasDlg::Impl_Reset()
290 : : {
291 [ # # ]: 0 : String aStrRange;
292 [ # # ]: 0 : const ScRange* pRepeatColRange = pDoc->GetRepeatColRange( nCurTab );
293 [ # # ]: 0 : const ScRange* pRepeatRowRange = pDoc->GetRepeatRowRange( nCurTab );
294 : :
295 [ # # ]: 0 : aEdPrintArea.SetModifyHdl ( HDL(Impl_ModifyHdl) );
296 [ # # ]: 0 : aEdRepeatRow.SetModifyHdl ( HDL(Impl_ModifyHdl) );
297 [ # # ]: 0 : aEdRepeatCol.SetModifyHdl ( HDL(Impl_ModifyHdl) );
298 [ # # ]: 0 : aEdPrintArea.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
299 [ # # ]: 0 : aEdRepeatRow.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
300 [ # # ]: 0 : aEdRepeatCol.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
301 [ # # ]: 0 : aLbPrintArea.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
302 [ # # ]: 0 : aLbRepeatRow.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
303 [ # # ]: 0 : aLbRepeatCol.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
304 [ # # ]: 0 : aLbPrintArea.SetSelectHdl ( HDL(Impl_SelectHdl) );
305 [ # # ]: 0 : aLbRepeatRow.SetSelectHdl ( HDL(Impl_SelectHdl) );
306 [ # # ]: 0 : aLbRepeatCol.SetSelectHdl ( HDL(Impl_SelectHdl) );
307 [ # # ]: 0 : aBtnOk .SetClickHdl ( HDL(Impl_BtnHdl) );
308 [ # # ]: 0 : aBtnCancel .SetClickHdl ( HDL(Impl_BtnHdl) );
309 : :
310 [ # # ]: 0 : Impl_FillLists();
311 : :
312 : : //-------------------------
313 : : // Druckbereich
314 : : //-------------------------
315 [ # # ]: 0 : aStrRange.Erase();
316 [ # # ]: 0 : String aOne;
317 [ # # ]: 0 : const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
318 [ # # ]: 0 : const sal_Unicode sep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
319 [ # # ]: 0 : sal_uInt16 nRangeCount = pDoc->GetPrintRangeCount( nCurTab );
320 [ # # ]: 0 : for (sal_uInt16 i=0; i<nRangeCount; i++)
321 : : {
322 [ # # ]: 0 : const ScRange* pPrintRange = pDoc->GetPrintRange( nCurTab, i );
323 [ # # ]: 0 : if (pPrintRange)
324 : : {
325 [ # # ]: 0 : if ( aStrRange.Len() )
326 [ # # ]: 0 : aStrRange += sep;
327 [ # # ]: 0 : pPrintRange->Format( aOne, SCR_ABS, pDoc, eConv );
328 [ # # ]: 0 : aStrRange += aOne;
329 : : }
330 : : }
331 [ # # ]: 0 : aEdPrintArea.SetText( aStrRange );
332 : :
333 : : //-------------------------------
334 : : // Wiederholungszeile
335 : : //-------------------------------
336 [ # # ]: 0 : lcl_GetRepeatRangeString(pRepeatRowRange, pDoc, true, aStrRange);
337 [ # # ]: 0 : aEdRepeatRow.SetText( aStrRange );
338 : :
339 : : //--------------------------------
340 : : // Wiederholungsspalte
341 : : //--------------------------------
342 [ # # ]: 0 : lcl_GetRepeatRangeString(pRepeatColRange, pDoc, false, aStrRange);
343 [ # # ]: 0 : aEdRepeatCol.SetText( aStrRange );
344 : :
345 [ # # ]: 0 : Impl_ModifyHdl( &aEdPrintArea );
346 [ # # ]: 0 : Impl_ModifyHdl( &aEdRepeatRow );
347 [ # # ]: 0 : Impl_ModifyHdl( &aEdRepeatCol );
348 [ # # ][ # # ]: 0 : if( pDoc->IsPrintEntireSheet( nCurTab ) )
349 [ # # ]: 0 : aLbPrintArea.SelectEntryPos( SC_AREASDLG_PR_ENTIRE );
350 : :
351 [ # # ]: 0 : aEdPrintArea.SaveValue(); // fuer FillItemSet() merken:
352 [ # # ]: 0 : aEdRepeatRow.SaveValue();
353 [ # # ][ # # ]: 0 : aEdRepeatCol.SaveValue();
[ # # ]
354 : 0 : }
355 : :
356 : :
357 : : //----------------------------------------------------------------------------
358 : :
359 : 0 : bool ScPrintAreasDlg::Impl_GetItem( Edit* pEd, SfxStringItem& rItem )
360 : : {
361 [ # # ]: 0 : String aRangeStr = pEd->GetText();
362 [ # # ]: 0 : bool bDataChanged = (pEd->GetSavedValue() != aRangeStr);
363 : :
364 [ # # ][ # # ]: 0 : if ( (aRangeStr.Len() > 0) && &aEdPrintArea != pEd )
[ # # ]
365 : : {
366 : 0 : ScRange aRange;
367 [ # # ]: 0 : const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
368 [ # # ]: 0 : lcl_CheckRepeatString(aRangeStr, pDoc, &aEdRepeatRow == pEd, &aRange);
369 [ # # ]: 0 : aRange.Format(aRangeStr, SCR_ABS, pDoc, eConv);
370 : : }
371 : :
372 [ # # ]: 0 : rItem.SetValue( aRangeStr );
373 : :
374 [ # # ]: 0 : return bDataChanged;
375 : : }
376 : :
377 : :
378 : : //----------------------------------------------------------------------------
379 : :
380 : 0 : sal_Bool ScPrintAreasDlg::Impl_CheckRefStrings()
381 : : {
382 : 0 : sal_Bool bOk = false;
383 [ # # ]: 0 : String aStrPrintArea = aEdPrintArea.GetText();
384 [ # # ]: 0 : String aStrRepeatRow = aEdRepeatRow.GetText();
385 [ # # ]: 0 : String aStrRepeatCol = aEdRepeatCol.GetText();
386 : :
387 : 0 : sal_Bool bPrintAreaOk = sal_True;
388 [ # # ]: 0 : if ( aStrPrintArea.Len() )
389 : : {
390 : 0 : const sal_uInt16 nValidAddr = SCA_VALID | SCA_VALID_ROW | SCA_VALID_COL;
391 : 0 : const sal_uInt16 nValidRange = nValidAddr | SCA_VALID_ROW2 | SCA_VALID_COL2;
392 [ # # ]: 0 : const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
393 [ # # ]: 0 : const sal_Unicode sep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
394 : :
395 : 0 : ScAddress aAddr;
396 : 0 : ScRange aRange;
397 [ # # ][ # # ]: 0 : xub_StrLen nSepCount = comphelper::string::getTokenCount(aStrPrintArea, sep);
398 [ # # ][ # # ]: 0 : for ( xub_StrLen i = 0; i < nSepCount && bPrintAreaOk; ++i )
[ # # ]
399 : : {
400 [ # # ]: 0 : String aOne = aStrPrintArea.GetToken(i, sep);
401 [ # # ]: 0 : sal_uInt16 nResult = aRange.Parse( aOne, pDoc, eConv );
402 [ # # ]: 0 : if ((nResult & nValidRange) != nValidRange)
403 : : {
404 [ # # ]: 0 : sal_uInt16 nAddrResult = aAddr.Parse( aOne, pDoc, eConv );
405 [ # # ]: 0 : if ((nAddrResult & nValidAddr) != nValidAddr)
406 : 0 : bPrintAreaOk = false;
407 : : }
408 [ # # ]: 0 : }
409 : : }
410 : :
411 : 0 : sal_Bool bRepeatRowOk = (aStrRepeatRow.Len() == 0);
412 [ # # ]: 0 : if ( !bRepeatRowOk )
413 [ # # ]: 0 : bRepeatRowOk = lcl_CheckRepeatString(aStrRepeatRow, pDoc, true, NULL);
414 : :
415 : 0 : sal_Bool bRepeatColOk = (aStrRepeatCol.Len() == 0);
416 [ # # ]: 0 : if ( !bRepeatColOk )
417 [ # # ]: 0 : bRepeatColOk = lcl_CheckRepeatString(aStrRepeatCol, pDoc, false, NULL);
418 : :
419 : : // Fehlermeldungen
420 : :
421 [ # # ][ # # ]: 0 : bOk = (bPrintAreaOk && bRepeatRowOk && bRepeatColOk);
[ # # ]
422 : :
423 [ # # ]: 0 : if ( !bOk )
424 : : {
425 : 0 : Edit* pEd = NULL;
426 : :
427 [ # # ]: 0 : if ( !bPrintAreaOk ) pEd = &aEdPrintArea;
428 [ # # ]: 0 : else if ( !bRepeatRowOk ) pEd = &aEdRepeatRow;
429 [ # # ]: 0 : else if ( !bRepeatColOk ) pEd = &aEdRepeatCol;
430 : :
431 [ # # ][ # # ]: 0 : ERRORBOX( STR_INVALID_TABREF );
[ # # ][ # # ]
432 : :
433 : : OSL_ASSERT(pEd);
434 : :
435 [ # # ]: 0 : if (pEd)
436 [ # # ]: 0 : pEd->GrabFocus();
437 : : }
438 : :
439 [ # # ][ # # ]: 0 : return bOk;
[ # # ]
440 : : }
441 : :
442 : :
443 : : //----------------------------------------------------------------------------
444 : :
445 : 0 : void ScPrintAreasDlg::Impl_FillLists()
446 : : {
447 : : //------------------------------------------------------
448 : : // Selektion holen und String in PrintArea-ListBox merken
449 : : //------------------------------------------------------
450 : 0 : ScRange aRange;
451 [ # # ]: 0 : String aStrRange;
452 : 0 : sal_Bool bSimple = sal_True;
453 : :
454 [ # # ]: 0 : if ( pViewData )
455 [ # # ]: 0 : bSimple = (pViewData->GetSimpleArea( aRange ) == SC_MARK_SIMPLE);
456 : :
457 [ # # ]: 0 : formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
458 : :
459 [ # # ]: 0 : if ( bSimple )
460 [ # # ]: 0 : aRange.Format( aStrRange, SCR_ABS, pDoc, eConv );
461 : : else
462 : : {
463 [ # # ][ # # ]: 0 : ScRangeListRef aList( new ScRangeList );
464 [ # # ][ # # ]: 0 : pViewData->GetMarkData().FillRangeListWithMarks( aList, false );
465 [ # # ][ # # ]: 0 : aList->Format( aStrRange, SCR_ABS, pDoc, eConv );
466 : : }
467 : :
468 [ # # ][ # # ]: 0 : aLbPrintArea.SetEntryData( SC_AREASDLG_PR_SELECT, new String( aStrRange ) );
[ # # ]
469 : :
470 : : //------------------------------------------------------
471 : : // Ranges holen und in ListBoxen merken
472 : : //------------------------------------------------------
473 [ # # ]: 0 : ScRangeName* pRangeNames = pDoc->GetRangeName();
474 : :
475 [ # # ][ # # ]: 0 : if (!pRangeNames || pRangeNames->empty())
[ # # ][ # # ]
476 : : // No range names to process.
477 : 0 : return;
478 : :
479 [ # # ][ # # ]: 0 : ScRangeName::const_iterator itr = pRangeNames->begin(), itrEnd = pRangeNames->end();
[ # # ][ # # ]
480 [ # # ][ # # ]: 0 : for (; itr != itrEnd; ++itr)
[ # # ]
481 : : {
482 [ # # ][ # # ]: 0 : if (!itr->second->HasType(RT_ABSAREA) && !itr->second->HasType(RT_REFAREA) && !itr->second->HasType(RT_ABSPOS))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # #
# ]
483 : 0 : continue;
484 : :
485 [ # # ]: 0 : OUString aName = itr->second->GetName();
486 : 0 : OUString aSymbol;
487 [ # # ][ # # ]: 0 : itr->second->GetSymbol(aSymbol);
488 [ # # ][ # # ]: 0 : if (aRange.ParseAny(aSymbol, pDoc, eConv) & SCA_VALID)
[ # # ][ # # ]
489 : : {
490 [ # # ][ # # ]: 0 : if (itr->second->HasType(RT_PRINTAREA))
491 : : {
492 [ # # ]: 0 : aRange.Format(aSymbol, SCR_ABS, pDoc, eConv);
493 : : aLbPrintArea.SetEntryData(
494 [ # # ][ # # ]: 0 : aLbPrintArea.InsertEntry(aName),
[ # # ]
495 [ # # ][ # # ]: 0 : new String(aSymbol) );
[ # # ]
496 : : }
497 : :
498 [ # # ][ # # ]: 0 : if (itr->second->HasType(RT_ROWHEADER))
499 : : {
500 [ # # ]: 0 : lcl_GetRepeatRangeString(&aRange, pDoc, true, aSymbol);
501 : : aLbRepeatRow.SetEntryData(
502 [ # # ][ # # ]: 0 : aLbRepeatRow.InsertEntry(aName),
[ # # ]
503 [ # # ][ # # ]: 0 : new String(aSymbol) );
[ # # ]
504 : : }
505 : :
506 [ # # ][ # # ]: 0 : if (itr->second->HasType(RT_COLHEADER))
507 : : {
508 [ # # ]: 0 : lcl_GetRepeatRangeString(&aRange, pDoc, false, aSymbol);
509 : : aLbRepeatCol.SetEntryData(
510 [ # # ][ # # ]: 0 : aLbRepeatCol.InsertEntry(aName),
[ # # ]
511 [ # # ][ # # ]: 0 : new String(aSymbol));
[ # # ]
512 : : }
513 : : }
514 [ # # ][ # # ]: 0 : }
515 : : }
516 : :
517 : :
518 : : //----------------------------------------------------------------------------
519 : : // Handler:
520 : : //----------------------------------------------------------------------------
521 : :
522 : 0 : IMPL_LINK( ScPrintAreasDlg, Impl_BtnHdl, PushButton*, pBtn )
523 : : {
524 [ # # ]: 0 : if ( &aBtnOk == pBtn )
525 : : {
526 [ # # ]: 0 : if ( Impl_CheckRefStrings() )
527 : : {
528 : 0 : bool bDataChanged = false;
529 [ # # ]: 0 : String aStr;
530 [ # # ]: 0 : SfxStringItem aPrintArea( SID_CHANGE_PRINTAREA, aStr );
531 [ # # ]: 0 : SfxStringItem aRepeatRow( FN_PARAM_2, aStr );
532 [ # # ]: 0 : SfxStringItem aRepeatCol( FN_PARAM_3, aStr );
533 : :
534 : : //-------------------------
535 : : // Druckbereich veraendert?
536 : : //-------------------------
537 : :
538 : : // first try the list box, if "Entite sheet" is selected
539 [ # # ]: 0 : bool bEntireSheet = (aLbPrintArea.GetSelectEntryPos() == SC_AREASDLG_PR_ENTIRE);
540 [ # # ]: 0 : SfxBoolItem aEntireSheet( FN_PARAM_4, bEntireSheet );
541 : :
542 [ # # ]: 0 : bDataChanged = bEntireSheet != pDoc->IsPrintEntireSheet( nCurTab );
543 [ # # ]: 0 : if( !bEntireSheet )
544 : : {
545 : : // if new list box selection is not "Entire sheet", get the edit field contents
546 [ # # ]: 0 : bDataChanged |= Impl_GetItem( &aEdPrintArea, aPrintArea );
547 : : }
548 : :
549 : : //-------------------------------
550 : : // Wiederholungszeile veraendert?
551 : : //-------------------------------
552 [ # # ]: 0 : bDataChanged |= Impl_GetItem( &aEdRepeatRow, aRepeatRow );
553 : :
554 : : //--------------------------------
555 : : // Wiederholungsspalte veraendert?
556 : : //--------------------------------
557 [ # # ]: 0 : bDataChanged |= Impl_GetItem( &aEdRepeatCol, aRepeatCol );
558 : :
559 [ # # ]: 0 : if ( bDataChanged )
560 : : {
561 [ # # ]: 0 : SetDispatcherLock( false );
562 [ # # ]: 0 : SwitchToDocument();
563 : 0 : GetBindings().GetDispatcher()->Execute( SID_CHANGE_PRINTAREA,
564 : : SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
565 [ # # ]: 0 : &aPrintArea, &aRepeatRow, &aRepeatCol, &aEntireSheet, 0L );
566 : : }
567 : :
568 [ # # ][ # # ]: 0 : Close();
[ # # ][ # # ]
[ # # ][ # # ]
569 : : }
570 : : }
571 [ # # ]: 0 : else if ( &aBtnCancel == pBtn )
572 : 0 : Close();
573 : :
574 : 0 : return 0;
575 : : }
576 : :
577 : :
578 : : //----------------------------------------------------------------------------
579 : :
580 : 0 : IMPL_LINK( ScPrintAreasDlg, Impl_GetFocusHdl, Control*, pCtr )
581 : : {
582 [ # # ][ # # ]: 0 : if ( pCtr ==(Control *) &aEdPrintArea ||
[ # # ]
583 : : pCtr ==(Control *) &aEdRepeatRow ||
584 : : pCtr ==(Control *) &aEdRepeatCol)
585 : : {
586 : 0 : pRefInputEdit = (formula::RefEdit*) pCtr;
587 : : }
588 [ # # ]: 0 : else if ( pCtr ==(Control *) &aLbPrintArea)
589 : : {
590 : 0 : pRefInputEdit = &aEdPrintArea;
591 : : }
592 [ # # ]: 0 : else if ( pCtr ==(Control *) &aLbRepeatRow)
593 : : {
594 : 0 : pRefInputEdit = &aEdRepeatRow;
595 : : }
596 [ # # ]: 0 : else if ( pCtr ==(Control *) &aLbRepeatCol)
597 : : {
598 : 0 : pRefInputEdit = &aEdRepeatCol;
599 : : }
600 : :
601 : 0 : return 0;
602 : : }
603 : :
604 : :
605 : : //----------------------------------------------------------------------------
606 : :
607 : 0 : IMPL_LINK( ScPrintAreasDlg, Impl_SelectHdl, ListBox*, pLb )
608 : : {
609 : 0 : sal_uInt16 nSelPos = pLb->GetSelectEntryPos();
610 : 0 : Edit* pEd = NULL;
611 : :
612 : : // list box positions of specific entries, default to "repeat row/column" list boxes
613 : 0 : sal_uInt16 nAllSheetPos = SC_AREASDLG_RR_NONE;
614 : 0 : sal_uInt16 nUserDefPos = SC_AREASDLG_RR_USER;
615 : 0 : sal_uInt16 nFirstCustomPos = SC_AREASDLG_RR_OFFSET;
616 : :
617 : : // find edit field for list box, and list box positions
618 [ # # ]: 0 : if( pLb == &aLbPrintArea )
619 : : {
620 : 0 : pEd = &aEdPrintArea;
621 : 0 : nAllSheetPos = SC_AREASDLG_PR_ENTIRE;
622 : 0 : nUserDefPos = SC_AREASDLG_PR_USER;
623 : 0 : nFirstCustomPos = SC_AREASDLG_PR_SELECT; // "Selection" and following
624 : : }
625 [ # # ]: 0 : else if( pLb == &aLbRepeatCol )
626 : 0 : pEd = &aEdRepeatCol;
627 [ # # ]: 0 : else if( pLb == &aLbRepeatRow )
628 : 0 : pEd = &aEdRepeatRow;
629 : : else
630 : 0 : return 0;
631 : :
632 : : // fill edit field according to list box selection
633 [ # # ][ # # ]: 0 : if( (nSelPos == 0) || (nSelPos == nAllSheetPos) )
634 : 0 : pEd->SetText( EMPTY_STRING );
635 [ # # ][ # # ]: 0 : else if( nSelPos == nUserDefPos && !pLb->IsTravelSelect() && pEd->GetText().Len() == 0 )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
636 : 0 : pLb->SelectEntryPos( 0 );
637 [ # # ]: 0 : else if( nSelPos >= nFirstCustomPos )
638 : 0 : pEd->SetText( *static_cast< String* >( pLb->GetEntryData( nSelPos ) ) );
639 : :
640 : 0 : return 0;
641 : : }
642 : :
643 : :
644 : : //----------------------------------------------------------------------------
645 : :
646 : 0 : IMPL_LINK( ScPrintAreasDlg, Impl_ModifyHdl, formula::RefEdit*, pEd )
647 : : {
648 : 0 : ListBox* pLb = NULL;
649 : :
650 : : // list box positions of specific entries, default to "repeat row/column" list boxes
651 : 0 : sal_uInt16 nUserDefPos = SC_AREASDLG_RR_USER;
652 : 0 : sal_uInt16 nFirstCustomPos = SC_AREASDLG_RR_OFFSET;
653 : :
654 [ # # ]: 0 : if( pEd == &aEdPrintArea )
655 : : {
656 : 0 : pLb = &aLbPrintArea;
657 : 0 : nUserDefPos = SC_AREASDLG_PR_USER;
658 : 0 : nFirstCustomPos = SC_AREASDLG_PR_SELECT; // "Selection" and following
659 : : }
660 [ # # ]: 0 : else if( pEd == &aEdRepeatCol )
661 : 0 : pLb = &aLbRepeatCol;
662 [ # # ]: 0 : else if( pEd == &aEdRepeatRow )
663 : 0 : pLb = &aLbRepeatRow;
664 : : else
665 : 0 : return 0;
666 : :
667 : : // set list box selection according to edit field
668 [ # # ]: 0 : sal_uInt16 nEntryCount = pLb->GetEntryCount();
669 [ # # ]: 0 : String aStrEd( pEd->GetText() );
670 [ # # ]: 0 : String aEdUpper = aStrEd;
671 [ # # ]: 0 : aEdUpper.ToUpperAscii();
672 : :
673 [ # # ][ # # ]: 0 : if ( (nEntryCount > nFirstCustomPos) && aStrEd.Len() > 0 )
[ # # ]
674 : : {
675 : 0 : sal_Bool bFound = false;
676 : 0 : String* pSymbol = NULL;
677 : : sal_uInt16 i;
678 : :
679 [ # # ][ # # ]: 0 : for ( i=nFirstCustomPos; i<nEntryCount && !bFound; i++ )
[ # # ]
680 : : {
681 [ # # ]: 0 : pSymbol = (String*)pLb->GetEntryData( i );
682 [ # # ][ # # ]: 0 : bFound = ( (*pSymbol == aStrEd) || (*pSymbol == aEdUpper) );
[ # # ][ # # ]
683 : : }
684 : :
685 [ # # ][ # # ]: 0 : pLb->SelectEntryPos( bFound ? i-1 : nUserDefPos );
686 : : }
687 : : else
688 [ # # ][ # # ]: 0 : pLb->SelectEntryPos( aStrEd.Len() ? nUserDefPos : 0 );
689 : :
690 [ # # ][ # # ]: 0 : return 0;
691 : : }
692 : :
693 : :
694 : : //============================================================================
695 : : // globale Funktionen:
696 : :
697 : : // ----------------------------------------------------------------------------
698 : :
699 : : // TODO: It might make sense to move these functions to address.?xx. -kohei
700 : :
701 : 0 : bool lcl_CheckOne_OOO( const String& rStr, bool bIsRow, SCCOLROW& rVal )
702 : : {
703 : : // Zulaessige Syntax fuer rStr:
704 : : // Row: [$]1-MAXTAB
705 : : // Col: [$]A-IV
706 : :
707 [ # # ]: 0 : String aStr = rStr;
708 : 0 : xub_StrLen nLen = aStr.Len();
709 : 0 : SCCOLROW nNum = 0;
710 [ # # ][ # # ]: 0 : sal_Bool bStrOk = ( nLen > 0 ) && ( bIsRow ? ( nLen < 6 ) : ( nLen < 4 ) );
[ # # ][ # # ]
711 : :
712 [ # # ]: 0 : if ( bStrOk )
713 : : {
714 [ # # ]: 0 : if ( '$' == aStr.GetChar(0) )
715 [ # # ]: 0 : aStr.Erase( 0, 1 );
716 : :
717 [ # # ]: 0 : if ( bIsRow )
718 : : {
719 [ # # ]: 0 : bStrOk = CharClass::isAsciiNumeric(aStr);
720 : :
721 [ # # ]: 0 : if ( bStrOk )
722 : : {
723 [ # # ]: 0 : sal_Int32 n = aStr.ToInt32();
724 : :
725 [ # # ][ # # ]: 0 : if ( ( bStrOk = (n > 0) && ( n <= MAXROWCOUNT ) ) != false )
[ # # ]
726 : 0 : nNum = static_cast<SCCOLROW>(n - 1);
727 : : }
728 : : }
729 : : else
730 : : {
731 : 0 : SCCOL nCol = 0;
732 [ # # ]: 0 : bStrOk = ::AlphaToCol( nCol, aStr);
733 : 0 : nNum = nCol;
734 : : }
735 : : }
736 : :
737 [ # # ]: 0 : if ( bStrOk )
738 : 0 : rVal = nNum;
739 : :
740 [ # # ]: 0 : return bStrOk;
741 : : }
742 : :
743 : 0 : bool lcl_CheckOne_XL_A1( const String& rStr, bool bIsRow, SCCOLROW& rVal )
744 : : {
745 : : // XL A1 style is identical to OOO one for print range formats.
746 : 0 : return lcl_CheckOne_OOO(rStr, bIsRow, rVal);
747 : : }
748 : :
749 : 0 : bool lcl_CheckOne_XL_R1C1( const String& rStr, bool bIsRow, SCCOLROW& rVal )
750 : : {
751 : 0 : xub_StrLen nLen = rStr.Len();
752 [ # # ]: 0 : if (nLen <= 1)
753 : : // There must be at least two characters.
754 : 0 : return false;
755 : :
756 [ # # ]: 0 : const sal_Unicode preUpper = bIsRow ? 'R' : 'C';
757 [ # # ]: 0 : const sal_Unicode preLower = bIsRow ? 'r' : 'c';
758 [ # # ][ # # ]: 0 : if (rStr.GetChar(0) != preUpper && rStr.GetChar(0) != preLower)
[ # # ]
759 : 0 : return false;
760 : :
761 [ # # ]: 0 : String aNumStr = rStr.Copy(1);
762 [ # # ][ # # ]: 0 : if (!CharClass::isAsciiNumeric(aNumStr))
763 : 0 : return false;
764 : :
765 [ # # ]: 0 : sal_Int32 nNum = aNumStr.ToInt32();
766 : :
767 [ # # ]: 0 : if (nNum <= 0)
768 : 0 : return false;
769 : :
770 [ # # ][ # # ]: 0 : if ((bIsRow && nNum > MAXROWCOUNT) || (!bIsRow && nNum > MAXCOLCOUNT))
[ # # ][ # # ]
771 : 0 : return false;
772 : :
773 : 0 : rVal = static_cast<SCCOLROW>(nNum-1);
774 [ # # ]: 0 : return true;
775 : : }
776 : :
777 : 0 : bool lcl_CheckRepeatOne( const String& rStr, formula::FormulaGrammar::AddressConvention eConv, bool bIsRow, SCCOLROW& rVal )
778 : : {
779 [ # # # # ]: 0 : switch (eConv)
780 : : {
781 : : case formula::FormulaGrammar::CONV_OOO:
782 : 0 : return lcl_CheckOne_OOO(rStr, bIsRow, rVal);
783 : : case formula::FormulaGrammar::CONV_XL_A1:
784 : 0 : return lcl_CheckOne_XL_A1(rStr, bIsRow, rVal);
785 : : case formula::FormulaGrammar::CONV_XL_R1C1:
786 : 0 : return lcl_CheckOne_XL_R1C1(rStr, bIsRow, rVal);
787 : : default:
788 : : {
789 : : // added to avoid warnings
790 : : }
791 : : }
792 : 0 : return false;
793 : : }
794 : :
795 : 0 : bool lcl_CheckRepeatString( const String& rStr, ScDocument* pDoc, bool bIsRow, ScRange* pRange )
796 : : {
797 : : // Row: [valid row] rsep [valid row]
798 : : // Col: [valid col] rsep [valid col]
799 : :
800 [ # # ]: 0 : const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
801 [ # # ]: 0 : const sal_Unicode rsep = ScCompiler::GetNativeSymbol(ocRange).GetChar(0);
802 : :
803 [ # # ]: 0 : if (pRange)
804 : : {
805 : : // initialize the range value.
806 : 0 : pRange->aStart.SetCol(0);
807 : 0 : pRange->aStart.SetRow(0);
808 : 0 : pRange->aEnd.SetCol(0);
809 : 0 : pRange->aEnd.SetRow(0);
810 : : }
811 : :
812 [ # # ]: 0 : String aBuf;
813 : 0 : SCCOLROW nVal = 0;
814 : 0 : xub_StrLen nLen = rStr.Len();
815 : 0 : bool bEndPos = false;
816 [ # # ]: 0 : for (xub_StrLen i = 0; i < nLen; ++i)
817 : : {
818 : 0 : const sal_Unicode c = rStr.GetChar(i);
819 [ # # ]: 0 : if (c == rsep)
820 : : {
821 [ # # ]: 0 : if (bEndPos)
822 : : // We aren't supposed to have more than one range separator.
823 : 0 : return false;
824 : :
825 : : // range separator
826 [ # # ]: 0 : if (aBuf.Len() == 0)
827 : 0 : return false;
828 : :
829 [ # # ]: 0 : bool bRes = lcl_CheckRepeatOne(aBuf, eConv, bIsRow, nVal);
830 [ # # ]: 0 : if (!bRes)
831 : 0 : return false;
832 : :
833 [ # # ]: 0 : if (pRange)
834 : : {
835 [ # # ]: 0 : if (bIsRow)
836 : : {
837 : 0 : pRange->aStart.SetRow(static_cast<SCROW>(nVal));
838 : 0 : pRange->aEnd.SetRow(static_cast<SCROW>(nVal));
839 : : }
840 : : else
841 : : {
842 : 0 : pRange->aStart.SetCol(static_cast<SCCOL>(nVal));
843 : 0 : pRange->aEnd.SetCol(static_cast<SCCOL>(nVal));
844 : : }
845 : : }
846 : :
847 [ # # ]: 0 : aBuf.Erase();
848 : 0 : bEndPos = true;
849 : : }
850 : : else
851 [ # # ]: 0 : aBuf.Append(c);
852 : : }
853 : :
854 [ # # ]: 0 : if (aBuf.Len() > 0)
855 : : {
856 [ # # ]: 0 : bool bRes = lcl_CheckRepeatOne(aBuf, eConv, bIsRow, nVal);
857 [ # # ]: 0 : if (!bRes)
858 : 0 : return false;
859 : :
860 [ # # ]: 0 : if (pRange)
861 : : {
862 [ # # ]: 0 : if (bIsRow)
863 : : {
864 [ # # ]: 0 : if (!bEndPos)
865 : 0 : pRange->aStart.SetRow(static_cast<SCROW>(nVal));
866 : 0 : pRange->aEnd.SetRow(static_cast<SCROW>(nVal));
867 : : }
868 : : else
869 : : {
870 [ # # ]: 0 : if (!bEndPos)
871 : 0 : pRange->aStart.SetCol(static_cast<SCCOL>(nVal));
872 : 0 : pRange->aEnd.SetCol(static_cast<SCCOL>(nVal));
873 : : }
874 : : }
875 : : }
876 : :
877 [ # # ]: 0 : return true;
878 : : }
879 : :
880 : : // ----------------------------------------------------------------------------
881 : :
882 : 0 : void lcl_GetRepeatRangeString( const ScRange* pRange, ScDocument* pDoc, bool bIsRow, String& rStr )
883 : : {
884 [ # # ]: 0 : rStr.Erase();
885 [ # # ]: 0 : if (!pRange)
886 : 0 : return;
887 : :
888 [ # # ]: 0 : const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
889 : 0 : const ScAddress& rStart = pRange->aStart;
890 : 0 : const ScAddress& rEnd = pRange->aEnd;
891 : :
892 [ # # ]: 0 : const sal_uInt16 nFmt = bIsRow ? (SCA_VALID_ROW | SCA_ROW_ABSOLUTE) : (SCA_VALID_COL | SCA_COL_ABSOLUTE);
893 [ # # ]: 0 : String aTmpStr;
894 [ # # ]: 0 : rStart.Format(aTmpStr, nFmt, pDoc, eConv);
895 [ # # ]: 0 : rStr += aTmpStr;
896 [ # # ][ # # ]: 0 : if ((bIsRow && rStart.Row() != rEnd.Row()) || (!bIsRow && rStart.Col() != rEnd.Col()))
[ # # ][ # # ]
[ # # ]
897 : : {
898 [ # # ][ # # ]: 0 : rStr += ScCompiler::GetNativeSymbol(ocRange);
899 [ # # ]: 0 : rEnd.Format(aTmpStr, nFmt, pDoc, eConv);
900 [ # # ]: 0 : rStr += aTmpStr;
901 [ # # ]: 0 : }
902 : : }
903 : :
904 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|