1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viewdata.cxx,v $
10 * $Revision: 1.65.24.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 // INCLUDE ---------------------------------------------------------------
38 #include "scitems.hxx"
39 #include <svx/eeitem.hxx>
42 #include <sfx2/viewfrm.hxx>
43 #include <svx/adjitem.hxx>
44 #include <svx/algitem.hxx>
45 #include <svx/brshitem.hxx>
46 #include <svtools/colorcfg.hxx>
47 #include <svx/editview.hxx>
48 #include <svx/editstat.hxx>
49 #include <svx/outliner.hxx>
50 #include <svx/unolingu.hxx>
52 #include <vcl/svapp.hxx>
53 #include <rtl/math.hxx>
55 #include "viewdata.hxx"
56 #include "docoptio.hxx"
59 #include "document.hxx"
61 #include "tabview.hxx"
62 #include "tabvwsh.hxx"
65 #include "patattr.hxx"
66 #include "editutil.hxx"
67 #include "scextopt.hxx"
68 #include "miscuno.hxx"
69 #include "unonames.hxx"
70 #include "inputopt.hxx"
71 #include "viewutil.hxx"
72 #include <xmloff/xmluconv.hxx>
73 #include "ViewSettingsSequenceDefines.hxx"
74 #include <rtl/ustrbuf.hxx>
75 #include <comphelper/processfactory.hxx>
76 #include <com/sun/star/container/XNameContainer.hpp>
78 using namespace com::sun::star
;
80 // STATIC DATA -----------------------------------------------------------
82 #define SC_GROWY_SMALL_EXTRA 100
83 #define SC_GROWY_BIG_EXTRA 200
85 #define TAG_TABBARWIDTH "tw:"
87 static BOOL bMoveArea
= FALSE
; //! Member?
88 USHORT nEditAdjust
= SVX_ADJUST_LEFT
; //! Member !!!
90 //==================================================================
92 ScViewDataTable::ScViewDataTable() :
93 eZoomType( SVX_ZOOM_PERCENT
),
96 aPageZoomX( 3,5 ), // Page-Default: 60%
100 eHSplitMode( SC_SPLIT_NONE
),
101 eVSplitMode( SC_SPLIT_NONE
),
102 eWhichActive( SC_SPLIT_BOTTOMLEFT
),
108 bOldCurValid( FALSE
),
109 aTabBgColor( Color(COL_AUTO
) )
113 nTPosX
[0]=nTPosX
[1]=0;
114 nTPosY
[0]=nTPosY
[1]=0;
115 nMPosX
[0]=nMPosX
[1]=0;
116 nMPosY
[0]=nMPosY
[1]=0;
117 nPixPosX
[0]=nPixPosX
[1]=0;
118 nPixPosY
[0]=nPixPosY
[1]=0;
121 ScViewDataTable::~ScViewDataTable()
125 void ScViewDataTable::WriteUserDataSequence(uno::Sequence
<beans::PropertyValue
>& rSettings
, const ScViewData
& /*rViewData*/, SCTAB
/*nTab*/)
127 rSettings
.realloc(SC_TABLE_VIEWSETTINGS_COUNT
);
128 beans::PropertyValue
* pSettings
= rSettings
.getArray();
131 pSettings
[SC_CURSOR_X
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_CURSORPOSITIONX
));
132 pSettings
[SC_CURSOR_X
].Value
<<= sal_Int32(nCurX
);
133 pSettings
[SC_CURSOR_Y
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_CURSORPOSITIONY
));
134 pSettings
[SC_CURSOR_Y
].Value
<<= sal_Int32(nCurY
);
135 pSettings
[SC_HORIZONTAL_SPLIT_MODE
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_HORIZONTALSPLITMODE
));
136 pSettings
[SC_HORIZONTAL_SPLIT_MODE
].Value
<<= sal_Int16(eHSplitMode
);
137 pSettings
[SC_VERTICAL_SPLIT_MODE
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VERTICALSPLITMODE
));
138 pSettings
[SC_VERTICAL_SPLIT_MODE
].Value
<<= sal_Int16(eVSplitMode
);
139 pSettings
[SC_HORIZONTAL_SPLIT_POSITION
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_HORIZONTALSPLITPOSITION
));
140 if (eHSplitMode
== SC_SPLIT_FIX
)
141 pSettings
[SC_HORIZONTAL_SPLIT_POSITION
].Value
<<= sal_Int32(nFixPosX
);
143 pSettings
[SC_HORIZONTAL_SPLIT_POSITION
].Value
<<= sal_Int32(nHSplitPos
);
144 pSettings
[SC_VERTICAL_SPLIT_POSITION
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VERTICALSPLITPOSITION
));
145 if (eVSplitMode
== SC_SPLIT_FIX
)
146 pSettings
[SC_VERTICAL_SPLIT_POSITION
].Value
<<= sal_Int32(nFixPosY
);
148 pSettings
[SC_VERTICAL_SPLIT_POSITION
].Value
<<= sal_Int32(nVSplitPos
);
149 pSettings
[SC_ACTIVE_SPLIT_RANGE
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ACTIVESPLITRANGE
));
150 pSettings
[SC_ACTIVE_SPLIT_RANGE
].Value
<<= sal_Int16(eWhichActive
);
151 pSettings
[SC_POSITION_LEFT
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_POSITIONLEFT
));
152 pSettings
[SC_POSITION_LEFT
].Value
<<= sal_Int32(nPosX
[SC_SPLIT_LEFT
]);
153 pSettings
[SC_POSITION_RIGHT
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_POSITIONRIGHT
));
154 pSettings
[SC_POSITION_RIGHT
].Value
<<= sal_Int32(nPosX
[SC_SPLIT_RIGHT
]);
155 pSettings
[SC_POSITION_TOP
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_POSITIONTOP
));
156 pSettings
[SC_POSITION_TOP
].Value
<<= sal_Int32(nPosY
[SC_SPLIT_TOP
]);
157 pSettings
[SC_POSITION_BOTTOM
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_POSITIONBOTTOM
));
158 pSettings
[SC_POSITION_BOTTOM
].Value
<<= sal_Int32(nPosY
[SC_SPLIT_BOTTOM
]);
160 sal_Int32
nZoomValue ((aZoomY
.GetNumerator() * 100) / aZoomY
.GetDenominator());
161 sal_Int32
nPageZoomValue ((aPageZoomY
.GetNumerator() * 100) / aPageZoomY
.GetDenominator());
162 pSettings
[SC_TABLE_ZOOM_TYPE
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ZOOMTYPE
));
163 pSettings
[SC_TABLE_ZOOM_TYPE
].Value
<<= sal_Int16(eZoomType
);
164 pSettings
[SC_TABLE_ZOOM_VALUE
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ZOOMVALUE
));
165 pSettings
[SC_TABLE_ZOOM_VALUE
].Value
<<= nZoomValue
;
166 pSettings
[SC_TABLE_PAGE_VIEW_ZOOM_VALUE
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_PAGEVIEWZOOMVALUE
));
167 pSettings
[SC_TABLE_PAGE_VIEW_ZOOM_VALUE
].Value
<<= nPageZoomValue
;
169 pSettings
[SC_TABLE_SHOWGRID
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWGRID
));
170 pSettings
[SC_TABLE_SHOWGRID
].Value
<<= static_cast<sal_Bool
>(bShowGrid
);
173 if ( !IsDefaultTabBgColor() )
175 pSettings
[SC_TABLE_TAB_BG_COLOR
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_TABCOLOR
));
176 pSettings
[SC_TABLE_TAB_BG_COLOR
].Value
<<= static_cast<sal_Int32
>(aTabBgColor
.GetColor());
178 // pSettings[SC_TABLE_SELECTED].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_TABLESELECTED));
179 // pSettings[SC_TABLE_SELECTED].Value <<= bool(rViewData.GetMarkData().GetTableSelect( nTab ));
183 void ScViewDataTable::ReadUserDataSequence(const uno::Sequence
<beans::PropertyValue
>& aSettings
, ScViewData
& rViewData
, SCTAB nTab
, bool& rHasZoom
)
187 sal_Int32
nCount(aSettings
.getLength());
188 sal_Int32
nTemp32(0);
189 sal_Int16
nTemp16(0);
190 sal_Int32
nTempPosV(0);
191 sal_Int32
nTempPosH(0);
192 sal_Int32
nTempPosVTw(0);
193 sal_Int32
nTempPosHTw(0);
194 bool bHasVSplitInTwips
= false;
195 bool bHasHSplitInTwips
= false;
196 for (sal_Int32 i
= 0; i
< nCount
; i
++)
198 rtl::OUString
sName(aSettings
[i
].Name
);
199 if (sName
.compareToAscii(SC_CURSORPOSITIONX
) == 0)
201 aSettings
[i
].Value
>>= nTemp32
;
202 nCurX
= SanitizeCol( static_cast<SCCOL
>(nTemp32
));
204 else if (sName
.compareToAscii(SC_CURSORPOSITIONY
) == 0)
206 aSettings
[i
].Value
>>= nTemp32
;
207 nCurY
= SanitizeRow( static_cast<SCROW
>(nTemp32
));
209 else if (sName
.compareToAscii(SC_HORIZONTALSPLITMODE
) == 0)
211 aSettings
[i
].Value
>>= nTemp16
;
212 eHSplitMode
= static_cast<ScSplitMode
>(nTemp16
);
214 else if (sName
.compareToAscii(SC_VERTICALSPLITMODE
) == 0)
216 aSettings
[i
].Value
>>= nTemp16
;
217 eVSplitMode
= static_cast<ScSplitMode
>(nTemp16
);
219 else if (sName
.compareToAscii(SC_HORIZONTALSPLITPOSITION
) == 0)
221 aSettings
[i
].Value
>>= nTempPosH
;
222 bHasHSplitInTwips
= false;
224 else if (sName
.compareToAscii(SC_VERTICALSPLITPOSITION
) == 0)
226 aSettings
[i
].Value
>>= nTempPosV
;
227 bHasVSplitInTwips
= false;
229 else if (sName
.compareToAscii(SC_HORIZONTALSPLITPOSITION_TWIPS
) == 0)
231 aSettings
[i
].Value
>>= nTempPosHTw
;
232 bHasHSplitInTwips
= true;
234 else if (sName
.compareToAscii(SC_VERTICALSPLITPOSITION_TWIPS
) == 0)
236 aSettings
[i
].Value
>>= nTempPosVTw
;
237 bHasVSplitInTwips
= true;
239 else if (sName
.compareToAscii(SC_ACTIVESPLITRANGE
) == 0)
241 aSettings
[i
].Value
>>= nTemp16
;
242 eWhichActive
= static_cast<ScSplitPos
>(nTemp16
);
244 else if (sName
.compareToAscii(SC_POSITIONLEFT
) == 0)
246 aSettings
[i
].Value
>>= nTemp32
;
247 nPosX
[SC_SPLIT_LEFT
] = SanitizeCol( static_cast<SCCOL
>(nTemp32
));
249 else if (sName
.compareToAscii(SC_POSITIONRIGHT
) == 0)
251 aSettings
[i
].Value
>>= nTemp32
;
252 nPosX
[SC_SPLIT_RIGHT
] = SanitizeCol( static_cast<SCCOL
>(nTemp32
));
254 else if (sName
.compareToAscii(SC_POSITIONTOP
) == 0)
256 aSettings
[i
].Value
>>= nTemp32
;
257 nPosY
[SC_SPLIT_TOP
] = SanitizeRow( static_cast<SCROW
>(nTemp32
));
259 else if (sName
.compareToAscii(SC_POSITIONBOTTOM
) == 0)
261 aSettings
[i
].Value
>>= nTemp32
;
262 nPosY
[SC_SPLIT_BOTTOM
] = SanitizeRow( static_cast<SCROW
>(nTemp32
));
264 else if (sName
.compareToAscii(SC_ZOOMTYPE
) == 0)
266 aSettings
[i
].Value
>>= nTemp16
;
267 eZoomType
= SvxZoomType(nTemp16
);
268 rHasZoom
= true; // set if there is any zoom information
270 else if (sName
.compareToAscii(SC_ZOOMVALUE
) == 0)
272 aSettings
[i
].Value
>>= nTemp32
;
273 Fraction
aZoom(nTemp32
, 100);
274 aZoomX
= aZoomY
= aZoom
;
277 else if (sName
.compareToAscii(SC_PAGEVIEWZOOMVALUE
) == 0)
279 aSettings
[i
].Value
>>= nTemp32
;
280 Fraction
aZoom(nTemp32
, 100);
281 aPageZoomX
= aPageZoomY
= aZoom
;
284 else if (sName
.compareToAscii(SC_UNO_SHOWGRID
) == 0)
286 aSettings
[i
].Value
>>= bShowGrid
;
288 else if (sName
.compareToAscii(SC_TABLESELECTED
) == 0)
290 bool bSelected
= false;
291 aSettings
[i
].Value
>>= bSelected
;
292 rViewData
.GetMarkData().SelectTable( nTab
, bSelected
);
294 else if (sName
.compareToAscii(SC_UNO_TABCOLOR
) == 0)
296 sal_Int32 nColor
= COL_AUTO
;
297 aSettings
[i
].Value
>>= nColor
;
298 if (nColor
!= COL_AUTO
)
299 aTabBgColor
.SetColor(static_cast<ColorData
>(nColor
));
302 if (eHSplitMode
== SC_SPLIT_FIX
)
303 nFixPosX
= SanitizeCol( static_cast<SCCOL
>( bHasHSplitInTwips
? nTempPosHTw
: nTempPosH
));
305 nHSplitPos
= bHasHSplitInTwips
? static_cast< long >( nTempPosHTw
* rViewData
.GetPPTX() ) : nTempPosH
;
307 if (eVSplitMode
== SC_SPLIT_FIX
)
308 nFixPosY
= SanitizeRow( static_cast<SCROW
>( bHasVSplitInTwips
? nTempPosVTw
: nTempPosV
));
310 nVSplitPos
= bHasVSplitInTwips
? static_cast< long >( nTempPosVTw
* rViewData
.GetPPTY() ) : nTempPosV
;
313 //==================================================================
315 ScViewData::ScViewData( ScDocShell
* pDocSh
, ScTabViewShell
* pViewSh
)
316 : pDocShell ( pDocSh
),
319 pViewShell ( pViewSh
),
320 pOptions ( new ScViewOptions
),
321 pSpellingView ( NULL
),
322 aLogicMode ( MAP_100TH_MM
),
323 eDefZoomType( SVX_ZOOM_PERCENT
),
326 aDefPageZoomX( 3,5 ),
327 aDefPageZoomY( 3,5 ),
328 eRefType ( SC_REFTYPE_NONE
),
331 nPasteFlags ( SC_PASTE_NONE
),
332 eEditActivePart( SC_SPLIT_BOTTOMLEFT
),
333 bActive ( TRUE
), //! wie initialisieren?
334 bIsRefMode ( FALSE
),
335 bDelMarkValid( FALSE
),
336 nFillMode ( SC_FILL_NONE
),
337 bPagebreak ( FALSE
),
338 bSelCtrlMouseClick( FALSE
)
341 SetGridMode ( TRUE
);
342 SetSyntaxMode ( FALSE
);
343 SetHeaderMode ( TRUE
);
345 SetVScrollMode ( TRUE
);
346 SetHScrollMode ( TRUE
);
347 SetOutlineMode ( TRUE
);
349 aScrSize
= Size( (long) ( STD_COL_WIDTH
* PIXEL_PER_TWIPS
* OLE_STD_CELLS_X
),
350 (long) ( ScGlobal::nStdRowHeight
* PIXEL_PER_TWIPS
* OLE_STD_CELLS_Y
) );
351 pTabData
[0] = new ScViewDataTable
;
352 for ( SCTAB i
= 1; i
<= MAXTAB
; i
++ )
354 pThisTab
= pTabData
[nTabNo
];
355 for (USHORT j
=0; j
<4; j
++)
358 bEditActive
[j
] = FALSE
;
361 nEditEndCol
= nEditStartCol
= nEditCol
= 0;
362 nEditEndRow
= nEditRow
= 0;
363 nTabStartCol
= SC_TABSTART_NONE
;
367 pDoc
= pDocShell
->GetDocument();
368 *pOptions
= pDoc
->GetViewOptions();
371 // keine ausgeblendete Tabelle anzeigen:
372 if (pDoc
&& !pDoc
->IsVisible(nTabNo
))
374 while ( !pDoc
->IsVisible(nTabNo
) && pDoc
->HasTable(nTabNo
+1) )
377 pTabData
[nTabNo
] = new ScViewDataTable
;
378 pThisTab
= pTabData
[nTabNo
];
384 ScViewData::ScViewData( const ScViewData
& rViewData
)
385 : pDocShell ( rViewData
.pDocShell
),
386 pDoc ( rViewData
.pDoc
),
387 pView ( rViewData
.pView
),
388 pViewShell ( rViewData
.pViewShell
),
389 pOptions ( new ScViewOptions( *(rViewData
.pOptions
) ) ),
390 pSpellingView ( rViewData
.pSpellingView
),
391 aLogicMode ( rViewData
.aLogicMode
),
392 eDefZoomType( rViewData
.eDefZoomType
),
393 aDefZoomX ( rViewData
.aDefZoomX
),
394 aDefZoomY ( rViewData
.aDefZoomY
),
395 aDefPageZoomX( rViewData
.aDefPageZoomX
),
396 aDefPageZoomY( rViewData
.aDefPageZoomY
),
397 eRefType ( SC_REFTYPE_NONE
),
398 nTabNo ( rViewData
.nTabNo
),
399 nRefTabNo ( rViewData
.nTabNo
), // kein RefMode
400 eEditActivePart( rViewData
.eEditActivePart
),
401 bActive ( TRUE
), //! wie initialisieren?
402 bIsRefMode ( FALSE
),
403 bDelMarkValid( FALSE
),
404 nFillMode ( SC_FILL_NONE
),
405 bPagebreak ( rViewData
.bPagebreak
),
406 bSelCtrlMouseClick( rViewData
.bSelCtrlMouseClick
)
409 SetGridMode ( rViewData
.IsGridMode() );
410 SetSyntaxMode ( rViewData
.IsSyntaxMode() );
411 SetHeaderMode ( rViewData
.IsHeaderMode() );
412 SetTabMode ( rViewData
.IsTabMode() );
413 SetVScrollMode ( rViewData
.IsVScrollMode() );
414 SetHScrollMode ( rViewData
.IsHScrollMode() );
415 SetOutlineMode ( rViewData
.IsOutlineMode() );
417 aScrSize
= rViewData
.aScrSize
;
418 for ( SCTAB i
= 0; i
<= MAXTAB
; i
++ )
419 if (rViewData
.pTabData
[i
])
420 pTabData
[i
] = new ScViewDataTable( *rViewData
.pTabData
[i
] );
423 pThisTab
= pTabData
[nTabNo
];
424 for (USHORT j
=0; j
<4; j
++)
427 bEditActive
[j
] = FALSE
;
430 nEditEndCol
= nEditStartCol
= nEditCol
= 0;
431 nEditEndRow
= nEditRow
= 0;
432 nTabStartCol
= SC_TABSTART_NONE
;
436 void ScViewData::InitData( ScDocument
* pDocument
)
439 *pOptions
= pDoc
->GetViewOptions();
442 //UNUSED2008-05 void ScViewData::InitFrom( const ScViewData* pRef )
444 //UNUSED2008-05 if (pRef==NULL)
446 //UNUSED2008-05 DBG_ERROR("ScViewData::InitFrom mit NULL");
447 //UNUSED2008-05 return;
450 //UNUSED2008-05 aScrSize = pRef->aScrSize;
451 //UNUSED2008-05 nTabNo = pRef->nTabNo;
452 //UNUSED2008-05 eDefZoomType = pRef->eDefZoomType;
453 //UNUSED2008-05 aDefZoomX = pRef->aDefZoomX;
454 //UNUSED2008-05 aDefZoomY = pRef->aDefZoomY;
455 //UNUSED2008-05 aDefPageZoomX = pRef->aDefPageZoomX;
456 //UNUSED2008-05 aDefPageZoomY = pRef->aDefPageZoomY;
457 //UNUSED2008-05 bPagebreak = pRef->bPagebreak;
458 //UNUSED2008-05 nPasteFlags = pRef->nPasteFlags;
459 //UNUSED2008-05 aLogicMode = pRef->aLogicMode;
461 //UNUSED2008-05 SetGridMode ( pRef->IsGridMode() );
462 //UNUSED2008-05 SetSyntaxMode ( pRef->IsSyntaxMode() );
463 //UNUSED2008-05 SetHeaderMode ( pRef->IsHeaderMode() );
464 //UNUSED2008-05 SetTabMode ( pRef->IsTabMode() );
465 //UNUSED2008-05 SetVScrollMode ( pRef->IsVScrollMode() );
466 //UNUSED2008-05 SetHScrollMode ( pRef->IsHScrollMode() );
467 //UNUSED2008-05 SetOutlineMode ( pRef->IsOutlineMode() );
469 //UNUSED2008-05 for (SCTAB i=0; i<=MAXTAB; i++)
471 //UNUSED2008-05 delete pTabData[i];
472 //UNUSED2008-05 if (pRef->pTabData[i])
473 //UNUSED2008-05 pTabData[i] = new ScViewDataTable( *pRef->pTabData[i] );
475 //UNUSED2008-05 pTabData[i] = NULL;
477 //UNUSED2008-05 pThisTab = pTabData[nTabNo];
478 //UNUSED2008-05 CalcPPT();
481 //UNUSED2008-05 void ScViewData::SetDocShell( ScDocShell* pShell )
483 //UNUSED2008-05 pDocShell = pShell;
484 //UNUSED2008-05 pDoc = pDocShell->GetDocument();
485 //UNUSED2008-05 *pOptions = pDoc->GetViewOptions();
486 //UNUSED2008-05 CalcPPT();
489 ScDocument
* ScViewData::GetDocument() const
494 return pDocShell
->GetDocument();
496 DBG_ERROR("kein Document an ViewData");
500 ScViewData::~ScViewData()
502 for (SCTAB i
=0; i
<=MAXTAB
; i
++)
510 void ScViewData::UpdateThis()
514 pThisTab
= pTabData
[nTabNo
];
520 pThisTab
= pTabData
[0] = new ScViewDataTable
;
522 // hier keine Assertion, weil sonst Paints kommen, bevor alles initialisiert ist!
528 void ScViewData::InsertTab( SCTAB nTab
)
530 delete pTabData
[MAXTAB
];
532 for (SCTAB i
=MAXTAB
; i
>nTab
; i
--)
533 pTabData
[i
] = pTabData
[i
-1];
535 pTabData
[nTab
] = NULL
; // force creating new
536 CreateTabData( nTab
);
539 aMarkData
.InsertTab( nTab
);
542 void ScViewData::DeleteTab( SCTAB nTab
)
544 delete pTabData
[nTab
];
546 for (SCTAB i
=nTab
; i
<MAXTAB
; i
++)
547 pTabData
[i
] = pTabData
[i
+1];
549 pTabData
[MAXTAB
] = NULL
;
552 aMarkData
.DeleteTab( nTab
);
555 void ScViewData::CopyTab( SCTAB nSrcTab
, SCTAB nDestTab
)
557 if (nDestTab
==SC_TAB_APPEND
)
558 nDestTab
= pDoc
->GetTableCount() - 1; // am Doc muss vorher kopiert worden sein
560 if (nDestTab
> MAXTAB
)
562 DBG_ERROR("Zuviele Tabellen");
566 delete pTabData
[MAXTAB
];
568 for (SCTAB i
=MAXTAB
; i
>nDestTab
; i
--)
569 pTabData
[i
] = pTabData
[i
-1];
571 if ( pTabData
[nSrcTab
] )
572 pTabData
[nDestTab
] = new ScViewDataTable( *pTabData
[nSrcTab
] );
574 pTabData
[nDestTab
] = NULL
;
577 aMarkData
.InsertTab( nDestTab
);
580 void ScViewData::MoveTab( SCTAB nSrcTab
, SCTAB nDestTab
)
582 if (nDestTab
==SC_TAB_APPEND
)
583 nDestTab
= pDoc
->GetTableCount() - 1;
586 ScViewDataTable
* pTab
= pTabData
[nSrcTab
];
588 SCTAB nInsTab
= nDestTab
;
589 if ( nSrcTab
< nDestTab
)
592 for (i
=nSrcTab
; i
<nDestTab
; i
++)
593 pTabData
[i
] = pTabData
[i
+1];
596 for (i
=nSrcTab
; i
>nDestTab
; i
--)
597 pTabData
[i
] = pTabData
[i
-1];
599 pTabData
[nDestTab
] = pTab
;
602 aMarkData
.DeleteTab( nSrcTab
);
603 aMarkData
.InsertTab( nInsTab
); // ggf. angepasst
606 void ScViewData::SetTabBgColor( Color rTabBgColor
, SCTAB nTab
)
608 if ( rTabBgColor
!= Color(COL_AUTO
) )
610 if ( !pTabData
[nTab
] )
611 CreateTabData( nTab
);
612 pTabData
[nTab
]->aTabBgColor
= rTabBgColor
;
616 if ( pTabData
[nTab
] )
617 pTabData
[nTab
]->aTabBgColor
= Color( COL_AUTO
);
621 Color
ScViewData::GetTabBgColor( SCTAB nTab
) const
623 if ( !pTabData
[nTab
] )
624 return Color(COL_AUTO
);
625 return pTabData
[nTab
]->aTabBgColor
;
628 BOOL
ScViewData::IsDefaultTabBgColor( SCTAB nTab
) const
630 if ( !pTabData
[nTab
] )
632 BOOL bResult
= pTabData
[nTab
]->aTabBgColor
==Color( COL_AUTO
) ? TRUE
: FALSE
;
636 //UNUSED2008-05 void ScViewData::UpdateOle( ScSplitPos /* eWhich */ )
638 //UNUSED2008-05 GetDocShell()->UpdateOle(this);
641 void ScViewData::SetViewShell( ScTabViewShell
* pViewSh
)
645 pViewShell
= pViewSh
;
654 void ScViewData::CreateTabData( std::vector
< SCTAB
>& rvTabs
)
656 std::vector
< SCTAB
>::iterator it_end
= rvTabs
.end();
657 for ( std::vector
< SCTAB
>::iterator it
= rvTabs
.begin(); it
!= it_end
; ++it
)
658 if ( !pTabData
[*it
] )
659 CreateTabData( *it
);
662 void ScViewData::SetZoomType( SvxZoomType eNew
, std::vector
< SCTAB
>& tabs
)
664 BOOL bAll
= ( tabs
.size() == 0 );
666 if ( !bAll
) // create associated table data
667 CreateTabData( tabs
);
669 std::vector
< SCTAB
>::iterator it_end
= tabs
.end();
670 std::vector
< SCTAB
>::iterator it
= tabs
.begin();
671 for ( SCTAB i
= ( bAll
? 0 : *it
); ( bAll
? i
<= MAXTAB
: it
!= it_end
); ++i
, ++it
)
674 pTabData
[i
]->eZoomType
= eNew
;
681 void ScViewData::SetZoomType( SvxZoomType eNew
, BOOL bAll
)
683 std::vector
< SCTAB
> vTabs
; // Empty for all tabs
684 if ( !bAll
) // get selected tabs
686 SCTAB nTabCount
= pDoc
->GetTableCount();
687 for (SCTAB i
=0; i
<nTabCount
; i
++)
689 if ( aMarkData
.GetTableSelect(i
) )
690 vTabs
.push_back( i
);
693 SetZoomType( eNew
, vTabs
);
696 void ScViewData::SetZoom( const Fraction
& rNewX
, const Fraction
& rNewY
, std::vector
< SCTAB
>& tabs
)
698 BOOL bAll
= ( tabs
.size() == 0 );
699 if ( !bAll
) // create associated table data
700 CreateTabData( tabs
);
701 Fraction
aFrac20( 1,5 );
702 Fraction
aFrac400( 4,1 );
704 Fraction aValidX
= rNewX
;
707 if (aValidX
>aFrac400
)
710 Fraction aValidY
= rNewY
;
713 if (aValidY
>aFrac400
)
716 std::vector
< SCTAB
>::iterator it_end
= tabs
.end();
717 std::vector
< SCTAB
>::iterator it
= tabs
.begin();
719 for ( SCTAB i
= ( bAll
? 0 : *it
); ( bAll
? i
<= MAXTAB
: it
!= it_end
); ++i
, ++it
)
725 pTabData
[i
]->aPageZoomX
= aValidX
;
726 pTabData
[i
]->aPageZoomY
= aValidY
;
730 pTabData
[i
]->aZoomX
= aValidX
;
731 pTabData
[i
]->aZoomY
= aValidY
;
738 void ScViewData::SetZoom( const Fraction
& rNewX
, const Fraction
& rNewY
, BOOL bAll
)
740 std::vector
< SCTAB
> vTabs
;
741 if ( !bAll
) // get selected tabs
743 SCTAB nTabCount
= pDoc
->GetTableCount();
744 for (SCTAB i
=0; i
<nTabCount
; i
++)
746 if ( aMarkData
.GetTableSelect(i
) )
747 vTabs
.push_back( i
);
750 SetZoom( rNewX
, rNewY
, vTabs
);
753 void ScViewData::SetShowGrid( bool bShow
)
755 CreateSelectedTabData();
756 pTabData
[nTabNo
]->bShowGrid
= bShow
;
759 void ScViewData::RefreshZoom()
761 // recalculate zoom-dependent values (only for current sheet)
765 aScenButSize
= Size(0,0);
766 aLogicMode
.SetScaleX( GetZoomX() );
767 aLogicMode
.SetScaleY( GetZoomY() );
770 void ScViewData::MoveNextRow()
773 aMarkData
.GetMarkArea(aMarkRange
);
774 aMarkRange
.aStart
.Set(aMarkRange
.aStart
.Col(), aMarkRange
.aStart
.Row() +1, aMarkRange
.aStart
.Tab());
775 aMarkData
.SetMarkArea(aMarkRange
);
778 void ScViewData::MovePrevRow()
781 aMarkData
.GetMarkArea(aMarkRange
);
782 aMarkRange
.aStart
.Set(aMarkRange
.aStart
.Col(), aMarkRange
.aStart
.Row() -1, aMarkRange
.aStart
.Tab());
783 aMarkData
.SetMarkArea(aMarkRange
);
786 void ScViewData::SetPagebreakMode( BOOL bSet
)
794 ScMarkType
ScViewData::GetSimpleArea( ScRange
& rRange
, ScMarkData
& rNewMark
) const
796 ScMarkType eMarkType
= SC_MARK_NONE
;
798 if ( rNewMark
.IsMarked() || rNewMark
.IsMultiMarked() )
800 if ( rNewMark
.IsMultiMarked() )
801 rNewMark
.MarkToSimple();
803 if ( rNewMark
.IsMarked() && !rNewMark
.IsMultiMarked() )
805 rNewMark
.GetMarkArea( rRange
);
806 if (ScViewUtil::HasFiltered( rRange
, GetDocument()))
807 eMarkType
= SC_MARK_SIMPLE_FILTERED
;
809 eMarkType
= SC_MARK_SIMPLE
;
812 eMarkType
= SC_MARK_MULTI
;
814 if (eMarkType
!= SC_MARK_SIMPLE
&& eMarkType
!= SC_MARK_SIMPLE_FILTERED
)
816 if (eMarkType
== SC_MARK_NONE
)
817 eMarkType
= SC_MARK_SIMPLE
;
818 rRange
= ScRange( GetCurX(), GetCurY(), GetTabNo() );
824 ScMarkType
ScViewData::GetSimpleArea( SCCOL
& rStartCol
, SCROW
& rStartRow
, SCTAB
& rStartTab
,
825 SCCOL
& rEndCol
, SCROW
& rEndRow
, SCTAB
& rEndTab
) const
827 // parameter bMergeMark is no longer needed: The view's selection is never modified
828 // (a local copy is used), and a multi selection that adds to a single range can always
829 // be treated like a single selection (#108266# - GetSimpleArea isn't used in selection
833 ScMarkData
aNewMark( aMarkData
); // use a local copy for MarkToSimple
834 ScMarkType eMarkType
= GetSimpleArea( aRange
, aNewMark
);
835 aRange
.GetVars( rStartCol
, rStartRow
, rStartTab
, rEndCol
, rEndRow
, rEndTab
);
839 ScMarkType
ScViewData::GetSimpleArea( ScRange
& rRange
) const
841 // parameter bMergeMark is no longer needed, see above
843 ScMarkData
aNewMark( aMarkData
); // use a local copy for MarkToSimple
844 return GetSimpleArea( rRange
, aNewMark
);
847 void ScViewData::GetMultiArea( ScRangeListRef
& rRange
) const
849 // parameter bMergeMark is no longer needed, see GetSimpleArea
851 ScMarkData
aNewMark( aMarkData
); // use a local copy for MarkToSimple
853 BOOL bMulti
= aNewMark
.IsMultiMarked();
856 aNewMark
.MarkToSimple();
857 bMulti
= aNewMark
.IsMultiMarked();
861 rRange
= new ScRangeList
;
862 aNewMark
.FillRangeListWithMarks( rRange
, FALSE
);
867 GetSimpleArea(aSimple
);
868 rRange
= new ScRangeList
;
869 rRange
->Append(aSimple
);
873 BOOL
ScViewData::SimpleColMarked()
881 if (GetSimpleArea(nStartCol
,nStartRow
,nStartTab
,nEndCol
,nEndRow
,nEndTab
) == SC_MARK_SIMPLE
)
882 if (nStartRow
==0 && nEndRow
==MAXROW
)
888 BOOL
ScViewData::SimpleRowMarked()
896 if (GetSimpleArea(nStartCol
,nStartRow
,nStartTab
,nEndCol
,nEndRow
,nEndTab
) == SC_MARK_SIMPLE
)
897 if (nStartCol
==0 && nEndCol
==MAXCOL
)
903 BOOL
ScViewData::IsMultiMarked()
905 // Test for "real" multi selection, calling MarkToSimple on a local copy,
906 // and taking filtered in simple area marks into account.
909 ScMarkType eType
= GetSimpleArea(aDummy
);
910 return (eType
& SC_MARK_SIMPLE
) != SC_MARK_SIMPLE
;
913 void ScViewData::SetFillMode( SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
)
915 nFillMode
= SC_FILL_FILL
;
916 nFillStartX
= nStartCol
;
917 nFillStartY
= nStartRow
;
922 void ScViewData::SetDragMode( SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
,
926 nFillStartX
= nStartCol
;
927 nFillStartY
= nStartRow
;
932 void ScViewData::ResetFillMode()
934 nFillMode
= SC_FILL_NONE
;
937 void ScViewData::GetFillData( SCCOL
& rStartCol
, SCROW
& rStartRow
,
938 SCCOL
& rEndCol
, SCROW
& rEndRow
)
940 rStartCol
= nFillStartX
;
941 rStartRow
= nFillStartY
;
946 SCCOL
ScViewData::GetOldCurX() const
948 if (pThisTab
->bOldCurValid
)
949 return pThisTab
->nOldCurX
;
951 return pThisTab
->nCurX
;
954 SCROW
ScViewData::GetOldCurY() const
956 if (pThisTab
->bOldCurValid
)
957 return pThisTab
->nOldCurY
;
959 return pThisTab
->nCurY
;
962 void ScViewData::SetOldCursor( SCCOL nNewX
, SCROW nNewY
)
964 pThisTab
->nOldCurX
= nNewX
;
965 pThisTab
->nOldCurY
= nNewY
;
966 pThisTab
->bOldCurValid
= TRUE
;
969 void ScViewData::ResetOldCursor()
971 pThisTab
->bOldCurValid
= FALSE
;
974 Rectangle
ScViewData::GetEditArea( ScSplitPos eWhich
, SCCOL nPosX
, SCROW nPosY
,
975 Window
* pWin
, const ScPatternAttr
* pPattern
,
978 return ScEditUtil( pDoc
, nPosX
, nPosY
, nTabNo
, GetScrPos(nPosX
,nPosY
,eWhich
,TRUE
),
979 pWin
, nPPTX
, nPPTY
, GetZoomX(), GetZoomY() ).
980 GetEditArea( pPattern
, bForceToTop
);
983 void ScViewData::SetEditEngine( ScSplitPos eWhich
,
984 ScEditEngineDefaulter
* pNewEngine
,
985 Window
* pWin
, SCCOL nNewX
, SCROW nNewY
)
987 BOOL bLayoutRTL
= pDoc
->IsLayoutRTL( nTabNo
);
988 ScHSplitPos eHWhich
= WhichH(eWhich
);
990 BOOL bWasThere
= FALSE
;
991 if (pEditView
[eWhich
])
993 // Wenn die View schon da ist, nichts aufrufen, was die Cursorposition aendert
995 if (bEditActive
[eWhich
])
998 pEditView
[eWhich
]->SetEditEngine(pNewEngine
);
1000 if (pEditView
[eWhich
]->GetWindow() != pWin
)
1002 pEditView
[eWhich
]->SetWindow(pWin
);
1003 DBG_ERROR("EditView Window geaendert");
1008 pEditView
[eWhich
] = new EditView( pNewEngine
, pWin
);
1011 // bei IdleFormat wird manchmal ein Cursor gemalt, wenn die View schon weg ist (23576)
1013 ULONG nEC
= pNewEngine
->GetControlWord();
1014 pNewEngine
->SetControlWord(nEC
& ~EE_CNTRL_DOIDLEFORMAT
);
1016 ULONG nVC
= pEditView
[eWhich
]->GetControlWord();
1017 pEditView
[eWhich
]->SetControlWord(nVC
& ~EV_CNTRL_AUTOSCROLL
);
1019 bEditActive
[eWhich
] = TRUE
;
1021 const ScPatternAttr
* pPattern
= pDoc
->GetPattern( nNewX
, nNewY
, nTabNo
);
1022 SvxCellHorJustify eJust
= (SvxCellHorJustify
)((const SvxHorJustifyItem
&)
1023 pPattern
->GetItem( ATTR_HOR_JUSTIFY
)).GetValue();
1025 BOOL bBreak
= ( eJust
== SVX_HOR_JUSTIFY_BLOCK
) ||
1026 ((SfxBoolItem
&)pPattern
->GetItem(ATTR_LINEBREAK
)).GetValue();
1028 BOOL bAsianVertical
= pNewEngine
->IsVertical(); // set by InputHandler
1030 Rectangle aPixRect
= ScEditUtil( pDoc
, nNewX
,nNewY
,nTabNo
, GetScrPos(nNewX
,nNewY
,eWhich
),
1031 pWin
, nPPTX
,nPPTY
,GetZoomX(),GetZoomY() ).
1032 GetEditArea( pPattern
, TRUE
);
1034 // when right-aligned, leave space for the cursor
1035 // in vertical mode, editing is always right-aligned
1036 if ( nEditAdjust
== SVX_ADJUST_RIGHT
|| bAsianVertical
)
1037 aPixRect
.Right() += 1;
1039 Rectangle aOutputArea
= pWin
->PixelToLogic( aPixRect
, GetLogicMode() );
1040 pEditView
[eWhich
]->SetOutputArea( aOutputArea
);
1042 if ( bActive
&& eWhich
== GetActivePart() )
1044 // keep the part that has the active edit view available after
1045 // switching sheets or reference input on a different part
1046 eEditActivePart
= eWhich
;
1048 // modify members nEditCol etc. only if also extending for needed area
1051 const ScMergeAttr
* pMergeAttr
= (ScMergeAttr
*)&pPattern
->GetItem(ATTR_MERGE
);
1052 nEditEndCol
= nEditCol
;
1053 if (pMergeAttr
->GetColMerge() > 1)
1054 nEditEndCol
+= pMergeAttr
->GetColMerge() - 1;
1055 nEditEndRow
= nEditRow
;
1056 if (pMergeAttr
->GetRowMerge() > 1)
1057 nEditEndRow
+= pMergeAttr
->GetRowMerge() - 1;
1058 nEditStartCol
= nEditCol
;
1060 // For growing use only the alignment value from the attribute, numbers
1061 // (existing or started) with default aligment extend to the right.
1062 BOOL bGrowCentered
= ( eJust
== SVX_HOR_JUSTIFY_CENTER
);
1063 BOOL bGrowToLeft
= ( eJust
== SVX_HOR_JUSTIFY_RIGHT
); // visual left
1064 BOOL bGrowBackwards
= bGrowToLeft
; // logical left
1066 bGrowBackwards
= !bGrowBackwards
; // invert on RTL sheet
1067 if ( bAsianVertical
)
1068 bGrowCentered
= bGrowToLeft
= bGrowBackwards
= FALSE
; // keep old behavior for asian mode
1071 if (bBreak
&& !bAsianVertical
)
1072 nSizeXPix
= aPixRect
.GetWidth(); // Papersize -> kein H-Scrolling
1075 DBG_ASSERT(pView
,"keine View fuer EditView");
1077 if ( bGrowCentered
)
1079 // growing into both directions until one edge is reached
1080 //! should be limited to whole cells in both directions
1081 long nLeft
= aPixRect
.Left();
1082 long nRight
= pView
->GetGridWidth(eHWhich
) - aPixRect
.Right();
1083 nSizeXPix
= aPixRect
.GetWidth() + 2 * Min( nLeft
, nRight
);
1085 else if ( bGrowToLeft
)
1086 nSizeXPix
= aPixRect
.Right(); // space that's available in the window when growing to the left
1088 nSizeXPix
= pView
->GetGridWidth(eHWhich
) - aPixRect
.Left();
1090 if ( nSizeXPix
<= 0 )
1091 nSizeXPix
= aPixRect
.GetWidth(); // editing outside to the right of the window -> keep cell width
1093 DBG_ASSERT(pView
,"keine View fuer EditView");
1094 long nSizeYPix
= pView
->GetGridHeight(WhichV(eWhich
)) - aPixRect
.Top();
1095 if ( nSizeYPix
<= 0 )
1096 nSizeYPix
= aPixRect
.GetHeight(); // editing outside below the window -> keep cell height
1098 Size aPaperSize
= pView
->GetActiveWin()->PixelToLogic( Size( nSizeXPix
, nSizeYPix
), GetLogicMode() );
1099 if ( bBreak
&& !bAsianVertical
&& SC_MOD()->GetInputOptions().GetTextWysiwyg() )
1101 // #95593# if text is formatted for printer, use the exact same paper width
1102 // (and same line breaks) as for output.
1104 Fraction
aFract(1,1);
1105 Rectangle aUtilRect
= ScEditUtil( pDoc
,nNewX
,nNewY
,nTabNo
, Point(0,0), pWin
,
1106 HMM_PER_TWIPS
, HMM_PER_TWIPS
, aFract
, aFract
).GetEditArea( pPattern
, FALSE
);
1107 aPaperSize
.Width() = aUtilRect
.GetWidth();
1109 pNewEngine
->SetPaperSize( aPaperSize
);
1111 // sichtbarer Ausschnitt
1112 Size aPaper
= pNewEngine
->GetPaperSize();
1113 Rectangle aVis
= pEditView
[eWhich
]->GetVisArea();
1114 long nDiff
= aVis
.Right() - aVis
.Left();
1115 if ( nEditAdjust
== SVX_ADJUST_RIGHT
)
1117 aVis
.Right() = aPaper
.Width() - 1;
1118 bMoveArea
= !bLayoutRTL
;
1120 else if ( nEditAdjust
== SVX_ADJUST_CENTER
)
1122 aVis
.Right() = ( aPaper
.Width() - 1 + nDiff
) / 2;
1123 bMoveArea
= TRUE
; // always
1127 aVis
.Right() = nDiff
;
1128 bMoveArea
= bLayoutRTL
;
1130 aVis
.Left() = aVis
.Right() - nDiff
;
1131 // --> OD 2005-12-22 #i49561#
1133 // The set offset of the visible area of the EditView for centered and
1134 // right alignment in horizontal layout is consider by instances of
1135 // class <ScEditObjectViewForwarder> in its methods <LogicToPixel(..)>
1136 // and <PixelToLogic(..)>. This is needed for the correct visibility
1137 // of paragraphs in edit mode at the accessibility API.
1139 pEditView
[eWhich
]->SetVisArea(aVis
);
1142 // UpdateMode has been disabled in ScInputHandler::StartTable
1143 // must be enabled before EditGrowY (GetTextHeight)
1144 pNewEngine
->SetUpdateMode( TRUE
);
1146 pNewEngine
->SetStatusEventHdl( LINK( this, ScViewData
, EditEngineHdl
) );
1148 EditGrowY( TRUE
); // adjust to existing text content
1151 Point aDocPos
= pEditView
[eWhich
]->GetWindowPosTopLeft(0);
1152 if (aDocPos
.Y() < aOutputArea
.Top())
1153 pEditView
[eWhich
]->Scroll( 0, aOutputArea
.Top() - aDocPos
.Y() );
1155 //! Status (Event) zuruecksetzen
1158 // hier muss bEditActive schon gesetzt sein
1159 // (wegen Map-Mode bei Paint)
1161 pNewEngine
->InsertView(pEditView
[eWhich
]);
1163 // Hintergrundfarbe der Zelle
1164 Color aBackCol
= ((const SvxBrushItem
&)pPattern
->GetItem(ATTR_BACKGROUND
)).GetColor();
1166 ScModule
* pScMod
= SC_MOD();
1167 // #105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed TRUE)
1168 if ( aBackCol
.GetTransparency() > 0 ||
1169 Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
1171 aBackCol
.SetColor( pScMod
->GetColorConfig().GetColorValue(svtools::DOCCOLOR
).nColor
);
1173 pEditView
[eWhich
]->SetBackgroundColor( aBackCol
);
1175 pEditView
[eWhich
]->Invalidate(); // noetig ??
1176 // noetig, wenn Position geaendert
1179 IMPL_LINK_INLINE_START( ScViewData
, EmptyEditHdl
, EditStatus
*, EMPTYARG
)
1183 IMPL_LINK_INLINE_END( ScViewData
, EmptyEditHdl
, EditStatus
*, EMPTYARG
)
1185 IMPL_LINK( ScViewData
, EditEngineHdl
, EditStatus
*, pStatus
)
1187 ULONG nStatus
= pStatus
->GetStatusWord();
1188 if (nStatus
& (EE_STAT_HSCROLL
| EE_STAT_TEXTHEIGHTCHANGED
| EE_STAT_TEXTWIDTHCHANGED
| EE_STAT_CURSOROUT
))
1193 if (nStatus
& EE_STAT_CURSOROUT
)
1195 ScSplitPos eWhich
= GetActivePart();
1196 if (pEditView
[eWhich
])
1197 pEditView
[eWhich
]->ShowCursor(FALSE
);
1203 void ScViewData::EditGrowX()
1205 ScDocument
* pLocalDoc
= GetDocument();
1207 ScSplitPos eWhich
= GetActivePart();
1208 ScHSplitPos eHWhich
= WhichH(eWhich
);
1209 EditView
* pCurView
= pEditView
[eWhich
];
1211 if ( !pCurView
|| !bEditActive
[eWhich
])
1214 BOOL bLayoutRTL
= pLocalDoc
->IsLayoutRTL( nTabNo
);
1216 ScEditEngineDefaulter
* pEngine
=
1217 (ScEditEngineDefaulter
*) pCurView
->GetEditEngine();
1218 Window
* pWin
= pCurView
->GetWindow();
1220 SCCOL nLeft
= GetPosX(eHWhich
);
1221 SCCOL nRight
= nLeft
+ VisibleCellsX(eHWhich
);
1223 Size aSize
= pEngine
->GetPaperSize();
1224 Rectangle aArea
= pCurView
->GetOutputArea();
1225 long nOldRight
= aArea
.Right();
1227 // Margin ist schon bei der urspruenglichen Breite beruecksichtigt
1228 long nTextWidth
= pEngine
->CalcTextWidth();
1230 BOOL bChanged
= FALSE
;
1231 BOOL bAsianVertical
= pEngine
->IsVertical();
1233 // get bGrow... variables the same way as in SetEditEngine
1234 const ScPatternAttr
* pPattern
= pLocalDoc
->GetPattern( nEditCol
, nEditRow
, nTabNo
);
1235 SvxCellHorJustify eJust
= (SvxCellHorJustify
)((const SvxHorJustifyItem
&)
1236 pPattern
->GetItem( ATTR_HOR_JUSTIFY
)).GetValue();
1237 BOOL bGrowCentered
= ( eJust
== SVX_HOR_JUSTIFY_CENTER
);
1238 BOOL bGrowToLeft
= ( eJust
== SVX_HOR_JUSTIFY_RIGHT
); // visual left
1239 BOOL bGrowBackwards
= bGrowToLeft
; // logical left
1241 bGrowBackwards
= !bGrowBackwards
; // invert on RTL sheet
1242 if ( bAsianVertical
)
1243 bGrowCentered
= bGrowToLeft
= bGrowBackwards
= FALSE
; // keep old behavior for asian mode
1245 BOOL bUnevenGrow
= FALSE
;
1246 if ( bGrowCentered
)
1248 while (aArea
.GetWidth() + 0 < nTextWidth
&& ( nEditStartCol
> nLeft
|| nEditEndCol
< nRight
) )
1250 long nLogicLeft
= 0;
1251 if ( nEditStartCol
> nLeft
)
1254 long nLeftPix
= ToPixel( pLocalDoc
->GetColWidth( nEditStartCol
, nTabNo
), nPPTX
);
1255 nLogicLeft
= pWin
->PixelToLogic(Size(nLeftPix
,0)).Width();
1257 long nLogicRight
= 0;
1258 if ( nEditEndCol
< nRight
)
1261 long nRightPix
= ToPixel( pLocalDoc
->GetColWidth( nEditEndCol
, nTabNo
), nPPTX
);
1262 nLogicRight
= pWin
->PixelToLogic(Size(nRightPix
,0)).Width();
1265 aArea
.Left() -= bLayoutRTL
? nLogicRight
: nLogicLeft
;
1266 aArea
.Right() += bLayoutRTL
? nLogicLeft
: nLogicRight
;
1268 if ( aArea
.Right() > aArea
.Left() + aSize
.Width() - 1 )
1270 long nCenter
= ( aArea
.Left() + aArea
.Right() ) / 2;
1271 long nHalf
= aSize
.Width() / 2;
1272 aArea
.Left() = nCenter
- nHalf
+ 1;
1273 aArea
.Right() = nCenter
+ aSize
.Width() - nHalf
- 1;
1277 if ( nLogicLeft
!= nLogicRight
)
1281 else if ( bGrowBackwards
)
1283 while (aArea
.GetWidth() + 0 < nTextWidth
&& nEditStartCol
> nLeft
)
1286 long nPix
= ToPixel( pLocalDoc
->GetColWidth( nEditStartCol
, nTabNo
), nPPTX
);
1287 long nLogicWidth
= pWin
->PixelToLogic(Size(nPix
,0)).Width();
1289 aArea
.Left() -= nLogicWidth
;
1291 aArea
.Right() += nLogicWidth
;
1293 if ( aArea
.Right() > aArea
.Left() + aSize
.Width() - 1 )
1296 aArea
.Left() = aArea
.Right() - aSize
.Width() + 1;
1298 aArea
.Right() = aArea
.Left() + aSize
.Width() - 1;
1306 while (aArea
.GetWidth() + 0 < nTextWidth
&& nEditEndCol
< nRight
)
1309 long nPix
= ToPixel( pLocalDoc
->GetColWidth( nEditEndCol
, nTabNo
), nPPTX
);
1310 long nLogicWidth
= pWin
->PixelToLogic(Size(nPix
,0)).Width();
1312 aArea
.Left() -= nLogicWidth
;
1314 aArea
.Right() += nLogicWidth
;
1316 if ( aArea
.Right() > aArea
.Left() + aSize
.Width() - 1 )
1319 aArea
.Left() = aArea
.Right() - aSize
.Width() + 1;
1321 aArea
.Right() = aArea
.Left() + aSize
.Width() - 1;
1330 if ( bMoveArea
|| bGrowCentered
|| bGrowBackwards
|| bLayoutRTL
)
1332 Rectangle aVis
= pCurView
->GetVisArea();
1334 if ( bGrowCentered
)
1336 // switch to center-aligned (undo?) and reset VisArea to center
1338 pEngine
->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_CENTER
, EE_PARA_JUST
) );
1340 long nCenter
= aSize
.Width() / 2;
1341 long nVisSize
= aArea
.GetWidth();
1342 aVis
.Left() = nCenter
- nVisSize
/ 2;
1343 aVis
.Right() = aVis
.Left() + nVisSize
- 1;
1345 else if ( bGrowToLeft
)
1347 // switch to right-aligned (undo?) and reset VisArea to the right
1349 pEngine
->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_RIGHT
, EE_PARA_JUST
) );
1351 aVis
.Right() = aSize
.Width() - 1;
1352 aVis
.Left() = aSize
.Width() - aArea
.GetWidth(); // with the new, increased area
1356 // switch to left-aligned (undo?) and reset VisArea to the left
1358 pEngine
->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_LEFT
, EE_PARA_JUST
) );
1360 long nMove
= aVis
.Left();
1362 aVis
.Right() -= nMove
;
1364 pCurView
->SetVisArea( aVis
);
1368 pCurView
->SetOutputArea(aArea
);
1370 // In vertical mode, the whole text is moved to the next cell (right-aligned),
1371 // so everything must be repainted. Otherwise, paint only the new area.
1372 // If growing in centered alignment, if the cells left and right have different sizes,
1373 // the whole text will move, and may not even obscure all of the original display.
1376 aArea
.Left() = pWin
->PixelToLogic( Point(0,0) ).X();
1377 aArea
.Right() = pWin
->PixelToLogic( aScrSize
).Width();
1379 else if ( !bAsianVertical
&& !bGrowToLeft
&& !bGrowCentered
)
1380 aArea
.Left() = nOldRight
;
1381 pWin
->Invalidate(aArea
);
1385 void ScViewData::EditGrowY( BOOL bInitial
)
1387 ScSplitPos eWhich
= GetActivePart();
1388 ScVSplitPos eVWhich
= WhichV(eWhich
);
1389 EditView
* pCurView
= pEditView
[eWhich
];
1391 if ( !pCurView
|| !bEditActive
[eWhich
])
1394 ULONG nControl
= pEditView
[eWhich
]->GetControlWord();
1395 if ( nControl
& EV_CNTRL_AUTOSCROLL
)
1397 // if end of screen had already been reached and scrolling enabled,
1398 // don't further try to grow the edit area
1400 pCurView
->SetOutputArea( pCurView
->GetOutputArea() ); // re-align to pixels
1404 EditEngine
* pEngine
= pCurView
->GetEditEngine();
1405 Window
* pWin
= pCurView
->GetWindow();
1407 SCROW nBottom
= GetPosY(eVWhich
) + VisibleCellsY(eVWhich
);
1409 Size aSize
= pEngine
->GetPaperSize();
1410 Rectangle aArea
= pCurView
->GetOutputArea();
1411 long nOldBottom
= aArea
.Bottom();
1412 long nTextHeight
= pEngine
->GetTextHeight();
1414 // #106635# When editing a formula in a cell with optimal height, allow a larger portion
1415 // to be clipped before extending to following rows, to avoid obscuring cells for
1416 // reference input (next row is likely to be useful in formulas).
1417 long nAllowedExtra
= SC_GROWY_SMALL_EXTRA
;
1418 if ( nEditEndRow
== nEditRow
&& !( pDoc
->GetRowFlags( nEditRow
, nTabNo
) & CR_MANUALSIZE
) &&
1419 pEngine
->GetParagraphCount() <= 1 )
1421 // If the (only) paragraph starts with a '=', it's a formula.
1422 // If this is the initial call and the text is empty, allow the larger value, too,
1423 // because this occurs in the normal progress of editing a formula.
1424 // Subsequent calls with empty text might involve changed attributes (including
1425 // font height), so they are treated like normal text.
1426 String aText
= pEngine
->GetText( (USHORT
) 0 );
1427 if ( ( aText
.Len() == 0 && bInitial
) || aText
.GetChar(0) == (sal_Unicode
)'=' )
1428 nAllowedExtra
= SC_GROWY_BIG_EXTRA
;
1431 BOOL bChanged
= FALSE
;
1432 BOOL bMaxReached
= FALSE
;
1433 while (aArea
.GetHeight() + nAllowedExtra
< nTextHeight
&& nEditEndRow
< nBottom
&& !bMaxReached
)
1436 ScDocument
* pLocalDoc
= GetDocument();
1437 long nPix
= ToPixel( pLocalDoc
->GetRowHeight( nEditEndRow
, nTabNo
), nPPTY
);
1438 aArea
.Bottom() += pWin
->PixelToLogic(Size(0,nPix
)).Height();
1440 if ( aArea
.Bottom() > aArea
.Top() + aSize
.Height() - 1 )
1442 aArea
.Bottom() = aArea
.Top() + aSize
.Height() - 1;
1443 bMaxReached
= TRUE
; // don't occupy more cells beyond paper size
1447 nAllowedExtra
= SC_GROWY_SMALL_EXTRA
; // larger value is only for first row
1452 pCurView
->SetOutputArea(aArea
);
1454 if (nEditEndRow
>= nBottom
|| bMaxReached
)
1456 if ((nControl
& EV_CNTRL_AUTOSCROLL
) == 0)
1457 pCurView
->SetControlWord( nControl
| EV_CNTRL_AUTOSCROLL
);
1460 aArea
.Top() = nOldBottom
;
1461 pWin
->Invalidate(aArea
);
1465 void ScViewData::ResetEditView()
1467 EditEngine
* pEngine
= NULL
;
1468 for (USHORT i
=0; i
<4; i
++)
1473 pEngine
= pEditView
[i
]->GetEditEngine();
1474 pEngine
->RemoveView(pEditView
[i
]);
1475 pEditView
[i
]->SetOutputArea( Rectangle() );
1477 bEditActive
[i
] = FALSE
;
1481 pEngine
->SetStatusEventHdl( LINK( this, ScViewData
, EmptyEditHdl
) );
1484 void ScViewData::KillEditView()
1486 for (USHORT i
=0; i
<4; i
++)
1490 pEditView
[i
]->GetEditEngine()->RemoveView(pEditView
[i
]);
1491 delete pEditView
[i
];
1492 pEditView
[i
] = NULL
;
1496 void ScViewData::GetEditView( ScSplitPos eWhich
, EditView
*& rViewPtr
, SCCOL
& rCol
, SCROW
& rRow
)
1498 rViewPtr
= pEditView
[eWhich
];
1503 void ScViewData::CreateTabData( SCTAB nNewTab
)
1505 if (!pTabData
[nNewTab
])
1507 pTabData
[nNewTab
] = new ScViewDataTable
;
1509 pTabData
[nNewTab
]->eZoomType
= eDefZoomType
;
1510 pTabData
[nNewTab
]->aZoomX
= aDefZoomX
;
1511 pTabData
[nNewTab
]->aZoomY
= aDefZoomY
;
1512 pTabData
[nNewTab
]->aPageZoomX
= aDefPageZoomX
;
1513 pTabData
[nNewTab
]->aPageZoomY
= aDefPageZoomY
;
1517 void ScViewData::CreateSelectedTabData()
1519 SCTAB nTabCount
= pDoc
->GetTableCount();
1520 for (SCTAB i
=0; i
<nTabCount
; i
++)
1521 if ( aMarkData
.GetTableSelect(i
) && !pTabData
[i
] )
1525 void ScViewData::SetTabNo( SCTAB nNewTab
)
1527 if (!ValidTab(nNewTab
))
1529 DBG_ERROR("falsche Tabellennummer");
1534 CreateTabData(nTabNo
);
1535 pThisTab
= pTabData
[nTabNo
];
1537 CalcPPT(); // for common column width correction
1538 RecalcPixPos(); //! nicht immer noetig!
1541 void ScViewData::SetActivePart( ScSplitPos eNewActive
)
1543 pThisTab
->eWhichActive
= eNewActive
;
1546 Point
ScViewData::GetScrPos( SCCOL nWhereX
, SCROW nWhereY
, ScHSplitPos eWhich
) const
1548 DBG_ASSERT( eWhich
==SC_SPLIT_LEFT
|| eWhich
==SC_SPLIT_RIGHT
, "Falsche Position" );
1549 ScSplitPos ePos
= ( eWhich
== SC_SPLIT_LEFT
) ? SC_SPLIT_BOTTOMLEFT
: SC_SPLIT_BOTTOMRIGHT
;
1550 return GetScrPos( nWhereX
, nWhereY
, ePos
);
1553 Point
ScViewData::GetScrPos( SCCOL nWhereX
, SCROW nWhereY
, ScVSplitPos eWhich
) const
1555 DBG_ASSERT( eWhich
==SC_SPLIT_TOP
|| eWhich
==SC_SPLIT_BOTTOM
, "Falsche Position" );
1556 ScSplitPos ePos
= ( eWhich
== SC_SPLIT_TOP
) ? SC_SPLIT_TOPLEFT
: SC_SPLIT_BOTTOMLEFT
;
1557 return GetScrPos( nWhereX
, nWhereY
, ePos
);
1560 Point
ScViewData::GetScrPos( SCCOL nWhereX
, SCROW nWhereY
, ScSplitPos eWhich
,
1561 BOOL bAllowNeg
) const
1563 ScHSplitPos eWhichX
= SC_SPLIT_LEFT
;
1564 ScVSplitPos eWhichY
= SC_SPLIT_BOTTOM
;
1567 case SC_SPLIT_TOPLEFT
:
1568 eWhichX
= SC_SPLIT_LEFT
;
1569 eWhichY
= SC_SPLIT_TOP
;
1571 case SC_SPLIT_TOPRIGHT
:
1572 eWhichX
= SC_SPLIT_RIGHT
;
1573 eWhichY
= SC_SPLIT_TOP
;
1575 case SC_SPLIT_BOTTOMLEFT
:
1576 eWhichX
= SC_SPLIT_LEFT
;
1577 eWhichY
= SC_SPLIT_BOTTOM
;
1579 case SC_SPLIT_BOTTOMRIGHT
:
1580 eWhichX
= SC_SPLIT_RIGHT
;
1581 eWhichY
= SC_SPLIT_BOTTOM
;
1587 ((ScViewData
*)this)->aScrSize
.Width() = pView
->GetGridWidth(eWhichX
);
1588 ((ScViewData
*)this)->aScrSize
.Height() = pView
->GetGridHeight(eWhichY
);
1593 SCCOL nPosX
= GetPosX(eWhichX
);
1597 if (nWhereX
>= nPosX
)
1598 for (nX
=nPosX
; nX
<nWhereX
&& (bAllowNeg
|| nScrPosX
<=aScrSize
.Width()); nX
++)
1604 nTSize
= pDoc
->GetColWidth( nX
, nTabNo
);
1607 long nSizeXPix
= ToPixel( nTSize
, nPPTX
);
1608 nScrPosX
+= nSizeXPix
;
1613 for (nX
=nPosX
; nX
>nWhereX
;)
1616 nTSize
= pDoc
->GetColWidth( nX
, nTabNo
);
1619 long nSizeXPix
= ToPixel( nTSize
, nPPTX
);
1620 nScrPosX
-= nSizeXPix
;
1624 SCROW nPosY
= GetPosY(eWhichY
);
1628 if (nWhereY
>= nPosY
)
1629 for (nY
=nPosY
; nY
<nWhereY
&& (bAllowNeg
|| nScrPosY
<=aScrSize
.Height()); nY
++)
1635 nTSize
= pDoc
->FastGetRowHeight( nY
, nTabNo
);
1638 long nSizeYPix
= ToPixel( nTSize
, nPPTY
);
1639 nScrPosY
+= nSizeYPix
;
1641 else if ( nY
< MAXROW
)
1643 // skip multiple hidden rows (forward only for now)
1644 SCROW nNext
= pDoc
->FirstVisibleRow(nY
+ 1, MAXROW
, nTabNo
);
1645 if ( nNext
> MAXROW
)
1648 nY
= nNext
- 1; // +=nDir advances to next visible row
1653 for (nY
=nPosY
; nY
>nWhereY
;)
1656 nTSize
= pDoc
->FastGetRowHeight( nY
, nTabNo
);
1659 long nSizeYPix
= ToPixel( nTSize
, nPPTY
);
1660 nScrPosY
-= nSizeYPix
;
1664 if ( pDoc
->IsLayoutRTL( nTabNo
) )
1666 // mirror horizontal position
1667 nScrPosX
= aScrSize
.Width() - 1 - nScrPosX
;
1670 if (nScrPosX
> 32767) nScrPosX
=32767;
1671 if (nScrPosY
> 32767) nScrPosY
=32767;
1672 return Point( nScrPosX
, nScrPosY
);
1676 // Anzahl Zellen auf einem Bildschirm
1679 SCCOL
ScViewData::CellsAtX( SCsCOL nPosX
, SCsCOL nDir
, ScHSplitPos eWhichX
, USHORT nScrSizeX
) const
1681 DBG_ASSERT( nDir
==1 || nDir
==-1, "falscher CellsAt Aufruf" );
1684 ((ScViewData
*)this)->aScrSize
.Width() = pView
->GetGridWidth(eWhichX
);
1687 USHORT nScrPosX
= 0;
1688 if (nScrSizeX
== SC_SIZE_NONE
) nScrSizeX
= (USHORT
) aScrSize
.Width();
1691 nX
= nPosX
; // vorwaerts
1693 nX
= nPosX
-1; // rueckwaerts
1696 for ( ; nScrPosX
<=nScrSizeX
&& !bOut
; nX
= sal::static_int_cast
<SCsCOL
>(nX
+ nDir
) )
1699 if ( nColNo
< 0 || nColNo
> MAXCOL
)
1703 USHORT nTSize
= pDoc
->GetColWidth( nColNo
, nTabNo
);
1706 long nSizeXPix
= ToPixel( nTSize
, nPPTX
);
1707 nScrPosX
= sal::static_int_cast
<USHORT
>( nScrPosX
+ (USHORT
) nSizeXPix
);
1713 nX
= sal::static_int_cast
<SCsCOL
>( nX
- nPosX
);
1721 SCROW
ScViewData::CellsAtY( SCsROW nPosY
, SCsROW nDir
, ScVSplitPos eWhichY
, USHORT nScrSizeY
) const
1723 DBG_ASSERT( nDir
==1 || nDir
==-1, "falscher CellsAt Aufruf" );
1726 ((ScViewData
*)this)->aScrSize
.Height() = pView
->GetGridHeight(eWhichY
);
1729 USHORT nScrPosY
= 0;
1731 if (nScrSizeY
== SC_SIZE_NONE
) nScrSizeY
= (USHORT
) aScrSize
.Height();
1734 nY
= nPosY
; // vorwaerts
1736 nY
= nPosY
-1; // rueckwaerts
1739 for ( ; nScrPosY
<=nScrSizeY
&& !bOut
; nY
+=nDir
)
1742 if ( nRowNo
< 0 || nRowNo
> MAXROW
)
1746 // USHORT nTSize = pDoc->GetRowHeight( nRowNo, nTabNo );
1747 USHORT nTSize
= pDoc
->FastGetRowHeight( nRowNo
, nTabNo
);
1750 long nSizeYPix
= ToPixel( nTSize
, nPPTY
);
1751 nScrPosY
= sal::static_int_cast
<USHORT
>( nScrPosY
+ (USHORT
) nSizeYPix
);
1753 else if ( nDir
== 1 && nRowNo
< MAXROW
)
1755 // skip multiple hidden rows (forward only for now)
1756 SCROW nNext
= pDoc
->FirstVisibleRow(nRowNo
+ 1, MAXROW
, nTabNo
);
1757 if ( nNext
> MAXROW
)
1759 // same behavior as without the optimization: set bOut with nY=MAXROW+1
1764 nY
= nNext
- 1; // +=nDir advances to next visible row
1778 SCCOL
ScViewData::VisibleCellsX( ScHSplitPos eWhichX
) const
1780 return CellsAtX( GetPosX( eWhichX
), 1, eWhichX
, SC_SIZE_NONE
);
1783 SCROW
ScViewData::VisibleCellsY( ScVSplitPos eWhichY
) const
1785 return CellsAtY( GetPosY( eWhichY
), 1, eWhichY
, SC_SIZE_NONE
);
1788 SCCOL
ScViewData::PrevCellsX( ScHSplitPos eWhichX
) const
1790 return CellsAtX( GetPosX( eWhichX
), -1, eWhichX
, SC_SIZE_NONE
);
1793 SCROW
ScViewData::PrevCellsY( ScVSplitPos eWhichY
) const
1795 return CellsAtY( GetPosY( eWhichY
), -1, eWhichY
, SC_SIZE_NONE
);
1798 //UNUSED2008-05 SCCOL ScViewData::LastCellsX( ScHSplitPos eWhichX ) const
1800 //UNUSED2008-05 return CellsAtX( MAXCOL+1, -1, eWhichX, SC_SIZE_NONE );
1803 //UNUSED2008-05 SCROW ScViewData::LastCellsY( ScVSplitPos eWhichY ) const
1805 //UNUSED2008-05 return CellsAtY( MAXROW+1, -1, eWhichY, SC_SIZE_NONE );
1808 BOOL
ScViewData::GetMergeSizePixel( SCCOL nX
, SCROW nY
, long& rSizeXPix
, long& rSizeYPix
)
1810 const ScMergeAttr
* pMerge
= (const ScMergeAttr
*) pDoc
->GetAttr( nX
,nY
,nTabNo
, ATTR_MERGE
);
1811 if ( pMerge
->GetColMerge() > 1 || pMerge
->GetRowMerge() > 1 )
1814 long nOutHeight
= 0;
1815 SCCOL nCountX
= pMerge
->GetColMerge();
1816 for (SCCOL i
=0; i
<nCountX
; i
++)
1817 nOutWidth
+= ToPixel( pDoc
->GetColWidth(nX
+i
,nTabNo
), nPPTX
);
1818 SCROW nCountY
= pMerge
->GetRowMerge();
1820 for (SCROW nRow
= nY
; nRow
<= nY
+nCountY
-1; ++nRow
)
1822 SCROW nLastRow
= nRow
;
1823 if (pDoc
->RowHidden(nRow
, nTabNo
, NULL
, &nLastRow
))
1829 USHORT nHeight
= pDoc
->GetRowHeight(nRow
, nTabNo
);
1830 nOutHeight
+= ToPixel(nHeight
, nPPTY
);
1833 rSizeXPix
= nOutWidth
;
1834 rSizeYPix
= nOutHeight
;
1839 rSizeXPix
= ToPixel( pDoc
->GetColWidth( nX
, nTabNo
), nPPTX
);
1840 rSizeYPix
= ToPixel( pDoc
->GetRowHeight( nY
, nTabNo
), nPPTY
);
1845 BOOL
ScViewData::GetPosFromPixel( long nClickX
, long nClickY
, ScSplitPos eWhich
,
1846 SCsCOL
& rPosX
, SCsROW
& rPosY
,
1847 BOOL bTestMerge
, BOOL bRepair
, BOOL bNextIfLarge
)
1849 // special handling of 0 is now in ScViewFunctionSet::SetCursorAtPoint
1851 ScHSplitPos eHWhich
= WhichH(eWhich
);
1852 ScVSplitPos eVWhich
= WhichV(eWhich
);
1854 if ( pDoc
->IsLayoutRTL( nTabNo
) )
1856 // mirror horizontal position
1858 aScrSize
.Width() = pView
->GetGridWidth(eHWhich
);
1859 nClickX
= aScrSize
.Width() - 1 - nClickX
;
1862 SCsCOL nStartPosX
= GetPosX(eHWhich
);
1863 SCsROW nStartPosY
= GetPosY(eVWhich
);
1871 while ( rPosX
<=MAXCOL
&& nClickX
>= nScrX
)
1873 nScrX
+= ToPixel( pDoc
->GetColWidth( rPosX
, nTabNo
), nPPTX
);
1880 while ( rPosX
>0 && nClickX
< nScrX
)
1883 nScrX
-= ToPixel( pDoc
->GetColWidth( rPosX
, nTabNo
), nPPTX
);
1889 while ( rPosY
<=MAXROW
&& nClickY
>= nScrY
)
1891 nScrY
+= ToPixel( pDoc
->FastGetRowHeight( rPosY
, nTabNo
), nPPTY
);
1898 while ( rPosY
>0 && nClickY
< nScrY
)
1901 nScrY
-= ToPixel( pDoc
->FastGetRowHeight( rPosY
, nTabNo
), nPPTY
);
1905 if (bNextIfLarge
) // zu grosse Zellen ?
1907 if ( rPosX
== nStartPosX
&& nClickX
> 0 )
1910 aScrSize
.Width() = pView
->GetGridWidth(eHWhich
);
1911 if ( nClickX
> aScrSize
.Width() )
1914 if ( rPosY
== nStartPosY
&& nClickY
> 0 )
1917 aScrSize
.Height() = pView
->GetGridHeight(eVWhich
);
1918 if ( nClickY
> aScrSize
.Height() )
1923 if (rPosX
<0) rPosX
=0;
1924 if (rPosX
>MAXCOL
) rPosX
=MAXCOL
;
1925 if (rPosY
<0) rPosY
=0;
1926 if (rPosY
>MAXROW
) rPosY
=MAXROW
;
1930 //! public Methode um Position anzupassen
1932 SCCOL nOrigX
= rPosX
;
1933 SCROW nOrigY
= rPosY
;
1934 pDoc
->SkipOverlapped(rPosX
, rPosY
, nTabNo
);
1935 bool bHOver
= (nOrigX
!= rPosX
);
1936 bool bVOver
= (nOrigY
!= rPosY
);
1938 if ( bRepair
&& ( bHOver
|| bVOver
) )
1940 const ScMergeAttr
* pMerge
= (const ScMergeAttr
*)
1941 pDoc
->GetAttr( rPosX
, rPosY
, nTabNo
, ATTR_MERGE
);
1942 if ( ( bHOver
&& pMerge
->GetColMerge() <= 1 ) ||
1943 ( bVOver
&& pMerge
->GetRowMerge() <= 1 ) )
1945 DBG_ERROR("Merge-Fehler gefunden");
1947 pDoc
->RemoveFlagsTab( 0,0, MAXCOL
,MAXROW
, nTabNo
, SC_MF_HOR
| SC_MF_VER
);
1948 SCCOL nEndCol
= MAXCOL
;
1949 SCROW nEndRow
= MAXROW
;
1950 pDoc
->ExtendMerge( 0,0, nEndCol
,nEndRow
, nTabNo
, TRUE
, FALSE
);
1952 pDocShell
->PostPaint( ScRange(0,0,nTabNo
,MAXCOL
,MAXROW
,nTabNo
), PAINT_GRID
);
1960 void ScViewData::GetMouseQuadrant( const Point
& rClickPos
, ScSplitPos eWhich
,
1961 SCsCOL nPosX
, SCsROW nPosY
, BOOL
& rLeft
, BOOL
& rTop
)
1963 BOOL bLayoutRTL
= pDoc
->IsLayoutRTL( nTabNo
);
1964 long nLayoutSign
= bLayoutRTL
? -1 : 1;
1966 Point aCellStart
= GetScrPos( nPosX
, nPosY
, eWhich
, TRUE
);
1969 GetMergeSizePixel( nPosX
, nPosY
, nSizeX
, nSizeY
);
1970 rLeft
= ( rClickPos
.X() - aCellStart
.X() ) * nLayoutSign
<= nSizeX
/ 2;
1971 rTop
= rClickPos
.Y() - aCellStart
.Y() <= nSizeY
/ 2;
1974 void ScViewData::SetPosX( ScHSplitPos eWhich
, SCCOL nNewPosX
)
1978 SCCOL nOldPosX
= pThisTab
->nPosX
[eWhich
];
1979 long nTPosX
= pThisTab
->nTPosX
[eWhich
];
1980 long nPixPosX
= pThisTab
->nPixPosX
[eWhich
];
1982 if ( nNewPosX
> nOldPosX
)
1983 for ( i
=nOldPosX
; i
<nNewPosX
; i
++ )
1985 long nThis
= pDoc
->GetColWidth( i
,nTabNo
);
1987 nPixPosX
-= ToPixel(sal::static_int_cast
<USHORT
>(nThis
), nPPTX
);
1990 for ( i
=nNewPosX
; i
<nOldPosX
; i
++ )
1992 long nThis
= pDoc
->GetColWidth( i
,nTabNo
);
1994 nPixPosX
+= ToPixel(sal::static_int_cast
<USHORT
>(nThis
), nPPTX
);
1997 pThisTab
->nPosX
[eWhich
] = nNewPosX
;
1998 pThisTab
->nTPosX
[eWhich
] = nTPosX
;
1999 pThisTab
->nMPosX
[eWhich
] = (long) (nTPosX
* HMM_PER_TWIPS
);
2000 pThisTab
->nPixPosX
[eWhich
] = nPixPosX
;
2003 pThisTab
->nPixPosX
[eWhich
] =
2004 pThisTab
->nTPosX
[eWhich
] =
2005 pThisTab
->nMPosX
[eWhich
] =
2006 pThisTab
->nPosX
[eWhich
] = 0;
2009 void ScViewData::SetPosY( ScVSplitPos eWhich
, SCROW nNewPosY
)
2013 SCROW nOldPosY
= pThisTab
->nPosY
[eWhich
];
2014 long nTPosY
= pThisTab
->nTPosY
[eWhich
];
2015 long nPixPosY
= pThisTab
->nPixPosY
[eWhich
];
2017 if ( nNewPosY
> nOldPosY
)
2018 for ( i
=nOldPosY
; i
<nNewPosY
; i
++ )
2020 long nThis
= pDoc
->FastGetRowHeight( i
,nTabNo
);
2022 nPixPosY
-= ToPixel(sal::static_int_cast
<USHORT
>(nThis
), nPPTY
);
2025 for ( i
=nNewPosY
; i
<nOldPosY
; i
++ )
2027 long nThis
= pDoc
->FastGetRowHeight( i
,nTabNo
);
2029 nPixPosY
+= ToPixel(sal::static_int_cast
<USHORT
>(nThis
), nPPTY
);
2032 pThisTab
->nPosY
[eWhich
] = nNewPosY
;
2033 pThisTab
->nTPosY
[eWhich
] = nTPosY
;
2034 pThisTab
->nMPosY
[eWhich
] = (long) (nTPosY
* HMM_PER_TWIPS
);
2035 pThisTab
->nPixPosY
[eWhich
] = nPixPosY
;
2038 pThisTab
->nPixPosY
[eWhich
] =
2039 pThisTab
->nTPosY
[eWhich
] =
2040 pThisTab
->nMPosY
[eWhich
] =
2041 pThisTab
->nPosY
[eWhich
] = 0;
2044 void ScViewData::RecalcPixPos() // nach Zoom-Aenderungen
2046 for (USHORT eWhich
=0; eWhich
<2; eWhich
++)
2049 SCCOL nPosX
= pThisTab
->nPosX
[eWhich
];
2050 for (SCCOL i
=0; i
<nPosX
; i
++)
2051 nPixPosX
-= ToPixel(pDoc
->GetColWidth(i
,nTabNo
), nPPTX
);
2052 pThisTab
->nPixPosX
[eWhich
] = nPixPosX
;
2055 SCROW nPosY
= pThisTab
->nPosY
[eWhich
];
2056 for (SCROW j
=0; j
<nPosY
; j
++)
2057 nPixPosY
-= ToPixel(pDoc
->FastGetRowHeight(j
,nTabNo
), nPPTY
);
2058 pThisTab
->nPixPosY
[eWhich
] = nPixPosY
;
2062 const MapMode
& ScViewData::GetLogicMode( ScSplitPos eWhich
)
2064 aLogicMode
.SetOrigin( Point( pThisTab
->nMPosX
[WhichH(eWhich
)],
2065 pThisTab
->nMPosY
[WhichV(eWhich
)] ) );
2069 const MapMode
& ScViewData::GetLogicMode()
2071 aLogicMode
.SetOrigin( Point() );
2075 void ScViewData::SetScreen( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
)
2084 SetActivePart( SC_SPLIT_BOTTOMLEFT
);
2085 SetPosX( SC_SPLIT_LEFT
, nCol1
);
2086 SetPosY( SC_SPLIT_BOTTOM
, nRow1
);
2088 for (nCol
=nCol1
; nCol
<=nCol2
; nCol
++)
2090 nTSize
= pDoc
->GetColWidth( nCol
, nTabNo
);
2093 nSizePix
= ToPixel( nTSize
, nPPTX
);
2094 nScrPosX
+= (USHORT
) nSizePix
;
2098 for (nRow
=nRow1
; nRow
<=nRow2
; nRow
++)
2100 nTSize
= pDoc
->FastGetRowHeight( nRow
, nTabNo
);
2103 nSizePix
= ToPixel( nTSize
, nPPTY
);
2104 nScrPosY
+= (USHORT
) nSizePix
;
2108 aScrSize
= Size( nScrPosX
, nScrPosY
);
2111 void ScViewData::SetScreenPos( const Point
& rVisAreaStart
)
2119 nTwips
= (long) (rVisAreaStart
.X() / HMM_PER_TWIPS
);
2120 if ( pDoc
->IsLayoutRTL( nTabNo
) )
2126 nAdd
= (long) pDoc
->GetColWidth(nX1
,nTabNo
);
2127 if (nSize
+nAdd
<= nTwips
+1 && nX1
<MAXCOL
)
2137 nTwips
= (long) (rVisAreaStart
.Y() / HMM_PER_TWIPS
);
2142 nAdd
= (long) pDoc
->FastGetRowHeight(nY1
,nTabNo
);
2143 if (nSize
+nAdd
<= nTwips
+1 && nY1
<MAXROW
)
2152 SetActivePart( SC_SPLIT_BOTTOMLEFT
);
2153 SetPosX( SC_SPLIT_LEFT
, nX1
);
2154 SetPosY( SC_SPLIT_BOTTOM
, nY1
);
2160 void ScViewData::SetScreen( const Rectangle
& rVisArea
)
2162 SetScreenPos( rVisArea
.TopLeft() );
2164 // hier ohne GetOutputFactor(), weil fuer Ausgabe in Metafile
2166 aScrSize
= rVisArea
.GetSize();
2167 aScrSize
.Width() = (long)
2168 ( aScrSize
.Width() * ScGlobal::nScreenPPTX
/ HMM_PER_TWIPS
);
2169 aScrSize
.Height() = (long)
2170 ( aScrSize
.Height() * ScGlobal::nScreenPPTY
/ HMM_PER_TWIPS
);
2173 SfxObjectShell
* ScViewData::GetSfxDocShell() const
2178 SfxBindings
& ScViewData::GetBindings()
2180 DBG_ASSERT( pViewShell
, "GetBindings() without ViewShell" );
2181 return pViewShell
->GetViewFrame()->GetBindings();
2184 SfxDispatcher
& ScViewData::GetDispatcher()
2186 DBG_ASSERT( pViewShell
, "GetDispatcher() without ViewShell" );
2187 return *pViewShell
->GetViewFrame()->GetDispatcher();
2190 Window
* ScViewData::GetDialogParent()
2192 DBG_ASSERT( pViewShell
, "GetDialogParent() ohne ViewShell" );
2193 return pViewShell
->GetDialogParent();
2196 Window
* ScViewData::GetActiveWin()
2198 DBG_ASSERT( pView
, "GetActiveWin() ohne View" );
2199 return pView
->GetActiveWin();
2202 ScDrawView
* ScViewData::GetScDrawView()
2204 DBG_ASSERT( pView
, "GetScDrawView() ohne View" );
2205 return pView
->GetScDrawView();
2208 BOOL
ScViewData::IsMinimized()
2210 DBG_ASSERT( pView
, "IsMinimized() ohne View" );
2211 return pView
->IsMinimized();
2214 void ScViewData::UpdateScreenZoom( const Fraction
& rNewX
, const Fraction
& rNewY
)
2216 Fraction aOldX
= GetZoomX();
2217 Fraction aOldY
= GetZoomY();
2219 SetZoom( rNewX
, rNewY
, FALSE
);
2221 Fraction aWidth
= GetZoomX();
2222 aWidth
*= Fraction( aScrSize
.Width(),1 );
2225 Fraction aHeight
= GetZoomY();
2226 aHeight
*= Fraction( aScrSize
.Height(),1 );
2229 aScrSize
.Width() = (long) aWidth
;
2230 aScrSize
.Height() = (long) aHeight
;
2233 void ScViewData::CalcPPT()
2235 nPPTX
= ScGlobal::nScreenPPTX
* (double) GetZoomX();
2237 nPPTX
= nPPTX
/ pDocShell
->GetOutputFactor(); // Faktor ist Drucker zu Bildschirm
2238 nPPTY
= ScGlobal::nScreenPPTY
* (double) GetZoomY();
2240 // #83616# if detective objects are present,
2241 // try to adjust horizontal scale so the most common column width has minimal rounding errors,
2242 // to avoid differences between cell and drawing layer output
2244 if ( pDoc
&& pDoc
->HasDetectiveObjects(nTabNo
) )
2248 pDoc
->GetTableArea( nTabNo
, nEndCol
, nDummy
);
2250 nEndCol
= 20; // same end position as when determining draw scale
2252 USHORT nTwips
= pDoc
->GetCommonWidth( nEndCol
, nTabNo
);
2255 double fOriginal
= nTwips
* nPPTX
;
2256 if ( fOriginal
< static_cast<double>(nEndCol
) )
2258 // if one column is smaller than the column count,
2259 // rounding errors are likely to add up to a whole column.
2261 double fRounded
= ::rtl::math::approxFloor( fOriginal
+ 0.5 );
2262 if ( fRounded
> 0.0 )
2264 double fScale
= fRounded
/ fOriginal
+ 1E-6;
2265 if ( fScale
>= 0.9 && fScale
<= 1.1 )
2273 //------------------------------------------------------------------
2275 #define SC_OLD_TABSEP '/'
2276 #define SC_NEW_TABSEP '+'
2278 void ScViewData::WriteUserData(String
& rData
)
2280 // nZoom (bis 364v) oder nZoom/nPageZoom/bPageMode (ab 364w)
2282 // Tab-ControlBreite
2284 // CursorX/CursorY/HSplitMode/VSplitMode/HSplitPos/VSplitPos/SplitActive/
2285 // PosX[links]/PosX[rechts]/PosY[oben]/PosY[unten]
2286 // wenn Zeilen groesser 8192, "+" statt "/"
2288 USHORT nZoom
= (USHORT
)((pThisTab
->aZoomY
.GetNumerator() * 100) / pThisTab
->aZoomY
.GetDenominator());
2289 rData
= String::CreateFromInt32( nZoom
);
2291 nZoom
= (USHORT
)((pThisTab
->aPageZoomY
.GetNumerator() * 100) / pThisTab
->aPageZoomY
.GetDenominator());
2292 rData
+= String::CreateFromInt32( nZoom
);
2300 rData
+= String::CreateFromInt32( nTabNo
);
2302 rData
.AppendAscii(RTL_CONSTASCII_STRINGPARAM( TAG_TABBARWIDTH
));
2303 rData
+= String::CreateFromInt32( pView
->GetTabBarWidth() );
2305 SCTAB nTabCount
= pDoc
->GetTableCount();
2306 for (SCTAB i
=0; i
<nTabCount
; i
++)
2308 rData
+= ';'; // Numerierung darf auf keinen Fall durcheinanderkommen
2311 sal_Unicode cTabSep
= SC_OLD_TABSEP
; // wie 3.1
2312 if ( pTabData
[i
]->nCurY
> MAXROW_30
||
2313 pTabData
[i
]->nPosY
[0] > MAXROW_30
|| pTabData
[i
]->nPosY
[1] > MAXROW_30
||
2314 ( pTabData
[i
]->eVSplitMode
== SC_SPLIT_FIX
&&
2315 pTabData
[i
]->nFixPosY
> MAXROW_30
) )
2317 cTabSep
= SC_NEW_TABSEP
; // um eine 3.1-Version nicht umzubringen
2321 rData
+= String::CreateFromInt32( pTabData
[i
]->nCurX
);
2323 rData
+= String::CreateFromInt32( pTabData
[i
]->nCurY
);
2325 rData
+= String::CreateFromInt32( pTabData
[i
]->eHSplitMode
);
2327 rData
+= String::CreateFromInt32( pTabData
[i
]->eVSplitMode
);
2329 if ( pTabData
[i
]->eHSplitMode
== SC_SPLIT_FIX
)
2330 rData
+= String::CreateFromInt32( pTabData
[i
]->nFixPosX
);
2332 rData
+= String::CreateFromInt32( pTabData
[i
]->nHSplitPos
);
2334 if ( pTabData
[i
]->eVSplitMode
== SC_SPLIT_FIX
)
2335 rData
+= String::CreateFromInt32( pTabData
[i
]->nFixPosY
);
2337 rData
+= String::CreateFromInt32( pTabData
[i
]->nVSplitPos
);
2339 rData
+= String::CreateFromInt32( pTabData
[i
]->eWhichActive
);
2341 rData
+= String::CreateFromInt32( pTabData
[i
]->nPosX
[0] );
2343 rData
+= String::CreateFromInt32( pTabData
[i
]->nPosX
[1] );
2345 rData
+= String::CreateFromInt32( pTabData
[i
]->nPosY
[0] );
2347 rData
+= String::CreateFromInt32( pTabData
[i
]->nPosY
[1] );
2352 void ScViewData::ReadUserData(const String
& rData
)
2354 if (!rData
.Len()) // Leerer String kommt bei "neu Laden"
2355 return; // dann auch ohne Assertion beenden
2357 xub_StrLen nCount
= rData
.GetTokenCount(';');
2360 // #45208# beim Reload in der Seitenansicht sind evtl. die Preview-UserData
2361 // stehengelassen worden. Den Zoom von der Preview will man hier nicht...
2362 DBG_ERROR("ReadUserData: das sind nicht meine Daten");
2367 xub_StrLen nTagLen
= String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(TAG_TABBARWIDTH
)).Len();
2369 //-------------------
2370 // nicht pro Tabelle:
2371 //-------------------
2372 SCTAB nTabStart
= 2;
2374 Fraction aZoomX
, aZoomY
, aPageZoomX
, aPageZoomY
; //! evaluate (all sheets?)
2376 String aZoomStr
= rData
.GetToken(0); // Zoom/PageZoom/Modus
2377 USHORT nNormZoom
= sal::static_int_cast
<USHORT
>(aZoomStr
.GetToken(0,'/').ToInt32());
2378 if ( nNormZoom
>= MINZOOM
&& nNormZoom
<= MAXZOOM
)
2379 aZoomX
= aZoomY
= Fraction( nNormZoom
, 100 ); // "normaler" Zoom (immer)
2380 USHORT nPageZoom
= sal::static_int_cast
<USHORT
>(aZoomStr
.GetToken(1,'/').ToInt32());
2381 if ( nPageZoom
>= MINZOOM
&& nPageZoom
<= MAXZOOM
)
2382 aPageZoomX
= aPageZoomY
= Fraction( nPageZoom
, 100 ); // Pagebreak-Zoom, wenn gesetzt
2383 sal_Unicode cMode
= aZoomStr
.GetToken(2,'/').GetChar(0); // 0 oder "0"/"1"
2384 SetPagebreakMode( cMode
== '1' );
2385 // SetPagebreakMode muss immer gerufen werden wegen CalcPPT / RecalcPixPos()
2388 // Tabelle kann ungueltig geworden sein (z.B. letzte Version):
2390 SCTAB nNewTab
= static_cast<SCTAB
>(rData
.GetToken(1).ToInt32());
2391 if (pDoc
->HasTable( nNewTab
))
2395 // wenn vorhanden, TabBar-Breite holen:
2397 aTabOpt
= rData
.GetToken(2);
2399 if ( nTagLen
&& aTabOpt
.Copy(0,nTagLen
).EqualsAscii(TAG_TABBARWIDTH
) )
2401 pView
->SetTabBarWidth( aTabOpt
.Copy(nTagLen
).ToInt32() );
2409 while ( nCount
> nPos
+nTabStart
)
2411 aTabOpt
= rData
.GetToken(static_cast<xub_StrLen
>(nPos
+nTabStart
));
2412 if (!pTabData
[nPos
])
2413 pTabData
[nPos
] = new ScViewDataTable
;
2415 sal_Unicode cTabSep
= 0;
2416 if (aTabOpt
.GetTokenCount(SC_OLD_TABSEP
) >= 11)
2417 cTabSep
= SC_OLD_TABSEP
;
2418 #ifndef SC_LIMIT_ROWS
2419 else if (aTabOpt
.GetTokenCount(SC_NEW_TABSEP
) >= 11)
2420 cTabSep
= SC_NEW_TABSEP
;
2421 // '+' ist nur erlaubt, wenn wir mit Zeilen > 8192 umgehen koennen
2426 pTabData
[nPos
]->nCurX
= SanitizeCol( static_cast<SCCOL
>(aTabOpt
.GetToken(0,cTabSep
).ToInt32()));
2427 pTabData
[nPos
]->nCurY
= SanitizeRow( aTabOpt
.GetToken(1,cTabSep
).ToInt32());
2428 pTabData
[nPos
]->eHSplitMode
= (ScSplitMode
) aTabOpt
.GetToken(2,cTabSep
).ToInt32();
2429 pTabData
[nPos
]->eVSplitMode
= (ScSplitMode
) aTabOpt
.GetToken(3,cTabSep
).ToInt32();
2431 if ( pTabData
[nPos
]->eHSplitMode
== SC_SPLIT_FIX
)
2433 pTabData
[nPos
]->nFixPosX
= SanitizeCol( static_cast<SCCOL
>(aTabOpt
.GetToken(4,cTabSep
).ToInt32()));
2437 pTabData
[nPos
]->nHSplitPos
= aTabOpt
.GetToken(4,cTabSep
).ToInt32();
2439 if ( pTabData
[nPos
]->eVSplitMode
== SC_SPLIT_FIX
)
2441 pTabData
[nPos
]->nFixPosY
= SanitizeRow( aTabOpt
.GetToken(5,cTabSep
).ToInt32());
2445 pTabData
[nPos
]->nVSplitPos
= aTabOpt
.GetToken(5,cTabSep
).ToInt32();
2447 pTabData
[nPos
]->eWhichActive
= (ScSplitPos
) aTabOpt
.GetToken(6,cTabSep
).ToInt32();
2448 pTabData
[nPos
]->nPosX
[0] = SanitizeCol( static_cast<SCCOL
>(aTabOpt
.GetToken(7,cTabSep
).ToInt32()));
2449 pTabData
[nPos
]->nPosX
[1] = SanitizeCol( static_cast<SCCOL
>(aTabOpt
.GetToken(8,cTabSep
).ToInt32()));
2450 pTabData
[nPos
]->nPosY
[0] = SanitizeRow( aTabOpt
.GetToken(9,cTabSep
).ToInt32());
2451 pTabData
[nPos
]->nPosY
[1] = SanitizeRow( aTabOpt
.GetToken(10,cTabSep
).ToInt32());
2453 // Test, ob der aktive Teil laut SplitMode ueberhaupt existiert
2455 ScSplitPos eTest
= pTabData
[nPos
]->eWhichActive
;
2456 if ( ( WhichH( eTest
) == SC_SPLIT_RIGHT
&&
2457 pTabData
[nPos
]->eHSplitMode
== SC_SPLIT_NONE
) ||
2458 ( WhichV( eTest
) == SC_SPLIT_TOP
&&
2459 pTabData
[nPos
]->eVSplitMode
== SC_SPLIT_NONE
) )
2461 // dann wieder auf Default (unten links)
2462 pTabData
[nPos
]->eWhichActive
= SC_SPLIT_BOTTOMLEFT
;
2463 DBG_ERROR("SplitPos musste korrigiert werden");
2472 void ScViewData::WriteExtOptions( ScExtDocOptions
& rDocOpt
) const
2474 // *** Fill extended document data for export filters ***
2476 // document settings
2477 ScExtDocSettings
& rDocSett
= rDocOpt
.GetDocSettings();
2480 rDocSett
.mnDisplTab
= GetTabNo();
2482 // width of the tabbar, relative to frame window width
2483 rDocSett
.mfTabBarWidth
= pView
->GetPendingRelTabBarWidth();
2484 if( rDocSett
.mfTabBarWidth
< 0.0 )
2485 rDocSett
.mfTabBarWidth
= pView
->GetRelTabBarWidth();
2488 for( SCTAB nTab
= 0, nTabCount
= pDoc
->GetTableCount(); nTab
< nTabCount
; ++nTab
)
2490 if( const ScViewDataTable
* pViewTab
= pTabData
[ nTab
] )
2492 ScExtTabSettings
& rTabSett
= rDocOpt
.GetOrCreateTabSettings( nTab
);
2495 ScSplitMode eHSplit
= pViewTab
->eHSplitMode
;
2496 ScSplitMode eVSplit
= pViewTab
->eVSplitMode
;
2497 bool bHSplit
= eHSplit
!= SC_SPLIT_NONE
;
2498 bool bVSplit
= eVSplit
!= SC_SPLIT_NONE
;
2499 bool bRealSplit
= (eHSplit
== SC_SPLIT_NORMAL
) || (eVSplit
== SC_SPLIT_NORMAL
);
2500 bool bFrozen
= (eHSplit
== SC_SPLIT_FIX
) || (eVSplit
== SC_SPLIT_FIX
);
2501 DBG_ASSERT( !bRealSplit
|| !bFrozen
, "ScViewData::WriteExtOptions - split and freeze in same sheet" );
2502 rTabSett
.mbFrozenPanes
= !bRealSplit
&& bFrozen
;
2504 // split and freeze position
2505 rTabSett
.maSplitPos
= Point( 0, 0 );
2506 rTabSett
.maFreezePos
.Set( 0, 0, nTab
);
2509 Point
& rSplitPos
= rTabSett
.maSplitPos
;
2510 rSplitPos
= Point( bHSplit
? pViewTab
->nHSplitPos
: 0, bVSplit
? pViewTab
->nVSplitPos
: 0 );
2511 rSplitPos
= Application::GetDefaultDevice()->PixelToLogic( rSplitPos
, MapMode( MAP_TWIP
) );
2513 rSplitPos
.X() = (long)((double)rSplitPos
.X() / pDocShell
->GetOutputFactor());
2517 if( bHSplit
) rTabSett
.maFreezePos
.SetCol( pViewTab
->nFixPosX
);
2518 if( bVSplit
) rTabSett
.maFreezePos
.SetRow( pViewTab
->nFixPosY
);
2521 // first visible cell in top-left and additional panes
2522 rTabSett
.maFirstVis
.Set( pViewTab
->nPosX
[ SC_SPLIT_LEFT
], pViewTab
->nPosY
[ bVSplit
? SC_SPLIT_TOP
: SC_SPLIT_BOTTOM
], nTab
);
2523 rTabSett
.maSecondVis
.Set( pViewTab
->nPosX
[ SC_SPLIT_RIGHT
], pViewTab
->nPosY
[ SC_SPLIT_BOTTOM
], nTab
);
2526 switch( pViewTab
->eWhichActive
)
2528 // no horizontal split -> always use left panes
2529 // no vertical split -> always use top panes
2530 case SC_SPLIT_TOPLEFT
:
2531 rTabSett
.meActivePane
= SCEXT_PANE_TOPLEFT
;
2533 case SC_SPLIT_TOPRIGHT
:
2534 rTabSett
.meActivePane
= bHSplit
? SCEXT_PANE_TOPRIGHT
: SCEXT_PANE_TOPLEFT
;
2536 case SC_SPLIT_BOTTOMLEFT
:
2537 rTabSett
.meActivePane
= bVSplit
? SCEXT_PANE_BOTTOMLEFT
: SCEXT_PANE_TOPLEFT
;
2539 case SC_SPLIT_BOTTOMRIGHT
:
2540 rTabSett
.meActivePane
= bHSplit
?
2541 (bVSplit
? SCEXT_PANE_BOTTOMRIGHT
: SCEXT_PANE_TOPRIGHT
) :
2542 (bVSplit
? SCEXT_PANE_BOTTOMLEFT
: SCEXT_PANE_TOPLEFT
);
2547 rTabSett
.maCursor
.Set( pViewTab
->nCurX
, pViewTab
->nCurY
, nTab
);
2549 // sheet selection and selected ranges
2550 const ScMarkData
& rMarkData
= GetMarkData();
2551 rTabSett
.mbSelected
= rMarkData
.GetTableSelect( nTab
);
2552 rMarkData
.FillRangeListWithMarks( &rTabSett
.maSelection
, TRUE
);
2555 rTabSett
.maGridColor
.SetColor( COL_AUTO
);
2558 const Color
& rGridColor
= pOptions
->GetGridColor();
2559 if( rGridColor
.GetColor() != SC_STD_GRIDCOLOR
)
2560 rTabSett
.maGridColor
= rGridColor
;
2562 rTabSett
.mbShowGrid
= pViewTab
->bShowGrid
;
2564 // view mode and zoom
2565 rTabSett
.mbPageMode
= bPagebreak
;
2566 rTabSett
.mnNormalZoom
= static_cast< long >( pViewTab
->aZoomY
* Fraction( 100.0 ) );
2567 rTabSett
.mnPageZoom
= static_cast< long >( pViewTab
->aPageZoomY
* Fraction( 100.0 ) );
2570 rTabSett
.maTabBgColor
= pViewTab
->aTabBgColor
;
2575 void ScViewData::ReadExtOptions( const ScExtDocOptions
& rDocOpt
)
2577 // *** Get extended document data from import filters ***
2579 if( !rDocOpt
.IsChanged() ) return;
2581 // document settings
2582 const ScExtDocSettings
& rDocSett
= rDocOpt
.GetDocSettings();
2585 SetTabNo( rDocSett
.mnDisplTab
);
2587 /* Width of the tabbar, relative to frame window width. We do not have the
2588 correct width of the frame window here -> store in ScTabView, which sets
2589 the size in the next resize. */
2590 pView
->SetPendingRelTabBarWidth( rDocSett
.mfTabBarWidth
);
2593 for( SCTAB nTab
= 0, nTabCount
= pDoc
->GetTableCount(); nTab
< nTabCount
; ++nTab
)
2595 if( const ScExtTabSettings
* pTabSett
= rDocOpt
.GetTabSettings( nTab
) )
2597 if( !pTabData
[ nTab
] )
2598 pTabData
[ nTab
] = new ScViewDataTable
;
2600 const ScExtTabSettings
& rTabSett
= *pTabSett
;
2601 ScViewDataTable
& rViewTab
= *pTabData
[ nTab
];
2603 // split mode initialization
2604 bool bFrozen
= rTabSett
.mbFrozenPanes
;
2605 bool bHSplit
= bFrozen
? (rTabSett
.maFreezePos
.Col() > 0) : (rTabSett
.maSplitPos
.X() > 0);
2606 bool bVSplit
= bFrozen
? (rTabSett
.maFreezePos
.Row() > 0) : (rTabSett
.maSplitPos
.Y() > 0);
2608 // first visible cell of top-left pane and additional panes
2609 rViewTab
.nPosX
[ SC_SPLIT_LEFT
] = rTabSett
.maFirstVis
.Col();
2610 rViewTab
.nPosY
[ bVSplit
? SC_SPLIT_TOP
: SC_SPLIT_BOTTOM
] = rTabSett
.maFirstVis
.Row();
2611 if( bHSplit
) rViewTab
.nPosX
[ SC_SPLIT_RIGHT
] = rTabSett
.maSecondVis
.Col();
2612 if( bVSplit
) rViewTab
.nPosY
[ SC_SPLIT_BOTTOM
] = rTabSett
.maSecondVis
.Row();
2614 // split mode, split and freeze position
2615 rViewTab
.eHSplitMode
= rViewTab
.eVSplitMode
= SC_SPLIT_NONE
;
2616 rViewTab
.nHSplitPos
= rViewTab
.nVSplitPos
= 0;
2617 rViewTab
.nFixPosX
= 0;
2618 rViewTab
.nFixPosY
= 0;
2623 rViewTab
.eHSplitMode
= SC_SPLIT_FIX
;
2624 rViewTab
.nFixPosX
= rTabSett
.maFreezePos
.Col();
2629 rViewTab
.eVSplitMode
= SC_SPLIT_FIX
;
2630 rViewTab
.nFixPosY
= rTabSett
.maFreezePos
.Row();
2636 Point aPixel
= Application::GetDefaultDevice()->LogicToPixel(
2637 rTabSett
.maSplitPos
, MapMode( MAP_TWIP
) ); //! Zoom?
2638 // #109648# - the test for use of printer metrics for text formatting here
2639 // effectively results in the nFactor = 1.0 regardless of the Option setting.
2640 if( pDocShell
&& SC_MOD()->GetInputOptions().GetTextWysiwyg())
2642 double nFactor
= pDocShell
->GetOutputFactor();
2643 aPixel
.X() = (long)( aPixel
.X() * nFactor
+ 0.5 );
2647 rViewTab
.eHSplitMode
= SC_SPLIT_NORMAL
;
2648 rViewTab
.nHSplitPos
= aPixel
.X();
2652 rViewTab
.eVSplitMode
= SC_SPLIT_NORMAL
;
2653 rViewTab
.nVSplitPos
= aPixel
.Y();
2658 ScSplitPos ePos
= SC_SPLIT_BOTTOMLEFT
;
2659 switch( rTabSett
.meActivePane
)
2661 // no horizontal split -> always use left panes
2662 // no vertical split -> always use *bottom* panes
2663 case SCEXT_PANE_TOPLEFT
:
2664 ePos
= bVSplit
? SC_SPLIT_TOPLEFT
: SC_SPLIT_BOTTOMLEFT
;
2666 case SCEXT_PANE_TOPRIGHT
:
2668 (bVSplit
? SC_SPLIT_TOPRIGHT
: SC_SPLIT_BOTTOMRIGHT
) :
2669 (bVSplit
? SC_SPLIT_TOPLEFT
: SC_SPLIT_BOTTOMLEFT
);
2671 case SCEXT_PANE_BOTTOMLEFT
:
2672 ePos
= SC_SPLIT_BOTTOMLEFT
;
2674 case SCEXT_PANE_BOTTOMRIGHT
:
2675 ePos
= bHSplit
? SC_SPLIT_BOTTOMRIGHT
: SC_SPLIT_BOTTOMLEFT
;
2678 rViewTab
.eWhichActive
= ePos
;
2681 const ScAddress
& rCursor
= rTabSett
.maCursor
;
2682 if( rCursor
.IsValid() )
2684 rViewTab
.nCurX
= rCursor
.Col();
2685 rViewTab
.nCurY
= rCursor
.Row();
2688 // sheet selection and selected ranges
2689 ScMarkData
& rMarkData
= GetMarkData();
2690 rMarkData
.SelectTable( nTab
, rTabSett
.mbSelected
);
2692 // zoom for each sheet
2693 if( rTabSett
.mnNormalZoom
)
2694 rViewTab
.aZoomX
= rViewTab
.aZoomY
= Fraction( rTabSett
.mnNormalZoom
, 100L );
2695 if( rTabSett
.mnPageZoom
)
2696 rViewTab
.aPageZoomX
= rViewTab
.aPageZoomY
= Fraction( rTabSett
.mnPageZoom
, 100L );
2698 rViewTab
.bShowGrid
= rTabSett
.mbShowGrid
;
2700 // get some settings from displayed Excel sheet, set at Calc document
2701 if( nTab
== GetTabNo() )
2703 // selection only for displayed sheet, do not select single cell
2704 // Disabled, does not work correctly. Anyway, our own XML filters do not import a selection at all.
2705 // const ScRangeList& rSel = rTabSett.maSelection;
2706 // if( (rSel.Count() >= 2) || ((rSel.Count() == 1) && (*rSel.GetObject( 0 ) != ScRange( rCursor ))) )
2707 // rMarkData.MarkFromRangeList( rTabSett.maSelection, FALSE );
2709 // grid color -- #i47435# set automatic grid color explicitly
2712 Color
aGridColor( rTabSett
.maGridColor
);
2713 if( aGridColor
.GetColor() == COL_AUTO
)
2714 aGridColor
.SetColor( SC_STD_GRIDCOLOR
);
2715 pOptions
->SetGridColor( aGridColor
, EMPTY_STRING
);
2718 // view mode and default zoom (for new sheets) from current sheet
2719 if( rTabSett
.mnNormalZoom
)
2720 aDefZoomX
= aDefZoomY
= Fraction( rTabSett
.mnNormalZoom
, 100L );
2721 if( rTabSett
.mnPageZoom
)
2722 aDefPageZoomX
= aDefPageZoomY
= Fraction( rTabSett
.mnPageZoom
, 100L );
2723 /* #i46820# set pagebreak mode via SetPagebreakMode(), this will
2724 update map modes that are needed to draw text correctly. */
2725 SetPagebreakMode( rTabSett
.mbPageMode
);
2729 if( !rTabSett
.IsDefaultTabBgColor() )
2730 rViewTab
.aTabBgColor
= rTabSett
.maTabBgColor
;
2734 // RecalcPixPos oder so - auch nMPos - auch bei ReadUserData ??!?!
2737 void ScViewData::WriteUserDataSequence(uno::Sequence
<beans::PropertyValue
>& rSettings
)
2739 rSettings
.realloc(SC_VIEWSETTINGS_COUNT
);
2740 // + 1, because we have to put the view id in the sequence
2741 beans::PropertyValue
* pSettings
= rSettings
.getArray();
2744 sal_uInt16
nViewID(pViewShell
->GetViewFrame()->GetCurViewId());
2745 pSettings
[SC_VIEW_ID
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VIEWID
));
2746 rtl::OUStringBuffer
sBuffer(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VIEW
)));
2747 SvXMLUnitConverter::convertNumber(sBuffer
, static_cast<sal_Int32
>(nViewID
));
2748 pSettings
[SC_VIEW_ID
].Value
<<= sBuffer
.makeStringAndClear();
2750 SCTAB
nTabCount (pDoc
->GetTableCount());
2751 uno::Reference
<lang::XMultiServiceFactory
> xServiceFactory
=
2752 comphelper::getProcessServiceFactory();
2753 DBG_ASSERT( xServiceFactory
.is(), "got no service manager" );
2754 if( xServiceFactory
.is() )
2756 rtl::OUString
sName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.NamedPropertyValues"));
2757 uno::Reference
<container::XNameContainer
> xNameContainer
= uno::Reference
<container::XNameContainer
>(xServiceFactory
->createInstance(sName
), uno::UNO_QUERY
);
2758 if (xNameContainer
.is())
2760 for (SCTAB nTab
=0; nTab
<nTabCount
; nTab
++)
2764 uno::Sequence
<beans::PropertyValue
> aTableViewSettings
;
2765 pTabData
[nTab
]->WriteUserDataSequence(aTableViewSettings
, *this, nTab
);
2767 GetDocument()->GetName( nTab
, sTabName
);
2768 rtl::OUString
sOUName(sTabName
);
2770 aAny
<<= aTableViewSettings
;
2773 xNameContainer
->insertByName(sTabName
, aAny
);
2775 //#101739#; two tables with the same name are possible
2776 catch ( container::ElementExistException
& )
2778 DBG_ERRORFILE("seems there are two tables with the same name");
2780 catch ( uno::RuntimeException
& )
2782 DBG_ERRORFILE("something went wrong");
2786 pSettings
[SC_TABLE_VIEWSETTINGS
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_TABLES
));
2787 pSettings
[SC_TABLE_VIEWSETTINGS
].Value
<<= xNameContainer
;
2792 GetDocument()->GetName( nTabNo
, sName
);
2793 rtl::OUString
sOUName(sName
);
2794 pSettings
[SC_ACTIVE_TABLE
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ACTIVETABLE
));
2795 pSettings
[SC_ACTIVE_TABLE
].Value
<<= sOUName
;
2796 pSettings
[SC_HORIZONTAL_SCROLL_BAR_WIDTH
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_HORIZONTALSCROLLBARWIDTH
));
2797 pSettings
[SC_HORIZONTAL_SCROLL_BAR_WIDTH
].Value
<<= sal_Int32(pView
->GetTabBarWidth());
2798 sal_Int32
nZoomValue ((pThisTab
->aZoomY
.GetNumerator() * 100) / pThisTab
->aZoomY
.GetDenominator());
2799 sal_Int32
nPageZoomValue ((pThisTab
->aPageZoomY
.GetNumerator() * 100) / pThisTab
->aPageZoomY
.GetDenominator());
2800 pSettings
[SC_ZOOM_TYPE
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ZOOMTYPE
));
2801 pSettings
[SC_ZOOM_TYPE
].Value
<<= sal_Int16(pThisTab
->eZoomType
);
2802 pSettings
[SC_ZOOM_VALUE
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ZOOMVALUE
));
2803 pSettings
[SC_ZOOM_VALUE
].Value
<<= nZoomValue
;
2804 pSettings
[SC_PAGE_VIEW_ZOOM_VALUE
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_PAGEVIEWZOOMVALUE
));
2805 pSettings
[SC_PAGE_VIEW_ZOOM_VALUE
].Value
<<= nPageZoomValue
;
2806 pSettings
[SC_PAGE_BREAK_PREVIEW
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_SHOWPAGEBREAKPREVIEW
));
2807 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_PAGE_BREAK_PREVIEW
].Value
, bPagebreak
);
2811 pSettings
[SC_SHOWZERO
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWZERO
));
2812 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_SHOWZERO
].Value
, pOptions
->GetOption( VOPT_NULLVALS
) );
2813 pSettings
[SC_SHOWNOTES
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWNOTES
));
2814 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_SHOWNOTES
].Value
, pOptions
->GetOption( VOPT_NOTES
) );
2815 pSettings
[SC_SHOWGRID
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWGRID
));
2816 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_SHOWGRID
].Value
, pOptions
->GetOption( VOPT_GRID
) );
2817 pSettings
[SC_GRIDCOLOR
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_GRIDCOLOR
));
2819 Color aColor
= pOptions
->GetGridColor(&aColorName
);
2820 pSettings
[SC_GRIDCOLOR
].Value
<<= static_cast<sal_Int64
>(aColor
.GetColor());
2821 pSettings
[SC_SHOWPAGEBR
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWPAGEBR
));
2822 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_SHOWPAGEBR
].Value
, pOptions
->GetOption( VOPT_PAGEBREAKS
) );
2823 pSettings
[SC_COLROWHDR
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_COLROWHDR
));
2824 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_COLROWHDR
].Value
, pOptions
->GetOption( VOPT_HEADER
) );
2825 pSettings
[SC_SHEETTABS
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHEETTABS
));
2826 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_SHEETTABS
].Value
, pOptions
->GetOption( VOPT_TABCONTROLS
) );
2827 pSettings
[SC_OUTLSYMB
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_OUTLSYMB
));
2828 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_OUTLSYMB
].Value
, pOptions
->GetOption( VOPT_OUTLINER
) );
2830 const ScGridOptions
& aGridOpt
= pOptions
->GetGridOptions();
2831 pSettings
[SC_SNAPTORASTER
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SNAPTORASTER
));
2832 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_SNAPTORASTER
].Value
, aGridOpt
.GetUseGridSnap() );
2833 pSettings
[SC_RASTERVIS
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERVIS
));
2834 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_RASTERVIS
].Value
, aGridOpt
.GetGridVisible() );
2835 pSettings
[SC_RASTERRESX
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERRESX
));
2836 pSettings
[SC_RASTERRESX
].Value
<<= static_cast<sal_Int32
> ( aGridOpt
.GetFldDrawX() );
2837 pSettings
[SC_RASTERRESY
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERRESY
));
2838 pSettings
[SC_RASTERRESY
].Value
<<= static_cast<sal_Int32
> ( aGridOpt
.GetFldDrawY() );
2839 pSettings
[SC_RASTERSUBX
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERSUBX
));
2840 pSettings
[SC_RASTERSUBX
].Value
<<= static_cast<sal_Int32
> ( aGridOpt
.GetFldDivisionX() );
2841 pSettings
[SC_RASTERSUBY
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERSUBY
));
2842 pSettings
[SC_RASTERSUBY
].Value
<<= static_cast<sal_Int32
> ( aGridOpt
.GetFldDivisionY() );
2843 pSettings
[SC_RASTERSYNC
].Name
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERSYNC
));
2844 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_RASTERSYNC
].Value
, aGridOpt
.GetSynchronize() );
2849 void ScViewData::ReadUserDataSequence(const uno::Sequence
<beans::PropertyValue
>& rSettings
)
2851 Fraction aZoomX
, aZoomY
, aPageZoomX
, aPageZoomY
; //! evaluate (all sheets?)
2853 std::vector
<bool> aHasZoomVect( GetDocument()->GetTableCount(), false );
2855 sal_Int32
nCount(rSettings
.getLength());
2856 sal_Int32
nTemp32(0);
2857 sal_Int16
nTemp16(0);
2858 sal_Bool
bPageMode(sal_False
);
2859 for (sal_Int32 i
= 0; i
< nCount
; i
++)
2861 // SC_VIEWID has to parse and use by mba
2862 rtl::OUString
sName(rSettings
[i
].Name
);
2863 if (sName
.compareToAscii(SC_TABLES
) == 0)
2865 uno::Reference
<container::XNameContainer
> xNameContainer
;
2866 if ((rSettings
[i
].Value
>>= xNameContainer
) && xNameContainer
->hasElements())
2868 uno::Sequence
< rtl::OUString
> aNames(xNameContainer
->getElementNames());
2869 for (sal_Int32 nTabPos
= 0; nTabPos
< aNames
.getLength(); nTabPos
++)
2871 String
sTabName(aNames
[nTabPos
]);
2873 if (GetDocument()->GetTable(sTabName
, nTab
))
2875 uno::Any aAny
= xNameContainer
->getByName(aNames
[nTabPos
]);
2876 uno::Sequence
<beans::PropertyValue
> aTabSettings
;
2877 if (aAny
>>= aTabSettings
)
2879 pTabData
[nTab
] = new ScViewDataTable
;
2880 bool bHasZoom
= false;
2881 pTabData
[nTab
]->ReadUserDataSequence(aTabSettings
, *this, nTab
, bHasZoom
);
2882 aHasZoomVect
[nTab
] = bHasZoom
;
2888 else if (sName
.compareToAscii(SC_ACTIVETABLE
) == 0)
2890 rtl::OUString sValue
;
2891 if(rSettings
[i
].Value
>>= sValue
)
2893 String
sTabName(sValue
);
2895 if (GetDocument()->GetTable(sTabName
, nTab
))
2899 else if (sName
.compareToAscii(SC_HORIZONTALSCROLLBARWIDTH
) == 0)
2901 if (rSettings
[i
].Value
>>= nTemp32
)
2902 pView
->SetTabBarWidth(nTemp32
);
2904 else if (sName
.compareToAscii(SC_RELHORIZONTALTABBARWIDTH
) == 0)
2906 double fWidth
= 0.0;
2907 if (rSettings
[i
].Value
>>= fWidth
)
2908 pView
->SetPendingRelTabBarWidth( fWidth
);
2910 else if (sName
.compareToAscii(SC_ZOOMTYPE
) == 0)
2912 if (rSettings
[i
].Value
>>= nTemp16
)
2913 eDefZoomType
= SvxZoomType(nTemp16
);
2915 else if (sName
.compareToAscii(SC_ZOOMVALUE
) == 0)
2917 if (rSettings
[i
].Value
>>= nTemp32
)
2919 Fraction
aZoom(nTemp32
, 100);
2920 aDefZoomX
= aDefZoomY
= aZoom
;
2923 else if (sName
.compareToAscii(SC_PAGEVIEWZOOMVALUE
) == 0)
2925 if (rSettings
[i
].Value
>>= nTemp32
)
2927 Fraction
aZoom(nTemp32
, 100);
2928 aDefPageZoomX
= aDefPageZoomY
= aZoom
;
2931 else if (sName
.compareToAscii(SC_SHOWPAGEBREAKPREVIEW
) == 0)
2932 bPageMode
= ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
);
2933 else if ( sName
.compareToAscii( SC_UNO_SHOWZERO
) == 0 )
2934 pOptions
->SetOption(VOPT_NULLVALS
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2935 else if ( sName
.compareToAscii( SC_UNO_SHOWNOTES
) == 0 )
2936 pOptions
->SetOption(VOPT_NOTES
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2937 else if ( sName
.compareToAscii( SC_UNO_SHOWGRID
) == 0 )
2938 pOptions
->SetOption(VOPT_GRID
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2939 else if ( sName
.compareToAscii( SC_UNO_GRIDCOLOR
) == 0 )
2941 sal_Int64 nColor
= 0;
2942 if (rSettings
[i
].Value
>>= nColor
)
2945 Color
aColor(static_cast<sal_uInt32
>(nColor
));
2946 // #i47435# set automatic grid color explicitly
2947 if( aColor
.GetColor() == COL_AUTO
)
2948 aColor
.SetColor( SC_STD_GRIDCOLOR
);
2949 pOptions
->SetGridColor(aColor
, aColorName
);
2952 else if ( sName
.compareToAscii( SC_UNO_SHOWPAGEBR
) == 0 )
2953 pOptions
->SetOption(VOPT_PAGEBREAKS
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2954 else if ( sName
.compareToAscii( SC_UNO_COLROWHDR
) == 0 )
2955 pOptions
->SetOption(VOPT_HEADER
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2956 else if ( sName
.compareToAscii( SC_UNO_SHEETTABS
) == 0 )
2957 pOptions
->SetOption(VOPT_TABCONTROLS
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2958 else if ( sName
.compareToAscii( SC_UNO_OUTLSYMB
) == 0 )
2959 pOptions
->SetOption(VOPT_OUTLINER
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2960 else if ( sName
.compareToAscii( SC_UNO_SHOWOBJ
) == 0 )
2962 // #i80528# placeholders not supported anymore
2963 if ( rSettings
[i
].Value
>>= nTemp16
)
2964 pOptions
->SetObjMode( VOBJ_TYPE_OLE
, (nTemp16
== 1) ? VOBJ_MODE_HIDE
: VOBJ_MODE_SHOW
);
2966 else if ( sName
.compareToAscii( SC_UNO_SHOWCHARTS
) == 0 )
2968 // #i80528# placeholders not supported anymore
2969 if ( rSettings
[i
].Value
>>= nTemp16
)
2970 pOptions
->SetObjMode( VOBJ_TYPE_CHART
, (nTemp16
== 1) ? VOBJ_MODE_HIDE
: VOBJ_MODE_SHOW
);
2972 else if ( sName
.compareToAscii( SC_UNO_SHOWDRAW
) == 0 )
2974 // #i80528# placeholders not supported anymore
2975 if ( rSettings
[i
].Value
>>= nTemp16
)
2976 pOptions
->SetObjMode( VOBJ_TYPE_DRAW
, (nTemp16
== 1) ? VOBJ_MODE_HIDE
: VOBJ_MODE_SHOW
);
2980 ScGridOptions
aGridOpt(pOptions
->GetGridOptions());
2981 if ( sName
.compareToAscii( SC_UNO_SNAPTORASTER
) == 0 )
2982 aGridOpt
.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2983 else if ( sName
.compareToAscii( SC_UNO_RASTERVIS
) == 0 )
2984 aGridOpt
.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2985 else if ( sName
.compareToAscii( SC_UNO_RASTERRESX
) == 0 )
2986 aGridOpt
.SetFldDrawX( static_cast <sal_uInt32
> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings
[i
].Value
) ) );
2987 else if ( sName
.compareToAscii( SC_UNO_RASTERRESY
) == 0 )
2988 aGridOpt
.SetFldDrawY( static_cast <sal_uInt32
> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings
[i
].Value
) ) );
2989 else if ( sName
.compareToAscii( SC_UNO_RASTERSUBX
) == 0 )
2990 aGridOpt
.SetFldDivisionX( static_cast <sal_uInt32
> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings
[i
].Value
) ) );
2991 else if ( sName
.compareToAscii( SC_UNO_RASTERSUBY
) == 0 )
2992 aGridOpt
.SetFldDivisionY( static_cast <sal_uInt32
> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings
[i
].Value
) ) );
2993 else if ( sName
.compareToAscii( SC_UNO_RASTERSYNC
) == 0 )
2994 aGridOpt
.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2995 pOptions
->SetGridOptions(aGridOpt
);
2999 // copy default zoom to sheets where a different one wasn't specified
3000 for (SCTAB nZoomTab
=0; nZoomTab
<=MAXTAB
; ++nZoomTab
)
3001 if (pTabData
[nZoomTab
] && ( nZoomTab
>= static_cast<SCTAB
>(aHasZoomVect
.size()) || !aHasZoomVect
[nZoomTab
] ))
3003 pTabData
[nZoomTab
]->eZoomType
= eDefZoomType
;
3004 pTabData
[nZoomTab
]->aZoomX
= aDefZoomX
;
3005 pTabData
[nZoomTab
]->aZoomY
= aDefZoomY
;
3006 pTabData
[nZoomTab
]->aPageZoomX
= aDefPageZoomX
;
3007 pTabData
[nZoomTab
]->aPageZoomY
= aDefPageZoomY
;
3011 SetPagebreakMode( bPageMode
);
3013 // #i47426# write view options to document, needed e.g. for Excel export
3014 pDoc
->SetViewOptions( *pOptions
);
3017 void ScViewData::SetOptions( const ScViewOptions
& rOpt
)
3019 // if visibility of horiz. ScrollBar is changed, TabBar may have to be resized...
3020 BOOL bHScrollChanged
= ( rOpt
.GetOption(VOPT_HSCROLL
) != pOptions
->GetOption(VOPT_HSCROLL
) );
3022 // if graphics are turned on or off, animation has to be started or stopped
3023 // graphics are controlled by VOBJ_TYPE_OLE
3024 BOOL bGraphicsChanged
= ( pOptions
->GetObjMode(VOBJ_TYPE_OLE
) !=
3025 rOpt
.GetObjMode(VOBJ_TYPE_OLE
) );
3028 DBG_ASSERT( pView
, "No View" );
3032 pView
->ViewOptionsHasChanged( bHScrollChanged
, bGraphicsChanged
);
3036 Point
ScViewData::GetMousePosPixel()
3038 DBG_ASSERT( pView
, "GetMousePosPixel() ohne View" );
3039 return pView
->GetMousePosPixel();
3042 void ScViewData::UpdateInputHandler( BOOL bForce
, BOOL bStopEditing
)
3045 pViewShell
->UpdateInputHandler( bForce
, bStopEditing
);
3048 BOOL
ScViewData::IsOle()
3050 return pDocShell
&& pDocShell
->IsOle();
3053 BOOL
ScViewData::UpdateFixX( SCTAB nTab
) // TRUE = Wert geaendert
3055 if (!ValidTab(nTab
)) // Default
3056 nTab
=nTabNo
; // akuelle Tabelle
3058 if (!pView
|| pTabData
[nTab
]->eHSplitMode
!= SC_SPLIT_FIX
)
3061 ScDocument
* pLocalDoc
= GetDocument();
3062 if (!pLocalDoc
->HasTable(nTab
)) // #114007# if called from reload, the sheet may not exist
3065 SCCOL nFix
= pTabData
[nTab
]->nFixPosX
;
3067 for (SCCOL nX
=pTabData
[nTab
]->nPosX
[SC_SPLIT_LEFT
]; nX
<nFix
; nX
++)
3069 USHORT nTSize
= pLocalDoc
->GetColWidth( nX
, nTab
);
3072 long nPix
= ToPixel( nTSize
, nPPTX
);
3076 nNewPos
+= pView
->GetGridOffset().X();
3077 if (nNewPos
!= pTabData
[nTab
]->nHSplitPos
)
3079 pTabData
[nTab
]->nHSplitPos
= nNewPos
;
3081 RecalcPixPos(); //! sollte nicht noetig sein !!!
3088 BOOL
ScViewData::UpdateFixY( SCTAB nTab
) // TRUE = Wert geaendert
3090 if (!ValidTab(nTab
)) // Default
3091 nTab
=nTabNo
; // akuelle Tabelle
3093 if (!pView
|| pTabData
[nTab
]->eVSplitMode
!= SC_SPLIT_FIX
)
3096 ScDocument
* pLocalDoc
= GetDocument();
3097 if (!pLocalDoc
->HasTable(nTab
)) // #114007# if called from reload, the sheet may not exist
3100 SCROW nFix
= pTabData
[nTab
]->nFixPosY
;
3102 for (SCROW nY
=pTabData
[nTab
]->nPosY
[SC_SPLIT_TOP
]; nY
<nFix
; nY
++)
3104 USHORT nTSize
= pLocalDoc
->FastGetRowHeight( nY
, nTab
);
3107 long nPix
= ToPixel( nTSize
, nPPTY
);
3111 nNewPos
+= pView
->GetGridOffset().Y();
3112 if (nNewPos
!= pTabData
[nTab
]->nVSplitPos
)
3114 pTabData
[nTab
]->nVSplitPos
= nNewPos
;
3116 RecalcPixPos(); //! sollte nicht noetig sein !!!
3123 void ScViewData::UpdateOutlinerFlags( Outliner
& rOutl
) const
3125 ScDocument
* pLocalDoc
= GetDocument();
3126 BOOL bOnlineSpell
= pLocalDoc
->GetDocOptions().IsAutoSpell();
3128 ULONG nCntrl
= rOutl
.GetControlWord();
3129 nCntrl
|= EE_CNTRL_URLSFXEXECUTE
;
3130 nCntrl
|= EE_CNTRL_MARKFIELDS
;
3131 nCntrl
|= EE_CNTRL_AUTOCORRECT
;
3133 nCntrl
|= EE_CNTRL_ONLINESPELLING
;
3135 nCntrl
&= ~EE_CNTRL_ONLINESPELLING
;
3136 rOutl
.SetControlWord(nCntrl
);
3138 rOutl
.SetCalcFieldValueHdl( LINK( SC_MOD(), ScModule
, CalcFieldValueHdl
) );
3140 // #97417# don't call GetSpellChecker if online spelling isn't enabled.
3141 // The language for AutoCorrect etc. is taken from the pool defaults
3142 // (set in ScDocument::UpdateDrawLanguages)
3146 com::sun::star::uno::Reference
<com::sun::star::linguistic2::XSpellChecker1
> xXSpellChecker1( LinguMgr::GetSpellChecker() );
3147 rOutl
.SetSpeller( xXSpellChecker1
);
3150 rOutl
.SetDefaultHorizontalTextDirection(
3151 (EEHorizontalTextDirection
)pLocalDoc
->GetEditTextDirection( nTabNo
) );
3154 ScAddress
ScViewData::GetCurPos() const
3156 return ScAddress( GetCurX(), GetCurY(), GetTabNo() );